@cortex-agent/server 2026.8.3-2 → 2026.8.6
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/defaults/config/thread-templates/agents/benchmark-coder.json +2 -2
- package/defaults/config/thread-templates/agents/benchmark-fixer.json +17 -0
- package/defaults/config/thread-templates/agents/benchmark-reviewer.json +5 -5
- package/defaults/config/thread-templates/templates/benchmark-coder-review-fix.json +21 -0
- package/defaults/plugins/cortex-system/skills/thread/SKILL.md +1 -0
- package/defaults/prompts/directives/benchmark-coder.md +1 -0
- package/defaults/prompts/directives/benchmark-fixer.md +1 -0
- package/defaults/prompts/directives/benchmark-reviewer.md +1 -0
- package/defaults/prompts/systemPrompts/benchmark-coder.md +1 -0
- package/defaults/prompts/systemPrompts/benchmark-fixer.md +1 -0
- package/defaults/prompts/systemPrompts/benchmark-reviewer.md +1 -0
- package/dist/agent-adapter/capabilities.d.ts +32 -1
- package/dist/agent-adapter/capabilities.js +39 -1
- package/dist/agent-adapter/claude/adapter.d.ts +15 -0
- package/dist/agent-adapter/claude/adapter.js +29 -7
- package/dist/agent-adapter/claude/spawn-args.d.ts +5 -2
- package/dist/agent-adapter/claude/spawn-args.js +29 -6
- package/dist/agent-adapter/index.js +11 -1
- package/dist/agent-adapter/normalize/tool-names.d.ts +4 -0
- package/dist/agent-adapter/normalize/tool-names.js +10 -0
- package/dist/agent-adapter/pi/adapter.d.ts +20 -8
- package/dist/agent-adapter/pi/adapter.js +130 -35
- package/dist/agent-adapter/pi/agent-dir.d.ts +20 -53
- package/dist/agent-adapter/pi/agent-dir.js +48 -89
- package/dist/agent-adapter/pi/custom-catalog.d.ts +10 -0
- package/dist/agent-adapter/pi/custom-catalog.js +42 -0
- package/dist/agent-adapter/pi/defaults.d.ts +9 -0
- package/dist/agent-adapter/pi/defaults.js +14 -4
- package/dist/agent-adapter/pi/discovery.d.ts +1 -3
- package/dist/agent-adapter/pi/discovery.js +3 -15
- package/dist/agent-adapter/pi/event-parser.js +8 -0
- package/dist/agent-adapter/pi/mcp-bridge.d.ts +13 -0
- package/dist/agent-adapter/pi/mcp-bridge.js +31 -6
- package/dist/agent-adapter/pi/mcp-duration.d.ts +28 -0
- package/dist/agent-adapter/pi/mcp-duration.js +48 -0
- package/dist/agent-adapter/pi/policy-guard.d.ts +40 -0
- package/dist/agent-adapter/pi/policy-guard.js +111 -0
- package/dist/agent-adapter/pi/providers-config.d.ts +62 -0
- package/dist/agent-adapter/pi/providers-config.js +101 -0
- package/dist/agent-adapter/pi/quota-probe.d.ts +11 -0
- package/dist/agent-adapter/pi/quota-probe.js +36 -0
- package/dist/agent-adapter/pi/quota-sink.d.ts +25 -0
- package/dist/agent-adapter/pi/quota-sink.js +31 -0
- package/dist/agent-adapter/pi/session-files.d.ts +2 -0
- package/dist/agent-adapter/pi/session-files.js +19 -0
- package/dist/agent-adapter/pi/session-support.d.ts +14 -3
- package/dist/agent-adapter/pi/session-support.js +8 -0
- package/dist/agent-adapter/pi/spawn-args.d.ts +11 -1
- package/dist/agent-adapter/pi/spawn-args.js +13 -0
- package/dist/agent-adapter/pi/tool-shims.d.ts +2 -2
- package/dist/agent-adapter/pi/tool-shims.js +32 -21
- package/dist/agent-adapter/pi/web-search.js +36 -8
- package/dist/agent-adapter/types.d.ts +14 -0
- package/dist/core/locales/en.d.ts +54 -1
- package/dist/core/locales/en.js +2 -0
- package/dist/core/locales/slices/commands.d.ts +12 -1
- package/dist/core/locales/slices/commands.js +24 -2
- package/dist/core/locales/slices/providers.d.ts +45 -0
- package/dist/core/locales/slices/providers.js +95 -0
- package/dist/core/locales/zh.js +2 -0
- package/dist/core/resilient-watch.d.ts +28 -0
- package/dist/core/resilient-watch.js +110 -0
- package/dist/core/settings.js +15 -20
- package/dist/core/types/agent-types.d.ts +6 -0
- package/dist/core/types/thread-types.d.ts +21 -3
- package/dist/domain/agent-run/agent-run-cli.js +3 -1
- package/dist/domain/agent-run/benchmark-local-thread-orchestrator.d.ts +31 -0
- package/dist/domain/agent-run/benchmark-local-thread-orchestrator.js +231 -24
- package/dist/domain/agent-run/benchmark-thread-identity.d.ts +15 -2
- package/dist/domain/agent-run/benchmark-thread-identity.js +123 -34
- package/dist/domain/agent-run/identity.d.ts +5 -0
- package/dist/domain/agent-run/identity.js +4 -1
- package/dist/domain/agent-run/journal.d.ts +3 -2
- package/dist/domain/agent-run/manifest.js +11 -4
- package/dist/domain/agent-run/pinned-node-process.d.ts +4 -0
- package/dist/domain/agent-run/pinned-node-process.js +9 -0
- package/dist/domain/agent-run/role-surface.d.ts +2 -2
- package/dist/domain/agent-run/role-surface.js +7 -3
- package/dist/domain/agent-run/run-config.d.ts +10 -1
- package/dist/domain/agent-run/run-config.js +57 -6
- package/dist/domain/agent-run/runner.js +149 -31
- package/dist/domain/agents/facade.d.ts +37 -122
- package/dist/domain/agents/facade.js +47 -115
- package/dist/domain/agents/spawn-config.d.ts +135 -0
- package/dist/domain/agents/spawn-config.js +121 -0
- package/dist/domain/benchmark/accounting-reconciliation.d.ts +98 -0
- package/dist/domain/benchmark/accounting-reconciliation.js +218 -0
- package/dist/domain/benchmark/arm-schema.d.ts +43 -0
- package/dist/domain/benchmark/arm-schema.js +243 -0
- package/dist/domain/benchmark/capabilities.d.ts +4 -0
- package/dist/domain/benchmark/capabilities.js +54 -0
- package/dist/domain/benchmark/decimal-text.d.ts +27 -0
- package/dist/domain/benchmark/decimal-text.js +67 -0
- package/dist/domain/benchmark/lease-echo.d.ts +43 -0
- package/dist/domain/benchmark/lease-echo.js +56 -0
- package/dist/domain/benchmark/policy-backed-runtime-deps.d.ts +14 -0
- package/dist/domain/benchmark/policy-backed-runtime-deps.js +47 -0
- package/dist/domain/benchmark/policy-compiler.d.ts +68 -0
- package/dist/domain/benchmark/policy-compiler.js +680 -0
- package/dist/domain/benchmark/resolved-policy.d.ts +110 -0
- package/dist/domain/benchmark/resolved-policy.js +195 -0
- package/dist/domain/benchmark/trial-adapter-factory.d.ts +38 -0
- package/dist/domain/benchmark/trial-adapter-factory.js +165 -0
- package/dist/domain/benchmark/trial-thread-adapter.d.ts +25 -0
- package/dist/domain/benchmark/trial-thread-adapter.js +106 -0
- package/dist/domain/benchmark/variant-proposal.d.ts +45 -0
- package/dist/domain/benchmark/variant-proposal.js +42 -0
- package/dist/domain/benchmark/workspace-lease.d.ts +99 -0
- package/dist/domain/benchmark/workspace-lease.js +272 -0
- package/dist/domain/costs/codex-quota.d.ts +29 -0
- package/dist/domain/costs/codex-quota.js +102 -0
- package/dist/domain/costs/cost-tracker.d.ts +48 -9
- package/dist/domain/costs/cost-tracker.js +74 -18
- package/dist/domain/costs/rate-limit-throttle.d.ts +23 -1
- package/dist/domain/costs/rate-limit-throttle.js +61 -6
- package/dist/domain/costs/resume-registry.d.ts +3 -1
- package/dist/domain/costs/resume-registry.js +10 -1
- package/dist/domain/mcp/tools/benchmark-thread-run.d.ts +26 -2
- package/dist/domain/mcp/tools/benchmark-thread-run.js +63 -20
- package/dist/domain/mcp/tools/cost.js +15 -6
- package/dist/domain/pi-providers/custom-provider-model.d.ts +53 -0
- package/dist/domain/pi-providers/custom-provider-model.js +122 -0
- package/dist/domain/pi-providers/custom-provider-service.d.ts +59 -0
- package/dist/domain/pi-providers/custom-provider-service.js +143 -0
- package/dist/domain/pi-providers/gateway-route-store.d.ts +23 -0
- package/dist/domain/pi-providers/gateway-route-store.js +78 -0
- package/dist/domain/pi-providers/index.d.ts +4 -0
- package/dist/domain/pi-providers/index.js +8 -0
- package/dist/domain/pi-providers/models-json-store.d.ts +6 -0
- package/dist/domain/pi-providers/models-json-store.js +77 -0
- package/dist/domain/scheduling/jobs/_shared.d.ts +4 -1
- package/dist/domain/scheduling/jobs/_shared.js +11 -2
- package/dist/domain/scheduling/jobs/scheduled-task.js +1 -0
- package/dist/domain/scheduling/jobs/task-dispatch.js +49 -54
- package/dist/domain/sessions/session-lifecycle.d.ts +22 -0
- package/dist/domain/sessions/session-lifecycle.js +20 -1
- package/dist/domain/system/system-notice.d.ts +4 -1
- package/dist/domain/system/system-notice.js +6 -2
- package/dist/domain/tasks/dispatch-utils.d.ts +0 -4
- package/dist/domain/tasks/dispatch-utils.js +24 -37
- package/dist/domain/threads/runner.d.ts +16 -1
- package/dist/domain/threads/runner.js +62 -8
- package/dist/domain/threads/template-loader.d.ts +5 -0
- package/dist/domain/threads/template-loader.js +120 -36
- package/dist/domain/threads/template-validate.d.ts +244 -0
- package/dist/domain/threads/template-validate.js +574 -0
- package/dist/domain/threads/template-validate.parity.d.ts +1 -0
- package/dist/domain/threads/template-validate.parity.js +47 -0
- package/dist/domain/threads/template-writer.d.ts +55 -0
- package/dist/domain/threads/template-writer.js +131 -0
- package/dist/domain/ui-service/app-router.d.ts +143 -1
- package/dist/domain/ui-service/app-router.js +29 -3
- package/dist/domain/ui-service/input-schemas.d.ts +228 -4
- package/dist/domain/ui-service/input-schemas.js +132 -1
- package/dist/domain/ui-service/mutate/config.d.ts +10 -1
- package/dist/domain/ui-service/mutate/config.js +45 -5
- package/dist/domain/ui-service/mutate/custom-providers.d.ts +8 -0
- package/dist/domain/ui-service/mutate/custom-providers.js +37 -0
- package/dist/domain/ui-service/mutate/profiles.d.ts +21 -0
- package/dist/domain/ui-service/mutate/profiles.js +156 -0
- package/dist/domain/ui-service/mutate/schedules.d.ts +2 -1
- package/dist/domain/ui-service/mutate/schedules.js +53 -3
- package/dist/domain/ui-service/mutate/sessions.d.ts +2 -1
- package/dist/domain/ui-service/mutate/sessions.js +25 -1
- package/dist/domain/ui-service/mutate/system.d.ts +2 -1
- package/dist/domain/ui-service/mutate/system.js +17 -3
- package/dist/domain/ui-service/mutate/thread-templates.d.ts +4 -0
- package/dist/domain/ui-service/mutate/thread-templates.js +71 -0
- package/dist/domain/ui-service/query/config.js +30 -0
- package/dist/domain/ui-service/query/custom-providers.d.ts +8 -0
- package/dist/domain/ui-service/query/custom-providers.js +13 -0
- package/dist/domain/ui-service/query/machine-detail.d.ts +2 -0
- package/dist/domain/ui-service/query/machine-detail.js +56 -0
- package/dist/domain/ui-service/query/machine-probe.d.ts +18 -0
- package/dist/domain/ui-service/query/machine-probe.js +136 -0
- package/dist/domain/ui-service/query/schedules.js +5 -0
- package/dist/domain/ui-service/query/sessions.js +8 -2
- package/dist/domain/ui-service/query/thread-template-detail.d.ts +8 -0
- package/dist/domain/ui-service/query/thread-template-detail.js +94 -0
- package/dist/domain/ui-service/query/thread-templates.d.ts +5 -3
- package/dist/domain/ui-service/query/thread-templates.js +44 -7
- package/dist/domain/ui-service/types.d.ts +298 -7
- package/dist/domain/ui-service/ui-service.js +27 -3
- package/dist/entry/app.js +24 -3
- package/dist/entry/auth-cli.d.ts +4 -1
- package/dist/entry/auth-cli.js +10 -2
- package/dist/entry/cli-help.js +6 -2
- package/dist/entry/cli.js +2 -1
- package/dist/entry/daemon.d.ts +0 -11
- package/dist/entry/daemon.js +5 -49
- package/dist/entry/provider-cli.d.ts +16 -0
- package/dist/entry/provider-cli.js +203 -0
- package/dist/events/event-types.d.ts +2 -1
- package/dist/orchestration/agent-runner.js +3 -2
- package/dist/orchestration/routing/commands/cost.d.ts +8 -0
- package/dist/orchestration/routing/commands/cost.js +93 -21
- package/dist/orchestration/routing/commands/login-custom.d.ts +26 -0
- package/dist/orchestration/routing/commands/login-custom.js +89 -0
- package/dist/orchestration/routing/commands/login.d.ts +3 -0
- package/dist/orchestration/routing/commands/login.js +7 -0
- package/dist/orchestration/routing/message-router.js +48 -33
- package/dist/orchestration/routing/webhook.js +1 -1
- package/dist/orchestration/session-events.d.ts +2 -1
- package/dist/orchestration/session-events.js +1 -0
- package/dist/orchestration/thread-callback.js +1 -1
- package/dist/store/conversation-history-repo.d.ts +5 -1
- package/dist/store/conversation-history-repo.js +2 -1
- package/dist/store/cost-repo.d.ts +17 -0
- package/dist/store/cost-repo.js +47 -5
- package/dist/store/profile-repo.d.ts +0 -10
- package/dist/store/profile-repo.js +34 -56
- package/dist/store/session-registry-repo.d.ts +12 -0
- package/dist/store/session-registry-repo.js +16 -0
- package/package.json +1 -1
- package/web/dist/assets/index-DYMfaAi4.css +1 -0
- package/web/dist/assets/index-uOoZjGKa.js +141 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/index-XqBCYtkw.js +0 -139
- package/web/dist/assets/index-zpf3OSKC.css +0 -1
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
var Ey=e=>{throw TypeError(e)};var xh=(e,t,n)=>t.has(e)||Ey("Cannot "+n);var M=(e,t,n)=>(xh(e,t,"read from private field"),n?n.call(e):t.get(e)),xe=(e,t,n)=>t.has(e)?Ey("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),le=(e,t,n,r)=>(xh(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Se=(e,t,n)=>(xh(e,t,"access private method"),n);var Qd=(e,t,n,r)=>({set _(i){le(e,t,i,n)},get _(){return M(e,t,r)}});function b2(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();function j2(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var w2={exports:{}},uf={},k2={exports:{}},Pe={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var md=Symbol.for("react.element"),QE=Symbol.for("react.portal"),GE=Symbol.for("react.fragment"),YE=Symbol.for("react.strict_mode"),XE=Symbol.for("react.profiler"),JE=Symbol.for("react.provider"),ZE=Symbol.for("react.context"),eR=Symbol.for("react.forward_ref"),tR=Symbol.for("react.suspense"),nR=Symbol.for("react.memo"),rR=Symbol.for("react.lazy"),Ry=Symbol.iterator;function oR(e){return e===null||typeof e!="object"?null:(e=Ry&&e[Ry]||e["@@iterator"],typeof e=="function"?e:null)}var S2={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C2=Object.assign,T2={};function vl(e,t,n){this.props=e,this.context=t,this.refs=T2,this.updater=n||S2}vl.prototype.isReactComponent={};vl.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};vl.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function E2(){}E2.prototype=vl.prototype;function Vm(e,t,n){this.props=e,this.context=t,this.refs=T2,this.updater=n||S2}var Km=Vm.prototype=new E2;Km.constructor=Vm;C2(Km,vl.prototype);Km.isPureReactComponent=!0;var Py=Array.isArray,R2=Object.prototype.hasOwnProperty,Qm={current:null},P2={key:!0,ref:!0,__self:!0,__source:!0};function I2(e,t,n){var r,i={},s=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(s=""+t.key),t)R2.call(t,r)&&!P2.hasOwnProperty(r)&&(i[r]=t[r]);var l=arguments.length-2;if(l===1)i.children=n;else if(1<l){for(var c=Array(l),d=0;d<l;d++)c[d]=arguments[d+2];i.children=c}if(e&&e.defaultProps)for(r in l=e.defaultProps,l)i[r]===void 0&&(i[r]=l[r]);return{$$typeof:md,type:e,key:s,ref:a,props:i,_owner:Qm.current}}function iR(e,t){return{$$typeof:md,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Gm(e){return typeof e=="object"&&e!==null&&e.$$typeof===md}function sR(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Iy=/\/+/g;function mh(e,t){return typeof e=="object"&&e!==null&&e.key!=null?sR(""+e.key):t.toString(36)}function qu(e,t,n,r,i){var s=typeof e;(s==="undefined"||s==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(s){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case md:case QE:a=!0}}if(a)return a=e,i=i(a),e=r===""?"."+mh(a,0):r,Py(i)?(n="",e!=null&&(n=e.replace(Iy,"$&/")+"/"),qu(i,t,n,"",function(d){return d})):i!=null&&(Gm(i)&&(i=iR(i,n+(!i.key||a&&a.key===i.key?"":(""+i.key).replace(Iy,"$&/")+"/")+e)),t.push(i)),1;if(a=0,r=r===""?".":r+":",Py(e))for(var l=0;l<e.length;l++){s=e[l];var c=r+mh(s,l);a+=qu(s,t,n,c,i)}else if(c=oR(e),typeof c=="function")for(e=c.call(e),l=0;!(s=e.next()).done;)s=s.value,c=r+mh(s,l++),a+=qu(s,t,n,c,i);else if(s==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return a}function Gd(e,t,n){if(e==null)return e;var r=[],i=0;return qu(e,r,"","",function(s){return t.call(n,s,i++)}),r}function aR(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var pn={current:null},Vu={transition:null},lR={ReactCurrentDispatcher:pn,ReactCurrentBatchConfig:Vu,ReactCurrentOwner:Qm};function M2(){throw Error("act(...) is not supported in production builds of React.")}Pe.Children={map:Gd,forEach:function(e,t,n){Gd(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Gd(e,function(){t++}),t},toArray:function(e){return Gd(e,function(t){return t})||[]},only:function(e){if(!Gm(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Pe.Component=vl;Pe.Fragment=GE;Pe.Profiler=XE;Pe.PureComponent=Vm;Pe.StrictMode=YE;Pe.Suspense=tR;Pe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=lR;Pe.act=M2;Pe.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=C2({},e.props),i=e.key,s=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(s=t.ref,a=Qm.current),t.key!==void 0&&(i=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)R2.call(t,c)&&!P2.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&l!==void 0?l[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){l=Array(c);for(var d=0;d<c;d++)l[d]=arguments[d+2];r.children=l}return{$$typeof:md,type:e.type,key:i,ref:s,props:r,_owner:a}};Pe.createContext=function(e){return e={$$typeof:ZE,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:JE,_context:e},e.Consumer=e};Pe.createElement=I2;Pe.createFactory=function(e){var t=I2.bind(null,e);return t.type=e,t};Pe.createRef=function(){return{current:null}};Pe.forwardRef=function(e){return{$$typeof:eR,render:e}};Pe.isValidElement=Gm;Pe.lazy=function(e){return{$$typeof:rR,_payload:{_status:-1,_result:e},_init:aR}};Pe.memo=function(e,t){return{$$typeof:nR,type:e,compare:t===void 0?null:t}};Pe.startTransition=function(e){var t=Vu.transition;Vu.transition={};try{e()}finally{Vu.transition=t}};Pe.unstable_act=M2;Pe.useCallback=function(e,t){return pn.current.useCallback(e,t)};Pe.useContext=function(e){return pn.current.useContext(e)};Pe.useDebugValue=function(){};Pe.useDeferredValue=function(e){return pn.current.useDeferredValue(e)};Pe.useEffect=function(e,t){return pn.current.useEffect(e,t)};Pe.useId=function(){return pn.current.useId()};Pe.useImperativeHandle=function(e,t,n){return pn.current.useImperativeHandle(e,t,n)};Pe.useInsertionEffect=function(e,t){return pn.current.useInsertionEffect(e,t)};Pe.useLayoutEffect=function(e,t){return pn.current.useLayoutEffect(e,t)};Pe.useMemo=function(e,t){return pn.current.useMemo(e,t)};Pe.useReducer=function(e,t,n){return pn.current.useReducer(e,t,n)};Pe.useRef=function(e){return pn.current.useRef(e)};Pe.useState=function(e){return pn.current.useState(e)};Pe.useSyncExternalStore=function(e,t,n){return pn.current.useSyncExternalStore(e,t,n)};Pe.useTransition=function(){return pn.current.useTransition()};Pe.version="18.3.1";k2.exports=Pe;var f=k2.exports;const cR=j2(f),yl=b2({__proto__:null,default:cR},[f]);/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.production.min.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var dR=f,uR=Symbol.for("react.element"),pR=Symbol.for("react.fragment"),fR=Object.prototype.hasOwnProperty,hR=dR.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,gR={key:!0,ref:!0,__self:!0,__source:!0};function L2(e,t,n){var r,i={},s=null,a=null;n!==void 0&&(s=""+n),t.key!==void 0&&(s=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)fR.call(t,r)&&!gR.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)i[r]===void 0&&(i[r]=t[r]);return{$$typeof:uR,type:e,key:s,ref:a,props:i,_owner:hR.current}}uf.Fragment=pR;uf.jsx=L2;uf.jsxs=L2;w2.exports=uf;var o=w2.exports,O2={exports:{}},Bn={},D2={exports:{}},A2={};/**
|
|
18
|
+
* @license React
|
|
19
|
+
* scheduler.production.min.js
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
+
*
|
|
23
|
+
* This source code is licensed under the MIT license found in the
|
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
|
25
|
+
*/(function(e){function t(N,F){var H=N.length;N.push(F);e:for(;0<H;){var re=H-1>>>1,D=N[re];if(0<i(D,F))N[re]=F,N[H]=D,H=re;else break e}}function n(N){return N.length===0?null:N[0]}function r(N){if(N.length===0)return null;var F=N[0],H=N.pop();if(H!==F){N[0]=H;e:for(var re=0,D=N.length,Q=D>>>1;re<Q;){var ne=2*(re+1)-1,J=N[ne],te=ne+1,fe=N[te];if(0>i(J,H))te<D&&0>i(fe,J)?(N[re]=fe,N[te]=H,re=te):(N[re]=J,N[ne]=H,re=ne);else if(te<D&&0>i(fe,H))N[re]=fe,N[te]=H,re=te;else break e}}return F}function i(N,F){var H=N.sortIndex-F.sortIndex;return H!==0?H:N.id-F.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var a=Date,l=a.now();e.unstable_now=function(){return a.now()-l}}var c=[],d=[],u=1,p=null,h=3,g=!1,v=!1,x=!1,w=typeof setTimeout=="function"?setTimeout:null,b=typeof clearTimeout=="function"?clearTimeout:null,y=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function j(N){for(var F=n(d);F!==null;){if(F.callback===null)r(d);else if(F.startTime<=N)r(d),F.sortIndex=F.expirationTime,t(c,F);else break;F=n(d)}}function S(N){if(x=!1,j(N),!v)if(n(c)!==null)v=!0,V(k);else{var F=n(d);F!==null&&Z(S,F.startTime-N)}}function k(N,F){v=!1,x&&(x=!1,b(R),R=-1),g=!0;var H=h;try{for(j(F),p=n(c);p!==null&&(!(p.expirationTime>F)||N&&!_());){var re=p.callback;if(typeof re=="function"){p.callback=null,h=p.priorityLevel;var D=re(p.expirationTime<=F);F=e.unstable_now(),typeof D=="function"?p.callback=D:p===n(c)&&r(c),j(F)}else r(c);p=n(c)}if(p!==null)var Q=!0;else{var ne=n(d);ne!==null&&Z(S,ne.startTime-F),Q=!1}return Q}finally{p=null,h=H,g=!1}}var E=!1,C=null,R=-1,P=5,L=-1;function _(){return!(e.unstable_now()-L<P)}function U(){if(C!==null){var N=e.unstable_now();L=N;var F=!0;try{F=C(!0,N)}finally{F?K():(E=!1,C=null)}}else E=!1}var K;if(typeof y=="function")K=function(){y(U)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,W=$.port2;$.port1.onmessage=U,K=function(){W.postMessage(null)}}else K=function(){w(U,0)};function V(N){C=N,E||(E=!0,K())}function Z(N,F){R=w(function(){N(e.unstable_now())},F)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(N){N.callback=null},e.unstable_continueExecution=function(){v||g||(v=!0,V(k))},e.unstable_forceFrameRate=function(N){0>N||125<N?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<N?Math.floor(1e3/N):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(N){switch(h){case 1:case 2:case 3:var F=3;break;default:F=h}var H=h;h=F;try{return N()}finally{h=H}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(N,F){switch(N){case 1:case 2:case 3:case 4:case 5:break;default:N=3}var H=h;h=N;try{return F()}finally{h=H}},e.unstable_scheduleCallback=function(N,F,H){var re=e.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?re+H:re):H=re,N){case 1:var D=-1;break;case 2:D=250;break;case 5:D=1073741823;break;case 4:D=1e4;break;default:D=5e3}return D=H+D,N={id:u++,callback:F,priorityLevel:N,startTime:H,expirationTime:D,sortIndex:-1},H>re?(N.sortIndex=H,t(d,N),n(c)===null&&N===n(d)&&(x?(b(R),R=-1):x=!0,Z(S,H-re))):(N.sortIndex=D,t(c,N),v||g||(v=!0,V(k))),N},e.unstable_shouldYield=_,e.unstable_wrapCallback=function(N){var F=h;return function(){var H=h;h=F;try{return N.apply(this,arguments)}finally{h=H}}}})(A2);D2.exports=A2;var xR=D2.exports;/**
|
|
26
|
+
* @license React
|
|
27
|
+
* react-dom.production.min.js
|
|
28
|
+
*
|
|
29
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
+
*
|
|
31
|
+
* This source code is licensed under the MIT license found in the
|
|
32
|
+
* LICENSE file in the root directory of this source tree.
|
|
33
|
+
*/var mR=f,Fn=xR;function ee(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var N2=new Set,Oc={};function Ds(e,t){Xa(e,t),Xa(e+"Capture",t)}function Xa(e,t){for(Oc[e]=t,e=0;e<t.length;e++)N2.add(t[e])}var xo=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Fg=Object.prototype.hasOwnProperty,vR=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,My={},Ly={};function yR(e){return Fg.call(Ly,e)?!0:Fg.call(My,e)?!1:vR.test(e)?Ly[e]=!0:(My[e]=!0,!1)}function bR(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function jR(e,t,n,r){if(t===null||typeof t>"u"||bR(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function fn(e,t,n,r,i,s,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=a}var Qt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Qt[e]=new fn(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Qt[t]=new fn(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Qt[e]=new fn(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Qt[e]=new fn(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Qt[e]=new fn(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Qt[e]=new fn(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Qt[e]=new fn(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Qt[e]=new fn(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Qt[e]=new fn(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ym=/[\-:]([a-z])/g;function Xm(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Ym,Xm);Qt[t]=new fn(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Ym,Xm);Qt[t]=new fn(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Ym,Xm);Qt[t]=new fn(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Qt[e]=new fn(e,1,!1,e.toLowerCase(),null,!1,!1)});Qt.xlinkHref=new fn("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Qt[e]=new fn(e,1,!1,e.toLowerCase(),null,!0,!0)});function Jm(e,t,n,r){var i=Qt.hasOwnProperty(t)?Qt[t]:null;(i!==null?i.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(jR(t,n,i,r)&&(n=null),r||i===null?yR(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):i.mustUseProperty?e[i.propertyName]=n===null?i.type===3?!1:"":n:(t=i.attributeName,r=i.attributeNamespace,n===null?e.removeAttribute(t):(i=i.type,n=i===3||i===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var ko=mR.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Yd=Symbol.for("react.element"),pa=Symbol.for("react.portal"),fa=Symbol.for("react.fragment"),Zm=Symbol.for("react.strict_mode"),zg=Symbol.for("react.profiler"),$2=Symbol.for("react.provider"),_2=Symbol.for("react.context"),ev=Symbol.for("react.forward_ref"),Bg=Symbol.for("react.suspense"),Wg=Symbol.for("react.suspense_list"),tv=Symbol.for("react.memo"),Ho=Symbol.for("react.lazy"),F2=Symbol.for("react.offscreen"),Oy=Symbol.iterator;function $l(e){return e===null||typeof e!="object"?null:(e=Oy&&e[Oy]||e["@@iterator"],typeof e=="function"?e:null)}var pt=Object.assign,vh;function tc(e){if(vh===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);vh=t&&t[1]||""}return`
|
|
34
|
+
`+vh+e}var yh=!1;function bh(e,t){if(!e||yh)return"";yh=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(d){var r=d}Reflect.construct(e,[],t)}else{try{t.call()}catch(d){r=d}e.call(t.prototype)}else{try{throw Error()}catch(d){r=d}e()}}catch(d){if(d&&r&&typeof d.stack=="string"){for(var i=d.stack.split(`
|
|
35
|
+
`),s=r.stack.split(`
|
|
36
|
+
`),a=i.length-1,l=s.length-1;1<=a&&0<=l&&i[a]!==s[l];)l--;for(;1<=a&&0<=l;a--,l--)if(i[a]!==s[l]){if(a!==1||l!==1)do if(a--,l--,0>l||i[a]!==s[l]){var c=`
|
|
37
|
+
`+i[a].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=a&&0<=l);break}}}finally{yh=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?tc(e):""}function wR(e){switch(e.tag){case 5:return tc(e.type);case 16:return tc("Lazy");case 13:return tc("Suspense");case 19:return tc("SuspenseList");case 0:case 2:case 15:return e=bh(e.type,!1),e;case 11:return e=bh(e.type.render,!1),e;case 1:return e=bh(e.type,!0),e;default:return""}}function Ug(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case fa:return"Fragment";case pa:return"Portal";case zg:return"Profiler";case Zm:return"StrictMode";case Bg:return"Suspense";case Wg:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case _2:return(e.displayName||"Context")+".Consumer";case $2:return(e._context.displayName||"Context")+".Provider";case ev:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case tv:return t=e.displayName||null,t!==null?t:Ug(e.type)||"Memo";case Ho:t=e._payload,e=e._init;try{return Ug(e(t))}catch{}}return null}function kR(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ug(t);case 8:return t===Zm?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function bi(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function z2(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function SR(e){var t=z2(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(a){r=""+a,s.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Xd(e){e._valueTracker||(e._valueTracker=SR(e))}function B2(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=z2(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function mp(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Hg(e,t){var n=t.checked;return pt({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Dy(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=bi(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function W2(e,t){t=t.checked,t!=null&&Jm(e,"checked",t,!1)}function qg(e,t){W2(e,t);var n=bi(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Vg(e,t.type,n):t.hasOwnProperty("defaultValue")&&Vg(e,t.type,bi(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Ay(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Vg(e,t,n){(t!=="number"||mp(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var nc=Array.isArray;function Ea(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t["$"+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty("$"+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=""+bi(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Kg(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(ee(91));return pt({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Ny(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(ee(92));if(nc(n)){if(1<n.length)throw Error(ee(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:bi(n)}}function U2(e,t){var n=bi(t.value),r=bi(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function $y(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function H2(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Qg(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?H2(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Jd,q2=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,i)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Jd=Jd||document.createElement("div"),Jd.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Jd.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Dc(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var pc={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},CR=["Webkit","ms","Moz","O"];Object.keys(pc).forEach(function(e){CR.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),pc[t]=pc[e]})});function V2(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||pc.hasOwnProperty(e)&&pc[e]?(""+t).trim():t+"px"}function K2(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=V2(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var TR=pt({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Gg(e,t){if(t){if(TR[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(ee(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(ee(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(ee(61))}if(t.style!=null&&typeof t.style!="object")throw Error(ee(62))}}function Yg(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Xg=null;function nv(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Jg=null,Ra=null,Pa=null;function _y(e){if(e=bd(e)){if(typeof Jg!="function")throw Error(ee(280));var t=e.stateNode;t&&(t=xf(t),Jg(e.stateNode,e.type,t))}}function Q2(e){Ra?Pa?Pa.push(e):Pa=[e]:Ra=e}function G2(){if(Ra){var e=Ra,t=Pa;if(Pa=Ra=null,_y(e),t)for(e=0;e<t.length;e++)_y(t[e])}}function Y2(e,t){return e(t)}function X2(){}var jh=!1;function J2(e,t,n){if(jh)return e(t,n);jh=!0;try{return Y2(e,t,n)}finally{jh=!1,(Ra!==null||Pa!==null)&&(X2(),G2())}}function Ac(e,t){var n=e.stateNode;if(n===null)return null;var r=xf(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(ee(231,t,typeof n));return n}var Zg=!1;if(xo)try{var _l={};Object.defineProperty(_l,"passive",{get:function(){Zg=!0}}),window.addEventListener("test",_l,_l),window.removeEventListener("test",_l,_l)}catch{Zg=!1}function ER(e,t,n,r,i,s,a,l,c){var d=Array.prototype.slice.call(arguments,3);try{t.apply(n,d)}catch(u){this.onError(u)}}var fc=!1,vp=null,yp=!1,ex=null,RR={onError:function(e){fc=!0,vp=e}};function PR(e,t,n,r,i,s,a,l,c){fc=!1,vp=null,ER.apply(RR,arguments)}function IR(e,t,n,r,i,s,a,l,c){if(PR.apply(this,arguments),fc){if(fc){var d=vp;fc=!1,vp=null}else throw Error(ee(198));yp||(yp=!0,ex=d)}}function As(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function Z2(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function Fy(e){if(As(e)!==e)throw Error(ee(188))}function MR(e){var t=e.alternate;if(!t){if(t=As(e),t===null)throw Error(ee(188));return t!==e?null:e}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var s=i.alternate;if(s===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===s.child){for(s=i.child;s;){if(s===n)return Fy(i),e;if(s===r)return Fy(i),t;s=s.sibling}throw Error(ee(188))}if(n.return!==r.return)n=i,r=s;else{for(var a=!1,l=i.child;l;){if(l===n){a=!0,n=i,r=s;break}if(l===r){a=!0,r=i,n=s;break}l=l.sibling}if(!a){for(l=s.child;l;){if(l===n){a=!0,n=s,r=i;break}if(l===r){a=!0,r=s,n=i;break}l=l.sibling}if(!a)throw Error(ee(189))}}if(n.alternate!==r)throw Error(ee(190))}if(n.tag!==3)throw Error(ee(188));return n.stateNode.current===n?e:t}function ek(e){return e=MR(e),e!==null?tk(e):null}function tk(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=tk(e);if(t!==null)return t;e=e.sibling}return null}var nk=Fn.unstable_scheduleCallback,zy=Fn.unstable_cancelCallback,LR=Fn.unstable_shouldYield,OR=Fn.unstable_requestPaint,bt=Fn.unstable_now,DR=Fn.unstable_getCurrentPriorityLevel,rv=Fn.unstable_ImmediatePriority,rk=Fn.unstable_UserBlockingPriority,bp=Fn.unstable_NormalPriority,AR=Fn.unstable_LowPriority,ok=Fn.unstable_IdlePriority,pf=null,Nr=null;function NR(e){if(Nr&&typeof Nr.onCommitFiberRoot=="function")try{Nr.onCommitFiberRoot(pf,e,void 0,(e.current.flags&128)===128)}catch{}}var fr=Math.clz32?Math.clz32:FR,$R=Math.log,_R=Math.LN2;function FR(e){return e>>>=0,e===0?32:31-($R(e)/_R|0)|0}var Zd=64,eu=4194304;function rc(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function jp(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,s=e.pingedLanes,a=n&268435455;if(a!==0){var l=a&~i;l!==0?r=rc(l):(s&=a,s!==0&&(r=rc(s)))}else a=n&~i,a!==0?r=rc(a):s!==0&&(r=rc(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,s=t&-t,i>=s||i===16&&(s&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-fr(t),i=1<<n,r|=e[n],t&=~i;return r}function zR(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function BR(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,s=e.pendingLanes;0<s;){var a=31-fr(s),l=1<<a,c=i[a];c===-1?(!(l&n)||l&r)&&(i[a]=zR(l,t)):c<=t&&(e.expiredLanes|=l),s&=~l}}function tx(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function ik(){var e=Zd;return Zd<<=1,!(Zd&4194240)&&(Zd=64),e}function wh(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function vd(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-fr(t),e[t]=n}function WR(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var i=31-fr(n),s=1<<i;t[i]=0,r[i]=-1,e[i]=-1,n&=~s}}function ov(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-fr(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}var qe=0;function sk(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var ak,iv,lk,ck,dk,nx=!1,tu=[],ci=null,di=null,ui=null,Nc=new Map,$c=new Map,Ko=[],UR="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function By(e,t){switch(e){case"focusin":case"focusout":ci=null;break;case"dragenter":case"dragleave":di=null;break;case"mouseover":case"mouseout":ui=null;break;case"pointerover":case"pointerout":Nc.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":$c.delete(t.pointerId)}}function Fl(e,t,n,r,i,s){return e===null||e.nativeEvent!==s?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:s,targetContainers:[i]},t!==null&&(t=bd(t),t!==null&&iv(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function HR(e,t,n,r,i){switch(t){case"focusin":return ci=Fl(ci,e,t,n,r,i),!0;case"dragenter":return di=Fl(di,e,t,n,r,i),!0;case"mouseover":return ui=Fl(ui,e,t,n,r,i),!0;case"pointerover":var s=i.pointerId;return Nc.set(s,Fl(Nc.get(s)||null,e,t,n,r,i)),!0;case"gotpointercapture":return s=i.pointerId,$c.set(s,Fl($c.get(s)||null,e,t,n,r,i)),!0}return!1}function uk(e){var t=os(e.target);if(t!==null){var n=As(t);if(n!==null){if(t=n.tag,t===13){if(t=Z2(n),t!==null){e.blockedOn=t,dk(e.priority,function(){lk(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ku(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=rx(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Xg=r,n.target.dispatchEvent(r),Xg=null}else return t=bd(n),t!==null&&iv(t),e.blockedOn=n,!1;t.shift()}return!0}function Wy(e,t,n){Ku(e)&&n.delete(t)}function qR(){nx=!1,ci!==null&&Ku(ci)&&(ci=null),di!==null&&Ku(di)&&(di=null),ui!==null&&Ku(ui)&&(ui=null),Nc.forEach(Wy),$c.forEach(Wy)}function zl(e,t){e.blockedOn===t&&(e.blockedOn=null,nx||(nx=!0,Fn.unstable_scheduleCallback(Fn.unstable_NormalPriority,qR)))}function _c(e){function t(i){return zl(i,e)}if(0<tu.length){zl(tu[0],e);for(var n=1;n<tu.length;n++){var r=tu[n];r.blockedOn===e&&(r.blockedOn=null)}}for(ci!==null&&zl(ci,e),di!==null&&zl(di,e),ui!==null&&zl(ui,e),Nc.forEach(t),$c.forEach(t),n=0;n<Ko.length;n++)r=Ko[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Ko.length&&(n=Ko[0],n.blockedOn===null);)uk(n),n.blockedOn===null&&Ko.shift()}var Ia=ko.ReactCurrentBatchConfig,wp=!0;function VR(e,t,n,r){var i=qe,s=Ia.transition;Ia.transition=null;try{qe=1,sv(e,t,n,r)}finally{qe=i,Ia.transition=s}}function KR(e,t,n,r){var i=qe,s=Ia.transition;Ia.transition=null;try{qe=4,sv(e,t,n,r)}finally{qe=i,Ia.transition=s}}function sv(e,t,n,r){if(wp){var i=rx(e,t,n,r);if(i===null)Lh(e,t,r,kp,n),By(e,r);else if(HR(i,e,t,n,r))r.stopPropagation();else if(By(e,r),t&4&&-1<UR.indexOf(e)){for(;i!==null;){var s=bd(i);if(s!==null&&ak(s),s=rx(e,t,n,r),s===null&&Lh(e,t,r,kp,n),s===i)break;i=s}i!==null&&r.stopPropagation()}else Lh(e,t,r,null,n)}}var kp=null;function rx(e,t,n,r){if(kp=null,e=nv(r),e=os(e),e!==null)if(t=As(e),t===null)e=null;else if(n=t.tag,n===13){if(e=Z2(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return kp=e,null}function pk(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(DR()){case rv:return 1;case rk:return 4;case bp:case AR:return 16;case ok:return 536870912;default:return 16}default:return 16}}var ii=null,av=null,Qu=null;function fk(){if(Qu)return Qu;var e,t=av,n=t.length,r,i="value"in ii?ii.value:ii.textContent,s=i.length;for(e=0;e<n&&t[e]===i[e];e++);var a=n-e;for(r=1;r<=a&&t[n-r]===i[s-r];r++);return Qu=i.slice(e,1<r?1-r:void 0)}function Gu(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function nu(){return!0}function Uy(){return!1}function Wn(e){function t(n,r,i,s,a){this._reactName=n,this._targetInst=i,this.type=r,this.nativeEvent=s,this.target=a,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(s):s[l]);return this.isDefaultPrevented=(s.defaultPrevented!=null?s.defaultPrevented:s.returnValue===!1)?nu:Uy,this.isPropagationStopped=Uy,this}return pt(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=nu)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=nu)},persist:function(){},isPersistent:nu}),t}var bl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},lv=Wn(bl),yd=pt({},bl,{view:0,detail:0}),QR=Wn(yd),kh,Sh,Bl,ff=pt({},yd,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:cv,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Bl&&(Bl&&e.type==="mousemove"?(kh=e.screenX-Bl.screenX,Sh=e.screenY-Bl.screenY):Sh=kh=0,Bl=e),kh)},movementY:function(e){return"movementY"in e?e.movementY:Sh}}),Hy=Wn(ff),GR=pt({},ff,{dataTransfer:0}),YR=Wn(GR),XR=pt({},yd,{relatedTarget:0}),Ch=Wn(XR),JR=pt({},bl,{animationName:0,elapsedTime:0,pseudoElement:0}),ZR=Wn(JR),eP=pt({},bl,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),tP=Wn(eP),nP=pt({},bl,{data:0}),qy=Wn(nP),rP={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},oP={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},iP={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function sP(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=iP[e])?!!t[e]:!1}function cv(){return sP}var aP=pt({},yd,{key:function(e){if(e.key){var t=rP[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Gu(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?oP[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:cv,charCode:function(e){return e.type==="keypress"?Gu(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Gu(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),lP=Wn(aP),cP=pt({},ff,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Vy=Wn(cP),dP=pt({},yd,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:cv}),uP=Wn(dP),pP=pt({},bl,{propertyName:0,elapsedTime:0,pseudoElement:0}),fP=Wn(pP),hP=pt({},ff,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),gP=Wn(hP),xP=[9,13,27,32],dv=xo&&"CompositionEvent"in window,hc=null;xo&&"documentMode"in document&&(hc=document.documentMode);var mP=xo&&"TextEvent"in window&&!hc,hk=xo&&(!dv||hc&&8<hc&&11>=hc),Ky=" ",Qy=!1;function gk(e,t){switch(e){case"keyup":return xP.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function xk(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ha=!1;function vP(e,t){switch(e){case"compositionend":return xk(t);case"keypress":return t.which!==32?null:(Qy=!0,Ky);case"textInput":return e=t.data,e===Ky&&Qy?null:e;default:return null}}function yP(e,t){if(ha)return e==="compositionend"||!dv&&gk(e,t)?(e=fk(),Qu=av=ii=null,ha=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return hk&&t.locale!=="ko"?null:t.data;default:return null}}var bP={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Gy(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!bP[e.type]:t==="textarea"}function mk(e,t,n,r){Q2(r),t=Sp(t,"onChange"),0<t.length&&(n=new lv("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var gc=null,Fc=null;function jP(e){Rk(e,0)}function hf(e){var t=ma(e);if(B2(t))return e}function wP(e,t){if(e==="change")return t}var vk=!1;if(xo){var Th;if(xo){var Eh="oninput"in document;if(!Eh){var Yy=document.createElement("div");Yy.setAttribute("oninput","return;"),Eh=typeof Yy.oninput=="function"}Th=Eh}else Th=!1;vk=Th&&(!document.documentMode||9<document.documentMode)}function Xy(){gc&&(gc.detachEvent("onpropertychange",yk),Fc=gc=null)}function yk(e){if(e.propertyName==="value"&&hf(Fc)){var t=[];mk(t,Fc,e,nv(e)),J2(jP,t)}}function kP(e,t,n){e==="focusin"?(Xy(),gc=t,Fc=n,gc.attachEvent("onpropertychange",yk)):e==="focusout"&&Xy()}function SP(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return hf(Fc)}function CP(e,t){if(e==="click")return hf(t)}function TP(e,t){if(e==="input"||e==="change")return hf(t)}function EP(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var xr=typeof Object.is=="function"?Object.is:EP;function zc(e,t){if(xr(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Fg.call(t,i)||!xr(e[i],t[i]))return!1}return!0}function Jy(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Zy(e,t){var n=Jy(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Jy(n)}}function bk(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?bk(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function jk(){for(var e=window,t=mp();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=mp(e.document)}return t}function uv(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function RP(e){var t=jk(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&bk(n.ownerDocument.documentElement,n)){if(r!==null&&uv(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!e.extend&&s>r&&(i=r,r=s,s=i),i=Zy(n,s);var a=Zy(n,r);i&&a&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var PP=xo&&"documentMode"in document&&11>=document.documentMode,ga=null,ox=null,xc=null,ix=!1;function e1(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ix||ga==null||ga!==mp(r)||(r=ga,"selectionStart"in r&&uv(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),xc&&zc(xc,r)||(xc=r,r=Sp(ox,"onSelect"),0<r.length&&(t=new lv("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=ga)))}function ru(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var xa={animationend:ru("Animation","AnimationEnd"),animationiteration:ru("Animation","AnimationIteration"),animationstart:ru("Animation","AnimationStart"),transitionend:ru("Transition","TransitionEnd")},Rh={},wk={};xo&&(wk=document.createElement("div").style,"AnimationEvent"in window||(delete xa.animationend.animation,delete xa.animationiteration.animation,delete xa.animationstart.animation),"TransitionEvent"in window||delete xa.transitionend.transition);function gf(e){if(Rh[e])return Rh[e];if(!xa[e])return e;var t=xa[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in wk)return Rh[e]=t[n];return e}var kk=gf("animationend"),Sk=gf("animationiteration"),Ck=gf("animationstart"),Tk=gf("transitionend"),Ek=new Map,t1="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Ei(e,t){Ek.set(e,t),Ds(t,[e])}for(var Ph=0;Ph<t1.length;Ph++){var Ih=t1[Ph],IP=Ih.toLowerCase(),MP=Ih[0].toUpperCase()+Ih.slice(1);Ei(IP,"on"+MP)}Ei(kk,"onAnimationEnd");Ei(Sk,"onAnimationIteration");Ei(Ck,"onAnimationStart");Ei("dblclick","onDoubleClick");Ei("focusin","onFocus");Ei("focusout","onBlur");Ei(Tk,"onTransitionEnd");Xa("onMouseEnter",["mouseout","mouseover"]);Xa("onMouseLeave",["mouseout","mouseover"]);Xa("onPointerEnter",["pointerout","pointerover"]);Xa("onPointerLeave",["pointerout","pointerover"]);Ds("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Ds("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Ds("onBeforeInput",["compositionend","keypress","textInput","paste"]);Ds("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Ds("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Ds("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var oc="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),LP=new Set("cancel close invalid load scroll toggle".split(" ").concat(oc));function n1(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,IR(r,t,void 0,e),e.currentTarget=null}function Rk(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;e:{var s=void 0;if(t)for(var a=r.length-1;0<=a;a--){var l=r[a],c=l.instance,d=l.currentTarget;if(l=l.listener,c!==s&&i.isPropagationStopped())break e;n1(i,l,d),s=c}else for(a=0;a<r.length;a++){if(l=r[a],c=l.instance,d=l.currentTarget,l=l.listener,c!==s&&i.isPropagationStopped())break e;n1(i,l,d),s=c}}}if(yp)throw e=ex,yp=!1,ex=null,e}function Ze(e,t){var n=t[dx];n===void 0&&(n=t[dx]=new Set);var r=e+"__bubble";n.has(r)||(Pk(t,e,2,!1),n.add(r))}function Mh(e,t,n){var r=0;t&&(r|=4),Pk(n,e,r,t)}var ou="_reactListening"+Math.random().toString(36).slice(2);function Bc(e){if(!e[ou]){e[ou]=!0,N2.forEach(function(n){n!=="selectionchange"&&(LP.has(n)||Mh(n,!1,e),Mh(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[ou]||(t[ou]=!0,Mh("selectionchange",!1,t))}}function Pk(e,t,n,r){switch(pk(t)){case 1:var i=VR;break;case 4:i=KR;break;default:i=sv}n=i.bind(null,t,n,e),i=void 0,!Zg||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),r?i!==void 0?e.addEventListener(t,n,{capture:!0,passive:i}):e.addEventListener(t,n,!0):i!==void 0?e.addEventListener(t,n,{passive:i}):e.addEventListener(t,n,!1)}function Lh(e,t,n,r,i){var s=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var a=r.tag;if(a===3||a===4){var l=r.stateNode.containerInfo;if(l===i||l.nodeType===8&&l.parentNode===i)break;if(a===4)for(a=r.return;a!==null;){var c=a.tag;if((c===3||c===4)&&(c=a.stateNode.containerInfo,c===i||c.nodeType===8&&c.parentNode===i))return;a=a.return}for(;l!==null;){if(a=os(l),a===null)return;if(c=a.tag,c===5||c===6){r=s=a;continue e}l=l.parentNode}}r=r.return}J2(function(){var d=s,u=nv(n),p=[];e:{var h=Ek.get(e);if(h!==void 0){var g=lv,v=e;switch(e){case"keypress":if(Gu(n)===0)break e;case"keydown":case"keyup":g=lP;break;case"focusin":v="focus",g=Ch;break;case"focusout":v="blur",g=Ch;break;case"beforeblur":case"afterblur":g=Ch;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":g=Hy;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":g=YR;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":g=uP;break;case kk:case Sk:case Ck:g=ZR;break;case Tk:g=fP;break;case"scroll":g=QR;break;case"wheel":g=gP;break;case"copy":case"cut":case"paste":g=tP;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":g=Vy}var x=(t&4)!==0,w=!x&&e==="scroll",b=x?h!==null?h+"Capture":null:h;x=[];for(var y=d,j;y!==null;){j=y;var S=j.stateNode;if(j.tag===5&&S!==null&&(j=S,b!==null&&(S=Ac(y,b),S!=null&&x.push(Wc(y,S,j)))),w)break;y=y.return}0<x.length&&(h=new g(h,v,null,n,u),p.push({event:h,listeners:x}))}}if(!(t&7)){e:{if(h=e==="mouseover"||e==="pointerover",g=e==="mouseout"||e==="pointerout",h&&n!==Xg&&(v=n.relatedTarget||n.fromElement)&&(os(v)||v[mo]))break e;if((g||h)&&(h=u.window===u?u:(h=u.ownerDocument)?h.defaultView||h.parentWindow:window,g?(v=n.relatedTarget||n.toElement,g=d,v=v?os(v):null,v!==null&&(w=As(v),v!==w||v.tag!==5&&v.tag!==6)&&(v=null)):(g=null,v=d),g!==v)){if(x=Hy,S="onMouseLeave",b="onMouseEnter",y="mouse",(e==="pointerout"||e==="pointerover")&&(x=Vy,S="onPointerLeave",b="onPointerEnter",y="pointer"),w=g==null?h:ma(g),j=v==null?h:ma(v),h=new x(S,y+"leave",g,n,u),h.target=w,h.relatedTarget=j,S=null,os(u)===d&&(x=new x(b,y+"enter",v,n,u),x.target=j,x.relatedTarget=w,S=x),w=S,g&&v)t:{for(x=g,b=v,y=0,j=x;j;j=Bs(j))y++;for(j=0,S=b;S;S=Bs(S))j++;for(;0<y-j;)x=Bs(x),y--;for(;0<j-y;)b=Bs(b),j--;for(;y--;){if(x===b||b!==null&&x===b.alternate)break t;x=Bs(x),b=Bs(b)}x=null}else x=null;g!==null&&r1(p,h,g,x,!1),v!==null&&w!==null&&r1(p,w,v,x,!0)}}e:{if(h=d?ma(d):window,g=h.nodeName&&h.nodeName.toLowerCase(),g==="select"||g==="input"&&h.type==="file")var k=wP;else if(Gy(h))if(vk)k=TP;else{k=SP;var E=kP}else(g=h.nodeName)&&g.toLowerCase()==="input"&&(h.type==="checkbox"||h.type==="radio")&&(k=CP);if(k&&(k=k(e,d))){mk(p,k,n,u);break e}E&&E(e,h,d),e==="focusout"&&(E=h._wrapperState)&&E.controlled&&h.type==="number"&&Vg(h,"number",h.value)}switch(E=d?ma(d):window,e){case"focusin":(Gy(E)||E.contentEditable==="true")&&(ga=E,ox=d,xc=null);break;case"focusout":xc=ox=ga=null;break;case"mousedown":ix=!0;break;case"contextmenu":case"mouseup":case"dragend":ix=!1,e1(p,n,u);break;case"selectionchange":if(PP)break;case"keydown":case"keyup":e1(p,n,u)}var C;if(dv)e:{switch(e){case"compositionstart":var R="onCompositionStart";break e;case"compositionend":R="onCompositionEnd";break e;case"compositionupdate":R="onCompositionUpdate";break e}R=void 0}else ha?gk(e,n)&&(R="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(R="onCompositionStart");R&&(hk&&n.locale!=="ko"&&(ha||R!=="onCompositionStart"?R==="onCompositionEnd"&&ha&&(C=fk()):(ii=u,av="value"in ii?ii.value:ii.textContent,ha=!0)),E=Sp(d,R),0<E.length&&(R=new qy(R,e,null,n,u),p.push({event:R,listeners:E}),C?R.data=C:(C=xk(n),C!==null&&(R.data=C)))),(C=mP?vP(e,n):yP(e,n))&&(d=Sp(d,"onBeforeInput"),0<d.length&&(u=new qy("onBeforeInput","beforeinput",null,n,u),p.push({event:u,listeners:d}),u.data=C))}Rk(p,t)})}function Wc(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Sp(e,t){for(var n=t+"Capture",r=[];e!==null;){var i=e,s=i.stateNode;i.tag===5&&s!==null&&(i=s,s=Ac(e,n),s!=null&&r.unshift(Wc(e,s,i)),s=Ac(e,t),s!=null&&r.push(Wc(e,s,i))),e=e.return}return r}function Bs(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function r1(e,t,n,r,i){for(var s=t._reactName,a=[];n!==null&&n!==r;){var l=n,c=l.alternate,d=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&d!==null&&(l=d,i?(c=Ac(n,s),c!=null&&a.unshift(Wc(n,c,l))):i||(c=Ac(n,s),c!=null&&a.push(Wc(n,c,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var OP=/\r\n?/g,DP=/\u0000|\uFFFD/g;function o1(e){return(typeof e=="string"?e:""+e).replace(OP,`
|
|
38
|
+
`).replace(DP,"")}function iu(e,t,n){if(t=o1(t),o1(e)!==t&&n)throw Error(ee(425))}function Cp(){}var sx=null,ax=null;function lx(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var cx=typeof setTimeout=="function"?setTimeout:void 0,AP=typeof clearTimeout=="function"?clearTimeout:void 0,i1=typeof Promise=="function"?Promise:void 0,NP=typeof queueMicrotask=="function"?queueMicrotask:typeof i1<"u"?function(e){return i1.resolve(null).then(e).catch($P)}:cx;function $P(e){setTimeout(function(){throw e})}function Oh(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n==="/$"){if(r===0){e.removeChild(i),_c(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=i}while(n);_c(t)}function pi(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function s1(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var jl=Math.random().toString(36).slice(2),Or="__reactFiber$"+jl,Uc="__reactProps$"+jl,mo="__reactContainer$"+jl,dx="__reactEvents$"+jl,_P="__reactListeners$"+jl,FP="__reactHandles$"+jl;function os(e){var t=e[Or];if(t)return t;for(var n=e.parentNode;n;){if(t=n[mo]||n[Or]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=s1(e);e!==null;){if(n=e[Or])return n;e=s1(e)}return t}e=n,n=e.parentNode}return null}function bd(e){return e=e[Or]||e[mo],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function ma(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(ee(33))}function xf(e){return e[Uc]||null}var ux=[],va=-1;function Ri(e){return{current:e}}function tt(e){0>va||(e.current=ux[va],ux[va]=null,va--)}function Ge(e,t){va++,ux[va]=e.current,e.current=t}var ji={},rn=Ri(ji),kn=Ri(!1),ws=ji;function Ja(e,t){var n=e.type.contextTypes;if(!n)return ji;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Sn(e){return e=e.childContextTypes,e!=null}function Tp(){tt(kn),tt(rn)}function a1(e,t,n){if(rn.current!==ji)throw Error(ee(168));Ge(rn,t),Ge(kn,n)}function Ik(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(ee(108,kR(e)||"Unknown",i));return pt({},n,r)}function Ep(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ji,ws=rn.current,Ge(rn,e),Ge(kn,kn.current),!0}function l1(e,t,n){var r=e.stateNode;if(!r)throw Error(ee(169));n?(e=Ik(e,t,ws),r.__reactInternalMemoizedMergedChildContext=e,tt(kn),tt(rn),Ge(rn,e)):tt(kn),Ge(kn,n)}var to=null,mf=!1,Dh=!1;function Mk(e){to===null?to=[e]:to.push(e)}function zP(e){mf=!0,Mk(e)}function Pi(){if(!Dh&&to!==null){Dh=!0;var e=0,t=qe;try{var n=to;for(qe=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}to=null,mf=!1}catch(i){throw to!==null&&(to=to.slice(e+1)),nk(rv,Pi),i}finally{qe=t,Dh=!1}}return null}var ya=[],ba=0,Rp=null,Pp=0,Qn=[],Gn=0,ks=null,lo=1,co="";function Yi(e,t){ya[ba++]=Pp,ya[ba++]=Rp,Rp=e,Pp=t}function Lk(e,t,n){Qn[Gn++]=lo,Qn[Gn++]=co,Qn[Gn++]=ks,ks=e;var r=lo;e=co;var i=32-fr(r)-1;r&=~(1<<i),n+=1;var s=32-fr(t)+i;if(30<s){var a=i-i%5;s=(r&(1<<a)-1).toString(32),r>>=a,i-=a,lo=1<<32-fr(t)+i|n<<i|r,co=s+e}else lo=1<<s|n<<i|r,co=e}function pv(e){e.return!==null&&(Yi(e,1),Lk(e,1,0))}function fv(e){for(;e===Rp;)Rp=ya[--ba],ya[ba]=null,Pp=ya[--ba],ya[ba]=null;for(;e===ks;)ks=Qn[--Gn],Qn[Gn]=null,co=Qn[--Gn],Qn[Gn]=null,lo=Qn[--Gn],Qn[Gn]=null}var An=null,Dn=null,st=!1,dr=null;function Ok(e,t){var n=Xn(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function c1(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,An=e,Dn=pi(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,An=e,Dn=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=ks!==null?{id:lo,overflow:co}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Xn(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,An=e,Dn=null,!0):!1;default:return!1}}function px(e){return(e.mode&1)!==0&&(e.flags&128)===0}function fx(e){if(st){var t=Dn;if(t){var n=t;if(!c1(e,t)){if(px(e))throw Error(ee(418));t=pi(n.nextSibling);var r=An;t&&c1(e,t)?Ok(r,n):(e.flags=e.flags&-4097|2,st=!1,An=e)}}else{if(px(e))throw Error(ee(418));e.flags=e.flags&-4097|2,st=!1,An=e}}}function d1(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;An=e}function su(e){if(e!==An)return!1;if(!st)return d1(e),st=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!lx(e.type,e.memoizedProps)),t&&(t=Dn)){if(px(e))throw Dk(),Error(ee(418));for(;t;)Ok(e,t),t=pi(t.nextSibling)}if(d1(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(ee(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){Dn=pi(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}Dn=null}}else Dn=An?pi(e.stateNode.nextSibling):null;return!0}function Dk(){for(var e=Dn;e;)e=pi(e.nextSibling)}function Za(){Dn=An=null,st=!1}function hv(e){dr===null?dr=[e]:dr.push(e)}var BP=ko.ReactCurrentBatchConfig;function Wl(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(ee(309));var r=n.stateNode}if(!r)throw Error(ee(147,e));var i=r,s=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===s?t.ref:(t=function(a){var l=i.refs;a===null?delete l[s]:l[s]=a},t._stringRef=s,t)}if(typeof e!="string")throw Error(ee(284));if(!n._owner)throw Error(ee(290,e))}return e}function au(e,t){throw e=Object.prototype.toString.call(t),Error(ee(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function u1(e){var t=e._init;return t(e._payload)}function Ak(e){function t(b,y){if(e){var j=b.deletions;j===null?(b.deletions=[y],b.flags|=16):j.push(y)}}function n(b,y){if(!e)return null;for(;y!==null;)t(b,y),y=y.sibling;return null}function r(b,y){for(b=new Map;y!==null;)y.key!==null?b.set(y.key,y):b.set(y.index,y),y=y.sibling;return b}function i(b,y){return b=xi(b,y),b.index=0,b.sibling=null,b}function s(b,y,j){return b.index=j,e?(j=b.alternate,j!==null?(j=j.index,j<y?(b.flags|=2,y):j):(b.flags|=2,y)):(b.flags|=1048576,y)}function a(b){return e&&b.alternate===null&&(b.flags|=2),b}function l(b,y,j,S){return y===null||y.tag!==6?(y=Bh(j,b.mode,S),y.return=b,y):(y=i(y,j),y.return=b,y)}function c(b,y,j,S){var k=j.type;return k===fa?u(b,y,j.props.children,S,j.key):y!==null&&(y.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===Ho&&u1(k)===y.type)?(S=i(y,j.props),S.ref=Wl(b,y,j),S.return=b,S):(S=np(j.type,j.key,j.props,null,b.mode,S),S.ref=Wl(b,y,j),S.return=b,S)}function d(b,y,j,S){return y===null||y.tag!==4||y.stateNode.containerInfo!==j.containerInfo||y.stateNode.implementation!==j.implementation?(y=Wh(j,b.mode,S),y.return=b,y):(y=i(y,j.children||[]),y.return=b,y)}function u(b,y,j,S,k){return y===null||y.tag!==7?(y=ys(j,b.mode,S,k),y.return=b,y):(y=i(y,j),y.return=b,y)}function p(b,y,j){if(typeof y=="string"&&y!==""||typeof y=="number")return y=Bh(""+y,b.mode,j),y.return=b,y;if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Yd:return j=np(y.type,y.key,y.props,null,b.mode,j),j.ref=Wl(b,null,y),j.return=b,j;case pa:return y=Wh(y,b.mode,j),y.return=b,y;case Ho:var S=y._init;return p(b,S(y._payload),j)}if(nc(y)||$l(y))return y=ys(y,b.mode,j,null),y.return=b,y;au(b,y)}return null}function h(b,y,j,S){var k=y!==null?y.key:null;if(typeof j=="string"&&j!==""||typeof j=="number")return k!==null?null:l(b,y,""+j,S);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case Yd:return j.key===k?c(b,y,j,S):null;case pa:return j.key===k?d(b,y,j,S):null;case Ho:return k=j._init,h(b,y,k(j._payload),S)}if(nc(j)||$l(j))return k!==null?null:u(b,y,j,S,null);au(b,j)}return null}function g(b,y,j,S,k){if(typeof S=="string"&&S!==""||typeof S=="number")return b=b.get(j)||null,l(y,b,""+S,k);if(typeof S=="object"&&S!==null){switch(S.$$typeof){case Yd:return b=b.get(S.key===null?j:S.key)||null,c(y,b,S,k);case pa:return b=b.get(S.key===null?j:S.key)||null,d(y,b,S,k);case Ho:var E=S._init;return g(b,y,j,E(S._payload),k)}if(nc(S)||$l(S))return b=b.get(j)||null,u(y,b,S,k,null);au(y,S)}return null}function v(b,y,j,S){for(var k=null,E=null,C=y,R=y=0,P=null;C!==null&&R<j.length;R++){C.index>R?(P=C,C=null):P=C.sibling;var L=h(b,C,j[R],S);if(L===null){C===null&&(C=P);break}e&&C&&L.alternate===null&&t(b,C),y=s(L,y,R),E===null?k=L:E.sibling=L,E=L,C=P}if(R===j.length)return n(b,C),st&&Yi(b,R),k;if(C===null){for(;R<j.length;R++)C=p(b,j[R],S),C!==null&&(y=s(C,y,R),E===null?k=C:E.sibling=C,E=C);return st&&Yi(b,R),k}for(C=r(b,C);R<j.length;R++)P=g(C,b,R,j[R],S),P!==null&&(e&&P.alternate!==null&&C.delete(P.key===null?R:P.key),y=s(P,y,R),E===null?k=P:E.sibling=P,E=P);return e&&C.forEach(function(_){return t(b,_)}),st&&Yi(b,R),k}function x(b,y,j,S){var k=$l(j);if(typeof k!="function")throw Error(ee(150));if(j=k.call(j),j==null)throw Error(ee(151));for(var E=k=null,C=y,R=y=0,P=null,L=j.next();C!==null&&!L.done;R++,L=j.next()){C.index>R?(P=C,C=null):P=C.sibling;var _=h(b,C,L.value,S);if(_===null){C===null&&(C=P);break}e&&C&&_.alternate===null&&t(b,C),y=s(_,y,R),E===null?k=_:E.sibling=_,E=_,C=P}if(L.done)return n(b,C),st&&Yi(b,R),k;if(C===null){for(;!L.done;R++,L=j.next())L=p(b,L.value,S),L!==null&&(y=s(L,y,R),E===null?k=L:E.sibling=L,E=L);return st&&Yi(b,R),k}for(C=r(b,C);!L.done;R++,L=j.next())L=g(C,b,R,L.value,S),L!==null&&(e&&L.alternate!==null&&C.delete(L.key===null?R:L.key),y=s(L,y,R),E===null?k=L:E.sibling=L,E=L);return e&&C.forEach(function(U){return t(b,U)}),st&&Yi(b,R),k}function w(b,y,j,S){if(typeof j=="object"&&j!==null&&j.type===fa&&j.key===null&&(j=j.props.children),typeof j=="object"&&j!==null){switch(j.$$typeof){case Yd:e:{for(var k=j.key,E=y;E!==null;){if(E.key===k){if(k=j.type,k===fa){if(E.tag===7){n(b,E.sibling),y=i(E,j.props.children),y.return=b,b=y;break e}}else if(E.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===Ho&&u1(k)===E.type){n(b,E.sibling),y=i(E,j.props),y.ref=Wl(b,E,j),y.return=b,b=y;break e}n(b,E);break}else t(b,E);E=E.sibling}j.type===fa?(y=ys(j.props.children,b.mode,S,j.key),y.return=b,b=y):(S=np(j.type,j.key,j.props,null,b.mode,S),S.ref=Wl(b,y,j),S.return=b,b=S)}return a(b);case pa:e:{for(E=j.key;y!==null;){if(y.key===E)if(y.tag===4&&y.stateNode.containerInfo===j.containerInfo&&y.stateNode.implementation===j.implementation){n(b,y.sibling),y=i(y,j.children||[]),y.return=b,b=y;break e}else{n(b,y);break}else t(b,y);y=y.sibling}y=Wh(j,b.mode,S),y.return=b,b=y}return a(b);case Ho:return E=j._init,w(b,y,E(j._payload),S)}if(nc(j))return v(b,y,j,S);if($l(j))return x(b,y,j,S);au(b,j)}return typeof j=="string"&&j!==""||typeof j=="number"?(j=""+j,y!==null&&y.tag===6?(n(b,y.sibling),y=i(y,j),y.return=b,b=y):(n(b,y),y=Bh(j,b.mode,S),y.return=b,b=y),a(b)):n(b,y)}return w}var el=Ak(!0),Nk=Ak(!1),Ip=Ri(null),Mp=null,ja=null,gv=null;function xv(){gv=ja=Mp=null}function mv(e){var t=Ip.current;tt(Ip),e._currentValue=t}function hx(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Ma(e,t){Mp=e,gv=ja=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(wn=!0),e.firstContext=null)}function Zn(e){var t=e._currentValue;if(gv!==e)if(e={context:e,memoizedValue:t,next:null},ja===null){if(Mp===null)throw Error(ee(308));ja=e,Mp.dependencies={lanes:0,firstContext:e}}else ja=ja.next=e;return t}var is=null;function vv(e){is===null?is=[e]:is.push(e)}function $k(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,vv(t)):(n.next=i.next,i.next=n),t.interleaved=n,vo(e,r)}function vo(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var qo=!1;function yv(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function _k(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function fo(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function fi(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,_e&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,vo(e,n)}return i=r.interleaved,i===null?(t.next=t,vv(r)):(t.next=i.next,i.next=t),r.interleaved=t,vo(e,n)}function Yu(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ov(e,n)}}function p1(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?i=s=a:s=s.next=a,n=n.next}while(n!==null);s===null?i=s=t:s=s.next=t}else i=s=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Lp(e,t,n,r){var i=e.updateQueue;qo=!1;var s=i.firstBaseUpdate,a=i.lastBaseUpdate,l=i.shared.pending;if(l!==null){i.shared.pending=null;var c=l,d=c.next;c.next=null,a===null?s=d:a.next=d,a=c;var u=e.alternate;u!==null&&(u=u.updateQueue,l=u.lastBaseUpdate,l!==a&&(l===null?u.firstBaseUpdate=d:l.next=d,u.lastBaseUpdate=c))}if(s!==null){var p=i.baseState;a=0,u=d=c=null,l=s;do{var h=l.lane,g=l.eventTime;if((r&h)===h){u!==null&&(u=u.next={eventTime:g,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var v=e,x=l;switch(h=t,g=n,x.tag){case 1:if(v=x.payload,typeof v=="function"){p=v.call(g,p,h);break e}p=v;break e;case 3:v.flags=v.flags&-65537|128;case 0:if(v=x.payload,h=typeof v=="function"?v.call(g,p,h):v,h==null)break e;p=pt({},p,h);break e;case 2:qo=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,h=i.effects,h===null?i.effects=[l]:h.push(l))}else g={eventTime:g,lane:h,tag:l.tag,payload:l.payload,callback:l.callback,next:null},u===null?(d=u=g,c=p):u=u.next=g,a|=h;if(l=l.next,l===null){if(l=i.shared.pending,l===null)break;h=l,l=h.next,h.next=null,i.lastBaseUpdate=h,i.shared.pending=null}}while(!0);if(u===null&&(c=p),i.baseState=c,i.firstBaseUpdate=d,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do a|=i.lane,i=i.next;while(i!==t)}else s===null&&(i.shared.lanes=0);Cs|=a,e.lanes=a,e.memoizedState=p}}function f1(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],i=r.callback;if(i!==null){if(r.callback=null,r=n,typeof i!="function")throw Error(ee(191,i));i.call(r)}}}var jd={},$r=Ri(jd),Hc=Ri(jd),qc=Ri(jd);function ss(e){if(e===jd)throw Error(ee(174));return e}function bv(e,t){switch(Ge(qc,t),Ge(Hc,e),Ge($r,jd),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Qg(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Qg(t,e)}tt($r),Ge($r,t)}function tl(){tt($r),tt(Hc),tt(qc)}function Fk(e){ss(qc.current);var t=ss($r.current),n=Qg(t,e.type);t!==n&&(Ge(Hc,e),Ge($r,n))}function jv(e){Hc.current===e&&(tt($r),tt(Hc))}var dt=Ri(0);function Op(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Ah=[];function wv(){for(var e=0;e<Ah.length;e++)Ah[e]._workInProgressVersionPrimary=null;Ah.length=0}var Xu=ko.ReactCurrentDispatcher,Nh=ko.ReactCurrentBatchConfig,Ss=0,ut=null,Pt=null,$t=null,Dp=!1,mc=!1,Vc=0,WP=0;function Xt(){throw Error(ee(321))}function kv(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!xr(e[n],t[n]))return!1;return!0}function Sv(e,t,n,r,i,s){if(Ss=s,ut=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Xu.current=e===null||e.memoizedState===null?VP:KP,e=n(r,i),mc){s=0;do{if(mc=!1,Vc=0,25<=s)throw Error(ee(301));s+=1,$t=Pt=null,t.updateQueue=null,Xu.current=QP,e=n(r,i)}while(mc)}if(Xu.current=Ap,t=Pt!==null&&Pt.next!==null,Ss=0,$t=Pt=ut=null,Dp=!1,t)throw Error(ee(300));return e}function Cv(){var e=Vc!==0;return Vc=0,e}function Pr(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return $t===null?ut.memoizedState=$t=e:$t=$t.next=e,$t}function er(){if(Pt===null){var e=ut.alternate;e=e!==null?e.memoizedState:null}else e=Pt.next;var t=$t===null?ut.memoizedState:$t.next;if(t!==null)$t=t,Pt=e;else{if(e===null)throw Error(ee(310));Pt=e,e={memoizedState:Pt.memoizedState,baseState:Pt.baseState,baseQueue:Pt.baseQueue,queue:Pt.queue,next:null},$t===null?ut.memoizedState=$t=e:$t=$t.next=e}return $t}function Kc(e,t){return typeof t=="function"?t(e):t}function $h(e){var t=er(),n=t.queue;if(n===null)throw Error(ee(311));n.lastRenderedReducer=e;var r=Pt,i=r.baseQueue,s=n.pending;if(s!==null){if(i!==null){var a=i.next;i.next=s.next,s.next=a}r.baseQueue=i=s,n.pending=null}if(i!==null){s=i.next,r=r.baseState;var l=a=null,c=null,d=s;do{var u=d.lane;if((Ss&u)===u)c!==null&&(c=c.next={lane:0,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null}),r=d.hasEagerState?d.eagerState:e(r,d.action);else{var p={lane:u,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(l=c=p,a=r):c=c.next=p,ut.lanes|=u,Cs|=u}d=d.next}while(d!==null&&d!==s);c===null?a=r:c.next=l,xr(r,t.memoizedState)||(wn=!0),t.memoizedState=r,t.baseState=a,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){i=e;do s=i.lane,ut.lanes|=s,Cs|=s,i=i.next;while(i!==e)}else i===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function _h(e){var t=er(),n=t.queue;if(n===null)throw Error(ee(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,s=t.memoizedState;if(i!==null){n.pending=null;var a=i=i.next;do s=e(s,a.action),a=a.next;while(a!==i);xr(s,t.memoizedState)||(wn=!0),t.memoizedState=s,t.baseQueue===null&&(t.baseState=s),n.lastRenderedState=s}return[s,r]}function zk(){}function Bk(e,t){var n=ut,r=er(),i=t(),s=!xr(r.memoizedState,i);if(s&&(r.memoizedState=i,wn=!0),r=r.queue,Tv(Hk.bind(null,n,r,e),[e]),r.getSnapshot!==t||s||$t!==null&&$t.memoizedState.tag&1){if(n.flags|=2048,Qc(9,Uk.bind(null,n,r,i,t),void 0,null),_t===null)throw Error(ee(349));Ss&30||Wk(n,t,i)}return i}function Wk(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=ut.updateQueue,t===null?(t={lastEffect:null,stores:null},ut.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Uk(e,t,n,r){t.value=n,t.getSnapshot=r,qk(t)&&Vk(e)}function Hk(e,t,n){return n(function(){qk(t)&&Vk(e)})}function qk(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!xr(e,n)}catch{return!0}}function Vk(e){var t=vo(e,1);t!==null&&hr(t,e,1,-1)}function h1(e){var t=Pr();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Kc,lastRenderedState:e},t.queue=e,e=e.dispatch=qP.bind(null,ut,e),[t.memoizedState,e]}function Qc(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=ut.updateQueue,t===null?(t={lastEffect:null,stores:null},ut.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function Kk(){return er().memoizedState}function Ju(e,t,n,r){var i=Pr();ut.flags|=e,i.memoizedState=Qc(1|t,n,void 0,r===void 0?null:r)}function vf(e,t,n,r){var i=er();r=r===void 0?null:r;var s=void 0;if(Pt!==null){var a=Pt.memoizedState;if(s=a.destroy,r!==null&&kv(r,a.deps)){i.memoizedState=Qc(t,n,s,r);return}}ut.flags|=e,i.memoizedState=Qc(1|t,n,s,r)}function g1(e,t){return Ju(8390656,8,e,t)}function Tv(e,t){return vf(2048,8,e,t)}function Qk(e,t){return vf(4,2,e,t)}function Gk(e,t){return vf(4,4,e,t)}function Yk(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Xk(e,t,n){return n=n!=null?n.concat([e]):null,vf(4,4,Yk.bind(null,t,e),n)}function Ev(){}function Jk(e,t){var n=er();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&kv(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Zk(e,t){var n=er();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&kv(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function eS(e,t,n){return Ss&21?(xr(n,t)||(n=ik(),ut.lanes|=n,Cs|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,wn=!0),e.memoizedState=n)}function UP(e,t){var n=qe;qe=n!==0&&4>n?n:4,e(!0);var r=Nh.transition;Nh.transition={};try{e(!1),t()}finally{qe=n,Nh.transition=r}}function tS(){return er().memoizedState}function HP(e,t,n){var r=gi(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},nS(e))rS(t,n);else if(n=$k(e,t,n,r),n!==null){var i=un();hr(n,e,r,i),oS(n,t,r)}}function qP(e,t,n){var r=gi(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(nS(e))rS(t,i);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var a=t.lastRenderedState,l=s(a,n);if(i.hasEagerState=!0,i.eagerState=l,xr(l,a)){var c=t.interleaved;c===null?(i.next=i,vv(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}finally{}n=$k(e,t,i,r),n!==null&&(i=un(),hr(n,e,r,i),oS(n,t,r))}}function nS(e){var t=e.alternate;return e===ut||t!==null&&t===ut}function rS(e,t){mc=Dp=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function oS(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ov(e,n)}}var Ap={readContext:Zn,useCallback:Xt,useContext:Xt,useEffect:Xt,useImperativeHandle:Xt,useInsertionEffect:Xt,useLayoutEffect:Xt,useMemo:Xt,useReducer:Xt,useRef:Xt,useState:Xt,useDebugValue:Xt,useDeferredValue:Xt,useTransition:Xt,useMutableSource:Xt,useSyncExternalStore:Xt,useId:Xt,unstable_isNewReconciler:!1},VP={readContext:Zn,useCallback:function(e,t){return Pr().memoizedState=[e,t===void 0?null:t],e},useContext:Zn,useEffect:g1,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ju(4194308,4,Yk.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ju(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ju(4,2,e,t)},useMemo:function(e,t){var n=Pr();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Pr();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=HP.bind(null,ut,e),[r.memoizedState,e]},useRef:function(e){var t=Pr();return e={current:e},t.memoizedState=e},useState:h1,useDebugValue:Ev,useDeferredValue:function(e){return Pr().memoizedState=e},useTransition:function(){var e=h1(!1),t=e[0];return e=UP.bind(null,e[1]),Pr().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ut,i=Pr();if(st){if(n===void 0)throw Error(ee(407));n=n()}else{if(n=t(),_t===null)throw Error(ee(349));Ss&30||Wk(r,t,n)}i.memoizedState=n;var s={value:n,getSnapshot:t};return i.queue=s,g1(Hk.bind(null,r,s,e),[e]),r.flags|=2048,Qc(9,Uk.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=Pr(),t=_t.identifierPrefix;if(st){var n=co,r=lo;n=(r&~(1<<32-fr(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Vc++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=WP++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},KP={readContext:Zn,useCallback:Jk,useContext:Zn,useEffect:Tv,useImperativeHandle:Xk,useInsertionEffect:Qk,useLayoutEffect:Gk,useMemo:Zk,useReducer:$h,useRef:Kk,useState:function(){return $h(Kc)},useDebugValue:Ev,useDeferredValue:function(e){var t=er();return eS(t,Pt.memoizedState,e)},useTransition:function(){var e=$h(Kc)[0],t=er().memoizedState;return[e,t]},useMutableSource:zk,useSyncExternalStore:Bk,useId:tS,unstable_isNewReconciler:!1},QP={readContext:Zn,useCallback:Jk,useContext:Zn,useEffect:Tv,useImperativeHandle:Xk,useInsertionEffect:Qk,useLayoutEffect:Gk,useMemo:Zk,useReducer:_h,useRef:Kk,useState:function(){return _h(Kc)},useDebugValue:Ev,useDeferredValue:function(e){var t=er();return Pt===null?t.memoizedState=e:eS(t,Pt.memoizedState,e)},useTransition:function(){var e=_h(Kc)[0],t=er().memoizedState;return[e,t]},useMutableSource:zk,useSyncExternalStore:Bk,useId:tS,unstable_isNewReconciler:!1};function sr(e,t){if(e&&e.defaultProps){t=pt({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function gx(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:pt({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var yf={isMounted:function(e){return(e=e._reactInternals)?As(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=un(),i=gi(e),s=fo(r,i);s.payload=t,n!=null&&(s.callback=n),t=fi(e,s,i),t!==null&&(hr(t,e,i,r),Yu(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=un(),i=gi(e),s=fo(r,i);s.tag=1,s.payload=t,n!=null&&(s.callback=n),t=fi(e,s,i),t!==null&&(hr(t,e,i,r),Yu(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=un(),r=gi(e),i=fo(n,r);i.tag=2,t!=null&&(i.callback=t),t=fi(e,i,r),t!==null&&(hr(t,e,r,n),Yu(t,e,r))}};function x1(e,t,n,r,i,s,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,s,a):t.prototype&&t.prototype.isPureReactComponent?!zc(n,r)||!zc(i,s):!0}function iS(e,t,n){var r=!1,i=ji,s=t.contextType;return typeof s=="object"&&s!==null?s=Zn(s):(i=Sn(t)?ws:rn.current,r=t.contextTypes,s=(r=r!=null)?Ja(e,i):ji),t=new t(n,s),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=yf,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=s),t}function m1(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&yf.enqueueReplaceState(t,t.state,null)}function xx(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},yv(e);var s=t.contextType;typeof s=="object"&&s!==null?i.context=Zn(s):(s=Sn(t)?ws:rn.current,i.context=Ja(e,s)),i.state=e.memoizedState,s=t.getDerivedStateFromProps,typeof s=="function"&&(gx(e,t,s,n),i.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(t=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),t!==i.state&&yf.enqueueReplaceState(i,i.state,null),Lp(e,n,i,r),i.state=e.memoizedState),typeof i.componentDidMount=="function"&&(e.flags|=4194308)}function nl(e,t){try{var n="",r=t;do n+=wR(r),r=r.return;while(r);var i=n}catch(s){i=`
|
|
39
|
+
Error generating stack: `+s.message+`
|
|
40
|
+
`+s.stack}return{value:e,source:t,stack:i,digest:null}}function Fh(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function mx(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var GP=typeof WeakMap=="function"?WeakMap:Map;function sS(e,t,n){n=fo(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){$p||($p=!0,Ex=r),mx(e,t)},n}function aS(e,t,n){n=fo(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){mx(e,t)}}var s=e.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){mx(e,t),typeof r!="function"&&(hi===null?hi=new Set([this]):hi.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function v1(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new GP;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=c8.bind(null,e,t,n),t.then(e,e))}function y1(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function b1(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=fo(-1,1),t.tag=2,fi(n,t,1))),n.lanes|=1),e)}var YP=ko.ReactCurrentOwner,wn=!1;function cn(e,t,n,r){t.child=e===null?Nk(t,null,n,r):el(t,e.child,n,r)}function j1(e,t,n,r,i){n=n.render;var s=t.ref;return Ma(t,i),r=Sv(e,t,n,r,s,i),n=Cv(),e!==null&&!wn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,yo(e,t,i)):(st&&n&&pv(t),t.flags|=1,cn(e,t,r,i),t.child)}function w1(e,t,n,r,i){if(e===null){var s=n.type;return typeof s=="function"&&!Av(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=s,lS(e,t,s,r,i)):(e=np(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(s=e.child,!(e.lanes&i)){var a=s.memoizedProps;if(n=n.compare,n=n!==null?n:zc,n(a,r)&&e.ref===t.ref)return yo(e,t,i)}return t.flags|=1,e=xi(s,r),e.ref=t.ref,e.return=t,t.child=e}function lS(e,t,n,r,i){if(e!==null){var s=e.memoizedProps;if(zc(s,r)&&e.ref===t.ref)if(wn=!1,t.pendingProps=r=s,(e.lanes&i)!==0)e.flags&131072&&(wn=!0);else return t.lanes=e.lanes,yo(e,t,i)}return vx(e,t,n,r,i)}function cS(e,t,n){var r=t.pendingProps,i=r.children,s=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ge(ka,Rn),Rn|=n;else{if(!(n&1073741824))return e=s!==null?s.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Ge(ka,Rn),Rn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:n,Ge(ka,Rn),Rn|=r}else s!==null?(r=s.baseLanes|n,t.memoizedState=null):r=n,Ge(ka,Rn),Rn|=r;return cn(e,t,i,n),t.child}function dS(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function vx(e,t,n,r,i){var s=Sn(n)?ws:rn.current;return s=Ja(t,s),Ma(t,i),n=Sv(e,t,n,r,s,i),r=Cv(),e!==null&&!wn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,yo(e,t,i)):(st&&r&&pv(t),t.flags|=1,cn(e,t,n,i),t.child)}function k1(e,t,n,r,i){if(Sn(n)){var s=!0;Ep(t)}else s=!1;if(Ma(t,i),t.stateNode===null)Zu(e,t),iS(t,n,r),xx(t,n,r,i),r=!0;else if(e===null){var a=t.stateNode,l=t.memoizedProps;a.props=l;var c=a.context,d=n.contextType;typeof d=="object"&&d!==null?d=Zn(d):(d=Sn(n)?ws:rn.current,d=Ja(t,d));var u=n.getDerivedStateFromProps,p=typeof u=="function"||typeof a.getSnapshotBeforeUpdate=="function";p||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==r||c!==d)&&m1(t,a,r,d),qo=!1;var h=t.memoizedState;a.state=h,Lp(t,r,a,i),c=t.memoizedState,l!==r||h!==c||kn.current||qo?(typeof u=="function"&&(gx(t,n,u,r),c=t.memoizedState),(l=qo||x1(t,n,l,r,h,c,d))?(p||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(t.flags|=4194308)):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),a.props=r,a.state=c,a.context=d,r=l):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,_k(e,t),l=t.memoizedProps,d=t.type===t.elementType?l:sr(t.type,l),a.props=d,p=t.pendingProps,h=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=Zn(c):(c=Sn(n)?ws:rn.current,c=Ja(t,c));var g=n.getDerivedStateFromProps;(u=typeof g=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==p||h!==c)&&m1(t,a,r,c),qo=!1,h=t.memoizedState,a.state=h,Lp(t,r,a,i);var v=t.memoizedState;l!==p||h!==v||kn.current||qo?(typeof g=="function"&&(gx(t,n,g,r),v=t.memoizedState),(d=qo||x1(t,n,d,r,h,v,c)||!1)?(u||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,v,c),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,v,c)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=v),a.props=r,a.state=v,a.context=c,r=d):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),r=!1)}return yx(e,t,n,r,s,i)}function yx(e,t,n,r,i,s){dS(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return i&&l1(t,n,!1),yo(e,t,s);r=t.stateNode,YP.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=el(t,e.child,null,s),t.child=el(t,null,l,s)):cn(e,t,l,s),t.memoizedState=r.state,i&&l1(t,n,!0),t.child}function uS(e){var t=e.stateNode;t.pendingContext?a1(e,t.pendingContext,t.pendingContext!==t.context):t.context&&a1(e,t.context,!1),bv(e,t.containerInfo)}function S1(e,t,n,r,i){return Za(),hv(i),t.flags|=256,cn(e,t,n,r),t.child}var bx={dehydrated:null,treeContext:null,retryLane:0};function jx(e){return{baseLanes:e,cachePool:null,transitions:null}}function pS(e,t,n){var r=t.pendingProps,i=dt.current,s=!1,a=(t.flags&128)!==0,l;if((l=a)||(l=e!==null&&e.memoizedState===null?!1:(i&2)!==0),l?(s=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),Ge(dt,i&1),e===null)return fx(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(a=r.children,e=r.fallback,s?(r=t.mode,s=t.child,a={mode:"hidden",children:a},!(r&1)&&s!==null?(s.childLanes=0,s.pendingProps=a):s=wf(a,r,0,null),e=ys(e,r,n,null),s.return=t,e.return=t,s.sibling=e,t.child=s,t.child.memoizedState=jx(n),t.memoizedState=bx,e):Rv(t,a));if(i=e.memoizedState,i!==null&&(l=i.dehydrated,l!==null))return XP(e,t,a,r,l,i,n);if(s){s=r.fallback,a=t.mode,i=e.child,l=i.sibling;var c={mode:"hidden",children:r.children};return!(a&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=xi(i,c),r.subtreeFlags=i.subtreeFlags&14680064),l!==null?s=xi(l,s):(s=ys(s,a,n,null),s.flags|=2),s.return=t,r.return=t,r.sibling=s,t.child=r,r=s,s=t.child,a=e.child.memoizedState,a=a===null?jx(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},s.memoizedState=a,s.childLanes=e.childLanes&~n,t.memoizedState=bx,r}return s=e.child,e=s.sibling,r=xi(s,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Rv(e,t){return t=wf({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function lu(e,t,n,r){return r!==null&&hv(r),el(t,e.child,null,n),e=Rv(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function XP(e,t,n,r,i,s,a){if(n)return t.flags&256?(t.flags&=-257,r=Fh(Error(ee(422))),lu(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(s=r.fallback,i=t.mode,r=wf({mode:"visible",children:r.children},i,0,null),s=ys(s,i,a,null),s.flags|=2,r.return=t,s.return=t,r.sibling=s,t.child=r,t.mode&1&&el(t,e.child,null,a),t.child.memoizedState=jx(a),t.memoizedState=bx,s);if(!(t.mode&1))return lu(e,t,a,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var l=r.dgst;return r=l,s=Error(ee(419)),r=Fh(s,r,void 0),lu(e,t,a,r)}if(l=(a&e.childLanes)!==0,wn||l){if(r=_t,r!==null){switch(a&-a){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|a)?0:i,i!==0&&i!==s.retryLane&&(s.retryLane=i,vo(e,i),hr(r,e,i,-1))}return Dv(),r=Fh(Error(ee(421))),lu(e,t,a,r)}return i.data==="$?"?(t.flags|=128,t.child=e.child,t=d8.bind(null,e),i._reactRetry=t,null):(e=s.treeContext,Dn=pi(i.nextSibling),An=t,st=!0,dr=null,e!==null&&(Qn[Gn++]=lo,Qn[Gn++]=co,Qn[Gn++]=ks,lo=e.id,co=e.overflow,ks=t),t=Rv(t,r.children),t.flags|=4096,t)}function C1(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),hx(e.return,t,n)}function zh(e,t,n,r,i){var s=e.memoizedState;s===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=i)}function fS(e,t,n){var r=t.pendingProps,i=r.revealOrder,s=r.tail;if(cn(e,t,r.children,n),r=dt.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&C1(e,n,t);else if(e.tag===19)C1(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Ge(dt,r),!(t.mode&1))t.memoizedState=null;else switch(i){case"forwards":for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&Op(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),zh(t,!1,i,n,s);break;case"backwards":for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Op(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}zh(t,!0,n,null,s);break;case"together":zh(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Zu(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function yo(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Cs|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(ee(153));if(t.child!==null){for(e=t.child,n=xi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=xi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function JP(e,t,n){switch(t.tag){case 3:uS(t),Za();break;case 5:Fk(t);break;case 1:Sn(t.type)&&Ep(t);break;case 4:bv(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;Ge(Ip,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Ge(dt,dt.current&1),t.flags|=128,null):n&t.child.childLanes?pS(e,t,n):(Ge(dt,dt.current&1),e=yo(e,t,n),e!==null?e.sibling:null);Ge(dt,dt.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return fS(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Ge(dt,dt.current),r)break;return null;case 22:case 23:return t.lanes=0,cS(e,t,n)}return yo(e,t,n)}var hS,wx,gS,xS;hS=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};wx=function(){};gS=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,ss($r.current);var s=null;switch(n){case"input":i=Hg(e,i),r=Hg(e,r),s=[];break;case"select":i=pt({},i,{value:void 0}),r=pt({},r,{value:void 0}),s=[];break;case"textarea":i=Kg(e,i),r=Kg(e,r),s=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Cp)}Gg(n,r);var a;n=null;for(d in i)if(!r.hasOwnProperty(d)&&i.hasOwnProperty(d)&&i[d]!=null)if(d==="style"){var l=i[d];for(a in l)l.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else d!=="dangerouslySetInnerHTML"&&d!=="children"&&d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&d!=="autoFocus"&&(Oc.hasOwnProperty(d)?s||(s=[]):(s=s||[]).push(d,null));for(d in r){var c=r[d];if(l=i!=null?i[d]:void 0,r.hasOwnProperty(d)&&c!==l&&(c!=null||l!=null))if(d==="style")if(l){for(a in l)!l.hasOwnProperty(a)||c&&c.hasOwnProperty(a)||(n||(n={}),n[a]="");for(a in c)c.hasOwnProperty(a)&&l[a]!==c[a]&&(n||(n={}),n[a]=c[a])}else n||(s||(s=[]),s.push(d,n)),n=c;else d==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(s=s||[]).push(d,c)):d==="children"?typeof c!="string"&&typeof c!="number"||(s=s||[]).push(d,""+c):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(Oc.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&Ze("scroll",e),s||l===c||(s=[])):(s=s||[]).push(d,c))}n&&(s=s||[]).push("style",n);var d=s;(t.updateQueue=d)&&(t.flags|=4)}};xS=function(e,t,n,r){n!==r&&(t.flags|=4)};function Ul(e,t){if(!st)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Jt(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function ZP(e,t,n){var r=t.pendingProps;switch(fv(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Jt(t),null;case 1:return Sn(t.type)&&Tp(),Jt(t),null;case 3:return r=t.stateNode,tl(),tt(kn),tt(rn),wv(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(su(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,dr!==null&&(Ix(dr),dr=null))),wx(e,t),Jt(t),null;case 5:jv(t);var i=ss(qc.current);if(n=t.type,e!==null&&t.stateNode!=null)gS(e,t,n,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(ee(166));return Jt(t),null}if(e=ss($r.current),su(t)){r=t.stateNode,n=t.type;var s=t.memoizedProps;switch(r[Or]=t,r[Uc]=s,e=(t.mode&1)!==0,n){case"dialog":Ze("cancel",r),Ze("close",r);break;case"iframe":case"object":case"embed":Ze("load",r);break;case"video":case"audio":for(i=0;i<oc.length;i++)Ze(oc[i],r);break;case"source":Ze("error",r);break;case"img":case"image":case"link":Ze("error",r),Ze("load",r);break;case"details":Ze("toggle",r);break;case"input":Dy(r,s),Ze("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!s.multiple},Ze("invalid",r);break;case"textarea":Ny(r,s),Ze("invalid",r)}Gg(n,s),i=null;for(var a in s)if(s.hasOwnProperty(a)){var l=s[a];a==="children"?typeof l=="string"?r.textContent!==l&&(s.suppressHydrationWarning!==!0&&iu(r.textContent,l,e),i=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(s.suppressHydrationWarning!==!0&&iu(r.textContent,l,e),i=["children",""+l]):Oc.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&Ze("scroll",r)}switch(n){case"input":Xd(r),Ay(r,s,!0);break;case"textarea":Xd(r),$y(r);break;case"select":case"option":break;default:typeof s.onClick=="function"&&(r.onclick=Cp)}r=i,t.updateQueue=r,r!==null&&(t.flags|=4)}else{a=i.nodeType===9?i:i.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=H2(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=a.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=a.createElement(n,{is:r.is}):(e=a.createElement(n),n==="select"&&(a=e,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):e=a.createElementNS(e,n),e[Or]=t,e[Uc]=r,hS(e,t,!1,!1),t.stateNode=e;e:{switch(a=Yg(n,r),n){case"dialog":Ze("cancel",e),Ze("close",e),i=r;break;case"iframe":case"object":case"embed":Ze("load",e),i=r;break;case"video":case"audio":for(i=0;i<oc.length;i++)Ze(oc[i],e);i=r;break;case"source":Ze("error",e),i=r;break;case"img":case"image":case"link":Ze("error",e),Ze("load",e),i=r;break;case"details":Ze("toggle",e),i=r;break;case"input":Dy(e,r),i=Hg(e,r),Ze("invalid",e);break;case"option":i=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},i=pt({},r,{value:void 0}),Ze("invalid",e);break;case"textarea":Ny(e,r),i=Kg(e,r),Ze("invalid",e);break;default:i=r}Gg(n,i),l=i;for(s in l)if(l.hasOwnProperty(s)){var c=l[s];s==="style"?K2(e,c):s==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&q2(e,c)):s==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Dc(e,c):typeof c=="number"&&Dc(e,""+c):s!=="suppressContentEditableWarning"&&s!=="suppressHydrationWarning"&&s!=="autoFocus"&&(Oc.hasOwnProperty(s)?c!=null&&s==="onScroll"&&Ze("scroll",e):c!=null&&Jm(e,s,c,a))}switch(n){case"input":Xd(e),Ay(e,r,!1);break;case"textarea":Xd(e),$y(e);break;case"option":r.value!=null&&e.setAttribute("value",""+bi(r.value));break;case"select":e.multiple=!!r.multiple,s=r.value,s!=null?Ea(e,!!r.multiple,s,!1):r.defaultValue!=null&&Ea(e,!!r.multiple,r.defaultValue,!0);break;default:typeof i.onClick=="function"&&(e.onclick=Cp)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Jt(t),null;case 6:if(e&&t.stateNode!=null)xS(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(ee(166));if(n=ss(qc.current),ss($r.current),su(t)){if(r=t.stateNode,n=t.memoizedProps,r[Or]=t,(s=r.nodeValue!==n)&&(e=An,e!==null))switch(e.tag){case 3:iu(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&iu(r.nodeValue,n,(e.mode&1)!==0)}s&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Or]=t,t.stateNode=r}return Jt(t),null;case 13:if(tt(dt),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(st&&Dn!==null&&t.mode&1&&!(t.flags&128))Dk(),Za(),t.flags|=98560,s=!1;else if(s=su(t),r!==null&&r.dehydrated!==null){if(e===null){if(!s)throw Error(ee(318));if(s=t.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(ee(317));s[Or]=t}else Za(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Jt(t),s=!1}else dr!==null&&(Ix(dr),dr=null),s=!0;if(!s)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||dt.current&1?Mt===0&&(Mt=3):Dv())),t.updateQueue!==null&&(t.flags|=4),Jt(t),null);case 4:return tl(),wx(e,t),e===null&&Bc(t.stateNode.containerInfo),Jt(t),null;case 10:return mv(t.type._context),Jt(t),null;case 17:return Sn(t.type)&&Tp(),Jt(t),null;case 19:if(tt(dt),s=t.memoizedState,s===null)return Jt(t),null;if(r=(t.flags&128)!==0,a=s.rendering,a===null)if(r)Ul(s,!1);else{if(Mt!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Op(e),a!==null){for(t.flags|=128,Ul(s,!1),r=a.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)s=n,e=r,s.flags&=14680066,a=s.alternate,a===null?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=a.childLanes,s.lanes=a.lanes,s.child=a.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=a.memoizedProps,s.memoizedState=a.memoizedState,s.updateQueue=a.updateQueue,s.type=a.type,e=a.dependencies,s.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return Ge(dt,dt.current&1|2),t.child}e=e.sibling}s.tail!==null&&bt()>rl&&(t.flags|=128,r=!0,Ul(s,!1),t.lanes=4194304)}else{if(!r)if(e=Op(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Ul(s,!0),s.tail===null&&s.tailMode==="hidden"&&!a.alternate&&!st)return Jt(t),null}else 2*bt()-s.renderingStartTime>rl&&n!==1073741824&&(t.flags|=128,r=!0,Ul(s,!1),t.lanes=4194304);s.isBackwards?(a.sibling=t.child,t.child=a):(n=s.last,n!==null?n.sibling=a:t.child=a,s.last=a)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=bt(),t.sibling=null,n=dt.current,Ge(dt,r?n&1|2:n&1),t):(Jt(t),null);case 22:case 23:return Ov(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Rn&1073741824&&(Jt(t),t.subtreeFlags&6&&(t.flags|=8192)):Jt(t),null;case 24:return null;case 25:return null}throw Error(ee(156,t.tag))}function e8(e,t){switch(fv(t),t.tag){case 1:return Sn(t.type)&&Tp(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return tl(),tt(kn),tt(rn),wv(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return jv(t),null;case 13:if(tt(dt),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(ee(340));Za()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return tt(dt),null;case 4:return tl(),null;case 10:return mv(t.type._context),null;case 22:case 23:return Ov(),null;case 24:return null;default:return null}}var cu=!1,nn=!1,t8=typeof WeakSet=="function"?WeakSet:Set,ge=null;function wa(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){mt(e,t,r)}else n.current=null}function kx(e,t,n){try{n()}catch(r){mt(e,t,r)}}var T1=!1;function n8(e,t){if(sx=wp,e=jk(),uv(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var a=0,l=-1,c=-1,d=0,u=0,p=e,h=null;t:for(;;){for(var g;p!==n||i!==0&&p.nodeType!==3||(l=a+i),p!==s||r!==0&&p.nodeType!==3||(c=a+r),p.nodeType===3&&(a+=p.nodeValue.length),(g=p.firstChild)!==null;)h=p,p=g;for(;;){if(p===e)break t;if(h===n&&++d===i&&(l=a),h===s&&++u===r&&(c=a),(g=p.nextSibling)!==null)break;p=h,h=p.parentNode}p=g}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(ax={focusedElem:e,selectionRange:n},wp=!1,ge=t;ge!==null;)if(t=ge,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,ge=e;else for(;ge!==null;){t=ge;try{var v=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(v!==null){var x=v.memoizedProps,w=v.memoizedState,b=t.stateNode,y=b.getSnapshotBeforeUpdate(t.elementType===t.type?x:sr(t.type,x),w);b.__reactInternalSnapshotBeforeUpdate=y}break;case 3:var j=t.stateNode.containerInfo;j.nodeType===1?j.textContent="":j.nodeType===9&&j.documentElement&&j.removeChild(j.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(ee(163))}}catch(S){mt(t,t.return,S)}if(e=t.sibling,e!==null){e.return=t.return,ge=e;break}ge=t.return}return v=T1,T1=!1,v}function vc(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var s=i.destroy;i.destroy=void 0,s!==void 0&&kx(t,n,s)}i=i.next}while(i!==r)}}function bf(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Sx(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function mS(e){var t=e.alternate;t!==null&&(e.alternate=null,mS(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Or],delete t[Uc],delete t[dx],delete t[_P],delete t[FP])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function vS(e){return e.tag===5||e.tag===3||e.tag===4}function E1(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||vS(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Cx(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Cp));else if(r!==4&&(e=e.child,e!==null))for(Cx(e,t,n),e=e.sibling;e!==null;)Cx(e,t,n),e=e.sibling}function Tx(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Tx(e,t,n),e=e.sibling;e!==null;)Tx(e,t,n),e=e.sibling}var Vt=null,lr=!1;function $o(e,t,n){for(n=n.child;n!==null;)yS(e,t,n),n=n.sibling}function yS(e,t,n){if(Nr&&typeof Nr.onCommitFiberUnmount=="function")try{Nr.onCommitFiberUnmount(pf,n)}catch{}switch(n.tag){case 5:nn||wa(n,t);case 6:var r=Vt,i=lr;Vt=null,$o(e,t,n),Vt=r,lr=i,Vt!==null&&(lr?(e=Vt,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Vt.removeChild(n.stateNode));break;case 18:Vt!==null&&(lr?(e=Vt,n=n.stateNode,e.nodeType===8?Oh(e.parentNode,n):e.nodeType===1&&Oh(e,n),_c(e)):Oh(Vt,n.stateNode));break;case 4:r=Vt,i=lr,Vt=n.stateNode.containerInfo,lr=!0,$o(e,t,n),Vt=r,lr=i;break;case 0:case 11:case 14:case 15:if(!nn&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,a=s.destroy;s=s.tag,a!==void 0&&(s&2||s&4)&&kx(n,t,a),i=i.next}while(i!==r)}$o(e,t,n);break;case 1:if(!nn&&(wa(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){mt(n,t,l)}$o(e,t,n);break;case 21:$o(e,t,n);break;case 22:n.mode&1?(nn=(r=nn)||n.memoizedState!==null,$o(e,t,n),nn=r):$o(e,t,n);break;default:$o(e,t,n)}}function R1(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new t8),t.forEach(function(r){var i=u8.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}}function or(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];try{var s=e,a=t,l=a;e:for(;l!==null;){switch(l.tag){case 5:Vt=l.stateNode,lr=!1;break e;case 3:Vt=l.stateNode.containerInfo,lr=!0;break e;case 4:Vt=l.stateNode.containerInfo,lr=!0;break e}l=l.return}if(Vt===null)throw Error(ee(160));yS(s,a,i),Vt=null,lr=!1;var c=i.alternate;c!==null&&(c.return=null),i.return=null}catch(d){mt(i,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)bS(t,e),t=t.sibling}function bS(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(or(t,e),Er(e),r&4){try{vc(3,e,e.return),bf(3,e)}catch(x){mt(e,e.return,x)}try{vc(5,e,e.return)}catch(x){mt(e,e.return,x)}}break;case 1:or(t,e),Er(e),r&512&&n!==null&&wa(n,n.return);break;case 5:if(or(t,e),Er(e),r&512&&n!==null&&wa(n,n.return),e.flags&32){var i=e.stateNode;try{Dc(i,"")}catch(x){mt(e,e.return,x)}}if(r&4&&(i=e.stateNode,i!=null)){var s=e.memoizedProps,a=n!==null?n.memoizedProps:s,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&s.type==="radio"&&s.name!=null&&W2(i,s),Yg(l,a);var d=Yg(l,s);for(a=0;a<c.length;a+=2){var u=c[a],p=c[a+1];u==="style"?K2(i,p):u==="dangerouslySetInnerHTML"?q2(i,p):u==="children"?Dc(i,p):Jm(i,u,p,d)}switch(l){case"input":qg(i,s);break;case"textarea":U2(i,s);break;case"select":var h=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!s.multiple;var g=s.value;g!=null?Ea(i,!!s.multiple,g,!1):h!==!!s.multiple&&(s.defaultValue!=null?Ea(i,!!s.multiple,s.defaultValue,!0):Ea(i,!!s.multiple,s.multiple?[]:"",!1))}i[Uc]=s}catch(x){mt(e,e.return,x)}}break;case 6:if(or(t,e),Er(e),r&4){if(e.stateNode===null)throw Error(ee(162));i=e.stateNode,s=e.memoizedProps;try{i.nodeValue=s}catch(x){mt(e,e.return,x)}}break;case 3:if(or(t,e),Er(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{_c(t.containerInfo)}catch(x){mt(e,e.return,x)}break;case 4:or(t,e),Er(e);break;case 13:or(t,e),Er(e),i=e.child,i.flags&8192&&(s=i.memoizedState!==null,i.stateNode.isHidden=s,!s||i.alternate!==null&&i.alternate.memoizedState!==null||(Mv=bt())),r&4&&R1(e);break;case 22:if(u=n!==null&&n.memoizedState!==null,e.mode&1?(nn=(d=nn)||u,or(t,e),nn=d):or(t,e),Er(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!u&&e.mode&1)for(ge=e,u=e.child;u!==null;){for(p=ge=u;ge!==null;){switch(h=ge,g=h.child,h.tag){case 0:case 11:case 14:case 15:vc(4,h,h.return);break;case 1:wa(h,h.return);var v=h.stateNode;if(typeof v.componentWillUnmount=="function"){r=h,n=h.return;try{t=r,v.props=t.memoizedProps,v.state=t.memoizedState,v.componentWillUnmount()}catch(x){mt(r,n,x)}}break;case 5:wa(h,h.return);break;case 22:if(h.memoizedState!==null){I1(p);continue}}g!==null?(g.return=h,ge=g):I1(p)}u=u.sibling}e:for(u=null,p=e;;){if(p.tag===5){if(u===null){u=p;try{i=p.stateNode,d?(s=i.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none"):(l=p.stateNode,c=p.memoizedProps.style,a=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=V2("display",a))}catch(x){mt(e,e.return,x)}}}else if(p.tag===6){if(u===null)try{p.stateNode.nodeValue=d?"":p.memoizedProps}catch(x){mt(e,e.return,x)}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===e)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===e)break e;for(;p.sibling===null;){if(p.return===null||p.return===e)break e;u===p&&(u=null),p=p.return}u===p&&(u=null),p.sibling.return=p.return,p=p.sibling}}break;case 19:or(t,e),Er(e),r&4&&R1(e);break;case 21:break;default:or(t,e),Er(e)}}function Er(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(vS(n)){var r=n;break e}n=n.return}throw Error(ee(160))}switch(r.tag){case 5:var i=r.stateNode;r.flags&32&&(Dc(i,""),r.flags&=-33);var s=E1(e);Tx(e,s,i);break;case 3:case 4:var a=r.stateNode.containerInfo,l=E1(e);Cx(e,l,a);break;default:throw Error(ee(161))}}catch(c){mt(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function r8(e,t,n){ge=e,jS(e)}function jS(e,t,n){for(var r=(e.mode&1)!==0;ge!==null;){var i=ge,s=i.child;if(i.tag===22&&r){var a=i.memoizedState!==null||cu;if(!a){var l=i.alternate,c=l!==null&&l.memoizedState!==null||nn;l=cu;var d=nn;if(cu=a,(nn=c)&&!d)for(ge=i;ge!==null;)a=ge,c=a.child,a.tag===22&&a.memoizedState!==null?M1(i):c!==null?(c.return=a,ge=c):M1(i);for(;s!==null;)ge=s,jS(s),s=s.sibling;ge=i,cu=l,nn=d}P1(e)}else i.subtreeFlags&8772&&s!==null?(s.return=i,ge=s):P1(e)}}function P1(e){for(;ge!==null;){var t=ge;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:nn||bf(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!nn)if(n===null)r.componentDidMount();else{var i=t.elementType===t.type?n.memoizedProps:sr(t.type,n.memoizedProps);r.componentDidUpdate(i,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var s=t.updateQueue;s!==null&&f1(t,s,r);break;case 3:var a=t.updateQueue;if(a!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}f1(t,a,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var d=t.alternate;if(d!==null){var u=d.memoizedState;if(u!==null){var p=u.dehydrated;p!==null&&_c(p)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(ee(163))}nn||t.flags&512&&Sx(t)}catch(h){mt(t,t.return,h)}}if(t===e){ge=null;break}if(n=t.sibling,n!==null){n.return=t.return,ge=n;break}ge=t.return}}function I1(e){for(;ge!==null;){var t=ge;if(t===e){ge=null;break}var n=t.sibling;if(n!==null){n.return=t.return,ge=n;break}ge=t.return}}function M1(e){for(;ge!==null;){var t=ge;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{bf(4,t)}catch(c){mt(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var i=t.return;try{r.componentDidMount()}catch(c){mt(t,i,c)}}var s=t.return;try{Sx(t)}catch(c){mt(t,s,c)}break;case 5:var a=t.return;try{Sx(t)}catch(c){mt(t,a,c)}}}catch(c){mt(t,t.return,c)}if(t===e){ge=null;break}var l=t.sibling;if(l!==null){l.return=t.return,ge=l;break}ge=t.return}}var o8=Math.ceil,Np=ko.ReactCurrentDispatcher,Pv=ko.ReactCurrentOwner,Jn=ko.ReactCurrentBatchConfig,_e=0,_t=null,St=null,Kt=0,Rn=0,ka=Ri(0),Mt=0,Gc=null,Cs=0,jf=0,Iv=0,yc=null,jn=null,Mv=0,rl=1/0,eo=null,$p=!1,Ex=null,hi=null,du=!1,si=null,_p=0,bc=0,Rx=null,ep=-1,tp=0;function un(){return _e&6?bt():ep!==-1?ep:ep=bt()}function gi(e){return e.mode&1?_e&2&&Kt!==0?Kt&-Kt:BP.transition!==null?(tp===0&&(tp=ik()),tp):(e=qe,e!==0||(e=window.event,e=e===void 0?16:pk(e.type)),e):1}function hr(e,t,n,r){if(50<bc)throw bc=0,Rx=null,Error(ee(185));vd(e,n,r),(!(_e&2)||e!==_t)&&(e===_t&&(!(_e&2)&&(jf|=n),Mt===4&&Qo(e,Kt)),Cn(e,r),n===1&&_e===0&&!(t.mode&1)&&(rl=bt()+500,mf&&Pi()))}function Cn(e,t){var n=e.callbackNode;BR(e,t);var r=jp(e,e===_t?Kt:0);if(r===0)n!==null&&zy(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&zy(n),t===1)e.tag===0?zP(L1.bind(null,e)):Mk(L1.bind(null,e)),NP(function(){!(_e&6)&&Pi()}),n=null;else{switch(sk(r)){case 1:n=rv;break;case 4:n=rk;break;case 16:n=bp;break;case 536870912:n=ok;break;default:n=bp}n=PS(n,wS.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function wS(e,t){if(ep=-1,tp=0,_e&6)throw Error(ee(327));var n=e.callbackNode;if(La()&&e.callbackNode!==n)return null;var r=jp(e,e===_t?Kt:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Fp(e,r);else{t=r;var i=_e;_e|=2;var s=SS();(_t!==e||Kt!==t)&&(eo=null,rl=bt()+500,vs(e,t));do try{a8();break}catch(l){kS(e,l)}while(!0);xv(),Np.current=s,_e=i,St!==null?t=0:(_t=null,Kt=0,t=Mt)}if(t!==0){if(t===2&&(i=tx(e),i!==0&&(r=i,t=Px(e,i))),t===1)throw n=Gc,vs(e,0),Qo(e,r),Cn(e,bt()),n;if(t===6)Qo(e,r);else{if(i=e.current.alternate,!(r&30)&&!i8(i)&&(t=Fp(e,r),t===2&&(s=tx(e),s!==0&&(r=s,t=Px(e,s))),t===1))throw n=Gc,vs(e,0),Qo(e,r),Cn(e,bt()),n;switch(e.finishedWork=i,e.finishedLanes=r,t){case 0:case 1:throw Error(ee(345));case 2:Xi(e,jn,eo);break;case 3:if(Qo(e,r),(r&130023424)===r&&(t=Mv+500-bt(),10<t)){if(jp(e,0)!==0)break;if(i=e.suspendedLanes,(i&r)!==r){un(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=cx(Xi.bind(null,e,jn,eo),t);break}Xi(e,jn,eo);break;case 4:if(Qo(e,r),(r&4194240)===r)break;for(t=e.eventTimes,i=-1;0<r;){var a=31-fr(r);s=1<<a,a=t[a],a>i&&(i=a),r&=~s}if(r=i,r=bt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*o8(r/1960))-r,10<r){e.timeoutHandle=cx(Xi.bind(null,e,jn,eo),r);break}Xi(e,jn,eo);break;case 5:Xi(e,jn,eo);break;default:throw Error(ee(329))}}}return Cn(e,bt()),e.callbackNode===n?wS.bind(null,e):null}function Px(e,t){var n=yc;return e.current.memoizedState.isDehydrated&&(vs(e,t).flags|=256),e=Fp(e,t),e!==2&&(t=jn,jn=n,t!==null&&Ix(t)),e}function Ix(e){jn===null?jn=e:jn.push.apply(jn,e)}function i8(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var i=n[r],s=i.getSnapshot;i=i.value;try{if(!xr(s(),i))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Qo(e,t){for(t&=~Iv,t&=~jf,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-fr(t),r=1<<n;e[n]=-1,t&=~r}}function L1(e){if(_e&6)throw Error(ee(327));La();var t=jp(e,0);if(!(t&1))return Cn(e,bt()),null;var n=Fp(e,t);if(e.tag!==0&&n===2){var r=tx(e);r!==0&&(t=r,n=Px(e,r))}if(n===1)throw n=Gc,vs(e,0),Qo(e,t),Cn(e,bt()),n;if(n===6)throw Error(ee(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Xi(e,jn,eo),Cn(e,bt()),null}function Lv(e,t){var n=_e;_e|=1;try{return e(t)}finally{_e=n,_e===0&&(rl=bt()+500,mf&&Pi())}}function Ts(e){si!==null&&si.tag===0&&!(_e&6)&&La();var t=_e;_e|=1;var n=Jn.transition,r=qe;try{if(Jn.transition=null,qe=1,e)return e()}finally{qe=r,Jn.transition=n,_e=t,!(_e&6)&&Pi()}}function Ov(){Rn=ka.current,tt(ka)}function vs(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,AP(n)),St!==null)for(n=St.return;n!==null;){var r=n;switch(fv(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Tp();break;case 3:tl(),tt(kn),tt(rn),wv();break;case 5:jv(r);break;case 4:tl();break;case 13:tt(dt);break;case 19:tt(dt);break;case 10:mv(r.type._context);break;case 22:case 23:Ov()}n=n.return}if(_t=e,St=e=xi(e.current,null),Kt=Rn=t,Mt=0,Gc=null,Iv=jf=Cs=0,jn=yc=null,is!==null){for(t=0;t<is.length;t++)if(n=is[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,s=n.pending;if(s!==null){var a=s.next;s.next=i,r.next=a}n.pending=r}is=null}return e}function kS(e,t){do{var n=St;try{if(xv(),Xu.current=Ap,Dp){for(var r=ut.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}Dp=!1}if(Ss=0,$t=Pt=ut=null,mc=!1,Vc=0,Pv.current=null,n===null||n.return===null){Mt=1,Gc=t,St=null;break}e:{var s=e,a=n.return,l=n,c=t;if(t=Kt,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,u=l,p=u.tag;if(!(u.mode&1)&&(p===0||p===11||p===15)){var h=u.alternate;h?(u.updateQueue=h.updateQueue,u.memoizedState=h.memoizedState,u.lanes=h.lanes):(u.updateQueue=null,u.memoizedState=null)}var g=y1(a);if(g!==null){g.flags&=-257,b1(g,a,l,s,t),g.mode&1&&v1(s,d,t),t=g,c=d;var v=t.updateQueue;if(v===null){var x=new Set;x.add(c),t.updateQueue=x}else v.add(c);break e}else{if(!(t&1)){v1(s,d,t),Dv();break e}c=Error(ee(426))}}else if(st&&l.mode&1){var w=y1(a);if(w!==null){!(w.flags&65536)&&(w.flags|=256),b1(w,a,l,s,t),hv(nl(c,l));break e}}s=c=nl(c,l),Mt!==4&&(Mt=2),yc===null?yc=[s]:yc.push(s),s=a;do{switch(s.tag){case 3:s.flags|=65536,t&=-t,s.lanes|=t;var b=sS(s,c,t);p1(s,b);break e;case 1:l=c;var y=s.type,j=s.stateNode;if(!(s.flags&128)&&(typeof y.getDerivedStateFromError=="function"||j!==null&&typeof j.componentDidCatch=="function"&&(hi===null||!hi.has(j)))){s.flags|=65536,t&=-t,s.lanes|=t;var S=aS(s,l,t);p1(s,S);break e}}s=s.return}while(s!==null)}TS(n)}catch(k){t=k,St===n&&n!==null&&(St=n=n.return);continue}break}while(!0)}function SS(){var e=Np.current;return Np.current=Ap,e===null?Ap:e}function Dv(){(Mt===0||Mt===3||Mt===2)&&(Mt=4),_t===null||!(Cs&268435455)&&!(jf&268435455)||Qo(_t,Kt)}function Fp(e,t){var n=_e;_e|=2;var r=SS();(_t!==e||Kt!==t)&&(eo=null,vs(e,t));do try{s8();break}catch(i){kS(e,i)}while(!0);if(xv(),_e=n,Np.current=r,St!==null)throw Error(ee(261));return _t=null,Kt=0,Mt}function s8(){for(;St!==null;)CS(St)}function a8(){for(;St!==null&&!LR();)CS(St)}function CS(e){var t=RS(e.alternate,e,Rn);e.memoizedProps=e.pendingProps,t===null?TS(e):St=t,Pv.current=null}function TS(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=e8(n,t),n!==null){n.flags&=32767,St=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Mt=6,St=null;return}}else if(n=ZP(n,t,Rn),n!==null){St=n;return}if(t=t.sibling,t!==null){St=t;return}St=t=e}while(t!==null);Mt===0&&(Mt=5)}function Xi(e,t,n){var r=qe,i=Jn.transition;try{Jn.transition=null,qe=1,l8(e,t,n,r)}finally{Jn.transition=i,qe=r}return null}function l8(e,t,n,r){do La();while(si!==null);if(_e&6)throw Error(ee(327));n=e.finishedWork;var i=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(ee(177));e.callbackNode=null,e.callbackPriority=0;var s=n.lanes|n.childLanes;if(WR(e,s),e===_t&&(St=_t=null,Kt=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||du||(du=!0,PS(bp,function(){return La(),null})),s=(n.flags&15990)!==0,n.subtreeFlags&15990||s){s=Jn.transition,Jn.transition=null;var a=qe;qe=1;var l=_e;_e|=4,Pv.current=null,n8(e,n),bS(n,e),RP(ax),wp=!!sx,ax=sx=null,e.current=n,r8(n),OR(),_e=l,qe=a,Jn.transition=s}else e.current=n;if(du&&(du=!1,si=e,_p=i),s=e.pendingLanes,s===0&&(hi=null),NR(n.stateNode),Cn(e,bt()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)i=t[n],r(i.value,{componentStack:i.stack,digest:i.digest});if($p)throw $p=!1,e=Ex,Ex=null,e;return _p&1&&e.tag!==0&&La(),s=e.pendingLanes,s&1?e===Rx?bc++:(bc=0,Rx=e):bc=0,Pi(),null}function La(){if(si!==null){var e=sk(_p),t=Jn.transition,n=qe;try{if(Jn.transition=null,qe=16>e?16:e,si===null)var r=!1;else{if(e=si,si=null,_p=0,_e&6)throw Error(ee(331));var i=_e;for(_e|=4,ge=e.current;ge!==null;){var s=ge,a=s.child;if(ge.flags&16){var l=s.deletions;if(l!==null){for(var c=0;c<l.length;c++){var d=l[c];for(ge=d;ge!==null;){var u=ge;switch(u.tag){case 0:case 11:case 15:vc(8,u,s)}var p=u.child;if(p!==null)p.return=u,ge=p;else for(;ge!==null;){u=ge;var h=u.sibling,g=u.return;if(mS(u),u===d){ge=null;break}if(h!==null){h.return=g,ge=h;break}ge=g}}}var v=s.alternate;if(v!==null){var x=v.child;if(x!==null){v.child=null;do{var w=x.sibling;x.sibling=null,x=w}while(x!==null)}}ge=s}}if(s.subtreeFlags&2064&&a!==null)a.return=s,ge=a;else e:for(;ge!==null;){if(s=ge,s.flags&2048)switch(s.tag){case 0:case 11:case 15:vc(9,s,s.return)}var b=s.sibling;if(b!==null){b.return=s.return,ge=b;break e}ge=s.return}}var y=e.current;for(ge=y;ge!==null;){a=ge;var j=a.child;if(a.subtreeFlags&2064&&j!==null)j.return=a,ge=j;else e:for(a=y;ge!==null;){if(l=ge,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:bf(9,l)}}catch(k){mt(l,l.return,k)}if(l===a){ge=null;break e}var S=l.sibling;if(S!==null){S.return=l.return,ge=S;break e}ge=l.return}}if(_e=i,Pi(),Nr&&typeof Nr.onPostCommitFiberRoot=="function")try{Nr.onPostCommitFiberRoot(pf,e)}catch{}r=!0}return r}finally{qe=n,Jn.transition=t}}return!1}function O1(e,t,n){t=nl(n,t),t=sS(e,t,1),e=fi(e,t,1),t=un(),e!==null&&(vd(e,1,t),Cn(e,t))}function mt(e,t,n){if(e.tag===3)O1(e,e,n);else for(;t!==null;){if(t.tag===3){O1(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(hi===null||!hi.has(r))){e=nl(n,e),e=aS(t,e,1),t=fi(t,e,1),e=un(),t!==null&&(vd(t,1,e),Cn(t,e));break}}t=t.return}}function c8(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=un(),e.pingedLanes|=e.suspendedLanes&n,_t===e&&(Kt&n)===n&&(Mt===4||Mt===3&&(Kt&130023424)===Kt&&500>bt()-Mv?vs(e,0):Iv|=n),Cn(e,t)}function ES(e,t){t===0&&(e.mode&1?(t=eu,eu<<=1,!(eu&130023424)&&(eu=4194304)):t=1);var n=un();e=vo(e,t),e!==null&&(vd(e,t,n),Cn(e,n))}function d8(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),ES(e,n)}function u8(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(ee(314))}r!==null&&r.delete(t),ES(e,n)}var RS;RS=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||kn.current)wn=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return wn=!1,JP(e,t,n);wn=!!(e.flags&131072)}else wn=!1,st&&t.flags&1048576&&Lk(t,Pp,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Zu(e,t),e=t.pendingProps;var i=Ja(t,rn.current);Ma(t,n),i=Sv(null,t,r,e,i,n);var s=Cv();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Sn(r)?(s=!0,Ep(t)):s=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,yv(t),i.updater=yf,t.stateNode=i,i._reactInternals=t,xx(t,r,e,n),t=yx(null,t,r,!0,s,n)):(t.tag=0,st&&s&&pv(t),cn(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Zu(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=f8(r),e=sr(r,e),i){case 0:t=vx(null,t,r,e,n);break e;case 1:t=k1(null,t,r,e,n);break e;case 11:t=j1(null,t,r,e,n);break e;case 14:t=w1(null,t,r,sr(r.type,e),n);break e}throw Error(ee(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:sr(r,i),vx(e,t,r,i,n);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:sr(r,i),k1(e,t,r,i,n);case 3:e:{if(uS(t),e===null)throw Error(ee(387));r=t.pendingProps,s=t.memoizedState,i=s.element,_k(e,t),Lp(t,r,null,n);var a=t.memoizedState;if(r=a.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){i=nl(Error(ee(423)),t),t=S1(e,t,r,n,i);break e}else if(r!==i){i=nl(Error(ee(424)),t),t=S1(e,t,r,n,i);break e}else for(Dn=pi(t.stateNode.containerInfo.firstChild),An=t,st=!0,dr=null,n=Nk(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Za(),r===i){t=yo(e,t,n);break e}cn(e,t,r,n)}t=t.child}return t;case 5:return Fk(t),e===null&&fx(t),r=t.type,i=t.pendingProps,s=e!==null?e.memoizedProps:null,a=i.children,lx(r,i)?a=null:s!==null&&lx(r,s)&&(t.flags|=32),dS(e,t),cn(e,t,a,n),t.child;case 6:return e===null&&fx(t),null;case 13:return pS(e,t,n);case 4:return bv(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=el(t,null,r,n):cn(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:sr(r,i),j1(e,t,r,i,n);case 7:return cn(e,t,t.pendingProps,n),t.child;case 8:return cn(e,t,t.pendingProps.children,n),t.child;case 12:return cn(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,s=t.memoizedProps,a=i.value,Ge(Ip,r._currentValue),r._currentValue=a,s!==null)if(xr(s.value,a)){if(s.children===i.children&&!kn.current){t=yo(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var l=s.dependencies;if(l!==null){a=s.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(s.tag===1){c=fo(-1,n&-n),c.tag=2;var d=s.updateQueue;if(d!==null){d=d.shared;var u=d.pending;u===null?c.next=c:(c.next=u.next,u.next=c),d.pending=c}}s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),hx(s.return,n,t),l.lanes|=n;break}c=c.next}}else if(s.tag===10)a=s.type===t.type?null:s.child;else if(s.tag===18){if(a=s.return,a===null)throw Error(ee(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),hx(a,n,t),a=s.sibling}else a=s.child;if(a!==null)a.return=s;else for(a=s;a!==null;){if(a===t){a=null;break}if(s=a.sibling,s!==null){s.return=a.return,a=s;break}a=a.return}s=a}cn(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,Ma(t,n),i=Zn(i),r=r(i),t.flags|=1,cn(e,t,r,n),t.child;case 14:return r=t.type,i=sr(r,t.pendingProps),i=sr(r.type,i),w1(e,t,r,i,n);case 15:return lS(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:sr(r,i),Zu(e,t),t.tag=1,Sn(r)?(e=!0,Ep(t)):e=!1,Ma(t,n),iS(t,r,i),xx(t,r,i,n),yx(null,t,r,!0,e,n);case 19:return fS(e,t,n);case 22:return cS(e,t,n)}throw Error(ee(156,t.tag))};function PS(e,t){return nk(e,t)}function p8(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Xn(e,t,n,r){return new p8(e,t,n,r)}function Av(e){return e=e.prototype,!(!e||!e.isReactComponent)}function f8(e){if(typeof e=="function")return Av(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ev)return 11;if(e===tv)return 14}return 2}function xi(e,t){var n=e.alternate;return n===null?(n=Xn(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function np(e,t,n,r,i,s){var a=2;if(r=e,typeof e=="function")Av(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case fa:return ys(n.children,i,s,t);case Zm:a=8,i|=8;break;case zg:return e=Xn(12,n,t,i|2),e.elementType=zg,e.lanes=s,e;case Bg:return e=Xn(13,n,t,i),e.elementType=Bg,e.lanes=s,e;case Wg:return e=Xn(19,n,t,i),e.elementType=Wg,e.lanes=s,e;case F2:return wf(n,i,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case $2:a=10;break e;case _2:a=9;break e;case ev:a=11;break e;case tv:a=14;break e;case Ho:a=16,r=null;break e}throw Error(ee(130,e==null?e:typeof e,""))}return t=Xn(a,n,t,i),t.elementType=e,t.type=r,t.lanes=s,t}function ys(e,t,n,r){return e=Xn(7,e,r,t),e.lanes=n,e}function wf(e,t,n,r){return e=Xn(22,e,r,t),e.elementType=F2,e.lanes=n,e.stateNode={isHidden:!1},e}function Bh(e,t,n){return e=Xn(6,e,null,t),e.lanes=n,e}function Wh(e,t,n){return t=Xn(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function h8(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=wh(0),this.expirationTimes=wh(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=wh(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Nv(e,t,n,r,i,s,a,l,c){return e=new h8(e,t,n,l,c),t===1?(t=1,s===!0&&(t|=8)):t=0,s=Xn(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},yv(s),e}function g8(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:pa,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function IS(e){if(!e)return ji;e=e._reactInternals;e:{if(As(e)!==e||e.tag!==1)throw Error(ee(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Sn(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(ee(171))}if(e.tag===1){var n=e.type;if(Sn(n))return Ik(e,n,t)}return t}function MS(e,t,n,r,i,s,a,l,c){return e=Nv(n,r,!0,e,i,s,a,l,c),e.context=IS(null),n=e.current,r=un(),i=gi(n),s=fo(r,i),s.callback=t??null,fi(n,s,i),e.current.lanes=i,vd(e,i,r),Cn(e,r),e}function kf(e,t,n,r){var i=t.current,s=un(),a=gi(i);return n=IS(n),t.context===null?t.context=n:t.pendingContext=n,t=fo(s,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=fi(i,t,a),e!==null&&(hr(e,i,a,s),Yu(e,i,a)),a}function zp(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function D1(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function $v(e,t){D1(e,t),(e=e.alternate)&&D1(e,t)}function x8(){return null}var LS=typeof reportError=="function"?reportError:function(e){console.error(e)};function _v(e){this._internalRoot=e}Sf.prototype.render=_v.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(ee(409));kf(e,t,null,null)};Sf.prototype.unmount=_v.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Ts(function(){kf(null,e,null,null)}),t[mo]=null}};function Sf(e){this._internalRoot=e}Sf.prototype.unstable_scheduleHydration=function(e){if(e){var t=ck();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ko.length&&t!==0&&t<Ko[n].priority;n++);Ko.splice(n,0,e),n===0&&uk(e)}};function Fv(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Cf(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function A1(){}function m8(e,t,n,r,i){if(i){if(typeof r=="function"){var s=r;r=function(){var d=zp(a);s.call(d)}}var a=MS(t,r,e,0,null,!1,!1,"",A1);return e._reactRootContainer=a,e[mo]=a.current,Bc(e.nodeType===8?e.parentNode:e),Ts(),a}for(;i=e.lastChild;)e.removeChild(i);if(typeof r=="function"){var l=r;r=function(){var d=zp(c);l.call(d)}}var c=Nv(e,0,!1,null,null,!1,!1,"",A1);return e._reactRootContainer=c,e[mo]=c.current,Bc(e.nodeType===8?e.parentNode:e),Ts(function(){kf(t,c,n,r)}),c}function Tf(e,t,n,r,i){var s=n._reactRootContainer;if(s){var a=s;if(typeof i=="function"){var l=i;i=function(){var c=zp(a);l.call(c)}}kf(t,a,e,i)}else a=m8(n,t,e,i,r);return zp(a)}ak=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=rc(t.pendingLanes);n!==0&&(ov(t,n|1),Cn(t,bt()),!(_e&6)&&(rl=bt()+500,Pi()))}break;case 13:Ts(function(){var r=vo(e,1);if(r!==null){var i=un();hr(r,e,1,i)}}),$v(e,1)}};iv=function(e){if(e.tag===13){var t=vo(e,134217728);if(t!==null){var n=un();hr(t,e,134217728,n)}$v(e,134217728)}};lk=function(e){if(e.tag===13){var t=gi(e),n=vo(e,t);if(n!==null){var r=un();hr(n,e,t,r)}$v(e,t)}};ck=function(){return qe};dk=function(e,t){var n=qe;try{return qe=e,t()}finally{qe=n}};Jg=function(e,t,n){switch(t){case"input":if(qg(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=xf(r);if(!i)throw Error(ee(90));B2(r),qg(r,i)}}}break;case"textarea":U2(e,n);break;case"select":t=n.value,t!=null&&Ea(e,!!n.multiple,t,!1)}};Y2=Lv;X2=Ts;var v8={usingClientEntryPoint:!1,Events:[bd,ma,xf,Q2,G2,Lv]},Hl={findFiberByHostInstance:os,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},y8={bundleType:Hl.bundleType,version:Hl.version,rendererPackageName:Hl.rendererPackageName,rendererConfig:Hl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:ko.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=ek(e),e===null?null:e.stateNode},findFiberByHostInstance:Hl.findFiberByHostInstance||x8,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var uu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!uu.isDisabled&&uu.supportsFiber)try{pf=uu.inject(y8),Nr=uu}catch{}}Bn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=v8;Bn.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Fv(t))throw Error(ee(200));return g8(e,t,null,n)};Bn.createRoot=function(e,t){if(!Fv(e))throw Error(ee(299));var n=!1,r="",i=LS;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError)),t=Nv(e,1,!1,null,null,n,!1,r,i),e[mo]=t.current,Bc(e.nodeType===8?e.parentNode:e),new _v(t)};Bn.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(ee(188)):(e=Object.keys(e).join(","),Error(ee(268,e)));return e=ek(t),e=e===null?null:e.stateNode,e};Bn.flushSync=function(e){return Ts(e)};Bn.hydrate=function(e,t,n){if(!Cf(t))throw Error(ee(200));return Tf(null,e,t,!0,n)};Bn.hydrateRoot=function(e,t,n){if(!Fv(e))throw Error(ee(405));var r=n!=null&&n.hydratedSources||null,i=!1,s="",a=LS;if(n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(s=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=MS(t,null,e,1,n??null,i,!1,s,a),e[mo]=t.current,Bc(e),r)for(e=0;e<r.length;e++)n=r[e],i=n._getVersion,i=i(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,i]:t.mutableSourceEagerHydrationData.push(n,i);return new Sf(t)};Bn.render=function(e,t,n){if(!Cf(t))throw Error(ee(200));return Tf(null,e,t,!1,n)};Bn.unmountComponentAtNode=function(e){if(!Cf(e))throw Error(ee(40));return e._reactRootContainer?(Ts(function(){Tf(null,null,e,!1,function(){e._reactRootContainer=null,e[mo]=null})}),!0):!1};Bn.unstable_batchedUpdates=Lv;Bn.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Cf(n))throw Error(ee(200));if(e==null||e._reactInternals===void 0)throw Error(ee(38));return Tf(e,t,n,!1,r)};Bn.version="18.3.1-next-f1338f8080-20240426";function OS(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(OS)}catch(e){console.error(e)}}OS(),O2.exports=Bn;var Ns=O2.exports;const b8=j2(Ns),j8=b2({__proto__:null,default:b8},[Ns]);var DS,N1=Ns;DS=N1.createRoot,N1.hydrateRoot;var wl=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},cs,Yo,_a,c2,w8=(c2=class extends wl{constructor(){super();xe(this,cs);xe(this,Yo);xe(this,_a);le(this,_a,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){M(this,Yo)||this.setEventListener(M(this,_a))}onUnsubscribe(){var t;this.hasListeners()||((t=M(this,Yo))==null||t.call(this),le(this,Yo,void 0))}setEventListener(t){var n;le(this,_a,t),(n=M(this,Yo))==null||n.call(this),le(this,Yo,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){M(this,cs)!==t&&(le(this,cs,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof M(this,cs)=="boolean"?M(this,cs):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},cs=new WeakMap,Yo=new WeakMap,_a=new WeakMap,c2),zv=new w8,k8={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Xo,qm,d2,S8=(d2=class{constructor(){xe(this,Xo,k8);xe(this,qm,!1)}setTimeoutProvider(e){le(this,Xo,e)}setTimeout(e,t){return M(this,Xo).setTimeout(e,t)}clearTimeout(e){M(this,Xo).clearTimeout(e)}setInterval(e,t){return M(this,Xo).setInterval(e,t)}clearInterval(e){M(this,Xo).clearInterval(e)}},Xo=new WeakMap,qm=new WeakMap,d2),as=new S8;function C8(e){setTimeout(e,0)}var T8=typeof window>"u"||"Deno"in globalThis;function dn(){}function E8(e,t){return typeof e=="function"?e(t):e}function Mx(e){return typeof e=="number"&&e>=0&&e!==1/0}function AS(e,t){return Math.max(e+(t||0)-Date.now(),0)}function mi(e,t){return typeof e=="function"?e(t):e}function In(e,t){return typeof e=="function"?e(t):e}function $1(e,t){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:a,stale:l}=e;if(a){if(r){if(t.queryHash!==Bv(a,t.options))return!1}else if(!Yc(t.queryKey,a))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||i&&i!==t.state.fetchStatus||s&&!s(t))}function _1(e,t){const{exact:n,status:r,predicate:i,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(n){if(Es(t.options.mutationKey)!==Es(s))return!1}else if(!Yc(t.options.mutationKey,s))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Bv(e,t){return((t==null?void 0:t.queryKeyHashFn)||Es)(e)}function Es(e){return JSON.stringify(e,(t,n)=>Lx(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function Yc(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Yc(e[n],t[n])):!1}var R8=Object.prototype.hasOwnProperty;function NS(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=F1(e)&&F1(t);if(!r&&!(Lx(e)&&Lx(t)))return t;const s=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),l=a.length,c=r?new Array(l):{};let d=0;for(let u=0;u<l;u++){const p=r?u:a[u],h=e[p],g=t[p];if(h===g){c[p]=h,(r?u<s:R8.call(e,p))&&d++;continue}if(h===null||g===null||typeof h!="object"||typeof g!="object"){c[p]=g;continue}const v=NS(h,g,n+1);c[p]=v,v===h&&d++}return s===l&&d===s?e:c}function Bp(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function F1(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Lx(e){if(!z1(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!z1(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function z1(e){return Object.prototype.toString.call(e)==="[object Object]"}function P8(e){return new Promise(t=>{as.setTimeout(t,e)})}function Ox(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?NS(e,t):t}function I8(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function M8(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var bo=Symbol();function $S(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===bo?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Wv(e,t){return typeof e=="function"?e(...t):!!e}function L8(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??(i=t()),r||(r=!0,i.aborted?n():i.addEventListener("abort",n,{once:!0})),i)}),e}var Xc=(()=>{let e=()=>T8;return{isServer(){return e()},setIsServer(t){e=t}}})();function Dx(){let e,t;const n=new Promise((i,s)=>{e=i,t=s});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),e(i)},n.reject=i=>{r({status:"rejected",reason:i}),t(i)},n}var O8=C8;function D8(){let e=[],t=0,n=l=>{l()},r=l=>{l()},i=O8;const s=l=>{t?e.push(l):i(()=>{n(l)})},a=()=>{const l=e;e=[],l.length&&i(()=>{r(()=>{l.forEach(c=>{n(c)})})})};return{batch:l=>{let c;t++;try{c=l()}finally{t--,t||a()}return c},batchCalls:l=>(...c)=>{s(()=>{l(...c)})},schedule:s,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{i=l}}}var It=D8(),Fa,Jo,za,u2,A8=(u2=class extends wl{constructor(){super();xe(this,Fa,!0);xe(this,Jo);xe(this,za);le(this,za,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){M(this,Jo)||this.setEventListener(M(this,za))}onUnsubscribe(){var t;this.hasListeners()||((t=M(this,Jo))==null||t.call(this),le(this,Jo,void 0))}setEventListener(t){var n;le(this,za,t),(n=M(this,Jo))==null||n.call(this),le(this,Jo,t(this.setOnline.bind(this)))}setOnline(t){M(this,Fa)!==t&&(le(this,Fa,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return M(this,Fa)}},Fa=new WeakMap,Jo=new WeakMap,za=new WeakMap,u2),Wp=new A8;function N8(e){return Math.min(1e3*2**e,3e4)}function _S(e){return(e??"online")==="online"?Wp.isOnline():!0}var Ax=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function FS(e){let t=!1,n=0,r;const i=Dx(),s=()=>i.status!=="pending",a=x=>{var w;if(!s()){const b=new Ax(x);h(b),(w=e.onCancel)==null||w.call(e,b)}},l=()=>{t=!0},c=()=>{t=!1},d=()=>zv.isFocused()&&(e.networkMode==="always"||Wp.isOnline())&&e.canRun(),u=()=>_S(e.networkMode)&&e.canRun(),p=x=>{s()||(r==null||r(),i.resolve(x))},h=x=>{s()||(r==null||r(),i.reject(x))},g=()=>new Promise(x=>{var w;r=b=>{(s()||d())&&x(b)},(w=e.onPause)==null||w.call(e)}).then(()=>{var x;r=void 0,s()||(x=e.onContinue)==null||x.call(e)}),v=()=>{if(s())return;let x;const w=n===0?e.initialPromise:void 0;try{x=w??e.fn()}catch(b){x=Promise.reject(b)}Promise.resolve(x).then(p).catch(b=>{var E;if(s())return;const y=e.retry??(Xc.isServer()?0:3),j=e.retryDelay??N8,S=typeof j=="function"?j(n,b):j,k=y===!0||typeof y=="number"&&n<y||typeof y=="function"&&y(n,b);if(t||!k){h(b);return}n++,(E=e.onFail)==null||E.call(e,n,b),P8(S).then(()=>d()?void 0:g()).then(()=>{t?h(b):v()})})};return{promise:i,status:()=>i.status,cancel:a,continue:()=>(r==null||r(),i),cancelRetry:l,continueRetry:c,canStart:u,start:()=>(u()?v():g().then(v),i)}}var ds,p2,zS=(p2=class{constructor(){xe(this,ds)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Mx(this.gcTime)&&le(this,ds,as.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Xc.isServer()?1/0:5*60*1e3))}clearGcTimeout(){M(this,ds)!==void 0&&(as.clearTimeout(M(this,ds)),le(this,ds,void 0))}},ds=new WeakMap,p2);function $8(e){return{onFetch:(t,n)=>{var u,p,h,g,v;const r=t.options,i=(h=(p=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:p.fetchMore)==null?void 0:h.direction,s=((g=t.state.data)==null?void 0:g.pages)||[],a=((v=t.state.data)==null?void 0:v.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const d=async()=>{let x=!1;const w=j=>{L8(j,()=>t.signal,()=>x=!0)},b=$S(t.options,t.fetchOptions),y=async(j,S,k)=>{if(x)return Promise.reject(t.signal.reason);if(S==null&&j.pages.length)return Promise.resolve(j);const C=(()=>{const _={client:t.client,queryKey:t.queryKey,pageParam:S,direction:k?"backward":"forward",meta:t.options.meta};return w(_),_})(),R=await b(C),{maxPages:P}=t.options,L=k?M8:I8;return{pages:L(j.pages,R,P),pageParams:L(j.pageParams,S,P)}};if(i&&s.length){const j=i==="backward",S=j?_8:B1,k={pages:s,pageParams:a},E=S(r,k);l=await y(k,E,j)}else{const j=e??s.length;do{const S=c===0?a[0]??r.initialPageParam:B1(r,l);if(c>0&&S==null)break;l=await y(l,S),c++}while(c<j)}return l};t.options.persister?t.fetchFn=()=>{var x,w;return(w=(x=t.options).persister)==null?void 0:w.call(x,d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=d}}}function B1(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function _8(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var Ba,us,Wa,Kn,ps,Nt,pd,fs,Pn,BS,Jr,f2,F8=(f2=class extends zS{constructor(t){super();xe(this,Pn);xe(this,Ba);xe(this,us);xe(this,Wa);xe(this,Kn);xe(this,ps);xe(this,Nt);xe(this,pd);xe(this,fs);le(this,fs,!1),le(this,pd,t.defaultOptions),this.setOptions(t.options),this.observers=[],le(this,ps,t.client),le(this,Kn,M(this,ps).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,le(this,us,U1(this.options)),this.state=t.state??M(this,us),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return M(this,Ba)}get promise(){var t;return(t=M(this,Nt))==null?void 0:t.promise}setOptions(t){if(this.options={...M(this,pd),...t},t!=null&&t._type&&le(this,Ba,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=U1(this.options);n.data!==void 0&&(this.setState(W1(n.data,n.dataUpdatedAt)),le(this,us,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&M(this,Kn).remove(this)}setData(t,n){const r=Ox(this.state.data,t,this.options);return Se(this,Pn,Jr).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t){Se(this,Pn,Jr).call(this,{type:"setState",state:t})}cancel(t){var r,i;const n=(r=M(this,Nt))==null?void 0:r.promise;return(i=M(this,Nt))==null||i.cancel(t),n?n.then(dn).catch(dn):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return M(this,us)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>In(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===bo||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>mi(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!AS(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=M(this,Nt))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=M(this,Nt))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),M(this,Kn).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(M(this,Nt)&&(M(this,fs)||Se(this,Pn,BS).call(this)?M(this,Nt).cancel({revert:!0}):M(this,Nt).cancelRetry()),this.scheduleGc()),M(this,Kn).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Se(this,Pn,Jr).call(this,{type:"invalidate"})}async fetch(t,n){var d,u,p,h,g,v,x,w,b,y,j;if(this.state.fetchStatus!=="idle"&&((d=M(this,Nt))==null?void 0:d.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(M(this,Nt))return M(this,Nt).continueRetry(),M(this,Nt).promise}if(t&&this.setOptions(t),!this.options.queryFn){const S=this.observers.find(k=>k.options.queryFn);S&&this.setOptions(S.options)}const r=new AbortController,i=S=>{Object.defineProperty(S,"signal",{enumerable:!0,get:()=>(le(this,fs,!0),r.signal)})},s=()=>{const S=$S(this.options,n),E=(()=>{const C={client:M(this,ps),queryKey:this.queryKey,meta:this.meta};return i(C),C})();return le(this,fs,!1),this.options.persister?this.options.persister(S,E,this):S(E)},l=(()=>{const S={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:M(this,ps),state:this.state,fetchFn:s};return i(S),S})(),c=M(this,Ba)==="infinite"?$8(this.options.pages):this.options.behavior;c==null||c.onFetch(l,this),le(this,Wa,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=l.fetchOptions)==null?void 0:u.meta))&&Se(this,Pn,Jr).call(this,{type:"fetch",meta:(p=l.fetchOptions)==null?void 0:p.meta}),le(this,Nt,FS({initialPromise:n==null?void 0:n.initialPromise,fn:l.fetchFn,onCancel:S=>{S instanceof Ax&&S.revert&&this.setState({...M(this,Wa),fetchStatus:"idle"}),r.abort()},onFail:(S,k)=>{Se(this,Pn,Jr).call(this,{type:"failed",failureCount:S,error:k})},onPause:()=>{Se(this,Pn,Jr).call(this,{type:"pause"})},onContinue:()=>{Se(this,Pn,Jr).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const S=await M(this,Nt).start();if(S===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(S),(g=(h=M(this,Kn).config).onSuccess)==null||g.call(h,S,this),(x=(v=M(this,Kn).config).onSettled)==null||x.call(v,S,this.state.error,this),S}catch(S){if(S instanceof Ax){if(S.silent)return M(this,Nt).promise;if(S.revert){if(this.state.data===void 0)throw S;return this.state.data}}throw Se(this,Pn,Jr).call(this,{type:"error",error:S}),(b=(w=M(this,Kn).config).onError)==null||b.call(w,S,this),(j=(y=M(this,Kn).config).onSettled)==null||j.call(y,this.state.data,S,this),S}finally{this.scheduleGc()}}},Ba=new WeakMap,us=new WeakMap,Wa=new WeakMap,Kn=new WeakMap,ps=new WeakMap,Nt=new WeakMap,pd=new WeakMap,fs=new WeakMap,Pn=new WeakSet,BS=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Jr=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...WS(r.data,this.options),fetchMeta:t.meta??null};case"success":const i={...r,...W1(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return le(this,Wa,t.manual?i:void 0),i;case"error":const s=t.error;return{...r,error:s,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),It.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),M(this,Kn).notify({query:this,type:"updated",action:t})})},f2);function WS(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:_S(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function W1(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function U1(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var xn,Le,fd,ln,hs,Ua,ro,Zo,hd,Ha,qa,gs,xs,ei,Va,ze,ic,Nx,$x,_x,Fx,zx,Bx,Wx,US,h2,z8=(h2=class extends wl{constructor(t,n){super();xe(this,ze);xe(this,xn);xe(this,Le);xe(this,fd);xe(this,ln);xe(this,hs);xe(this,Ua);xe(this,ro);xe(this,Zo);xe(this,hd);xe(this,Ha);xe(this,qa);xe(this,gs);xe(this,xs);xe(this,ei);xe(this,Va,new Set);this.options=n,le(this,xn,t),le(this,Zo,null),le(this,ro,Dx()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(M(this,Le).addObserver(this),H1(M(this,Le),this.options)?Se(this,ze,ic).call(this):this.updateResult(),Se(this,ze,Fx).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ux(M(this,Le),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ux(M(this,Le),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Se(this,ze,zx).call(this),Se(this,ze,Bx).call(this),M(this,Le).removeObserver(this)}setOptions(t){const n=this.options,r=M(this,Le);if(this.options=M(this,xn).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof In(this.options.enabled,M(this,Le))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Se(this,ze,Wx).call(this),M(this,Le).setOptions(this.options),n._defaulted&&!Bp(this.options,n)&&M(this,xn).getQueryCache().notify({type:"observerOptionsUpdated",query:M(this,Le),observer:this});const i=this.hasListeners();i&&q1(M(this,Le),r,this.options,n)&&Se(this,ze,ic).call(this),this.updateResult(),i&&(M(this,Le)!==r||In(this.options.enabled,M(this,Le))!==In(n.enabled,M(this,Le))||mi(this.options.staleTime,M(this,Le))!==mi(n.staleTime,M(this,Le)))&&Se(this,ze,Nx).call(this);const s=Se(this,ze,$x).call(this);i&&(M(this,Le)!==r||In(this.options.enabled,M(this,Le))!==In(n.enabled,M(this,Le))||s!==M(this,ei))&&Se(this,ze,_x).call(this,s)}getOptimisticResult(t){const n=M(this,xn).getQueryCache().build(M(this,xn),t),r=this.createResult(n,t);return W8(this,r)&&(le(this,ln,r),le(this,Ua,this.options),le(this,hs,M(this,Le).state)),r}getCurrentResult(){return M(this,ln)}trackResult(t,n){return new Proxy(t,{get:(r,i)=>(this.trackProp(i),n==null||n(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&M(this,ro).status==="pending"&&M(this,ro).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,i))})}trackProp(t){M(this,Va).add(t)}getCurrentQuery(){return M(this,Le)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=M(this,xn).defaultQueryOptions(t),r=M(this,xn).getQueryCache().build(M(this,xn),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return Se(this,ze,ic).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),M(this,ln)))}createResult(t,n){var P;const r=M(this,Le),i=this.options,s=M(this,ln),a=M(this,hs),l=M(this,Ua),d=t!==r?t.state:M(this,fd),{state:u}=t;let p={...u},h=!1,g;if(n._optimisticResults){const L=this.hasListeners(),_=!L&&H1(t,n),U=L&&q1(t,r,n,i);(_||U)&&(p={...p,...WS(u.data,t.options)}),n._optimisticResults==="isRestoring"&&(p.fetchStatus="idle")}let{error:v,errorUpdatedAt:x,status:w}=p;g=p.data;let b=!1;if(n.placeholderData!==void 0&&g===void 0&&w==="pending"){let L;s!=null&&s.isPlaceholderData&&n.placeholderData===(l==null?void 0:l.placeholderData)?(L=s.data,b=!0):L=typeof n.placeholderData=="function"?n.placeholderData((P=M(this,qa))==null?void 0:P.state.data,M(this,qa)):n.placeholderData,L!==void 0&&(w="success",g=Ox(s==null?void 0:s.data,L,n),h=!0)}if(n.select&&g!==void 0&&!b)if(s&&g===(a==null?void 0:a.data)&&n.select===M(this,hd))g=M(this,Ha);else try{le(this,hd,n.select),g=n.select(g),g=Ox(s==null?void 0:s.data,g,n),le(this,Ha,g),le(this,Zo,null)}catch(L){le(this,Zo,L)}M(this,Zo)&&(v=M(this,Zo),g=M(this,Ha),x=Date.now(),w="error");const y=p.fetchStatus==="fetching",j=w==="pending",S=w==="error",k=j&&y,E=g!==void 0,R={status:w,fetchStatus:p.fetchStatus,isPending:j,isSuccess:w==="success",isError:S,isInitialLoading:k,isLoading:k,data:g,dataUpdatedAt:p.dataUpdatedAt,error:v,errorUpdatedAt:x,failureCount:p.fetchFailureCount,failureReason:p.fetchFailureReason,errorUpdateCount:p.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:p.dataUpdateCount>d.dataUpdateCount||p.errorUpdateCount>d.errorUpdateCount,isFetching:y,isRefetching:y&&!j,isLoadingError:S&&!E,isPaused:p.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:S&&E,isStale:Uv(t,n),refetch:this.refetch,promise:M(this,ro),isEnabled:In(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const L=R.data!==void 0,_=R.status==="error"&&!L,U=W=>{_?W.reject(R.error):L&&W.resolve(R.data)},K=()=>{const W=le(this,ro,R.promise=Dx());U(W)},$=M(this,ro);switch($.status){case"pending":t.queryHash===r.queryHash&&U($);break;case"fulfilled":(_||R.data!==$.value)&&K();break;case"rejected":(!_||R.error!==$.reason)&&K();break}}return R}updateResult(){const t=M(this,ln),n=this.createResult(M(this,Le),this.options);if(le(this,hs,M(this,Le).state),le(this,Ua,this.options),M(this,hs).data!==void 0&&le(this,qa,M(this,Le)),Bp(n,t))return;le(this,ln,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:i}=this.options,s=typeof i=="function"?i():i;if(s==="all"||!s&&!M(this,Va).size)return!0;const a=new Set(s??M(this,Va));return this.options.throwOnError&&a.add("error"),Object.keys(M(this,ln)).some(l=>{const c=l;return M(this,ln)[c]!==t[c]&&a.has(c)})};Se(this,ze,US).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Se(this,ze,Fx).call(this)}},xn=new WeakMap,Le=new WeakMap,fd=new WeakMap,ln=new WeakMap,hs=new WeakMap,Ua=new WeakMap,ro=new WeakMap,Zo=new WeakMap,hd=new WeakMap,Ha=new WeakMap,qa=new WeakMap,gs=new WeakMap,xs=new WeakMap,ei=new WeakMap,Va=new WeakMap,ze=new WeakSet,ic=function(t){Se(this,ze,Wx).call(this);let n=M(this,Le).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(dn)),n},Nx=function(){Se(this,ze,zx).call(this);const t=mi(this.options.staleTime,M(this,Le));if(Xc.isServer()||M(this,ln).isStale||!Mx(t))return;const r=AS(M(this,ln).dataUpdatedAt,t)+1;le(this,gs,as.setTimeout(()=>{M(this,ln).isStale||this.updateResult()},r))},$x=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(M(this,Le)):this.options.refetchInterval)??!1},_x=function(t){Se(this,ze,Bx).call(this),le(this,ei,t),!(Xc.isServer()||In(this.options.enabled,M(this,Le))===!1||!Mx(M(this,ei))||M(this,ei)===0)&&le(this,xs,as.setInterval(()=>{(this.options.refetchIntervalInBackground||zv.isFocused())&&Se(this,ze,ic).call(this)},M(this,ei)))},Fx=function(){Se(this,ze,Nx).call(this),Se(this,ze,_x).call(this,Se(this,ze,$x).call(this))},zx=function(){M(this,gs)!==void 0&&(as.clearTimeout(M(this,gs)),le(this,gs,void 0))},Bx=function(){M(this,xs)!==void 0&&(as.clearInterval(M(this,xs)),le(this,xs,void 0))},Wx=function(){const t=M(this,xn).getQueryCache().build(M(this,xn),this.options);if(t===M(this,Le))return;const n=M(this,Le);le(this,Le,t),le(this,fd,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},US=function(t){It.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(M(this,ln))}),M(this,xn).getQueryCache().notify({query:M(this,Le),type:"observerResultsUpdated"})})},h2);function B8(e,t){return In(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&In(t.retryOnMount,e)===!1)}function H1(e,t){return B8(e,t)||e.state.data!==void 0&&Ux(e,t,t.refetchOnMount)}function Ux(e,t,n){if(In(t.enabled,e)!==!1&&mi(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Uv(e,t)}return!1}function q1(e,t,n,r){return(e!==t||In(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Uv(e,n)}function Uv(e,t){return In(t.enabled,e)!==!1&&e.isStaleByTime(mi(t.staleTime,e))}function W8(e,t){return!Bp(e.getCurrentResult(),t)}var gd,Ir,en,ms,Mr,zo,g2,U8=(g2=class extends zS{constructor(t){super();xe(this,Mr);xe(this,gd);xe(this,Ir);xe(this,en);xe(this,ms);le(this,gd,t.client),this.mutationId=t.mutationId,le(this,en,t.mutationCache),le(this,Ir,[]),this.state=t.state||HS(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){M(this,Ir).includes(t)||(M(this,Ir).push(t),this.clearGcTimeout(),M(this,en).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){le(this,Ir,M(this,Ir).filter(n=>n!==t)),this.scheduleGc(),M(this,en).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){M(this,Ir).length||(this.state.status==="pending"?this.scheduleGc():M(this,en).remove(this))}continue(){var t;return((t=M(this,ms))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var a,l,c,d,u,p,h,g,v,x,w,b,y,j,S,k,E,C;const n=()=>{Se(this,Mr,zo).call(this,{type:"continue"})},r={client:M(this,gd),meta:this.options.meta,mutationKey:this.options.mutationKey};le(this,ms,FS({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(R,P)=>{Se(this,Mr,zo).call(this,{type:"failed",failureCount:R,error:P})},onPause:()=>{Se(this,Mr,zo).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>M(this,en).canRun(this)}));const i=this.state.status==="pending",s=!M(this,ms).canStart();try{if(i)n();else{Se(this,Mr,zo).call(this,{type:"pending",variables:t,isPaused:s}),M(this,en).config.onMutate&&await M(this,en).config.onMutate(t,this,r);const P=await((l=(a=this.options).onMutate)==null?void 0:l.call(a,t,r));P!==this.state.context&&Se(this,Mr,zo).call(this,{type:"pending",context:P,variables:t,isPaused:s})}const R=await M(this,ms).start();return await((d=(c=M(this,en).config).onSuccess)==null?void 0:d.call(c,R,t,this.state.context,this,r)),await((p=(u=this.options).onSuccess)==null?void 0:p.call(u,R,t,this.state.context,r)),await((g=(h=M(this,en).config).onSettled)==null?void 0:g.call(h,R,null,this.state.variables,this.state.context,this,r)),await((x=(v=this.options).onSettled)==null?void 0:x.call(v,R,null,t,this.state.context,r)),Se(this,Mr,zo).call(this,{type:"success",data:R}),R}catch(R){try{await((b=(w=M(this,en).config).onError)==null?void 0:b.call(w,R,t,this.state.context,this,r))}catch(P){Promise.reject(P)}try{await((j=(y=this.options).onError)==null?void 0:j.call(y,R,t,this.state.context,r))}catch(P){Promise.reject(P)}try{await((k=(S=M(this,en).config).onSettled)==null?void 0:k.call(S,void 0,R,this.state.variables,this.state.context,this,r))}catch(P){Promise.reject(P)}try{await((C=(E=this.options).onSettled)==null?void 0:C.call(E,void 0,R,t,this.state.context,r))}catch(P){Promise.reject(P)}throw Se(this,Mr,zo).call(this,{type:"error",error:R}),R}finally{M(this,en).runNext(this)}}},gd=new WeakMap,Ir=new WeakMap,en=new WeakMap,ms=new WeakMap,Mr=new WeakSet,zo=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),It.batch(()=>{M(this,Ir).forEach(r=>{r.onMutationUpdate(t)}),M(this,en).notify({mutation:this,type:"updated",action:t})})},g2);function HS(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var oo,ar,xd,x2,H8=(x2=class extends wl{constructor(t={}){super();xe(this,oo);xe(this,ar);xe(this,xd);this.config=t,le(this,oo,new Set),le(this,ar,new Map),le(this,xd,0)}build(t,n,r){const i=new U8({client:t,mutationCache:this,mutationId:++Qd(this,xd)._,options:t.defaultMutationOptions(n),state:r});return this.add(i),i}add(t){M(this,oo).add(t);const n=pu(t);if(typeof n=="string"){const r=M(this,ar).get(n);r?r.push(t):M(this,ar).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(M(this,oo).delete(t)){const n=pu(t);if(typeof n=="string"){const r=M(this,ar).get(n);if(r)if(r.length>1){const i=r.indexOf(t);i!==-1&&r.splice(i,1)}else r[0]===t&&M(this,ar).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=pu(t);if(typeof n=="string"){const r=M(this,ar).get(n),i=r==null?void 0:r.find(s=>s.state.status==="pending");return!i||i===t}else return!0}runNext(t){var r;const n=pu(t);if(typeof n=="string"){const i=(r=M(this,ar).get(n))==null?void 0:r.find(s=>s!==t&&s.state.isPaused);return(i==null?void 0:i.continue())??Promise.resolve()}else return Promise.resolve()}clear(){It.batch(()=>{M(this,oo).forEach(t=>{this.notify({type:"removed",mutation:t})}),M(this,oo).clear(),M(this,ar).clear()})}getAll(){return Array.from(M(this,oo))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>_1(n,r))}findAll(t={}){return this.getAll().filter(n=>_1(t,n))}notify(t){It.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return It.batch(()=>Promise.all(t.map(n=>n.continue().catch(dn))))}},oo=new WeakMap,ar=new WeakMap,xd=new WeakMap,x2);function pu(e){var t;return(t=e.options.scope)==null?void 0:t.id}var io,ti,mn,so,go,rp,Hx,m2,q8=(m2=class extends wl{constructor(n,r){super();xe(this,go);xe(this,io);xe(this,ti);xe(this,mn);xe(this,so);le(this,io,n),this.setOptions(r),this.bindMethods(),Se(this,go,rp).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var i;const r=this.options;this.options=M(this,io).defaultMutationOptions(n),Bp(this.options,r)||M(this,io).getMutationCache().notify({type:"observerOptionsUpdated",mutation:M(this,mn),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Es(r.mutationKey)!==Es(this.options.mutationKey)?this.reset():((i=M(this,mn))==null?void 0:i.state.status)==="pending"&&M(this,mn).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=M(this,mn))==null||n.removeObserver(this)}onMutationUpdate(n){Se(this,go,rp).call(this),Se(this,go,Hx).call(this,n)}getCurrentResult(){return M(this,ti)}reset(){var n;(n=M(this,mn))==null||n.removeObserver(this),le(this,mn,void 0),Se(this,go,rp).call(this),Se(this,go,Hx).call(this)}mutate(n,r){var i;return le(this,so,r),(i=M(this,mn))==null||i.removeObserver(this),le(this,mn,M(this,io).getMutationCache().build(M(this,io),this.options)),M(this,mn).addObserver(this),M(this,mn).execute(n)}},io=new WeakMap,ti=new WeakMap,mn=new WeakMap,so=new WeakMap,go=new WeakSet,rp=function(){var r;const n=((r=M(this,mn))==null?void 0:r.state)??HS();le(this,ti,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Hx=function(n){It.batch(()=>{var r,i,s,a,l,c,d,u;if(M(this,so)&&this.hasListeners()){const p=M(this,ti).variables,h=M(this,ti).context,g={client:M(this,io),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(i=(r=M(this,so)).onSuccess)==null||i.call(r,n.data,p,h,g)}catch(v){Promise.reject(v)}try{(a=(s=M(this,so)).onSettled)==null||a.call(s,n.data,null,p,h,g)}catch(v){Promise.reject(v)}}else if((n==null?void 0:n.type)==="error"){try{(c=(l=M(this,so)).onError)==null||c.call(l,n.error,p,h,g)}catch(v){Promise.reject(v)}try{(u=(d=M(this,so)).onSettled)==null||u.call(d,void 0,n.error,p,h,g)}catch(v){Promise.reject(v)}}}this.listeners.forEach(p=>{p(M(this,ti))})})},m2),Lr,v2,V8=(v2=class extends wl{constructor(t={}){super();xe(this,Lr);this.config=t,le(this,Lr,new Map)}build(t,n,r){const i=n.queryKey,s=n.queryHash??Bv(i,n);let a=this.get(s);return a||(a=new F8({client:t,queryKey:i,queryHash:s,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(i)}),this.add(a)),a}add(t){M(this,Lr).has(t.queryHash)||(M(this,Lr).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=M(this,Lr).get(t.queryHash);n&&(t.destroy(),n===t&&M(this,Lr).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){It.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return M(this,Lr).get(t)}getAll(){return[...M(this,Lr).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>$1(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>$1(t,r)):n}notify(t){It.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){It.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){It.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Lr=new WeakMap,v2),xt,ni,ri,Ka,Qa,oi,Ga,Ya,y2,K8=(y2=class{constructor(e={}){xe(this,xt);xe(this,ni);xe(this,ri);xe(this,Ka);xe(this,Qa);xe(this,oi);xe(this,Ga);xe(this,Ya);le(this,xt,e.queryCache||new V8),le(this,ni,e.mutationCache||new H8),le(this,ri,e.defaultOptions||{}),le(this,Ka,new Map),le(this,Qa,new Map),le(this,oi,0)}mount(){Qd(this,oi)._++,M(this,oi)===1&&(le(this,Ga,zv.subscribe(async e=>{e&&(await this.resumePausedMutations(),M(this,xt).onFocus())})),le(this,Ya,Wp.subscribe(async e=>{e&&(await this.resumePausedMutations(),M(this,xt).onOnline())})))}unmount(){var e,t;Qd(this,oi)._--,M(this,oi)===0&&((e=M(this,Ga))==null||e.call(this),le(this,Ga,void 0),(t=M(this,Ya))==null||t.call(this),le(this,Ya,void 0))}isFetching(e){return M(this,xt).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return M(this,ni).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=M(this,xt).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=M(this,xt).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(mi(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return M(this,xt).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),i=M(this,xt).get(r.queryHash),s=i==null?void 0:i.state.data,a=E8(t,s);if(a!==void 0)return M(this,xt).build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return It.batch(()=>M(this,xt).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=M(this,xt).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=M(this,xt);It.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=M(this,xt);return It.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=It.batch(()=>M(this,xt).findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then(dn).catch(dn)}invalidateQueries(e,t={}){return It.batch(()=>(M(this,xt).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=It.batch(()=>M(this,xt).findAll(e).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let s=i.fetch(void 0,n);return n.throwOnError||(s=s.catch(dn)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(dn)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=M(this,xt).build(this,t);return n.isStaleByTime(mi(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(dn).catch(dn)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(dn).catch(dn)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return Wp.isOnline()?M(this,ni).resumePausedMutations():Promise.resolve()}getQueryCache(){return M(this,xt)}getMutationCache(){return M(this,ni)}getDefaultOptions(){return M(this,ri)}setDefaultOptions(e){le(this,ri,e)}setQueryDefaults(e,t){M(this,Ka).set(Es(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...M(this,Ka).values()],n={};return t.forEach(r=>{Yc(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){M(this,Qa).set(Es(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...M(this,Qa).values()],n={};return t.forEach(r=>{Yc(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...M(this,ri).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Bv(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===bo&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...M(this,ri).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){M(this,xt).clear(),M(this,ni).clear()}},xt=new WeakMap,ni=new WeakMap,ri=new WeakMap,Ka=new WeakMap,Qa=new WeakMap,oi=new WeakMap,Ga=new WeakMap,Ya=new WeakMap,y2),qS=f.createContext(void 0),je=e=>{const t=f.useContext(qS);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Q8=({client:e,children:t})=>(f.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),o.jsx(qS.Provider,{value:e,children:t})),VS=f.createContext(!1),G8=()=>f.useContext(VS);VS.Provider;function Y8(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var X8=f.createContext(Y8()),J8=()=>f.useContext(X8),Z8=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Wv(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},eI=e=>{f.useEffect(()=>{e.clearReset()},[e])},tI=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Wv(n,[e.error,r])),nI=e=>{if(e.suspense){const n=i=>i==="static"?i:Math.max(i??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...i)=>n(r(...i)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},rI=(e,t)=>e.isLoading&&e.isFetching&&!t,oI=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,V1=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function iI(e,t,n){var g,v,x,w;const r=G8(),i=J8(),s=je(),a=s.defaultQueryOptions(e);(v=(g=s.getDefaultOptions().queries)==null?void 0:g._experimental_beforeQuery)==null||v.call(g,a);const l=s.getQueryCache().get(a.queryHash),c=e.subscribed!==!1;a._optimisticResults=r?"isRestoring":c?"optimistic":void 0,nI(a),Z8(a,i,l),eI(i);const d=!s.getQueryCache().get(a.queryHash),[u]=f.useState(()=>new t(s,a)),p=u.getOptimisticResult(a),h=!r&&c;if(f.useSyncExternalStore(f.useCallback(b=>{const y=h?u.subscribe(It.batchCalls(b)):dn;return u.updateResult(),y},[u,h]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),f.useEffect(()=>{u.setOptions(a)},[a,u]),oI(a,p))throw V1(a,u,i);if(tI({result:p,errorResetBoundary:i,throwOnError:a.throwOnError,query:l,suspense:a.suspense}))throw p.error;if((w=(x=s.getDefaultOptions().queries)==null?void 0:x._experimental_afterQuery)==null||w.call(x,a,p),a.experimental_prefetchInRender&&!Xc.isServer()&&rI(p,r)){const b=d?V1(a,u,i):l==null?void 0:l.promise;b==null||b.catch(dn).finally(()=>{u.updateResult()})}return a.notifyOnChangeProps?p:u.trackResult(p)}function G(e,t){return iI(e,z8)}function ue(e,t){const n=je(),[r]=f.useState(()=>new q8(n,e));f.useEffect(()=>{r.setOptions(e)},[r,e]);const i=f.useSyncExternalStore(f.useCallback(a=>r.subscribe(It.batchCalls(a)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=f.useCallback((a,l)=>{r.mutate(a,l).catch(dn)},[r]);if(i.error&&Wv(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}var sI=Object.create,KS=Object.defineProperty,aI=Object.getOwnPropertyDescriptor,QS=Object.getOwnPropertyNames,lI=Object.getPrototypeOf,cI=Object.prototype.hasOwnProperty,Wr=(e,t)=>function(){return t||(0,e[QS(e)[0]])((t={exports:{}}).exports,t),t.exports},dI=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var i=QS(t),s=0,a=i.length,l;s<a;s++)l=i[s],!cI.call(e,l)&&l!==n&&KS(e,l,{get:(c=>t[c]).bind(null,l),enumerable:!(r=aI(t,l))||r.enumerable});return e},wt=(e,t,n)=>(n=e!=null?sI(lI(e)):{},dI(t||!e||!e.__esModule?KS(n,"default",{value:e,enumerable:!0}):n,e)),GS=Wr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e,t){function n(r){"@babel/helpers - typeof";return t.exports=n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(i){return typeof i}:function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},t.exports.__esModule=!0,t.exports.default=t.exports,n(r)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),uI=Wr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var n=GS().default;function r(i,s){if(n(i)!="object"||!i)return i;var a=i[Symbol.toPrimitive];if(a!==void 0){var l=a.call(i,s||"default");if(n(l)!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(i)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),pI=Wr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var n=GS().default,r=uI();function i(s){var a=r(s,"string");return n(a)=="symbol"?a:a+""}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}}),$s=Wr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var n=pI();function r(i,s,a){return(s=n(s))in i?Object.defineProperty(i,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[s]=a,i}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),yr=Wr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e,t){var n=$s();function r(s,a){var l=Object.keys(s);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(s);a&&(c=c.filter(function(d){return Object.getOwnPropertyDescriptor(s,d).enumerable})),l.push.apply(l,c)}return l}function i(s){for(var a=1;a<arguments.length;a++){var l=arguments[a]!=null?arguments[a]:{};a%2?r(Object(l),!0).forEach(function(c){n(s,c,l[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(l)):r(Object(l)).forEach(function(c){Object.defineProperty(s,c,Object.getOwnPropertyDescriptor(l,c))})}return s}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}});function kl(e){const t={subscribe(n){let r=null,i=!1,s=!1,a=!1;function l(){if(r===null){a=!0;return}s||(s=!0,typeof r=="function"?r():r&&r.unsubscribe())}return r=e({next(c){var d;i||(d=n.next)===null||d===void 0||d.call(n,c)},error(c){var d;i||(i=!0,(d=n.error)===null||d===void 0||d.call(n,c),l())},complete(){var c;i||(i=!0,(c=n.complete)===null||c===void 0||c.call(n),l())}}),a&&l(),{unsubscribe:l}},pipe(...n){return n.reduce(fI,t)}};return t}function fI(e,t){return t(e)}function hI(e){const t=new AbortController;return new Promise((r,i)=>{let s=!1;function a(){s||(s=!0,l.unsubscribe())}t.signal.addEventListener("abort",()=>{i(t.signal.reason)});const l=e.subscribe({next(c){s=!0,r(c),a()},error(c){i(c)},complete(){t.abort(),a()}})})}function gI(e){return t=>{let n=0,r=null;const i=[];function s(){r||(r=t.subscribe({next(l){for(const d of i){var c;(c=d.next)===null||c===void 0||c.call(d,l)}},error(l){for(const d of i){var c;(c=d.error)===null||c===void 0||c.call(d,l)}},complete(){for(const c of i){var l;(l=c.complete)===null||l===void 0||l.call(c)}}}))}function a(){if(n===0&&r){const l=r;r=null,l.unsubscribe()}}return kl(l=>(n++,i.push(l),s(),{unsubscribe(){n--,a();const c=i.findIndex(d=>d===l);c>-1&&i.splice(c,1)}}))}}function YS(e){let t=e;const n=[],r=a=>{t!==void 0&&a.next(t),n.push(a)},i=a=>{n.splice(n.indexOf(a),1)},s=kl(a=>(r(a),()=>{i(a)}));return s.next=a=>{if(t!==a){t=a;for(const l of n)l.next(a)}},s.get=()=>t,s}function XS(e){return kl(t=>{function n(i=0,s=e.op){const a=e.links[i];if(!a)throw new Error("No more links to execute - did you forget to add an ending link?");return a({op:s,next(c){return n(i+1,c)}})}return n().subscribe(t)})}function K1(e){return Array.isArray(e)?e:[e]}function xI(e){return t=>{const n=K1(e.true).map(i=>i(t)),r=K1(e.false).map(i=>i(t));return i=>kl(s=>{const a=e.condition(i.op)?n:r;return XS({op:i.op,links:a}).subscribe(s)})}}function wi(e){return!!e&&!Array.isArray(e)&&typeof e=="object"}function mI(e){return typeof e=="function"}function JS(){return Object.create(null)}const vI=typeof Symbol=="function"&&!!Symbol.asyncIterator;function yI(e){return vI&&wi(e)&&Symbol.asyncIterator in e}const Hv=e=>e(),fu={INTERNAL_SERVER_ERROR:-32603,BAD_GATEWAY:-32603,SERVICE_UNAVAILABLE:-32603,GATEWAY_TIMEOUT:-32603},bI=[fu.BAD_GATEWAY,fu.SERVICE_UNAVAILABLE,fu.GATEWAY_TIMEOUT,fu.INTERNAL_SERVER_ERROR];var jI=Object.create,ZS=Object.defineProperty,wI=Object.getOwnPropertyDescriptor,e5=Object.getOwnPropertyNames,kI=Object.getPrototypeOf,SI=Object.prototype.hasOwnProperty,br=(e,t)=>function(){return t||(0,e[e5(e)[0]])((t={exports:{}}).exports,t),t.exports},CI=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var i=e5(t),s=0,a=i.length,l;s<a;s++)l=i[s],!SI.call(e,l)&&l!==n&&ZS(e,l,{get:(c=>t[c]).bind(null,l),enumerable:!(r=wI(t,l))||r.enumerable});return e},Ye=(e,t,n)=>(n=e!=null?jI(kI(e)):{},CI(ZS(n,"default",{value:e,enumerable:!0}),e));const t5=()=>{},Q1=e=>{Object.freeze&&Object.freeze(e)};function n5(e,t,n){var r;const i=t.join(".");return(r=n[i])!==null&&r!==void 0||(n[i]=new Proxy(t5,{get(s,a){if(!(typeof a!="string"||a==="then"))return n5(e,[...t,a],n)},apply(s,a,l){const c=t[t.length-1];if(c==="valueOf"||c==="toString"||c==="toJSON")return`tRPC.proxy(${t.slice(0,-1).join(".")})`;let d={args:l,path:t};return c==="call"?d={args:l.length>=2?[l[1]]:[],path:t.slice(0,-1)}:c==="apply"&&(d={args:l.length>=2?l[1]:[],path:t.slice(0,-1)}),Q1(d.args),Q1(d.path),e(d)}})),n[i]}const r5=e=>n5(e,[],JS()),TI=e=>new Proxy(t5,{get(t,n){if(n!=="then")return e(n)}});var o5=br({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e,t){function n(r){"@babel/helpers - typeof";return t.exports=n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(i){return typeof i}:function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},t.exports.__esModule=!0,t.exports.default=t.exports,n(r)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),EI=br({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var n=o5().default;function r(i,s){if(n(i)!="object"||!i)return i;var a=i[Symbol.toPrimitive];if(a!==void 0){var l=a.call(i,s||"default");if(n(l)!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(i)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),RI=br({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var n=o5().default,r=EI();function i(s){var a=r(s,"string");return n(a)=="symbol"?a:a+""}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}}),qv=br({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var n=RI();function r(i,s,a){return(s=n(s))in i?Object.defineProperty(i,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[s]=a,i}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),wd=br({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e,t){var n=qv();function r(s,a){var l=Object.keys(s);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(s);a&&(c=c.filter(function(d){return Object.getOwnPropertyDescriptor(s,d).enumerable})),l.push.apply(l,c)}return l}function i(s){for(var a=1;a<arguments.length;a++){var l=arguments[a]!=null?arguments[a]:{};a%2?r(Object(l),!0).forEach(function(c){n(s,c,l[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(l)):r(Object(l)).forEach(function(c){Object.defineProperty(s,c,Object.getOwnPropertyDescriptor(l,c))})}return s}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}});Ye(wd());var G1=Ye(qv()),PI=class extends Error{constructor(e){super(II(e)),Object.assign(this,e)}};function II(e){if("message"in e)return String(e.message)}function MI(e){if(e instanceof Error)return e;const t=typeof e;if(!(t==="undefined"||t==="function"||e===null)){if(t!=="object")return new Error(String(e));if(wi(e))return new PI(e)}}var Y1=class extends Error{constructor(e){var t,n,r;const i=MI(e.cause),s=(t=(n=e.message)!==null&&n!==void 0?n:i==null?void 0:i.message)!==null&&t!==void 0?t:e.code;super(s,{cause:i}),(0,G1.default)(this,"cause",void 0),(0,G1.default)(this,"code",void 0),this.code=e.code,this.name="TRPCError",(r=this.cause)!==null&&r!==void 0||(this.cause=i)}},hu=Ye(wd());function LI(e,t){if("error"in e){const r=t.deserialize(e.error);return{ok:!1,error:(0,hu.default)((0,hu.default)({},e),{},{error:r})}}return{ok:!0,result:(0,hu.default)((0,hu.default)({},e.result),(!e.result.type||e.result.type==="data")&&{type:"data",data:t.deserialize(e.result.data)})}}var Uh=class extends Error{constructor(){super("Unable to transform response from server")}};function OI(e,t){let n;try{n=LI(e,t)}catch{throw new Uh}if(!n.ok&&(!wi(n.error.error)||typeof n.error.error.code!="number"))throw new Uh;if(n.ok&&!wi(n.result))throw new Uh;return n}Ye(wd());function DI(e){return typeof e=="function"}async function AI(e,t){const{_def:n}=e;let r=n.procedures[t];for(;!r;){const i=Object.keys(n.lazy).find(a=>t.startsWith(a));if(!i)return null;await n.lazy[i].load(),r=n.procedures[t]}return r}async function NI(e){const{type:t,path:n}=e,r=await AI(e.router,n);if(!r||!DI(r)||r._def.type!==t&&!e.allowMethodOverride)throw new Y1({code:"NOT_FOUND",message:`No "${t}"-procedure on path "${n}"`});/* istanbul ignore if -- @preserve */if(r._def.type!==t&&e.allowMethodOverride&&r._def.type==="subscription")throw new Y1({code:"METHOD_NOT_SUPPORTED",message:"Method override is not supported for subscriptions"});return r(e)}Ye(wd());var gu=Ye(qv());let i5;const Hh=new WeakMap,$I=()=>{};i5=Symbol.toStringTag;var s5=class Ji{constructor(t){(0,gu.default)(this,"promise",void 0),(0,gu.default)(this,"subscribers",[]),(0,gu.default)(this,"settlement",null),(0,gu.default)(this,i5,"Unpromise"),typeof t=="function"?this.promise=new Promise(t):this.promise=t;const n=this.promise.then(r=>{const{subscribers:i}=this;this.subscribers=null,this.settlement={status:"fulfilled",value:r},i==null||i.forEach(({resolve:s})=>{s(r)})});"catch"in n&&n.catch(r=>{const{subscribers:i}=this;this.subscribers=null,this.settlement={status:"rejected",reason:r},i==null||i.forEach(({reject:s})=>{s(r)})})}subscribe(){let t,n;const{settlement:r}=this;if(r===null){if(this.subscribers===null)throw new Error("Unpromise settled but still has subscribers");const i=FI();this.subscribers=zI(this.subscribers,i),t=i.promise,n=()=>{this.subscribers!==null&&(this.subscribers=WI(this.subscribers,i))}}else{const{status:i}=r;i==="fulfilled"?t=Promise.resolve(r.value):t=Promise.reject(r.reason),n=$I}return Object.assign(t,{unsubscribe:n})}then(t,n){const r=this.subscribe(),{unsubscribe:i}=r;return Object.assign(r.then(t,n),{unsubscribe:i})}catch(t){const n=this.subscribe(),{unsubscribe:r}=n;return Object.assign(n.catch(t),{unsubscribe:r})}finally(t){const n=this.subscribe(),{unsubscribe:r}=n;return Object.assign(n.finally(t),{unsubscribe:r})}static proxy(t){const n=Ji.getSubscribablePromise(t);return typeof n<"u"?n:Ji.createSubscribablePromise(t)}static createSubscribablePromise(t){const n=new Ji(t);return Hh.set(t,n),Hh.set(n,n),n}static getSubscribablePromise(t){return Hh.get(t)}static resolve(t){const n=typeof t=="object"&&t!==null&&"then"in t&&typeof t.then=="function"?t:Promise.resolve(t);return Ji.proxy(n).subscribe()}static async any(t){const r=(Array.isArray(t)?t:[...t]).map(Ji.resolve);try{return await Promise.any(r)}finally{r.forEach(({unsubscribe:i})=>{i()})}}static async race(t){const r=(Array.isArray(t)?t:[...t]).map(Ji.resolve);try{return await Promise.race(r)}finally{r.forEach(({unsubscribe:i})=>{i()})}}static async raceReferences(t){const n=t.map(_I);try{return await Promise.race(n)}finally{for(const r of n)r.unsubscribe()}}};function _I(e){return s5.proxy(e).then(()=>[e])}function FI(){let e,t;return{promise:new Promise((r,i)=>{e=r,t=i}),resolve:e,reject:t}}function zI(e,t){return[...e,t]}function BI(e,t){return[...e.slice(0,t),...e.slice(t+1)]}function WI(e,t){const n=e.indexOf(t);return n!==-1?BI(e,n):e}var X1,J1,Z1,eb;(J1=(X1=Symbol).dispose)!==null&&J1!==void 0||(X1.dispose=Symbol());(eb=(Z1=Symbol).asyncDispose)!==null&&eb!==void 0||(Z1.asyncDispose=Symbol());function UI(e,t){const n=e,r=n[Symbol.dispose];return n[Symbol.dispose]=()=>{t(),r==null||r()},n}function HI(e,t){const n=e,r=n[Symbol.asyncDispose];return n[Symbol.asyncDispose]=async()=>{await t(),await(r==null?void 0:r())},n}const a5=Symbol();function qI(e){let t=null;return UI({start(){if(t)throw new Error("Timer already started");return new Promise(r=>{t=setTimeout(()=>r(a5),e)})}},()=>{t&&clearTimeout(t)})}var kd=br({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(e,t){function n(){var r=typeof SuppressedError=="function"?SuppressedError:function(l,c){var d=Error();return d.name="SuppressedError",d.error=l,d.suppressed=c,d},i={},s=[];function a(l,c){if(c!=null){if(Object(c)!==c)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(l)var d=c[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(d===void 0&&(d=c[Symbol.dispose||Symbol.for("Symbol.dispose")],l))var u=d;if(typeof d!="function")throw new TypeError("Object is not disposable.");u&&(d=function(){try{u.call(c)}catch(h){return Promise.reject(h)}}),s.push({v:c,d,a:l})}else l&&s.push({d:c,a:l});return c}return{e:i,u:a.bind(null,!1),a:a.bind(null,!0),d:function(){var c,d=this.e,u=0;function p(){for(;c=s.pop();)try{if(!c.a&&u===1)return u=0,s.push(c),Promise.resolve().then(p);if(c.d){var g=c.d.call(c.v);if(c.a)return u|=2,Promise.resolve(g).then(p,h)}else u|=1}catch(v){return h(v)}if(u===1)return d!==i?Promise.reject(d):Promise.resolve();if(d!==i)throw d}function h(g){return d=d!==i?new r(g,d):g,p()}return p()}}}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),Vv=br({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(e,t){function n(r,i){this.v=r,this.k=i}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),Sd=br({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(e,t){var n=Vv();function r(i){return new n(i,0)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),Sl=br({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(e,t){var n=Vv();function r(s){return function(){return new i(s.apply(this,arguments))}}function i(s){var a,l;function c(u,p){try{var h=s[u](p),g=h.value,v=g instanceof n;Promise.resolve(v?g.v:g).then(function(x){if(v){var w=u==="return"?"return":"next";if(!g.k||x.done)return c(w,x);x=s[w](x).value}d(h.done?"return":"normal",x)},function(x){c("throw",x)})}catch(x){d("throw",x)}}function d(u,p){switch(u){case"return":a.resolve({value:p,done:!0});break;case"throw":a.reject(p);break;default:a.resolve({value:p,done:!1})}(a=a.next)?c(a.key,a.arg):l=null}this._invoke=function(u,p){return new Promise(function(h,g){var v={key:u,arg:p,resolve:h,reject:g,next:null};l?l=l.next=v:(a=l=v,c(u,p))})},typeof s.return!="function"&&(this.return=void 0)}i.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},i.prototype.next=function(s){return this._invoke("next",s)},i.prototype.throw=function(s){return this._invoke("throw",s)},i.prototype.return=function(s){return this._invoke("return",s)},t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}});Ye(kd());Ye(Sd());Ye(Sl());Ye(kd());Ye(Sd());Ye(Sl());Ye(kd());Ye(Sd());Ye(Sl());var l5=br({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(e,t){function n(i){var s,a,l,c=2;for(typeof Symbol<"u"&&(a=Symbol.asyncIterator,l=Symbol.iterator);c--;){if(a&&(s=i[a])!=null)return s.call(i);if(l&&(s=i[l])!=null)return new r(s.call(i));a="@@asyncIterator",l="@@iterator"}throw new TypeError("Object is not async iterable")}function r(i){function s(a){if(Object(a)!==a)return Promise.reject(new TypeError(a+" is not an object."));var l=a.done;return Promise.resolve(a.value).then(function(c){return{value:c,done:l}})}return r=function(l){this.s=l,this.n=l.next},r.prototype={s:null,n:null,next:function(){return s(this.n.apply(this.s,arguments))},return:function(l){var c=this.s.return;return c===void 0?Promise.resolve({value:l,done:!0}):s(c.apply(this.s,arguments))},throw:function(l){var c=this.s.return;return c===void 0?Promise.reject(l):s(c.apply(this.s,arguments))}},new r(i)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}});Ye(Sd());Ye(Sl());Ye(kd());Ye(l5());var VI=br({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncGeneratorDelegate.js"(e,t){var n=Vv();function r(i){var s={},a=!1;function l(c,d){return a=!0,d=new Promise(function(u){u(i[c](d))}),{done:!1,value:new n(d,1)}}return s[typeof Symbol<"u"&&Symbol.iterator||"@@iterator"]=function(){return this},s.next=function(c){return a?(a=!1,c):l("next",c)},typeof i.throw=="function"&&(s.throw=function(c){if(a)throw a=!1,c;return l("throw",c)}),typeof i.return=="function"&&(s.return=function(c){return a?(a=!1,c):l("return",c)}),s}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}});Ye(l5());var tb=Ye(Sd()),KI=Ye(Sl());Ye(VI());var c5=Ye(kd());const QI="ping",GI="serialized-error",YI="connected",XI="return";async function JI(e){try{var t=(0,c5.default)();const n=t.u(qI(e.timeoutMs)),r=await s5.race([e.promise,n.start()]);return r===a5?await e.onTimeout():r}catch(n){t.e=n}finally{t.d()}}function ZI(e){const{deserialize:t=l=>l}=e;let n=JS();const r=e.signal;let i=null;const s=()=>new ReadableStream({async start(l){const[c,d]=await Promise.all([e.url(),e.init()]),u=i=new e.EventSource(c,d);l.enqueue({type:"connecting",eventSource:i,event:null}),u.addEventListener(YI,h=>{const v=JSON.parse(h.data);n=v,l.enqueue({type:"connected",options:v,eventSource:u})}),u.addEventListener(GI,h=>{const g=h;l.enqueue({type:"serialized-error",error:t(JSON.parse(g.data)),eventSource:u})}),u.addEventListener(QI,()=>{l.enqueue({type:"ping",eventSource:u})}),u.addEventListener(XI,()=>{u.close(),l.close(),i=null}),u.addEventListener("error",h=>{u.readyState===u.CLOSED?l.error(h):l.enqueue({type:"connecting",eventSource:u,event:h})}),u.addEventListener("message",h=>{const g=h,x={data:t(JSON.parse(g.data))};g.lastEventId&&(x.id=g.lastEventId),l.enqueue({type:"data",data:x,eventSource:u})});const p=()=>{try{u.close(),l.close()}catch{}};r.aborted?p():r.addEventListener("abort",p)},cancel(){i==null||i.close()}}),a=()=>{let l=s(),c=l.getReader();async function d(){await c.cancel(),i=null}return HI({read(){return c.read()},async recreate(){await d(),l=s(),c=l.getReader()}},d)};return Hv((0,KI.default)(function*(){try{var l=(0,c5.default)();const c=l.a(a());for(;;){let d=c.read();const u=n.reconnectAfterInactivityMs;u&&(d=JI({promise:d,timeoutMs:u,onTimeout:async()=>{const h={value:{type:"timeout",ms:u,eventSource:i},done:!1};return await c.recreate(),h}}));const p=yield(0,tb.default)(d);if(p.done)return p.value;yield p.value}}catch(c){l.e=c}finally{yield(0,tb.default)(l.d())}}))}Ye(Sl());Ye(wd());var xu=wt($s(),1),Ws=wt(yr(),1);function e9(e){return e instanceof ai}function t9(e){return wi(e)&&wi(e.error)&&typeof e.error.code=="number"&&typeof e.error.message=="string"}function n9(e,t){return typeof e=="string"?e:wi(e)&&typeof e.message=="string"?e.message:t}var ai=class op extends Error{constructor(t,n){var r,i;const s=n==null?void 0:n.cause;super(t,{cause:s}),(0,xu.default)(this,"cause",void 0),(0,xu.default)(this,"shape",void 0),(0,xu.default)(this,"data",void 0),(0,xu.default)(this,"meta",void 0),this.meta=n==null?void 0:n.meta,this.cause=s,this.shape=n==null||(r=n.result)===null||r===void 0?void 0:r.error,this.data=n==null||(i=n.result)===null||i===void 0?void 0:i.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,op.prototype)}static from(t,n={}){const r=t;return e9(r)?(n.meta&&(r.meta=(0,Ws.default)((0,Ws.default)({},r.meta),n.meta)),r):t9(r)?new op(r.error.message,(0,Ws.default)((0,Ws.default)({},n),{},{result:r,cause:n.cause})):new op(n9(r,"Unknown error"),(0,Ws.default)((0,Ws.default)({},n),{},{cause:r}))}};function d5(e){const t=e;return t?"input"in t?t:{input:t,output:t}:{input:{serialize:n=>n,deserialize:n=>n},output:{serialize:n=>n,deserialize:n=>n}}}const nb=e=>typeof e=="function";function r9(e){if(e)return e;if(typeof window<"u"&&nb(window.fetch))return window.fetch;if(typeof globalThis<"u"&&nb(globalThis.fetch))return globalThis.fetch;throw new Error("No fetch implementation found")}var jc=wt(yr());function o9(e){return{url:e.url.toString(),fetch:e.fetch,transformer:d5(e.transformer),methodOverride:e.methodOverride}}function i9(e){const t={};for(let n=0;n<e.length;n++){const r=e[n];t[n]=r}return t}const s9={query:"GET",mutation:"POST",subscription:"PATCH"};function u5(e){return"input"in e?e.transformer.input.serialize(e.input):i9(e.inputs.map(t=>e.transformer.input.serialize(t)))}const Kv=e=>{const t=e.url.split("?");let r=t[0].replace(/\/$/,"")+"/"+e.path;const i=[];if(t[1]&&i.push(t[1]),"inputs"in e&&i.push("batch=1"),e.type==="query"||e.type==="subscription"){const s=u5(e);s!==void 0&&e.methodOverride!=="POST"&&i.push(`input=${encodeURIComponent(JSON.stringify(s))}`)}return i.length&&(r+="?"+i.join("&")),r},a9=e=>{if(e.type==="query"&&e.methodOverride!=="POST")return;const t=u5(e);return t!==void 0?JSON.stringify(t):void 0},l9=e=>p9((0,jc.default)((0,jc.default)({},e),{},{contentTypeHeader:"application/json",getUrl:Kv,getBody:a9}));var c9=class extends Error{constructor(){const e="AbortError";super(e),this.name=e,this.message=e}};const d9=e=>{var t;if(e!=null&&e.aborted)throw(t=e.throwIfAborted)===null||t===void 0||t.call(e),typeof DOMException<"u"?new DOMException("AbortError","AbortError"):new c9};async function u9(e){var t,n;d9(e.signal);const r=e.getUrl(e),i=e.getBody(e),s=(t=e.methodOverride)!==null&&t!==void 0?t:s9[e.type],a=await(async()=>{const c=await e.headers();return Symbol.iterator in c?Object.fromEntries(c):c})(),l=(0,jc.default)((0,jc.default)((0,jc.default)({},e.contentTypeHeader&&s!=="GET"?{"content-type":e.contentTypeHeader}:{}),e.trpcAcceptHeader?{[(n=e.trpcAcceptHeaderKey)!==null&&n!==void 0?n:"trpc-accept"]:e.trpcAcceptHeader}:void 0),a);return r9(e.fetch)(r,{method:s,signal:e.signal,body:i,headers:l})}async function p9(e){const t={},n=await u9(e);t.response=n;const r=await n.json();return t.responseJSON=r,{json:r,meta:t}}wt(yr(),1);const rb=()=>{throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")};function ob(e){let t=null,n=null;const r=()=>{clearTimeout(n),n=null,t=null};function i(l){const c=[[]];let d=0;for(;;){const h=l[d];if(!h)break;const g=c[c.length-1];if(h.aborted){var u;(u=h.reject)===null||u===void 0||u.call(h,new Error("Aborted")),d++;continue}if(e.validate(g.concat(h).map(x=>x.key))){g.push(h),d++;continue}if(g.length===0){var p;(p=h.reject)===null||p===void 0||p.call(h,new Error("Input is too big for a single dispatch")),d++;continue}c.push([])}return c}function s(){const l=i(t);r();for(const c of l){if(!c.length)continue;const d={items:c};for(const p of c)p.batch=d;e.fetch(d.items.map(p=>p.key)).then(async p=>{await Promise.all(p.map(async(g,v)=>{const x=d.items[v];try{var w;const y=await Promise.resolve(g);(w=x.resolve)===null||w===void 0||w.call(x,y)}catch(y){var b;(b=x.reject)===null||b===void 0||b.call(x,y)}x.batch=null,x.reject=null,x.resolve=null}));for(const g of d.items){var h;(h=g.reject)===null||h===void 0||h.call(g,new Error("Missing result")),g.batch=null}}).catch(p=>{for(const g of d.items){var h;(h=g.reject)===null||h===void 0||h.call(g,p),g.batch=null}})}}function a(l){var c;const d={aborted:!1,key:l,batch:null,resolve:rb,reject:rb},u=new Promise((p,h)=>{var g;d.reject=h,d.resolve=p,(g=t)!==null&&g!==void 0||(t=[]),t.push(d)});return(c=n)!==null&&c!==void 0||(n=setTimeout(s)),u}return{load:a}}function f9(...e){const t=new AbortController,n=e.length;let r=0;const i=()=>{++r===n&&t.abort()};for(const s of e)s!=null&&s.aborted?i():s==null||s.addEventListener("abort",i,{once:!0});return t.signal}function h9(...e){const t=new AbortController;for(const n of e)n!=null&&n.aborted?t.abort():n==null||n.addEventListener("abort",()=>t.abort(),{once:!0});return t.signal}var mu=wt(yr(),1);function g9(e){var t,n;const r=o9(e),i=(t=e.maxURLLength)!==null&&t!==void 0?t:1/0,s=(n=e.maxItems)!==null&&n!==void 0?n:1/0;return()=>{const a=u=>({validate(p){if(i===1/0&&s===1/0)return!0;if(p.length>s)return!1;const h=p.map(x=>x.path).join(","),g=p.map(x=>x.input);return Kv((0,mu.default)((0,mu.default)({},r),{},{type:u,path:h,inputs:g,signal:null})).length<=i},async fetch(p){const h=p.map(y=>y.path).join(","),g=p.map(y=>y.input),v=f9(...p.map(y=>y.signal)),x=await l9((0,mu.default)((0,mu.default)({},r),{},{path:h,inputs:g,type:u,headers(){return e.headers?typeof e.headers=="function"?e.headers({opList:p}):e.headers:{}},signal:v}));return(Array.isArray(x.json)?x.json:p.map(()=>x.json)).map(y=>({meta:x.meta,json:y}))}}),l=ob(a("query")),c=ob(a("mutation")),d={query:l,mutation:c};return({op:u})=>kl(p=>{/* istanbul ignore if -- @preserve */if(u.type==="subscription")throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");const g=d[u.type].load(u);let v;return g.then(x=>{v=x;const w=OI(x.json,r.transformer.output);if(!w.ok){p.error(ai.from(w.error,{meta:x.meta}));return}p.next({context:x.meta,result:w.result}),p.complete()}).catch(x=>{p.error(ai.from(x,{meta:v==null?void 0:v.meta}))}),()=>{}})}}wt(yr(),1);const Jc=(e,...t)=>typeof e=="function"?e(...t):e;wt($s(),1);function x9(){let e,t;return{promise:new Promise((r,i)=>{e=r,t=i}),resolve:e,reject:t}}async function m9(e){const t=await Jc(e.url);if(!e.connectionParams)return t;const r=`${t.includes("?")?"&":"?"}connectionParams=1`;return t+r}async function v9(e,t){const n={method:"connectionParams",data:await Jc(e)};return t.encode(n)}wt($s(),1);var Bo=wt($s(),1);function y9(e){const{promise:t,resolve:n,reject:r}=x9();return e.addEventListener("open",()=>{e.removeEventListener("error",r),n()}),e.addEventListener("error",r),t}function b9(e,{intervalMs:t,pongTimeoutMs:n}){let r,i;function s(){r=setTimeout(()=>{e.send("PING"),i=setTimeout(()=>{e.close()},n)},t)}function a(){clearTimeout(r),s()}function l(){clearTimeout(i),a()}e.addEventListener("open",s),e.addEventListener("message",({data:c})=>{clearTimeout(r),s(),c==="PONG"&&l()}),e.addEventListener("close",()=>{clearTimeout(r),clearTimeout(i)})}var j9=class qx{constructor(t){var n;if((0,Bo.default)(this,"id",++qx.connectCount),(0,Bo.default)(this,"WebSocketPonyfill",void 0),(0,Bo.default)(this,"urlOptions",void 0),(0,Bo.default)(this,"keepAliveOpts",void 0),(0,Bo.default)(this,"encoder",void 0),(0,Bo.default)(this,"wsObservable",YS(null)),(0,Bo.default)(this,"openPromise",null),this.WebSocketPonyfill=(n=t.WebSocketPonyfill)!==null&&n!==void 0?n:WebSocket,!this.WebSocketPonyfill)throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");this.urlOptions=t.urlOptions,this.keepAliveOpts=t.keepAlive,this.encoder=t.encoder}get ws(){return this.wsObservable.get()}set ws(t){this.wsObservable.next(t)}isOpen(){return!!this.ws&&this.ws.readyState===this.WebSocketPonyfill.OPEN&&!this.openPromise}isClosed(){return!!this.ws&&(this.ws.readyState===this.WebSocketPonyfill.CLOSING||this.ws.readyState===this.WebSocketPonyfill.CLOSED)}async open(){var t=this;if(t.openPromise)return t.openPromise;t.id=++qx.connectCount;const n=m9(t.urlOptions).then(r=>new t.WebSocketPonyfill(r));t.openPromise=n.then(async r=>{t.ws=r,r.binaryType="arraybuffer",r.addEventListener("message",function({data:i}){i==="PING"&&this.send("PONG")}),t.keepAliveOpts.enabled&&b9(r,t.keepAliveOpts),r.addEventListener("close",()=>{t.ws===r&&(t.ws=null)}),await y9(r),t.urlOptions.connectionParams&&r.send(await v9(t.urlOptions.connectionParams,t.encoder))});try{await t.openPromise}finally{t.openPromise=null}}async close(){var t=this;try{await t.openPromise}finally{var n;(n=t.ws)===null||n===void 0||n.close()}}};(0,Bo.default)(j9,"connectCount",0);wt($s(),1);wt(yr(),1);var qh=wt($s(),1),ib=wt(yr(),1),p5=class{constructor(e){(0,qh.default)(this,"links",void 0),(0,qh.default)(this,"runtime",void 0),(0,qh.default)(this,"requestId",void 0),this.requestId=0,this.runtime={},this.links=e.links.map(t=>t(this.runtime))}$request(e){var t;return XS({links:this.links,op:(0,ib.default)((0,ib.default)({},e),{},{context:(t=e.context)!==null&&t!==void 0?t:{},id:++this.requestId})}).pipe(gI())}async requestAsPromise(e){var t=this;try{const n=t.$request(e);return(await hI(n)).result.data}catch(n){throw ai.from(n)}}query(e,t,n){return this.requestAsPromise({type:"query",path:e,input:t,context:n==null?void 0:n.context,signal:n==null?void 0:n.signal})}mutation(e,t,n){return this.requestAsPromise({type:"mutation",path:e,input:t,context:n==null?void 0:n.context,signal:n==null?void 0:n.signal})}subscription(e,t,n){return this.$request({type:"subscription",path:e,input:t,context:n.context,signal:n.signal}).subscribe({next(i){switch(i.result.type){case"state":{var s;(s=n.onConnectionStateChange)===null||s===void 0||s.call(n,i.result);break}case"started":{var a;(a=n.onStarted)===null||a===void 0||a.call(n,{context:i.context});break}case"stopped":{var l;(l=n.onStopped)===null||l===void 0||l.call(n);break}case"data":case void 0:{var c;(c=n.onData)===null||c===void 0||c.call(n,i.result.data);break}}},error(i){var s;(s=n.onError)===null||s===void 0||s.call(n,i)},complete(){var i;(i=n.onComplete)===null||i===void 0||i.call(n)}})}};const f5=Symbol.for("trpc_untypedClient"),w9={query:"query",mutate:"mutation",subscribe:"subscription"},k9=e=>w9[e];function S9(e){const t=r5(({path:n,args:r})=>{const i=[...n],s=k9(i.pop()),a=i.join(".");return e[s](a,...r)});return TI(n=>n===f5?e:t[n])}function C9(e){const t=new p5(e);return S9(t)}function T9(e){return e[f5]}wt(yr(),1);var sb=wt(yr(),1);function E9(e,t){return!t||e!=null&&typeof e!="object"?e:(0,sb.default)((0,sb.default)({},e??{}),{},{lastEventId:t})}var R9=Wr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(e,t){function n(i){var s,a,l,c=2;for(typeof Symbol<"u"&&(a=Symbol.asyncIterator,l=Symbol.iterator);c--;){if(a&&(s=i[a])!=null)return s.call(i);if(l&&(s=i[l])!=null)return new r(s.call(i));a="@@asyncIterator",l="@@iterator"}throw new TypeError("Object is not async iterable")}function r(i){function s(a){if(Object(a)!==a)return Promise.reject(new TypeError(a+" is not an object."));var l=a.done;return Promise.resolve(a.value).then(function(c){return{value:c,done:l}})}return r=function(l){this.s=l,this.n=l.next},r.prototype={s:null,n:null,next:function(){return s(this.n.apply(this.s,arguments))},return:function(l){var c=this.s.return;return c===void 0?Promise.resolve({value:l,done:!0}):s(c.apply(this.s,arguments))},throw:function(l){var c=this.s.return;return c===void 0?Promise.reject(l):s(c.apply(this.s,arguments))}},new r(i)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),P9=wt(R9(),1);async function I9(e){let t=await Jc(e.url);if(e.connectionParams){const n=await Jc(e.connectionParams),r=t.includes("?")?"&":"?";t+=r+"connectionParams="+encodeURIComponent(JSON.stringify(n))}return t}function ab(e){const t=d5(e.transformer);return()=>({op:n})=>kl(r=>{var i;const{type:s,path:a,input:l}=n;/* istanbul ignore if -- @preserve */if(s!=="subscription")throw new Error("httpSubscriptionLink only supports subscriptions");let c;const d=new AbortController,u=h9(n.signal,d.signal),p=ZI({url:async()=>Kv({transformer:t,url:await I9(e),input:E9(l,c),path:a,type:s,signal:null}),init:()=>Jc(e.eventSourceOptions,{op:n}),signal:u,deserialize:v=>t.output.deserialize(v),EventSource:(i=e.EventSource)!==null&&i!==void 0?i:globalThis.EventSource}),h=YS({type:"state",state:"connecting",error:null}),g=h.subscribe({next(v){r.next({result:v})}});return Hv(async()=>{var v=!1,x=!1,w;try{for(var b=(0,P9.default)(p),y;v=!(y=await b.next()).done;v=!1){const j=y.value;switch(j.type){case"ping":break;case"data":const S=j.data;let k;S.id?(c=S.id,k={id:S.id,data:S}):k={data:S.data},r.next({result:k,context:{eventSource:j.eventSource}});break;case"connected":{r.next({result:{type:"started"},context:{eventSource:j.eventSource}}),h.next({type:"state",state:"pending",error:null});break}case"serialized-error":{const E=ai.from({error:j.error});if(bI.includes(j.error.code)){h.next({type:"state",state:"connecting",error:E});break}throw E}case"connecting":{const E=h.get(),C=j.event&&ai.from(j.event);if(!C&&E.state==="connecting")break;h.next({type:"state",state:"connecting",error:C});break}case"timeout":h.next({type:"state",state:"connecting",error:new ai(`Timeout of ${j.ms}ms reached while waiting for a response`)})}}}catch(j){x=!0,w=j}finally{try{v&&b.return!=null&&await b.return()}finally{if(x)throw w}}r.next({result:{type:"stopped"}}),h.next({type:"state",state:"idle",error:null}),r.complete()}).catch(v=>{r.error(ai.from(v))}),()=>{r.complete(),d.abort(),g.unsubscribe()}})}wt(yr(),1);var M9=Wr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(e,t){function n(){var r=typeof SuppressedError=="function"?SuppressedError:function(l,c){var d=Error();return d.name="SuppressedError",d.error=l,d.suppressed=c,d},i={},s=[];function a(l,c){if(c!=null){if(Object(c)!==c)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(l)var d=c[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(d===void 0&&(d=c[Symbol.dispose||Symbol.for("Symbol.dispose")],l))var u=d;if(typeof d!="function")throw new TypeError("Object is not disposable.");u&&(d=function(){try{u.call(c)}catch(h){return Promise.reject(h)}}),s.push({v:c,d,a:l})}else l&&s.push({d:c,a:l});return c}return{e:i,u:a.bind(null,!1),a:a.bind(null,!0),d:function(){var c,d=this.e,u=0;function p(){for(;c=s.pop();)try{if(!c.a&&u===1)return u=0,s.push(c),Promise.resolve().then(p);if(c.d){var g=c.d.call(c.v);if(c.a)return u|=2,Promise.resolve(g).then(p,h)}else u|=1}catch(v){return h(v)}if(u===1)return d!==i?Promise.reject(d):Promise.resolve();if(d!==i)throw d}function h(g){return d=d!==i?new r(g,d):g,p()}return p()}}}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),h5=Wr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(e,t){function n(r,i){this.v=r,this.k=i}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),L9=Wr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(e,t){var n=h5();function r(i){return new n(i,0)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),O9=Wr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(e,t){var n=h5();function r(s){return function(){return new i(s.apply(this,arguments))}}function i(s){var a,l;function c(u,p){try{var h=s[u](p),g=h.value,v=g instanceof n;Promise.resolve(v?g.v:g).then(function(x){if(v){var w=u==="return"?"return":"next";if(!g.k||x.done)return c(w,x);x=s[w](x).value}d(h.done?"return":"normal",x)},function(x){c("throw",x)})}catch(x){d("throw",x)}}function d(u,p){switch(u){case"return":a.resolve({value:p,done:!0});break;case"throw":a.reject(p);break;default:a.resolve({value:p,done:!1})}(a=a.next)?c(a.key,a.arg):l=null}this._invoke=function(u,p){return new Promise(function(h,g){var v={key:u,arg:p,resolve:h,reject:g,next:null};l?l=l.next=v:(a=l=v,c(u,p))})},typeof s.return!="function"&&(this.return=void 0)}i.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},i.prototype.next=function(s){return this._invoke("next",s)},i.prototype.throw=function(s){return this._invoke("throw",s)},i.prototype.return=function(s){return this._invoke("return",s)},t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}});wt(M9(),1);wt(L9(),1);wt(O9(),1);wt(yr(),1);var D9=Object.create,g5=Object.defineProperty,A9=Object.getOwnPropertyDescriptor,x5=Object.getOwnPropertyNames,N9=Object.getPrototypeOf,$9=Object.prototype.hasOwnProperty,Ii=(e,t)=>function(){return t||(0,e[x5(e)[0]])((t={exports:{}}).exports,t),t.exports},_9=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var i=x5(t),s=0,a=i.length,l;s<a;s++)l=i[s],!$9.call(e,l)&&l!==n&&g5(e,l,{get:(c=>t[c]).bind(null,l),enumerable:!(r=A9(t,l))||r.enumerable});return e},Mi=(e,t,n)=>(n=e!=null?D9(N9(e)):{},_9(t||!e||!e.__esModule?g5(n,"default",{value:e,enumerable:!0}):n,e)),m5=Ii({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e,t){function n(r){"@babel/helpers - typeof";return t.exports=n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(i){return typeof i}:function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},t.exports.__esModule=!0,t.exports.default=t.exports,n(r)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),F9=Ii({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var n=m5().default;function r(i,s){if(n(i)!="object"||!i)return i;var a=i[Symbol.toPrimitive];if(a!==void 0){var l=a.call(i,s||"default");if(n(l)!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(i)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),z9=Ii({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var n=m5().default,r=F9();function i(s){var a=r(s,"string");return n(a)=="symbol"?a:a+""}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}}),B9=Ii({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var n=z9();function r(i,s,a){return(s=n(s))in i?Object.defineProperty(i,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[s]=a,i}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),Cl=Ii({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e,t){var n=B9();function r(s,a){var l=Object.keys(s);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(s);a&&(c=c.filter(function(d){return Object.getOwnPropertyDescriptor(s,d).enumerable})),l.push.apply(l,c)}return l}function i(s){for(var a=1;a<arguments.length;a++){var l=arguments[a]!=null?arguments[a]:{};a%2?r(Object(l),!0).forEach(function(c){n(s,c,l[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(l)):r(Object(l)).forEach(function(c){Object.defineProperty(s,c,Object.getOwnPropertyDescriptor(l,c))})}return s}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}}),W9=Ii({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(e,t){function n(i){var s,a,l,c=2;for(typeof Symbol<"u"&&(a=Symbol.asyncIterator,l=Symbol.iterator);c--;){if(a&&(s=i[a])!=null)return s.call(i);if(l&&(s=i[l])!=null)return new r(s.call(i));a="@@asyncIterator",l="@@iterator"}throw new TypeError("Object is not async iterable")}function r(i){function s(a){if(Object(a)!==a)return Promise.reject(new TypeError(a+" is not an object."));var l=a.done;return Promise.resolve(a.value).then(function(c){return{value:c,done:l}})}return r=function(l){this.s=l,this.n=l.next},r.prototype={s:null,n:null,next:function(){return s(this.n.apply(this.s,arguments))},return:function(l){var c=this.s.return;return c===void 0?Promise.resolve({value:l,done:!0}):s(c.apply(this.s,arguments))},throw:function(l){var c=this.s.return;return c===void 0?Promise.reject(l):s(c.apply(this.s,arguments))}},new r(i)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),U9=Ii({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutPropertiesLoose.js"(e,t){function n(r,i){if(r==null)return{};var s={};for(var a in r)if({}.hasOwnProperty.call(r,a)){if(i.includes(a))continue;s[a]=r[a]}return s}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),H9=Ii({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutProperties.js"(e,t){var n=U9();function r(i,s){if(i==null)return{};var a,l,c=n(i,s);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(i);for(l=0;l<d.length;l++)a=d[l],s.includes(a)||{}.propertyIsEnumerable.call(i,a)&&(c[a]=i[a])}return c}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),wc=Mi(Cl(),1),q9=Mi(W9(),1),V9=Mi(H9(),1);const K9=["cursor","direction"];function Ef(e){return{path:e.path.join(".")}}function Q9(e){return e.length>=3}function v5(e){return Q9(e)?{type:"prefixed",prefix:e[0],path:e[1],args:e[2]}:{type:"unprefixed",prefix:void 0,path:e[0],args:e[1]}}function Qv(e,t,n){var r;const i=v5(e);let s=(r=i.args)===null||r===void 0?void 0:r.input;if(n){var a,l;s=(0,wc.default)((0,wc.default)((0,wc.default)({},(a=(l=i.args)===null||l===void 0?void 0:l.input)!==null&&a!==void 0?a:{}),n.pageParam!==void 0?{cursor:n.pageParam}:{}),{},{direction:n.direction})}return[i.path.join("."),s,t==null?void 0:t.trpc]}async function G9(e,t,n){const i=t.getQueryCache().build(t,{queryKey:n});i.setState({data:[],status:"success"});const s=[];var a=!1,l=!1,c;try{for(var d=(0,q9.default)(e),u;a=!(u=await d.next()).done;a=!1){const p=u.value;s.push(p),i.setState({data:[...s]})}}catch(p){l=!0,c=p}finally{try{a&&d.return!=null&&await d.return()}finally{if(l)throw c}}return s}function Yr(e){const t=Hv(()=>{const{input:n,type:r}=e,i=e.path.flatMap(s=>s.split("."));if(!n&&r==="any")return i.length?[i]:[];if(r==="infinite"&&wi(n)&&("direction"in n||"cursor"in n)){const{cursor:s,direction:a}=n,l=(0,V9.default)(n,K9);return[i,{input:l,type:"infinite"}]}return[i,(0,wc.default)((0,wc.default)({},typeof n<"u"&&n!==bo&&{input:n}),r&&r!=="any"&&{type:r})]});return e.prefix&&t.unshift([e.prefix]),t}function y5(e){const t=[e.path.flatMap(n=>n.split("."))];return e.prefix&&t.unshift([e.prefix]),t}function Gv(e){return mI(e)?e():e}var Us=Mi(Cl());function Y9(e){var t;const{input:n,query:r,path:i,queryKey:s,opts:a}=e,l=n===bo,c=async d=>{var u;const p=(0,Us.default)((0,Us.default)({},a),{},{trpc:(0,Us.default)((0,Us.default)({},a==null?void 0:a.trpc),!(a==null||(u=a.trpc)===null||u===void 0)&&u.abortOnUnmount?{signal:d.signal}:{signal:null})});return await r(...Qv(s,p,{direction:d.direction,pageParam:d.pageParam}))};return Object.assign((0,Us.default)((0,Us.default)({},a??{}),{},{queryKey:s,queryFn:l?bo:c,initialPageParam:(t=a==null?void 0:a.initialCursor)!==null&&t!==void 0?t:n==null?void 0:n.cursor}),{trpc:Ef({path:i})})}var lb=Mi(Cl());function X9(e){var t,n;const{mutate:r,path:i,prefix:s,opts:a,overrides:l}=e,c=Gv(e.queryClient),d=y5({path:i,prefix:(t=a==null?void 0:a.keyPrefix)!==null&&t!==void 0?t:s}),u=c.defaultMutationOptions(c.getMutationDefaults(d)),p=(n=l==null?void 0:l.onSuccess)!==null&&n!==void 0?n:g=>g.originalFn(),h=async g=>await r(...Qv([...d,{input:g}],a));return(0,lb.default)((0,lb.default)({},a),{},{mutationKey:d,mutationFn:h,onSuccess(...g){var v,x;return p({originalFn:()=>{var b,y,j;return(b=a==null||(y=a.onSuccess)===null||y===void 0?void 0:y.call(a,...g))!==null&&b!==void 0?b:u==null||(j=u.onSuccess)===null||j===void 0?void 0:j.call(u,...g)},queryClient:c,meta:(v=(x=a==null?void 0:a.meta)!==null&&x!==void 0?x:u==null?void 0:u.meta)!==null&&v!==void 0?v:{}})},trpc:Ef({path:i})})}var Hs=Mi(Cl());function J9(e){const{input:t,query:n,path:r,queryKey:i,opts:s}=e,a=Gv(e.queryClient),l=t===bo,c=async d=>{var u;const p=(0,Hs.default)((0,Hs.default)({},s),{},{trpc:(0,Hs.default)((0,Hs.default)({},s==null?void 0:s.trpc),!(s==null||(u=s.trpc)===null||u===void 0)&&u.abortOnUnmount?{signal:d.signal}:{signal:null})}),h=d.queryKey,g=await n(...Qv(h,p));return yI(g)?G9(g,a,h):g};return Object.assign((0,Hs.default)((0,Hs.default)({},s),{},{queryKey:i,queryFn:l?bo:c}),{trpc:Ef({path:r})})}var cb=Mi(Cl(),1);const Z9=e=>{var t;const{subscribe:n,path:r,queryKey:i,opts:s={}}=e,a=(t=v5(i))===null||t===void 0||(t=t.args)===null||t===void 0?void 0:t.input,l="enabled"in s?!!s.enabled:a!==bo,c=d=>n(r.join("."),a??void 0,d);return(0,cb.default)((0,cb.default)({},s),{},{enabled:l,subscribe:c,queryKey:i,trpc:Ef({path:r})})};var qs=Mi(Cl(),1);function eM(e){const t=e.keyPrefix,n=r=>(i,s,a)=>"router"in e?Promise.resolve(Gv(e.ctx)).then(c=>NI({router:e.router,path:i,getRawInput:async()=>s,ctx:c,type:r,signal:void 0,batchIndex:0})):(e.client instanceof p5?e.client:T9(e.client))[r](i,s,a);return r5(({args:r,path:i})=>{const s=[...i],a=s.pop(),[l,c]=r;return{"~types":void 0,pathKey:()=>Yr({path:s,type:"any",prefix:t}),pathFilter:()=>(0,qs.default)((0,qs.default)({},l),{},{queryKey:Yr({path:s,type:"any",prefix:t})}),queryOptions:()=>J9({input:l,opts:c,path:s,queryClient:e.queryClient,queryKey:Yr({path:s,input:l,type:"query",prefix:t}),query:n("query")}),queryKey:()=>Yr({path:s,input:l,type:"query",prefix:t}),queryFilter:()=>(0,qs.default)((0,qs.default)({},c),{},{queryKey:Yr({path:s,input:l,type:"query",prefix:t})}),infiniteQueryOptions:()=>Y9({input:l,opts:c,path:s,queryKey:Yr({path:s,input:l,type:"infinite",prefix:t}),query:n("query")}),infiniteQueryKey:()=>Yr({path:s,input:l,type:"infinite",prefix:t}),infiniteQueryFilter:()=>(0,qs.default)((0,qs.default)({},c),{},{queryKey:Yr({path:s,input:l,type:"infinite",prefix:t})}),mutationOptions:()=>{var u;return X9({opts:l,path:s,prefix:t,queryClient:e.queryClient,mutate:n("mutation"),overrides:(u=e.overrides)===null||u===void 0?void 0:u.mutations})},mutationKey:()=>y5({path:s,prefix:t}),subscriptionOptions:()=>Z9({opts:c,path:s,queryKey:Yr({path:s,input:l,type:"any",prefix:t}),subscribe:n("subscription")})}[a]()})}function tM(){const e=f.createContext(null),t=f.createContext(null),n=s=>{const a=f.useMemo(()=>eM({client:s.trpcClient,queryClient:s.queryClient,keyPrefix:s.keyPrefix}),[s.trpcClient,s.queryClient,s.keyPrefix]);return o.jsx(e.Provider,{value:s.trpcClient,children:o.jsx(t.Provider,{value:a,children:s.children})})};n.displayName="TRPCProvider";function r(){const s=f.useContext(t);if(!s)throw new Error("useTRPC() can only be used inside of a <TRPCProvider>");return s}function i(){const s=f.useContext(e);if(!s)throw new Error("useTRPCClient() can only be used inside of a <TRPCProvider>");return s}return{TRPCProvider:n,useTRPC:r,useTRPCClient:i}}class Vh extends Error{constructor(t,n){super(t),this.name="ParseError",this.type=n.type,this.field=n.field,this.value=n.value,this.line=n.line}}const db=10,nM=13,Vi=32;function Kh(e){}function rM(e){if(typeof e=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");const{onEvent:t=Kh,onError:n=Kh,onRetry:r=Kh,onComment:i,maxBufferSize:s}=e,a=[];let l=0,c=!0,d,u="",p=0,h,g=!1;function v(k){if(g)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,k.charCodeAt(0)===239&&k.charCodeAt(1)===187&&k.charCodeAt(2)===191&&(k=k.slice(3))),a.length===0){const R=w(k);R!==""&&(a.push(R),l=R.length),x();return}if(k.indexOf(`
|
|
41
|
+
`)===-1&&k.indexOf("\r")===-1){a.push(k),l+=k.length,x();return}a.push(k);const E=a.join("");a.length=0,l=0;const C=w(E);C!==""&&(a.push(C),l=C.length),x()}function x(){s!==void 0&&(l+u.length<=s||(g=!0,a.length=0,l=0,d=void 0,u="",p=0,h=void 0,n(new Vh(`Buffered data exceeded max buffer size of ${s} characters`,{type:"max-buffer-size-exceeded"}))))}function w(k){let E=0;if(k.indexOf("\r")===-1){let C=k.indexOf(`
|
|
42
|
+
`,E);for(;C!==-1;){if(E===C){p>0&&t({id:d,event:h,data:u}),d=void 0,u="",p=0,h=void 0,E=C+1,C=k.indexOf(`
|
|
43
|
+
`,E);continue}const R=k.charCodeAt(E);if(ub(k,E,R)){const P=k.charCodeAt(E+5)===Vi?E+6:E+5,L=k.slice(P,C);if(p===0&&k.charCodeAt(C+1)===db){t({id:d,event:h,data:L}),d=void 0,u="",h=void 0,E=C+2,C=k.indexOf(`
|
|
44
|
+
`,E);continue}u=p===0?L:`${u}
|
|
45
|
+
${L}`,p++}else pb(k,E,R)?h=k.slice(k.charCodeAt(E+6)===Vi?E+7:E+6,C)||void 0:b(k,E,C);E=C+1,C=k.indexOf(`
|
|
46
|
+
`,E)}return k.slice(E)}for(;E<k.length;){const C=k.indexOf("\r",E),R=k.indexOf(`
|
|
47
|
+
`,E);let P=-1;if(C!==-1&&R!==-1?P=C<R?C:R:C!==-1?C===k.length-1?P=-1:P=C:R!==-1&&(P=R),P===-1)break;b(k,E,P),E=P+1,k.charCodeAt(E-1)===nM&&k.charCodeAt(E)===db&&E++}return k.slice(E)}function b(k,E,C){if(E===C){j();return}const R=k.charCodeAt(E);if(ub(k,E,R)){const $=k.charCodeAt(E+5)===Vi?E+6:E+5,W=k.slice($,C);u=p===0?W:`${u}
|
|
48
|
+
${W}`,p++;return}if(pb(k,E,R)){h=k.slice(k.charCodeAt(E+6)===Vi?E+7:E+6,C)||void 0;return}if(R===105&&k.charCodeAt(E+1)===100&&k.charCodeAt(E+2)===58){const $=k.slice(k.charCodeAt(E+3)===Vi?E+4:E+3,C);d=$.includes("\0")?void 0:$;return}if(R===58){if(i){const $=k.slice(E,C);i($.slice(k.charCodeAt(E+1)===Vi?2:1))}return}const P=k.slice(E,C),L=P.indexOf(":");if(L===-1){y(P,"",P);return}const _=P.slice(0,L),U=P.charCodeAt(L+1)===Vi?2:1,K=P.slice(L+U);y(_,K,P)}function y(k,E,C){switch(k){case"event":h=E||void 0;break;case"data":u=p===0?E:`${u}
|
|
49
|
+
${E}`,p++;break;case"id":d=E.includes("\0")?void 0:E;break;case"retry":/^\d+$/.test(E)?r(parseInt(E,10)):n(new Vh(`Invalid \`retry\` value: "${E}"`,{type:"invalid-retry",value:E,line:C}));break;default:n(new Vh(`Unknown field "${k.length>20?`${k.slice(0,20)}…`:k}"`,{type:"unknown-field",field:k,value:E,line:C}));break}}function j(){p>0&&t({id:d,event:h,data:u}),d=void 0,u="",p=0,h=void 0}function S(k={}){if(k.consume&&a.length>0){const E=a.join("");b(E,0,E.length)}c=!0,d=void 0,u="",p=0,h=void 0,a.length=0,l=0,g=!1}return{feed:v,reset:S}}function ub(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function pb(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}class fb extends Event{constructor(t,n){var r,i;super(t),this.code=(r=n==null?void 0:n.code)!=null?r:void 0,this.message=(i=n==null?void 0:n.message)!=null?i:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,n,r){return r(hb(this),n)}[Symbol.for("Deno.customInspect")](t,n){return t(hb(this),n)}}function oM(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function Vx(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(Vx).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${Vx(e.cause)}`:e.message:`${e}`}function hb(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var b5=e=>{throw TypeError(e)},Yv=(e,t,n)=>t.has(e)||b5("Cannot "+n),Re=(e,t,n)=>(Yv(e,t,"read from private field"),n?n.call(e):t.get(e)),Et=(e,t,n)=>t.has(e)?b5("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ot=(e,t,n,r)=>(Yv(e,t,"write to private field"),t.set(e,n),n),Zr=(e,t,n)=>(Yv(e,t,"access private method"),n),yn,es,ia,ip,Up,kc,Sa,Sc,Go,sa,Oa,aa,sc,ir,Kx,Qx,Gx,gb,Yx,Xx,ac,Jx,Zx;class sp extends EventTarget{constructor(t,n){var r,i;super(),Et(this,ir),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,Et(this,yn),Et(this,es),Et(this,ia),Et(this,ip),Et(this,Up),Et(this,kc),Et(this,Sa),Et(this,Sc,null),Et(this,Go),Et(this,sa),Et(this,Oa,null),Et(this,aa,null),Et(this,sc,null),Et(this,Qx,async s=>{var a;Re(this,sa).reset();const{body:l,redirected:c,status:d,headers:u}=s;if(d===204){Zr(this,ir,ac).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?ot(this,ia,new URL(s.url)):ot(this,ia,void 0),d!==200){Zr(this,ir,ac).call(this,`Non-200 status code (${d})`,d);return}if(!(u.get("content-type")||"").startsWith("text/event-stream")){Zr(this,ir,ac).call(this,'Invalid content type, expected "text/event-stream"',d);return}if(Re(this,yn)===this.CLOSED)return;ot(this,yn,this.OPEN);const p=new Event("open");if((a=Re(this,sc))==null||a.call(this,p),this.dispatchEvent(p),typeof l!="object"||!l||!("getReader"in l)){Zr(this,ir,ac).call(this,"Invalid response body, expected a web ReadableStream",d),this.close();return}const h=new TextDecoder,g=l.getReader();let v=!0;do{const{done:x,value:w}=await g.read();w&&Re(this,sa).feed(h.decode(w,{stream:!x})),x&&(v=!1,Re(this,sa).reset(),Zr(this,ir,Jx).call(this))}while(v)}),Et(this,Gx,s=>{ot(this,Go,void 0),!(s.name==="AbortError"||s.type==="aborted")&&Zr(this,ir,Jx).call(this,Vx(s))}),Et(this,Yx,s=>{typeof s.id=="string"&&ot(this,Sc,s.id);const a=new MessageEvent(s.event||"message",{data:s.data,origin:Re(this,ia)?Re(this,ia).origin:Re(this,es).origin,lastEventId:s.id||""});Re(this,aa)&&(!s.event||s.event==="message")&&Re(this,aa).call(this,a),this.dispatchEvent(a)}),Et(this,Xx,s=>{ot(this,kc,s)}),Et(this,Zx,()=>{ot(this,Sa,void 0),Re(this,yn)===this.CONNECTING&&Zr(this,ir,Kx).call(this)});try{if(t instanceof URL)ot(this,es,t);else if(typeof t=="string")ot(this,es,new URL(t,iM()));else throw new Error("Invalid URL")}catch{throw oM("An invalid or illegal string was specified")}ot(this,sa,rM({onEvent:Re(this,Yx),onRetry:Re(this,Xx)})),ot(this,yn,this.CONNECTING),ot(this,kc,3e3),ot(this,Up,(r=n==null?void 0:n.fetch)!=null?r:globalThis.fetch),ot(this,ip,(i=n==null?void 0:n.withCredentials)!=null?i:!1),Zr(this,ir,Kx).call(this)}get readyState(){return Re(this,yn)}get url(){return Re(this,es).href}get withCredentials(){return Re(this,ip)}get onerror(){return Re(this,Oa)}set onerror(t){ot(this,Oa,t)}get onmessage(){return Re(this,aa)}set onmessage(t){ot(this,aa,t)}get onopen(){return Re(this,sc)}set onopen(t){ot(this,sc,t)}addEventListener(t,n,r){const i=n;super.addEventListener(t,i,r)}removeEventListener(t,n,r){const i=n;super.removeEventListener(t,i,r)}close(){Re(this,Sa)&&clearTimeout(Re(this,Sa)),Re(this,yn)!==this.CLOSED&&(Re(this,Go)&&Re(this,Go).abort(),ot(this,yn,this.CLOSED),ot(this,Go,void 0))}}yn=new WeakMap,es=new WeakMap,ia=new WeakMap,ip=new WeakMap,Up=new WeakMap,kc=new WeakMap,Sa=new WeakMap,Sc=new WeakMap,Go=new WeakMap,sa=new WeakMap,Oa=new WeakMap,aa=new WeakMap,sc=new WeakMap,ir=new WeakSet,Kx=function(){ot(this,yn,this.CONNECTING),ot(this,Go,new AbortController),Re(this,Up)(Re(this,es),Zr(this,ir,gb).call(this)).then(Re(this,Qx)).catch(Re(this,Gx))},Qx=new WeakMap,Gx=new WeakMap,gb=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...Re(this,Sc)?{"Last-Event-ID":Re(this,Sc)}:void 0},cache:"no-store",signal:(e=Re(this,Go))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},Yx=new WeakMap,Xx=new WeakMap,ac=function(e,t){var n;Re(this,yn)!==this.CLOSED&&ot(this,yn,this.CLOSED);const r=new fb("error",{code:t,message:e});(n=Re(this,Oa))==null||n.call(this,r),this.dispatchEvent(r)},Jx=function(e,t){var n;if(Re(this,yn)===this.CLOSED)return;ot(this,yn,this.CONNECTING);const r=new fb("error",{code:t,message:e});(n=Re(this,Oa))==null||n.call(this,r),this.dispatchEvent(r),ot(this,Sa,setTimeout(Re(this,Zx),Re(this,kc)))},Zx=new WeakMap,sp.CONNECTING=0,sp.OPEN=1,sp.CLOSED=2;function iM(){const e="document"in globalThis?globalThis.document:void 0;return e&&typeof e=="object"&&"baseURI"in e&&typeof e.baseURI=="string"?e.baseURI:void 0}const{TRPCProvider:sM,useTRPC:ae,useTRPCClient:Rf}=tM();function aM(e){return e?`${e.serverUrl}/trpc`:"/trpc"}function lM(e){return e?{"x-cortex-token":e.token}:{}}function cM(e){return(t,n)=>fetch(t,{signal:n.signal,headers:{...n.headers,"x-cortex-token":e},mode:n.mode,credentials:n.credentials,cache:n.cache,redirect:n.redirect})}function dM(e){const t=aM(e),n=lM(e);return C9({links:[xI({condition:r=>r.type==="subscription",true:ab(e?{url:t,EventSource:sp,eventSourceOptions:()=>({fetch:cM(e.token)})}:{url:t}),false:g9({url:t,headers:()=>n})})]})}function Hp(){const e=globalThis.__CORTEX_DESKTOP_CONFIG;if(e!=null&&e.serverUrl&&(e!=null&&e.token))return{serverUrl:e.serverUrl,token:e.token}}function Xv(){var e;return((e=Hp())==null?void 0:e.serverUrl)??""}function Rs(){const e=Hp();return e?{"x-cortex-token":e.token}:{}}function uM(){return globalThis.__CORTEX_DESKTOP__===!0}function Pf(){return globalThis.__CORTEX_MOBILE__===!0}function on(){return uM()||Pf()}const pM=["running","waiting","done","failed","cancelled"],fM={running:"running",open:"running",waiting:"waiting",completed:"done",done:"done",failed:"failed",aborted:"failed",cancelled:"cancelled",stale:"cancelled"};function hM(e){return fM[e.toLowerCase()]??"cancelled"}const gM={running:"bg-pill-running-bg text-pill-running-fg",waiting:"bg-pill-waiting-bg text-pill-waiting-fg",done:"bg-pill-done-bg text-pill-done-fg",failed:"bg-pill-failed-bg text-pill-failed-fg",cancelled:"bg-pill-cancelled-bg text-pill-cancelled-fg"},xM="inline-flex items-center rounded-card px-1g py-0.5g font-mono text-ui leading-none";function qp({tone:e,status:t,label:n,className:r}){const i=e??(t?hM(t):"cancelled"),s=n??t??i;return o.jsx("span",{className:[xM,gM[i],r].filter(Boolean).join(" "),children:s})}function bn({children:e,className:t,muted:n,as:r="span"}){return o.jsx(r,{className:["font-mono text-ui",n?"text-state-ink/60":"",t].filter(Boolean).join(" "),children:e})}function em({value:e,copyable:t,className:n}){const[r,i]=f.useState(!1),s=f.useCallback(()=>{var l;const a=(l=navigator.clipboard)==null?void 0:l.writeText(e);a&&a.then(()=>{i(!0),setTimeout(()=>i(!1),1200)}).catch(()=>{})},[e]);return t?o.jsxs("button",{type:"button",onClick:s,title:r?"Copied":"Copy",className:["group inline-flex items-center gap-0.5g rounded-card px-0.5g font-mono text-ui","text-state-ink/60 transition-colors hover:bg-surface-canvas-alt hover:text-state-ink","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",n].filter(Boolean).join(" "),children:[e,o.jsx("span",{className:"text-state-ink/40 group-hover:text-state-ink/70",children:r?"✓":"⧉"})]}):o.jsx(bn,{muted:!0,className:n,children:e})}function tm({children:e,className:t,padded:n}){return o.jsx("div",{className:["rounded-card border border-card bg-surface-card shadow-card",n?"p-2g":"",t].filter(Boolean).join(" "),children:e})}function mM({children:e,className:t}){return o.jsx("div",{className:["border-b border-card px-2g py-1.5g",t].filter(Boolean).join(" "),children:e})}function vM({children:e,className:t}){return o.jsx("div",{className:["p-2g",t].filter(Boolean).join(" "),children:e})}function la({title:e,count:t,description:n,actions:r,className:i}){return o.jsxs("div",{className:["flex flex-col gap-0.5g",i].filter(Boolean).join(" "),children:[o.jsxs("div",{className:"flex items-center gap-1g",children:[o.jsx("h2",{className:"text-body font-medium text-state-ink",children:e}),t!==void 0&&o.jsx(bn,{muted:!0,className:"rounded-card bg-surface-canvas-alt px-1g py-0.5g",children:t}),r&&o.jsx("div",{className:"ml-auto flex items-center gap-1g",children:r})]}),n&&o.jsx("p",{className:"text-ui text-state-ink/60",children:n})]})}const yM={primary:"bg-state-run text-surface-card hover:bg-state-run/90",secondary:"border border-card bg-surface-card text-state-ink hover:bg-surface-canvas-alt",ghost:"text-state-ink/80 hover:bg-surface-canvas-alt",danger:"bg-state-fail text-surface-card hover:bg-state-fail/90"},bM={sm:"px-1g py-0.5g text-ui",md:"px-2g py-1g text-ui"},jM="inline-flex items-center justify-center gap-1g rounded-card font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40 disabled:cursor-not-allowed disabled:opacity-50",jt=f.forwardRef(function({variant:t="secondary",size:n="md",className:r,type:i="button",...s},a){return o.jsx("button",{ref:a,type:i,className:[jM,yM[t],bM[n],r].filter(Boolean).join(" "),...s})});function Te(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}function Li(e,t=[]){let n=[];function r(s,a){const l=f.createContext(a);l.displayName=s+"Context";const c=n.length;n=[...n,a];const d=p=>{var b;const{scope:h,children:g,...v}=p,x=((b=h==null?void 0:h[e])==null?void 0:b[c])||l,w=f.useMemo(()=>v,Object.values(v));return o.jsx(x.Provider,{value:w,children:g})};d.displayName=s+"Provider";function u(p,h){var x;const g=((x=h==null?void 0:h[e])==null?void 0:x[c])||l,v=f.useContext(g);if(v)return v;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[d,u]}const i=()=>{const s=n.map(a=>f.createContext(a));return function(l){const c=(l==null?void 0:l[e])||s;return f.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return i.scopeName=e,[r,wM(i,...t)]}function wM(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const a=r.reduce((l,{useScope:c,scopeName:d})=>{const p=c(s)[`__scope${d}`];return{...l,...p}},{});return f.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}function xb(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function ol(...e){return t=>{let n=!1;const r=e.map(i=>{const s=xb(i,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let i=0;i<r.length;i++){const s=r[i];typeof s=="function"?s():xb(e[i],null)}}}}function Ft(...e){return f.useCallback(ol(...e),e)}function Zc(e){const t=f.forwardRef((n,r)=>{let{children:i,...s}=n,a=null,l=!1;const c=[];mb(i)&&typeof vu=="function"&&(i=vu(i._payload)),f.Children.forEach(i,h=>{var g;if(EM(h)){l=!0;const v=h;let x="child"in v.props?v.props.child:v.props.children;mb(x)&&typeof vu=="function"&&(x=vu(x._payload)),a=SM(v,x),c.push((g=a==null?void 0:a.props)==null?void 0:g.children)}else c.push(h)}),a?a=f.cloneElement(a,void 0,c):!l&&f.Children.count(i)===1&&f.isValidElement(i)&&(a=i);const d=a?TM(a):void 0,u=Ft(r,d);if(!a){if(i||i===0)throw new Error(l?MM(e):IM(e));return i}const p=CM(s,a.props??{});return a.type!==f.Fragment&&(p.ref=r?u:d),f.cloneElement(a,p)});return t.displayName=`${e}.Slot`,t}var j5=Symbol.for("radix.slottable");function kM(e){const t=n=>"child"in n?n.children(n.child):n.children;return t.displayName=`${e}.Slottable`,t.__radixId=j5,t}var SM=(e,t)=>{if("child"in e.props){const n=e.props.child;return f.isValidElement(n)?f.cloneElement(n,void 0,e.props.children(n.props.children)):null}return f.isValidElement(t)?t:null};function CM(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...l)=>{const c=s(...l);return i(...l),c}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function TM(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function EM(e){return f.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===j5}var RM=Symbol.for("react.lazy");function mb(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===RM&&"_payload"in e&&PM(e._payload)}function PM(e){return typeof e=="object"&&e!==null&&"then"in e}var IM=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,MM=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,vu=yl[" use ".trim().toString()];function w5(e){const t=e+"CollectionProvider",[n,r]=Li(t),[i,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=x=>{const{scope:w,children:b}=x,y=f.useRef(null),j=f.useRef(new Map).current;return o.jsx(i,{scope:w,itemMap:j,collectionRef:y,children:b})};a.displayName=t;const l=e+"CollectionSlot",c=Zc(l),d=f.forwardRef((x,w)=>{const{scope:b,children:y}=x,j=s(l,b),S=Ft(w,j.collectionRef);return o.jsx(c,{ref:S,children:y})});d.displayName=l;const u=e+"CollectionItemSlot",p="data-radix-collection-item",h=Zc(u),g=f.forwardRef((x,w)=>{const{scope:b,children:y,...j}=x,S=f.useRef(null),k=Ft(w,S),E=s(u,b);return f.useEffect(()=>(E.itemMap.set(S,{ref:S,...j}),()=>void E.itemMap.delete(S))),o.jsx(h,{[p]:"",ref:k,children:y})});g.displayName=u;function v(x){const w=s(e+"CollectionConsumer",x);return f.useCallback(()=>{const y=w.collectionRef.current;if(!y)return[];const j=Array.from(y.querySelectorAll(`[${p}]`));return Array.from(w.itemMap.values()).sort((E,C)=>j.indexOf(E.ref.current)-j.indexOf(C.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:a,Slot:d,ItemSlot:g},v,r]}var gr=globalThis!=null&&globalThis.document?f.useLayoutEffect:()=>{},LM=yl[" useId ".trim().toString()]||(()=>{}),OM=0;function Nn(e){const[t,n]=f.useState(LM());return gr(()=>{n(r=>r??String(OM++))},[e]),e||(t?`radix-${t}`:"")}var DM=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Me=DM.reduce((e,t)=>{const n=Zc(`Primitive.${t}`),r=f.forwardRef((i,s)=>{const{asChild:a,...l}=i,c=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(c,{...l,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function k5(e,t){e&&Ns.flushSync(()=>e.dispatchEvent(t))}function zr(e){const t=f.useRef(e);return f.useEffect(()=>{t.current=e}),f.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}var vb=yl[" useEffectEvent ".trim().toString()],yb=yl[" useInsertionEffect ".trim().toString()];function AM(e){if(typeof vb=="function")return vb(e);const t=f.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof yb=="function"?yb(()=>{t.current=e}):gr(()=>{t.current=e}),f.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}var NM=yl[" useInsertionEffect ".trim().toString()]||gr;function Tl({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[i,s,a]=$M({defaultProp:t,onChange:n}),l=e!==void 0,c=l?e:i;{const u=f.useRef(e!==void 0);f.useEffect(()=>{const p=u.current;p!==l&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=l},[l,r])}const d=f.useCallback(u=>{var p;if(l){const h=_M(u)?u(e):u;h!==e&&((p=a.current)==null||p.call(a,h))}else s(u)},[l,e,s,a]);return[c,d]}function $M({defaultProp:e,onChange:t}){const[n,r]=f.useState(e),i=f.useRef(n),s=f.useRef(t);return NM(()=>{s.current=t},[t]),f.useEffect(()=>{var a;i.current!==n&&((a=s.current)==null||a.call(s,n),i.current=n)},[n,i]),[n,r,s]}function _M(e){return typeof e=="function"}var FM=f.createContext(void 0);function S5(e){const t=f.useContext(FM);return e||t||"ltr"}var Qh="rovingFocusGroup.onEntryFocus",zM={bubbles:!1,cancelable:!0},Cd="RovingFocusGroup",[nm,C5,BM]=w5(Cd),[WM,T5]=Li(Cd,[BM]),[UM,HM]=WM(Cd),E5=f.forwardRef((e,t)=>o.jsx(nm.Provider,{scope:e.__scopeRovingFocusGroup,children:o.jsx(nm.Slot,{scope:e.__scopeRovingFocusGroup,children:o.jsx(qM,{...e,ref:t})})}));E5.displayName=Cd;var qM=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:u=!1,...p}=e,h=f.useRef(null),g=Ft(t,h),v=S5(s),[x,w]=Tl({prop:a,defaultProp:l??null,onChange:c,caller:Cd}),[b,y]=f.useState(!1),j=zr(d),S=C5(n),k=f.useRef(!1),[E,C]=f.useState(0);return f.useEffect(()=>{const R=h.current;if(R)return R.addEventListener(Qh,j),()=>R.removeEventListener(Qh,j)},[j]),o.jsx(UM,{scope:n,orientation:r,dir:v,loop:i,currentTabStopId:x,onItemFocus:f.useCallback(R=>w(R),[w]),onItemShiftTab:f.useCallback(()=>y(!0),[]),onFocusableItemAdd:f.useCallback(()=>C(R=>R+1),[]),onFocusableItemRemove:f.useCallback(()=>C(R=>R-1),[]),children:o.jsx(Me.div,{tabIndex:b||E===0?-1:0,"data-orientation":r,...p,ref:g,style:{outline:"none",...e.style},onMouseDown:Te(e.onMouseDown,()=>{k.current=!0}),onFocus:Te(e.onFocus,R=>{const P=!k.current;if(R.target===R.currentTarget&&P&&!b){const L=new CustomEvent(Qh,zM);if(R.currentTarget.dispatchEvent(L),!L.defaultPrevented){const _=S().filter(V=>V.focusable),U=_.find(V=>V.active),K=_.find(V=>V.id===x),W=[U,K,..._].filter(Boolean).map(V=>V.ref.current);I5(W,u)}}k.current=!1}),onBlur:Te(e.onBlur,()=>y(!1))})})}),R5="RovingFocusGroupItem",P5=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:a,...l}=e,c=Nn(),d=s||c,u=HM(R5,n),p=u.currentTabStopId===d,h=C5(n),{onFocusableItemAdd:g,onFocusableItemRemove:v,currentTabStopId:x}=u;return f.useEffect(()=>{if(r)return g(),()=>v()},[r,g,v]),o.jsx(nm.ItemSlot,{scope:n,id:d,focusable:r,active:i,children:o.jsx(Me.span,{tabIndex:p?0:-1,"data-orientation":u.orientation,...l,ref:t,onMouseDown:Te(e.onMouseDown,w=>{r?u.onItemFocus(d):w.preventDefault()}),onFocus:Te(e.onFocus,()=>u.onItemFocus(d)),onKeyDown:Te(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){u.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const b=QM(w,u.orientation,u.dir);if(b!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let j=h().filter(S=>S.focusable).map(S=>S.ref.current);if(b==="last")j.reverse();else if(b==="prev"||b==="next"){b==="prev"&&j.reverse();const S=j.indexOf(w.currentTarget);j=u.loop?GM(j,S+1):j.slice(S+1)}setTimeout(()=>I5(j))}}),children:typeof a=="function"?a({isCurrentTabStop:p,hasTabStop:x!=null}):a})})});P5.displayName=R5;var VM={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function KM(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function QM(e,t,n){const r=KM(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return VM[r]}function I5(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function GM(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var YM=E5,XM=P5;function JM(e,t){return f.useReducer((n,r)=>t[n][r]??n,e)}var Ur=e=>{const{present:t,children:n}=e,r=ZM(t),i=typeof n=="function"?n({present:r.isPresent}):f.Children.only(n),s=e7(r.ref,t7(i));return typeof n=="function"||r.isPresent?f.cloneElement(i,{ref:s}):null};Ur.displayName="Presence";function ZM(e){const[t,n]=f.useState(),r=f.useRef(null),i=f.useRef(e),s=f.useRef("none"),a=e?"mounted":"unmounted",[l,c]=JM(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return f.useEffect(()=>{const d=yu(r.current);s.current=l==="mounted"?d:"none"},[l]),gr(()=>{const d=r.current,u=i.current;if(u!==e){const h=s.current,g=yu(d);e?c("MOUNT"):g==="none"||(d==null?void 0:d.display)==="none"?c("UNMOUNT"):c(u&&h!==g?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,c]),gr(()=>{if(t){let d;const u=t.ownerDocument.defaultView??window,p=g=>{const x=yu(r.current).includes(CSS.escape(g.animationName));if(g.target===t&&x&&(c("ANIMATION_END"),!i.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",d=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},h=g=>{g.target===t&&(s.current=yu(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{u.clearTimeout(d),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:f.useCallback(d=>{r.current=d?getComputedStyle(d):null,n(d)},[])}}function bb(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function e7(...e){const t=f.useRef(e);return t.current=e,f.useCallback(n=>{const r=t.current;let i=!1;const s=r.map(a=>{const l=bb(a,n);return!i&&typeof l=="function"&&(i=!0),l});if(i)return()=>{for(let a=0;a<s.length;a++){const l=s[a];typeof l=="function"?l():bb(r[a],null)}}},[])}function yu(e){return(e==null?void 0:e.animationName)||"none"}function t7(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var If="Tabs",[n7]=Li(If,[T5]),M5=T5(),[r7,Jv]=n7(If),L5=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:s,orientation:a="horizontal",dir:l,activationMode:c="automatic",...d}=e,u=S5(l),[p,h]=Tl({prop:r,onChange:i,defaultProp:s??"",caller:If});return o.jsx(r7,{scope:n,baseId:Nn(),value:p,onValueChange:h,orientation:a,dir:u,activationMode:c,children:o.jsx(Me.div,{dir:u,"data-orientation":a,...d,ref:t})})});L5.displayName=If;var O5="TabsList",D5=f.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...i}=e,s=Jv(O5,n),a=M5(n);return o.jsx(YM,{asChild:!0,...a,orientation:s.orientation,dir:s.dir,loop:r,children:o.jsx(Me.div,{role:"tablist","aria-orientation":s.orientation,...i,ref:t})})});D5.displayName=O5;var A5="TabsTrigger",N5=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...s}=e,a=Jv(A5,n),l=M5(n),c=F5(a.baseId,r),d=z5(a.baseId,r),u=r===a.value;return o.jsx(XM,{asChild:!0,...l,focusable:!i,active:u,children:o.jsx(Me.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":d,"data-state":u?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:c,...s,ref:t,onMouseDown:Te(e.onMouseDown,p=>{!i&&p.button===0&&p.ctrlKey===!1?a.onValueChange(r):p.preventDefault()}),onKeyDown:Te(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&a.onValueChange(r)}),onFocus:Te(e.onFocus,()=>{const p=a.activationMode!=="manual";!u&&!i&&p&&a.onValueChange(r)})})})});N5.displayName=A5;var $5="TabsContent",_5=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:i,children:s,...a}=e,l=Jv($5,n),c=F5(l.baseId,r),d=z5(l.baseId,r),u=r===l.value,p=f.useRef(u);return f.useEffect(()=>{const h=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(h)},[]),o.jsx(Ur,{present:i||u,children:({present:h})=>o.jsx(Me.div,{"data-state":u?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!h,id:d,tabIndex:0,...a,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:h&&s})})});_5.displayName=$5;function F5(e,t){return`${e}-trigger-${t}`}function z5(e,t){return`${e}-content-${t}`}var o7=L5,i7=D5,s7=N5,a7=_5;const l7="flex items-center gap-0.5g border-b border-card",c7="rounded-t-card px-2g py-1g text-ui font-medium text-state-ink/60 transition-colors hover:text-state-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40 data-[state=active]:bg-pill-running-bg data-[state=active]:text-pill-running-fg";function d7({items:e,defaultValue:t,className:n}){var r;return o.jsxs(o7,{defaultValue:t??((r=e[0])==null?void 0:r.value),className:n,children:[o.jsx(i7,{className:l7,children:e.map(i=>o.jsx(s7,{value:i.value,className:c7,children:i.label},i.value))}),e.map(i=>o.jsx(a7,{value:i.value,className:"pt-2g",children:i.content},i.value))]})}var u7="DismissableLayer",rm="dismissableLayer.update",p7="dismissableLayer.pointerDownOutside",f7="dismissableLayer.focusOutside",jb,Zv=f.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Td=f.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...d}=e,u=f.useContext(Zv),[p,h]=f.useState(null),g=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,v]=f.useState({}),x=Ft(t,h),w=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=w.indexOf(b),j=p?w.indexOf(p):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,k=j>=y,E=f.useRef(!1),C=x7(_=>{const U=_.target;if(!(U instanceof Node))return;const K=[...u.branches].some($=>$.contains(U));!k||K||(s==null||s(_),l==null||l(_),_.defaultPrevented||c==null||c())},{ownerDocument:g,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:E,dismissableSurfaces:u.dismissableSurfaces}),R=m7(_=>{if(r&&E.current)return;const U=_.target;[...u.branches].some($=>$.contains(U))||(a==null||a(_),l==null||l(_),_.defaultPrevented||c==null||c())},g),P=p?j===w.length-1:!1,L=AM(_=>{_.key==="Escape"&&(i==null||i(_),!_.defaultPrevented&&c&&(_.preventDefault(),c()))});return f.useEffect(()=>{if(P)return g.addEventListener("keydown",L,{capture:!0}),()=>g.removeEventListener("keydown",L,{capture:!0})},[g,P]),f.useEffect(()=>{if(p)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(jb=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),wb(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(p),u.layersWithOutsidePointerEventsDisabled.size===0&&(g.body.style.pointerEvents=jb))}},[p,g,n,u]),f.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),wb())},[p,u]),f.useEffect(()=>{const _=()=>v({});return document.addEventListener(rm,_),()=>document.removeEventListener(rm,_)},[]),o.jsx(Me.div,{...d,ref:x,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:Te(e.onFocusCapture,R.onFocusCapture),onBlurCapture:Te(e.onBlurCapture,R.onBlurCapture),onPointerDownCapture:Te(e.onPointerDownCapture,C.onPointerDownCapture)})});Td.displayName=u7;var h7="DismissableLayerBranch",B5=f.forwardRef((e,t)=>{const n=f.useContext(Zv),r=f.useRef(null),i=Ft(t,r);return f.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),o.jsx(Me.div,{...e,ref:i})});B5.displayName=h7;function g7(){const e=f.useContext(Zv),[t,n]=f.useState(null);return f.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}function x7(e,t){const{ownerDocument:n=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:s}=t,a=zr(e),l=f.useRef(!1),c=f.useRef(!1),d=f.useRef(new Map),u=f.useRef(()=>{});return f.useEffect(()=>{function p(){c.current=!1,i.current=!1,d.current.clear()}function h(){return Array.from(d.current.values()).some(Boolean)}function g(y){if(!c.current)return;const j=y.target;j instanceof Node&&[...s].some(k=>k.contains(j))||d.current.set(y.type,!0),y.type==="click"&&window.setTimeout(()=>{c.current&&u.current()},0)}function v(y){c.current&&d.current.set(y.type,!1)}const x=y=>{if(y.target&&!l.current){let j=function(){n.removeEventListener("click",u.current);const k=h();p(),k||W5(p7,a,S,{discrete:!0})};const S={originalEvent:y};c.current=!0,i.current=r&&y.button===0,d.current.clear(),!r||y.button!==0?j():(n.removeEventListener("click",u.current),u.current=j,n.addEventListener("click",u.current,{once:!0}))}else n.removeEventListener("click",u.current),p();l.current=!1},w=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const y of w)n.addEventListener(y,g,!0),n.addEventListener(y,v);const b=window.setTimeout(()=>{n.addEventListener("pointerdown",x)},0);return()=>{window.clearTimeout(b),n.removeEventListener("pointerdown",x),n.removeEventListener("click",u.current);for(const y of w)n.removeEventListener(y,g,!0),n.removeEventListener(y,v)}},[n,a,r,i,s]),{onPointerDownCapture:()=>l.current=!0}}function m7(e,t=globalThis==null?void 0:globalThis.document){const n=zr(e),r=f.useRef(!1);return f.useEffect(()=>{const i=s=>{s.target&&!r.current&&W5(f7,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function wb(){const e=new CustomEvent(rm);document.dispatchEvent(e)}function W5(e,t,n,{discrete:r}){const i=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?k5(i,s):i.dispatchEvent(s)}var v7=Td,y7=B5;const b7=["top","right","bottom","left"],ki=Math.min,Ln=Math.max,Vp=Math.round,bu=Math.floor,_r=e=>({x:e,y:e}),j7={left:"right",right:"left",bottom:"top",top:"bottom"};function om(e,t,n){return Ln(e,ki(t,n))}function jo(e,t){return typeof e=="function"?e(t):e}function wo(e){return e.split("-")[0]}function El(e){return e.split("-")[1]}function e0(e){return e==="x"?"y":"x"}function t0(e){return e==="y"?"height":"width"}function Ar(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function n0(e){return e0(Ar(e))}function w7(e,t,n){n===void 0&&(n=!1);const r=El(e),i=n0(e),s=t0(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Kp(a)),[a,Kp(a)]}function k7(e){const t=Kp(e);return[im(e),t,im(t)]}function im(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const kb=["left","right"],Sb=["right","left"],S7=["top","bottom"],C7=["bottom","top"];function T7(e,t,n){switch(e){case"top":case"bottom":return n?t?Sb:kb:t?kb:Sb;case"left":case"right":return t?S7:C7;default:return[]}}function E7(e,t,n,r){const i=El(e);let s=T7(wo(e),n==="start",r);return i&&(s=s.map(a=>a+"-"+i),t&&(s=s.concat(s.map(im)))),s}function Kp(e){const t=wo(e);return j7[t]+e.slice(t.length)}function R7(e){return{top:0,right:0,bottom:0,left:0,...e}}function U5(e){return typeof e!="number"?R7(e):{top:e,right:e,bottom:e,left:e}}function Qp(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Cb(e,t,n){let{reference:r,floating:i}=e;const s=Ar(t),a=n0(t),l=t0(a),c=wo(t),d=s==="y",u=r.x+r.width/2-i.width/2,p=r.y+r.height/2-i.height/2,h=r[l]/2-i[l]/2;let g;switch(c){case"top":g={x:u,y:r.y-i.height};break;case"bottom":g={x:u,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:p};break;case"left":g={x:r.x-i.width,y:p};break;default:g={x:r.x,y:r.y}}switch(El(t)){case"start":g[a]-=h*(n&&d?-1:1);break;case"end":g[a]+=h*(n&&d?-1:1);break}return g}async function P7(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:a,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:u="viewport",elementContext:p="floating",altBoundary:h=!1,padding:g=0}=jo(t,e),v=U5(g),w=l[h?p==="floating"?"reference":"floating":p],b=Qp(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(w)))==null||n?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:u,strategy:c})),y=p==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,j=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),S=await(s.isElement==null?void 0:s.isElement(j))?await(s.getScale==null?void 0:s.getScale(j))||{x:1,y:1}:{x:1,y:1},k=Qp(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:j,strategy:c}):y);return{top:(b.top-k.top+v.top)/S.y,bottom:(k.bottom-b.bottom+v.bottom)/S.y,left:(b.left-k.left+v.left)/S.x,right:(k.right-b.right+v.right)/S.x}}const I7=50,M7=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:P7},c=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:p}=Cb(d,r,c),h=r,g=0;const v={};for(let x=0;x<s.length;x++){const w=s[x];if(!w)continue;const{name:b,fn:y}=w,{x:j,y:S,data:k,reset:E}=await y({x:u,y:p,initialPlacement:r,placement:h,strategy:i,middlewareData:v,rects:d,platform:l,elements:{reference:e,floating:t}});u=j??u,p=S??p,v[b]={...v[b],...k},E&&g<I7&&(g++,typeof E=="object"&&(E.placement&&(h=E.placement),E.rects&&(d=E.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:i}):E.rects),{x:u,y:p}=Cb(d,h,c)),x=-1)}return{x:u,y:p,placement:h,strategy:i,middlewareData:v}},L7=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:a,elements:l,middlewareData:c}=t,{element:d,padding:u=0}=jo(e,t)||{};if(d==null)return{};const p=U5(u),h={x:n,y:r},g=n0(i),v=t0(g),x=await a.getDimensions(d),w=g==="y",b=w?"top":"left",y=w?"bottom":"right",j=w?"clientHeight":"clientWidth",S=s.reference[v]+s.reference[g]-h[g]-s.floating[v],k=h[g]-s.reference[g],E=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let C=E?E[j]:0;(!C||!await(a.isElement==null?void 0:a.isElement(E)))&&(C=l.floating[j]||s.floating[v]);const R=S/2-k/2,P=C/2-x[v]/2-1,L=ki(p[b],P),_=ki(p[y],P),U=L,K=C-x[v]-_,$=C/2-x[v]/2+R,W=om(U,$,K),V=!c.arrow&&El(i)!=null&&$!==W&&s.reference[v]/2-($<U?L:_)-x[v]/2<0,Z=V?$<U?$-U:$-K:0;return{[g]:h[g]+Z,data:{[g]:W,centerOffset:$-W-Z,...V&&{alignmentOffset:Z}},reset:V}}}),O7=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:a,initialPlacement:l,platform:c,elements:d}=t,{mainAxis:u=!0,crossAxis:p=!0,fallbackPlacements:h,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:x=!0,...w}=jo(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const b=wo(i),y=Ar(l),j=wo(l)===l,S=await(c.isRTL==null?void 0:c.isRTL(d.floating)),k=h||(j||!x?[Kp(l)]:k7(l)),E=v!=="none";!h&&E&&k.push(...E7(l,x,v,S));const C=[l,...k],R=await c.detectOverflow(t,w),P=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&P.push(R[b]),p){const $=w7(i,a,S);P.push(R[$[0]],R[$[1]])}if(L=[...L,{placement:i,overflows:P}],!P.every($=>$<=0)){var _,U;const $=(((_=s.flip)==null?void 0:_.index)||0)+1,W=C[$];if(W&&(!(p==="alignment"?y!==Ar(W):!1)||L.every(N=>Ar(N.placement)===y?N.overflows[0]>0:!0)))return{data:{index:$,overflows:L},reset:{placement:W}};let V=(U=L.filter(Z=>Z.overflows[0]<=0).sort((Z,N)=>Z.overflows[1]-N.overflows[1])[0])==null?void 0:U.placement;if(!V)switch(g){case"bestFit":{var K;const Z=(K=L.filter(N=>{if(E){const F=Ar(N.placement);return F===y||F==="y"}return!0}).map(N=>[N.placement,N.overflows.filter(F=>F>0).reduce((F,H)=>F+H,0)]).sort((N,F)=>N[1]-F[1])[0])==null?void 0:K[0];Z&&(V=Z);break}case"initialPlacement":V=l;break}if(i!==V)return{reset:{placement:V}}}return{}}}};function Tb(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Eb(e){return b7.some(t=>e[t]>=0)}const D7=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=jo(e,t);switch(i){case"referenceHidden":{const a=await r.detectOverflow(t,{...s,elementContext:"reference"}),l=Tb(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Eb(l)}}}case"escaped":{const a=await r.detectOverflow(t,{...s,altBoundary:!0}),l=Tb(a,n.floating);return{data:{escapedOffsets:l,escaped:Eb(l)}}}default:return{}}}}},H5=new Set(["left","top"]);async function A7(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),a=wo(n),l=El(n),c=Ar(n)==="y",d=H5.has(a)?-1:1,u=s&&c?-1:1,p=jo(t,e);let{mainAxis:h,crossAxis:g,alignmentAxis:v}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&typeof v=="number"&&(g=l==="end"?v*-1:v),c?{x:g*u,y:h*d}:{x:h*d,y:g*u}}const N7=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:a,middlewareData:l}=t,c=await A7(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:s+c.y,data:{...c,placement:a}}}}},$7=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:c={fn:b=>{let{x:y,y:j}=b;return{x:y,y:j}}},...d}=jo(e,t),u={x:n,y:r},p=await s.detectOverflow(t,d),h=Ar(wo(i)),g=e0(h);let v=u[g],x=u[h];if(a){const b=g==="y"?"top":"left",y=g==="y"?"bottom":"right",j=v+p[b],S=v-p[y];v=om(j,v,S)}if(l){const b=h==="y"?"top":"left",y=h==="y"?"bottom":"right",j=x+p[b],S=x-p[y];x=om(j,x,S)}const w=c.fn({...t,[g]:v,[h]:x});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[g]:a,[h]:l}}}}}},_7=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:a}=t,{offset:l=0,mainAxis:c=!0,crossAxis:d=!0}=jo(e,t),u={x:n,y:r},p=Ar(i),h=e0(p);let g=u[h],v=u[p];const x=jo(l,t),w=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(c){const j=h==="y"?"height":"width",S=s.reference[h]-s.floating[j]+w.mainAxis,k=s.reference[h]+s.reference[j]-w.mainAxis;g<S?g=S:g>k&&(g=k)}if(d){var b,y;const j=h==="y"?"width":"height",S=H5.has(wo(i)),k=s.reference[p]-s.floating[j]+(S&&((b=a.offset)==null?void 0:b[p])||0)+(S?0:w.crossAxis),E=s.reference[p]+s.reference[j]+(S?0:((y=a.offset)==null?void 0:y[p])||0)-(S?w.crossAxis:0);v<k?v=k:v>E&&(v=E)}return{[h]:g,[p]:v}}}},F7=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:s,platform:a,elements:l}=t,{apply:c=()=>{},...d}=jo(e,t),u=await a.detectOverflow(t,d),p=wo(i),h=El(i),g=Ar(i)==="y",{width:v,height:x}=s.floating;let w,b;p==="top"||p==="bottom"?(w=p,b=h===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(b=p,w=h==="end"?"top":"bottom");const y=x-u.top-u.bottom,j=v-u.left-u.right,S=ki(x-u[w],y),k=ki(v-u[b],j),E=!t.middlewareData.shift;let C=S,R=k;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(R=j),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=y),E&&!h){const L=Ln(u.left,0),_=Ln(u.right,0),U=Ln(u.top,0),K=Ln(u.bottom,0);g?R=v-2*(L!==0||_!==0?L+_:Ln(u.left,u.right)):C=x-2*(U!==0||K!==0?U+K:Ln(u.top,u.bottom))}await c({...t,availableWidth:R,availableHeight:C});const P=await a.getDimensions(l.floating);return v!==P.width||x!==P.height?{reset:{rects:!0}}:{}}}};function Mf(){return typeof window<"u"}function Rl(e){return q5(e)?(e.nodeName||"").toLowerCase():"#document"}function $n(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Hr(e){var t;return(t=(q5(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function q5(e){return Mf()?e instanceof Node||e instanceof $n(e).Node:!1}function mr(e){return Mf()?e instanceof Element||e instanceof $n(e).Element:!1}function So(e){return Mf()?e instanceof HTMLElement||e instanceof $n(e).HTMLElement:!1}function Rb(e){return!Mf()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof $n(e).ShadowRoot}function Ed(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=vr(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function z7(e){return/^(table|td|th)$/.test(Rl(e))}function Lf(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const B7=/transform|translate|scale|rotate|perspective|filter/,W7=/paint|layout|strict|content/,Ki=e=>!!e&&e!=="none";let Gh;function r0(e){const t=mr(e)?vr(e):e;return Ki(t.transform)||Ki(t.translate)||Ki(t.scale)||Ki(t.rotate)||Ki(t.perspective)||!o0()&&(Ki(t.backdropFilter)||Ki(t.filter))||B7.test(t.willChange||"")||W7.test(t.contain||"")}function U7(e){let t=Si(e);for(;So(t)&&!il(t);){if(r0(t))return t;if(Lf(t))return null;t=Si(t)}return null}function o0(){return Gh==null&&(Gh=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Gh}function il(e){return/^(html|body|#document)$/.test(Rl(e))}function vr(e){return $n(e).getComputedStyle(e)}function Of(e){return mr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Si(e){if(Rl(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Rb(e)&&e.host||Hr(e);return Rb(t)?t.host:t}function V5(e){const t=Si(e);return il(t)?e.ownerDocument?e.ownerDocument.body:e.body:So(t)&&Ed(t)?t:V5(t)}function ed(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=V5(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),a=$n(i);if(s){const l=sm(a);return t.concat(a,a.visualViewport||[],Ed(i)?i:[],l&&n?ed(l):[])}else return t.concat(i,ed(i,[],n))}function sm(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function K5(e){const t=vr(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=So(e),s=i?e.offsetWidth:n,a=i?e.offsetHeight:r,l=Vp(n)!==s||Vp(r)!==a;return l&&(n=s,r=a),{width:n,height:r,$:l}}function i0(e){return mr(e)?e:e.contextElement}function Da(e){const t=i0(e);if(!So(t))return _r(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=K5(t);let a=(s?Vp(n.width):n.width)/r,l=(s?Vp(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const H7=_r(0);function Q5(e){const t=$n(e);return!o0()||!t.visualViewport?H7:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function q7(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==$n(e)?!1:t}function Ps(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=i0(e);let a=_r(1);t&&(r?mr(r)&&(a=Da(r)):a=Da(e));const l=q7(s,n,r)?Q5(s):_r(0);let c=(i.left+l.x)/a.x,d=(i.top+l.y)/a.y,u=i.width/a.x,p=i.height/a.y;if(s){const h=$n(s),g=r&&mr(r)?$n(r):r;let v=h,x=sm(v);for(;x&&r&&g!==v;){const w=Da(x),b=x.getBoundingClientRect(),y=vr(x),j=b.left+(x.clientLeft+parseFloat(y.paddingLeft))*w.x,S=b.top+(x.clientTop+parseFloat(y.paddingTop))*w.y;c*=w.x,d*=w.y,u*=w.x,p*=w.y,c+=j,d+=S,v=$n(x),x=sm(v)}}return Qp({width:u,height:p,x:c,y:d})}function Df(e,t){const n=Of(e).scrollLeft;return t?t.left+n:Ps(Hr(e)).left+n}function G5(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Df(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function V7(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",a=Hr(r),l=t?Lf(t.floating):!1;if(r===a||l&&s)return n;let c={scrollLeft:0,scrollTop:0},d=_r(1);const u=_r(0),p=So(r);if((p||!p&&!s)&&((Rl(r)!=="body"||Ed(a))&&(c=Of(r)),p)){const g=Ps(r);d=Da(r),u.x=g.x+r.clientLeft,u.y=g.y+r.clientTop}const h=a&&!p&&!s?G5(a,c):_r(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+u.x+h.x,y:n.y*d.y-c.scrollTop*d.y+u.y+h.y}}function K7(e){return Array.from(e.getClientRects())}function Q7(e){const t=Hr(e),n=Of(e),r=e.ownerDocument.body,i=Ln(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Ln(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Df(e);const l=-n.scrollTop;return vr(r).direction==="rtl"&&(a+=Ln(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:a,y:l}}const Pb=25;function G7(e,t){const n=$n(e),r=Hr(e),i=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,l=0,c=0;if(i){s=i.width,a=i.height;const u=o0();(!u||u&&t==="fixed")&&(l=i.offsetLeft,c=i.offsetTop)}const d=Df(r);if(d<=0){const u=r.ownerDocument,p=u.body,h=getComputedStyle(p),g=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,v=Math.abs(r.clientWidth-p.clientWidth-g);v<=Pb&&(s-=v)}else d<=Pb&&(s+=d);return{width:s,height:a,x:l,y:c}}function Y7(e,t){const n=Ps(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=So(e)?Da(e):_r(1),a=e.clientWidth*s.x,l=e.clientHeight*s.y,c=i*s.x,d=r*s.y;return{width:a,height:l,x:c,y:d}}function Ib(e,t,n){let r;if(t==="viewport")r=G7(e,n);else if(t==="document")r=Q7(Hr(e));else if(mr(t))r=Y7(t,n);else{const i=Q5(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Qp(r)}function Y5(e,t){const n=Si(e);return n===t||!mr(n)||il(n)?!1:vr(n).position==="fixed"||Y5(n,t)}function X7(e,t){const n=t.get(e);if(n)return n;let r=ed(e,[],!1).filter(l=>mr(l)&&Rl(l)!=="body"),i=null;const s=vr(e).position==="fixed";let a=s?Si(e):e;for(;mr(a)&&!il(a);){const l=vr(a),c=r0(a);!c&&l.position==="fixed"&&(i=null),(s?!c&&!i:!c&&l.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||Ed(a)&&!c&&Y5(e,a))?r=r.filter(u=>u!==a):i=l,a=Si(a)}return t.set(e,r),r}function J7(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const a=[...n==="clippingAncestors"?Lf(t)?[]:X7(t,this._c):[].concat(n),r],l=Ib(t,a[0],i);let c=l.top,d=l.right,u=l.bottom,p=l.left;for(let h=1;h<a.length;h++){const g=Ib(t,a[h],i);c=Ln(g.top,c),d=ki(g.right,d),u=ki(g.bottom,u),p=Ln(g.left,p)}return{width:d-p,height:u-c,x:p,y:c}}function Z7(e){const{width:t,height:n}=K5(e);return{width:t,height:n}}function eL(e,t,n){const r=So(t),i=Hr(t),s=n==="fixed",a=Ps(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const c=_r(0);function d(){c.x=Df(i)}if(r||!r&&!s)if((Rl(t)!=="body"||Ed(i))&&(l=Of(t)),r){const g=Ps(t,!0,s,t);c.x=g.x+t.clientLeft,c.y=g.y+t.clientTop}else i&&d();s&&!r&&i&&d();const u=i&&!r&&!s?G5(i,l):_r(0),p=a.left+l.scrollLeft-c.x-u.x,h=a.top+l.scrollTop-c.y-u.y;return{x:p,y:h,width:a.width,height:a.height}}function Yh(e){return vr(e).position==="static"}function Mb(e,t){if(!So(e)||vr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Hr(e)===n&&(n=n.ownerDocument.body),n}function X5(e,t){const n=$n(e);if(Lf(e))return n;if(!So(e)){let i=Si(e);for(;i&&!il(i);){if(mr(i)&&!Yh(i))return i;i=Si(i)}return n}let r=Mb(e,t);for(;r&&z7(r)&&Yh(r);)r=Mb(r,t);return r&&il(r)&&Yh(r)&&!r0(r)?n:r||U7(e)||n}const tL=async function(e){const t=this.getOffsetParent||X5,n=this.getDimensions,r=await n(e.floating);return{reference:eL(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function nL(e){return vr(e).direction==="rtl"}const rL={convertOffsetParentRelativeRectToViewportRelativeRect:V7,getDocumentElement:Hr,getClippingRect:J7,getOffsetParent:X5,getElementRects:tL,getClientRects:K7,getDimensions:Z7,getScale:Da,isElement:mr,isRTL:nL};function J5(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function oL(e,t){let n=null,r;const i=Hr(e);function s(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),s();const d=e.getBoundingClientRect(),{left:u,top:p,width:h,height:g}=d;if(l||t(),!h||!g)return;const v=bu(p),x=bu(i.clientWidth-(u+h)),w=bu(i.clientHeight-(p+g)),b=bu(u),j={rootMargin:-v+"px "+-x+"px "+-w+"px "+-b+"px",threshold:Ln(0,ki(1,c))||1};let S=!0;function k(E){const C=E[0].intersectionRatio;if(C!==c){if(!S)return a();C?a(!1,C):r=setTimeout(()=>{a(!1,1e-7)},1e3)}C===1&&!J5(d,e.getBoundingClientRect())&&a(),S=!1}try{n=new IntersectionObserver(k,{...j,root:i.ownerDocument})}catch{n=new IntersectionObserver(k,j)}n.observe(e)}return a(!0),s}function iL(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,d=i0(e),u=i||s?[...d?ed(d):[],...t?ed(t):[]]:[];u.forEach(b=>{i&&b.addEventListener("scroll",n,{passive:!0}),s&&b.addEventListener("resize",n)});const p=d&&l?oL(d,n):null;let h=-1,g=null;a&&(g=new ResizeObserver(b=>{let[y]=b;y&&y.target===d&&g&&t&&(g.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var j;(j=g)==null||j.observe(t)})),n()}),d&&!c&&g.observe(d),t&&g.observe(t));let v,x=c?Ps(e):null;c&&w();function w(){const b=Ps(e);x&&!J5(x,b)&&n(),x=b,v=requestAnimationFrame(w)}return n(),()=>{var b;u.forEach(y=>{i&&y.removeEventListener("scroll",n),s&&y.removeEventListener("resize",n)}),p==null||p(),(b=g)==null||b.disconnect(),g=null,c&&cancelAnimationFrame(v)}}const sL=N7,aL=$7,lL=O7,cL=F7,dL=D7,Lb=L7,uL=_7,pL=(e,t,n)=>{const r=new Map,i={platform:rL,...n},s={...i.platform,_c:r};return M7(e,t,{...i,platform:s})};var fL=typeof document<"u",hL=function(){},ap=fL?f.useLayoutEffect:hL;function Gp(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Gp(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!Gp(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Z5(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ob(e,t){const n=Z5(e);return Math.round(t*n)/n}function Xh(e){const t=f.useRef(e);return ap(()=>{t.current=e}),t}function gL(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:a}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[u,p]=f.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,g]=f.useState(r);Gp(h,r)||g(r);const[v,x]=f.useState(null),[w,b]=f.useState(null),y=f.useCallback(N=>{N!==E.current&&(E.current=N,x(N))},[]),j=f.useCallback(N=>{N!==C.current&&(C.current=N,b(N))},[]),S=s||v,k=a||w,E=f.useRef(null),C=f.useRef(null),R=f.useRef(u),P=c!=null,L=Xh(c),_=Xh(i),U=Xh(d),K=f.useCallback(()=>{if(!E.current||!C.current)return;const N={placement:t,strategy:n,middleware:h};_.current&&(N.platform=_.current),pL(E.current,C.current,N).then(F=>{const H={...F,isPositioned:U.current!==!1};$.current&&!Gp(R.current,H)&&(R.current=H,Ns.flushSync(()=>{p(H)}))})},[h,t,n,_,U]);ap(()=>{d===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,p(N=>({...N,isPositioned:!1})))},[d]);const $=f.useRef(!1);ap(()=>($.current=!0,()=>{$.current=!1}),[]),ap(()=>{if(S&&(E.current=S),k&&(C.current=k),S&&k){if(L.current)return L.current(S,k,K);K()}},[S,k,K,L,P]);const W=f.useMemo(()=>({reference:E,floating:C,setReference:y,setFloating:j}),[y,j]),V=f.useMemo(()=>({reference:S,floating:k}),[S,k]),Z=f.useMemo(()=>{const N={position:n,left:0,top:0};if(!V.floating)return N;const F=Ob(V.floating,u.x),H=Ob(V.floating,u.y);return l?{...N,transform:"translate("+F+"px, "+H+"px)",...Z5(V.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:H}},[n,l,V.floating,u.x,u.y]);return f.useMemo(()=>({...u,update:K,refs:W,elements:V,floatingStyles:Z}),[u,K,W,V,Z])}const xL=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Lb({element:r.current,padding:i}).fn(n):{}:r?Lb({element:r,padding:i}).fn(n):{}}}},mL=(e,t)=>{const n=sL(e);return{name:n.name,fn:n.fn,options:[e,t]}},vL=(e,t)=>{const n=aL(e);return{name:n.name,fn:n.fn,options:[e,t]}},yL=(e,t)=>({fn:uL(e).fn,options:[e,t]}),bL=(e,t)=>{const n=lL(e);return{name:n.name,fn:n.fn,options:[e,t]}},jL=(e,t)=>{const n=cL(e);return{name:n.name,fn:n.fn,options:[e,t]}},wL=(e,t)=>{const n=dL(e);return{name:n.name,fn:n.fn,options:[e,t]}},kL=(e,t)=>{const n=xL(e);return{name:n.name,fn:n.fn,options:[e,t]}};var SL="Arrow",e4=f.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return o.jsx(Me.svg,{...s,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:o.jsx("polygon",{points:"0,0 30,0 15,10"})})});e4.displayName=SL;var CL=e4;function TL(e){const[t,n]=f.useState(void 0);return gr(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let a,l;if("borderBoxSize"in s){const c=s.borderBoxSize,d=Array.isArray(c)?c[0]:c;a=d.inlineSize,l=d.blockSize}else a=e.offsetWidth,l=e.offsetHeight;n({width:a,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var s0="Popper",[t4,Af]=Li(s0),[EL,n4]=t4(s0),r4=e=>{const{__scopePopper:t,children:n}=e,[r,i]=f.useState(null),[s,a]=f.useState(void 0);return o.jsx(EL,{scope:t,anchor:r,onAnchorChange:i,placementState:s,setPlacementState:a,children:n})};r4.displayName=s0;var o4="PopperAnchor",i4=f.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=n4(o4,n),a=f.useRef(null),l=s.onAnchorChange,c=f.useCallback(v=>{a.current=v,v&&l(v)},[l]),d=Ft(t,c),u=f.useRef(null);f.useEffect(()=>{if(!r)return;const v=u.current;u.current=r.current,v!==u.current&&l(u.current)});const p=s.placementState&&l0(s.placementState),h=p==null?void 0:p[0],g=p==null?void 0:p[1];return r?null:o.jsx(Me.div,{"data-radix-popper-side":h,"data-radix-popper-align":g,...i,ref:d})});i4.displayName=o4;var a0="PopperContent",[RL,PL]=t4(a0),s4=f.forwardRef((e,t)=>{var ve,ke,Ct,we,Ee,Xe;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:u=0,sticky:p="partial",hideWhenDetached:h=!1,updatePositionStrategy:g="optimized",onPlaced:v,...x}=e,w=n4(a0,n),[b,y]=f.useState(null),j=Ft(t,y),[S,k]=f.useState(null),E=TL(S),C=(E==null?void 0:E.width)??0,R=(E==null?void 0:E.height)??0,P=r+(s!=="center"?"-"+s:""),L=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},_=Array.isArray(d)?d:[d],U=_.length>0,K={padding:L,boundary:_.filter(ML),altBoundary:U},{refs:$,floatingStyles:W,placement:V,isPositioned:Z,middlewareData:N}=gL({strategy:"fixed",placement:P,whileElementsMounted:(...Tt)=>iL(...Tt,{animationFrame:g==="always"}),elements:{reference:w.anchor},middleware:[mL({mainAxis:i+R,alignmentAxis:a}),c&&vL({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?yL():void 0,...K}),c&&bL({...K}),jL({...K,apply:({elements:Tt,rects:ht,availableWidth:lt,availableHeight:Kr})=>{const{width:zt,height:Ot}=ht.reference,hn=Tt.floating.style;hn.setProperty("--radix-popper-available-width",`${lt}px`),hn.setProperty("--radix-popper-available-height",`${Kr}px`),hn.setProperty("--radix-popper-anchor-width",`${zt}px`),hn.setProperty("--radix-popper-anchor-height",`${Ot}px`)}}),S&&kL({element:S,padding:l}),LL({arrowWidth:C,arrowHeight:R}),h&&wL({strategy:"referenceHidden",...K,boundary:U?K.boundary:void 0})]}),F=w.setPlacementState;gr(()=>(F(V),()=>{F(void 0)}),[V,F]);const[H,re]=l0(V),D=zr(v);gr(()=>{Z&&(D==null||D())},[Z,D]);const Q=(ve=N.arrow)==null?void 0:ve.x,ne=(ke=N.arrow)==null?void 0:ke.y,J=((Ct=N.arrow)==null?void 0:Ct.centerOffset)!==0,[te,fe]=f.useState();return gr(()=>{b&&fe(window.getComputedStyle(b).zIndex)},[b]),o.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:Z?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:te,"--radix-popper-transform-origin":[(we=N.transformOrigin)==null?void 0:we.x,(Ee=N.transformOrigin)==null?void 0:Ee.y].join(" "),...((Xe=N.hide)==null?void 0:Xe.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:o.jsx(RL,{scope:n,placedSide:H,placedAlign:re,onArrowChange:k,arrowX:Q,arrowY:ne,shouldHideArrow:J,children:o.jsx(Me.div,{"data-side":H,"data-align":re,...x,ref:j,style:{...x.style,animation:Z?void 0:"none"}})})})});s4.displayName=a0;var a4="PopperArrow",IL={top:"bottom",right:"left",bottom:"top",left:"right"},l4=f.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=PL(a4,r),a=IL[s.placedSide];return o.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:o.jsx(CL,{...i,ref:n,style:{...i.style,display:"block"}})})});l4.displayName=a4;function ML(e){return e!==null}var LL=e=>({name:"transformOrigin",options:e,fn(t){var w,b,y;const{placement:n,rects:r,middlewareData:i}=t,a=((w=i.arrow)==null?void 0:w.centerOffset)!==0,l=a?0:e.arrowWidth,c=a?0:e.arrowHeight,[d,u]=l0(n),p={start:"0%",center:"50%",end:"100%"}[u],h=(((b=i.arrow)==null?void 0:b.x)??0)+l/2,g=(((y=i.arrow)==null?void 0:y.y)??0)+c/2;let v="",x="";return d==="bottom"?(v=a?p:`${h}px`,x=`${-c}px`):d==="top"?(v=a?p:`${h}px`,x=`${r.floating.height+c}px`):d==="right"?(v=`${-c}px`,x=a?p:`${g}px`):d==="left"&&(v=`${r.floating.width+c}px`,x=a?p:`${g}px`),{data:{x:v,y:x}}}});function l0(e){const[t,n="center"]=e.split("-");return[t,n]}var c4=r4,c0=i4,d4=s4,u4=l4,OL="Portal",Rd=f.forwardRef((e,t)=>{var l;const{container:n,...r}=e,[i,s]=f.useState(!1);gr(()=>s(!0),[]);const a=n||i&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return a?Ns.createPortal(o.jsx(Me.div,{...r,ref:t}),a):null});Rd.displayName=OL;var DL=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),AL="VisuallyHidden",Nf=f.forwardRef((e,t)=>o.jsx(Me.span,{...e,ref:t,style:{...DL,...e.style}}));Nf.displayName=AL;var NL=Nf,[$f]=Li("Tooltip",[Af]),_f=Af(),p4="TooltipProvider",$L=700,am="tooltip.open",[_L,d0]=$f(p4),f4=e=>{const{__scopeTooltip:t,delayDuration:n=$L,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,a=f.useRef(!0),l=f.useRef(!1),c=f.useRef(0);return f.useEffect(()=>{const d=c.current;return()=>window.clearTimeout(d)},[]),o.jsx(_L,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:f.useCallback(()=>{r<=0||(window.clearTimeout(c.current),a.current=!1)},[r]),onClose:f.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,r))},[r]),isPointerInTransitRef:l,onPointerInTransitChange:f.useCallback(d=>{l.current=d},[]),disableHoverableContent:i,children:s})};f4.displayName=p4;var td="Tooltip",[FL,Pd]=$f(td),h4=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:a,delayDuration:l}=e,c=d0(td,e.__scopeTooltip),d=_f(t),[u,p]=f.useState(null),h=Nn(),g=f.useRef(0),v=a??c.disableHoverableContent,x=l??c.delayDuration,w=f.useRef(!1),[b,y]=Tl({prop:r,defaultProp:i??!1,onChange:C=>{C?(c.onOpen(),document.dispatchEvent(new CustomEvent(am))):c.onClose(),s==null||s(C)},caller:td}),j=f.useMemo(()=>b?w.current?"delayed-open":"instant-open":"closed",[b]),S=f.useCallback(()=>{window.clearTimeout(g.current),g.current=0,w.current=!1,y(!0)},[y]),k=f.useCallback(()=>{window.clearTimeout(g.current),g.current=0,y(!1)},[y]),E=f.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{w.current=!0,y(!0),g.current=0},x)},[x,y]);return f.useEffect(()=>()=>{g.current&&(window.clearTimeout(g.current),g.current=0)},[]),o.jsx(c4,{...d,children:o.jsx(FL,{scope:t,contentId:h,open:b,stateAttribute:j,trigger:u,onTriggerChange:p,onTriggerEnter:f.useCallback(()=>{c.isOpenDelayedRef.current?E():S()},[c.isOpenDelayedRef,E,S]),onTriggerLeave:f.useCallback(()=>{v?k():(window.clearTimeout(g.current),g.current=0)},[k,v]),onOpen:S,onClose:k,disableHoverableContent:v,children:n})})};h4.displayName=td;var lm="TooltipTrigger",g4=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Pd(lm,n),s=d0(lm,n),a=_f(n),l=f.useRef(null),c=Ft(t,l,i.onTriggerChange),d=f.useRef(!1),u=f.useRef(!1),p=f.useCallback(()=>d.current=!1,[]);return f.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),o.jsx(c0,{asChild:!0,...a,children:o.jsx(Me.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:c,onPointerMove:Te(e.onPointerMove,h=>{h.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Te(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Te(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:Te(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:Te(e.onBlur,i.onClose),onClick:Te(e.onClick,i.onClose)})})});g4.displayName=lm;var u0="TooltipPortal",[zL,BL]=$f(u0,{forceMount:void 0}),x4=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=Pd(u0,t);return o.jsx(zL,{scope:t,forceMount:n,children:o.jsx(Ur,{present:n||s.open,children:o.jsx(Rd,{asChild:!0,container:i,children:r})})})};x4.displayName=u0;var sl="TooltipContent",m4=f.forwardRef((e,t)=>{const n=BL(sl,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,a=Pd(sl,e.__scopeTooltip);return o.jsx(Ur,{present:r||a.open,children:a.disableHoverableContent?o.jsx(v4,{side:i,...s,ref:t}):o.jsx(WL,{side:i,...s,ref:t})})}),WL=f.forwardRef((e,t)=>{const n=Pd(sl,e.__scopeTooltip),r=d0(sl,e.__scopeTooltip),i=f.useRef(null),s=Ft(t,i),[a,l]=f.useState(null),{trigger:c,onClose:d}=n,u=i.current,{onPointerInTransitChange:p}=r,h=f.useCallback(()=>{l(null),p(!1)},[p]),g=f.useCallback((v,x)=>{const w=v.currentTarget,b={x:v.clientX,y:v.clientY},y=VL(b,w.getBoundingClientRect()),j=KL(b,y),S=QL(x.getBoundingClientRect()),k=YL([...j,...S]);l(k),p(!0)},[p]);return f.useEffect(()=>()=>h(),[h]),f.useEffect(()=>{if(c&&u){const v=w=>g(w,u),x=w=>g(w,c);return c.addEventListener("pointerleave",v),u.addEventListener("pointerleave",x),()=>{c.removeEventListener("pointerleave",v),u.removeEventListener("pointerleave",x)}}},[c,u,g,h]),f.useEffect(()=>{if(a){const v=x=>{const w=x.target,b={x:x.clientX,y:x.clientY},y=(c==null?void 0:c.contains(w))||(u==null?void 0:u.contains(w)),j=!GL(b,a);y?h():j&&(h(),d())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[c,u,a,d,h]),o.jsx(v4,{...e,ref:s})}),[UL,HL]=$f(td,{isInside:!1}),qL=kM("TooltipContent"),v4=f.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:a,...l}=e,c=Pd(sl,n),d=_f(n),{onClose:u}=c;return f.useEffect(()=>(document.addEventListener(am,u),()=>document.removeEventListener(am,u)),[u]),f.useEffect(()=>{if(c.trigger){const p=h=>{h.target instanceof Node&&h.target.contains(c.trigger)&&u()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[c.trigger,u]),o.jsx(Td,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:p=>p.preventDefault(),onDismiss:u,children:o.jsxs(d4,{"data-state":c.stateAttribute,...d,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[o.jsx(qL,{children:r}),o.jsx(UL,{scope:n,isInside:!0,children:o.jsx(NL,{id:c.contentId,role:"tooltip",children:i||r})})]})})});m4.displayName=sl;var y4="TooltipArrow",b4=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=_f(n);return HL(y4,n).isInside?null:o.jsx(u4,{...i,...r,ref:t})});b4.displayName=y4;function VL(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function KL(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function QL(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function GL(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const l=t[s],c=t[a],d=l.x,u=l.y,p=c.x,h=c.y;u>r!=h>r&&n<(p-d)*(r-u)/(h-u)+d&&(i=!i)}return i}function YL(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),XL(t)}function XL(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var JL=f4,ZL=h4,eO=g4,tO=x4,nO=m4,rO=b4;const oO=JL;function iO({content:e,children:t,side:n="top",delayDuration:r}){return o.jsxs(ZL,{delayDuration:r,children:[o.jsx(eO,{asChild:!0,children:t}),o.jsx(tO,{children:o.jsxs(nO,{side:n,sideOffset:4,className:"z-50 rounded-card bg-state-ink px-1g py-0.5g font-sans text-ui text-surface-card shadow-card",children:[e,o.jsx(rO,{className:"fill-state-ink"})]})})]})}function lp({title:e,description:t,icon:n,action:r,className:i}){return o.jsxs("div",{className:["flex flex-col items-center justify-center gap-1g rounded-card border border-card","bg-surface-card p-6g text-center shadow-card",i].filter(Boolean).join(" "),children:[n&&o.jsx("div",{className:"text-state-ink/40",children:n}),o.jsx("div",{className:"text-body font-medium text-state-ink/70",children:e}),t&&o.jsx("p",{className:"max-w-md text-ui text-state-ink/50",children:t}),r&&o.jsx("div",{className:"mt-1g",children:r})]})}const sO={waiting:"bg-pill-waiting-bg text-pill-waiting-fg",human:"bg-pill-failed-bg text-pill-failed-fg",info:"bg-pill-running-bg text-pill-running-fg"},aO={waiting:"bg-state-wait",human:"bg-state-fail",info:"bg-state-run"};function Ff({severity:e,title:t,meta:n,detail:r,actions:i,children:s,pulse:a,className:l}){const c=r||i||s;return o.jsxs("div",{className:["overflow-hidden rounded-card border border-card bg-surface-card shadow-card",l].filter(Boolean).join(" "),children:[o.jsxs("div",{className:["flex items-center gap-1g px-1.5g py-1g",sO[e]].join(" "),children:[o.jsx("span",{className:["h-1g w-1g flex-none rounded-full",aO[e],a?"animate-pulse":""].filter(Boolean).join(" ")}),o.jsx("span",{className:"text-ui font-medium",children:t}),n&&o.jsx("span",{className:"ml-auto font-mono text-ui opacity-80",children:n})]}),c&&o.jsxs("div",{className:"flex flex-col gap-1g p-1.5g",children:[r&&o.jsx("div",{className:"text-ui text-state-ink/80",children:r}),s,i&&o.jsx("div",{className:"flex flex-wrap gap-1g",children:i})]})]})}var Jh="focusScope.autoFocusOnMount",Zh="focusScope.autoFocusOnUnmount",Db={bubbles:!1,cancelable:!0},lO="FocusScope",p0=f.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...a}=e,[l,c]=f.useState(null),d=zr(i),u=zr(s),p=f.useRef(null),h=Ft(t,c),g=f.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;f.useEffect(()=>{if(r){let x=function(j){if(g.paused||!l)return;const S=j.target;l.contains(S)?p.current=S:Wo(p.current,{select:!0})},w=function(j){if(g.paused||!l)return;const S=j.relatedTarget;S!==null&&(l.contains(S)||Wo(p.current,{select:!0}))},b=function(j){if(document.activeElement===document.body)for(const k of j)k.removedNodes.length>0&&Wo(l)};document.addEventListener("focusin",x),document.addEventListener("focusout",w);const y=new MutationObserver(b);return l&&y.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",w),y.disconnect()}}},[r,l,g.paused]),f.useEffect(()=>{if(l){Nb.add(g);const x=document.activeElement;if(!l.contains(x)){const b=new CustomEvent(Jh,Db);l.addEventListener(Jh,d),l.dispatchEvent(b),b.defaultPrevented||(cO(hO(j4(l)),{select:!0}),document.activeElement===x&&Wo(l))}return()=>{l.removeEventListener(Jh,d),setTimeout(()=>{const b=new CustomEvent(Zh,Db);l.addEventListener(Zh,u),l.dispatchEvent(b),b.defaultPrevented||Wo(x??document.body,{select:!0}),l.removeEventListener(Zh,u),Nb.remove(g)},0)}}},[l,d,u,g]);const v=f.useCallback(x=>{if(!n&&!r||g.paused)return;const w=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,b=document.activeElement;if(w&&b){const y=x.currentTarget,[j,S]=dO(y);j&&S?!x.shiftKey&&b===S?(x.preventDefault(),n&&Wo(j,{select:!0})):x.shiftKey&&b===j&&(x.preventDefault(),n&&Wo(S,{select:!0})):b===y&&x.preventDefault()}},[n,r,g.paused]);return o.jsx(Me.div,{tabIndex:-1,...a,ref:h,onKeyDown:v})});p0.displayName=lO;function cO(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Wo(r,{select:t}),document.activeElement!==n)return}function dO(e){const t=j4(e),n=Ab(t,e),r=Ab(t.reverse(),e);return[n,r]}function j4(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Ab(e,t){for(const n of e)if(!uO(n,{upTo:t}))return n}function uO(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function pO(e){return e instanceof HTMLInputElement&&"select"in e}function Wo(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&pO(e)&&t&&e.select()}}var Nb=fO();function fO(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=$b(e,t),e.unshift(t)},remove(t){var n;e=$b(e,t),(n=e[0])==null||n.resume()}}}function $b(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function hO(e){return e.filter(t=>t.tagName!=="A")}var ju=0,Rr=null;function w4(){f.useEffect(()=>{Rr||(Rr={start:_b(),end:_b()});const{start:e,end:t}=Rr;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),ju++,()=>{ju===1&&(Rr==null||Rr.start.remove(),Rr==null||Rr.end.remove(),Rr=null),ju=Math.max(0,ju-1)}},[])}function _b(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Dr=function(){return Dr=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Dr.apply(this,arguments)};function k4(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function gO(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}var cp="right-scroll-bar-position",dp="width-before-scroll-bar",xO="with-scroll-bars-hidden",mO="--removed-body-scroll-bar-size";function eg(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function vO(e,t){var n=f.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=t,n.facade}var yO=typeof window<"u"?f.useLayoutEffect:f.useEffect,Fb=new WeakMap;function bO(e,t){var n=vO(null,function(r){return e.forEach(function(i){return eg(i,r)})});return yO(function(){var r=Fb.get(n);if(r){var i=new Set(r),s=new Set(e),a=n.current;i.forEach(function(l){s.has(l)||eg(l,null)}),s.forEach(function(l){i.has(l)||eg(l,a)})}Fb.set(n,e)},[e]),n}function jO(e){return e}function wO(e,t){t===void 0&&(t=jO);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var a=t(s,r);return n.push(a),function(){n=n.filter(function(l){return l!==a})}},assignSyncMedium:function(s){for(r=!0;n.length;){var a=n;n=[],a.forEach(s)}n={push:function(l){return s(l)},filter:function(){return n}}},assignMedium:function(s){r=!0;var a=[];if(n.length){var l=n;n=[],l.forEach(s),a=n}var c=function(){var u=a;a=[],u.forEach(s)},d=function(){return Promise.resolve().then(c)};d(),n={push:function(u){a.push(u),d()},filter:function(u){return a=a.filter(u),n}}}};return i}function kO(e){e===void 0&&(e={});var t=wO(null);return t.options=Dr({async:!0,ssr:!1},e),t}var S4=function(e){var t=e.sideCar,n=k4(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return f.createElement(r,Dr({},n))};S4.isSideCarExport=!0;function SO(e,t){return e.useMedium(t),S4}var C4=kO(),tg=function(){},zf=f.forwardRef(function(e,t){var n=f.useRef(null),r=f.useState({onScrollCapture:tg,onWheelCapture:tg,onTouchMoveCapture:tg}),i=r[0],s=r[1],a=e.forwardProps,l=e.children,c=e.className,d=e.removeScrollBar,u=e.enabled,p=e.shards,h=e.sideCar,g=e.noRelative,v=e.noIsolation,x=e.inert,w=e.allowPinchZoom,b=e.as,y=b===void 0?"div":b,j=e.gapMode,S=k4(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=h,E=bO([n,t]),C=Dr(Dr({},S),i);return f.createElement(f.Fragment,null,u&&f.createElement(k,{sideCar:C4,removeScrollBar:d,shards:p,noRelative:g,noIsolation:v,inert:x,setCallbacks:s,allowPinchZoom:!!w,lockRef:n,gapMode:j}),a?f.cloneElement(f.Children.only(l),Dr(Dr({},C),{ref:E})):f.createElement(y,Dr({},C,{className:c,ref:E}),l))});zf.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};zf.classNames={fullWidth:dp,zeroRight:cp};var CO=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function TO(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=CO();return t&&e.setAttribute("nonce",t),e}function EO(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function RO(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var PO=function(){var e=0,t=null;return{add:function(n){e==0&&(t=TO())&&(EO(t,n),RO(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},IO=function(){var e=PO();return function(t,n){f.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},T4=function(){var e=IO(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},MO={left:0,top:0,right:0,gap:0},ng=function(e){return parseInt(e||"",10)||0},LO=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[ng(n),ng(r),ng(i)]},OO=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return MO;var t=LO(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},DO=T4(),Aa="data-scroll-locked",AO=function(e,t,n,r){var i=e.left,s=e.top,a=e.right,l=e.gap;return n===void 0&&(n="margin"),`
|
|
50
|
+
.`.concat(xO,` {
|
|
51
|
+
overflow: hidden `).concat(r,`;
|
|
52
|
+
padding-right: `).concat(l,"px ").concat(r,`;
|
|
53
|
+
}
|
|
54
|
+
body[`).concat(Aa,`] {
|
|
55
|
+
overflow: hidden `).concat(r,`;
|
|
56
|
+
overscroll-behavior: contain;
|
|
57
|
+
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
58
|
+
padding-left: `.concat(i,`px;
|
|
59
|
+
padding-top: `).concat(s,`px;
|
|
60
|
+
padding-right: `).concat(a,`px;
|
|
61
|
+
margin-left:0;
|
|
62
|
+
margin-top:0;
|
|
63
|
+
margin-right: `).concat(l,"px ").concat(r,`;
|
|
64
|
+
`),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.`).concat(cp,` {
|
|
68
|
+
right: `).concat(l,"px ").concat(r,`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.`).concat(dp,` {
|
|
72
|
+
margin-right: `).concat(l,"px ").concat(r,`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.`).concat(cp," .").concat(cp,` {
|
|
76
|
+
right: 0 `).concat(r,`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.`).concat(dp," .").concat(dp,` {
|
|
80
|
+
margin-right: 0 `).concat(r,`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
body[`).concat(Aa,`] {
|
|
84
|
+
`).concat(mO,": ").concat(l,`px;
|
|
85
|
+
}
|
|
86
|
+
`)},zb=function(){var e=parseInt(document.body.getAttribute(Aa)||"0",10);return isFinite(e)?e:0},NO=function(){f.useEffect(function(){return document.body.setAttribute(Aa,(zb()+1).toString()),function(){var e=zb()-1;e<=0?document.body.removeAttribute(Aa):document.body.setAttribute(Aa,e.toString())}},[])},$O=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;NO();var s=f.useMemo(function(){return OO(i)},[i]);return f.createElement(DO,{styles:AO(s,!t,i,n?"":"!important")})},cm=!1;if(typeof window<"u")try{var wu=Object.defineProperty({},"passive",{get:function(){return cm=!0,!0}});window.addEventListener("test",wu,wu),window.removeEventListener("test",wu,wu)}catch{cm=!1}var Vs=cm?{passive:!1}:!1,_O=function(e){return e.tagName==="TEXTAREA"},E4=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!_O(e)&&n[t]==="visible")},FO=function(e){return E4(e,"overflowY")},zO=function(e){return E4(e,"overflowX")},Bb=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=R4(e,r);if(i){var s=P4(e,r),a=s[1],l=s[2];if(a>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},BO=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},WO=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},R4=function(e,t){return e==="v"?FO(t):zO(t)},P4=function(e,t){return e==="v"?BO(t):WO(t)},UO=function(e,t){return e==="h"&&t==="rtl"?-1:1},HO=function(e,t,n,r,i){var s=UO(e,window.getComputedStyle(t).direction),a=s*r,l=n.target,c=t.contains(l),d=!1,u=a>0,p=0,h=0;do{if(!l)break;var g=P4(e,l),v=g[0],x=g[1],w=g[2],b=x-w-s*v;(v||b)&&R4(e,l)&&(p+=b,h+=v);var y=l.parentNode;l=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!c&&l!==document.body||c&&(t.contains(l)||t===l));return(u&&Math.abs(p)<1||!u&&Math.abs(h)<1)&&(d=!0),d},ku=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Wb=function(e){return[e.deltaX,e.deltaY]},Ub=function(e){return e&&"current"in e?e.current:e},qO=function(e,t){return e[0]===t[0]&&e[1]===t[1]},VO=function(e){return`
|
|
87
|
+
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
88
|
+
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
89
|
+
`)},KO=0,Ks=[];function QO(e){var t=f.useRef([]),n=f.useRef([0,0]),r=f.useRef(),i=f.useState(KO++)[0],s=f.useState(T4)[0],a=f.useRef(e);f.useEffect(function(){a.current=e},[e]),f.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var x=gO([e.lockRef.current],(e.shards||[]).map(Ub),!0).filter(Boolean);return x.forEach(function(w){return w.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),x.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var l=f.useCallback(function(x,w){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!a.current.allowPinchZoom;var b=ku(x),y=n.current,j="deltaX"in x?x.deltaX:y[0]-b[0],S="deltaY"in x?x.deltaY:y[1]-b[1],k,E=x.target,C=Math.abs(j)>Math.abs(S)?"h":"v";if("touches"in x&&C==="h"&&E.type==="range")return!1;var R=window.getSelection(),P=R&&R.anchorNode,L=P?P===E||P.contains(E):!1;if(L)return!1;var _=Bb(C,E);if(!_)return!0;if(_?k=C:(k=C==="v"?"h":"v",_=Bb(C,E)),!_)return!1;if(!r.current&&"changedTouches"in x&&(j||S)&&(r.current=k),!k)return!0;var U=r.current||k;return HO(U,w,x,U==="h"?j:S)},[]),c=f.useCallback(function(x){var w=x;if(!(!Ks.length||Ks[Ks.length-1]!==s)){var b="deltaY"in w?Wb(w):ku(w),y=t.current.filter(function(k){return k.name===w.type&&(k.target===w.target||w.target===k.shadowParent)&&qO(k.delta,b)})[0];if(y&&y.should){w.cancelable&&w.preventDefault();return}if(!y){var j=(a.current.shards||[]).map(Ub).filter(Boolean).filter(function(k){return k.contains(w.target)}),S=j.length>0?l(w,j[0]):!a.current.noIsolation;S&&w.cancelable&&w.preventDefault()}}},[]),d=f.useCallback(function(x,w,b,y){var j={name:x,delta:w,target:b,should:y,shadowParent:GO(b)};t.current.push(j),setTimeout(function(){t.current=t.current.filter(function(S){return S!==j})},1)},[]),u=f.useCallback(function(x){n.current=ku(x),r.current=void 0},[]),p=f.useCallback(function(x){d(x.type,Wb(x),x.target,l(x,e.lockRef.current))},[]),h=f.useCallback(function(x){d(x.type,ku(x),x.target,l(x,e.lockRef.current))},[]);f.useEffect(function(){return Ks.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:h}),document.addEventListener("wheel",c,Vs),document.addEventListener("touchmove",c,Vs),document.addEventListener("touchstart",u,Vs),function(){Ks=Ks.filter(function(x){return x!==s}),document.removeEventListener("wheel",c,Vs),document.removeEventListener("touchmove",c,Vs),document.removeEventListener("touchstart",u,Vs)}},[]);var g=e.removeScrollBar,v=e.inert;return f.createElement(f.Fragment,null,v?f.createElement(s,{styles:VO(i)}):null,g?f.createElement($O,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function GO(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const YO=SO(C4,QO);var f0=f.forwardRef(function(e,t){return f.createElement(zf,Dr({},e,{ref:t,sideCar:YO}))});f0.classNames=zf.classNames;var XO=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Qs=new WeakMap,Su=new WeakMap,Cu={},rg=0,I4=function(e){return e&&(e.host||I4(e.parentNode))},JO=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=I4(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},ZO=function(e,t,n,r){var i=JO(t,Array.isArray(e)?e:[e]);Cu[n]||(Cu[n]=new WeakMap);var s=Cu[n],a=[],l=new Set,c=new Set(i),d=function(p){!p||l.has(p)||(l.add(p),d(p.parentNode))};i.forEach(d);var u=function(p){!p||c.has(p)||Array.prototype.forEach.call(p.children,function(h){if(l.has(h))u(h);else try{var g=h.getAttribute(r),v=g!==null&&g!=="false",x=(Qs.get(h)||0)+1,w=(s.get(h)||0)+1;Qs.set(h,x),s.set(h,w),a.push(h),x===1&&v&&Su.set(h,!0),w===1&&h.setAttribute(n,"true"),v||h.setAttribute(r,"true")}catch(b){console.error("aria-hidden: cannot operate on ",h,b)}})};return u(t),l.clear(),rg++,function(){a.forEach(function(p){var h=Qs.get(p)-1,g=s.get(p)-1;Qs.set(p,h),s.set(p,g),h||(Su.has(p)||p.removeAttribute(r),Su.delete(p)),g||p.removeAttribute(n)}),rg--,rg||(Qs=new WeakMap,Qs=new WeakMap,Su=new WeakMap,Cu={})}},M4=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=XO(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),ZO(r,i,n,"aria-hidden")):function(){return null}},Bf="Dialog",[L4]=Li(Bf),[eD,jr]=L4(Bf),Co=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:a=!0}=e,l=f.useRef(null),c=f.useRef(null),[d,u]=Tl({prop:r,defaultProp:i??!1,onChange:s,caller:Bf});return o.jsx(eD,{scope:t,triggerRef:l,contentRef:c,contentId:Nn(),titleId:Nn(),descriptionId:Nn(),open:d,onOpenChange:u,onOpenToggle:f.useCallback(()=>u(p=>!p),[u]),modal:a,children:n})};Co.displayName=Bf;var O4="DialogTrigger",h0=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=jr(O4,n),s=Ft(t,i.triggerRef);return o.jsx(Me.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":x0(i.open),...r,ref:s,onClick:Te(e.onClick,i.onOpenToggle)})});h0.displayName=O4;var g0="DialogPortal",[tD,D4]=L4(g0,{forceMount:void 0}),To=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,s=jr(g0,t);return o.jsx(tD,{scope:t,forceMount:n,children:f.Children.map(r,a=>o.jsx(Ur,{present:n||s.open,children:o.jsx(Rd,{asChild:!0,container:i,children:a})}))})};To.displayName=g0;var Yp="DialogOverlay",Eo=f.forwardRef((e,t)=>{const n=D4(Yp,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=jr(Yp,e.__scopeDialog);return s.modal?o.jsx(Ur,{present:r||s.open,children:o.jsx(rD,{...i,ref:t})}):null});Eo.displayName=Yp;var nD=Zc("DialogOverlay.RemoveScroll"),rD=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=jr(Yp,n),s=g7(),a=Ft(t,s);return o.jsx(f0,{as:nD,allowPinchZoom:!0,shards:[i.contentRef],children:o.jsx(Me.div,{"data-state":x0(i.open),...r,ref:a,style:{pointerEvents:"auto",...r.style}})})}),al="DialogContent",Ro=f.forwardRef((e,t)=>{const n=D4(al,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=jr(al,e.__scopeDialog);return o.jsx(Ur,{present:r||s.open,children:s.modal?o.jsx(oD,{...i,ref:t}):o.jsx(iD,{...i,ref:t})})});Ro.displayName=al;var oD=f.forwardRef((e,t)=>{const n=jr(al,e.__scopeDialog),r=f.useRef(null),i=Ft(t,n.contentRef,r);return f.useEffect(()=>{const s=r.current;if(s)return M4(s)},[]),o.jsx(A4,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Te(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:Te(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0;(a.button===2||l)&&s.preventDefault()}),onFocusOutside:Te(e.onFocusOutside,s=>s.preventDefault())})}),iD=f.forwardRef((e,t)=>{const n=jr(al,e.__scopeDialog),r=f.useRef(!1),i=f.useRef(!1);return o.jsx(A4,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var a,l;(a=e.onCloseAutoFocus)==null||a.call(e,s),s.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var c,d;(c=e.onInteractOutside)==null||c.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const a=s.target;((d=n.triggerRef.current)==null?void 0:d.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),A4=f.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,...a}=e,l=jr(al,n);return w4(),o.jsx(o.Fragment,{children:o.jsx(p0,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:o.jsx(Td,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":x0(l.open),...a,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})}),N4="DialogTitle",Oi=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=jr(N4,n);return o.jsx(Me.h2,{id:i.titleId,...r,ref:t})});Oi.displayName=N4;var $4="DialogDescription",Id=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=jr($4,n);return o.jsx(Me.p,{id:i.descriptionId,...r,ref:t})});Id.displayName=$4;var _4="DialogClose",Md=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=jr(_4,n);return o.jsx(Me.button,{type:"button",...r,ref:t,onClick:Te(e.onClick,()=>i.onOpenChange(!1))})});Md.displayName=_4;function x0(e){return e?"open":"closed"}const sD="fixed inset-0 bg-state-ink/40 data-[state=open]:animate-fade-in data-[state=closed]:animate-fade-out motion-reduce:animate-none ",aD="fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 flex max-h-[85vh] w-[90vw] flex-col gap-2g rounded-card border border-card bg-surface-card p-3g shadow-overlay focus:outline-none data-[state=open]:animate-zoom-in data-[state=closed]:animate-zoom-out motion-reduce:animate-none ",lD={default:"max-w-lg",wide:"max-w-3xl"},F4={default:{overlay:"z-40",content:"z-50"},nested:{overlay:"z-[80]",content:"z-[90]"}};function cD(e="default"){return sD+F4[e].overlay}function dD(e="default",t="default"){return`${aD}${lD[e]} ${F4[t].content}`}function uD({title:e,hideTitle:t}){return o.jsxs("div",{className:"flex items-start justify-between gap-2g",children:[o.jsx(Oi,{className:t?"sr-only":"text-body font-medium text-state-ink",children:e}),o.jsx(Md,{"aria-label":"Close",className:"-mr-1g -mt-1g rounded-card p-0.5g text-ui text-state-ink/60 transition-colors hover:bg-surface-canvas-alt hover:text-state-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",children:"✕"})]})}function pD({title:e,description:t,hideTitle:n,children:r,footer:i,size:s="default",layer:a="default"}){return o.jsxs(Ro,{className:dD(s,a),children:[o.jsx(uD,{title:e,hideTitle:n}),t?o.jsx(Id,{className:"text-ui text-state-ink/70",children:t}):null,r?o.jsx("div",{className:"overflow-y-auto text-ui text-state-ink/80",children:r}):null,i?o.jsx("div",{className:"flex items-center justify-end gap-1g pt-1g",children:i}):null]})}function Wf({trigger:e,open:t,onOpenChange:n,...r}){return o.jsxs(Co,{open:t,onOpenChange:n,children:[e?o.jsx(h0,{asChild:!0,children:e}):null,o.jsxs(To,{children:[o.jsx(Eo,{className:cD(r.layer)}),o.jsx(pD,{...r})]})]})}const fD=Md,hD="fixed inset-0 z-40 bg-state-ink/40 data-[state=open]:animate-fade-in data-[state=closed]:animate-fade-out motion-reduce:animate-none",gD={right:"right-0 border-l data-[state=open]:animate-slide-in-right data-[state=closed]:animate-slide-out-right",left:"left-0 border-r data-[state=open]:animate-slide-in-left data-[state=closed]:animate-slide-out-left"};function xD({title:e,description:t,hideTitle:n,side:r="right",children:i,footer:s,trigger:a,open:l,onOpenChange:c}){const d="fixed inset-y-0 z-50 flex h-full w-[92vw] max-w-md flex-col gap-2g border-card bg-surface-card p-3g shadow-overlay focus:outline-none motion-reduce:animate-none "+gD[r];return o.jsxs(Co,{open:l,onOpenChange:c,children:[a?o.jsx(h0,{asChild:!0,children:a}):null,o.jsxs(To,{children:[o.jsx(Eo,{className:hD}),o.jsxs(Ro,{className:d,children:[o.jsxs("div",{className:"flex items-start justify-between gap-2g",children:[o.jsx(Oi,{className:n?"sr-only":"text-body font-medium text-state-ink",children:e}),o.jsx(Md,{"aria-label":"Close",className:"-mr-1g -mt-1g rounded-card p-0.5g text-ui text-state-ink/60 transition-colors hover:bg-surface-canvas-alt hover:text-state-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",children:"✕"})]}),t?o.jsx(Id,{className:"text-ui text-state-ink/70",children:t}):null,i?o.jsx("div",{className:"flex-1 overflow-y-auto text-ui text-state-ink/80",children:i}):null,s?o.jsx("div",{className:"flex items-center justify-end gap-1g pt-1g",children:s}):null]})]})]})}const mD=Md;var Uf="Popover",[z4]=Li(Uf,[Af]),Ld=Af(),[vD,Di]=z4(Uf),B4=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:a=!1}=e,l=Ld(t),c=f.useRef(null),[d,u]=f.useState(!1),[p,h]=Tl({prop:r,defaultProp:i??!1,onChange:s,caller:Uf});return o.jsx(c4,{...l,children:o.jsx(vD,{scope:t,contentId:Nn(),triggerRef:c,open:p,onOpenChange:h,onOpenToggle:f.useCallback(()=>h(g=>!g),[h]),hasCustomAnchor:d,onCustomAnchorAdd:f.useCallback(()=>u(!0),[]),onCustomAnchorRemove:f.useCallback(()=>u(!1),[]),modal:a,children:n})})};B4.displayName=Uf;var W4="PopoverAnchor",yD=f.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Di(W4,n),s=Ld(n),{onCustomAnchorAdd:a,onCustomAnchorRemove:l}=i;return f.useEffect(()=>(a(),()=>l()),[a,l]),o.jsx(c0,{...s,...r,ref:t})});yD.displayName=W4;var U4="PopoverTrigger",H4=f.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Di(U4,n),s=Ld(n),a=Ft(t,i.triggerRef),l=o.jsx(Me.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":Y4(i.open),...r,ref:a,onClick:Te(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?l:o.jsx(c0,{asChild:!0,...s,children:l})});H4.displayName=U4;var m0="PopoverPortal",[bD,jD]=z4(m0,{forceMount:void 0}),q4=e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,s=Di(m0,t);return o.jsx(bD,{scope:t,forceMount:n,children:o.jsx(Ur,{present:n||s.open,children:o.jsx(Rd,{asChild:!0,container:i,children:r})})})};q4.displayName=m0;var ll="PopoverContent",V4=f.forwardRef((e,t)=>{const n=jD(ll,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,s=Di(ll,e.__scopePopover);return o.jsx(Ur,{present:r||s.open,children:s.modal?o.jsx(kD,{...i,ref:t}):o.jsx(SD,{...i,ref:t})})});V4.displayName=ll;var wD=Zc("PopoverContent.RemoveScroll"),kD=f.forwardRef((e,t)=>{const n=Di(ll,e.__scopePopover),r=f.useRef(null),i=Ft(t,r),s=f.useRef(!1);return f.useEffect(()=>{const a=r.current;if(a)return M4(a)},[]),o.jsx(f0,{as:wD,allowPinchZoom:!0,children:o.jsx(K4,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Te(e.onCloseAutoFocus,a=>{var l;a.preventDefault(),s.current||(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Te(e.onPointerDownOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;s.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:Te(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),SD=f.forwardRef((e,t)=>{const n=Di(ll,e.__scopePopover),r=f.useRef(!1),i=f.useRef(!1);return o.jsx(K4,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var a,l;(a=e.onCloseAutoFocus)==null||a.call(e,s),s.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var c,d;(c=e.onInteractOutside)==null||c.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const a=s.target;((d=n.triggerRef.current)==null?void 0:d.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),K4=f.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:u,...p}=e,h=Di(ll,n),g=Ld(n);return w4(),o.jsx(p0,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:o.jsx(Td,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:u,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onDismiss:()=>h.onOpenChange(!1),deferPointerDownOutside:!0,children:o.jsx(d4,{"data-state":Y4(h.open),role:"dialog",id:h.contentId,...g,...p,ref:t,style:{...p.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Q4="PopoverClose",CD=f.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Di(Q4,n);return o.jsx(Me.button,{type:"button",...r,ref:t,onClick:Te(e.onClick,()=>i.onOpenChange(!1))})});CD.displayName=Q4;var TD="PopoverArrow",G4=f.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Ld(n);return o.jsx(u4,{...i,...r,ref:t})});G4.displayName=TD;function Y4(e){return e?"open":"closed"}var ED=B4,RD=H4,PD=q4,ID=V4,MD=G4;const LD="z-50 min-w-[12rem] rounded-card border border-card bg-surface-card p-2g text-ui text-state-ink shadow-overlay focus:outline-none data-[state=open]:animate-popover-in data-[state=closed]:animate-popover-out motion-reduce:animate-none";function X4({trigger:e,children:t,side:n="bottom",align:r="center",open:i,onOpenChange:s}){return o.jsxs(ED,{open:i,onOpenChange:s,children:[o.jsx(RD,{asChild:!0,children:e}),o.jsx(PD,{children:o.jsxs(ID,{className:LD,side:n,align:r,sideOffset:6,children:[t,o.jsx(MD,{className:"fill-surface-card"})]})})]})}var v0="ToastProvider",[y0,OD,DD]=w5("Toast"),[J4]=Li("Toast",[DD]),[AD,Hf]=J4(v0),Z4=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:i="right",swipeThreshold:s=50,announcerContainer:a,children:l}=e,[c,d]=f.useState(null),[u,p]=f.useState(0),h=f.useRef(!1),g=f.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${v0}\`. Expected non-empty \`string\`.`),o.jsx(y0.Provider,{scope:t,children:o.jsx(AD,{scope:t,label:n,duration:r,swipeDirection:i,swipeThreshold:s,toastCount:u,viewport:c,onViewportChange:d,onToastAdd:f.useCallback(()=>p(v=>v+1),[]),onToastRemove:f.useCallback(()=>p(v=>v-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:g,announcerContainer:a,children:l})})};Z4.displayName=v0;var eC="ToastViewport",ND=["F8"],dm="toast.viewportPause",um="toast.viewportResume",tC=f.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=ND,label:i="Notifications ({hotkey})",...s}=e,a=Hf(eC,n),l=OD(n),c=f.useRef(null),d=f.useRef(null),u=f.useRef(null),p=f.useRef(null),h=Ft(t,p,a.onViewportChange),g=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=a.toastCount>0;f.useEffect(()=>{const w=b=>{var j;r.length!==0&&r.every(S=>b[S]||b.code===S)&&((j=p.current)==null||j.focus())};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[r]),f.useEffect(()=>{const w=c.current,b=p.current;if(v&&w&&b){const y=()=>{if(!a.isClosePausedRef.current){const E=new CustomEvent(dm);b.dispatchEvent(E),a.isClosePausedRef.current=!0}},j=()=>{if(a.isClosePausedRef.current){const E=new CustomEvent(um);b.dispatchEvent(E),a.isClosePausedRef.current=!1}},S=E=>{!w.contains(E.relatedTarget)&&j()},k=()=>{w.contains(document.activeElement)||j()};return w.addEventListener("focusin",y),w.addEventListener("focusout",S),w.addEventListener("pointermove",y),w.addEventListener("pointerleave",k),window.addEventListener("blur",y),window.addEventListener("focus",j),()=>{w.removeEventListener("focusin",y),w.removeEventListener("focusout",S),w.removeEventListener("pointermove",y),w.removeEventListener("pointerleave",k),window.removeEventListener("blur",y),window.removeEventListener("focus",j)}}},[v,a.isClosePausedRef]);const x=f.useCallback(({tabbingDirection:w})=>{const y=l().map(j=>{const S=j.ref.current,k=[S,...GD(S)];return w==="forwards"?k:k.reverse()});return(w==="forwards"?y.reverse():y).flat()},[l]);return f.useEffect(()=>{const w=p.current;if(w){const b=y=>{var k,E,C;const j=y.altKey||y.ctrlKey||y.metaKey;if(y.key==="Tab"&&!j){const R=document.activeElement,P=y.shiftKey;if(y.target===w&&P){(k=d.current)==null||k.focus();return}const U=x({tabbingDirection:P?"backwards":"forwards"}),K=U.findIndex($=>$===R);og(U.slice(K+1))?y.preventDefault():P?(E=d.current)==null||E.focus():(C=u.current)==null||C.focus()}};return w.addEventListener("keydown",b),()=>w.removeEventListener("keydown",b)}},[l,x]),o.jsxs(y7,{ref:c,role:"region","aria-label":i.replace("{hotkey}",g),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&o.jsx(pm,{ref:d,onFocusFromOutsideViewport:()=>{const w=x({tabbingDirection:"forwards"});og(w)}}),o.jsx(y0.Slot,{scope:n,children:o.jsx(Me.ol,{tabIndex:-1,...s,ref:h})}),v&&o.jsx(pm,{ref:u,onFocusFromOutsideViewport:()=>{const w=x({tabbingDirection:"backwards"});og(w)}})]})});tC.displayName=eC;var nC="ToastFocusProxy",pm=f.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...i}=e,s=Hf(nC,n);return o.jsx(Nf,{tabIndex:0,...i,ref:t,style:{position:"fixed"},onFocus:a=>{var d;const l=a.relatedTarget;!((d=s.viewport)!=null&&d.contains(l))&&r()}})});pm.displayName=nC;var Od="Toast",$D="toast.swipeStart",_D="toast.swipeMove",FD="toast.swipeCancel",zD="toast.swipeEnd",rC=f.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:i,onOpenChange:s,...a}=e,[l,c]=Tl({prop:r,defaultProp:i??!0,onChange:s,caller:Od});return o.jsx(Ur,{present:n||l,children:o.jsx(UD,{open:l,...a,ref:t,onClose:()=>c(!1),onPause:zr(e.onPause),onResume:zr(e.onResume),onSwipeStart:Te(e.onSwipeStart,d=>{d.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Te(e.onSwipeMove,d=>{const{x:u,y:p}=d.detail.delta;d.currentTarget.setAttribute("data-swipe","move"),d.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${u}px`),d.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${p}px`)}),onSwipeCancel:Te(e.onSwipeCancel,d=>{d.currentTarget.setAttribute("data-swipe","cancel"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),d.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Te(e.onSwipeEnd,d=>{const{x:u,y:p}=d.detail.delta;d.currentTarget.setAttribute("data-swipe","end"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),d.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${u}px`),d.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${p}px`),c(!1)})})})});rC.displayName=Od;var[BD,WD]=J4(Od,{onClose(){}}),UD=f.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:i,open:s,onClose:a,onEscapeKeyDown:l,onPause:c,onResume:d,onSwipeStart:u,onSwipeMove:p,onSwipeCancel:h,onSwipeEnd:g,...v}=e,x=Hf(Od,n),[w,b]=f.useState(null),y=Ft(t,b),j=f.useRef(null),S=f.useRef(null),k=i||x.duration,E=f.useRef(0),C=f.useRef(k),R=f.useRef(0),{onToastAdd:P,onToastRemove:L}=x,_=zr(()=>{var W;(w==null?void 0:w.contains(document.activeElement))&&((W=x.viewport)==null||W.focus()),a()}),U=f.useCallback($=>{!$||$===1/0||(window.clearTimeout(R.current),E.current=new Date().getTime(),R.current=window.setTimeout(_,$))},[_]);f.useEffect(()=>{const $=x.viewport;if($){const W=()=>{U(C.current),d==null||d()},V=()=>{const Z=new Date().getTime()-E.current;C.current=C.current-Z,window.clearTimeout(R.current),c==null||c()};return $.addEventListener(dm,V),$.addEventListener(um,W),()=>{$.removeEventListener(dm,V),$.removeEventListener(um,W)}}},[x.viewport,k,c,d,U]),f.useEffect(()=>{s&&!x.isClosePausedRef.current&&U(k)},[s,k,x.isClosePausedRef,U]),f.useEffect(()=>()=>{window.clearTimeout(R.current)},[]),f.useEffect(()=>(P(),()=>L()),[P,L]);const K=f.useMemo(()=>w?dC(w):null,[w]);return x.viewport?o.jsxs(o.Fragment,{children:[K&&o.jsx(HD,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:K}),o.jsx(BD,{scope:n,onClose:_,children:Ns.createPortal(o.jsx(y0.ItemSlot,{scope:n,children:o.jsx(v7,{asChild:!0,onEscapeKeyDown:Te(l,()=>{x.isFocusedToastEscapeKeyDownRef.current||_(),x.isFocusedToastEscapeKeyDownRef.current=!1}),children:o.jsx(Me.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":x.swipeDirection,...v,ref:y,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:Te(e.onKeyDown,$=>{$.key==="Escape"&&(l==null||l($.nativeEvent),$.nativeEvent.defaultPrevented||(x.isFocusedToastEscapeKeyDownRef.current=!0,_()))}),onPointerDown:Te(e.onPointerDown,$=>{$.button===0&&(j.current={x:$.clientX,y:$.clientY})}),onPointerMove:Te(e.onPointerMove,$=>{if(!j.current)return;const W=$.clientX-j.current.x,V=$.clientY-j.current.y,Z=!!S.current,N=["left","right"].includes(x.swipeDirection),F=["left","up"].includes(x.swipeDirection)?Math.min:Math.max,H=N?F(0,W):0,re=N?0:F(0,V),D=$.pointerType==="touch"?10:2,Q={x:H,y:re},ne={originalEvent:$,delta:Q};Z?(S.current=Q,Tu(_D,p,ne,{discrete:!1})):Hb(Q,x.swipeDirection,D)?(S.current=Q,Tu($D,u,ne,{discrete:!1}),$.target.setPointerCapture($.pointerId)):(Math.abs(W)>D||Math.abs(V)>D)&&(j.current=null)}),onPointerUp:Te(e.onPointerUp,$=>{const W=S.current,V=$.target;if(V.hasPointerCapture($.pointerId)&&V.releasePointerCapture($.pointerId),S.current=null,j.current=null,W){const Z=$.currentTarget,N={originalEvent:$,delta:W};Hb(W,x.swipeDirection,x.swipeThreshold)?Tu(zD,g,N,{discrete:!0}):Tu(FD,h,N,{discrete:!0}),Z.addEventListener("click",F=>F.preventDefault(),{once:!0})}})})})}),x.viewport)})]}):null}),HD=e=>{const{__scopeToast:t,children:n,...r}=e,i=Hf(Od,t),[s,a]=f.useState(!1),[l,c]=f.useState(!1);return KD(()=>a(!0)),f.useEffect(()=>{const d=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(d)},[]),l?null:o.jsx(Rd,{asChild:!0,container:i.announcerContainer||void 0,children:o.jsx(Nf,{...r,children:s&&o.jsxs(o.Fragment,{children:[i.label," ",n]})})})},qD="ToastTitle",oC=f.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return o.jsx(Me.div,{...r,ref:t})});oC.displayName=qD;var VD="ToastDescription",iC=f.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return o.jsx(Me.div,{...r,ref:t})});iC.displayName=VD;var sC="ToastAction",aC=f.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?o.jsx(cC,{altText:n,asChild:!0,children:o.jsx(b0,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${sC}\`. Expected non-empty \`string\`.`),null)});aC.displayName=sC;var lC="ToastClose",b0=f.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,i=WD(lC,n);return o.jsx(cC,{asChild:!0,children:o.jsx(Me.button,{type:"button",...r,ref:t,onClick:Te(e.onClick,i.onClose)})})});b0.displayName=lC;var cC=f.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...i}=e;return o.jsx(Me.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...i,ref:t})});function dC(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),QD(r)){const i=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!i)if(s){const a=r.dataset.radixToastAnnounceAlt;a&&t.push(a)}else t.push(...dC(r))}}),t}function Tu(e,t,n,{discrete:r}){const i=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?k5(i,s):i.dispatchEvent(s)}var Hb=(e,t,n=0)=>{const r=Math.abs(e.x),i=Math.abs(e.y),s=r>i;return t==="left"||t==="right"?s&&r>n:!s&&i>n};function KD(e=()=>{}){const t=zr(e);gr(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function QD(e){return e.nodeType===e.ELEMENT_NODE}function GD(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function og(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var YD=Z4,XD=tC,JD=rC,ZD=oC,eA=iC,tA=aC,nA=b0;const rA=4;function oA(e,t,n=rA){const r=[...e,t];return r.length>n?r.slice(r.length-n):r}function iA(e,t){return e.filter(n=>n.id!==t)}const sA={running:"border-l-pill-running-fg",waiting:"border-l-pill-waiting-fg",done:"border-l-pill-done-fg",failed:"border-l-pill-failed-fg",cancelled:"border-l-pill-cancelled-fg"},aA="relative flex flex-col gap-0.5g rounded-card border border-card border-l-4 bg-surface-card p-2g pr-4g shadow-overlay data-[state=open]:animate-toast-in data-[state=closed]:animate-toast-out data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=cancel]:translate-x-0 data-[swipe=end]:animate-toast-out motion-reduce:animate-none",j0=f.createContext(null);function lA({children:e}){const[t,n]=f.useState([]),r=f.useRef(0),i=f.useCallback(l=>{n(c=>iA(c,l))},[]),s=f.useCallback(l=>{const c=`toast-${r.current++}`,d={id:c,title:l.title,description:l.description,tone:l.tone??"running",duration:l.duration??5e3,actions:l.actions};return n(u=>oA(u,d)),c},[]),a=f.useMemo(()=>({toast:s,dismiss:i}),[s,i]);return o.jsx(j0.Provider,{value:a,children:o.jsxs(YD,{swipeDirection:"right",children:[e,t.map(l=>o.jsxs(JD,{duration:l.duration,onOpenChange:c=>{c||i(l.id)},className:[aA,sA[l.tone]].join(" "),children:[o.jsx(ZD,{className:"text-ui font-medium text-state-ink",children:l.title}),l.description?o.jsx(eA,{className:"text-ui text-state-ink/70",children:l.description}):null,l.actions&&l.actions.length>0?o.jsx("div",{className:"mt-1g flex flex-wrap gap-1g",children:l.actions.map((c,d)=>o.jsx(tA,{altText:c.altText??c.label,asChild:!0,children:o.jsx("button",{type:"button",onClick:c.onClick,className:"rounded-card border border-card bg-surface-canvas-alt px-1.5g py-0.5g text-ui text-state-ink transition-colors hover:bg-surface-card focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",children:c.label})},d))}):null,o.jsx(nA,{"aria-label":"Dismiss",className:"absolute right-1g top-1g rounded-card p-0.5g text-ui text-state-ink/50 transition-colors hover:bg-surface-canvas-alt hover:text-state-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",children:"✕"})]},l.id)),o.jsx(XD,{className:"fixed bottom-0 right-0 z-50 m-2g flex w-[24rem] max-w-[calc(100vw-2rem)] flex-col gap-1g outline-none"})]})})}function Tn(){const e=f.useContext(j0);if(!e)throw new Error("useToast must be used within a ToastProvider");return e}function cA(){return f.useContext(j0)}const dA={newSession:"New session",settings:"Settings",threads:"Threads",tasks:"Tasks",machines:"Machines",today:"Today",active:"Active",recentDay:"Last 1 day",history:"History",open:"Open",pause:"Pause",resume:"Resume",cancel:"Cancel",approve:"Approve",deny:"Deny",stop:"Stop",commands:"commands",composerPh:"Message Cortex — type / for commands",adjustBudget:"Adjust budget",approvals:"Approvals",cmdkPh:"Jump to session / thread / task / file…",openOverview:"Open project overview",switchProject:"SWITCH PROJECT",newProject:"New project",synced:"synced 2s ago",emptyHistory:"No finished threads yet in this demo — cancel or commit one.",approvalPending:"approval pending",approvalsPending:"approvals pending",autoAttached:"auto-attached",tuiDesc:"adds a local terminal gateway on top of the platforms",warnNote:"one warning to the admin channel",obNote:"checked against the estimate before dispatch",default:"default",month:"this month",obExample:"Over-estimate → approval card in chat & approval center (e.g. APR-0007)",mHeartbeat:"heartbeat",mRecover:"recovery",mFirewall:"strict firewall",tplList:"Templates",mcpCore:"cross-machine execution surface",mcpSlack:"Slack conversation tools — enabled with CORTEX_PLATFORM",mcpFoot:"core variant keeps only remote_* tools; tui variant serves terminal-gateway sessions",hkAuto:"dispatch auto-adds",hkBridge:"Blocking interactions (questions / plan approvals) surface as chat messages via the hook-bridge (30-min TTL); the PI backend reuses the same scripts through a bridge.",advConc:"Task dispatch concurrency",advConcNote:"hot-read from settings.json",advMock:"test-only mock JSON, overrides nvidia-smi",aprEmptyTitle:"All clear",aprEmptyDesc:"New approvals appear here and as cards in chat",issuesTitle:"Issues",issuesStat:"issues",isListLabel:"ISSUES",isRecorded:"recorded",isEmptyTitle:"No issues",isEmptyDesc:"Issues agents register during runs appear here",isNoStatusNote:"No status column — listed = pending; handle / delete to leave",isFootNote:"Handle → new session carrying the issue full text, then removed. Delete → removed. Both land in the events log",isDescLabel:"Description",isDelete:"Delete",isConfirmDelete:"Confirm delete",isHandle:"Handle",isViewAll:"View all",isToastHandled:"Session created for this issue",isToastDeleted:"Issue deleted",whyApproval:"Why approval",rejectFeedback:"Reject — feedback",denyConfirm:"Confirm reject",rename:"Rename",delete:"Delete",profNote:"read on every spawn",pillRunning:"Running",pillGated:"Gated",pillPaused:"Paused",pillWaiting:"Waiting",pillBackground:"Background",pillDone:"Done",pillFailed:"Failed",pillCancelled:"Cancelled",sessions:"Sessions",workbench:"Workbench",overview:"Overview",back:"Back",search:"Search",more:"More",project:"Project",toProcess:"to process",weekProcessed:"Processed this week",slackSynced:"Slack sync available",toolCallsUnit:"tool calls",toolCallUnit:"tool call",needsApproval:"Approval required",subthreads:"subthreads",dayToday:"Today",dayYesterday:"Yesterday",mExecutable:"Executable",mAll:"All",mInProgress:"In progress",mClaimable:"Claimable",mWaitingDeps:"Waiting",mBlocked:"Blocked",mDoneWhen:"DONE WHEN",mDoneWhenGap:"Done-when detail not available here yet",mUnblock:"Unblock",mClaim:"Claimed",mDependsOn:"needs",mAutoUnlock:"auto-unlocks",mBlockedPill:"Blocked",mNoTasks:"No tasks",step:"step",depth:"depth",pendingApproval:"Pending",budgetPerDay:"budget",perDay:"/day",thisWeek:"this week",forecastToday:"forecast today",projectMemory:"Project memory",viewAll:"All",scheduleCard:"Schedules",newSchedule:"New",execFlow:"Executions",paused:"Paused",execCountUnit:"today",mOnline:"online",mOffline:"offline",mNoMachines:"No machines configured",mLiveRuns:"live",mGpu:"GPU",mProbing:"Probing…",mProbeFailed:"Probe failed",mNoGpuReported:"No GPU reported",mOfflineNoTelemetry:"Offline — no live telemetry",mConnectedFor:"up",mPath:"path",mSsh:"ssh",mUptime:"uptime",wbToday:"today",wbDaemon:"daemon",connConnected:"connected",connConnecting:"connecting",connReconnecting:"reconnecting",connDisconnected:"disconnected",wbProfile:"profile",wbIdle:"idle",wbSwitchTo:"Switch to",wbNeedsNewSession:"needs a new session (this conversation runs on a different backend)",wbEscToStop:"esc to stop",wbNewConversation:"New conversation",wbSend:"send",wbSendFailed:"Send failed",wbDraftRestored:"message restored",wbNewline:"newline",wbNavigate:"navigate",wbRun:"run",wbEscDismiss:"esc dismiss",wbTurnsUnit:"turns",wbEmptyTitle:"Start with one message",wbEmptyBody:"This project is empty. Just chat — describe the mission and the agent runs project_init (mission.md · TASKS.yaml · memory scaffold · git).",wbEmptyHint:"Everything else — tasks, threads, cross-machine runs — starts from this chat",wbDebugInspect:"Inspect DEBUG data",wbDebugAgentMessage:"AGENT MESSAGE",wbDebugParameters:"PARAMETERS",wbDebugResult:"RESULT",wbDebugCharacters:"CHARACTERS",wbDebugSuccess:"SUCCESS",wbDebugError:"ERROR",wbDebugPending:"PENDING",wbAttach:"+ attach",wbAttachPlaceholder:"Add a message or drop more files",wbAttachHint:"paste or drop files",wbDropFilesSingular:"Drop file to attach",wbDropFilesPlural:"Drop {n} files to attach",wbAttachPath:"→ workspace/attachments/",wbFileDownload:"Download",wbFileCopyPath:"Copy path",wbFileOpen:"open",wbFileDownloadAll:"download all",wbFileFiles:"files",wbFileDownloadDone:"Download complete",wbFileDownloadFailed:"Download failed",wbFileSavedTo:"Saved to {path}",wbFileOpenFile:"Open file",wbFileOpenFolder:"Open folder",wbDragOverCount:"{n} → {m} attachments",wbDropAddMore:"Drop to add more",wbDropAddMoreN:"Drop to add {n} more",wbSessionToday:"TODAY",wbSessionYesterday:"YESTERDAY",wbSessionEarlier:"EARLIER",wbFromSchedule:"from schedule",wbAllRuns:"all {n} runs",wbSchedSection:"SCHEDULED",wbSchedManage:"manage ↗",wbSchedUnread:"{n} unread",wbSchedOnce:"once",wbSchedNextRun:"next in {d}",wbSchedPausedPill:"paused",wbSchedRunListHint:"click a run → opens that session in the chat pane",wbSchedReplyHint:"Replying converts this run into a normal session — it moves into the timeline; the schedule's next run is unaffected",wbProjects:"PROJECTS",wbSessions:"SESSIONS",wbNewShort:"New",wbCost:"Cost",wbSessionId:"Session ID",wbCortexId:"Cortex ID",wbBackendUuid:"Backend UUID",wbCopy:"Copy",wbCopied:"Copied",dmDaemon:"Daemon status",dmEsc:"esc",dmUp:"up",dmPid:"pid",dmPort:"port",dmLastRestart:"last restart",dmReason:"reason",dmSoftRestart:"Soft restart",dmSoftRestartDesc:"Drain and restart when idle — running agents are not interrupted",dmHardRestart:"Hard restart",dmHardRestartDesc:"Terminate all processes immediately and restart — running agents will be interrupted",dmHardConfirm:"Hard restart — confirm",dmHardConfirmDetail:"This will immediately kill all running agents. Active threads and sessions will be lost.",dmConfirmCancel:"Cancel",dmConfirmProceed:"Hard restart",dmRestartSent:"Restart signal sent",dmRestartFailed:"Restart failed",dmDisconnect:"Disconnect",dmDisconnectDesc:"Clear the saved server & token and return to the login screen",rpNoActiveThreads:"No active threads",rpNoActiveThreadsHint:"Running and waiting threads will appear here.",rpNoRecentThreads:"No threads finished in the last day.",rpNoFinishedThreads:"No finished threads yet.",rpOpen:"Open",rpStep:"step",rpDepth:"depth",rpLoadingThread:"Loading thread…",rpFailedLoadThread:"Failed to load thread.",rpNoMachinesHint:"Connected machines (atlas, nimbus…) appear here once registered in machines.json.",rpLoadingMachines:"Loading machines…",rpFailedLoadMachines:"Failed to load machines.",tkNone:"None",tkLoading:"Loading tasks…",tkLoadFailed:"Failed to load tasks",tkDone:"Done",tkPriHigh:"high",tkPriMed:"medium",tkPriLow:"low",tkOpen:"Open",tkActionable:"Actionable",tkAll:"All",tkInProgress:"In progress",tkApprovalNeeded:"Approval needed",tkWaitingDeps:"Waiting",tkWhy:"WHY",tkNoWhy:"no `why` recorded on this task",tkDoneWhen:"DONE-WHEN",tkNoDoneWhen:"no done-when recorded on this task",tkCompletedAt:"completed",tkDispatchHistory:"Dispatch history",tkLoadingDispatch:"loading dispatch history…",tkDispatchFailed:"failed to load dispatch history",tkNoDispatches:"no dispatches recorded for this task",tkFields:"Fields",tkDependencies:"Dependencies",tkNoDependencies:"No dependencies",ovLast14Days:"Last 14 days",ovAvg:"avg",ovGitBacked:"git-backed",ovOpenMemoryViewer:"Open memory viewer",ovMemoryDesc:"Mission · roadmap · STATUS · TASKS + experiments / knowledge / patterns / decisions.",ovWhereItGoes:"Where it goes",ovNoSpend:"No spend recorded this week.",ovNoSchedules:"No schedules for this project.",ovExecSubtitle:"every cortex-run, auditable",ovColId:"ID",ovColSummary:"SUMMARY",ovColMachine:"MACHINE",ovColDur:"DUR",ovColCost:"COST",ovColStatus:"STATUS",ovNoExecutions:"No executions for this project.",ovLogs:"Logs",stConfigured:"configured",stNotConfigured:"not configured",stReconnect:"Reconnect",stMessagingPlatforms:"Messaging platforms",stTuiGateway:"TUI gateway",stApi:"API",stDaemonNetwork:"Daemon & network",stDefaultProfile:"default profile",stProfReadNote:"read at every agent start — no restart",stColName:"NAME",stColModel:"MODEL",stColBackend:"BACKEND",stColMode:"MODE",stColThinking:"THINKING",stNoProfiles:"No profiles in profiles.json",pfNew:"New profile",pfEdit:"Edit",pfDelete:"Delete",pfConfirmDelete:"Confirm delete",pfDeleteDefaultBlocked:"The default profile cannot be deleted — point the default at another profile first",pfCreateTitle:"New profile",pfEditTitle:"Edit profile",pfSave:"Save",pfRevert:"Revert",pfDirty:"Unsaved changes",pfFieldName:"name",pfFieldModel:"model",pfFieldBackend:"backend",pfFieldMode:"mode",pfFieldProvider:"provider",pfFieldThinking:"thinking",pfFieldClaudeBackend:"claudeBackend",pfFieldExtraOption:"extraOption",pfFieldExtraEnv:"extraEnv",pfFieldFallback:"fallback",pfNameHint:"Letters, digits, - and _",pfNoRename:"The name cannot be changed — channels and sessions bind to it. Create a new profile and delete this one instead.",pfModelHint:"Model id passed to the backend CLI",pfModeHint:"Gateway route name resolved by gateway.yaml",pfProviderHint:"Required when the backend is pi",pfNotDeclared:"not declared",pfPrintDefault:"print (default)",pfAddOption:"+ Add flag",pfOptionKeyPlaceholder:"--flag",pfOptionValuePlaceholder:"value",pfRemoveOption:"Remove",pfNoExtraEnv:"none",pfExtraEnvNote:"Values never leave the server. Preserved on save — edit them in profiles.json.",pfFallbackNote:"Preserved on save — edit the fallback chain in profiles.json.",pfFallbackCount:"entries",pfErrNameRequired:"A name is required",pfErrNameCharset:"Only letters, digits, - and _ are allowed",pfErrNameTaken:"That name is already used",pfErrModelRequired:"A model is required",pfErrModeCharset:"Only letters, digits, - and _ are allowed",pfErrProviderRequired:"A pi profile must declare a provider",pfErrProviderCharset:"Only letters, digits, - and _ are allowed",pfErrThinkingLevel:"Not a valid level for this backend",pfErrOptionKeyPrefix:"A flag must start with --",pfErrOptionKeyDuplicate:"Duplicate flag",pfErrOptionValueRequired:"A flag needs a value",pfToastCreated:"Profile created",pfToastSaved:"Profile saved",pfToastUnchanged:"No change to write",pfToastDeleted:"Profile deleted",pfToastWriteFailed:"Write failed",stColCortexPath:"CORTEX PATH",stColSsh:"SSH",stColOs:"OS",stNoMachinesFile:"No machines in machines.json",stMachineLocal:"— local",stLogs:"Logs",stAddMachine:"+ Add machine",stClientLifecycle:"Client lifecycle",stConnectivity:"Connectivity",stMachinesFootNote:"SSH is a presence flag only (the raw user@host is never returned). Live CLIENT version / STATUS / heartbeat are runtime state the config.get contract does not carry — omitted rather than fabricated. The two cards above are static architecture notes.",stEntry:"entry",stEntries:"entries",stOpenEditor:"Open editor ↗",stColKind:"KIND",stColDescription:"DESCRIPTION",stColKeys:"KEYS",stNoTemplates:"No templates in thread-templates/",stTemplatesFootNote1:"Real content from thread-templates/. KEYS = top-level body keys. Template body shown as-read; no fabricated structure.",stGrpTemplates:"templates",stGrpAgents:"agents",stGrpShells:"shells",stNone:"none",stTemplatesFootNote2:"Names are the real thread-templates/ basenames. Per-template step chips / hook bindings are not in the config.get contract (no fabricated metadata).",stServers:"Servers",stNoServers:"No servers in mcp-config.json",stMcpFootNote:"core variant keeps only remote_* tools; tui variant serves terminal-gateway sessions. Per-server tool lists are not in the config.get contract (server names are the real mcp-config.json keys).",stNotifyTurnTitle:"Post a new message after a long task finishes",stNotifyTurnDesc:"Stay quiet on short turns · current threshold",stNotifyResumeTitle:"Auto-resume and notify after the rate-limit window resets",stNotifyResumeDesc:"Interrupted sessions and threads pick up automatically",stNotifyCompactionTitle:"Context compaction notice",stNotifyCompactionDesc:"Post a note in the conversation when compaction happens",stNotifyRoutingTitle:"System notification routing",stNotifyRoutingRight:"fanned out to each platform",stApprovalReminderNote:"Approval reminders are always on — re-reminds every 30 min while a thread is blocked",stRecentNotifications:"Recent notifications",stRecentNotifRight:"runtime only · no history scope",stRecentNotifNote:"Notification activity is held in the TUI client's in-memory ring buffer (cap 50, no file persistence) — not exposed via any tRPC read scope. Real-time history is not available in the web UI; use the TUI terminal interface to view live notifications.",stAgentHooks:"Mounted hooks",stNoHooks:"No mounted hooks",stHookEnabled:"Enabled",stHookDisabled:"Disabled",stHooksFootNote:"Mounted state comes from config/hooks declarations and thread-template lifecycle hooks, using the same source classification as cortex-hook list.",hkFilterAll:"All",hkFilterAgent:"Agent",hkFilterClaude:"Claude",hkFilterPi:"PI",hkFilterServer:"Server",hkFilterTemplate:"Template",hkSearchPh:"Search id, event, script…",hkNoMatch:"No hook matches this filter",hkSelectHint:"Select a hook to read its declaration",hkLoading:"Loading hooks…",hkLoadFailed:"Failed to load hooks:",hkCreate:"New hook",hkSecTrigger:"Trigger",hkSecAction:"Action",hkSecScope:"Scope",hkSecAdvanced:"Advanced",hkSecDeclaration:"Declaration",hkSecRegistry:"Registry",hkOrderNote:"order = run order within one event",hkFieldId:"id",hkFieldEvent:"event",hkFieldMatcher:"matcher",hkFieldFilters:"filters",hkFieldRun:"run",hkFieldTemplate:"template",hkFieldScript:"script",hkFieldCommand:"command",hkFieldTimeout:"timeout",hkFieldBackends:"backends",hkFieldRequiresTool:"requires tool",hkFieldResult:"result",hkFieldSource:"source",hkFieldFile:"file",hkFieldOrder:"order",hkFieldBlocking:"blocking",hkFieldVersion:"version",hkFieldMountsOn:"mounts on",hkFieldAppliesAt:"applies at",hkSeconds:"seconds",hkUnscoped:"both — derived from the event prefix",hkNoMatcher:"empty — matches everything",hkMatcherRegexHint:"Regular expression tested against the tool name",hkMatcherFiltersHint:"Every key must be present in the payload with exactly this value",hkMatcherInvalid:"Invalid regular expression",hkAddFilter:"Add filter",hkRemoveFilter:"Remove",hkFilterKeyPh:"key",hkFilterValuePh:"value",hkResultLocked:"This event cannot return a result — the loader only accepts none.",hkAppliesNextAgent:"Takes effect on the next agent spawn.",hkAppliesRestart:"The event bus snapshots the registry at startup — this takes effect after a server restart.",hkNoteManaged:"Managed entry, shipped with Cortex. Only the enabled switch is writable here, and a future hook sync will restore the shipped enabled state.",hkNoteTemplate:"Owned by a thread template file. Edit it in the Thread templates section — this panel keeps it read-only.",hkClaudeGap:"No Claude mount point for this agent:* event — it reaches PI only. To hook Claude, declare it natively as:",hkScriptMissing:"Script not found in the hooks directory — this hook fails silently.",hkBroken:"broken",hkDirty:"Unsaved changes",hkSave:"Save",hkRevert:"Revert",hkDelete:"Delete",hkConfirmDelete:"Confirm delete",hkCancelCreate:"Discard",hkTest:"Test",hkTestTitle:"Test run",hkTestPayload:"Payload — JSON delivered on stdin",hkTestRun:"Run",hkTestClose:"Close",hkTestReset:"Reset to sample",hkTestNoOutput:"no output",hkTestBlockingWarn:"This hook blocks on a webhook round trip and posts a card to the message platform. The test run is capped at 15s, but it can park for that whole cap.",hkPayloadInvalid:"Payload is not valid JSON",hkErrIdRequired:"An id is required",hkErrIdTaken:"That id is already claimed by another declaration",hkErrEventRequired:"An event is required",hkErrRunRequired:"Exactly one of script or command is required",hkErrTimeout:"Timeout must be a positive number of seconds",hkErrFiltersEmptyKey:"Filter keys cannot be empty",hkErrFiltersDuplicate:"Filter keys must be unique",hkErrResult:"That result mode is not legal for this event",hkToastSaved:"Hook saved",hkToastCreated:"Hook created",hkToastDeleted:"Hook deleted",hkToastEnabled:"Hook enabled",hkToastDisabled:"Hook disabled",hkToastWriteFailed:"Hook write failed",hkToastTestFailed:"Test run failed",stAdvConcNote:"auto = max(4, cpus − 2) · hot-read from settings.json",stSet:"set",stAuto:"auto",stGpuMock:"GPU mock",stLoadingConfig:"Loading config…",stFailedLoadConfig:"Failed to load config:",stPolicyPauseTitle:"Pause & request approval",stPolicyPauseDesc:"over-estimate → approval (class: over-budget compute); continues once approved",stPolicyWarnTitle:"Warn only, keep going",stPolicyWarnDesc:"posts a warning to the admin channel, never blocks",stPolicyStopTitle:"Hard stop",stPolicyStopDesc:"no new dispatches today; running work unaffected",stLimits:"Limits",stDaily:"DAILY",stMonthly:"MONTHLY",stApply:"Apply",stBudgetScope:"SCOPE",stBudgetScopeGlobal:"Global",stBudgetScopeNote:"global default, or one project’s own limits",stBudgetInherited:"No limits of its own — showing the global defaults it currently inherits. Setting either limit creates a per-project override with both.",stBudgetClear:"Clear override",stBudgetClearHint:"Remove this project’s own limits and let it inherit the global defaults again.",stBudgetCustomPlaceholder:"custom",stBudgetAmountInvalid:"Enter a positive amount, e.g. 12.50",stWarnAt:"WARN AT",stOverBudgetBehavior:"Over-budget behavior",stCurrentSpend:"Current spend",stObNote:"Over-estimate → approval card in chat & approval center",stBudgetFootNote:"today / month are real (cost.summary, scoped to the selected scope); the daily/monthly denominators are real (budget.json, per-project override when one exists). Budget is advisory — nothing in the server stops work on it.",stNavAppearance:"Appearance",stNavPlatform:"Platform",stNavAccounts:"Accounts",stNavProfiles:"Profiles",stNavBudget:"Budget",stNavMachines:"Machines",stNavTemplates:"Thread templates",stNavMcp:"MCP servers",stNavNotifications:"Notifications",stNavHooks:"Hooks",stNavAdvanced:"Advanced",stMetaAppearanceSub:"Language & theme — interface language and light/dark. Applies instantly and is remembered on this device.",stMetaPlatformSub:"config/.env — loaded once at daemon startup; the only restart-required config",stMetaAccountsSub:"Claude Code credentials and every PI provider reported by auth.status",stMetaProfilesSub:"config/profiles.json — read on every agent spawn, no restart needed",stMetaBudgetSub:"config/budget.json — hot-read, applies immediately; upgrades never overwrite (only --force)",stMetaMachinesSub:"config/machines.json — fs.watch hot-reload; clients auto-launched over SSH at startup",stMetaTemplatesSub:"config/thread-templates/ — validated on save, hot-reloaded without a restart",stMetaMcpSub:"config/mcp-config.json — full / core / tui variants picked per runtime mode",stMetaNotificationsSub:"config/settings.json — live notification controls and per-platform routing",stMetaHooksSub:"mounted registry and template-scoped hooks — current event, enabled state, and source",stMetaAdvancedSub:"runtime flags in settings.json; DEBUG remains read-only from the process environment",stThemeLabel:"Theme",stThemeLight:"Light",stThemeDark:"Dark",stThemeHint:"Colors follow the Cortex design system in both modes; the choice is saved on this device.",stLangLabel:"Language",stLangHint:"Interface language for the workbench. Applies instantly and is saved on this device.",stLangEnglish:"English",stLangChinese:"中文",stBudgetWriteError:"Cannot write budget — both the daily and the monthly limit must be positive (overrides are pair-only)",stCostsJsonlLabel:"costs.jsonl · 90d",stEsc:"esc",stWinOs:"windows",stUnixOs:"unix",stAddMachinePrompt:"Machine name to request (queued for approval, not added directly):",stMachineFieldsHint:"name · cortexPath · gpuCount · ssh · win · clientCommand",stToastQueuedApproval:"Queued for approval — review in the Approval Center",stToastWriteFailed:"Write failed",stToastCouldNotQueue:"Could not queue request",stToastBudgetWritten:"budget.json written",stToastBudgetCleared:"override removed — inheriting the global limits",stToastDefaultProfile:"profiles.json written",stReconnectApprovalTitle:"Queues a reconnect request for approval — never runs directly from the browser",stReconnectInertTitle:"No reconnect backend op — inert",stAddMachineApprovalTitle:"Queues an add-machine request for approval — never writes machines.json directly",stAddMachineInertTitle:"Writes machines.json — no add-machine backend op (form out of scope)",ttEditorTitle:"Thread templates",ttNew:"New",ttSearchPh:"Search name or description",ttFilterAll:"all",ttFilterTemplate:"templates",ttFilterAgent:"agents",ttFilterShell:"shells",ttNoMatch:"Nothing matches this filter",ttSelectPrompt:"Select an entry to view or edit it",ttTabBody:"Body",ttTabValidation:"Validation",ttTabReferences:"References",ttOriginStock:"stock",ttOriginModified:"modified",ttOriginCustom:"custom",ttOriginStockTitle:"Identical to the shipped default",ttOriginModifiedTitle:"Differs from the shipped default — it no longer receives upstream changes",ttOriginCustomTitle:"No shipped default of this name",ttSave:"Save",ttSaveConfirm:"Save anyway",ttRevert:"Revert",ttValidate:"Validate",ttDelete:"Delete",ttDeleteConfirm:"Confirm delete",ttDuplicate:"Duplicate",ttCancel:"Cancel",ttFormat:"Format",ttNameLabel:"name",ttKindLabel:"kind",ttNamePh:"lowercase-with-hyphens",ttNoErrors:"No errors",ttNoWarnings:"No warnings",ttErrors:"Errors",ttWarnings:"Warnings",ttErrorsBlock:"Errors block saving. Warnings do not.",ttUsedBy:"Used by templates",ttUsedByNone:"No template references this",ttRunningThreads:"Running threads",ttReferencingTasks:"Open tasks dispatching this",ttFilePath:"File",ttExpanded:"Expanded graph",ttExpandedNote:"This template binds a shell. Below is the transition graph it expands to at load time.",ttRunningWarn:"thread(s) are running on this template. Transitions are re-read on every step, so saving now can reroute or stall them.",ttForkWarn:"This matches the shipped default. Saving forks it — it will stop receiving upstream updates.",ttDeleteBlockedDependents:"Cannot delete while other templates reference this",ttDeleteBlockedRunning:"Cannot delete while threads are running on it",ttHintParse:"Body is not valid JSON",ttHintClean:"No changes to save",ttHintName:"Enter a valid name",ttToastSaved:"Saved",ttToastDeleted:"Deleted",ttToastValid:"Valid — no errors",ttToastInvalid:"Validation failed",ttToastWriteFailed:"Write failed",ttToastConflict:"Changed on disk since it was loaded — reload before saving",ttInvalidBadge:"invalid",ttFootNote:"Files under config/thread-templates/. The filename is the identity; renaming is duplicate-then-delete. The directory is git-tracked, so git is the undo.",stAdvDebugTitle:"Debug logging",stAdvDebugDesc:"verbose output to daemon.log",stAdvEventLogTitle:"Event-bus log",stAdvEventLogDesc:"records every event-bus message",stAdvDiskMonitorTitle:"Disk-space monitor",stAdvDiskMonitorDesc:"checks the Cortex data filesystem and warns below 500 MB",stAdvToolCallsTitle:"Inline tool-call rendering",stAdvToolCallsDesc:"renders tool calls in message tails",stAdvDisableUserTitle:"Disable USER.md injection",stAdvDisableUserDesc:"direct turns inject by default; thread steps never do",stAdvDisableUpdateTitle:"Disable auto-update check",stAdvDisableUpdateDesc:"update check is on by default",npProjectName:"PROJECT NAME",npHint:"Becomes context/projects/<name>/ — the agent handles everything else",npCreate:"Create →",cpNoResults:"No results.",cpFooterHint:"↑↓ navigate · ⏎ open · esc dismiss",cpSubOverview:"project dashboard",cpSubWorkbench:"session chat",cpSubTasks:"task queue",cpSubThreads:"thread runs",cpSubSettings:"platform · profiles · budget · machines…",skTitle:"Skills",skScanning:"Scanning…",skLoadError:"Could not load skills",skLoadingBody:"Loading skills…",skFailedBody:"Failed to load skills. Is agent-server running?",skEmpty:"No skills found. Add skill directories under DATA_DIR/.claude/skills/ or plugins/.",skUserSkills:"user skills",shNothingHere:"Nothing here yet",apPending:"PENDING",apFrom:"from",apTask:"task",apProject:"project",apOperation:"OPERATION",apReason:"REASON",apImpact:"IMPACT",apCommand:"COMMAND",apFeedbackLabel:"Feedback",apFeedbackPh:"Reason — sent back to the agent…",apFootNote:"On decision → PENDING_APPROVALS.md flips · the chat card stays in sync",apToastApproved:"Approved — PENDING_APPROVALS.md updated",apToastRejected:"Rejected — reason sent back to the agent",scNewSchedule:"New schedule",scType:"TYPE",scTypeInterval:"interval",scTypeDaily:"daily",scTypeWeekly:"weekly",scTypeOnce:"once",scTime:"TIME",scEvery:"EVERY",scIn:"IN",scDay:"DAY",scProfile:"PROFILE",scMessage:"MESSAGE",scMessagePh:"Check GPU status on all machines and post a one-line summary.",scTarget:"TARGET",scFallback:"FALLBACK",scNextRun:"next run",scFooterIn:"in",scCreateSchedule:"Create schedule",scDaySun:"Sun",scDayMon:"Mon",scDayTue:"Tue",scDayWed:"Wed",scDayThu:"Thu",scDayFri:"Fri",scDaySat:"Sat",scToastCreated:"Schedule created",scToastCreateFailed:"Could not create schedule",scEditSchedule:"Edit schedule",scSaveSchedule:"Save changes",scToastUpdated:"Schedule updated",scToastUpdateFailed:"Could not update schedule",memMemory:"Memory",memLoading:"Loading…",memNoFiles:"No memory files.",memDiffUnavailable:"diff metadata unavailable",memLinesChanged:"lines changed vs HEAD (git numstat).",memBlameNote:"Each line below is annotated with its real last-touch commit hash and task ref (git blame); a task ref is blank when that commit carries no task tag.",memBlameUnavailable:"Per-line blame is unavailable — this project directory is not a git work tree (or git is unavailable), so commit hashes / task refs are not shown. The file below is the current content.",memLoadingFile:"Loading file…",memReadError:"Could not read this file.",memSelectFile:"Select a file to view.",memSummary:"summary",thArtifact:"THREAD ARTIFACT",thLive:"live",thNoArtifact:"No artifact",thOwner:"owner",thReferences:"REFERENCES",thWrittenBy:"WRITTEN BY",thWorkspace:"workspace",thTask:"task",thProject:"project",thFailedLoadThread:"Failed to load thread",thTemplate:"template",thStarted:"started",thElapsed:"elapsed",thCostInclChildren:"cost incl. children",thPipeline:"PIPELINE",thOpenSub:"open",thAgentLabel:"agent",thAgentSection:"AGENT",thSubThreads:"SUB-THREADS",thStepNoSession:"not started — no session yet",thStepLoading:"loading transcript…",thStepEmpty:"no messages yet",exLogTitle:"Execution log",exAlreadyFinished:"already finished",exKilled:"killed",exWaitingOutput:"waiting for output…",exNoLiveLog:"no live log — this execution is not a cortex-run launch",exNoLogOutput:"no log output",exLinesDropped:"lines dropped",exFooterHeartbeat:"heartbeat 30s · missed 0 · → costs.jsonl",exKillRun:"Kill run",authLoginTitle:"Backend login",authLoginIntro:"Choose a backend, provider, and authentication type.",authLoginBackend:"Backend",authLoginType:"Authentication type",authLoginApiKey:"API key",authLoginOAuth:"OAuth",authLoginSubscription:"Subscription (OAuth)",authLoginProvider:"Provider",authLoginStart:"Start login",authLoginAgain:"Log in again",noticeCancelResume:"Don't resume",noticeCancelResumeDone:"Resume cancelled",authLoginSubmit:"Submit",authLoginClose:"Close",authLoginRunning:"Starting login…",authLoginSecretPrompt:"Enter the API key. It will not be stored in chat or transcripts.",authLoginOpenLink:"Open link",authLoginOpenAuthorization:"Open authorization page",authLoginOpenVerification:"Open verification page",authLoginExpiresIn:"Expires in {seconds} seconds.",authLoginDone:"Login complete",authLoginDoneSummary:"Logged in to {provider}.",authLoginFailed:"Login failed",authLoginUnknownFailure:"The login flow failed.",authLoginExpired:"This login flow expired or is no longer available.",authLoginAlreadyActive:"A login flow is already active on another surface.",authLoginCancelled:"Login cancelled",authLoginCancelledSummary:"No credential was submitted.",accountsTitle:"Accounts",accountsSource:"Source",accountsExpires:"Expires",accountsInUse:"In use",accountsPiProviders:"PI providers",accountsLogin:"Log in",accountsLogout:"Log out",accountsFilter:"Filter providers",accountsFilterPlaceholder:"Filter by provider name…",accountsNoProviders:"No providers match this filter.",accountsStatusLoggedIn:"Logged in",accountsStatusExpiring:"Expiring soon",accountsStatusLoggedOut:"Not logged in",accountsStatusInvalid:"Invalid",accountsGroupInUse:"In use",accountsGroupLoggedIn:"Logged in",accountsGroupOther:"Other",accountsConnectedMark:"✓",accountsDisconnected:"not logged in",accountsPiSummary:"PI logged in {count}",accountsLoading:"Loading accounts…",accountsLoadFailed:"Could not load account status.",accountsLogoutDone:"Logged out",accountsLogoutFailed:"Logout failed",cpvTitle:"Custom providers",cpvSubtitle:"Self-hosted or proxied endpoints, routed through the gateway",cpvNew:"New provider",cpvEdit:"Edit",cpvDelete:"Delete",cpvConfirmDelete:"Confirm delete",cpvSave:"Save",cpvCancel:"Cancel",cpvCreateTitle:"New custom provider",cpvEditTitle:"Edit custom provider",cpvFieldName:"name",cpvFieldApi:"protocol",cpvFieldUrl:"upstream",cpvFieldKey:"key",cpvFieldModels:"models",cpvNameHint:"Letters, digits, - and _",cpvNoRename:"The name cannot be changed — profiles bind to it. Create a new provider and delete this one instead.",cpvApiHint:"Request protocol the endpoint speaks",cpvUrlHint:"The real endpoint; it is stored in the gateway route, not in PI",cpvKeyHint:"Kept in the gateway only. Leave empty to keep the stored key.",cpvKeyPlaceholder:"unchanged",cpvModelsHint:"One model id per line",cpvNone:"No custom providers defined.",cpvUnrouted:"no gateway route",cpvKeyStored:"key stored",cpvNoKey:"no key",cpvErrNameRequired:"A name is required",cpvErrNameCharset:"Only letters, digits, - and _ are allowed",cpvErrNameTaken:"That name is already used",cpvErrUpstreamRequired:"An upstream URL is required",cpvErrUpstreamScheme:"The URL must start with http:// or https://",cpvErrModelsRequired:"At least one model id is required",cpvErrModelsDuplicate:"Model ids must be unique",cpvToastSaved:"Provider saved",cpvToastDeleted:"Provider deleted",cpvToastFailed:"Write failed"},uA={newSession:"新会话",settings:"设置",threads:"线程",tasks:"任务",machines:"机器",today:"今日",active:"活跃",recentDay:"近 1 天",history:"历史",open:"打开",pause:"暂停",resume:"恢复",cancel:"取消",approve:"批准",deny:"拒绝",stop:"停止",commands:"命令",composerPh:"输入消息,/ 调用命令",adjustBudget:"调整预算",approvals:"审批",cmdkPh:"跳转到会话 / 线程 / 任务 / 文件…",openOverview:"打开项目 Overview",switchProject:"切换项目",newProject:"新建项目",synced:"2 秒前同步",emptyHistory:"演示里还没有已结束的线程——试试取消或提交一个。",approvalPending:"项待审批",approvalsPending:"项待审批",autoAttached:"自动附带",tuiDesc:"在消息平台之上附加本机终端入口",warnNote:"到线向 admin 频道发一次警告",obNote:"dispatch 前按预估成本判定",default:"默认",month:"本月",obExample:"预估超限 → chat 审批卡 + 审批中心(如 APR-0007)",mHeartbeat:"心跳",mRecover:"断连恢复",mFirewall:"严格防火墙",tplList:"模板",mcpCore:"跨机执行入口",mcpSlack:"Slack 会话工具 — 随 CORTEX_PLATFORM 启用",mcpFoot:"core 变体仅保留 remote_* 工具;tui 变体供终端网关会话使用",hkAuto:"dispatch 自动追加",hkBridge:"阻塞式交互(提问 / 计划审批)经 hook-bridge 变成 chat 里的交互消息(30 分钟 TTL);PI 后端通过桥复用同一批脚本。",advConc:"任务派发并发上限",advConcNote:"从 settings.json 热读取",advMock:"测试用 mock JSON,覆盖真实 nvidia-smi",aprEmptyTitle:"队列已清空",aprEmptyDesc:"新审批会出现在这里,并同步为 chat 里的审批卡",issuesTitle:"Issues",issuesStat:"issues",isListLabel:"ISSUES",isRecorded:"记录于",isEmptyTitle:"没有 issue",isEmptyDesc:"agent 运行中登记的 issue 会出现在这里",isNoStatusNote:"无状态列 — 在列表即待处理;处理 / 删除 即离场",isFootNote:"处理 → 新建会话携带 issue 全文,处理后移除;删除 → 直接移除 · 两者均落 events log",isDescLabel:"描述",isDelete:"删除",isConfirmDelete:"确认删除",isHandle:"处理",isViewAll:"查看全部",isToastHandled:"已创建处理会话",isToastDeleted:"已删除 issue",whyApproval:"为什么需要审批",rejectFeedback:"拒绝并反馈",denyConfirm:"确认拒绝",rename:"重命名",delete:"删除",profNote:"每次启动现读",pillRunning:"运行中",pillGated:"等审批",pillPaused:"已暂停",pillWaiting:"等待中",pillBackground:"后台运行",pillDone:"完成",pillFailed:"失败",pillCancelled:"已取消",sessions:"会话",workbench:"工作台",overview:"概览",back:"返回",search:"搜索",more:"更多",project:"项目",toProcess:"待处理",weekProcessed:"本周已处理",slackSynced:"Slack 同步可用",toolCallsUnit:"次工具调用",toolCallUnit:"次工具调用",needsApproval:"需要审批",subthreads:"子线程",dayToday:"今天",dayYesterday:"昨天",mExecutable:"可执行",mAll:"全部",mInProgress:"进行中",mClaimable:"可认领",mWaitingDeps:"等依赖",mBlocked:"已阻塞",mDoneWhen:"完成标准(DONE WHEN)",mDoneWhenGap:"done-when 明细暂无法在此展示",mUnblock:"解除",mClaim:"认领",mDependsOn:"依赖",mAutoUnlock:"自动解锁",mBlockedPill:"阻塞",mNoTasks:"暂无任务",step:"步骤",depth:"深度",pendingApproval:"待审批",budgetPerDay:"预算",perDay:"/日",thisWeek:"本周",forecastToday:"预测今日",projectMemory:"项目记忆",viewAll:"全部",scheduleCard:"调度",newSchedule:"新建",execFlow:"执行流水",paused:"已暂停",execCountUnit:"今日",mOnline:"在线",mOffline:"离线",mNoMachines:"暂无机器",mLiveRuns:"运行",mGpu:"GPU",mProbing:"探测中…",mProbeFailed:"探测失败",mNoGpuReported:"未检测到 GPU",mOfflineNoTelemetry:"离线 — 无实时数据",mConnectedFor:"已连接",mPath:"路径",mSsh:"ssh",mUptime:"运行时长",wbToday:"今日",wbDaemon:"守护进程",connConnected:"已连接",connConnecting:"连接中",connReconnecting:"正在重连",connDisconnected:"已断开",wbProfile:"配置",wbIdle:"空闲",wbSwitchTo:"切换到",wbNeedsNewSession:"需要新建会话(当前对话运行在不同的后端上)",wbEscToStop:"esc 停止",wbNewConversation:"新对话",wbSend:"发送",wbSendFailed:"发送失败",wbDraftRestored:"消息已恢复",wbNewline:"换行",wbNavigate:"导航",wbRun:"执行",wbEscDismiss:"esc 关闭",wbTurnsUnit:"轮",wbEmptyTitle:"从一条消息开始",wbEmptyBody:"这个项目还是空的。直接聊——描述目标,agent 会运行 project_init(mission.md · TASKS.yaml · 记忆脚手架 · git)。",wbEmptyHint:"其余的一切——任务、线程、跨机运行——都从这个对话开始",wbDebugInspect:"查看 DEBUG 数据",wbDebugAgentMessage:"实际 AGENT 消息",wbDebugParameters:"完整参数",wbDebugResult:"完整结果",wbDebugCharacters:"字符",wbDebugSuccess:"成功",wbDebugError:"错误",wbDebugPending:"等待中",wbAttach:"+ 附件",wbAttachPlaceholder:"输入消息或拖入更多文件",wbAttachHint:"粘贴或拖入文件",wbDropFilesSingular:"拖入文件以添加附件",wbDropFilesPlural:"拖入 {n} 个文件以添加附件",wbAttachPath:"→ workspace/attachments/",wbFileDownload:"下载",wbFileCopyPath:"复制路径",wbFileOpen:"打开",wbFileDownloadAll:"全部下载",wbFileFiles:"个文件",wbFileDownloadDone:"下载完成",wbFileDownloadFailed:"下载失败",wbFileSavedTo:"已保存到 {path}",wbFileOpenFile:"打开文件",wbFileOpenFolder:"打开文件夹",wbDragOverCount:"{n} → {m} 个附件",wbDropAddMore:"拖入以添加更多",wbDropAddMoreN:"拖入以添加 {n} 个更多",wbSessionToday:"今天",wbSessionYesterday:"昨天",wbSessionEarlier:"更早",wbFromSchedule:"来自调度",wbAllRuns:"全部 {n} runs",wbSchedSection:"SCHEDULED",wbSchedManage:"manage ↗",wbSchedUnread:"{n} 未读",wbSchedOnce:"单次",wbSchedNextRun:"{d} 后运行",wbSchedPausedPill:"已暂停",wbSchedRunListHint:"点击任意 run → chat 栏打开该次 session",wbSchedReplyHint:"发送后提取为普通 session:移入时间线;schedule 的下次 run 不受影响",wbProjects:"项目",wbSessions:"会话",wbNewShort:"新建",wbCost:"成本",wbSessionId:"会话 ID",wbCortexId:"Cortex ID",wbBackendUuid:"后端 UUID",wbCopy:"复制",wbCopied:"已复制",dmDaemon:"守护进程状态",dmEsc:"esc",dmUp:"运行",dmPid:"pid",dmPort:"端口",dmLastRestart:"上次重启",dmReason:"原因",dmSoftRestart:"软重启",dmSoftRestartDesc:"等待空闲时重启,运行中的 Agent 不中断",dmHardRestart:"硬重启",dmHardRestartDesc:"立即终止全部进程再拉起,运行中的 Agent 会被打断",dmHardConfirm:"硬重启 — 确认",dmHardConfirmDetail:"这将立即终止所有运行中的 Agent。活跃的线程和会话将会丢失。",dmConfirmCancel:"取消",dmConfirmProceed:"硬重启",dmRestartSent:"重启信号已发送",dmRestartFailed:"重启失败",dmDisconnect:"断开连接",dmDisconnectDesc:"清除已保存的服务器与令牌,返回登录页",rpNoActiveThreads:"暂无活跃线程",rpNoActiveThreadsHint:"运行中和等待中的线程将显示在此处。",rpNoRecentThreads:"近 1 天没有结束的线程。",rpNoFinishedThreads:"暂无已完成的线程。",rpOpen:"打开",rpStep:"步骤",rpDepth:"深度",rpLoadingThread:"正在加载线程…",rpFailedLoadThread:"加载线程失败。",rpNoMachinesHint:"已连接的机器(atlas、nimbus…)在 machines.json 中注册后将显示在此处。",rpLoadingMachines:"正在加载机器…",rpFailedLoadMachines:"加载机器失败。",tkNone:"无",tkLoading:"正在加载任务…",tkLoadFailed:"加载任务失败",tkDone:"已完成",tkPriHigh:"高",tkPriMed:"中",tkPriLow:"低",tkOpen:"未完成",tkActionable:"可执行",tkAll:"全部",tkInProgress:"进行中",tkApprovalNeeded:"需要审批",tkWaitingDeps:"等待",tkWhy:"为什么",tkNoWhy:"该任务未记录 `why`",tkDoneWhen:"完成标准",tkNoDoneWhen:"该任务未记录完成标准",tkCompletedAt:"完成于",tkDispatchHistory:"派发历史",tkLoadingDispatch:"正在加载派发历史…",tkDispatchFailed:"加载派发历史失败",tkNoDispatches:"该任务未记录派发",tkFields:"字段",tkDependencies:"依赖",tkNoDependencies:"无依赖",ovLast14Days:"最近 14 天",ovAvg:"平均",ovGitBacked:"Git 托管",ovOpenMemoryViewer:"打开记忆查看器",ovMemoryDesc:"使命 · 路线图 · STATUS · TASKS + 实验 / 知识 / 模式 / 决策",ovWhereItGoes:"花在哪里",ovNoSpend:"本周暂无支出记录",ovNoSchedules:"本项目暂无调度",ovExecSubtitle:"每次 cortex-run 均可审计",ovColId:"ID",ovColSummary:"摘要",ovColMachine:"机器",ovColDur:"时长",ovColCost:"成本",ovColStatus:"状态",ovNoExecutions:"本项目暂无执行记录",ovLogs:"日志",stConfigured:"已配置",stNotConfigured:"未配置",stReconnect:"重新连接",stMessagingPlatforms:"消息平台",stTuiGateway:"TUI 网关",stApi:"API",stDaemonNetwork:"守护进程与网络",stDefaultProfile:"默认配置",stProfReadNote:"读取于每次 agent 启动 — 免重启",stColName:"名称",stColModel:"模型",stColBackend:"后端",stColMode:"模式",stColThinking:"思考",stNoProfiles:"profiles.json 中暂无配置",pfNew:"新建配置",pfEdit:"编辑",pfDelete:"删除",pfConfirmDelete:"确认删除",pfDeleteDefaultBlocked:"默认配置不能删除 — 请先把默认指向其他配置",pfCreateTitle:"新建配置",pfEditTitle:"编辑配置",pfSave:"保存",pfRevert:"还原",pfDirty:"有未保存的更改",pfFieldName:"名称",pfFieldModel:"模型",pfFieldBackend:"后端",pfFieldMode:"模式",pfFieldProvider:"供应商",pfFieldThinking:"思考",pfFieldClaudeBackend:"claudeBackend",pfFieldExtraOption:"额外参数",pfFieldExtraEnv:"额外环境变量",pfFieldFallback:"回退链",pfNameHint:"仅允许字母、数字、- 和 _",pfNoRename:"名称不可更改 — 频道与会话按名称绑定。请新建一个配置再删除此配置。",pfModelHint:"传给后端 CLI 的模型 id",pfModeHint:"由 gateway.yaml 解析的网关路由名",pfProviderHint:"后端为 pi 时必填",pfNotDeclared:"未声明",pfPrintDefault:"print(默认)",pfAddOption:"+ 添加参数",pfOptionKeyPlaceholder:"--参数",pfOptionValuePlaceholder:"值",pfRemoveOption:"移除",pfNoExtraEnv:"无",pfExtraEnvNote:"值不会下发到前端。保存时原样保留 — 需要修改请编辑 profiles.json。",pfFallbackNote:"保存时原样保留 — 需要修改回退链请编辑 profiles.json。",pfFallbackCount:"条",pfErrNameRequired:"名称必填",pfErrNameCharset:"仅允许字母、数字、- 和 _",pfErrNameTaken:"该名称已被占用",pfErrModelRequired:"模型必填",pfErrModeCharset:"仅允许字母、数字、- 和 _",pfErrProviderRequired:"pi 配置必须声明 provider",pfErrProviderCharset:"仅允许字母、数字、- 和 _",pfErrThinkingLevel:"该后端不支持这个级别",pfErrOptionKeyPrefix:"参数需以 -- 开头",pfErrOptionKeyDuplicate:"参数重复",pfErrOptionValueRequired:"参数需要一个值",pfToastCreated:"配置已创建",pfToastSaved:"配置已保存",pfToastUnchanged:"没有需要写入的更改",pfToastDeleted:"配置已删除",pfToastWriteFailed:"写入失败",stColCortexPath:"CORTEX 路径",stColSsh:"SSH",stColOs:"系统",stNoMachinesFile:"machines.json 中暂无机器",stMachineLocal:"— 本地",stLogs:"日志",stAddMachine:"+ 添加机器",stClientLifecycle:"客户端生命周期",stConnectivity:"连通性",stMachinesFootNote:"SSH 仅为存在标记(绝不返回原始 user@host)。实时 CLIENT 版本 / STATUS / 心跳属于运行时状态,config.get 契约不携带——宁可省略也不编造。上方两张卡片为静态架构说明。",stEntry:"条",stEntries:"条",stOpenEditor:"打开编辑器 ↗",stColKind:"类型",stColDescription:"描述",stColKeys:"键数",stNoTemplates:"thread-templates/ 中暂无模板",stTemplatesFootNote1:"真实内容来自 thread-templates/。KEYS = 顶层 body 键数。模板 body 按读取原样展示;不编造结构。",stGrpTemplates:"模板",stGrpAgents:"智能体",stGrpShells:"Shell",stNone:"无",stTemplatesFootNote2:"名称为 thread-templates/ 的真实文件名。单模板的步骤标签 / 钩子绑定不在 config.get 契约中(不编造元数据)。",stServers:"服务器",stNoServers:"mcp-config.json 中暂无服务器",stMcpFootNote:"core 变体仅保留 remote_* 工具;tui 变体供终端网关会话使用。单服务器的工具列表不在 config.get 契约中(服务器名称为 mcp-config.json 的真实键)。",stNotifyTurnTitle:"长任务完成后发新消息",stNotifyTurnDesc:"短回合保持安静 · 当前阈值",stNotifyResumeTitle:"限额窗口重置后自动续跑并通知",stNotifyResumeDesc:"中断的会话与线程自动接着跑",stNotifyCompactionTitle:"上下文压缩(compaction)提示",stNotifyCompactionDesc:"压缩时在对话里发一条说明",stNotifyRoutingTitle:"系统通知去向",stNotifyRoutingRight:"多平台逐个分发",stApprovalReminderNote:"审批提醒固定开启 — 阻塞线程时每 30 分钟重新提醒",stRecentNotifications:"最近通知",stRecentNotifRight:"仅运行时 · 无历史范围",stRecentNotifNote:"通知活动保存在 TUI 客户端的内存环形缓冲区中(上限 50,无文件持久化)——不经由任何 tRPC 读取范围暴露。Web UI 中无法查看实时历史;请使用 TUI 终端界面查看实时通知。",stAgentHooks:"已挂载钩子",stNoHooks:"暂无已挂载钩子",stHookEnabled:"已启用",stHookDisabled:"已停用",stHooksFootNote:"挂载状态来自 config/hooks 声明与线程模板生命周期钩子,来源分类与 cortex-hook list 完全一致。",hkFilterAll:"全部",hkFilterAgent:"智能体",hkFilterClaude:"Claude",hkFilterPi:"PI",hkFilterServer:"服务端",hkFilterTemplate:"模板",hkSearchPh:"搜索 id、事件、脚本…",hkNoMatch:"没有钩子符合当前筛选",hkSelectHint:"选择一个钩子以查看其声明",hkLoading:"正在加载钩子…",hkLoadFailed:"加载钩子失败:",hkCreate:"新建钩子",hkSecTrigger:"触发",hkSecAction:"动作",hkSecScope:"作用域",hkSecAdvanced:"高级",hkSecDeclaration:"声明",hkSecRegistry:"注册表",hkOrderNote:"order = 同一事件内的执行顺序",hkFieldId:"id",hkFieldEvent:"事件",hkFieldMatcher:"匹配式",hkFieldFilters:"过滤条件",hkFieldRun:"执行",hkFieldTemplate:"模板",hkFieldScript:"脚本",hkFieldCommand:"命令",hkFieldTimeout:"超时",hkFieldBackends:"后端",hkFieldRequiresTool:"需要工具",hkFieldResult:"结果",hkFieldSource:"来源",hkFieldFile:"文件",hkFieldOrder:"顺序",hkFieldBlocking:"阻塞",hkFieldVersion:"版本",hkFieldMountsOn:"挂载于",hkFieldAppliesAt:"生效时机",hkSeconds:"秒",hkUnscoped:"两者 — 由事件前缀推导",hkNoMatcher:"留空 — 匹配全部",hkMatcherRegexHint:"与工具名进行匹配的正则表达式",hkMatcherFiltersHint:"每个键都必须在负载中存在,且值完全相等",hkMatcherInvalid:"正则表达式无效",hkAddFilter:"添加过滤条件",hkRemoveFilter:"移除",hkFilterKeyPh:"键",hkFilterValuePh:"值",hkResultLocked:"该事件无法返回结果 — 加载器只接受 none。",hkAppliesNextAgent:"下次智能体启动时生效。",hkAppliesRestart:"事件总线在启动时快照注册表 — 需重启服务端后才会生效。",hkNoteManaged:"受管条目,随 Cortex 一同分发。此处只有启用开关可写,且后续的 hook sync 会把启用状态恢复为随附值。",hkNoteTemplate:"由线程模板文件拥有。请在「线程模板」区域编辑 — 本面板保持只读。",hkClaudeGap:"该 agent:* 事件在 Claude 侧没有挂载点,只会到达 PI。要挂到 Claude,请改用原生声明:",hkScriptMissing:"钩子目录中找不到该脚本 — 此钩子会静默失败。",hkBroken:"失效",hkDirty:"有未保存的更改",hkSave:"保存",hkRevert:"还原",hkDelete:"删除",hkConfirmDelete:"确认删除",hkCancelCreate:"放弃",hkTest:"测试",hkTestTitle:"测试运行",hkTestPayload:"负载 — 通过 stdin 传入的 JSON",hkTestRun:"运行",hkTestClose:"关闭",hkTestReset:"重置为样例",hkTestNoOutput:"无输出",hkTestBlockingWarn:"该钩子会阻塞等待 webhook 往返,并向消息平台发送卡片。测试运行上限为 15 秒,但可能会一直占满该上限。",hkPayloadInvalid:"负载不是合法 JSON",hkErrIdRequired:"必须填写 id",hkErrIdTaken:"该 id 已被其他声明占用",hkErrEventRequired:"必须填写事件",hkErrRunRequired:"脚本与命令必须且只能填写一个",hkErrTimeout:"超时必须是正数秒",hkErrFiltersEmptyKey:"过滤键不能为空",hkErrFiltersDuplicate:"过滤键必须唯一",hkErrResult:"该结果模式对此事件不合法",hkToastSaved:"钩子已保存",hkToastCreated:"钩子已创建",hkToastDeleted:"钩子已删除",hkToastEnabled:"钩子已启用",hkToastDisabled:"钩子已停用",hkToastWriteFailed:"钩子写入失败",hkToastTestFailed:"测试运行失败",stAdvConcNote:"自动 = max(4, cpus − 2) · 从 settings.json 热读取",stSet:"已设置",stAuto:"自动",stGpuMock:"GPU 模拟",stLoadingConfig:"正在加载配置…",stFailedLoadConfig:"加载配置失败:",stPolicyPauseTitle:"暂停并申请审批",stPolicyPauseDesc:"预估超限 → 审批(类别:超预算算力);批准后继续",stPolicyWarnTitle:"仅警告,继续运行",stPolicyWarnDesc:"向 admin 频道发一条警告,绝不阻塞",stPolicyStopTitle:"硬性停止",stPolicyStopDesc:"今日不再派发新任务;运行中的工作不受影响",stLimits:"限额",stDaily:"每日",stMonthly:"每月",stApply:"应用",stBudgetScope:"范围",stBudgetScopeGlobal:"全局",stBudgetScopeNote:"全局默认,或单个项目的独立限额",stBudgetInherited:"该项目没有独立限额,显示的是它当前继承的全局默认值。设置任一限额都会创建包含日额和月额的项目级覆盖。",stBudgetClear:"清除覆盖",stBudgetClearHint:"移除该项目的独立限额,恢复继承全局默认值。",stBudgetCustomPlaceholder:"自定义",stBudgetAmountInvalid:"请输入正数金额,例如 12.50",stWarnAt:"警告阈值",stOverBudgetBehavior:"超预算行为",stCurrentSpend:"当前支出",stObNote:"预估超限 → chat 审批卡 + 审批中心",stBudgetFootNote:"今日 / 本月为真实值(cost.summary,按所选范围过滤);每日/每月分母为真实值(budget.json,存在项目覆盖时用覆盖值)。预算仅供参考——服务端不会据此中止任何工作。",stNavAppearance:"外观",stNavPlatform:"平台",stNavAccounts:"账号",stNavProfiles:"配置",stNavBudget:"预算",stNavMachines:"机器",stNavTemplates:"线程模板",stNavMcp:"MCP 服务器",stNavNotifications:"通知",stNavHooks:"钩子",stNavAdvanced:"高级",stMetaAppearanceSub:"语言与主题 — 界面语言与浅色/深色。即时生效,并记住在本设备上。",stMetaPlatformSub:"config/.env — 守护进程启动时加载一次;唯一需要重启的配置",stMetaAccountsSub:"Claude Code 凭据与 auth.status 返回的全部 PI provider",stMetaProfilesSub:"config/profiles.json — 每次 agent 启动时读取,无需重启",stMetaBudgetSub:"config/budget.json — 热读取,即时生效;升级永不覆盖(仅 --force)",stMetaMachinesSub:"config/machines.json — fs.watch 热重载;启动时通过 SSH 自动拉起客户端",stMetaTemplatesSub:"config/thread-templates/ — 保存时校验,无需重启即热重载",stMetaMcpSub:"config/mcp-config.json — 根据运行时模式选择 full / core / tui 变体",stMetaNotificationsSub:"config/settings.json — 实时通知控制与多平台路由",stMetaHooksSub:"注册表与模板作用域的已挂载钩子 — 当前事件、启用状态与来源",stMetaAdvancedSub:"settings.json 运行时开关;DEBUG 仍只读显示进程环境状态",stThemeLabel:"主题",stThemeLight:"浅色",stThemeDark:"深色",stThemeHint:"两种模式的配色都遵循 Cortex 设计系统;选择保存在本设备上。",stLangLabel:"语言",stLangHint:"工作台的界面语言。即时生效,并保存在本设备上。",stLangEnglish:"English",stLangChinese:"中文",stBudgetWriteError:"无法写入预算 — 日额和月额都必须为正数(项目覆盖必须成对设置)",stCostsJsonlLabel:"costs.jsonl · 90天",stEsc:"esc",stWinOs:"windows",stUnixOs:"unix",stAddMachinePrompt:"要请求添加的机器名称(排队审批,不会直接添加):",stMachineFieldsHint:"name · cortexPath · gpuCount · ssh · win · clientCommand",stToastQueuedApproval:"已排队等待审批 — 请在审批中心查看",stToastWriteFailed:"写入失败",stToastCouldNotQueue:"无法排队请求",stToastBudgetWritten:"budget.json 已写入",stToastBudgetCleared:"覆盖已移除 — 恢复继承全局限额",stToastDefaultProfile:"profiles.json 已写入",stReconnectApprovalTitle:"将重连请求排队等待审批 — 绝不直接从浏览器执行",stReconnectInertTitle:"无重连后端操作 — 占位",stAddMachineApprovalTitle:"将添加机器请求排队等待审批 — 绝不直接写入 machines.json",stAddMachineInertTitle:"写入 machines.json — 无 add-machine 后端操作(表单不在范围内)",ttEditorTitle:"Thread 模板",ttNew:"新建",ttSearchPh:"搜索名称或描述",ttFilterAll:"全部",ttFilterTemplate:"模板",ttFilterAgent:"agent",ttFilterShell:"shell",ttNoMatch:"没有匹配的条目",ttSelectPrompt:"选择一个条目以查看或编辑",ttTabBody:"内容",ttTabValidation:"校验",ttTabReferences:"引用",ttOriginStock:"原版",ttOriginModified:"已改",ttOriginCustom:"自建",ttOriginStockTitle:"与内置默认完全一致",ttOriginModifiedTitle:"与内置默认不同 — 不再接收上游更新",ttOriginCustomTitle:"没有同名的内置默认",ttSave:"保存",ttSaveConfirm:"仍然保存",ttRevert:"还原",ttValidate:"校验",ttDelete:"删除",ttDeleteConfirm:"确认删除",ttDuplicate:"复制",ttCancel:"取消",ttFormat:"格式化",ttNameLabel:"名称",ttKindLabel:"类型",ttNamePh:"小写字母与连字符",ttNoErrors:"没有错误",ttNoWarnings:"没有警告",ttErrors:"错误",ttWarnings:"警告",ttErrorsBlock:"错误会阻止保存,警告不会。",ttUsedBy:"被这些模板引用",ttUsedByNone:"没有模板引用它",ttRunningThreads:"正在运行的 thread",ttReferencingTasks:"引用它的未完成任务",ttFilePath:"文件",ttExpanded:"展开后的图",ttExpandedNote:"这个模板绑定了一个 shell。下面是它在加载时展开成的 transition 图。",ttRunningWarn:"个 thread 正跑在这个模板上。transition 每一步都会重新读取,现在保存可能让它们改道或卡住。",ttForkWarn:"这个文件与内置默认一致。保存会把它分叉 — 之后不再接收上游更新。",ttDeleteBlockedDependents:"还有别的模板引用它,无法删除",ttDeleteBlockedRunning:"还有 thread 跑在上面,无法删除",ttHintParse:"内容不是合法 JSON",ttHintClean:"没有改动可保存",ttHintName:"请输入合法名称",ttToastSaved:"已保存",ttToastDeleted:"已删除",ttToastValid:"校验通过 — 没有错误",ttToastInvalid:"校验未通过",ttToastWriteFailed:"写入失败",ttToastConflict:"加载后磁盘上已被改动 — 请重新加载再保存",ttInvalidBadge:"有错",ttFootNote:"文件位于 config/thread-templates/。文件名即身份;改名请用复制再删除。该目录已纳入 git,git 就是撤销。",stAdvDebugTitle:"调试日志",stAdvDebugDesc:"详细输出写入 daemon.log",stAdvEventLogTitle:"事件总线日志",stAdvEventLogDesc:"记录每条事件总线消息",stAdvDiskMonitorTitle:"磁盘空间监控",stAdvDiskMonitorDesc:"检查 Cortex 数据目录所在文件系统,低于 500 MB 时告警",stAdvToolCallsTitle:"内联工具调用渲染",stAdvToolCallsDesc:"在消息尾部渲染工具调用",stAdvDisableUserTitle:"禁用 USER.md 注入",stAdvDisableUserDesc:"直接对话默认注入;线程步骤始终不注入",stAdvDisableUpdateTitle:"禁用自动更新检查",stAdvDisableUpdateDesc:"更新检查默认开启",npProjectName:"项目名称",npHint:"将创建 context/projects/<name>/ —— 其余交给 agent 处理",npCreate:"创建 →",cpNoResults:"无结果",cpFooterHint:"↑↓ 导航 · ⏎ 打开 · esc 关闭",cpSubOverview:"项目仪表盘",cpSubWorkbench:"会话对话",cpSubTasks:"任务队列",cpSubThreads:"线程运行",cpSubSettings:"平台 · 配置 · 预算 · 机器…",skTitle:"技能",skScanning:"扫描中…",skLoadError:"无法加载技能",skLoadingBody:"正在加载技能…",skFailedBody:"加载技能失败。agent-server 在运行吗?",skEmpty:"未找到技能。请在 DATA_DIR/.claude/skills/ 或 plugins/ 下添加技能目录。",skUserSkills:"用户技能",shNothingHere:"这里还什么都没有",apPending:"待审批",apFrom:"来自",apTask:"任务",apProject:"项目",apOperation:"操作",apReason:"原因",apImpact:"影响",apCommand:"命令",apFeedbackLabel:"反馈",apFeedbackPh:"原因 — 将回传给 agent…",apFootNote:"决定后 → PENDING_APPROVALS.md 翻转 · chat 卡片保持同步",apToastApproved:"已批准 — PENDING_APPROVALS.md 已更新",apToastRejected:"已拒绝 — 原因已回传给 agent",scNewSchedule:"新建调度",scType:"类型",scTypeInterval:"间隔",scTypeDaily:"每日",scTypeWeekly:"每周",scTypeOnce:"单次",scTime:"时间",scEvery:"每",scIn:"延迟",scDay:"星期",scProfile:"配置",scMessage:"消息",scMessagePh:"检查所有机器的 GPU 状态并发一句话摘要。",scTarget:"目标",scFallback:"回退",scNextRun:"下次运行",scFooterIn:"还有",scCreateSchedule:"创建调度",scDaySun:"周日",scDayMon:"周一",scDayTue:"周二",scDayWed:"周三",scDayThu:"周四",scDayFri:"周五",scDaySat:"周六",scToastCreated:"调度已创建",scToastCreateFailed:"无法创建调度",scEditSchedule:"编辑调度",scSaveSchedule:"保存修改",scToastUpdated:"调度已更新",scToastUpdateFailed:"无法更新调度",memMemory:"记忆",memLoading:"加载中…",memNoFiles:"暂无记忆文件。",memDiffUnavailable:"差异元数据不可用",memLinesChanged:"行相较 HEAD 变更(git numstat)。",memBlameNote:"下方每一行都标注了其真实的最后改动提交哈希与任务引用(git blame);当该提交不携带任务标签时,任务引用为空。",memBlameUnavailable:"逐行 blame 不可用——该项目目录不是 git 工作树(或 git 不可用),因此不显示提交哈希 / 任务引用。下方为文件当前内容。",memLoadingFile:"正在加载文件…",memReadError:"无法读取此文件。",memSelectFile:"选择一个文件查看。",memSummary:"摘要",thArtifact:"线程产物",thLive:"实时",thNoArtifact:"暂无产物",thOwner:"归属",thReferences:"引用",thWrittenBy:"编写者",thWorkspace:"工作区",thTask:"任务",thProject:"项目",thFailedLoadThread:"加载线程失败",thTemplate:"模板",thStarted:"开始于",thElapsed:"已用时",thCostInclChildren:"成本(含子线程)",thPipeline:"流水线",thOpenSub:"打开",thAgentLabel:"智能体",thAgentSection:"智能体",thSubThreads:"子线程",thStepNoSession:"尚未开始 · 无会话",thStepLoading:"加载对话中…",thStepEmpty:"暂无消息",exLogTitle:"执行日志",exAlreadyFinished:"已结束",exKilled:"已终止",exWaitingOutput:"等待输出…",exNoLiveLog:"无实时日志——该执行不是 cortex-run 启动",exNoLogOutput:"无日志输出",exLinesDropped:"行日志被丢弃",exFooterHeartbeat:"心跳 30s · 丢失 0 · → costs.jsonl",exKillRun:"终止运行",authLoginTitle:"Backend 登录",authLoginIntro:"选择 backend、provider 与认证类型。",authLoginBackend:"Backend",authLoginType:"认证类型",authLoginApiKey:"API key",authLoginOAuth:"OAuth",authLoginSubscription:"订阅(OAuth)",authLoginProvider:"Provider",authLoginStart:"开始登录",authLoginAgain:"重新登录",noticeCancelResume:"不要自动续跑",noticeCancelResumeDone:"已取消续跑",authLoginSubmit:"提交",authLoginClose:"关闭",authLoginRunning:"正在启动登录…",authLoginSecretPrompt:"输入 API key。它不会进入聊天消息或 transcript。",authLoginOpenLink:"打开链接",authLoginOpenAuthorization:"打开授权页面",authLoginOpenVerification:"打开验证页面",authLoginExpiresIn:"{seconds} 秒后过期。",authLoginDone:"登录完成",authLoginDoneSummary:"已登录 {provider}。",authLoginFailed:"登录失败",authLoginUnknownFailure:"登录流程失败。",authLoginExpired:"此登录流程已过期或不再可用。",authLoginAlreadyActive:"另一个界面已有进行中的登录流程。",authLoginCancelled:"登录已取消",authLoginCancelledSummary:"未提交凭据。",accountsTitle:"账号",accountsSource:"来源",accountsExpires:"过期时间",accountsInUse:"使用中",accountsPiProviders:"PI Provider",accountsLogin:"登录",accountsLogout:"登出",accountsFilter:"筛选 Provider",accountsFilterPlaceholder:"按 Provider 名称筛选…",accountsNoProviders:"没有符合筛选条件的 Provider。",accountsStatusLoggedIn:"已登录",accountsStatusExpiring:"快过期",accountsStatusLoggedOut:"未登录",accountsStatusInvalid:"失效",accountsGroupInUse:"使用中",accountsGroupLoggedIn:"已登录",accountsGroupOther:"其他",accountsConnectedMark:"✓",accountsDisconnected:"未登录",accountsPiSummary:"PI 已登录 {count}",accountsLoading:"正在加载账号…",accountsLoadFailed:"无法加载账号状态。",accountsLogoutDone:"已登出",accountsLogoutFailed:"登出失败",cpvTitle:"自定义 Provider",cpvSubtitle:"自建或代理的推理端点,统一经网关路由",cpvNew:"新建 Provider",cpvEdit:"编辑",cpvDelete:"删除",cpvConfirmDelete:"确认删除",cpvSave:"保存",cpvCancel:"取消",cpvCreateTitle:"新建自定义 Provider",cpvEditTitle:"编辑自定义 Provider",cpvFieldName:"名称",cpvFieldApi:"协议",cpvFieldUrl:"上游地址",cpvFieldKey:"密钥",cpvFieldModels:"模型",cpvNameHint:"仅限字母、数字、- 和 _",cpvNoRename:"名称不可修改——profile 绑定在它上面。请新建一个再删除这条。",cpvApiHint:"端点使用的请求协议",cpvUrlHint:"真实端点地址,保存在网关路由里,不写进 PI",cpvKeyHint:"只保存在网关。留空表示沿用已存的密钥。",cpvKeyPlaceholder:"保持不变",cpvModelsHint:"每行一个模型 id",cpvNone:"尚未定义任何自定义 Provider。",cpvUnrouted:"没有网关路由",cpvKeyStored:"已存密钥",cpvNoKey:"无密钥",cpvErrNameRequired:"必须填写名称",cpvErrNameCharset:"只能使用字母、数字、- 和 _",cpvErrNameTaken:"这个名称已被占用",cpvErrUpstreamRequired:"必须填写上游地址",cpvErrUpstreamScheme:"地址必须以 http:// 或 https:// 开头",cpvErrModelsRequired:"至少填写一个模型 id",cpvErrModelsDuplicate:"模型 id 不能重复",cpvToastSaved:"Provider 已保存",cpvToastDeleted:"Provider 已删除",cpvToastFailed:"写入失败"};function uC(e){return e==="zh"?uA:dA}const pC="cortex.lang",fC="en";function pA(e,t){return e==="en"||e==="zh"?e:t&&t.toLowerCase().startsWith("zh")?"zh":fC}function hC(){if(typeof window>"u")return fC;let e=null;try{e=window.localStorage.getItem(pC)}catch{}return pA(e,typeof navigator<"u"?navigator.language:void 0)}function fA(e){if(!(typeof window>"u"))try{window.localStorage.setItem(pC,e)}catch{}}const w0=f.createContext(null);function hA({children:e}){const[t,n]=f.useState(hC),r=Pf(),i=f.useCallback(a=>{n(a),fA(a)},[]),s=f.useMemo(()=>({lang:t,vocab:uC(t),isMobile:r,setLang:i}),[t,r,i]);return o.jsx(w0.Provider,{value:s,children:e})}function qf(){const e=f.useContext(w0);if(!e)throw new Error("useLang must be used within <LangProvider>");return e}function ft(){return qf().lang}function gC(){return qf().setLang}function B(){return qf().vocab}function gA(){const e=f.useContext(w0);return(e==null?void 0:e.vocab)??uC(hC())}function xA(){return qf().isMobile}const xC="cortex.theme",mC="light";function mA(e,t){return e==="light"||e==="dark"?e:t?"dark":mC}function vA(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia("(prefers-color-scheme: dark)").matches}catch{return!1}}function yA(){if(typeof window>"u")return mC;let e=null;try{e=window.localStorage.getItem(xC)}catch{}return mA(e,vA())}function qb(e){if(!(typeof window>"u"))try{window.localStorage.setItem(xC,e)}catch{}}function ig(e){if(typeof document>"u")return;const t=document.documentElement;e==="dark"?t.setAttribute("data-theme","dark"):t.removeAttribute("data-theme"),t.style.colorScheme=e}const vC=f.createContext(null);function bA({children:e}){const[t,n]=f.useState(yA);f.useEffect(()=>{ig(t)},[t]);const r=f.useCallback(a=>{n(a),qb(a),ig(a)},[]),i=f.useCallback(()=>{n(a=>{const l=a==="dark"?"light":"dark";return qb(l),ig(l),l})},[]),s=f.useMemo(()=>({theme:t,setTheme:r,toggleTheme:i}),[t,r,i]);return o.jsx(vC.Provider,{value:s,children:e})}function yC(){const e=f.useContext(vC);if(!e)throw new Error("useTheme must be used within <ThemeProvider>");return e}function k0(){return yC().theme}function S0(){return yC().setTheme}function jA(e){return e==="secret"||e==="manual_code"?"password":e==="select"?"select":"text"}function wA(e,t){const n=e.pendingPrompt,r=n.kind==="secret"?t.authLoginSecretPrompt:n.message;return{kind:"prompt",title:t.authLoginTitle,message:r,inputType:jA(n.kind),options:n.options??[],notice:e.notice,terminal:!1}}function kA(e){return e.kind==="auth_url"?e.instructions??e.url:e.kind==="device_code"?e.userCode:e.message}function SA(e,t){var r;const n=((r=e.outcome)==null?void 0:r.provider)??e.provider??"";if(e.step==="done")return{kind:"done",title:t.authLoginDone,message:t.authLoginDoneSummary.replace("{provider}",n),inputType:null,options:[],notice:e.notice,terminal:!0};if(e.step==="failed"){const i=e.errorCode==="flow_not_found"?t.authLoginExpired:t.authLoginUnknownFailure;return{kind:"failed",title:t.authLoginFailed,message:e.error??i,inputType:null,options:[],notice:e.notice,terminal:!0}}return{kind:"cancelled",title:t.authLoginCancelled,message:t.authLoginCancelledSummary,inputType:null,options:[],notice:e.notice,terminal:!0}}function CA(e,t){return e?e.step==="prompt"&&e.pendingPrompt?wA(e,t):e.step==="done"||e.step==="failed"||e.step==="cancelled"?SA(e,t):e.notice?{kind:"notice",title:t.authLoginTitle,message:kA(e.notice),inputType:null,options:[],notice:e.notice,terminal:!1}:{kind:"running",title:t.authLoginTitle,message:t.authLoginRunning,inputType:null,options:[],notice:null,terminal:!1}:{kind:"selection",title:t.authLoginTitle,message:t.authLoginIntro,inputType:null,options:[],notice:null,terminal:!1}}const TA=500,EA=new Set(["done","failed","cancelled"]);function Xp(e){return!!e&&EA.has(e.step)}function RA(e){return{...e,step:"failed",pendingPrompt:null,notice:null,outcome:null,error:null,errorCode:"flow_not_found"}}function PA(e,t,n){return e?Xp(e)&&!Xp(t)?!0:n&&e.step==="running"&&t.step==="prompt":!1}function C0({href:e,children:t}){return o.jsx("a",{href:e,target:"_blank",rel:"noreferrer",className:"text-state-run underline",children:t})}function IA({notice:e,L:t}){return o.jsxs("div",{"data-auth-notice":"info",className:"space-y-1g",children:[o.jsx("p",{children:e.message}),(e.links??[]).map(n=>o.jsx(C0,{href:n.url,children:n.label??t.authLoginOpenLink},n.url))]})}function MA({notice:e,L:t}){return o.jsxs("div",{"data-auth-notice":"auth_url",className:"space-y-1g",children:[e.instructions?o.jsx("p",{children:e.instructions}):null,o.jsx(C0,{href:e.url,children:t.authLoginOpenAuthorization})]})}function LA({notice:e,L:t}){const n=e.expiresInSeconds===void 0?null:t.authLoginExpiresIn.replace("{seconds}",String(e.expiresInSeconds));return o.jsxs("div",{"data-auth-notice":"device_code",className:"space-y-1g",children:[o.jsx("div",{"data-auth-device-code":!0,className:"font-mono text-xl font-semibold tracking-wider text-state-ink",children:e.userCode}),o.jsxs("div",{className:"space-y-1g",children:[o.jsx("p",{children:t.authLoginOpenVerification}),o.jsx(C0,{href:e.verificationUri,children:e.verificationUri})]}),n?o.jsx("p",{className:"text-caption text-state-muted",children:n}):null]})}function OA({state:e}){const t=B(),n=e.notice;return n?n.kind==="info"?o.jsx(IA,{notice:n,L:t}):n.kind==="auth_url"?o.jsx(MA,{notice:n,L:t}):n.kind==="device_code"?o.jsx(LA,{notice:n,L:t}):o.jsx("div",{"data-auth-notice":"progress","data-auth-progress":!0,className:"text-state-run",role:"status",children:n.message}):null}function DA({state:e,value:t,onChange:n}){var r;return o.jsxs("select",{"data-auth-secret":!0,"aria-labelledby":"auth-login-prompt-label",value:t,onChange:i=>n(i.target.value),className:"w-full rounded-card border border-card bg-surface-card px-2g py-1g text-ui",children:[o.jsx("option",{value:""}),(((r=e.pendingPrompt)==null?void 0:r.options)??[]).map(i=>o.jsx("option",{value:i.id,children:i.label},i.id))]})}function AA({state:e,value:t,onChange:n}){const r=e.pendingPrompt;if(!r)return null;if(r.kind==="select")return o.jsx(DA,{state:e,value:t,onChange:n});const i=r.kind==="secret"||r.kind==="manual_code"?"password":"text";return o.jsx("input",{"data-auth-secret":!0,"aria-labelledby":"auth-login-prompt-label",type:i,value:t,autoComplete:"off",onChange:s=>n(s.target.value),className:"w-full rounded-card border border-card bg-surface-card px-2g py-1g text-ui"})}function NA({controller:e}){const t=B();return o.jsxs("div",{className:"space-y-2g",children:[o.jsxs("label",{className:"block space-y-1g text-ui",children:[o.jsx("span",{children:t.authLoginBackend}),o.jsxs("select",{"data-auth-backend":!0,value:e.backend,onChange:n=>e.chooseBackend(n.target.value),className:"w-full rounded-card border border-card bg-surface-card px-2g py-1g",children:[o.jsx("option",{value:"claude",children:"Claude Code"}),o.jsx("option",{value:"pi",children:"PI"})]})]}),e.backend==="pi"?o.jsx(_A,{controller:e}):null,e.authTypes.length>1?o.jsx($A,{controller:e}):null]})}function $A({controller:e}){const t=B();return o.jsxs("label",{className:"block space-y-1g text-ui",children:[o.jsx("span",{children:t.authLoginType}),o.jsx("select",{"data-auth-type":!0,value:e.authType,onChange:n=>e.chooseAuthType(n.target.value),className:"w-full rounded-card border border-card bg-surface-card px-2g py-1g",children:e.authTypes.map(n=>o.jsx("option",{value:n,children:n==="api_key"?t.authLoginApiKey:e.backend==="claude"?t.authLoginSubscription:t.authLoginOAuth},n))})]})}function _A({controller:e}){const t=B();return o.jsxs("label",{className:"block space-y-1g text-ui",children:[o.jsx("span",{children:t.authLoginProvider}),o.jsx("select",{"data-auth-provider":!0,value:e.provider,onChange:n=>e.chooseProvider(n.target.value),className:"w-full rounded-card border border-card bg-surface-card px-2g py-1g",children:e.providers.map(n=>o.jsx("option",{value:n.provider,children:n.label},n.provider))})]})}function FA(e){return e.filter(t=>t.backend==="pi"&&t.capabilities.length>0).map(t=>({provider:t.provider,label:t.label,capabilities:t.capabilities}))}function zA(e,t,n,r){const i=n==="claude"?e.find(s=>s.backend==="claude"&&s.provider===r):t.find(s=>s.provider===r);return(i==null?void 0:i.capabilities)??[]}function BA(e,t,n,r,i){f.useEffect(()=>{!e||!t||(n(t.backend),r(t.provider),i(t.authType))},[e,t,n,r,i])}function WA(e,t,n,r,i,s,a){f.useEffect(()=>{var l;e==="pi"&&n.length>0&&!n.some(c=>c.provider===t)&&s(((l=n[0])==null?void 0:l.provider)??"")},[e,t,n,s]),f.useEffect(()=>{!i.includes(r)&&i[0]&&a(i[0])},[r,i,a])}function UA(e,t){var v;const n=ae(),[r,i]=f.useState("claude"),[s,a]=f.useState("api_key"),[l,c]=f.useState("anthropic"),u=((v=G({...n.auth.status.queryOptions({}),enabled:e}).data)==null?void 0:v.accounts)??[],p=f.useMemo(()=>FA(u),[u]),h=zA(u,p,r,l);return BA(e,t,i,c,a),WA(r,l,p,s,h,c,a),{backend:r,authType:s,authTypes:h,provider:l,providers:p,chooseBackend:x=>{var w;i(x),c(x==="claude"?"anthropic":((w=p[0])==null?void 0:w.provider)??"")},chooseProvider:c,chooseAuthType:a,...t?{noticeId:t.noticeId}:{}}}function HA(e,t,n,r,i){const s=ae(),a=je(),l=G({...s.auth.flowState.queryOptions({flowId:t??""}),enabled:e&&!!t,refetchInterval:e&&t&&!Xp(n)?TA:!1});f.useEffect(()=>{l.data&&!PA(n,l.data,r)?i(l.data):!l.data&&l.isSuccess&&t&&n&&!Xp(n)&&i(RA(n))},[l.data,l.isSuccess,t,n,r,i]),f.useEffect(()=>{(n==null?void 0:n.step)==="done"&&a.invalidateQueries(s.auth.status.queryFilter({}))},[n==null?void 0:n.step,a,s.auth.status])}function T0(e,t,n){const r=e instanceof Error?e.message:String(e);return r==="Login flow not found or expired."?t:r.includes("active on another surface")?n:r}function cl(e,t){return e.generation.current===t}async function qA(e,t){const n=++t.generation.current;t.setError(null),t.setResponseSent(!1);try{const r=await e.auth.startLogin.mutate({backend:t.selection.backend,provider:t.selection.provider,authType:t.selection.authType,...t.selection.noticeId?{noticeId:t.selection.noticeId}:{}});if(!cl(t,n))return;t.setFlowId(r.flowId),t.setLatest(r),t.setResponse("")}catch(r){cl(t,n)&&t.setError(T0(r,t.expiredMessage,t.conflictMessage))}}async function VA(e,t){if(!t.flowId||!t.response)return;const n=t.generation.current,r=t.response;t.setResponse(""),t.setResponseSent(!0),t.setError(null);try{const i=await e.auth.respondPrompt.mutate({flowId:t.flowId,value:r});cl(t,n)&&t.setLatest(i)}catch(i){cl(t,n)&&t.setError(T0(i,t.expiredMessage,t.conflictMessage))}}async function KA(e,t){if(!t.flowId)return;const n=++t.generation.current;try{const r=await e.auth.cancelFlow.mutate({flowId:t.flowId});cl(t,n)&&t.setLatest(r)}catch(r){cl(t,n)&&t.setError(T0(r,t.expiredMessage,t.conflictMessage))}}function QA(e){const t=Rf();return{start:()=>qA(t,e),submit:()=>VA(t,e),cancel:()=>KA(t,e)}}function GA(e,t){return e.backend===t.backend&&e.provider===t.provider&&e.authType===t.authType}function bC(e){return e.noticeId??`settings:${e.backend}:${e.provider}:${e.authType}`}function YA(e,t,n,r){f.useEffect(()=>{r.generation.current+=1,r.setFlowId(e&&n?n.flowId:null),r.setLatest(e?n??null:null),r.setResponse(""),r.setResponseSent(!1),r.setError(null),r.autoStarted.current=n&&t?bC(t):null},[e,t,n])}function XA(e,t,n,r,i,s){f.useEffect(()=>{if(!e||!t||n||!r.canStart||!i)return;const a=bC(t);s.current!==a&&(s.current=a,r.start())},[e,t,n,r.canStart,r.start,i,s])}function JA(e,t,n,r){const i=B(),s=UA(e,t),[a,l]=f.useState(null),[c,d]=f.useState(null),[u,p]=f.useState(""),[h,g]=f.useState(!1),[v,x]=f.useState(null),w=f.useRef(0),b=f.useRef(null);HA(e,a,c,h,d);const y=QA({selection:s,flowId:a,response:u,generation:w,setFlowId:l,setLatest:d,setResponse:p,setResponseSent:g,setError:x,expiredMessage:i.authLoginExpired,conflictMessage:i.authLoginAlreadyActive}),j=!!s.provider&&s.authTypes.includes(s.authType);return YA(e,t,n,{generation:w,autoStarted:b,setFlowId:l,setLatest:d,setResponse:p,setResponseSent:g,setError:x}),XA(e,t,n,{canStart:j,start:y.start},!!t&&GA(s,t),b),f.useEffect(()=>{c&&(r==null||r(c))},[c,r]),{...s,latest:c,response:u,error:v,canCancel:!h,canStart:j,setResponse:p,...y}}function ZA(e,t){return t.kind==="selection"?o.jsxs("div",{className:"space-y-2g",children:[o.jsx(NA,{controller:e}),e.error?o.jsx("p",{role:"alert",className:"text-state-fail",children:e.error}):null]}):o.jsxs("div",{className:"space-y-2g","data-auth-flow-step":t.kind,children:[t.kind==="notice"?null:o.jsx("p",{id:t.kind==="prompt"?"auth-login-prompt-label":void 0,children:t.message}),e.error?o.jsx("p",{role:"alert",className:"text-state-fail",children:e.error}):null,e.latest?o.jsx(OA,{state:e.latest}):null,e.latest?o.jsx(AA,{state:e.latest,value:e.response,onChange:e.setResponse}):null]})}function eN(e,t,n,r){return t.kind==="selection"?o.jsx(jt,{"data-action":"auth-start",variant:"primary",disabled:!e.canStart,onClick:e.start,children:r.authLoginStart}):t.kind==="prompt"?o.jsxs(o.Fragment,{children:[e.canCancel?o.jsx(jt,{"data-action":"auth-cancel",onClick:e.cancel,children:r.cancel}):null,o.jsx(jt,{"data-action":"auth-submit",variant:"primary",disabled:!e.response,onClick:e.submit,children:r.authLoginSubmit})]}):t.terminal?o.jsx(jt,{"data-action":"auth-close",onClick:n,children:r.authLoginClose}):e.canCancel?o.jsx(jt,{"data-action":"auth-cancel",onClick:e.cancel,children:r.cancel}):null}function tN({open:e,onClose:t,target:n,initialState:r,onFlowStateChange:i}){const s=B(),a=JA(e,n,r,i),l=CA(a.latest,s);return o.jsx(Wf,{open:e,onOpenChange:c=>{c||t()},title:l.title,description:l.message,footer:eN(a,l,t,s),children:ZA(a,l)})}const jC=f.createContext(null);function nN({children:e}){const[t,n]=f.useState(!1),[r,i]=f.useState({target:null,initialState:null}),s=f.useRef(new Map),a=f.useCallback(u=>{i({target:u??null,initialState:u!=null&&u.noticeId?s.current.get(u.noticeId)??null:null}),n(!0)},[]),l=f.useCallback(()=>n(!1),[]),c=f.useCallback(u=>{var p;(p=r.target)!=null&&p.noticeId&&s.current.set(r.target.noticeId,u)},[r.target]),d=f.useMemo(()=>({openLogin:a,closeLogin:l}),[a,l]);return o.jsxs(jC.Provider,{value:d,children:[e,o.jsx(tN,{open:t,onClose:l,target:r.target,initialState:r.initialState,onFlowStateChange:c})]})}function wC(){return f.useContext(jC)}function E0(){const e=wC();if(!e)throw new Error("useLoginFlow must be used within LoginFlowProvider");return e}const rN=2e3,oN=20;function iN(){const[e,t]=f.useState(()=>{const n=Hp();return{config:n,done:!!n||!on()}});return f.useEffect(()=>{if(e.done)return;let n=!1;const r=Date.now(),i=setInterval(()=>{const s=Hp();s?(n||t({config:s,done:!0}),clearInterval(i)):Date.now()-r>=rN&&(n||t({config:void 0,done:!0}),clearInterval(i))},oN);return()=>{n=!0,clearInterval(i)}},[e.done]),e}function sN({children:e}){const[t]=f.useState(()=>new K8),{config:n,done:r}=iN(),i=f.useMemo(()=>dM(n),[n]);return r?o.jsx(Q8,{client:t,children:o.jsx(sM,{trpcClient:i,queryClient:t,children:o.jsx(bA,{children:o.jsx(oO,{children:o.jsx(lA,{children:o.jsx(hA,{children:o.jsx(nN,{children:e})})})})})})}):null}/**
|
|
90
|
+
* @remix-run/router v1.23.3
|
|
91
|
+
*
|
|
92
|
+
* Copyright (c) Remix Software Inc.
|
|
93
|
+
*
|
|
94
|
+
* This source code is licensed under the MIT license found in the
|
|
95
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
96
|
+
*
|
|
97
|
+
* @license MIT
|
|
98
|
+
*/function it(){return it=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},it.apply(null,arguments)}var kt;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(kt||(kt={}));const Vb="popstate";function aN(e){e===void 0&&(e={});function t(r,i){let{pathname:s,search:a,hash:l}=r.location;return dl("",{pathname:s,search:a,hash:l},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:Pl(i)}return kC(t,n,null,e)}function lN(e){e===void 0&&(e={});function t(i,s){let{pathname:a="/",search:l="",hash:c=""}=Po(i.location.hash.substr(1));return!a.startsWith("/")&&!a.startsWith(".")&&(a="/"+a),dl("",{pathname:a,search:l,hash:c},s.state&&s.state.usr||null,s.state&&s.state.key||"default")}function n(i,s){let a=i.document.querySelector("base"),l="";if(a&&a.getAttribute("href")){let c=i.location.href,d=c.indexOf("#");l=d===-1?c:c.slice(0,d)}return l+"#"+(typeof s=="string"?s:Pl(s))}function r(i,s){Ci(i.pathname.charAt(0)==="/","relative pathnames are not supported in hash history.push("+JSON.stringify(s)+")")}return kC(t,n,r,e)}function Ie(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ci(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function cN(){return Math.random().toString(36).substr(2,8)}function Kb(e,t){return{usr:e.state,key:e.key,idx:t}}function dl(e,t,n,r){return n===void 0&&(n=null),it({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?Po(t):t,{state:n,key:t&&t.key||r||cN()})}function Pl(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function Po(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function kC(e,t,n,r){r===void 0&&(r={});let{window:i=document.defaultView,v5Compat:s=!1}=r,a=i.history,l=kt.Pop,c=null,d=u();d==null&&(d=0,a.replaceState(it({},a.state,{idx:d}),""));function u(){return(a.state||{idx:null}).idx}function p(){l=kt.Pop;let w=u(),b=w==null?null:w-d;d=w,c&&c({action:l,location:x.location,delta:b})}function h(w,b){l=kt.Push;let y=dl(x.location,w,b);n&&n(y,w),d=u()+1;let j=Kb(y,d),S=x.createHref(y);try{a.pushState(j,"",S)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;i.location.assign(S)}s&&c&&c({action:l,location:x.location,delta:1})}function g(w,b){l=kt.Replace;let y=dl(x.location,w,b);n&&n(y,w),d=u();let j=Kb(y,d),S=x.createHref(y);a.replaceState(j,"",S),s&&c&&c({action:l,location:x.location,delta:0})}function v(w){let b=i.location.origin!=="null"?i.location.origin:i.location.href,y=typeof w=="string"?w:Pl(w);return y=y.replace(/ $/,"%20"),Ie(b,"No window.location.(origin|href) available to create URL for href: "+y),new URL(y,b)}let x={get action(){return l},get location(){return e(i,a)},listen(w){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(Vb,p),c=w,()=>{i.removeEventListener(Vb,p),c=null}},createHref(w){return t(i,w)},createURL:v,encodeLocation(w){let b=v(w);return{pathname:b.pathname,search:b.search,hash:b.hash}},push:h,replace:g,go(w){return a.go(w)}};return x}var Ue;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(Ue||(Ue={}));const dN=new Set(["lazy","caseSensitive","path","id","index","children"]);function uN(e){return e.index===!0}function Jp(e,t,n,r){return n===void 0&&(n=[]),r===void 0&&(r={}),e.map((i,s)=>{let a=[...n,String(s)],l=typeof i.id=="string"?i.id:a.join("-");if(Ie(i.index!==!0||!i.children,"Cannot specify children on an index route"),Ie(!r[l],'Found a route id collision on id "'+l+`". Route id's must be globally unique within Data Router usages`),uN(i)){let c=it({},i,t(i),{id:l});return r[l]=c,c}else{let c=it({},i,t(i),{id:l,children:void 0});return r[l]=c,i.children&&(c.children=Jp(i.children,t,a,r)),c}})}function ts(e,t,n){return n===void 0&&(n="/"),up(e,t,n,!1)}function up(e,t,n,r){let i=typeof t=="string"?Po(t):t,s=Dd(i.pathname||"/",n);if(s==null)return null;let a=SC(e);fN(a);let l=null,c=SN(s);for(let d=0;l==null&&d<a.length;++d)l=wN(a[d],c,r);return l}function pN(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],handle:n.handle}}function SC(e,t,n,r){t===void 0&&(t=[]),n===void 0&&(n=[]),r===void 0&&(r="");let i=(s,a,l)=>{let c={relativePath:l===void 0?s.path||"":l,caseSensitive:s.caseSensitive===!0,childrenIndex:a,route:s};c.relativePath.startsWith("/")&&(Ie(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 d=vi([r,c.relativePath]),u=n.concat(c);s.children&&s.children.length>0&&(Ie(s.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+d+'".')),SC(s.children,t,u,d)),!(s.path==null&&!s.index)&&t.push({path:d,score:bN(d,s.index),routesMeta:u})};return e.forEach((s,a)=>{var l;if(s.path===""||!((l=s.path)!=null&&l.includes("?")))i(s,a);else for(let c of CC(s.path))i(s,a,c)}),t}function CC(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,i=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return i?[s,""]:[s];let a=CC(r.join("/")),l=[];return l.push(...a.map(c=>c===""?s:[s,c].join("/"))),i&&l.push(...a),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function fN(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:jN(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const hN=/^:[\w-]+$/,gN=3,xN=2,mN=1,vN=10,yN=-2,Qb=e=>e==="*";function bN(e,t){let n=e.split("/"),r=n.length;return n.some(Qb)&&(r+=yN),t&&(r+=xN),n.filter(i=>!Qb(i)).reduce((i,s)=>i+(hN.test(s)?gN:s===""?mN:vN),r)}function jN(e,t){return e.length===t.length&&e.slice(0,-1).every((r,i)=>r===t[i])?e[e.length-1]-t[t.length-1]:0}function wN(e,t,n){n===void 0&&(n=!1);let{routesMeta:r}=e,i={},s="/",a=[];for(let l=0;l<r.length;++l){let c=r[l],d=l===r.length-1,u=s==="/"?t:t.slice(s.length)||"/",p=Gb({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},u),h=c.route;if(!p&&d&&n&&!r[r.length-1].route.index&&(p=Gb({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},u)),!p)return null;Object.assign(i,p.params),a.push({params:i,pathname:vi([s,p.pathname]),pathnameBase:RN(vi([s,p.pathnameBase])),route:h}),p.pathnameBase!=="/"&&(s=vi([s,p.pathnameBase]))}return a}function Gb(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=kN(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let s=i[0],a=s.replace(/(.)\/+$/,"$1"),l=i.slice(1);return{params:r.reduce((d,u,p)=>{let{paramName:h,isOptional:g}=u;if(h==="*"){let x=l[p]||"";a=s.slice(0,s.length-x.length).replace(/(.)\/+$/,"$1")}const v=l[p];return g&&!v?d[h]=void 0:d[h]=(v||"").replace(/%2F/g,"/"),d},{}),pathname:s,pathnameBase:a,pattern:e}}function kN(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),Ci(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,(a,l,c)=>(r.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),i+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":e!==""&&e!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,t?void 0:"i"),r]}function SN(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Ci(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Dd(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)||"/"}const CN=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,TN=e=>CN.test(e);function EN(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:i=""}=typeof e=="string"?Po(e):e,s;if(n)if(TN(n))s=n;else{if(n.includes("//")){let a=n;n=I0(n),Ci(!1,"Pathnames cannot have embedded double slashes - normalizing "+(a+" -> "+n))}n.startsWith("/")?s=Yb(n.substring(1),"/"):s=Yb(n,t)}else s=t;return{pathname:s,search:PN(r),hash:IN(i)}}function Yb(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(i=>{i===".."?n.length>1&&n.pop():i!=="."&&n.push(i)}),n.length>1?n.join("/"):"/"}function sg(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 TC(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function R0(e,t){let n=TC(e);return t?n.map((r,i)=>i===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function P0(e,t,n,r){r===void 0&&(r=!1);let i;typeof e=="string"?i=Po(e):(i=it({},e),Ie(!i.pathname||!i.pathname.includes("?"),sg("?","pathname","search",i)),Ie(!i.pathname||!i.pathname.includes("#"),sg("#","pathname","hash",i)),Ie(!i.search||!i.search.includes("#"),sg("#","search","hash",i)));let s=e===""||i.pathname==="",a=s?"/":i.pathname,l;if(a==null)l=n;else{let p=t.length-1;if(!r&&a.startsWith("..")){let h=a.split("/");for(;h[0]==="..";)h.shift(),p-=1;i.pathname=h.join("/")}l=p>=0?t[p]:"/"}let c=EN(i,l),d=a&&a!=="/"&&a.endsWith("/"),u=(s||a===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||u)&&(c.pathname+="/"),c}const I0=e=>e.replace(/\/\/+/g,"/"),vi=e=>I0(e.join("/")),RN=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),PN=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,IN=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;class Zp{constructor(t,n,r,i){i===void 0&&(i=!1),this.status=t,this.statusText=n||"",this.internal=i,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}}function nd(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const EC=["post","put","patch","delete"],MN=new Set(EC),LN=["get",...EC],ON=new Set(LN),DN=new Set([301,302,303,307,308]),AN=new Set([307,308]),ag={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},NN={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},ql={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},M0=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,$N=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),RC="remix-router-transitions";function PC(e){const t=e.window?e.window:typeof window<"u"?window:void 0,n=typeof t<"u"&&typeof t.document<"u"&&typeof t.document.createElement<"u",r=!n;Ie(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let i;if(e.mapRouteProperties)i=e.mapRouteProperties;else if(e.detectErrorBoundary){let T=e.detectErrorBoundary;i=I=>({hasErrorBoundary:T(I)})}else i=$N;let s={},a=Jp(e.routes,i,void 0,s),l,c=e.basename||"/",d=e.dataStrategy||BN,u=e.patchRoutesOnNavigation,p=it({v7_fetcherPersist:!1,v7_normalizeFormMethod:!1,v7_partialHydration:!1,v7_prependBasename:!1,v7_relativeSplatPath:!1,v7_skipActionErrorRevalidation:!1},e.future),h=null,g=new Set,v=null,x=null,w=null,b=e.hydrationData!=null,y=ts(a,e.history.location,c),j=!1,S=null;if(y==null&&!u){let T=vn(404,{pathname:e.history.location.pathname}),{matches:I,route:O}=aj(a);y=I,S={[O.id]:T}}y&&!e.hydrationData&&Sr(y,a,e.history.location.pathname).active&&(y=null);let k;if(y)if(y.some(T=>T.route.lazy))k=!1;else if(!y.some(T=>T.route.loader))k=!0;else if(p.v7_partialHydration){let T=e.hydrationData?e.hydrationData.loaderData:null,I=e.hydrationData?e.hydrationData.errors:null;if(I){let O=y.findIndex(z=>I[z.route.id]!==void 0);k=y.slice(0,O+1).every(z=>!hm(z.route,T,I))}else k=y.every(O=>!hm(O.route,T,I))}else k=e.hydrationData!=null;else if(k=!1,y=[],p.v7_partialHydration){let T=Sr(null,a,e.history.location.pathname);T.active&&T.matches&&(j=!0,y=T.matches)}let E,C={historyAction:e.history.action,location:e.history.location,matches:y,initialized:k,navigation:ag,restoreScrollPosition:e.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||S,fetchers:new Map,blockers:new Map},R=kt.Pop,P=!1,L,_=!1,U=new Map,K=null,$=!1,W=!1,V=[],Z=new Set,N=new Map,F=0,H=-1,re=new Map,D=new Set,Q=new Map,ne=new Map,J=new Set,te=new Map,fe=new Map,ve;function ke(){if(h=e.history.listen(T=>{let{action:I,location:O,delta:z}=T;if(ve){ve(),ve=void 0;return}Ci(fe.size===0||z!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let X=me({currentLocation:C.location,nextLocation:O,historyAction:I});if(X&&z!=null){let oe=new Promise(ce=>{ve=ce});e.history.go(z*-1),Y(X,{state:"blocked",location:O,proceed(){Y(X,{state:"proceeding",proceed:void 0,reset:void 0,location:O}),oe.then(()=>e.history.go(z))},reset(){let ce=new Map(C.blockers);ce.set(X,ql),Ee({blockers:ce})}});return}return lt(I,O)}),n){t$(t,U);let T=()=>n$(t,U);t.addEventListener("pagehide",T),K=()=>t.removeEventListener("pagehide",T)}return C.initialized||lt(kt.Pop,C.location,{initialHydration:!0}),E}function Ct(){h&&h(),K&&K(),g.clear(),L&&L.abort(),C.fetchers.forEach((T,I)=>qt(I)),C.blockers.forEach((T,I)=>nr(I))}function we(T){return g.add(T),()=>g.delete(T)}function Ee(T,I){I===void 0&&(I={}),C=it({},C,T);let O=[],z=[];p.v7_fetcherPersist&&C.fetchers.forEach((X,oe)=>{X.state==="idle"&&(J.has(oe)?z.push(oe):O.push(oe))}),J.forEach(X=>{!C.fetchers.has(X)&&!N.has(X)&&z.push(X)}),[...g].forEach(X=>X(C,{deletedFetchers:z,viewTransitionOpts:I.viewTransitionOpts,flushSync:I.flushSync===!0})),p.v7_fetcherPersist?(O.forEach(X=>C.fetchers.delete(X)),z.forEach(X=>qt(X))):z.forEach(X=>J.delete(X))}function Xe(T,I,O){var z,X;let{flushSync:oe}=O===void 0?{}:O,ce=C.actionData!=null&&C.navigation.formMethod!=null&&cr(C.navigation.formMethod)&&C.navigation.state==="loading"&&((z=T.state)==null?void 0:z._isRedirect)!==!0,de;I.actionData?Object.keys(I.actionData).length>0?de=I.actionData:de=null:ce?de=C.actionData:de=null;let se=I.loaderData?ij(C.loaderData,I.loaderData,I.matches||[],I.errors):C.loaderData,ie=C.blockers;ie.size>0&&(ie=new Map(ie),ie.forEach((Ce,Je)=>ie.set(Je,ql)));let pe=P===!0||C.navigation.formMethod!=null&&cr(C.navigation.formMethod)&&((X=T.state)==null?void 0:X._isRedirect)!==!0;l&&(a=l,l=void 0),$||R===kt.Pop||(R===kt.Push?e.history.push(T,T.state):R===kt.Replace&&e.history.replace(T,T.state));let ye;if(R===kt.Pop){let Ce=U.get(C.location.pathname);Ce&&Ce.has(T.pathname)?ye={currentLocation:C.location,nextLocation:T}:U.has(T.pathname)&&(ye={currentLocation:T,nextLocation:C.location})}else if(_){let Ce=U.get(C.location.pathname);Ce?Ce.add(T.pathname):(Ce=new Set([T.pathname]),U.set(C.location.pathname,Ce)),ye={currentLocation:C.location,nextLocation:T}}Ee(it({},I,{actionData:de,loaderData:se,historyAction:R,location:T,initialized:!0,navigation:ag,revalidation:"idle",restoreScrollPosition:Fi(T,I.matches||C.matches),preventScrollReset:pe,blockers:ie}),{viewTransitionOpts:ye,flushSync:oe===!0}),R=kt.Pop,P=!1,_=!1,$=!1,W=!1,V=[]}async function Tt(T,I){if(typeof T=="number"){e.history.go(T);return}let O=fm(C.location,C.matches,c,p.v7_prependBasename,T,p.v7_relativeSplatPath,I==null?void 0:I.fromRouteId,I==null?void 0:I.relative),{path:z,submission:X,error:oe}=Xb(p.v7_normalizeFormMethod,!1,O,I),ce=C.location,de=dl(C.location,z,I&&I.state);de=it({},de,e.history.encodeLocation(de));let se=I&&I.replace!=null?I.replace:void 0,ie=kt.Push;se===!0?ie=kt.Replace:se===!1||X!=null&&cr(X.formMethod)&&X.formAction===C.location.pathname+C.location.search&&(ie=kt.Replace);let pe=I&&"preventScrollReset"in I?I.preventScrollReset===!0:void 0,ye=(I&&I.flushSync)===!0,Ce=me({currentLocation:ce,nextLocation:de,historyAction:ie});if(Ce){Y(Ce,{state:"blocked",location:de,proceed(){Y(Ce,{state:"proceeding",proceed:void 0,reset:void 0,location:de}),Tt(T,I)},reset(){let Je=new Map(C.blockers);Je.set(Ce,ql),Ee({blockers:Je})}});return}return await lt(ie,de,{submission:X,pendingError:oe,preventScrollReset:pe,replace:I&&I.replace,enableViewTransition:I&&I.viewTransition,flushSync:ye})}function ht(){if(Yt(),Ee({revalidation:"loading"}),C.navigation.state!=="submitting"){if(C.navigation.state==="idle"){lt(C.historyAction,C.location,{startUninterruptedRevalidation:!0});return}lt(R||C.historyAction,C.navigation.location,{overrideNavigation:C.navigation,enableViewTransition:_===!0})}}async function lt(T,I,O){L&&L.abort(),L=null,R=T,$=(O&&O.startUninterruptedRevalidation)===!0,_i(C.location,C.matches),P=(O&&O.preventScrollReset)===!0,_=(O&&O.enableViewTransition)===!0;let z=l||a,X=O&&O.overrideNavigation,oe=O!=null&&O.initialHydration&&C.matches&&C.matches.length>0&&!j?C.matches:ts(z,I,c),ce=(O&&O.flushSync)===!0;if(oe&&C.initialized&&!W&&KN(C.location,I)&&!(O&&O.submission&&cr(O.submission.formMethod))){Xe(I,{matches:oe},{flushSync:ce});return}let de=Sr(oe,z,I.pathname);if(de.active&&de.matches&&(oe=de.matches),!oe){let{error:Ae,notFoundMatches:Ne,route:Ke}=Ve(I.pathname);Xe(I,{matches:Ne,loaderData:{},errors:{[Ke.id]:Ae}},{flushSync:ce});return}L=new AbortController;let se=Gs(e.history,I,L.signal,O&&O.submission),ie;if(O&&O.pendingError)ie=[ns(oe).route.id,{type:Ue.error,error:O.pendingError}];else if(O&&O.submission&&cr(O.submission.formMethod)){let Ae=await Kr(se,I,O.submission,oe,de.active,{replace:O.replace,flushSync:ce});if(Ae.shortCircuited)return;if(Ae.pendingActionResult){let[Ne,Ke]=Ae.pendingActionResult;if(Mn(Ke)&&nd(Ke.error)&&Ke.error.status===404){L=null,Xe(I,{matches:Ae.matches,loaderData:{},errors:{[Ne]:Ke.error}});return}}oe=Ae.matches||oe,ie=Ae.pendingActionResult,X=lg(I,O.submission),ce=!1,de.active=!1,se=Gs(e.history,se.url,se.signal)}let{shortCircuited:pe,matches:ye,loaderData:Ce,errors:Je}=await zt(se,I,oe,de.active,X,O&&O.submission,O&&O.fetcherSubmission,O&&O.replace,O&&O.initialHydration===!0,ce,ie);pe||(L=null,Xe(I,it({matches:ye||oe},sj(ie),{loaderData:Ce,errors:Je})))}async function Kr(T,I,O,z,X,oe){oe===void 0&&(oe={}),Yt();let ce=ZN(I,O);if(Ee({navigation:ce},{flushSync:oe.flushSync===!0}),X){let ie=await Cr(z,I.pathname,T.signal);if(ie.type==="aborted")return{shortCircuited:!0};if(ie.type==="error"){let pe=ns(ie.partialMatches).route.id;return{matches:ie.partialMatches,pendingActionResult:[pe,{type:Ue.error,error:ie.error}]}}else if(ie.matches)z=ie.matches;else{let{notFoundMatches:pe,error:ye,route:Ce}=Ve(I.pathname);return{matches:pe,pendingActionResult:[Ce.id,{type:Ue.error,error:ye}]}}}let de,se=lc(z,I);if(!se.route.action&&!se.route.lazy)de={type:Ue.error,error:vn(405,{method:T.method,pathname:I.pathname,routeId:se.route.id})};else if(de=(await yt("action",C,T,[se],z,null))[se.route.id],T.signal.aborted)return{shortCircuited:!0};if(ls(de)){let ie;return oe&&oe.replace!=null?ie=oe.replace:ie=nj(de.response.headers.get("Location"),new URL(T.url),c,e.history)===C.location.pathname+C.location.search,await sn(T,de,!0,{submission:O,replace:ie}),{shortCircuited:!0}}if(li(de))throw vn(400,{type:"defer-action"});if(Mn(de)){let ie=ns(z,se.route.id);return(oe&&oe.replace)!==!0&&(R=kt.Push),{matches:z,pendingActionResult:[ie.route.id,de]}}return{matches:z,pendingActionResult:[se.route.id,de]}}async function zt(T,I,O,z,X,oe,ce,de,se,ie,pe){let ye=X||lg(I,oe),Ce=oe||ce||cj(ye),Je=!$&&(!p.v7_partialHydration||!se);if(z){if(Je){let rt=Ot(pe);Ee(it({navigation:ye},rt!==void 0?{actionData:rt}:{}),{flushSync:ie})}let De=await Cr(O,I.pathname,T.signal);if(De.type==="aborted")return{shortCircuited:!0};if(De.type==="error"){let rt=ns(De.partialMatches).route.id;return{matches:De.partialMatches,loaderData:{},errors:{[rt]:De.error}}}else if(De.matches)O=De.matches;else{let{error:rt,notFoundMatches:Ao,route:Ui}=Ve(I.pathname);return{matches:Ao,loaderData:{},errors:{[Ui.id]:rt}}}}let Ae=l||a,[Ne,Ke]=Zb(e.history,C,O,Ce,I,p.v7_partialHydration&&se===!0,p.v7_skipActionErrorRevalidation,W,V,Z,J,Q,D,Ae,c,pe);if(nt(De=>!(O&&O.some(rt=>rt.route.id===De))||Ne&&Ne.some(rt=>rt.route.id===De)),H=++F,Ne.length===0&&Ke.length===0){let De=Un();return Xe(I,it({matches:O,loaderData:{},errors:pe&&Mn(pe[1])?{[pe[0]]:pe[1].error}:null},sj(pe),De?{fetchers:new Map(C.fetchers)}:{}),{flushSync:ie}),{shortCircuited:!0}}if(Je){let De={};if(!z){De.navigation=ye;let rt=Ot(pe);rt!==void 0&&(De.actionData=rt)}Ke.length>0&&(De.fetchers=hn(Ke)),Ee(De,{flushSync:ie})}Ke.forEach(De=>{Dt(De.key),De.controller&&N.set(De.key,De.controller)});let Bi=()=>Ke.forEach(De=>Dt(De.key));L&&L.signal.addEventListener("abort",Bi);let{loaderResults:Do,fetcherResults:rr}=await Wt(C,O,Ne,Ke,T);if(T.signal.aborted)return{shortCircuited:!0};L&&L.signal.removeEventListener("abort",Bi),Ke.forEach(De=>N.delete(De.key));let qn=Eu(Do);if(qn)return await sn(T,qn.result,!0,{replace:de}),{shortCircuited:!0};if(qn=Eu(rr),qn)return D.add(qn.key),await sn(T,qn.result,!0,{replace:de}),{shortCircuited:!0};let{loaderData:Dl,errors:Wi}=oj(C,O,Do,pe,Ke,rr,te);te.forEach((De,rt)=>{De.subscribe(Ao=>{(Ao||De.done)&&te.delete(rt)})}),p.v7_partialHydration&&se&&C.errors&&(Wi=it({},C.errors,Wi));let Gr=Un(),zs=Hn(H),Al=Gr||zs||Ke.length>0;return it({matches:O,loaderData:Dl,errors:Wi},Al?{fetchers:new Map(C.fetchers)}:{})}function Ot(T){if(T&&!Mn(T[1]))return{[T[0]]:T[1].data};if(C.actionData)return Object.keys(C.actionData).length===0?null:C.actionData}function hn(T){return T.forEach(I=>{let O=C.fetchers.get(I.key),z=Vl(void 0,O?O.data:void 0);C.fetchers.set(I.key,z)}),new Map(C.fetchers)}function Mo(T,I,O,z){if(r)throw new Error("router.fetch() was called during the server render, but it shouldn't be. You are likely calling a useFetcher() method in the body of your component. Try moving it to a useEffect or a callback.");Dt(T);let X=(z&&z.flushSync)===!0,oe=l||a,ce=fm(C.location,C.matches,c,p.v7_prependBasename,O,p.v7_relativeSplatPath,I,z==null?void 0:z.relative),de=ts(oe,ce,c),se=Sr(de,oe,ce);if(se.active&&se.matches&&(de=se.matches),!de){Ut(T,I,vn(404,{pathname:ce}),{flushSync:X});return}let{path:ie,submission:pe,error:ye}=Xb(p.v7_normalizeFormMethod,!0,ce,z);if(ye){Ut(T,I,ye,{flushSync:X});return}let Ce=lc(de,ie),Je=(z&&z.preventScrollReset)===!0;if(pe&&cr(pe.formMethod)){Bt(T,I,ie,Ce,de,se.active,X,Je,pe);return}Q.set(T,{routeId:I,path:ie}),kr(T,I,ie,Ce,de,se.active,X,Je,pe)}async function Bt(T,I,O,z,X,oe,ce,de,se){Yt(),Q.delete(T);function ie(ct){if(!ct.route.action&&!ct.route.lazy){let No=vn(405,{method:se.formMethod,pathname:O,routeId:I});return Ut(T,I,No,{flushSync:ce}),!0}return!1}if(!oe&&ie(z))return;let pe=C.fetchers.get(T);gt(T,e$(se,pe),{flushSync:ce});let ye=new AbortController,Ce=Gs(e.history,O,ye.signal,se);if(oe){let ct=await Cr(X,new URL(Ce.url).pathname,Ce.signal,T);if(ct.type==="aborted")return;if(ct.type==="error"){Ut(T,I,ct.error,{flushSync:ce});return}else if(ct.matches){if(X=ct.matches,z=lc(X,O),ie(z))return}else{Ut(T,I,vn(404,{pathname:O}),{flushSync:ce});return}}N.set(T,ye);let Je=F,Ne=(await yt("action",C,Ce,[z],X,T))[z.route.id];if(Ce.signal.aborted){N.get(T)===ye&&N.delete(T);return}if(p.v7_fetcherPersist&&J.has(T)){if(ls(Ne)||Mn(Ne)){gt(T,Uo(void 0));return}}else{if(ls(Ne))if(N.delete(T),H>Je){gt(T,Uo(void 0));return}else return D.add(T),gt(T,Vl(se)),sn(Ce,Ne,!1,{fetcherSubmission:se,preventScrollReset:de});if(Mn(Ne)){Ut(T,I,Ne.error);return}}if(li(Ne))throw vn(400,{type:"defer-action"});let Ke=C.navigation.location||C.location,Bi=Gs(e.history,Ke,ye.signal),Do=l||a,rr=C.navigation.state!=="idle"?ts(Do,C.navigation.location,c):C.matches;Ie(rr,"Didn't find any matches after fetcher action");let qn=++F;re.set(T,qn);let Dl=Vl(se,Ne.data);C.fetchers.set(T,Dl);let[Wi,Gr]=Zb(e.history,C,rr,se,Ke,!1,p.v7_skipActionErrorRevalidation,W,V,Z,J,Q,D,Do,c,[z.route.id,Ne]);Gr.filter(ct=>ct.key!==T).forEach(ct=>{let No=ct.key,Nl=C.fetchers.get(No),Kd=Vl(void 0,Nl?Nl.data:void 0);C.fetchers.set(No,Kd),Dt(No),ct.controller&&N.set(No,ct.controller)}),Ee({fetchers:new Map(C.fetchers)});let zs=()=>Gr.forEach(ct=>Dt(ct.key));ye.signal.addEventListener("abort",zs);let{loaderResults:Al,fetcherResults:De}=await Wt(C,rr,Wi,Gr,Bi);if(ye.signal.aborted)return;ye.signal.removeEventListener("abort",zs),re.delete(T),N.delete(T),Gr.forEach(ct=>N.delete(ct.key));let rt=Eu(Al);if(rt)return sn(Bi,rt.result,!1,{preventScrollReset:de});if(rt=Eu(De),rt)return D.add(rt.key),sn(Bi,rt.result,!1,{preventScrollReset:de});let{loaderData:Ao,errors:Ui}=oj(C,rr,Al,void 0,Gr,De,te);if(C.fetchers.has(T)){let ct=Uo(Ne.data);C.fetchers.set(T,ct)}Hn(qn),C.navigation.state==="loading"&&qn>H?(Ie(R,"Expected pending action"),L&&L.abort(),Xe(C.navigation.location,{matches:rr,loaderData:Ao,errors:Ui,fetchers:new Map(C.fetchers)})):(Ee({errors:Ui,loaderData:ij(C.loaderData,Ao,rr,Ui),fetchers:new Map(C.fetchers)}),W=!1)}async function kr(T,I,O,z,X,oe,ce,de,se){let ie=C.fetchers.get(T);gt(T,Vl(se,ie?ie.data:void 0),{flushSync:ce});let pe=new AbortController,ye=Gs(e.history,O,pe.signal);if(oe){let Ne=await Cr(X,new URL(ye.url).pathname,ye.signal,T);if(Ne.type==="aborted")return;if(Ne.type==="error"){Ut(T,I,Ne.error,{flushSync:ce});return}else if(Ne.matches)X=Ne.matches,z=lc(X,O);else{Ut(T,I,vn(404,{pathname:O}),{flushSync:ce});return}}N.set(T,pe);let Ce=F,Ae=(await yt("loader",C,ye,[z],X,T))[z.route.id];if(li(Ae)&&(Ae=await L0(Ae,ye.signal,!0)||Ae),N.get(T)===pe&&N.delete(T),!ye.signal.aborted){if(J.has(T)){gt(T,Uo(void 0));return}if(ls(Ae))if(H>Ce){gt(T,Uo(void 0));return}else{D.add(T),await sn(ye,Ae,!1,{preventScrollReset:de});return}if(Mn(Ae)){Ut(T,I,Ae.error);return}Ie(!li(Ae),"Unhandled fetcher deferred data"),gt(T,Uo(Ae.data))}}async function sn(T,I,O,z){let{submission:X,fetcherSubmission:oe,preventScrollReset:ce,replace:de}=z===void 0?{}:z;I.response.headers.has("X-Remix-Revalidate")&&(W=!0);let se=I.response.headers.get("Location");Ie(se,"Expected a Location header on the redirect Response"),se=nj(se,new URL(T.url),c,e.history);let ie=dl(C.location,se,{_isRedirect:!0});if(n){let Ne=!1;if(I.response.headers.has("X-Remix-Reload-Document"))Ne=!0;else if(M0.test(se)){const Ke=e.history.createURL(se);Ne=Ke.origin!==t.location.origin||Dd(Ke.pathname,c)==null}if(Ne){de?t.location.replace(se):t.location.assign(se);return}}L=null;let pe=de===!0||I.response.headers.has("X-Remix-Replace")?kt.Replace:kt.Push,{formMethod:ye,formAction:Ce,formEncType:Je}=C.navigation;!X&&!oe&&ye&&Ce&&Je&&(X=cj(C.navigation));let Ae=X||oe;if(AN.has(I.response.status)&&Ae&&cr(Ae.formMethod))await lt(pe,ie,{submission:it({},Ae,{formAction:se}),preventScrollReset:ce||P,enableViewTransition:O?_:void 0});else{let Ne=lg(ie,X);await lt(pe,ie,{overrideNavigation:Ne,fetcherSubmission:oe,preventScrollReset:ce||P,enableViewTransition:O?_:void 0})}}async function yt(T,I,O,z,X,oe){let ce,de={};try{ce=await WN(d,T,I,O,z,X,oe,s,i)}catch(se){return z.forEach(ie=>{de[ie.route.id]={type:Ue.error,error:se}}),de}for(let[se,ie]of Object.entries(ce))if(QN(ie)){let pe=ie.result;de[se]={type:Ue.redirect,response:qN(pe,O,se,X,c,p.v7_relativeSplatPath)}}else de[se]=await HN(ie);return de}async function Wt(T,I,O,z,X){let oe=T.matches,ce=yt("loader",T,X,O,I,null),de=Promise.all(z.map(async pe=>{if(pe.matches&&pe.match&&pe.controller){let Ce=(await yt("loader",T,Gs(e.history,pe.path,pe.controller.signal),[pe.match],pe.matches,pe.key))[pe.match.route.id];return{[pe.key]:Ce}}else return Promise.resolve({[pe.key]:{type:Ue.error,error:vn(404,{pathname:pe.path})}})})),se=await ce,ie=(await de).reduce((pe,ye)=>Object.assign(pe,ye),{});return await Promise.all([XN(I,se,X.signal,oe,T.loaderData),JN(I,ie,z)]),{loaderResults:se,fetcherResults:ie}}function Yt(){W=!0,V.push(...nt()),Q.forEach((T,I)=>{N.has(I)&&Z.add(I),Dt(I)})}function gt(T,I,O){O===void 0&&(O={}),C.fetchers.set(T,I),Ee({fetchers:new Map(C.fetchers)},{flushSync:(O&&O.flushSync)===!0})}function Ut(T,I,O,z){z===void 0&&(z={});let X=ns(C.matches,I);qt(T),Ee({errors:{[X.route.id]:O},fetchers:new Map(C.fetchers)},{flushSync:(z&&z.flushSync)===!0})}function Ht(T){return ne.set(T,(ne.get(T)||0)+1),J.has(T)&&J.delete(T),C.fetchers.get(T)||NN}function qt(T){let I=C.fetchers.get(T);N.has(T)&&!(I&&I.state==="loading"&&re.has(T))&&Dt(T),Q.delete(T),re.delete(T),D.delete(T),p.v7_fetcherPersist&&J.delete(T),Z.delete(T),C.fetchers.delete(T)}function Lo(T){let I=(ne.get(T)||0)-1;I<=0?(ne.delete(T),J.add(T),p.v7_fetcherPersist||qt(T)):ne.set(T,I),Ee({fetchers:new Map(C.fetchers)})}function Dt(T){let I=N.get(T);I&&(I.abort(),N.delete(T))}function Qr(T){for(let I of T){let O=Ht(I),z=Uo(O.data);C.fetchers.set(I,z)}}function Un(){let T=[],I=!1;for(let O of D){let z=C.fetchers.get(O);Ie(z,"Expected fetcher: "+O),z.state==="loading"&&(D.delete(O),T.push(O),I=!0)}return Qr(T),I}function Hn(T){let I=[];for(let[O,z]of re)if(z<T){let X=C.fetchers.get(O);Ie(X,"Expected fetcher: "+O),X.state==="loading"&&(Dt(O),re.delete(O),I.push(O))}return Qr(I),I.length>0}function an(T,I){let O=C.blockers.get(T)||ql;return fe.get(T)!==I&&fe.set(T,I),O}function nr(T){C.blockers.delete(T),fe.delete(T)}function Y(T,I){let O=C.blockers.get(T)||ql;Ie(O.state==="unblocked"&&I.state==="blocked"||O.state==="blocked"&&I.state==="blocked"||O.state==="blocked"&&I.state==="proceeding"||O.state==="blocked"&&I.state==="unblocked"||O.state==="proceeding"&&I.state==="unblocked","Invalid blocker state transition: "+O.state+" -> "+I.state);let z=new Map(C.blockers);z.set(T,I),Ee({blockers:z})}function me(T){let{currentLocation:I,nextLocation:O,historyAction:z}=T;if(fe.size===0)return;fe.size>1&&Ci(!1,"A router only supports one blocker at a time");let X=Array.from(fe.entries()),[oe,ce]=X[X.length-1],de=C.blockers.get(oe);if(!(de&&de.state==="proceeding")&&ce({currentLocation:I,nextLocation:O,historyAction:z}))return oe}function Ve(T){let I=vn(404,{pathname:T}),O=l||a,{matches:z,route:X}=aj(O);return nt(),{notFoundMatches:z,route:X,error:I}}function nt(T){let I=[];return te.forEach((O,z)=>{(!T||T(z))&&(O.cancel(),I.push(z),te.delete(z))}),I}function At(T,I,O){if(v=T,w=I,x=O||null,!b&&C.navigation===ag){b=!0;let z=Fi(C.location,C.matches);z!=null&&Ee({restoreScrollPosition:z})}return()=>{v=null,w=null,x=null}}function Oo(T,I){return x&&x(T,I.map(z=>pN(z,C.loaderData)))||T.key}function _i(T,I){if(v&&w){let O=Oo(T,I);v[O]=w()}}function Fi(T,I){if(v){let O=Oo(T,I),z=v[O];if(typeof z=="number")return z}return null}function Sr(T,I,O){if(u)if(T){if(Object.keys(T[0].params).length>0)return{active:!0,matches:up(I,O,c,!0)}}else return{active:!0,matches:up(I,O,c,!0)||[]};return{active:!1,matches:null}}async function Cr(T,I,O,z){if(!u)return{type:"success",matches:T};let X=T;for(;;){let oe=l==null,ce=l||a,de=s;try{await u({signal:O,path:I,matches:X,fetcherKey:z,patch:(pe,ye)=>{O.aborted||tj(pe,ye,ce,de,i)}})}catch(pe){return{type:"error",error:pe,partialMatches:X}}finally{oe&&!O.aborted&&(a=[...a])}if(O.aborted)return{type:"aborted"};let se=ts(ce,I,c);if(se)return{type:"success",matches:se};let ie=up(ce,I,c,!0);if(!ie||X.length===ie.length&&X.every((pe,ye)=>pe.route.id===ie[ye].route.id))return{type:"success",matches:null};X=ie}}function zi(T){s={},l=Jp(T,i,void 0,s)}function Fs(T,I){let O=l==null;tj(T,I,l||a,s,i),O&&(a=[...a],Ee({}))}return E={get basename(){return c},get future(){return p},get state(){return C},get routes(){return a},get window(){return t},initialize:ke,subscribe:we,enableScrollRestoration:At,navigate:Tt,fetch:Mo,revalidate:ht,createHref:T=>e.history.createHref(T),encodeLocation:T=>e.history.encodeLocation(T),getFetcher:Ht,deleteFetcher:Lo,dispose:Ct,getBlocker:an,deleteBlocker:nr,patchRoutes:Fs,_internalFetchControllers:N,_internalActiveDeferreds:te,_internalSetRoutes:zi},E}function _N(e){return e!=null&&("formData"in e&&e.formData!=null||"body"in e&&e.body!==void 0)}function fm(e,t,n,r,i,s,a,l){let c,d;if(a){c=[];for(let p of t)if(c.push(p),p.route.id===a){d=p;break}}else c=t,d=t[t.length-1];let u=P0(i||".",R0(c,s),Dd(e.pathname,n)||e.pathname,l==="path");if(i==null&&(u.search=e.search,u.hash=e.hash),(i==null||i===""||i===".")&&d){let p=O0(u.search);if(d.route.index&&!p)u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index";else if(!d.route.index&&p){let h=new URLSearchParams(u.search),g=h.getAll("index");h.delete("index"),g.filter(x=>x).forEach(x=>h.append("index",x));let v=h.toString();u.search=v?"?"+v:""}}return r&&n!=="/"&&(u.pathname=u.pathname==="/"?n:vi([n,u.pathname])),Pl(u)}function Xb(e,t,n,r){if(!r||!_N(r))return{path:n};if(r.formMethod&&!YN(r.formMethod))return{path:n,error:vn(405,{method:r.formMethod})};let i=()=>({path:n,error:vn(400,{type:"invalid-body"})}),s=r.formMethod||"get",a=e?s.toUpperCase():s.toLowerCase(),l=LC(n);if(r.body!==void 0){if(r.formEncType==="text/plain"){if(!cr(a))return i();let h=typeof r.body=="string"?r.body:r.body instanceof FormData||r.body instanceof URLSearchParams?Array.from(r.body.entries()).reduce((g,v)=>{let[x,w]=v;return""+g+x+"="+w+`
|
|
99
|
+
`},""):String(r.body);return{path:n,submission:{formMethod:a,formAction:l,formEncType:r.formEncType,formData:void 0,json:void 0,text:h}}}else if(r.formEncType==="application/json"){if(!cr(a))return i();try{let h=typeof r.body=="string"?JSON.parse(r.body):r.body;return{path:n,submission:{formMethod:a,formAction:l,formEncType:r.formEncType,formData:void 0,json:h,text:void 0}}}catch{return i()}}}Ie(typeof FormData=="function","FormData is not available in this environment");let c,d;if(r.formData)c=gm(r.formData),d=r.formData;else if(r.body instanceof FormData)c=gm(r.body),d=r.body;else if(r.body instanceof URLSearchParams)c=r.body,d=rj(c);else if(r.body==null)c=new URLSearchParams,d=new FormData;else try{c=new URLSearchParams(r.body),d=rj(c)}catch{return i()}let u={formMethod:a,formAction:l,formEncType:r&&r.formEncType||"application/x-www-form-urlencoded",formData:d,json:void 0,text:void 0};if(cr(u.formMethod))return{path:n,submission:u};let p=Po(n);return t&&p.search&&O0(p.search)&&c.append("index",""),p.search="?"+c,{path:Pl(p),submission:u}}function Jb(e,t,n){n===void 0&&(n=!1);let r=e.findIndex(i=>i.route.id===t);return r>=0?e.slice(0,n?r+1:r):e}function Zb(e,t,n,r,i,s,a,l,c,d,u,p,h,g,v,x){let w=x?Mn(x[1])?x[1].error:x[1].data:void 0,b=e.createURL(t.location),y=e.createURL(i),j=n;s&&t.errors?j=Jb(n,Object.keys(t.errors)[0],!0):x&&Mn(x[1])&&(j=Jb(n,x[0]));let S=x?x[1].statusCode:void 0,k=a&&S&&S>=400,E=j.filter((R,P)=>{let{route:L}=R;if(L.lazy)return!0;if(L.loader==null)return!1;if(s)return hm(L,t.loaderData,t.errors);if(FN(t.loaderData,t.matches[P],R)||c.some(K=>K===R.route.id))return!0;let _=t.matches[P],U=R;return ej(R,it({currentUrl:b,currentParams:_.params,nextUrl:y,nextParams:U.params},r,{actionResult:w,actionStatus:S,defaultShouldRevalidate:k?!1:l||b.pathname+b.search===y.pathname+y.search||b.search!==y.search||IC(_,U)}))}),C=[];return p.forEach((R,P)=>{if(s||!n.some($=>$.route.id===R.routeId)||u.has(P))return;let L=ts(g,R.path,v);if(!L){C.push({key:P,routeId:R.routeId,path:R.path,matches:null,match:null,controller:null});return}let _=t.fetchers.get(P),U=lc(L,R.path),K=!1;h.has(P)?K=!1:d.has(P)?(d.delete(P),K=!0):_&&_.state!=="idle"&&_.data===void 0?K=l:K=ej(U,it({currentUrl:b,currentParams:t.matches[t.matches.length-1].params,nextUrl:y,nextParams:n[n.length-1].params},r,{actionResult:w,actionStatus:S,defaultShouldRevalidate:k?!1:l})),K&&C.push({key:P,routeId:R.routeId,path:R.path,matches:L,match:U,controller:new AbortController})}),[E,C]}function hm(e,t,n){if(e.lazy)return!0;if(!e.loader)return!1;let r=t!=null&&t[e.id]!==void 0,i=n!=null&&n[e.id]!==void 0;return!r&&i?!1:typeof e.loader=="function"&&e.loader.hydrate===!0?!0:!r&&!i}function FN(e,t,n){let r=!t||n.route.id!==t.route.id,i=e[n.route.id]===void 0;return r||i}function IC(e,t){let n=e.route.path;return e.pathname!==t.pathname||n!=null&&n.endsWith("*")&&e.params["*"]!==t.params["*"]}function ej(e,t){if(e.route.shouldRevalidate){let n=e.route.shouldRevalidate(t);if(typeof n=="boolean")return n}return t.defaultShouldRevalidate}function tj(e,t,n,r,i){var s;let a;if(e){let d=r[e];Ie(d,"No route found to patch children into: routeId = "+e),d.children||(d.children=[]),a=d.children}else a=n;let l=t.filter(d=>!a.some(u=>MC(d,u))),c=Jp(l,i,[e||"_","patch",String(((s=a)==null?void 0:s.length)||"0")],r);a.push(...c)}function MC(e,t){return"id"in e&&"id"in t&&e.id===t.id?!0:e.index===t.index&&e.path===t.path&&e.caseSensitive===t.caseSensitive?(!e.children||e.children.length===0)&&(!t.children||t.children.length===0)?!0:e.children.every((n,r)=>{var i;return(i=t.children)==null?void 0:i.some(s=>MC(n,s))}):!1}async function zN(e,t,n){if(!e.lazy)return;let r=await e.lazy();if(!e.lazy)return;let i=n[e.id];Ie(i,"No route found in manifest");let s={};for(let a in r){let c=i[a]!==void 0&&a!=="hasErrorBoundary";Ci(!c,'Route "'+i.id+'" has a static property "'+a+'" defined but its lazy function is also returning a value for this property. '+('The lazy route property "'+a+'" will be ignored.')),!c&&!dN.has(a)&&(s[a]=r[a])}Object.assign(i,s),Object.assign(i,it({},t(i),{lazy:void 0}))}async function BN(e){let{matches:t}=e,n=t.filter(i=>i.shouldLoad);return(await Promise.all(n.map(i=>i.resolve()))).reduce((i,s,a)=>Object.assign(i,{[n[a].route.id]:s}),{})}async function WN(e,t,n,r,i,s,a,l,c,d){let u=s.map(g=>g.route.lazy?zN(g.route,c,l):void 0),p=s.map((g,v)=>{let x=u[v],w=i.some(y=>y.route.id===g.route.id);return it({},g,{shouldLoad:w,resolve:async y=>(y&&r.method==="GET"&&(g.route.lazy||g.route.loader)&&(w=!0),w?UN(t,r,g,x,y,d):Promise.resolve({type:Ue.data,result:void 0}))})}),h=await e({matches:p,request:r,params:s[0].params,fetcherKey:a,context:d});try{await Promise.all(u)}catch{}return h}async function UN(e,t,n,r,i,s){let a,l,c=d=>{let u,p=new Promise((v,x)=>u=x);l=()=>u(),t.signal.addEventListener("abort",l);let h=v=>typeof d!="function"?Promise.reject(new Error("You cannot call the handler for a route which defines a boolean "+('"'+e+'" [routeId: '+n.route.id+"]"))):d({request:t,params:n.params,context:s},...v!==void 0?[v]:[]),g=(async()=>{try{return{type:"data",result:await(i?i(x=>h(x)):h())}}catch(v){return{type:"error",result:v}}})();return Promise.race([g,p])};try{let d=n.route[e];if(r)if(d){let u,[p]=await Promise.all([c(d).catch(h=>{u=h}),r]);if(u!==void 0)throw u;a=p}else if(await r,d=n.route[e],d)a=await c(d);else if(e==="action"){let u=new URL(t.url),p=u.pathname+u.search;throw vn(405,{method:t.method,pathname:p,routeId:n.route.id})}else return{type:Ue.data,result:void 0};else if(d)a=await c(d);else{let u=new URL(t.url),p=u.pathname+u.search;throw vn(404,{pathname:p})}Ie(a.result!==void 0,"You defined "+(e==="action"?"an action":"a loader")+" for route "+('"'+n.route.id+"\" but didn't return anything from your `"+e+"` ")+"function. Please return a value or `null`.")}catch(d){return{type:Ue.error,result:d}}finally{l&&t.signal.removeEventListener("abort",l)}return a}async function HN(e){let{result:t,type:n}=e;if(OC(t)){let p;try{let h=t.headers.get("Content-Type");h&&/\bapplication\/json\b/.test(h)?t.body==null?p=null:p=await t.json():p=await t.text()}catch(h){return{type:Ue.error,error:h}}return n===Ue.error?{type:Ue.error,error:new Zp(t.status,t.statusText,p),statusCode:t.status,headers:t.headers}:{type:Ue.data,data:p,statusCode:t.status,headers:t.headers}}if(n===Ue.error){if(lj(t)){var r,i;if(t.data instanceof Error){var s,a;return{type:Ue.error,error:t.data,statusCode:(s=t.init)==null?void 0:s.status,headers:(a=t.init)!=null&&a.headers?new Headers(t.init.headers):void 0}}return{type:Ue.error,error:new Zp(((r=t.init)==null?void 0:r.status)||500,void 0,t.data),statusCode:nd(t)?t.status:void 0,headers:(i=t.init)!=null&&i.headers?new Headers(t.init.headers):void 0}}return{type:Ue.error,error:t,statusCode:nd(t)?t.status:void 0}}if(GN(t)){var l,c;return{type:Ue.deferred,deferredData:t,statusCode:(l=t.init)==null?void 0:l.status,headers:((c=t.init)==null?void 0:c.headers)&&new Headers(t.init.headers)}}if(lj(t)){var d,u;return{type:Ue.data,data:t.data,statusCode:(d=t.init)==null?void 0:d.status,headers:(u=t.init)!=null&&u.headers?new Headers(t.init.headers):void 0}}return{type:Ue.data,data:t}}function qN(e,t,n,r,i,s){let a=e.headers.get("Location");if(Ie(a,"Redirects returned/thrown from loaders/actions must have a Location header"),!M0.test(a)){let l=r.slice(0,r.findIndex(c=>c.route.id===n)+1);a=fm(new URL(t.url),l,i,!0,a,s),e.headers.set("Location",a)}return e}function nj(e,t,n,r){let i=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];if(M0.test(e)){let s=e,a=s.startsWith("//")?new URL(t.protocol+s):new URL(s);if(i.includes(a.protocol))throw new Error("Invalid redirect location");let l=Dd(a.pathname,n)!=null;if(a.origin===t.origin&&l)return I0(a.pathname)+a.search+a.hash}try{let s=r.createURL(e);if(i.includes(s.protocol))throw new Error("Invalid redirect location")}catch{}return e}function Gs(e,t,n,r){let i=e.createURL(LC(t)).toString(),s={signal:n};if(r&&cr(r.formMethod)){let{formMethod:a,formEncType:l}=r;s.method=a.toUpperCase(),l==="application/json"?(s.headers=new Headers({"Content-Type":l}),s.body=JSON.stringify(r.json)):l==="text/plain"?s.body=r.text:l==="application/x-www-form-urlencoded"&&r.formData?s.body=gm(r.formData):s.body=r.formData}return new Request(i,s)}function gm(e){let t=new URLSearchParams;for(let[n,r]of e.entries())t.append(n,typeof r=="string"?r:r.name);return t}function rj(e){let t=new FormData;for(let[n,r]of e.entries())t.append(n,r);return t}function VN(e,t,n,r,i){let s={},a=null,l,c=!1,d={},u=n&&Mn(n[1])?n[1].error:void 0;return e.forEach(p=>{if(!(p.route.id in t))return;let h=p.route.id,g=t[h];if(Ie(!ls(g),"Cannot handle redirect results in processLoaderData"),Mn(g)){let v=g.error;u!==void 0&&(v=u,u=void 0),a=a||{};{let x=ns(e,h);a[x.route.id]==null&&(a[x.route.id]=v)}s[h]=void 0,c||(c=!0,l=nd(g.error)?g.error.status:500),g.headers&&(d[h]=g.headers)}else li(g)?(r.set(h,g.deferredData),s[h]=g.deferredData.data,g.statusCode!=null&&g.statusCode!==200&&!c&&(l=g.statusCode),g.headers&&(d[h]=g.headers)):(s[h]=g.data,g.statusCode&&g.statusCode!==200&&!c&&(l=g.statusCode),g.headers&&(d[h]=g.headers))}),u!==void 0&&n&&(a={[n[0]]:u},s[n[0]]=void 0),{loaderData:s,errors:a,statusCode:l||200,loaderHeaders:d}}function oj(e,t,n,r,i,s,a){let{loaderData:l,errors:c}=VN(t,n,r,a);return i.forEach(d=>{let{key:u,match:p,controller:h}=d,g=s[u];if(Ie(g,"Did not find corresponding fetcher result"),!(h&&h.signal.aborted))if(Mn(g)){let v=ns(e.matches,p==null?void 0:p.route.id);c&&c[v.route.id]||(c=it({},c,{[v.route.id]:g.error})),e.fetchers.delete(u)}else if(ls(g))Ie(!1,"Unhandled fetcher revalidation redirect");else if(li(g))Ie(!1,"Unhandled fetcher deferred data");else{let v=Uo(g.data);e.fetchers.set(u,v)}}),{loaderData:l,errors:c}}function ij(e,t,n,r){let i=it({},t);for(let s of n){let a=s.route.id;if(t.hasOwnProperty(a)?t[a]!==void 0&&(i[a]=t[a]):e[a]!==void 0&&s.route.loader&&(i[a]=e[a]),r&&r.hasOwnProperty(a))break}return i}function sj(e){return e?Mn(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function ns(e,t){return(t?e.slice(0,e.findIndex(r=>r.route.id===t)+1):[...e]).reverse().find(r=>r.route.hasErrorBoundary===!0)||e[0]}function aj(e){let t=e.length===1?e[0]:e.find(n=>n.index||!n.path||n.path==="/")||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:t}],route:t}}function vn(e,t){let{pathname:n,routeId:r,method:i,type:s,message:a}=t===void 0?{}:t,l="Unknown Server Error",c="Unknown @remix-run/router error";return e===400?(l="Bad Request",i&&n&&r?c="You made a "+i+' request to "'+n+'" but '+('did not provide a `loader` for route "'+r+'", ')+"so there is no way to handle the request.":s==="defer-action"?c="defer() is not supported in actions":s==="invalid-body"&&(c="Unable to encode submission body")):e===403?(l="Forbidden",c='Route "'+r+'" does not match URL "'+n+'"'):e===404?(l="Not Found",c='No route matches URL "'+n+'"'):e===405&&(l="Method Not Allowed",i&&n&&r?c="You made a "+i.toUpperCase()+' request to "'+n+'" but '+('did not provide an `action` for route "'+r+'", ')+"so there is no way to handle the request.":i&&(c='Invalid request method "'+i.toUpperCase()+'"')),new Zp(e||500,l,new Error(c),!0)}function Eu(e){let t=Object.entries(e);for(let n=t.length-1;n>=0;n--){let[r,i]=t[n];if(ls(i))return{key:r,result:i}}}function LC(e){let t=typeof e=="string"?Po(e):e;return Pl(it({},t,{hash:""}))}function KN(e,t){return e.pathname!==t.pathname||e.search!==t.search?!1:e.hash===""?t.hash!=="":e.hash===t.hash?!0:t.hash!==""}function QN(e){return OC(e.result)&&DN.has(e.result.status)}function li(e){return e.type===Ue.deferred}function Mn(e){return e.type===Ue.error}function ls(e){return(e&&e.type)===Ue.redirect}function lj(e){return typeof e=="object"&&e!=null&&"type"in e&&"data"in e&&"init"in e&&e.type==="DataWithResponseInit"}function GN(e){let t=e;return t&&typeof t=="object"&&typeof t.data=="object"&&typeof t.subscribe=="function"&&typeof t.cancel=="function"&&typeof t.resolveData=="function"}function OC(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.headers=="object"&&typeof e.body<"u"}function YN(e){return ON.has(e.toLowerCase())}function cr(e){return MN.has(e.toLowerCase())}async function XN(e,t,n,r,i){let s=Object.entries(t);for(let a=0;a<s.length;a++){let[l,c]=s[a],d=e.find(h=>(h==null?void 0:h.route.id)===l);if(!d)continue;let u=r.find(h=>h.route.id===d.route.id),p=u!=null&&!IC(u,d)&&(i&&i[d.route.id])!==void 0;li(c)&&p&&await L0(c,n,!1).then(h=>{h&&(t[l]=h)})}}async function JN(e,t,n){for(let r=0;r<n.length;r++){let{key:i,routeId:s,controller:a}=n[r],l=t[i];e.find(d=>(d==null?void 0:d.route.id)===s)&&li(l)&&(Ie(a,"Expected an AbortController for revalidating fetcher deferred result"),await L0(l,a.signal,!0).then(d=>{d&&(t[i]=d)}))}}async function L0(e,t,n){if(n===void 0&&(n=!1),!await e.deferredData.resolveData(t)){if(n)try{return{type:Ue.data,data:e.deferredData.unwrappedData}}catch(i){return{type:Ue.error,error:i}}return{type:Ue.data,data:e.deferredData.data}}}function O0(e){return new URLSearchParams(e).getAll("index").some(t=>t==="")}function lc(e,t){let n=typeof t=="string"?Po(t).search:t.search;if(e[e.length-1].route.index&&O0(n||""))return e[e.length-1];let r=TC(e);return r[r.length-1]}function cj(e){let{formMethod:t,formAction:n,formEncType:r,text:i,formData:s,json:a}=e;if(!(!t||!n||!r)){if(i!=null)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:void 0,text:i};if(s!=null)return{formMethod:t,formAction:n,formEncType:r,formData:s,json:void 0,text:void 0};if(a!==void 0)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:a,text:void 0}}}function lg(e,t){return t?{state:"loading",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}:{state:"loading",location:e,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function ZN(e,t){return{state:"submitting",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}}function Vl(e,t){return e?{state:"loading",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t}:{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t}}function e$(e,t){return{state:"submitting",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t?t.data:void 0}}function Uo(e){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function t$(e,t){try{let n=e.sessionStorage.getItem(RC);if(n){let r=JSON.parse(n);for(let[i,s]of Object.entries(r||{}))s&&Array.isArray(s)&&t.set(i,new Set(s||[]))}}catch{}}function n$(e,t){if(t.size>0){let n={};for(let[r,i]of t)n[r]=[...i];try{e.sessionStorage.setItem(RC,JSON.stringify(n))}catch(r){Ci(!1,"Failed to save applied view transitions in sessionStorage ("+r+").")}}}/**
|
|
100
|
+
* React Router v6.30.4
|
|
101
|
+
*
|
|
102
|
+
* Copyright (c) Remix Software Inc.
|
|
103
|
+
*
|
|
104
|
+
* This source code is licensed under the MIT license found in the
|
|
105
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
106
|
+
*
|
|
107
|
+
* @license MIT
|
|
108
|
+
*/function ef(){return ef=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ef.apply(null,arguments)}const Vf=f.createContext(null),DC=f.createContext(null),Ad=f.createContext(null),Kf=f.createContext(null),Io=f.createContext({outlet:null,matches:[],isDataRoute:!1}),AC=f.createContext(null);function Nd(){return f.useContext(Kf)!=null}function wr(){return Nd()||Ie(!1),f.useContext(Kf).location}function r$(){return f.useContext(Kf).navigationType}function NC(e){f.useContext(Ad).static||f.useLayoutEffect(e)}function Be(){let{isDataRoute:e}=f.useContext(Io);return e?x$():o$()}function o$(){Nd()||Ie(!1);let e=f.useContext(Vf),{basename:t,future:n,navigator:r}=f.useContext(Ad),{matches:i}=f.useContext(Io),{pathname:s}=wr(),a=JSON.stringify(R0(i,n.v7_relativeSplatPath)),l=f.useRef(!1);return NC(()=>{l.current=!0}),f.useCallback(function(d,u){if(u===void 0&&(u={}),!l.current)return;if(typeof d=="number"){r.go(d);return}let p=P0(d,JSON.parse(a),s,u.relative==="path");e==null&&t!=="/"&&(p.pathname=p.pathname==="/"?t:vi([t,p.pathname])),(u.replace?r.replace:r.push)(p,u.state,u)},[t,r,a,s,e])}const i$=f.createContext(null);function $C(e){let t=f.useContext(Io).outlet;return t&&f.createElement(i$.Provider,{value:e},t)}function Qf(){let{matches:e}=f.useContext(Io),t=e[e.length-1];return t?t.params:{}}function s$(e,t,n,r){Nd()||Ie(!1);let{navigator:i}=f.useContext(Ad),{matches:s}=f.useContext(Io),a=s[s.length-1],l=a?a.params:{};a&&a.pathname;let c=a?a.pathnameBase:"/";a&&a.route;let d=wr(),u;u=d;let p=u.pathname||"/",h=p;if(c!=="/"){let x=c.replace(/^\//,"").split("/");h="/"+p.replace(/^\//,"").split("/").slice(x.length).join("/")}let g=ts(e,{pathname:h});return u$(g&&g.map(x=>Object.assign({},x,{params:Object.assign({},l,x.params),pathname:vi([c,i.encodeLocation?i.encodeLocation(x.pathname).pathname:x.pathname]),pathnameBase:x.pathnameBase==="/"?c:vi([c,i.encodeLocation?i.encodeLocation(x.pathnameBase).pathname:x.pathnameBase])})),s,n,r)}function a$(){let e=g$(),t=nd(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,i={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return f.createElement(f.Fragment,null,f.createElement("h2",null,"Unexpected Application Error!"),f.createElement("h3",{style:{fontStyle:"italic"}},t),n?f.createElement("pre",{style:i},n):null,null)}const l$=f.createElement(a$,null);class c$ extends f.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?f.createElement(Io.Provider,{value:this.props.routeContext},f.createElement(AC.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function d$(e){let{routeContext:t,match:n,children:r}=e,i=f.useContext(Vf);return i&&i.static&&i.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=n.route.id),f.createElement(Io.Provider,{value:t},r)}function u$(e,t,n,r){var i;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var s;if(!n)return null;if(n.errors)e=n.matches;else if((s=r)!=null&&s.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,l=(i=n)==null?void 0:i.errors;if(l!=null){let u=a.findIndex(p=>p.route.id&&(l==null?void 0:l[p.route.id])!==void 0);u>=0||Ie(!1),a=a.slice(0,Math.min(a.length,u+1))}let c=!1,d=-1;if(n&&r&&r.v7_partialHydration)for(let u=0;u<a.length;u++){let p=a[u];if((p.route.HydrateFallback||p.route.hydrateFallbackElement)&&(d=u),p.route.id){let{loaderData:h,errors:g}=n,v=p.route.loader&&h[p.route.id]===void 0&&(!g||g[p.route.id]===void 0);if(p.route.lazy||v){c=!0,d>=0?a=a.slice(0,d+1):a=[a[0]];break}}}return a.reduceRight((u,p,h)=>{let g,v=!1,x=null,w=null;n&&(g=l&&p.route.id?l[p.route.id]:void 0,x=p.route.errorElement||l$,c&&(d<0&&h===0?(m$("route-fallback"),v=!0,w=null):d===h&&(v=!0,w=p.route.hydrateFallbackElement||null)));let b=t.concat(a.slice(0,h+1)),y=()=>{let j;return g?j=x:v?j=w:p.route.Component?j=f.createElement(p.route.Component,null):p.route.element?j=p.route.element:j=u,f.createElement(d$,{match:p,routeContext:{outlet:u,matches:b,isDataRoute:n!=null},children:j})};return n&&(p.route.ErrorBoundary||p.route.errorElement||h===0)?f.createElement(c$,{location:n.location,revalidation:n.revalidation,component:x,error:g,children:y(),routeContext:{outlet:null,matches:b,isDataRoute:!0}}):y()},null)}var _C=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(_C||{}),FC=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(FC||{});function p$(e){let t=f.useContext(Vf);return t||Ie(!1),t}function f$(e){let t=f.useContext(DC);return t||Ie(!1),t}function h$(e){let t=f.useContext(Io);return t||Ie(!1),t}function zC(e){let t=h$(),n=t.matches[t.matches.length-1];return n.route.id||Ie(!1),n.route.id}function g$(){var e;let t=f.useContext(AC),n=f$(FC.UseRouteError),r=zC();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function x$(){let{router:e}=p$(_C.UseNavigateStable),t=zC(),n=f.useRef(!1);return NC(()=>{n.current=!0}),f.useCallback(function(i,s){s===void 0&&(s={}),n.current&&(typeof i=="number"?e.navigate(i):e.navigate(i,ef({fromRouteId:t},s)))},[e,t])}const dj={};function m$(e,t,n){dj[e]||(dj[e]=!0)}function v$(e,t){e==null||e.v7_startTransition,(e==null?void 0:e.v7_relativeSplatPath)===void 0&&(!t||t.v7_relativeSplatPath),t&&(t.v7_fetcherPersist,t.v7_normalizeFormMethod,t.v7_partialHydration,t.v7_skipActionErrorRevalidation)}function xm(e){let{to:t,replace:n,state:r,relative:i}=e;Nd()||Ie(!1);let{future:s,static:a}=f.useContext(Ad),{matches:l}=f.useContext(Io),{pathname:c}=wr(),d=Be(),u=P0(t,R0(l,s.v7_relativeSplatPath),c,i==="path"),p=JSON.stringify(u);return f.useEffect(()=>d(JSON.parse(p),{replace:n,state:r,relative:i}),[d,p,i,n,r]),null}function y$(e){return $C(e.context)}function b$(e){let{basename:t="/",children:n=null,location:r,navigationType:i=kt.Pop,navigator:s,static:a=!1,future:l}=e;Nd()&&Ie(!1);let c=t.replace(/^\/*/,"/"),d=f.useMemo(()=>({basename:c,navigator:s,static:a,future:ef({v7_relativeSplatPath:!1},l)}),[c,l,s,a]);typeof r=="string"&&(r=Po(r));let{pathname:u="/",search:p="",hash:h="",state:g=null,key:v="default"}=r,x=f.useMemo(()=>{let w=Dd(u,c);return w==null?null:{location:{pathname:w,search:p,hash:h,state:g,key:v},navigationType:i}},[c,u,p,h,g,v,i]);return x==null?null:f.createElement(Ad.Provider,{value:d},f.createElement(Kf.Provider,{children:n,value:x}))}new Promise(()=>{});function BC(e){let t={hasErrorBoundary:e.ErrorBoundary!=null||e.errorElement!=null};return e.Component&&Object.assign(t,{element:f.createElement(e.Component),Component:void 0}),e.HydrateFallback&&Object.assign(t,{hydrateFallbackElement:f.createElement(e.HydrateFallback),HydrateFallback:void 0}),e.ErrorBoundary&&Object.assign(t,{errorElement:f.createElement(e.ErrorBoundary),ErrorBoundary:void 0}),t}/**
|
|
109
|
+
* React Router DOM v6.30.4
|
|
110
|
+
*
|
|
111
|
+
* Copyright (c) Remix Software Inc.
|
|
112
|
+
*
|
|
113
|
+
* This source code is licensed under the MIT license found in the
|
|
114
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
115
|
+
*
|
|
116
|
+
* @license MIT
|
|
117
|
+
*/function rd(){return rd=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},rd.apply(null,arguments)}function mm(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(i=>[n,i]):[[n,r]])},[]))}function j$(e,t){let n=mm(e);return t&&t.forEach((r,i)=>{n.has(i)||t.getAll(i).forEach(s=>{n.append(i,s)})}),n}const w$="6";try{window.__reactRouterVersion=w$}catch{}function WC(e,t){return PC({basename:t==null?void 0:t.basename,future:rd({},t==null?void 0:t.future,{v7_prependBasename:!0}),history:aN({window:t==null?void 0:t.window}),hydrationData:(t==null?void 0:t.hydrationData)||HC(),routes:e,mapRouteProperties:BC,dataStrategy:t==null?void 0:t.dataStrategy,patchRoutesOnNavigation:t==null?void 0:t.patchRoutesOnNavigation,window:t==null?void 0:t.window}).initialize()}function UC(e,t){return PC({basename:t==null?void 0:t.basename,future:rd({},t==null?void 0:t.future,{v7_prependBasename:!0}),history:lN({window:t==null?void 0:t.window}),hydrationData:(t==null?void 0:t.hydrationData)||HC(),routes:e,mapRouteProperties:BC,dataStrategy:t==null?void 0:t.dataStrategy,patchRoutesOnNavigation:t==null?void 0:t.patchRoutesOnNavigation,window:t==null?void 0:t.window}).initialize()}function HC(){var e;let t=(e=window)==null?void 0:e.__staticRouterHydrationData;return t&&t.errors&&(t=rd({},t,{errors:k$(t.errors)})),t}function k$(e){if(!e)return null;let t=Object.entries(e),n={};for(let[r,i]of t)if(i&&i.__type==="RouteErrorResponse")n[r]=new Zp(i.status,i.statusText,i.data,i.internal===!0);else if(i&&i.__type==="Error"){if(i.__subType){let s=window[i.__subType];if(typeof s=="function")try{let a=new s(i.message);a.stack="",n[r]=a}catch{}}if(n[r]==null){let s=new Error(i.message);s.stack="",n[r]=s}}else n[r]=i;return n}const S$=f.createContext({isTransitioning:!1}),C$=f.createContext(new Map),T$="startTransition",uj=yl[T$],E$="flushSync",pj=j8[E$];function R$(e){uj?uj(e):e()}function Kl(e){pj?pj(e):e()}class P${constructor(){this.status="pending",this.promise=new Promise((t,n)=>{this.resolve=r=>{this.status==="pending"&&(this.status="resolved",t(r))},this.reject=r=>{this.status==="pending"&&(this.status="rejected",n(r))}})}}function I$(e){let{fallbackElement:t,router:n,future:r}=e,[i,s]=f.useState(n.state),[a,l]=f.useState(),[c,d]=f.useState({isTransitioning:!1}),[u,p]=f.useState(),[h,g]=f.useState(),[v,x]=f.useState(),w=f.useRef(new Map),{v7_startTransition:b}=r||{},y=f.useCallback(R=>{b?R$(R):R()},[b]),j=f.useCallback((R,P)=>{let{deletedFetchers:L,flushSync:_,viewTransitionOpts:U}=P;R.fetchers.forEach(($,W)=>{$.data!==void 0&&w.current.set(W,$.data)}),L.forEach($=>w.current.delete($));let K=n.window==null||n.window.document==null||typeof n.window.document.startViewTransition!="function";if(!U||K){_?Kl(()=>s(R)):y(()=>s(R));return}if(_){Kl(()=>{h&&(u&&u.resolve(),h.skipTransition()),d({isTransitioning:!0,flushSync:!0,currentLocation:U.currentLocation,nextLocation:U.nextLocation})});let $=n.window.document.startViewTransition(()=>{Kl(()=>s(R))});$.finished.finally(()=>{Kl(()=>{p(void 0),g(void 0),l(void 0),d({isTransitioning:!1})})}),Kl(()=>g($));return}h?(u&&u.resolve(),h.skipTransition(),x({state:R,currentLocation:U.currentLocation,nextLocation:U.nextLocation})):(l(R),d({isTransitioning:!0,flushSync:!1,currentLocation:U.currentLocation,nextLocation:U.nextLocation}))},[n.window,h,u,w,y]);f.useLayoutEffect(()=>n.subscribe(j),[n,j]),f.useEffect(()=>{c.isTransitioning&&!c.flushSync&&p(new P$)},[c]),f.useEffect(()=>{if(u&&a&&n.window){let R=a,P=u.promise,L=n.window.document.startViewTransition(async()=>{y(()=>s(R)),await P});L.finished.finally(()=>{p(void 0),g(void 0),l(void 0),d({isTransitioning:!1})}),g(L)}},[y,a,u,n.window]),f.useEffect(()=>{u&&a&&i.location.key===a.location.key&&u.resolve()},[u,h,i.location,a]),f.useEffect(()=>{!c.isTransitioning&&v&&(l(v.state),d({isTransitioning:!0,flushSync:!1,currentLocation:v.currentLocation,nextLocation:v.nextLocation}),x(void 0))},[c.isTransitioning,v]),f.useEffect(()=>{},[]);let S=f.useMemo(()=>({createHref:n.createHref,encodeLocation:n.encodeLocation,go:R=>n.navigate(R),push:(R,P,L)=>n.navigate(R,{state:P,preventScrollReset:L==null?void 0:L.preventScrollReset}),replace:(R,P,L)=>n.navigate(R,{replace:!0,state:P,preventScrollReset:L==null?void 0:L.preventScrollReset})}),[n]),k=n.basename||"/",E=f.useMemo(()=>({router:n,navigator:S,static:!1,basename:k}),[n,S,k]),C=f.useMemo(()=>({v7_relativeSplatPath:n.future.v7_relativeSplatPath}),[n.future.v7_relativeSplatPath]);return f.useEffect(()=>v$(r,n.future),[r,n.future]),f.createElement(f.Fragment,null,f.createElement(Vf.Provider,{value:E},f.createElement(DC.Provider,{value:i},f.createElement(C$.Provider,{value:w.current},f.createElement(S$.Provider,{value:c},f.createElement(b$,{basename:k,location:i.location,navigationType:i.historyAction,navigator:S,future:C},i.initialized||n.future.v7_partialHydration?f.createElement(M$,{routes:n.routes,future:n.future,state:i}):t))))),null)}const M$=f.memo(L$);function L$(e){let{routes:t,future:n,state:r}=e;return s$(t,void 0,r,n)}var fj;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(fj||(fj={}));var hj;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(hj||(hj={}));function O$(e){let t=f.useRef(mm(e)),n=f.useRef(!1),r=wr(),i=f.useMemo(()=>j$(r.search,n.current?null:t.current),[r.search]),s=Be(),a=f.useCallback((l,c)=>{const d=mm(typeof l=="function"?l(i):l);n.current=!0,s("?"+d,c)},[s,i]);return[i,a]}var gj=1,D$=.9,A$=.8,N$=.17,cg=.1,dg=.999,$$=.9999,_$=.99,F$=/[\\\/_+.#"@\[\(\{&]/,z$=/[\\\/_+.#"@\[\(\{&]/g,B$=/[\s-]/,qC=/[\s-]/g;function vm(e,t,n,r,i,s,a){if(s===t.length)return i===e.length?gj:_$;var l=`${i},${s}`;if(a[l]!==void 0)return a[l];for(var c=r.charAt(s),d=n.indexOf(c,i),u=0,p,h,g,v;d>=0;)p=vm(e,t,n,r,d+1,s+1,a),p>u&&(d===i?p*=gj:F$.test(e.charAt(d-1))?(p*=A$,g=e.slice(i,d-1).match(z$),g&&i>0&&(p*=Math.pow(dg,g.length))):B$.test(e.charAt(d-1))?(p*=D$,v=e.slice(i,d-1).match(qC),v&&i>0&&(p*=Math.pow(dg,v.length))):(p*=N$,i>0&&(p*=Math.pow(dg,d-i))),e.charAt(d)!==t.charAt(s)&&(p*=$$)),(p<cg&&n.charAt(d-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(d-1)!==r.charAt(s))&&(h=vm(e,t,n,r,d+1,s+2,a),h*cg>p&&(p=h*cg)),p>u&&(u=p),d=n.indexOf(c,d+1);return a[l]=u,u}function xj(e){return e.toLowerCase().replace(qC," ")}function W$(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,vm(e,t,xj(e),xj(t),0,0,{})}var Ql='[cmdk-group=""]',ug='[cmdk-group-items=""]',U$='[cmdk-group-heading=""]',VC='[cmdk-item=""]',mj=`${VC}:not([aria-disabled="true"])`,ym="cmdk-item-select",ca="data-value",H$=(e,t,n)=>W$(e,t,n),KC=f.createContext(void 0),$d=()=>f.useContext(KC),QC=f.createContext(void 0),D0=()=>f.useContext(QC),GC=f.createContext(void 0),YC=f.forwardRef((e,t)=>{let n=da(()=>{var D,Q;return{search:"",value:(Q=(D=e.value)!=null?D:e.defaultValue)!=null?Q:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=da(()=>new Set),i=da(()=>new Map),s=da(()=>new Map),a=da(()=>new Set),l=XC(e),{label:c,children:d,value:u,onValueChange:p,filter:h,shouldFilter:g,loop:v,disablePointerSelection:x=!1,vimBindings:w=!0,...b}=e,y=Nn(),j=Nn(),S=Nn(),k=f.useRef(null),E=t_();Is(()=>{if(u!==void 0){let D=u.trim();n.current.value=D,C.emit()}},[u]),Is(()=>{E(6,K)},[]);let C=f.useMemo(()=>({subscribe:D=>(a.current.add(D),()=>a.current.delete(D)),snapshot:()=>n.current,setState:(D,Q,ne)=>{var J,te,fe,ve;if(!Object.is(n.current[D],Q)){if(n.current[D]=Q,D==="search")U(),L(),E(1,_);else if(D==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ke=document.getElementById(S);ke?ke.focus():(J=document.getElementById(y))==null||J.focus()}if(E(7,()=>{var ke;n.current.selectedItemId=(ke=$())==null?void 0:ke.id,C.emit()}),ne||E(5,K),((te=l.current)==null?void 0:te.value)!==void 0){let ke=Q??"";(ve=(fe=l.current).onValueChange)==null||ve.call(fe,ke);return}}C.emit()}},emit:()=>{a.current.forEach(D=>D())}}),[]),R=f.useMemo(()=>({value:(D,Q,ne)=>{var J;Q!==((J=s.current.get(D))==null?void 0:J.value)&&(s.current.set(D,{value:Q,keywords:ne}),n.current.filtered.items.set(D,P(Q,ne)),E(2,()=>{L(),C.emit()}))},item:(D,Q)=>(r.current.add(D),Q&&(i.current.has(Q)?i.current.get(Q).add(D):i.current.set(Q,new Set([D]))),E(3,()=>{U(),L(),n.current.value||_(),C.emit()}),()=>{s.current.delete(D),r.current.delete(D),n.current.filtered.items.delete(D);let ne=$();E(4,()=>{U(),(ne==null?void 0:ne.getAttribute("id"))===D&&_(),C.emit()})}),group:D=>(i.current.has(D)||i.current.set(D,new Set),()=>{s.current.delete(D),i.current.delete(D)}),filter:()=>l.current.shouldFilter,label:c||e["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:y,inputId:S,labelId:j,listInnerRef:k}),[]);function P(D,Q){var ne,J;let te=(J=(ne=l.current)==null?void 0:ne.filter)!=null?J:H$;return D?te(D,n.current.search,Q):0}function L(){if(!n.current.search||l.current.shouldFilter===!1)return;let D=n.current.filtered.items,Q=[];n.current.filtered.groups.forEach(J=>{let te=i.current.get(J),fe=0;te.forEach(ve=>{let ke=D.get(ve);fe=Math.max(ke,fe)}),Q.push([J,fe])});let ne=k.current;W().sort((J,te)=>{var fe,ve;let ke=J.getAttribute("id"),Ct=te.getAttribute("id");return((fe=D.get(Ct))!=null?fe:0)-((ve=D.get(ke))!=null?ve:0)}).forEach(J=>{let te=J.closest(ug);te?te.appendChild(J.parentElement===te?J:J.closest(`${ug} > *`)):ne.appendChild(J.parentElement===ne?J:J.closest(`${ug} > *`))}),Q.sort((J,te)=>te[1]-J[1]).forEach(J=>{var te;let fe=(te=k.current)==null?void 0:te.querySelector(`${Ql}[${ca}="${encodeURIComponent(J[0])}"]`);fe==null||fe.parentElement.appendChild(fe)})}function _(){let D=W().find(ne=>ne.getAttribute("aria-disabled")!=="true"),Q=D==null?void 0:D.getAttribute(ca);C.setState("value",Q||void 0)}function U(){var D,Q,ne,J;if(!n.current.search||l.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let te=0;for(let fe of r.current){let ve=(Q=(D=s.current.get(fe))==null?void 0:D.value)!=null?Q:"",ke=(J=(ne=s.current.get(fe))==null?void 0:ne.keywords)!=null?J:[],Ct=P(ve,ke);n.current.filtered.items.set(fe,Ct),Ct>0&&te++}for(let[fe,ve]of i.current)for(let ke of ve)if(n.current.filtered.items.get(ke)>0){n.current.filtered.groups.add(fe);break}n.current.filtered.count=te}function K(){var D,Q,ne;let J=$();J&&(((D=J.parentElement)==null?void 0:D.firstChild)===J&&((ne=(Q=J.closest(Ql))==null?void 0:Q.querySelector(U$))==null||ne.scrollIntoView({block:"nearest"})),J.scrollIntoView({block:"nearest"}))}function $(){var D;return(D=k.current)==null?void 0:D.querySelector(`${VC}[aria-selected="true"]`)}function W(){var D;return Array.from(((D=k.current)==null?void 0:D.querySelectorAll(mj))||[])}function V(D){let Q=W()[D];Q&&C.setState("value",Q.getAttribute(ca))}function Z(D){var Q;let ne=$(),J=W(),te=J.findIndex(ve=>ve===ne),fe=J[te+D];(Q=l.current)!=null&&Q.loop&&(fe=te+D<0?J[J.length-1]:te+D===J.length?J[0]:J[te+D]),fe&&C.setState("value",fe.getAttribute(ca))}function N(D){let Q=$(),ne=Q==null?void 0:Q.closest(Ql),J;for(;ne&&!J;)ne=D>0?Z$(ne,Ql):e_(ne,Ql),J=ne==null?void 0:ne.querySelector(mj);J?C.setState("value",J.getAttribute(ca)):Z(D)}let F=()=>V(W().length-1),H=D=>{D.preventDefault(),D.metaKey?F():D.altKey?N(1):Z(1)},re=D=>{D.preventDefault(),D.metaKey?V(0):D.altKey?N(-1):Z(-1)};return f.createElement(Me.div,{ref:t,tabIndex:-1,...b,"cmdk-root":"",onKeyDown:D=>{var Q;(Q=b.onKeyDown)==null||Q.call(b,D);let ne=D.nativeEvent.isComposing||D.keyCode===229;if(!(D.defaultPrevented||ne))switch(D.key){case"n":case"j":{w&&D.ctrlKey&&H(D);break}case"ArrowDown":{H(D);break}case"p":case"k":{w&&D.ctrlKey&&re(D);break}case"ArrowUp":{re(D);break}case"Home":{D.preventDefault(),V(0);break}case"End":{D.preventDefault(),F();break}case"Enter":{D.preventDefault();let J=$();if(J){let te=new Event(ym);J.dispatchEvent(te)}}}}},f.createElement("label",{"cmdk-label":"",htmlFor:R.inputId,id:R.labelId,style:r_},c),Gf(e,D=>f.createElement(QC.Provider,{value:C},f.createElement(KC.Provider,{value:R},D))))}),q$=f.forwardRef((e,t)=>{var n,r;let i=Nn(),s=f.useRef(null),a=f.useContext(GC),l=$d(),c=XC(e),d=(r=(n=c.current)==null?void 0:n.forceMount)!=null?r:a==null?void 0:a.forceMount;Is(()=>{if(!d)return l.item(i,a==null?void 0:a.id)},[d]);let u=JC(i,s,[e.value,e.children,s],e.keywords),p=D0(),h=Ti(E=>E.value&&E.value===u.current),g=Ti(E=>d||l.filter()===!1?!0:E.search?E.filtered.items.get(i)>0:!0);f.useEffect(()=>{let E=s.current;if(!(!E||e.disabled))return E.addEventListener(ym,v),()=>E.removeEventListener(ym,v)},[g,e.onSelect,e.disabled]);function v(){var E,C;x(),(C=(E=c.current).onSelect)==null||C.call(E,u.current)}function x(){p.setState("value",u.current,!0)}if(!g)return null;let{disabled:w,value:b,onSelect:y,forceMount:j,keywords:S,...k}=e;return f.createElement(Me.div,{ref:ol(s,t),...k,id:i,"cmdk-item":"",role:"option","aria-disabled":!!w,"aria-selected":!!h,"data-disabled":!!w,"data-selected":!!h,onPointerMove:w||l.getDisablePointerSelection()?void 0:x,onClick:w?void 0:v},e.children)}),V$=f.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...s}=e,a=Nn(),l=f.useRef(null),c=f.useRef(null),d=Nn(),u=$d(),p=Ti(g=>i||u.filter()===!1?!0:g.search?g.filtered.groups.has(a):!0);Is(()=>u.group(a),[]),JC(a,l,[e.value,e.heading,c]);let h=f.useMemo(()=>({id:a,forceMount:i}),[i]);return f.createElement(Me.div,{ref:ol(l,t),...s,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&f.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:d},n),Gf(e,g=>f.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?d:void 0},f.createElement(GC.Provider,{value:h},g))))}),K$=f.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=f.useRef(null),s=Ti(a=>!a.search);return!n&&!s?null:f.createElement(Me.div,{ref:ol(i,t),...r,"cmdk-separator":"",role:"separator"})}),Q$=f.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,s=D0(),a=Ti(d=>d.search),l=Ti(d=>d.selectedItemId),c=$d();return f.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),f.createElement(Me.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":l,id:c.inputId,type:"text",value:i?e.value:a,onChange:d=>{i||s.setState("search",d.target.value),n==null||n(d.target.value)}})}),G$=f.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...i}=e,s=f.useRef(null),a=f.useRef(null),l=Ti(d=>d.selectedItemId),c=$d();return f.useEffect(()=>{if(a.current&&s.current){let d=a.current,u=s.current,p,h=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let g=d.offsetHeight;u.style.setProperty("--cmdk-list-height",g.toFixed(1)+"px")})});return h.observe(d),()=>{cancelAnimationFrame(p),h.unobserve(d)}}},[]),f.createElement(Me.div,{ref:ol(s,t),...i,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":r,id:c.listId},Gf(e,d=>f.createElement("div",{ref:ol(a,c.listInnerRef),"cmdk-list-sizer":""},d)))}),Y$=f.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:s,container:a,...l}=e;return f.createElement(Co,{open:n,onOpenChange:r},f.createElement(To,{container:a},f.createElement(Eo,{"cmdk-overlay":"",className:i}),f.createElement(Ro,{"aria-label":e.label,"cmdk-dialog":"",className:s},f.createElement(YC,{ref:t,...l}))))}),X$=f.forwardRef((e,t)=>Ti(n=>n.filtered.count===0)?f.createElement(Me.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),J$=f.forwardRef((e,t)=>{let{progress:n,children:r,label:i="Loading...",...s}=e;return f.createElement(Me.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Gf(e,a=>f.createElement("div",{"aria-hidden":!0},a)))}),od=Object.assign(YC,{List:G$,Item:q$,Input:Q$,Group:V$,Separator:K$,Dialog:Y$,Empty:X$,Loading:J$});function Z$(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function e_(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function XC(e){let t=f.useRef(e);return Is(()=>{t.current=e}),t}var Is=typeof window>"u"?f.useEffect:f.useLayoutEffect;function da(e){let t=f.useRef();return t.current===void 0&&(t.current=e()),t}function Ti(e){let t=D0(),n=()=>e(t.snapshot());return f.useSyncExternalStore(t.subscribe,n,n)}function JC(e,t,n,r=[]){let i=f.useRef(),s=$d();return Is(()=>{var a;let l=(()=>{var d;for(let u of n){if(typeof u=="string")return u.trim();if(typeof u=="object"&&"current"in u)return u.current?(d=u.current.textContent)==null?void 0:d.trim():i.current}})(),c=r.map(d=>d.trim());s.value(e,l,c),(a=t.current)==null||a.setAttribute(ca,l),i.current=l}),i}var t_=()=>{let[e,t]=f.useState(),n=da(()=>new Map);return Is(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,i)=>{n.current.set(r,i),t({})}};function n_(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Gf({asChild:e,children:t},n){return e&&f.isValidElement(t)?f.cloneElement(n_(t),{ref:t.ref},n(t.props.children)):n(t)}var r_={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const ZC={appearance:"stNavAppearance",platform:"stNavPlatform",accounts:"stNavAccounts",profiles:"stNavProfiles",budget:"stNavBudget",machines:"stNavMachines",templates:"stNavTemplates",mcp:"stNavMcp",notifications:"stNavNotifications",hooks:"stNavHooks",advanced:"stNavAdvanced"},o_={appearance:"stMetaAppearanceSub",platform:"stMetaPlatformSub",accounts:"stMetaAccountsSub",profiles:"stMetaProfilesSub",budget:"stMetaBudgetSub",machines:"stMetaMachinesSub",templates:"stMetaTemplatesSub",mcp:"stMetaMcpSub",notifications:"stMetaNotificationsSub",hooks:"stMetaHooksSub",advanced:"stMetaAdvancedSub"},i_=["appearance","platform","accounts","profiles","budget","machines","templates","mcp","notifications","hooks","advanced"];function s_(e){return i_.map(t=>({key:t,label:e[ZC[t]]}))}function a_(e,t){return{title:e[ZC[t]],sub:e[o_[t]]}}const A0="'IBM Plex Mono',monospace",l_={background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"0 1px 2px rgba(16,24,40,.03)"};function He({children:e,style:t}){return o.jsx("div",{style:{...l_,...t},children:e})}function _n({title:e,right:t}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:e}),t!=null?o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${A0}`,color:"var(--proto-muted-3)"},children:t}):null]})}function Yn({k:e,value:t,valueColor:n}){return o.jsxs("div",{style:{display:"flex"},children:[o.jsx("span",{style:{color:"var(--proto-muted-3)"},children:e}),o.jsx("span",{style:{marginLeft:"auto",color:n},children:t})]})}function Yf({on:e,onClick:t,inert:n}){return o.jsx("div",{onClick:t,role:t?"button":void 0,style:{width:32,height:19,borderRadius:999,background:e?"var(--proto-accent)":"var(--proto-line)",display:"flex",alignItems:"center",justifyContent:e?"flex-end":"flex-start",padding:2,boxSizing:"border-box",cursor:t?"pointer":n?"not-allowed":"default",flex:"none",opacity:n?.85:1},children:o.jsx("span",{style:{width:15,height:15,borderRadius:"50%",background:"var(--proto-card)"}})})}function e6({selected:e}){return o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:e?"4.5px solid var(--proto-accent)":"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none",marginTop:1}})}function uo({children:e}){return o.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".06em",color:"var(--proto-muted-3)",textTransform:"uppercase",margin:"14px 0 7px"},children:e})}function et({label:e,children:t,hint:n,hintTone:r}){return o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"4px 0"},children:[o.jsx("span",{style:{width:92,flex:"none",font:`400 10px ${A0}`,color:"var(--proto-muted-3)",paddingTop:6},children:e}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[t,n!=null?o.jsx("div",{style:{fontSize:9.5,lineHeight:1.6,marginTop:3,color:r==="danger"?"var(--proto-danger)":"var(--proto-faint)"},children:n}):null]})]})}const $e={width:"100%",boxSizing:"border-box",font:`400 11px ${A0}`,color:"var(--proto-ink)",background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:7,padding:"5px 9px",outline:"none"},N0={...$e,background:"var(--proto-alt)",color:"var(--proto-muted-2)",cursor:"not-allowed"},c_={accent:{base:{color:"var(--ink-solid-fg)",background:"var(--proto-accent)",border:"1px solid transparent"},hover:{background:"var(--proto-accent-strong)"}},danger:{base:{color:"var(--proto-danger)",background:"var(--proto-card)",border:"1px solid var(--proto-danger-bg)"},hover:{background:"var(--proto-danger-bg)"}},neutral:{base:{color:"var(--proto-ink)",background:"var(--proto-card)",border:"1px solid var(--proto-line-3)"},hover:{background:"var(--proto-alt)"}}};function Qe({tone:e,disabled:t,onClick:n,children:r,...i}){const[s,a]=f.useState(!1),l=c_[e],c={fontSize:11.5,fontWeight:600,borderRadius:8,padding:"6px 14px",flex:"none",cursor:t?"not-allowed":"pointer",opacity:t?.45:1,...l.base};return o.jsx("span",{...i,onClick:t?void 0:n,role:t?void 0:"button",onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:s&&!t?{...c,...l.hover}:c,children:r})}const d_="••••••••";function $0(e){const t={};for(const n of e)t[n.key]=n;return t}function bm(e,t){const n=e[t],r=(n==null?void 0:n.present)===!0;return{key:t,present:r,display:r?d_:"—"}}function ul(e,t){return e.some(n=>n.key.startsWith(t)&&n.present)}function t6(e){const t={};for(const n of e??[])t[n.key]=n;return t}function pl(e,t){return e[t]}const u_=["SLACK_BOT_TOKEN","SLACK_SIGNING_SECRET","SLACK_APP_TOKEN"],p_=["FEISHU_APP_ID","FEISHU_APP_SECRET","FEISHU_DOMAIN"],f_=["ANTHROPIC_API_KEY","ANTHROPIC_BASE_URL"],h_=["CORTEX_MACHINE","CORTEX_HOME","WEBHOOK_PORT","CORTEX_CLIENT_PORT","CORTEX_REPO"],g_=[{setting:"turnNotify",titleKey:"stNotifyTurnTitle",descKey:"stNotifyTurnDesc"},{setting:"autoResume",titleKey:"stNotifyResumeTitle",descKey:"stNotifyResumeDesc"},{setting:"notifyCompaction",titleKey:"stNotifyCompactionTitle",descKey:"stNotifyCompactionDesc"}],x_=[{kind:"env",env:"DEBUG",titleKey:"stAdvDebugTitle",descKey:"stAdvDebugDesc"},{kind:"setting",setting:"eventLog",titleKey:"stAdvEventLogTitle",descKey:"stAdvEventLogDesc"},{kind:"setting",setting:"diskMonitor",titleKey:"stAdvDiskMonitorTitle",descKey:"stAdvDiskMonitorDesc"},{kind:"setting",setting:"showToolCalls",titleKey:"stAdvToolCallsTitle",descKey:"stAdvToolCallsDesc"},{kind:"setting",setting:"disableUserContext",titleKey:"stAdvDisableUserTitle",descKey:"stAdvDisableUserDesc"},{kind:"setting",setting:"serverUpdateDisable",titleKey:"stAdvDisableUpdateTitle",descKey:"stAdvDisableUpdateDesc"}],On="'IBM Plex Mono',monospace";function jm({present:e}){const t=B();return o.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"1px 6px",borderRadius:999,background:e?"var(--proto-success-bg)":"var(--proto-gray)",color:e?"var(--proto-success)":"var(--proto-muted-2)"},children:e?t.stConfigured:t.stNotConfigured})}function wm({glyph:e}){return o.jsx("span",{style:{width:22,height:22,borderRadius:6,background:"var(--proto-gray)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:9,fontWeight:700,color:"var(--proto-muted)",flex:"none"},children:e})}function vj({platform:e,onReconnect:t}){const n=B(),r=!!t;return o.jsx("span",{onClick:r?()=>t(e):void 0,role:r?"button":void 0,"data-reconnect":e,title:r?n.stReconnectApprovalTitle:n.stReconnectInertTitle,style:{marginLeft:"auto",fontSize:10.5,fontWeight:600,color:r?"var(--proto-accent)":"var(--proto-faint)",cursor:r?"pointer":"not-allowed"},children:n.stReconnect})}function yj({index:e,keys:t}){return o.jsx("div",{style:{font:`400 10px/2 ${On}`,color:"var(--proto-muted)",marginTop:5,paddingLeft:31},children:t.map(n=>{const r=bm(e,n);return o.jsx(Yn,{k:n,valueColor:r.present?void 0:"var(--proto-faint)",value:r.present?o.jsxs(o.Fragment,{children:[r.display," ",o.jsx("span",{style:{color:"var(--proto-success)"},children:"✓"})]}):"—"},n)})})}function m_({snapshot:e,onReconnect:t}){var l;const n=B(),r=$0(e.env),i=ul(e.env,"SLACK_"),s=ul(e.env,"FEISHU_"),a=((l=r.CORTEX_TUI)==null?void 0:l.present)===!0;return o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1.2fr 1fr",gap:12,marginTop:12,alignItems:"start",maxWidth:980},children:[o.jsxs(He,{children:[o.jsx(_n,{title:n.stMessagingPlatforms,right:"CORTEX_PLATFORM"}),o.jsxs("div",{style:{padding:"11px 14px",borderBottom:"1px solid var(--proto-alt)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[o.jsx(wm,{glyph:"S"}),o.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--proto-ink)"},children:"Slack"}),o.jsx(jm,{present:i}),o.jsx(vj,{platform:"slack",onReconnect:t})]}),o.jsx(yj,{index:r,keys:u_})]}),o.jsxs("div",{style:{padding:"11px 14px",borderBottom:"1px solid var(--proto-alt)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[o.jsx(wm,{glyph:"飞"}),o.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--proto-ink)"},children:"飞书"}),o.jsx(jm,{present:s}),o.jsx(vj,{platform:"feishu",onReconnect:t})]}),o.jsx(yj,{index:r,keys:p_})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 14px"},children:[o.jsx(Yf,{on:a,inert:!0}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--proto-ink)"},children:n.stTuiGateway}),o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-muted-2)",marginTop:1},children:n.tuiDesc})]}),o.jsx("span",{style:{font:`400 9px ${On}`,color:"var(--proto-faint)",flex:"none"},children:"CORTEX_TUI"})]})]}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[o.jsxs(He,{children:[o.jsx(_n,{title:n.stApi}),o.jsx("div",{style:{padding:"8px 14px",font:`400 10px/2.1 ${On}`,color:"var(--proto-muted)"},children:f_.map(c=>{const d=bm(r,c);return o.jsx(Yn,{k:c,valueColor:d.present?void 0:"var(--proto-faint)",value:d.present?o.jsxs(o.Fragment,{children:[d.display," ",o.jsx("span",{style:{color:"var(--proto-success)"},children:"✓"})]}):"—"},c)})})]}),o.jsxs(He,{children:[o.jsx(_n,{title:n.stDaemonNetwork}),o.jsx("div",{style:{padding:"8px 14px",font:`400 10px/2.1 ${On}`,color:"var(--proto-muted)"},children:h_.map(c=>{const d=bm(r,c);return o.jsx(Yn,{k:c,valueColor:d.present?"var(--proto-ink)":"var(--proto-faint)",value:d.present?d.display:"—"},c)})})]})]})]})}const v_={fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)"};function y_({snapshot:e,onAddMachine:t}){const n=B(),r=e.machines,i="110px 1fr 44px 120px 90px 96px",s=!!t;return o.jsxs("div",{style:{marginTop:12,maxWidth:980},children:[o.jsxs(He,{style:{overflow:"hidden"},children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:i,padding:"7px 14px",borderBottom:"1px solid var(--proto-line-soft)",...v_},children:[o.jsx("span",{children:n.stColName}),o.jsx("span",{children:n.stColCortexPath}),o.jsx("span",{children:n.mGpu}),o.jsx("span",{children:n.stColSsh}),o.jsx("span",{children:n.stColOs}),o.jsx("span",{})]}),r.length===0?o.jsx("div",{style:{padding:"12px 14px",fontSize:11,color:"var(--proto-muted-3)"},children:n.stNoMachinesFile}):r.map(a=>o.jsxs("div",{style:{display:"grid",gridTemplateColumns:i,padding:"9px 14px",borderBottom:"1px solid var(--proto-alt)",alignItems:"center"},children:[o.jsx("span",{style:{font:`600 10.5px ${On}`,color:"var(--proto-ink)"},children:a.name}),o.jsx("span",{style:{font:`400 9.5px ${On}`,color:"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",paddingRight:8},children:a.cortexPath??"—"}),o.jsx("span",{style:{font:`400 10px ${On}`,color:"var(--proto-ink-2)"},children:a.gpuCount??"—"}),o.jsx("span",{style:{font:`400 9.5px ${On}`,color:a.ssh?"var(--proto-muted)":"var(--proto-faint)"},children:a.ssh?n.stConfigured:n.stMachineLocal}),o.jsx("span",{style:{font:`400 9.5px ${On}`,color:"var(--proto-muted)"},children:a.win?n.stWinOs:n.stUnixOs}),o.jsx("span",{title:"No machine logs/registry backend op — inert",style:{fontSize:10,fontWeight:600,color:"var(--proto-faint)",textAlign:"right",cursor:"not-allowed"},children:n.stLogs})]},a.name)),o.jsxs("div",{onClick:s?()=>{const a=window.prompt(n.stAddMachinePrompt),l=a==null?void 0:a.trim();l&&t(l)}:void 0,role:s?"button":void 0,"data-add-machine":s?"":void 0,title:s?n.stAddMachineApprovalTitle:n.stAddMachineInertTitle,style:{display:"flex",alignItems:"center",gap:7,padding:"9px 14px",cursor:s?"pointer":"not-allowed"},children:[o.jsx("span",{style:{fontSize:11,fontWeight:600,color:s?"var(--proto-accent)":"var(--proto-faint)"},children:n.stAddMachine}),o.jsx("span",{style:{font:`400 9px ${On}`,color:"var(--proto-faint)"},children:n.stMachineFieldsHint})]})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,marginTop:12,alignItems:"start"},children:[o.jsxs(He,{children:[o.jsx(_n,{title:n.stClientLifecycle,right:"client-manager"}),o.jsxs("div",{style:{padding:"8px 14px",fontSize:10.5,lineHeight:2,color:"var(--proto-muted)"},children:[o.jsx(_o,{k:n.mHeartbeat,v:"5s · 15s timeout"}),o.jsx(_o,{k:n.mRecover,v:"SSH restart · 60s backoff"}),o.jsx(_o,{k:"PID",v:"data/client-pids.json"}),o.jsx(_o,{k:"WebSocket",v:":3002 · CORTEX_CLIENT_TOKEN"})]})]}),o.jsxs(He,{children:[o.jsx(_n,{title:n.stConnectivity,right:"cortex-client.json"}),o.jsxs("div",{style:{padding:"8px 14px",fontSize:10.5,lineHeight:2,color:"var(--proto-muted)"},children:[o.jsx(_o,{k:"LAN",v:"serverHost = LAN IP"}),o.jsx(_o,{k:"Tailscale",v:"100.x.y.z"}),o.jsx(_o,{k:"CF Tunnel",v:"serverUrl = wss://…"}),o.jsx(_o,{k:n.mFirewall,v:"STCP"})]})]})]}),o.jsx(He,{style:{marginTop:12,padding:"10px 14px"},children:o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-muted-2)"},children:n.stMachinesFootNote})})]})}function _o({k:e,v:t}){return o.jsxs("div",{style:{display:"flex"},children:[o.jsx("span",{children:e}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${On}`,color:"var(--proto-ink)"},children:t})]})}function b_({snapshot:e}){var r;const t=B(),n=((r=e.mcp)==null?void 0:r.servers)??[];return o.jsxs(He,{style:{marginTop:12,maxWidth:760},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"11px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:t.stServers}),o.jsx("div",{title:"full / core / tui variant is a runtime-mode selection — no config.set for it (inert)",style:{marginLeft:"auto",display:"flex",background:"var(--proto-line-2)",borderRadius:7,padding:2},children:["full","core","tui"].map(i=>o.jsx("span",{style:{font:`500 10px ${On}`,color:i==="full"?"var(--proto-ink)":"var(--proto-muted-2)",background:i==="full"?"var(--proto-card)":"transparent",borderRadius:5,padding:"3px 10px",boxShadow:i==="full"?"0 1px 2px rgba(16,24,40,.06)":"none",cursor:"not-allowed"},children:i},i))})]}),n.length===0?o.jsx("div",{style:{padding:"12px 14px",fontSize:11,color:"var(--proto-muted-3)"},children:t.stNoServers}):n.map((i,s)=>o.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px",borderBottom:s<n.length-1?"1px solid var(--proto-alt)":void 0},children:o.jsx("span",{style:{font:`600 11.5px ${On}`,color:"var(--proto-ink)"},children:i})},i)),o.jsx("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"8px 14px",fontSize:10,color:"var(--proto-faint)"},children:t.stMcpFootNote})]})}const j_=["claude","pi"],km={claude:["low","medium","high","xhigh","max"],pi:["off","minimal","low","medium","high","xhigh"]},pg=/^[a-zA-Z0-9_-]+$/;function n6(e){return{name:e.name,model:e.model??"",backend:e.backend??"claude",mode:e.mode??"",provider:e.provider??"",thinking:e.thinking??"",claudeBackend:e.claudeBackend??"",extraOption:Object.entries(e.extraOption).map(([t,n])=>({key:t,value:n}))}}function fg(){return{name:"",model:"",backend:"claude",mode:"",provider:"",thinking:"",claudeBackend:"",extraOption:[]}}function _0(e){return e.filter(t=>t.key.trim()!==""||t.value.trim()!=="")}function bj(e){return JSON.stringify({name:e.name.trim(),model:e.model.trim(),backend:e.backend,mode:e.mode.trim(),provider:e.provider.trim(),thinking:e.thinking,claudeBackend:e.claudeBackend,extraOption:_0(e.extraOption).map(t=>[t.key.trim(),t.value.trim()]).sort((t,n)=>t[0].localeCompare(n[0]))})}function w_(e,t){return bj(e)!==bj(n6(t))}function k_(e,t){const n={},r=e.name.trim();r===""?n.name="name-required":pg.test(r)?t.mode==="create"&&t.existingNames.includes(r)&&(n.name="name-taken"):n.name="name-charset",e.model.trim()===""&&(n.model="model-required");const i=e.mode.trim();i!==""&&!pg.test(i)&&(n.mode="mode-charset");const s=e.provider.trim();e.backend==="pi"&&s===""?n.provider="provider-required":s!==""&&!pg.test(s)&&(n.provider="provider-charset"),e.thinking!==""&&!km[e.backend].includes(e.thinking)&&(n.thinking="thinking-level");const a=_0(e.extraOption),l=a.map(c=>c.key.trim());return l.some(c=>!c.startsWith("--"))?n.extraOption="option-key-prefix":new Set(l).size!==l.length?n.extraOption="option-key-duplicate":a.some(c=>c.value.trim()==="")&&(n.extraOption="option-value-required"),n}function S_(e){return Object.keys(e).length===0}function r6(e){const t={model:e.model.trim(),backend:e.backend},n=e.mode.trim();n!==""&&(t.mode=n);const r=e.provider.trim();r!==""&&(t.provider=r),e.thinking!==""&&(t.thinking=e.thinking),e.claudeBackend!==""&&(t.claudeBackend=e.claudeBackend);const i=_0(e.extraOption);return i.length>0&&(t.extraOption=Object.fromEntries(i.map(s=>[s.key.trim(),s.value.trim()]))),t}function C_(e){return{name:e.name.trim(),...r6(e)}}function T_(e){return{name:e.name.trim(),...r6(e)}}const Ca="'IBM Plex Mono',monospace",E_={fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)"},jj="84px 1fr 66px 52px 58px 118px",R_={"name-required":"pfErrNameRequired","name-charset":"pfErrNameCharset","name-taken":"pfErrNameTaken","model-required":"pfErrModelRequired","mode-charset":"pfErrModeCharset","provider-required":"pfErrProviderRequired","provider-charset":"pfErrProviderCharset","thinking-level":"pfErrThinkingLevel","option-key-prefix":"pfErrOptionKeyPrefix","option-key-duplicate":"pfErrOptionKeyDuplicate","option-value-required":"pfErrOptionValueRequired"};function rs({children:e,onClick:t,tone:n,title:r,...i}){const s=!!t;return o.jsx("span",{...i,onClick:t,role:s?"button":void 0,title:r,style:{fontSize:10.5,fontWeight:600,color:s?n==="danger"?"var(--proto-danger)":"var(--proto-accent)":"var(--proto-faint)",cursor:s?"pointer":"not-allowed"},children:e})}function Ru({value:e,dim:t}){return o.jsx("span",{style:{font:`400 10px ${Ca}`,color:e&&!t?"var(--proto-ink)":"var(--proto-faint)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",paddingRight:8},children:e??"—"})}function P_({draft:e,creating:t,entry:n,errors:r,onDraftChange:i}){const s=B(),a=d=>i({...e,...d}),l=(d,u)=>{const p=r[d];return p?s[R_[p]]:u},c=d=>r[d]?"danger":"muted";return o.jsxs(o.Fragment,{children:[o.jsx(uo,{children:t?s.pfCreateTitle:s.pfEditTitle}),o.jsx(et,{label:s.pfFieldName,hint:l("name",t?s.pfNameHint:s.pfNoRename),hintTone:c("name"),children:o.jsx("input",{"data-profile-field":"name",value:e.name,disabled:!t,onChange:d=>a({name:d.target.value}),style:t?$e:N0})}),o.jsx(et,{label:s.pfFieldModel,hint:l("model",s.pfModelHint),hintTone:c("model"),children:o.jsx("input",{"data-profile-field":"model",value:e.model,onChange:d=>a({model:d.target.value}),style:$e})}),o.jsx(et,{label:s.pfFieldBackend,children:o.jsx("select",{"data-profile-field":"backend",value:e.backend,onChange:d=>{const u=d.target.value,p=km[u].includes(e.thinking)?e.thinking:"";a({backend:u,thinking:p})},style:$e,children:j_.map(d=>o.jsx("option",{value:d,children:d},d))})}),o.jsx(et,{label:s.pfFieldMode,hint:l("mode",s.pfModeHint),hintTone:c("mode"),children:o.jsx("input",{"data-profile-field":"mode",value:e.mode,onChange:d=>a({mode:d.target.value}),style:$e})}),o.jsx(et,{label:s.pfFieldProvider,hint:l("provider",s.pfProviderHint),hintTone:c("provider"),children:o.jsx("input",{"data-profile-field":"provider",value:e.provider,onChange:d=>a({provider:d.target.value}),style:$e})}),o.jsx(et,{label:s.pfFieldThinking,hint:l("thinking"),hintTone:c("thinking"),children:o.jsxs("select",{"data-profile-field":"thinking",value:e.thinking,onChange:d=>a({thinking:d.target.value}),style:$e,children:[o.jsx("option",{value:"",children:s.pfNotDeclared}),km[e.backend].map(d=>o.jsx("option",{value:d,children:d},d))]})}),e.backend==="claude"?o.jsx(et,{label:s.pfFieldClaudeBackend,children:o.jsxs("select",{"data-profile-field":"claudeBackend",value:e.claudeBackend,onChange:d=>a({claudeBackend:d.target.value}),style:$e,children:[o.jsx("option",{value:"",children:s.pfPrintDefault}),o.jsx("option",{value:"print",children:"print"}),o.jsx("option",{value:"tui",children:"tui"})]})}):null,o.jsx(et,{label:s.pfFieldExtraOption,hint:l("extraOption"),hintTone:c("extraOption"),children:o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[e.extraOption.map((d,u)=>o.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[o.jsx("input",{"data-profile-option-key":u,value:d.key,placeholder:s.pfOptionKeyPlaceholder,onChange:p=>{const h=e.extraOption.slice();h[u]={...h[u],key:p.target.value},a({extraOption:h})},style:{...$e,width:140,flex:"none"}}),o.jsx("input",{"data-profile-option-value":u,value:d.value,placeholder:s.pfOptionValuePlaceholder,onChange:p=>{const h=e.extraOption.slice();h[u]={...h[u],value:p.target.value},a({extraOption:h})},style:$e}),o.jsx(rs,{"data-action":"remove-option",tone:"danger",onClick:()=>a({extraOption:e.extraOption.filter((p,h)=>h!==u)}),children:s.pfRemoveOption})]},u)),o.jsx(rs,{"data-action":"add-option",onClick:()=>a({extraOption:[...e.extraOption,{key:"",value:""}]}),children:s.pfAddOption})]})}),o.jsxs(uo,{children:[s.pfFieldExtraEnv," · ",s.pfFieldFallback]}),o.jsxs("div",{style:{font:`400 10px/2 ${Ca}`,color:"var(--proto-muted)"},children:[o.jsx(Yn,{k:s.pfFieldExtraEnv,value:n&&n.extraEnvKeys.length>0?n.extraEnvKeys.join(" · "):s.pfNoExtraEnv}),o.jsx(Yn,{k:s.pfFieldFallback,value:n&&n.fallbackCount>0?`${n.fallbackCount} ${s.pfFallbackCount}`:"—"})]}),o.jsxs("div",{style:{fontSize:9.5,lineHeight:1.7,color:"var(--proto-faint)",marginTop:4},children:[s.pfExtraEnvNote," ",s.pfFallbackNote]})]})}function I_(e){const t=B(),n=e.snapshot.profiles,r=(n==null?void 0:n.profiles)??[],i=!!e.onSetDefaultProfile&&r.length>0,s=e.draft!==null,a=e.editingName===null?null:r.find(u=>u.name===e.editingName)??null,l=e.draft?k_(e.draft,{mode:e.creating?"create":"update",existingNames:r.map(u=>u.name)}):{},c=e.draft!==null&&(e.creating||a!==null&&w_(e.draft,a)),d=s&&c&&S_(l)&&!e.saving;return o.jsxs("div",{"data-settings-panel":"profiles",children:[o.jsxs(He,{style:{padding:"10px 14px",display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[o.jsx("span",{style:{fontSize:11,color:"var(--proto-muted)"},children:t.stDefaultProfile}),i?o.jsx("select",{"data-default-profile-select":!0,value:(n==null?void 0:n.defaultProfile)??"",onChange:u=>e.onSetDefaultProfile(u.target.value),style:{font:`600 11px ${Ca}`,color:"var(--proto-ink)",border:"1px solid var(--proto-line)",borderRadius:7,padding:"4px 10px",background:"var(--proto-card)",cursor:"pointer"},children:r.map(u=>o.jsx("option",{value:u.name,children:u.name},u.name))}):o.jsxs("span",{title:"Select a profile to write profiles.json defaultProfile",style:{display:"flex",alignItems:"center",gap:7,border:"1px solid var(--proto-line)",borderRadius:7,padding:"4px 10px"},children:[o.jsx("span",{style:{font:`600 11px ${Ca}`,color:"var(--proto-ink)"},children:(n==null?void 0:n.defaultProfile)??"—"}),o.jsx("span",{style:{color:"var(--proto-muted-3)",fontSize:8},children:"▾"})]}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${Ca}`,color:"var(--proto-faint)"},children:t.stProfReadNote})]}),o.jsxs(He,{style:{marginTop:12,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:jj,padding:"7px 14px",borderBottom:"1px solid var(--proto-line-soft)",...E_},children:[o.jsx("span",{children:t.stColName}),o.jsx("span",{children:t.stColModel}),o.jsx("span",{children:t.stColBackend}),o.jsx("span",{children:t.stColMode}),o.jsx("span",{children:t.stColThinking}),o.jsx("span",{style:{textAlign:"right"},children:o.jsx(rs,{"data-action":"new-profile",onClick:e.saving||s?void 0:e.onStartCreate,children:t.pfNew})})]}),r.length===0?o.jsx("div",{style:{padding:"12px 14px",fontSize:11,color:"var(--proto-muted-3)"},children:t.stNoProfiles}):r.map((u,p)=>{const h=u.name===(n==null?void 0:n.defaultProfile),g=e.armedDelete===u.name,v=e.saving||s;return o.jsxs("div",{"data-profile-row":u.name,style:{display:"grid",gridTemplateColumns:jj,padding:"9px 14px",borderBottom:p<r.length-1?"1px solid var(--proto-alt)":void 0,alignItems:"center",background:e.editingName===u.name?"var(--proto-accent-bg)":void 0},children:[o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5},children:[o.jsx("span",{style:{font:`600 10.5px ${Ca}`,color:"var(--proto-ink-2)"},children:u.name}),h?o.jsx("span",{style:{fontSize:8,fontWeight:600,padding:"1px 4px",borderRadius:999,background:"var(--proto-accent-bg)",color:"var(--proto-accent)"},children:t.default}):null]}),o.jsx(Ru,{value:u.model,dim:!0}),o.jsx(Ru,{value:u.backend,dim:!0}),o.jsx(Ru,{value:u.mode}),o.jsx(Ru,{value:u.thinking}),o.jsx("span",{style:{display:"flex",gap:10,justifyContent:"flex-end"},children:g?o.jsxs(o.Fragment,{children:[o.jsx(rs,{"data-action":"cancel-delete",onClick:e.onCancelDelete,children:t.cancel}),o.jsx(rs,{"data-action":"confirm-delete",tone:"danger",onClick:e.saving?void 0:()=>e.onConfirmDelete(u.name),children:t.pfConfirmDelete})]}):o.jsxs(o.Fragment,{children:[o.jsx(rs,{"data-action":"edit",onClick:v?void 0:()=>e.onStartEdit(u.name),children:t.pfEdit}),o.jsx(rs,{"data-action":"delete","data-delete-blocked":h?"":void 0,tone:"danger",title:h?t.pfDeleteDefaultBlocked:void 0,onClick:v||h?void 0:()=>e.onArmDelete(u.name),children:t.pfDelete})]})})]},u.name)})]}),e.draft!==null?o.jsxs(He,{style:{marginTop:12,padding:"4px 14px 12px"},children:[o.jsx("div",{"data-profile-editor":""}),o.jsx(P_,{draft:e.draft,creating:e.creating,entry:a,errors:l,onDraftChange:e.onDraftChange}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:12},children:[c?o.jsx("span",{style:{fontSize:9.5,fontWeight:600,color:"var(--proto-amber)"},children:t.pfDirty}):null,o.jsx("span",{style:{marginLeft:"auto"}}),e.creating?null:o.jsx(Qe,{"data-action":"revert",tone:"neutral",disabled:!c,onClick:e.onRevert,children:t.pfRevert}),o.jsx(Qe,{"data-action":"cancel-edit",tone:"neutral",onClick:e.onCancelEdit,children:t.cancel}),o.jsx(Qe,{"data-action":"save",tone:"accent",disabled:!d,onClick:e.onSave,children:t.pfSave})]})]}):null]})}function M_({snapshot:e,onSetDefaultProfile:t}){var P;const n=B(),r=ae(),i=je(),{toast:s}=Tn(),[a,l]=f.useState(!1),[c,d]=f.useState(null),[u,p]=f.useState(null),[h,g]=f.useState(fg),[v,x]=f.useState(null),w=((P=e.profiles)==null?void 0:P.profiles)??[],b=c===null?null:w.find(L=>L.name===c)??null,y=a?h:b?u??n6(b):null,j=()=>i.invalidateQueries(r.config.get.queryFilter({})),S=L=>s({title:`${n.pfToastWriteFailed}: ${L.message}`,tone:"failed"}),k=()=>{l(!1),d(null),p(null),g(fg())},E=ue(r.profiles.create.mutationOptions({onSuccess:L=>{j(),s({title:`${n.pfToastCreated} · ${L.name}`,tone:"done"}),k()},onError:S})),C=ue(r.profiles.update.mutationOptions({onSuccess:L=>{j(),s({title:L.changed?n.pfToastSaved:n.pfToastUnchanged,tone:"done"}),k()},onError:S})),R=ue(r.profiles.remove.mutationOptions({onSuccess:()=>{j(),s({title:n.pfToastDeleted,tone:"done"}),x(null)},onError:L=>{x(null),S(L)}}));return o.jsx(I_,{snapshot:e,onSetDefaultProfile:t,draft:y,creating:a,editingName:a?null:c,armedDelete:v,saving:E.isPending||C.isPending||R.isPending,onStartCreate:()=>{l(!0),d(null),p(null),g(fg()),x(null)},onStartEdit:L=>{l(!1),d(L),p(null),x(null)},onCancelEdit:k,onDraftChange:L=>a?g(L):p(L),onSave:()=>{y!==null&&(a?E.mutate(C_(y)):C.mutate(T_(y)))},onRevert:()=>p(null),onArmDelete:x,onCancelDelete:()=>x(null),onConfirmDelete:L=>R.mutate({name:L})})}async function L_(e,t,n){var r,i;(r=e.onPending)==null||r.call(e,!0);try{await e.set({section:"settings",value:{[t]:n}}),await e.refresh()}catch(s){e.onError(s instanceof Error?s.message:String(s))}finally{(i=e.onPending)==null||i.call(e,!1)}}const Xf="'IBM Plex Mono',monospace",fl={display:"flex",alignItems:"center",gap:12,padding:"10px 14px",borderBottom:"1px solid var(--proto-alt)"},Jf={fontSize:12,fontWeight:600,color:"var(--proto-ink)"},Zf={fontSize:10.5,color:"var(--proto-muted-2)",marginTop:1},eh={font:`400 9px ${Xf}`,color:"var(--proto-faint)",flex:"none"};function o6(){const e=B(),t=ae(),n=je(),{toast:r}=Tn(),[i,s]=f.useState(!1),a=f.useRef(!1),l=ue(t.config.set.mutationOptions()),c=i||l.isPending,d=p=>{a.current=p,s(p)};return{pending:c,onToggle:(p,h)=>{a.current||l.isPending||L_({set:g=>l.mutateAsync(g),refresh:()=>n.invalidateQueries(t.config.get.queryFilter({})),onError:g=>r({title:`${e.stToastWriteFailed}: ${g}`,tone:"failed"}),onPending:d},p,h)}}}function i6(e){const t=e.source&&!e.pending?()=>e.onToggle(e.settingKey,!e.value):void 0;return o.jsxs("div",{"data-setting-key":e.settingKey,"data-setting-value":e.source?String(e.value):"missing","data-setting-source":e.source??"missing",style:fl,children:[o.jsx(Yf,{on:e.value,onClick:t,inert:!t}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:Jf,children:e.title}),o.jsx("div",{style:Zf,children:e.desc})]}),o.jsx("span",{style:eh,children:`settings.${e.settingKey} · ${e.source??"—"}`})]})}function O_({descriptors:e,settings:t,pending:n,onToggle:r,threshold:i}){const s=B();return e.map(a=>{const l=pl(t,a.setting),c=typeof(l==null?void 0:l.value)=="boolean"?l.value:!1,d=a.setting==="turnNotify"&&i!==void 0?` · ${i}s`:"";return o.jsx(i6,{settingKey:a.setting,value:c,source:typeof(l==null?void 0:l.value)=="boolean"?l.source:null,title:s[a.titleKey],desc:`${s[a.descKey]}${d}`,pending:n,onToggle:r},a.setting)})}function D_({snapshot:e,settings:t}){var s,a;const n=B(),r=(s=pl(t,"adminChannel"))==null?void 0:s.value,i=(a=pl(t,"feishuAdminChannel"))==null?void 0:a.value;return o.jsxs(He,{style:{marginTop:12},children:[o.jsx(_n,{title:n.stNotifyRoutingTitle,right:n.stNotifyRoutingRight}),o.jsx(wj,{platform:"Slack",glyph:"S",present:ul(e.env,"SLACK_"),setting:"adminChannel",channel:typeof r=="string"?r:null}),o.jsx(wj,{platform:"飞书",glyph:"飞",present:ul(e.env,"FEISHU_"),setting:"feishuAdminChannel",channel:typeof i=="string"?i:null,last:!0})]})}function wj(e){return o.jsxs("div",{style:{...fl,gap:10,borderBottom:e.last?void 0:fl.borderBottom},children:[o.jsx(wm,{glyph:e.glyph}),o.jsx("span",{style:{fontSize:11.5,fontWeight:600,color:"var(--proto-ink)"},children:e.platform}),o.jsx(jm,{present:e.present}),o.jsxs("span",{style:{marginLeft:"auto",font:`400 9.5px ${Xf}`,color:"var(--proto-muted-2)"},children:[`settings.${e.setting}: `,o.jsx("span",{style:{color:e.channel?"var(--proto-muted)":"var(--proto-faint)"},children:e.channel??"—"})]})]})}function A_(){const e=B();return o.jsxs("div",{style:{marginTop:12,display:"flex",alignItems:"center",gap:8,padding:"9px 12px",background:"var(--proto-amber-bg)",border:"1px solid var(--proto-amber-border)",borderRadius:9,maxWidth:760,boxSizing:"border-box"},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-amber)",flex:"none"}}),o.jsx("span",{style:{fontSize:10.5,color:"var(--proto-amber-fg)"},children:e.stApprovalReminderNote})]})}function N_(){const e=B();return o.jsxs(He,{style:{marginTop:12,maxWidth:760},children:[o.jsx(_n,{title:e.stRecentNotifications,right:e.stRecentNotifRight}),o.jsxs("div",{style:{padding:"10px 14px",display:"flex",alignItems:"flex-start",gap:8},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-line-3)",flex:"none",marginTop:5}}),o.jsx("span",{style:{fontSize:10.5,color:"var(--proto-muted-3)",lineHeight:1.6},children:e.stRecentNotifNote})]})]})}function $_({snapshot:e,pending:t,onToggle:n}){const r=t6(e.settings),i=pl(r,"turnNotifyThresholdS"),s=typeof(i==null?void 0:i.value)=="number"?i.value:void 0;return o.jsxs(o.Fragment,{children:[o.jsx(He,{children:o.jsx(O_,{descriptors:g_,settings:r,pending:t,onToggle:n,threshold:s})}),o.jsx(D_,{snapshot:e,settings:r}),o.jsx(A_,{}),o.jsx(N_,{})]})}function __({snapshot:e}){const t=o6();return o.jsx($_,{snapshot:e,pending:t.pending,onToggle:t.onToggle})}function F_({snapshot:e,title:t,desc:n}){var i;const r=((i=$0(e.env).DEBUG)==null?void 0:i.present)===!0;return o.jsxs("div",{"data-env-key":"DEBUG","data-env-present":String(r),"data-writable":"false",style:fl,children:[o.jsx(Yf,{on:r,inert:!0}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:Jf,children:t}),o.jsx("div",{style:Zf,children:n})]}),o.jsx("span",{style:eh,children:"DEBUG"})]})}function z_(e){const t=B();return x_.map(n=>{if(n.kind==="env")return o.jsx(F_,{snapshot:e.snapshot,title:t[n.titleKey],desc:t[n.descKey]},n.env);const r=pl(e.settings,n.setting);return o.jsx(i6,{settingKey:n.setting,value:typeof(r==null?void 0:r.value)=="boolean"?r.value:!1,source:typeof(r==null?void 0:r.value)=="boolean"?r.source:null,title:t[n.titleKey],desc:t[n.descKey],pending:e.pending,onToggle:e.onToggle},n.setting)})}function B_({settings:e}){const t=B(),n=pl(e,"taskDispatchMaxConcurrent"),r=typeof(n==null?void 0:n.value)=="number"?n.value:(n==null?void 0:n.value)===null?null:void 0;return o.jsxs("div",{"data-setting-key":"taskDispatchMaxConcurrent","data-setting-value":r===void 0?"missing":String(r),style:fl,children:[o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:Jf,children:t.advConc}),o.jsx("div",{style:Zf,children:t.stAdvConcNote})]}),o.jsx("span",{style:{font:`500 10.5px ${Xf}`,color:r===void 0?"var(--proto-faint)":"var(--proto-ink)",border:"1px solid var(--proto-line)",borderRadius:7,padding:"4px 11px"},children:typeof r=="number"?r:r===null?t.stAuto:"—"}),o.jsx("span",{style:eh,children:`settings.taskDispatchMaxConcurrent · ${(n==null?void 0:n.source)??"—"}`})]})}function W_({snapshot:e}){var r;const t=B(),n=((r=$0(e.env).CORTEX_GPU_MONITOR_MOCK)==null?void 0:r.present)===!0;return o.jsxs("div",{style:{...fl,borderBottom:void 0},children:[o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:Jf,children:t.stGpuMock}),o.jsx("div",{style:Zf,children:t.advMock})]}),o.jsx("span",{style:{font:`400 10.5px ${Xf}`,color:"var(--proto-faint)",border:"1px dashed var(--proto-line-3)",borderRadius:7,padding:"4px 11px"},children:n?t.stSet:"—"}),o.jsx("span",{style:eh,children:"CORTEX_GPU_MONITOR_MOCK"})]})}function U_({snapshot:e,pending:t,onToggle:n}){const r=t6(e.settings);return o.jsxs(He,{style:{marginTop:12,maxWidth:760},children:[o.jsx(z_,{snapshot:e,settings:r,pending:t,onToggle:n}),o.jsx(B_,{settings:r}),o.jsx(W_,{snapshot:e})]})}function H_({snapshot:e}){const t=o6();return o.jsx(U_,{snapshot:e,pending:t.pending,onToggle:t.onToggle})}const q_=[5,10,20,50],V_=[100,200,500,1e3],K_=[60,80,90];function kj(e,t){var n;return t?((n=e==null?void 0:e.projects)==null?void 0:n[t])!=null:!1}function Q_(e,t){var r;const n=t?(r=e==null?void 0:e.projects)==null?void 0:r[t]:void 0;return n?{daily:n.daily_usd,monthly:n.monthly_usd,inherited:!1}:{daily:(e==null?void 0:e.daily_usd)??null,monthly:(e==null?void 0:e.monthly_usd)??null,inherited:t!=null}}function Sm(e){return e!=null&&Number.isFinite(e)&&e>0}function G_(e,t){const n=t.daily??e.daily,r=t.monthly??e.monthly;return!Sm(n)||!Sm(r)?null:{daily_usd:n,monthly_usd:r}}function Y_(e,t){return e?{section:"budget",project:e,value:t}:{section:"budget",value:t}}function X_(e){return{section:"budget",project:e}}function J_(e){const t=e.replace(/[$,\s]/g,"");if(t===""||!/^\d*\.?\d+$/.test(t))return null;const n=Number(t);return Sm(n)?n:null}function Z_(e,t){return e===t}function Qi(e){return e==null||!Number.isFinite(e)?"—":Number.isInteger(e)?"$"+e:"$"+e.toFixed(2)}function Cm(e,t){if(t==null||!Number.isFinite(t)||t<=0)return"0%";const n=Math.max(0,Math.min(100,e/t*100));return Math.round(n)+"%"}const cc="'IBM Plex Mono',monospace",eF={font:`500 10.5px ${cc}`,borderRadius:7,padding:"4px 11px"};function Pu(e){return{...eF,fontWeight:e?600:500,color:e?"var(--proto-accent)":"var(--proto-muted)",background:e?"var(--proto-accent-bg)":"var(--proto-card)",border:"1px solid "+(e?"var(--proto-accent-border)":"var(--proto-line)"),cursor:"pointer"}}const Sj=[{titleKey:"stPolicyPauseTitle",descKey:"stPolicyPauseDesc",def:!0},{titleKey:"stPolicyWarnTitle",descKey:"stPolicyWarnDesc",def:!1},{titleKey:"stPolicyStopTitle",descKey:"stPolicyStopDesc",def:!1}],hg={fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)"};function tF({snapshot:e,cost:t}){const n=B(),r=ae(),i=je(),{toast:s}=Tn(),a=e.budget,[l,c]=f.useState(null),[d,u]=f.useState(""),p=G(r.projects.list.queryOptions({})).data??[],h=G({...r.cost.summary.queryOptions({projectId:l??void 0}),enabled:l!=null}),g=l==null?t:h.data,v=Q_(a,l),x=kj(a,l),w=(g==null?void 0:g.today)??0,b=(g==null?void 0:g.month)??0;f.useEffect(()=>u(""),[l]);const y=ue(r.config.set.mutationOptions({onSuccess:()=>{i.invalidateQueries(r.config.get.queryFilter({})),i.invalidateQueries(r.cost.summary.queryFilter())}})),j=(C,R)=>{const P=G_(v,C);if(!P){s({title:n.stBudgetWriteError,tone:"waiting"});return}y.mutate(Y_(l,P),{onSuccess:()=>s({title:`${R} · ${n.stToastBudgetWritten}`,tone:"done"}),onError:L=>s({title:`${n.stToastWriteFailed}: ${L.message}`,tone:"failed"})})},S=C=>{const R=J_(d);if(R==null){s({title:n.stBudgetAmountInvalid,tone:"waiting"});return}u(""),j({[C]:R},`${C==="daily"?n.stDaily:n.stMonthly} → ${Qi(R)}`)},k=()=>{l&&y.mutate(X_(l),{onSuccess:()=>s({title:`${l} · ${n.stToastBudgetCleared}`,tone:"done"}),onError:C=>s({title:`${n.stToastWriteFailed}: ${C.message}`,tone:"failed"})})},E=(C,R,P,L,_)=>o.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid var(--proto-alt)",display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[o.jsxs("div",{style:{width:104,flex:"none"},children:[o.jsx("div",{style:hg,children:R}),o.jsx("div",{style:{font:`600 19px ${cc}`,color:v.inherited?"var(--proto-muted-2)":"var(--proto-ink)",letterSpacing:"-.02em",marginTop:2},"data-budget-limit":C,children:Qi(P)})]}),o.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:L.map(U=>o.jsx("span",{onClick:()=>j({[C]:U},`${R} → ${Qi(U)}`),role:"button","data-budget-chip":`${C}-${U}`,style:{...Pu(!v.inherited&&Z_(P,U)),opacity:y.isPending?.6:1},children:"$"+U},U))}),o.jsxs("div",{style:{display:"flex",gap:6,marginLeft:"auto",alignItems:"center"},children:[o.jsx("input",{value:d,onChange:U=>u(U.target.value),onKeyDown:U=>{U.key==="Enter"&&S(C)},placeholder:n.stBudgetCustomPlaceholder,"data-budget-input":C,style:{...$e,width:88}}),o.jsx(Qe,{tone:"neutral",disabled:d.trim()==="",onClick:()=>S(C),children:n.stApply})]})]});return o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1.2fr 1fr",gap:12,marginTop:12,alignItems:"start",maxWidth:980},"data-settings-panel":"budget",children:[o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[o.jsxs(He,{children:[o.jsx(_n,{title:n.stLimits,right:n.stBudgetScopeNote}),o.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid var(--proto-alt)",display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[o.jsx("div",{style:{width:104,flex:"none",...hg},children:n.stBudgetScope}),o.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[o.jsx("span",{onClick:()=>c(null),role:"button","data-budget-scope":"global",style:Pu(l==null),children:n.stBudgetScopeGlobal}),p.map(C=>o.jsxs("span",{onClick:()=>c(C.id),role:"button","data-budget-scope":C.id,style:Pu(l===C.id),children:[C.id,kj(a,C.id)?" •":""]},C.id))]})]}),v.inherited?o.jsx("div",{style:{padding:"8px 14px",borderBottom:"1px solid var(--proto-alt)",fontSize:10.5,color:"var(--proto-muted-2)"},"data-budget-inherited":!0,children:n.stBudgetInherited}):null,E("daily",n.stDaily,v.daily,q_),E("monthly",n.stMonthly,v.monthly,V_),o.jsxs("div",{style:{padding:"12px 14px",display:"flex",alignItems:"center",gap:12},children:[o.jsxs("div",{style:{width:104,flex:"none"},children:[o.jsx("div",{style:hg,children:n.stWarnAt}),o.jsx("div",{style:{font:`600 19px ${cc}`,color:"var(--proto-faint)",letterSpacing:"-.02em",marginTop:2},children:"—"})]}),o.jsx("div",{style:{display:"flex",gap:6},children:K_.map(C=>o.jsx("span",{title:"No warn-threshold field in budget.json — inert",style:{...Pu(!1),cursor:"not-allowed",color:"var(--proto-faint)"},children:C+"%"},C))}),o.jsx("span",{style:{marginLeft:"auto",fontSize:10.5,color:"var(--proto-muted-2)"},children:n.warnNote})]}),x?o.jsxs("div",{style:{padding:"10px 14px",borderTop:"1px solid var(--proto-alt)",display:"flex",alignItems:"center",gap:10},children:[o.jsx("span",{style:{fontSize:10.5,color:"var(--proto-muted-2)",flex:1},children:n.stBudgetClearHint}),o.jsx(Qe,{tone:"danger",onClick:k,"data-budget-clear":!0,children:n.stBudgetClear})]}):null]}),o.jsxs(He,{children:[o.jsx(_n,{title:n.stOverBudgetBehavior,right:n.obNote}),o.jsx("div",{style:{padding:"4px 14px 8px"},children:Sj.map((C,R)=>o.jsxs("div",{title:"No over-budget-policy field in budget.json — inert",style:{display:"flex",alignItems:"flex-start",gap:10,padding:"9px 0",borderBottom:R<Sj.length-1?"1px solid var(--proto-alt)":void 0,cursor:"not-allowed"},children:[o.jsx(e6,{selected:!1}),o.jsxs("div",{style:{flex:1},children:[o.jsxs("div",{style:{fontSize:12,fontWeight:600,color:"var(--proto-muted)"},children:[n[C.titleKey],C.def?o.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"1px 6px",borderRadius:999,background:"var(--proto-accent-bg)",color:"var(--proto-accent)",marginLeft:4},children:n.default}):null]}),o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-muted-2)",marginTop:2},children:n[C.descKey]})]})]},C.titleKey))})]})]}),o.jsxs(He,{children:[o.jsx(_n,{title:n.stCurrentSpend,right:l??n.stBudgetScopeGlobal}),o.jsxs("div",{style:{padding:"12px 14px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[o.jsx("span",{style:{font:`600 21px ${cc}`,color:"var(--proto-ink)",letterSpacing:"-.02em"},children:Qi(w)}),o.jsxs("span",{style:{fontSize:11,color:"var(--proto-muted-3)"},children:["/ ",Qi(v.daily)]})]}),o.jsx("div",{style:{height:5,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden",marginTop:8,position:"relative"},children:o.jsx("div",{style:{width:Cm(w,v.daily),height:"100%",background:"var(--proto-accent)"}})}),o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,marginTop:14},children:[o.jsx("span",{style:{font:`600 14px ${cc}`,color:"var(--proto-ink-2)"},children:Qi(b)}),o.jsxs("span",{style:{fontSize:10.5,color:"var(--proto-muted-3)"},children:[n.month," / ",Qi(v.monthly)]})]}),o.jsx("div",{style:{height:5,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden",marginTop:7},children:o.jsx("div",{style:{width:Cm(b,v.monthly),height:"100%",background:"var(--proto-accent-2)"}})}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,background:"var(--proto-amber-bg)",border:"1px solid var(--proto-amber-border)",borderRadius:8,padding:"7px 10px",marginTop:13},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-amber)",flex:"none"}}),o.jsx("span",{style:{fontSize:10.5,color:"var(--proto-amber-fg)"},children:n.stObNote})]}),o.jsx("div",{style:{fontSize:10,color:"var(--proto-faint)",marginTop:10},children:n.stBudgetFootNote})]})]})]})}const s6=["all","agent","claude","pi","server","template"];function nF(e,t){switch(t){case"all":return!0;case"agent":return e.event.startsWith("agent:");case"claude":return e.mountsOn.includes("claude");case"pi":return e.mountsOn.includes("pi");case"server":return e.mountsOn.includes("server");case"template":return e.source==="template-scoped"}}function rF(e){return[e.id,e.event,e.fileName??"",e.run.script??"",e.run.command??"",e.matcher??"",e.template??"",e.source].join(`
|
|
118
|
+
`).toLowerCase()}function F0(e,t,n){const r=n.trim().toLowerCase();return e.filter(i=>nF(i,t)&&(r===""||rF(i).includes(r)))}function oF(e,t){const n={};for(const r of s6)n[r]=F0(e,r,t).length;return n}const iF=["agent","cc","pi","cortex","template"];function sF(e){return e.source==="template-scoped"?"template":e.event.startsWith("agent:")?"agent":e.event.startsWith("cc:")?"cc":e.event.startsWith("pi:")?"pi":"cortex"}function aF(e){const t=new Map;for(const r of e){const i=sF(r),s=t.get(i);s?s.push(r):t.set(i,[r])}const n=[];for(const r of iF){const i=t.get(r);!i||i.length===0||n.push({key:r,hooks:[...i].sort((s,a)=>s.order-a.order||s.id.localeCompare(a.id))})}return n}function lF(e,t,n){var r,i;return n!==null&&e.some(s=>s.id===n)?n:((r=t[0])==null?void 0:r.id)??((i=e[0])==null?void 0:i.id)??null}function cF(e){if(e.source==="template-scoped")return{canToggle:!1,canEdit:!1,canDelete:!1,canTest:!0,note:"template-scoped"};if(e.source==="managed")return{canToggle:!0,canEdit:!1,canDelete:!1,canTest:!0,note:"managed"};const t=e.editable;return{canToggle:!0,canEdit:t,canDelete:t,canTest:!0,note:null}}const dF={"agent:session-end":"cc:SessionEnd","agent:pre-compact":"cc:PreCompact","agent:user-prompt":"cc:UserPromptSubmit","agent:turn-end":"cc:Stop"};function uF(e){return e.event.startsWith("agent:")&&!e.mountsOn.includes("claude")}function pF(e){return dF[e]??null}const fF={"cortex:thread.start":"hook-result","cortex:thread.transition":"hook-result","cortex:thread.end":"hook-result","cortex:session.new":"stdout-as-prompt","cortex:session.messageEnd":"stdout-as-prompt"};function _d(e){const t=fF[e];return t?["none",t]:["none"]}function hF(e){return _d(e).length===1}function gF(e,t){return _d(t).includes(e)?e:"none"}function th(e){return e.startsWith("cortex:")?"filters":"regex"}function a6(e){if(e.trim()==="")return null;try{return new RegExp(e),null}catch(t){return t instanceof Error?t.message:String(t)}}function l6(e){const t=e.trim();if(t==="")return"";try{const n=JSON.parse(t);if(n===null||typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n}catch{}return e}function xF(e){return typeof e=="string"&&l6(e)===e?e:JSON.stringify(e)}function mF(e){const t={};let n=!1;for(const r of e){const i=r.key.trim();i!==""&&(t[i]=l6(r.value),n=!0)}return n?t:null}function c6(e){var t,n;return{id:e.id,event:e.event,matcher:e.matcher??"",filters:e.matcherFilters?Object.entries(e.matcherFilters).map(([r,i])=>({key:r,value:xF(i)})):[],runKind:e.run.command!==null?"command":"script",script:e.run.script??"",command:e.run.command??"",timeoutSec:e.run.timeoutSec==null?"":String(e.run.timeoutSec),backends:(t=e.scope)!=null&&t.backends?[...e.scope.backends]:[],requiresTool:((n=e.scope)==null?void 0:n.requiresTool)??"",result:e.result??"none",enabled:e.enabled}}function Iu(){return{id:"",event:"agent:pre-tool",matcher:"",filters:[],runKind:"script",script:"",command:"",timeoutSec:"",backends:[],requiresTool:"",result:"none",enabled:!0}}function Cj(e){return JSON.stringify({id:e.id.trim(),event:e.event.trim(),matcher:e.matcher,filters:e.filters.map(t=>[t.key,t.value]),runKind:e.runKind,script:e.script,command:e.command,timeoutSec:e.timeoutSec,backends:[...e.backends].sort(),requiresTool:e.requiresTool,result:e.result,enabled:e.enabled})}function vF(e,t){return Cj(e)!==Cj(c6(t))}function yF(e,t){const n={};if(t.mode==="create"){const a=e.id.trim();a===""?n.id="id-required":(t.existingIds??[]).includes(a)&&(n.id="id-taken")}const r=e.event.trim();if(r===""&&(n.event="event-required"),th(r)==="regex")a6(e.matcher)!==null&&(n.matcher="matcher-invalid");else{const a=e.filters.map(l=>l.key.trim());a.some(l=>l==="")?n.filters="filters-empty-key":new Set(a).size!==a.length&&(n.filters="filters-duplicate-key")}(e.runKind==="script"?e.script.trim():e.command.trim())===""&&(n.run="run-required");const s=e.timeoutSec.trim();if(s!==""){const a=Number(s);(!Number.isFinite(a)||a<=0)&&(n.timeoutSec="timeout-invalid")}return _d(r).includes(e.result)||(n.result="result-illegal"),n}function bF(e){return Object.keys(e).length===0}function d6(e){const t=e.event.trim(),n={event:t};if(th(t)==="regex"){const s=e.matcher.trim();s!==""&&(n.matcher=s)}else{const s=mF(e.filters);s!==null&&(n.matcherFilters=s)}if(e.runKind==="script"){const s=e.script.trim();s!==""&&(n.script=s)}else{const s=e.command.trim();s!==""&&(n.command=s)}const r=e.timeoutSec.trim();if(r!==""){const s=Number(r);Number.isFinite(s)&&s>0&&(n.timeoutSec=s)}e.backends.length>0&&(n.backends=[...e.backends]);const i=e.requiresTool.trim();return i!==""&&(n.requiresTool=i),e.result!=="none"&&_d(t).includes(e.result)&&(n.result=e.result),n.enabled=e.enabled,n}function jF(e){return{id:e.id.trim(),...d6(e)}}function wF(e){return{id:e.id.trim(),...d6(e)}}const Tj=["agent:pre-tool","agent:post-tool","agent:session-start","agent:session-end","agent:pre-compact","agent:user-prompt","agent:turn-end","cc:PreToolUse","cc:PostToolUse","cc:SessionStart","cc:SessionEnd","cc:PreCompact","cc:UserPromptSubmit","cc:Stop","cc:PermissionRequest","pi:tool_call","pi:tool_result","pi:session_start","pi:session_shutdown","pi:before_provider_headers","cortex:server.start","cortex:server.shutdown","cortex:thread.start","cortex:thread.transition","cortex:thread.end","cortex:dispatch.started","cortex:schedule.fired","cortex:task.completed","cortex:task.blocked","cortex:client.connected","cortex:client.disconnected","cortex:session.new","cortex:session.messageEnd"];function kF(e){const t=new Set(Tj),n=new Set(e.map(r=>r.event).filter(r=>!t.has(r)));return[...Tj,...n]}const Ej={channel:"C0000000",sessionId:"sess_example",sessionName:"cortex-0000",executionId:"exec_example",profile:"default",timestampIso:"2026-01-01T00:00:00.000Z"},gg={threadId:"thr_example",templateName:"example",source:"task-dispatch",project:"my-project",projectId:"my-project",taskId:"0000",currentStepIndex:0,activeAgent:"executor"},Mu={hook_event_name:"PreToolUse",session_id:"sess_example",cwd:"/tmp",tool_name:"Edit",tool_input:{file_path:"/tmp/example.txt",new_string:"example"}},SF={"agent:pre-tool":Mu,"cc:PreToolUse":Mu,"pi:tool_call":Mu,"agent:post-tool":{...Mu,hook_event_name:"PostToolUse",tool_response:{success:!0},is_error:!1},"agent:session-start":{hook_event_name:"SessionStart",session_id:"sess_example",cwd:"/tmp",source:"startup"},"agent:session-end":{hook_event_name:"SessionEnd",session_id:"sess_example",cwd:"/tmp"},"agent:pre-compact":{hook_event_name:"PreCompact",session_id:"sess_example",cwd:"/tmp"},"agent:user-prompt":{hook_event_name:"UserPromptSubmit",session_id:"sess_example",cwd:"/tmp",prompt:"example prompt"},"agent:turn-end":{hook_event_name:"Stop",session_id:"sess_example",cwd:"/tmp"},"cortex:server.start":{version:"0.0.0",pid:0},"cortex:server.shutdown":{version:"0.0.0",pid:0,reason:"SIGTERM"},"cortex:thread.start":{...gg,phase:"start"},"cortex:thread.transition":{...gg,phase:"transition"},"cortex:thread.end":{...gg,phase:"end"},"cortex:dispatch.started":{taskId:"0000",project:"my-project",source:"task-dispatch",templateName:"example"},"cortex:schedule.fired":{scheduleId:"sch_example",name:"example",project:"my-project"},"cortex:task.completed":{taskId:"0000",project:"my-project"},"cortex:task.blocked":{taskId:"0000",project:"my-project",reason:"example reason"},"cortex:client.connected":{device:"workstation"},"cortex:client.disconnected":{device:"workstation",reason:"socket closed"},"cortex:session.new":{...Ej,trigger:"new"},"cortex:session.messageEnd":{...Ej,trigger:"messageEnd"}};function u6(e){const t=SF[e];return t!==void 0?JSON.stringify(t,null,2):e.startsWith("cc:")?JSON.stringify({hook_event_name:e.slice(3),session_id:"sess_example",cwd:"/tmp"},null,2):e.startsWith("pi:")?JSON.stringify({event:e.slice(3),session_id:"sess_example"},null,2):JSON.stringify({hook_event_name:e},null,2)}function Rj(e){if(e.trim()==="")return!1;try{return JSON.parse(e),!0}catch{return!1}}const at="'IBM Plex Mono',monospace",CF=288,TF={claude:{bg:"var(--proto-accent-bg)",fg:"var(--proto-accent)"},pi:{bg:"var(--proto-success-bg)",fg:"var(--proto-success)"},server:{bg:"var(--proto-amber-bg)",fg:"var(--proto-amber)"}},EF={all:"hkFilterAll",agent:"hkFilterAgent",claude:"hkFilterClaude",pi:"hkFilterPi",server:"hkFilterServer",template:"hkFilterTemplate"},RF={"id-required":"hkErrIdRequired","id-taken":"hkErrIdTaken","event-required":"hkErrEventRequired","matcher-invalid":"hkMatcherInvalid","filters-empty-key":"hkErrFiltersEmptyKey","filters-duplicate-key":"hkErrFiltersDuplicate","run-required":"hkErrRunRequired","timeout-invalid":"hkErrTimeout","result-illegal":"hkErrResult"},Pj="cortex-hook-scripts",Ij="cortex-hook-events";function p6({target:e}){const t=TF[e];return o.jsx("span",{"data-hook-mount":e,style:{font:`600 8.5px ${at}`,padding:"1px 5px",borderRadius:999,background:t.bg,color:t.fg,flex:"none"},children:e})}function PF({source:e}){const t=e==="managed";return o.jsx("span",{"data-hook-source":e,style:{font:`600 9px ${at}`,padding:"1px 6px",borderRadius:999,background:t?"var(--proto-line-2)":"var(--proto-alt)",color:"var(--proto-muted)",flex:"none"},children:e})}function dc({tone:e,children:t,...n}){const r={amber:{bg:"var(--proto-amber-bg)",border:"var(--proto-amber-border)",fg:"var(--proto-amber-fg)"},accent:{bg:"var(--proto-accent-bg)",border:"var(--proto-accent-border)",fg:"var(--proto-accent)"},danger:{bg:"var(--proto-danger-bg)",border:"var(--proto-danger-bg)",fg:"var(--proto-danger)"}}[e];return o.jsxs("div",{...n,style:{display:"flex",alignItems:"flex-start",gap:7,padding:"7px 10px",borderRadius:8,background:r.bg,border:`1px solid ${r.border}`,marginTop:10},children:[o.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:r.fg,flex:"none",marginTop:5}}),o.jsx("span",{style:{fontSize:10.5,lineHeight:1.6,color:r.fg,minWidth:0},children:t})]})}function Mj({children:e}){return o.jsx("span",{style:{font:`500 10px ${at}`,color:"var(--proto-ink-2)"},children:e})}function IF({hook:e,selected:t,onSelect:n}){const r=B(),i=e.scriptExists===!1;return o.jsxs("div",{"data-hook-row":e.id,"data-hook-active":t?"":void 0,onClick:()=>n(e.id),role:"button",style:{display:"flex",alignItems:"flex-start",gap:7,padding:"7px 9px",borderRadius:8,background:t?"var(--proto-accent-bg)":"transparent",cursor:"pointer"},children:[o.jsx("span",{"data-hook-order":e.order,style:{font:`500 9.5px ${at}`,color:"var(--proto-faint)",flex:"none",paddingTop:1},children:String(e.order).padStart(2,"0")}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5},children:[o.jsx("span",{style:{font:`600 10.5px ${at}`,color:t?"var(--proto-accent)":"var(--proto-ink-2)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.id}),i?o.jsx("span",{"data-hook-broken":"",title:r.hkScriptMissing,style:{font:`600 8.5px ${at}`,padding:"0 5px",borderRadius:999,background:"var(--proto-danger-bg)",color:"var(--proto-danger)",flex:"none"},children:r.hkBroken}):null]}),o.jsx("div",{style:{font:`400 9.5px ${at}`,color:"var(--proto-muted-2)",marginTop:2,overflowWrap:"anywhere"},children:e.event}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginTop:4},children:[e.mountsOn.map(s=>o.jsx(p6,{target:s},s)),o.jsx("span",{style:{marginLeft:"auto",fontSize:9,fontWeight:650,color:e.enabled?"var(--proto-success)":"var(--proto-muted-2)",flex:"none"},children:e.enabled?r.stHookEnabled:r.stHookDisabled})]})]})]})}function MF({hooks:e,visible:t,filter:n,search:r,selectedId:i,onFilter:s,onSearch:a,onSelect:l,onStartCreate:c}){const d=B(),u=oF(e,r),p=aF(t);return o.jsxs(He,{style:{width:CF,flex:"none",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"9px 10px 7px",borderBottom:"1px solid var(--proto-line-2)",flex:"none"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[o.jsx("span",{style:{fontSize:11.5,fontWeight:650,color:"var(--proto-ink)"},children:d.stAgentHooks}),o.jsx("span",{style:{font:`400 9.5px ${at}`,color:"var(--proto-faint)"},children:e.length})]}),o.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:s6.map(h=>{const g=h===n;return o.jsxs("span",{onClick:()=>s(h),role:"button","data-hook-filter":h,"data-active":g?"":void 0,style:{font:`500 9.5px ${at}`,padding:"2px 7px",borderRadius:6,cursor:"pointer",color:g?"var(--proto-accent)":"var(--proto-muted-2)",background:g?"var(--proto-accent-bg)":"transparent",border:`1px solid ${g?"var(--proto-accent-border)":"var(--proto-line-2)"}`},children:[d[EF[h]],o.jsx("span",{style:{color:"var(--proto-faint)",marginLeft:4},children:u[h]})]},h)})}),o.jsx("input",{"data-hook-search":"",value:r,onChange:h=>a(h.target.value),placeholder:d.hkSearchPh,style:{...$e,marginTop:7,padding:"4px 8px"}})]}),o.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"4px 6px"},children:e.length===0||t.length===0?o.jsx("div",{"data-hooks-empty":"",style:{padding:"14px 8px",fontSize:10.5,color:"var(--proto-faint)",lineHeight:1.7},children:e.length===0?d.stNoHooks:d.hkNoMatch}):p.map(h=>o.jsxs("div",{style:{marginBottom:4},children:[o.jsx("div",{"data-hook-group":h.key,style:{font:`600 9px ${at}`,letterSpacing:".05em",color:"var(--proto-muted-3)",padding:"7px 9px 3px"},children:h.key==="template"?"template":`${h.key}:`}),h.hooks.map(g=>o.jsx(IF,{hook:g,selected:g.id===i,onSelect:l},g.id))]},h.key))}),o.jsxs("div",{style:{flex:"none",borderTop:"1px solid var(--proto-line-2)",padding:"8px 10px",display:"flex",alignItems:"center",gap:8},children:[o.jsxs("span",{"data-action":"create",onClick:c,role:"button",style:{fontSize:11,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer",flex:"none"},children:["+ ",d.hkCreate]}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9px ${at}`,color:"var(--proto-faint)"},children:d.hkOrderNote})]})]})}function LF({hook:e}){var r,i,s;const t=B(),n=[{k:t.hkFieldEvent,v:e.event},{k:th(e.event)==="filters"?t.hkFieldFilters:t.hkFieldMatcher,v:e.matcherFilters?JSON.stringify(e.matcherFilters):e.matcher??t.hkNoMatcher},{k:e.run.command!==null?t.hkFieldCommand:t.hkFieldScript,v:e.run.command??e.run.script??"—"},{k:t.hkFieldTimeout,v:e.run.timeoutSec==null?"—":`${e.run.timeoutSec}s`},{k:t.hkFieldBackends,v:((i=(r=e.scope)==null?void 0:r.backends)==null?void 0:i.join(" · "))??t.hkUnscoped},{k:t.hkFieldRequiresTool,v:((s=e.scope)==null?void 0:s.requiresTool)??"—"},{k:t.hkFieldResult,v:e.result??"none"}];return e.template!==null&&n.push({k:t.hkFieldTemplate,v:`${e.template} · ${e.phase??"—"}`}),o.jsx("div",{style:{font:`400 10px/2 ${at}`,color:"var(--proto-muted)",marginTop:4},children:n.map(a=>o.jsx(Yn,{k:a.k,value:a.v},a.k))})}function OF({draft:e,onDraftChange:t}){const n=B(),r=e.filters,i=s=>t({...e,filters:s});return o.jsxs("div",{"data-hook-filters-editor":"",children:[r.map((s,a)=>o.jsxs("div",{style:{display:"flex",gap:5,marginBottom:4},children:[o.jsx("input",{"data-hook-filter-key":a,value:s.key,placeholder:n.hkFilterKeyPh,onChange:l=>i(r.map((c,d)=>a===d?{...c,key:l.target.value}:c)),style:{...$e,flex:1}}),o.jsx("input",{"data-hook-filter-value":a,value:s.value,placeholder:n.hkFilterValuePh,onChange:l=>i(r.map((c,d)=>a===d?{...c,value:l.target.value}:c)),style:{...$e,flex:1}}),o.jsx("span",{"data-hook-filter-remove":a,onClick:()=>i(r.filter((l,c)=>c!==a)),role:"button",title:n.hkRemoveFilter,style:{font:`500 11px ${at}`,color:"var(--proto-muted-3)",cursor:"pointer",padding:"5px 6px",flex:"none"},children:"×"})]},a)),o.jsxs("span",{"data-action":"add-filter",onClick:()=>i([...r,{key:"",value:""}]),role:"button",style:{fontSize:10.5,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:["+ ",n.hkAddFilter]})]})}function DF({draft:e,creating:t,errors:n,scripts:r,eventOptions:i,onDraftChange:s}){const a=B(),l=h=>h?a[RF[h]]:void 0,c=th(e.event),d=c==="regex"?a6(e.matcher):null,u=_d(e.event),p=hF(e.event);return o.jsxs(o.Fragment,{children:[o.jsx(uo,{children:a.hkSecTrigger}),t?o.jsx(et,{label:a.hkFieldId,hint:l(n.id),hintTone:"danger",children:o.jsx("input",{"data-hook-field":"id",value:e.id,onChange:h=>s({...e,id:h.target.value}),style:$e})}):null,o.jsxs(et,{label:a.hkFieldEvent,hint:l(n.event),hintTone:"danger",children:[o.jsx("input",{"data-hook-field":"event",list:Ij,value:e.event,onChange:h=>{const g=h.target.value;s({...e,event:g,result:gF(e.result,g)})},style:$e}),o.jsx("datalist",{id:Ij,children:i.map(h=>o.jsx("option",{value:h},h))})]}),c==="regex"?o.jsx(et,{label:a.hkFieldMatcher,hint:d?`${a.hkMatcherInvalid} — ${d}`:a.hkMatcherRegexHint,hintTone:d?"danger":"muted",children:o.jsx("input",{"data-hook-field":"matcher","data-hook-matcher-error":d?"":void 0,value:e.matcher,placeholder:a.hkNoMatcher,onChange:h=>s({...e,matcher:h.target.value}),style:d?{...$e,borderColor:"var(--proto-danger)"}:$e})}):o.jsx(et,{label:a.hkFieldFilters,hint:l(n.filters)??a.hkMatcherFiltersHint,hintTone:n.filters?"danger":"muted",children:o.jsx(OF,{draft:e,onDraftChange:s})}),o.jsx(uo,{children:a.hkSecAction}),o.jsx(et,{label:a.hkFieldRun,hint:l(n.run),hintTone:"danger",children:o.jsx("div",{style:{display:"flex",alignItems:"center",gap:14,paddingTop:3},children:["script","command"].map(h=>o.jsxs("span",{"data-hook-run-kind":h,onClick:()=>s({...e,runKind:h}),role:"button",style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer"},children:[o.jsx(e6,{selected:e.runKind===h}),o.jsx("span",{style:{font:`500 10.5px ${at}`,color:"var(--proto-ink-2)"},children:h==="script"?a.hkFieldScript:a.hkFieldCommand})]},h))})}),e.runKind==="script"?o.jsxs(et,{label:a.hkFieldScript,children:[o.jsx("input",{"data-hook-field":"script",list:Pj,value:e.script,onChange:h=>s({...e,script:h.target.value}),style:$e}),o.jsx("datalist",{id:Pj,children:r.map(h=>o.jsx("option",{value:h.name},h.name))})]}):o.jsx(et,{label:a.hkFieldCommand,children:o.jsx("input",{"data-hook-field":"command",value:e.command,onChange:h=>s({...e,command:h.target.value}),style:$e})}),o.jsx(et,{label:a.hkFieldTimeout,hint:l(n.timeoutSec),hintTone:"danger",children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[o.jsx("input",{"data-hook-field":"timeout",value:e.timeoutSec,placeholder:"30",onChange:h=>s({...e,timeoutSec:h.target.value}),style:{...$e,width:92}}),o.jsx("span",{style:{fontSize:10,color:"var(--proto-faint)"},children:a.hkSeconds})]})}),o.jsx(uo,{children:a.hkSecScope}),o.jsx(et,{label:a.hkFieldBackends,hint:e.backends.length===0?a.hkUnscoped:void 0,children:o.jsx("div",{"data-hook-field":"backends",style:{display:"flex",gap:5,paddingTop:2},children:["claude","pi"].map(h=>{const g=e.backends.includes(h);return o.jsx("span",{"data-hook-backend":h,"data-active":g?"":void 0,onClick:()=>s({...e,backends:g?e.backends.filter(v=>v!==h):[...e.backends,h]}),role:"button",style:{font:`500 10px ${at}`,padding:"3px 9px",borderRadius:6,cursor:"pointer",color:g?"var(--proto-accent)":"var(--proto-muted-2)",background:g?"var(--proto-accent-bg)":"var(--proto-card)",border:`1px solid ${g?"var(--proto-accent-border)":"var(--proto-line)"}`},children:h},h)})})}),o.jsx(et,{label:a.hkFieldRequiresTool,children:o.jsx("input",{"data-hook-field":"requiresTool",value:e.requiresTool,placeholder:"—",onChange:h=>s({...e,requiresTool:h.target.value}),style:$e})}),o.jsx(uo,{children:a.hkSecAdvanced}),o.jsx(et,{label:a.hkFieldResult,hint:p?a.hkResultLocked:l(n.result),hintTone:n.result?"danger":"muted",children:o.jsx("select",{"data-hook-field":"result","data-hook-result-locked":p?"":void 0,disabled:p,value:e.result,onChange:h=>s({...e,result:h.target.value}),style:p?N0:$e,children:u.map(h=>o.jsx("option",{value:h,children:h},h))})})]})}function AF({hook:e,payload:t,result:n,pending:r,onPayloadChange:i,onRun:s,onClose:a,onReset:l}){const c=B(),d=t.trim()!==""&&!Rj(t),u=!r&&Rj(t);return o.jsxs("div",{style:{marginTop:12,borderTop:"1px solid var(--proto-line-2)",paddingTop:10},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{fontSize:11.5,fontWeight:650,color:"var(--proto-ink)"},children:c.hkTestTitle}),o.jsx("span",{"data-action":"reset-test-payload",onClick:l,role:"button",style:{font:`400 9.5px ${at}`,color:"var(--proto-accent)",cursor:"pointer",marginLeft:6},children:c.hkTestReset}),o.jsx("span",{"data-action":"close-test",onClick:a,role:"button",style:{marginLeft:"auto",font:`400 9.5px ${at}`,color:"var(--proto-muted-3)",cursor:"pointer"},children:c.hkTestClose})]}),e.blocking!==null?o.jsx(dc,{"data-hook-blocking-warning":"",tone:"amber",children:c.hkTestBlockingWarn}):null,o.jsx("div",{style:{fontSize:10,color:"var(--proto-faint)",margin:"8px 0 4px"},children:c.hkTestPayload}),o.jsx("textarea",{"data-hook-test-payload":"",value:t,onChange:p=>i(p.target.value),rows:6,style:{...$e,resize:"vertical",lineHeight:1.6,borderColor:d?"var(--proto-danger)":"var(--proto-line)"}}),d?o.jsx("div",{"data-hook-payload-error":"",style:{fontSize:9.5,color:"var(--proto-danger)",marginTop:3},children:c.hkPayloadInvalid}):null,o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:8},children:[o.jsx(Qe,{"data-action":"run-test",tone:"accent",disabled:!u,onClick:s,children:c.hkTestRun}),o.jsx("span",{style:{font:`400 9px ${at}`,color:"var(--proto-faint)"},children:e.run.command??e.run.script??"—"})]}),n!==null?o.jsxs("div",{"data-hook-test-result":"",style:{marginTop:9,border:"1px solid var(--proto-line-2)",borderRadius:8,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",background:"var(--proto-alt)",font:`500 9.5px ${at}`,color:"var(--proto-muted)"},children:[o.jsxs("span",{"data-hook-test-exit":n.exitCode===null?"":String(n.exitCode),style:{color:n.ok?"var(--proto-success)":"var(--proto-danger)",fontWeight:700},children:["exit ",n.exitCode??"—"]}),n.error!==null?o.jsx("span",{style:{color:"var(--proto-danger)"},children:n.error}):null]}),o.jsx(Lj,{label:"stdout",text:n.stdout}),o.jsx(Lj,{label:"stderr",text:n.stderr,tone:"danger"})]}):null]})}function Lj({label:e,text:t,tone:n}){const r=B(),i=t.trim()==="";return o.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"6px 10px"},children:[o.jsx("div",{style:{font:`600 9px ${at}`,color:"var(--proto-muted-3)",marginBottom:3},children:e}),o.jsx("pre",{style:{margin:0,font:`400 10px/1.65 ${at}`,color:i?"var(--proto-faint)":n==="danger"?"var(--proto-danger)":"var(--proto-ink-2)",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:130,overflow:"auto"},children:i?r.hkTestNoOutput:t})]})}const NF={flex:"none",borderTop:"1px solid var(--proto-line-2)",padding:"9px 14px",display:"flex",alignItems:"center",gap:8};function $F(e){const t=B(),{hook:n,draft:r,creating:i}=e;if(r===null||n===null&&!i)return o.jsx(He,{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsx("span",{style:{fontSize:11.5,color:"var(--proto-muted-3)"},children:t.hkSelectHint})});const s=n?cF(n):null,a=i||((s==null?void 0:s.canEdit)??!1),l=yF(r,{mode:i?"create":"update",existingIds:e.hooks.map(g=>g.id)}),c=i?!0:n!==null&&vF(r,n),d=a&&c&&bF(l)&&!e.saving,u=n!==null&&uF(n),p=n?pF(n.event):null,h=(n==null?void 0:n.appliesAt)??null;return o.jsxs(He,{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",gap:8,padding:"10px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{font:`600 12px ${at}`,color:"var(--proto-ink)",minWidth:0,overflowWrap:"anywhere"},children:i?r.id||t.hkCreate:n==null?void 0:n.id}),n?o.jsx(PF,{source:n.source}):null,n==null?void 0:n.mountsOn.map(g=>o.jsx(p6,{target:g},g)),c&&!i?o.jsx("span",{style:{fontSize:9.5,fontWeight:600,color:"var(--proto-amber)"},children:t.hkDirty}):null,n&&(s!=null&&s.canToggle)?o.jsxs("span",{"data-hook-toggle":"","data-hook-enabled":n.enabled?"":void 0,style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:7,flex:"none"},children:[o.jsx("span",{style:{fontSize:10,color:"var(--proto-muted-2)"},children:n.enabled?t.stHookEnabled:t.stHookDisabled}),o.jsx(Yf,{on:n.enabled,onClick:e.saving?void 0:()=>e.onToggleEnabled(n,!n.enabled)})]}):null]}),o.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"4px 14px 12px"},children:[(s==null?void 0:s.note)==="managed"?o.jsx(dc,{"data-hook-note":"managed",tone:"amber",children:t.hkNoteManaged}):null,(s==null?void 0:s.note)==="template-scoped"?o.jsxs(dc,{"data-hook-note":"template-scoped",tone:"accent",children:[t.hkNoteTemplate,n!=null&&n.template?o.jsxs(Mj,{children:[" · ",n.template]}):null]}):null,u?o.jsxs(dc,{"data-hook-claude-gap":"",tone:"amber",children:[t.hkClaudeGap," ",p?o.jsx(Mj,{children:p}):null]}):null,(n==null?void 0:n.scriptExists)===!1?o.jsx(dc,{"data-hook-script-missing":"",tone:"danger",children:t.hkScriptMissing}):null,a?o.jsx(DF,{draft:r,creating:i,errors:l,scripts:e.scripts,eventOptions:kF(e.hooks),onDraftChange:e.onDraftChange}):n?o.jsxs(o.Fragment,{children:[o.jsx(uo,{children:t.hkSecDeclaration}),o.jsx(LF,{hook:n})]}):null,n?o.jsxs(o.Fragment,{children:[o.jsx(uo,{children:t.hkSecRegistry}),o.jsxs("div",{style:{font:`400 10px/2 ${at}`,color:"var(--proto-muted)"},children:[o.jsx(Yn,{k:t.hkFieldSource,value:n.source}),o.jsx(Yn,{k:t.hkFieldFile,value:n.fileName??"—"}),o.jsx(Yn,{k:t.hkFieldOrder,value:String(n.order)}),o.jsx(Yn,{k:t.hkFieldVersion,value:n.version??"—"}),o.jsx(Yn,{k:t.hkFieldBlocking,value:n.blocking===null?"—":`${n.blocking.mode} · ${n.blocking.ttlMin} min`}),o.jsx(Yn,{k:t.hkFieldMountsOn,value:n.mountsOn.join(" · ")||"—"})]}),h!==null?o.jsx("div",{"data-hook-applies-at":h,style:{fontSize:10,lineHeight:1.7,color:"var(--proto-muted-2)",marginTop:7},children:h==="server-restart"?t.hkAppliesRestart:t.hkAppliesNextAgent}):null]}):null,e.testOpen&&n!==null?o.jsx(AF,{hook:n,payload:e.testPayload,result:e.testResult,pending:e.testPending,onPayloadChange:e.onTestPayloadChange,onRun:e.onRunTest,onClose:e.onCloseTest,onReset:()=>e.onTestPayloadChange(u6(n.event))}):null]}),o.jsxs("div",{style:NF,children:[o.jsx("span",{style:{font:`400 9px ${at}`,color:"var(--proto-faint)",flex:1,minWidth:0},children:e.hooksDir}),n!==null&&!e.testOpen?o.jsx(Qe,{"data-action":"open-test",tone:"neutral",onClick:e.onOpenTest,children:t.hkTest}):null,i?o.jsxs(o.Fragment,{children:[o.jsx(Qe,{"data-action":"cancel-create",tone:"neutral",onClick:e.onCancelCreate,children:t.hkCancelCreate}),o.jsx(Qe,{"data-action":"save",tone:"accent",disabled:!d,onClick:e.onSave,children:t.hkSave})]}):a?o.jsxs(o.Fragment,{children:[o.jsx(Qe,{"data-action":"revert",tone:"neutral",disabled:!c,onClick:e.onRevert,children:t.hkRevert}),o.jsx(Qe,{"data-action":"save",tone:"accent",disabled:!d,onClick:e.onSave,children:t.hkSave}),e.armedDelete?o.jsxs(o.Fragment,{children:[o.jsx(Qe,{"data-action":"cancel-delete",tone:"neutral",onClick:e.onCancelDelete,children:t.cancel}),o.jsx(Qe,{"data-action":"confirm-delete",tone:"danger",disabled:e.saving,onClick:e.onConfirmDelete,children:t.hkConfirmDelete})]}):o.jsx(Qe,{"data-action":"arm-delete",tone:"danger",disabled:e.saving,onClick:e.onArmDelete,children:t.hkDelete})]}):null]})]})}function _F(e){const t=F0(e.hooks,e.filter,e.search),n=e.hooks.find(r=>r.id===e.selectedId)??null;return o.jsx("div",{"data-settings-panel":"hooks",style:{marginTop:12,flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:o.jsxs("div",{"data-hook-cards":"",style:{display:"flex",gap:12,flex:1,minHeight:0,alignItems:"stretch"},children:[o.jsx(MF,{hooks:e.hooks,visible:t,filter:e.filter,search:e.search,selectedId:e.selectedId,onFilter:e.onFilter,onSearch:e.onSearch,onSelect:e.onSelect,onStartCreate:e.onStartCreate}),o.jsx($F,{...e,hook:n})]})})}function FF(){var re,D;const e=B(),t=ae(),n=je(),{toast:r}=Tn(),i=G(t.hooks.list.queryOptions({})),s=f.useMemo(()=>{var Q;return((Q=i.data)==null?void 0:Q.hooks)??[]},[i.data]),[a,l]=f.useState("all"),[c,d]=f.useState(""),[u,p]=f.useState(null),[h,g]=f.useState(!1),[v,x]=f.useState(Iu),[w,b]=f.useState(null),[y,j]=f.useState(!1),[S,k]=f.useState(!1),[E,C]=f.useState(""),[R,P]=f.useState(null),L=f.useMemo(()=>F0(s,a,c),[s,a,c]),_=h?null:lF(s,L,u),U=s.find(Q=>Q.id===_)??null;f.useEffect(()=>{b(null),j(!1),k(!1),P(null)},[_]);const K=()=>n.invalidateQueries(t.hooks.list.queryFilter({})),$=Q=>r({title:`${e.hkToastWriteFailed}: ${Q.message}`,tone:"failed"}),W=ue(t.hooks.setEnabled.mutationOptions({onSuccess:(Q,ne)=>{K(),r({title:ne.enabled?e.hkToastEnabled:e.hkToastDisabled,tone:"done"}),Q.warning!==null&&r({title:Q.warning,tone:"waiting"})},onError:$})),V=ue(t.hooks.create.mutationOptions({onSuccess:Q=>{K(),r({title:`${e.hkToastCreated} · ${Q.fileName}`,tone:"done"}),g(!1),x(Iu()),p(Q.id)},onError:$})),Z=ue(t.hooks.update.mutationOptions({onSuccess:()=>{K(),r({title:e.hkToastSaved,tone:"done"}),b(null)},onError:$})),N=ue(t.hooks.remove.mutationOptions({onSuccess:()=>{K(),r({title:e.hkToastDeleted,tone:"done"}),j(!1),p(null)},onError:$})),F=ue(t.hooks.test.mutationOptions({onSuccess:Q=>P(Q),onError:Q=>{P(null),r({title:`${e.hkToastTestFailed}: ${Q.message}`,tone:"failed"})}}));if(i.isLoading)return o.jsx("div",{style:{marginTop:16,fontSize:12,color:"var(--proto-muted-3)"},children:e.hkLoading});if(i.isError)return o.jsxs("div",{style:{marginTop:16,fontSize:12,color:"var(--proto-danger)"},children:[e.hkLoadFailed," ",i.error.message]});const H=h?v:w??(U?c6(U):null);return o.jsx(_F,{hooks:s,scripts:((re=i.data)==null?void 0:re.scripts)??[],hooksDir:((D=i.data)==null?void 0:D.hooksDir)??"",filter:a,search:c,selectedId:_,draft:H,creating:h,armedDelete:y,saving:V.isPending||Z.isPending||N.isPending||W.isPending,testOpen:S,testPayload:E,testResult:R,testPending:F.isPending,onFilter:l,onSearch:d,onSelect:Q=>{g(!1),p(Q)},onStartCreate:()=>{g(!0),x(Iu()),k(!1),j(!1)},onCancelCreate:()=>{g(!1),x(Iu())},onDraftChange:Q=>h?x(Q):b(Q),onToggleEnabled:(Q,ne)=>W.mutate({id:Q.id,enabled:ne}),onSave:()=>{H!==null&&(h?V.mutate(jF(H)):Z.mutate(wF(H)))},onRevert:()=>b(null),onArmDelete:()=>j(!0),onCancelDelete:()=>j(!1),onConfirmDelete:()=>{U!==null&&N.mutate({id:U.id})},onOpenTest:()=>{k(!0),P(null),U!==null&&C(u6(U.event))},onCloseTest:()=>{k(!1),P(null)},onTestPayloadChange:C,onRunTest:()=>{U!==null&&F.mutate({id:U.id,payload:E})}})}const f6=["all","template","agent","shell"],zF=/^[A-Za-z0-9][A-Za-z0-9_-]*$/;function h6(e,t,n){const r=n.trim().toLowerCase();return e.filter(i=>t!=="all"&&i.kind!==t?!1:r===""?!0:i.name.toLowerCase().includes(r)||(i.description??"").toLowerCase().includes(r))}function BF(e,t){const n={all:0,template:0,agent:0,shell:0};for(const r of f6)n[r]=h6(e,r,t).length;return n}function WF(e,t){if(t&&e.some(r=>r.kind===t.kind&&r.name===t.name))return t;const n=e[0];return n?{kind:n.kind,name:n.name}:null}function UF(e,t){return e==="agent"?{name:t,description:"",profile:"__active__",persistSession:!1,promptTemplate:"{{input}}",tools:"Read,Write,Edit,Glob,Grep,Bash"}:e==="shell"?{params:["worker"],agents:["{worker}"],transitions:[],entryAgent:"{worker}",maxTotalSteps:2}:{name:t,description:"",agents:["__active__"],transitions:[],entryAgent:"__active__",maxTotalSteps:1}}function pp(e){return`${JSON.stringify(e,null,2)}`}function id(e){if(e.trim()==="")return{body:null,parseError:"Body is empty"};try{const t=JSON.parse(e);return!t||typeof t!="object"||Array.isArray(t)?{body:null,parseError:"Body must be a JSON object"}:{body:t,parseError:null}}catch(t){return{body:null,parseError:t instanceof Error?t.message:String(t)}}}function g6(e,t){return e!==t}function x6(e){return e.trim()===""?"Name is required":zF.test(e)?null:"Name must start with a letter or digit and contain only letters, digits, '-' and '_'"}function m6(e){return(e.creating?x6(e.name):null)!==null?{canSave:!1,reason:"name"}:id(e.text).parseError!==null?{canSave:!1,reason:"parse"}:!e.creating&&!g6(e.text,e.loaded)?{canSave:!1,reason:"clean"}:{canSave:!0,reason:null}}function HF(e){if(!m6(e).canSave)return null;const{body:t}=id(e.text);if(t===null)return null;const n={kind:e.kind,name:e.name,body:t};return!e.creating&&e.baseHash!==null&&(n.baseHash=e.baseHash),n}function v6(e){return((e==null?void 0:e.runningThreads)??0)>0}function qF(e){return e?e.usedByTemplates.length>0?"dependents":e.runningThreads>0?"running":null:null}function VF(e){return(e==null?void 0:e.origin)==="stock"}const pr="'IBM Plex Mono',monospace",KF=232,QF={template:{bg:"var(--proto-accent-bg)",color:"var(--proto-accent)"},agent:{bg:"var(--proto-success-bg)",color:"var(--proto-success)"},shell:{bg:"var(--proto-amber-bg)",color:"var(--proto-amber)"}},GF={all:"ttFilterAll",template:"ttFilterTemplate",agent:"ttFilterAgent",shell:"ttFilterShell"},YF={stock:"ttOriginStock",modified:"ttOriginModified",custom:"ttOriginCustom"},XF={stock:"ttOriginStockTitle",modified:"ttOriginModifiedTitle",custom:"ttOriginCustomTitle"};function y6({kind:e}){const t=QF[e];return o.jsx("span",{"data-kind":e,style:{fontSize:9,fontWeight:700,padding:"1px 6px",borderRadius:999,background:t.bg,color:t.color,flex:"none",letterSpacing:".02em"},children:e})}function JF({origin:e}){const t=B();return o.jsx("span",{"data-origin":e,title:t[XF[e]],style:{font:`500 9px ${pr}`,padding:"1px 5px",borderRadius:5,border:"1px solid var(--proto-line-2)",color:"var(--proto-muted-3)",flex:"none"},children:t[YF[e]]})}function Lu({tone:e,children:t}){const n=e==="danger";return o.jsx("div",{"data-banner":e,style:{fontSize:10.5,lineHeight:1.6,padding:"7px 10px",borderRadius:7,marginBottom:8,color:n?"var(--proto-danger)":"var(--proto-amber)",background:n?"var(--proto-danger-bg)":"var(--proto-amber-bg)"},children:t})}function Oj({issues:e,tone:t}){const n=t==="danger"?"var(--proto-danger)":"var(--proto-amber)";return o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:e.map((r,i)=>o.jsxs("div",{"data-issue":t,style:{display:"flex",gap:8,fontSize:10.5},children:[o.jsx("span",{style:{font:`600 9.5px ${pr}`,color:n,flex:"none",minWidth:128,wordBreak:"break-all"},children:r.path}),o.jsx("span",{style:{color:"var(--proto-muted)",lineHeight:1.6},children:r.message})]},`${r.path}:${i}`))})}function Ou({k:e,v:t}){return o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:10,padding:"4px 0",fontSize:10.5},children:[o.jsx("span",{style:{color:"var(--proto-muted-3)",minWidth:168,flex:"none"},children:e}),o.jsx("span",{style:{color:"var(--proto-ink-2)",wordBreak:"break-all"},children:t})]})}function ZF({entry:e,selected:t,onSelect:n}){const r=B();return o.jsxs("div",{"data-template-row":`${e.kind}:${e.name}`,"data-selected":t?"":void 0,role:"button",onClick:()=>n({kind:e.kind,name:e.name}),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",borderRadius:7,cursor:"pointer",background:t?"var(--proto-accent-bg)":"transparent"},children:[o.jsx(y6,{kind:e.kind}),o.jsx("span",{style:{font:`600 10.5px ${pr}`,color:t?"var(--proto-accent)":"var(--proto-ink-2)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),e.valid?null:o.jsx("span",{"data-invalid":"",title:`${e.errorCount}`,style:{marginLeft:"auto",font:`600 9px ${pr}`,color:"var(--proto-danger)",flex:"none"},children:r.ttInvalidBadge})]})}function ez({entries:e,visible:t,filter:n,search:r,selection:i,onFilter:s,onSearch:a,onSelect:l,onStartCreate:c}){const d=B(),u=BF(e,r);return o.jsxs(He,{style:{width:KF,flex:"none",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"9px 10px 7px",borderBottom:"1px solid var(--proto-line-2)",flex:"none"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[o.jsx("span",{style:{fontSize:11.5,fontWeight:650,color:"var(--proto-ink)"},children:d.ttEditorTitle}),o.jsx("span",{style:{font:`400 9.5px ${pr}`,color:"var(--proto-faint)"},children:e.length})]}),o.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:f6.map(p=>{const h=p===n;return o.jsxs("span",{role:"button","data-template-filter":p,"data-active":h?"":void 0,onClick:()=>s(p),style:{font:`500 9.5px ${pr}`,padding:"2px 7px",borderRadius:6,cursor:"pointer",color:h?"var(--proto-accent)":"var(--proto-muted-2)",background:h?"var(--proto-accent-bg)":"transparent",border:`1px solid ${h?"var(--proto-accent-border)":"var(--proto-line-2)"}`},children:[d[GF[p]],o.jsx("span",{style:{color:"var(--proto-faint)",marginLeft:4},children:u[p]})]},p)})}),o.jsx("input",{"data-template-search":"",value:r,onChange:p=>a(p.target.value),placeholder:d.ttSearchPh,style:{...$e,marginTop:7,padding:"4px 8px"}})]}),o.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"4px 6px"},children:t.length===0?o.jsx("div",{"data-templates-empty":"",style:{padding:"14px 8px",fontSize:10.5,color:"var(--proto-faint)"},children:e.length===0?d.stNoTemplates:d.ttNoMatch}):t.map(p=>o.jsx(ZF,{entry:p,selected:(i==null?void 0:i.kind)===p.kind&&(i==null?void 0:i.name)===p.name,onSelect:l},`${p.kind}:${p.name}`))}),o.jsxs("div",{style:{flex:"none",borderTop:"1px solid var(--proto-line-2)",padding:"8px 10px",display:"flex",alignItems:"center",gap:8},children:[o.jsxs("span",{style:{fontSize:11,fontWeight:600,color:"var(--proto-muted-3)",flex:"none"},children:["+ ",d.ttNew]}),["template","agent","shell"].map(p=>o.jsx("span",{role:"button","data-create-kind":p,onClick:()=>c(p),style:{font:`500 9.5px ${pr}`,color:"var(--proto-accent)",cursor:"pointer"},children:p},p))]})]})}function tz(e){const t=B(),{detail:n,creating:r,text:i,loaded:s}=e,a=(r==null?void 0:r.kind)??(n==null?void 0:n.kind)??null,l=r?e.draftName:(n==null?void 0:n.name)??"";if(!a)return o.jsx(He,{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsx("span",{"data-template-detail-empty":"",style:{fontSize:11,color:"var(--proto-faint)"},children:t.ttSelectPrompt})});const c=m6({text:i,loaded:s,name:l,creating:r!==null}),d=r?x6(e.draftName):null,u=e.liveIssues??{errors:(n==null?void 0:n.errors)??[],warnings:(n==null?void 0:n.warnings)??[]},p=id(i).parseError,h=g6(i,s),g=qF(n),v=!r&&v6(n),x=!r&&h&&VF(n),w=c.reason==="parse"?t.ttHintParse:c.reason==="name"?t.ttHintName:c.reason==="clean"?t.ttHintClean:null,b=[{key:"body",label:t.ttTabBody},{key:"validation",label:t.ttTabValidation,badge:u.errors.length+u.warnings.length},{key:"references",label:t.ttTabReferences}];return o.jsxs(He,{"data-template-detail":`${a}:${l}`,style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"10px 14px 0",flex:"none"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[o.jsx(y6,{kind:a}),r?o.jsx("input",{"data-template-name":"",value:e.draftName,onChange:y=>e.onDraftName(y.target.value),placeholder:t.ttNamePh,style:{...$e,width:220,padding:"4px 8px"}}):o.jsx("span",{style:{font:`650 12px ${pr}`,color:"var(--proto-ink)"},children:l}),n&&!r?o.jsx(JF,{origin:n.origin}):null,h?o.jsx("span",{"data-dirty":"",style:{font:`500 9px ${pr}`,color:"var(--proto-amber)"},children:"●"}):null]}),o.jsx("div",{style:{display:"flex",gap:2,borderBottom:"1px solid var(--proto-line-2)"},children:b.map(y=>{const j=y.key===e.tab;return o.jsxs("span",{role:"button","data-template-tab":y.key,"data-active":j?"":void 0,onClick:()=>e.onTab(y.key),style:{fontSize:11,fontWeight:600,padding:"5px 10px",cursor:"pointer",color:j?"var(--proto-accent)":"var(--proto-muted-2)",borderBottom:`2px solid ${j?"var(--proto-accent)":"transparent"}`,marginBottom:-1},children:[y.label,y.badge?o.jsx("span",{style:{marginLeft:5,color:"var(--proto-faint)"},children:y.badge}):null]},y.key)})})]}),o.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"10px 14px"},children:[d&&r?o.jsx(Lu,{tone:"danger",children:d}):null,v?o.jsxs(Lu,{tone:"warn",children:[n==null?void 0:n.runningThreads," ",t.ttRunningWarn]}):null,x?o.jsx(Lu,{tone:"warn",children:t.ttForkWarn}):null,e.tab==="body"?o.jsxs(o.Fragment,{children:[p?o.jsx(Lu,{tone:"danger",children:p}):null,o.jsx("textarea",{"data-template-body":"",value:i,spellCheck:!1,onChange:y=>e.onText(y.target.value),onKeyDown:y=>{if(y.key!=="Tab")return;y.preventDefault();const j=y.currentTarget,{selectionStart:S,selectionEnd:k,value:E}=j;e.onText(`${E.slice(0,S)} ${E.slice(k)}`),requestAnimationFrame(()=>j.setSelectionRange(S+2,S+2))},style:{...$e,minHeight:320,height:"100%",resize:"vertical",lineHeight:1.65,whiteSpace:"pre",overflowWrap:"normal",overflowX:"auto"}})]}):null,e.tab==="validation"?o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[o.jsxs("div",{children:[o.jsx(xg,{children:t.ttErrors}),u.errors.length===0?o.jsx(Gl,{children:t.ttNoErrors}):o.jsx(Oj,{issues:u.errors,tone:"danger"})]}),o.jsxs("div",{children:[o.jsx(xg,{children:t.ttWarnings}),u.warnings.length===0?o.jsx(Gl,{children:t.ttNoWarnings}):o.jsx(Oj,{issues:u.warnings,tone:"warn"})]}),o.jsx(Gl,{children:t.ttErrorsBlock})]}):null,e.tab==="references"?o.jsx("div",{children:n?o.jsxs(o.Fragment,{children:[o.jsx(Ou,{k:t.ttFilePath,v:o.jsx("span",{style:{font:`400 10px ${pr}`},children:n.filePath})}),o.jsx(Ou,{k:t.ttUsedBy,v:n.usedByTemplates.length>0?n.usedByTemplates.join(", "):t.ttUsedByNone}),o.jsx(Ou,{k:t.ttRunningThreads,v:n.runningThreads}),o.jsx(Ou,{k:t.ttReferencingTasks,v:n.referencingTasks}),n.expanded?o.jsxs("div",{style:{marginTop:12},children:[o.jsx(xg,{children:t.ttExpanded}),o.jsx(Gl,{children:t.ttExpandedNote}),o.jsx("pre",{"data-template-expanded":"",style:{font:`400 10px ${pr}`,color:"var(--proto-muted)",background:"var(--proto-alt)",border:"1px solid var(--proto-line-2)",borderRadius:7,padding:10,marginTop:6,overflow:"auto"},children:pp(n.expanded)})]}):null]}):o.jsx(Gl,{children:t.ttSelectPrompt})}):null]}),o.jsxs("div",{style:{flex:"none",borderTop:"1px solid var(--proto-line-2)",padding:"9px 14px",display:"flex",alignItems:"center",gap:8},children:[o.jsx(Qe,{tone:"accent",disabled:!c.canSave||e.busy,onClick:e.onSave,"data-action":"save",children:e.armedSave?t.ttSaveConfirm:t.ttSave}),o.jsx(Qe,{tone:"neutral",disabled:e.busy,onClick:e.onValidate,"data-action":"validate",children:t.ttValidate}),o.jsx(Qe,{tone:"neutral",disabled:!h||e.busy,onClick:e.onRevert,"data-action":"revert",children:t.ttRevert}),o.jsx(Qe,{tone:"neutral",disabled:e.busy,onClick:e.onFormat,"data-action":"format",children:t.ttFormat}),r?o.jsx(Qe,{tone:"neutral",onClick:e.onCancelCreate,"data-action":"cancel-create",children:t.ttCancel}):o.jsxs(o.Fragment,{children:[o.jsx(Qe,{tone:"neutral",disabled:e.busy,onClick:e.onDuplicate,"data-action":"duplicate",children:t.ttDuplicate}),o.jsx(Qe,{tone:"danger",disabled:g!==null||e.busy,onClick:e.onDelete,"data-action":"delete",title:g==="dependents"?t.ttDeleteBlockedDependents:g==="running"?t.ttDeleteBlockedRunning:void 0,children:e.armedDelete?t.ttDeleteConfirm:t.ttDelete})]}),w?o.jsx("span",{"data-save-hint":"",style:{marginLeft:"auto",fontSize:10,color:"var(--proto-faint)"},children:w}):null]})]})}function xg({children:e}){return o.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".06em",color:"var(--proto-muted-3)",textTransform:"uppercase",marginBottom:6},children:e})}function Gl({children:e,style:t}){return o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",lineHeight:1.6,...t},children:e})}function nz(){const e=B(),t=ae(),n=je(),{toast:r}=Tn(),i=G(t.threadTemplates.get.queryOptions({})),s=f.useMemo(()=>i.data??[],[i.data]),[a,l]=f.useState("all"),[c,d]=f.useState(""),[u,p]=f.useState(null),[h,g]=f.useState(null),[v,x]=f.useState(""),[w,b]=f.useState("body"),[y,j]=f.useState(null),[S,k]=f.useState(null),[E,C]=f.useState(!1),[R,P]=f.useState(!1),[L,_]=f.useState(""),U=f.useMemo(()=>h6(s,a,c),[s,a,c]),K=h?null:WF(U,u),$=G({...t.threadTemplates.detail.queryOptions(K??{kind:"template",name:""}),enabled:K!==null}),W=K?$.data??null:null,V=h?L:W!=null&&W.body?pp(W.body):"",Z=h?L:y??V;f.useEffect(()=>{j(null),k(null),C(!1),P(!1)},[K==null?void 0:K.kind,K==null?void 0:K.name,h==null?void 0:h.kind]);const N=()=>{n.invalidateQueries(t.threadTemplates.get.queryFilter({})),K&&n.invalidateQueries(t.threadTemplates.detail.queryFilter(K))},F=we=>{const Ee=/changed on disk/i.test(we.message);r({title:Ee?e.ttToastConflict:`${e.ttToastWriteFailed}: ${we.message}`,tone:"failed"})},H=ue(t.threadTemplates.validate.mutationOptions({onSuccess:we=>{k({errors:we.errors,warnings:we.warnings}),b("validation"),r({title:we.ok?e.ttToastValid:e.ttToastInvalid,tone:we.ok?"done":"failed"})},onError:F})),re=ue(t.threadTemplates.save.mutationOptions({onSuccess:(we,Ee)=>{N(),j(null),C(!1),k(null),h&&(g(null),p({kind:Ee.kind,name:Ee.name})),r({title:e.ttToastSaved,tone:"done"});for(const Xe of we.warnings)r({title:`${Xe.path}: ${Xe.message}`,tone:"waiting"})},onError:F})),D=ue(t.threadTemplates.remove.mutationOptions({onSuccess:()=>{N(),p(null),P(!1),r({title:e.ttToastDeleted,tone:"done"})},onError:F})),Q=we=>{g({kind:we}),x(""),_(pp(UF(we,""))),b("body"),k(null)},ne=(h==null?void 0:h.kind)??(K==null?void 0:K.kind)??null,J=h?v:(K==null?void 0:K.name)??"",te=()=>{if(!ne)return;if(!h&&v6(W)&&!E){C(!0);return}const we=HF({kind:ne,name:J,text:Z,loaded:V,creating:h!==null,baseHash:(W==null?void 0:W.sha256)??null});we&&re.mutate(we)},fe=()=>{if(K){if(!R){P(!0);return}D.mutate(K)}},ve=()=>{ne&&(g({kind:ne}),x(`${J}-copy`),_(Z),b("body"),k(null))},ke=we=>{h?_(we):j(we)},Ct=re.isPending||D.isPending||H.isPending;return o.jsxs("div",{"data-settings-panel":"templates",style:{marginTop:12,flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[o.jsxs("div",{style:{display:"flex",gap:12,flex:1,minHeight:0,alignItems:"stretch"},children:[o.jsx(ez,{entries:s,visible:U,filter:a,search:c,selection:K,onFilter:l,onSearch:d,onSelect:we=>{g(null),p(we)},onStartCreate:Q}),o.jsx(tz,{selection:K,detail:W,creating:h,draftName:v,text:Z,loaded:V,tab:w,liveIssues:S,armedSave:E,armedDelete:R,busy:Ct,onDraftName:x,onText:ke,onTab:b,onSave:te,onRevert:()=>{j(null),k(null),C(!1)},onValidate:()=>{if(!ne)return;const we=id(Z);if(we.body===null){r({title:we.parseError??e.ttHintParse,tone:"failed"});return}H.mutate({kind:ne,name:J||"draft",body:we.body})},onDelete:fe,onDuplicate:ve,onCancelCreate:()=>g(null),onFormat:()=>{const we=id(Z);if(we.body===null){r({title:we.parseError??e.ttHintParse,tone:"failed"});return}ke(pp(we.body))}})]}),o.jsx("div",{style:{flex:"none",paddingTop:8,fontSize:10,color:"var(--proto-faint)",lineHeight:1.6},children:e.ttFootNote})]})}const rz="'IBM Plex Mono',monospace";function Dj({value:e,options:t,onChange:n,dataAttr:r}){return o.jsx("div",{style:{display:"flex",gap:2,padding:2,borderRadius:8,background:"var(--proto-gray)",border:"1px solid var(--proto-line)",flex:"none"},children:t.map(i=>{const s=e===i.id;return o.jsx("button",{type:"button","aria-pressed":s,[r]:i.id,onClick:()=>n(i.id),style:{border:"none",cursor:"pointer",fontSize:11.5,fontWeight:600,padding:"4px 16px",borderRadius:6,background:s?"var(--ink-solid-bg)":"transparent",color:s?"var(--ink-solid-fg)":"var(--proto-muted-2)",transition:"background .12s, color .12s"},children:i.label},i.id)})})}function Aj({title:e,hint:t,control:n}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--proto-ink)"},children:e}),o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-muted-2)",marginTop:3,lineHeight:1.5},children:t})]}),n]})}function oz(){const e=B(),t=k0(),n=S0(),r=ft(),i=gC();return o.jsxs("div",{style:{marginTop:12,maxWidth:760},children:[o.jsx(He,{style:{padding:"14px 16px"},children:o.jsx(Aj,{title:e.stLangLabel,hint:e.stLangHint,control:o.jsx(Dj,{value:r,options:[{id:"en",label:e.stLangEnglish},{id:"zh",label:e.stLangChinese}],onChange:i,dataAttr:"data-lang-option"})})}),o.jsx(He,{style:{marginTop:12,padding:"14px 16px"},children:o.jsx(Aj,{title:e.stThemeLabel,hint:e.stThemeHint,control:o.jsx(Dj,{value:t,options:[{id:"light",label:e.stThemeLight},{id:"dark",label:e.stThemeDark}],onChange:n,dataAttr:"data-theme-option"})})}),o.jsx("div",{style:{marginTop:10,font:`400 9.5px ${rz}`,color:"var(--proto-faint)",paddingLeft:2},children:"localStorage · cortex.lang · cortex.theme"})]})}const iz={anthropic:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M13.827 3.52h3.603L24 20h-3.603l-6.57-16.48zm-7.258 0h3.767L16.906 20h-3.674l-1.343-3.461H5.017l-1.344 3.46H0L6.57 3.522zm4.132 9.959L8.453 7.687 6.205 13.48H10.7z"></path></svg>',antgroup:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M15.984 1.383c-.259.593-.877.914-1.334 1.348-.702.669-.998 1.726-1.218 2.682 3.37.775 5.995 3.532 6.486 7.025.566 4.016-1.85 7.859-5.744 9.134-3.894 1.276-8.153-.38-10.126-3.935A8.339 8.339 0 016.457 6.833a18.703 18.703 0 01-.376-.802l-.174-.408a8.698 8.698 0 01-.618-1.987 7.523 7.523 0 01-.051-.37 3.717 3.717 0 01-.024-.34 2.506 2.506 0 01.132-.872 1.26 1.26 0 01.384-.594.842.842 0 011.165.11c.694.82.169 2.078.142 3.02.009.575.111 1.144.301 1.684l-.103.052a8.404 8.404 0 001.318-.79c.28-.243.45-.742.781-.864.33-.121.682.146.946.297.278.145.587.219.901.214l.462.007c.076.002.152.005.226.011.212.01.422.026.63.05l.196-1.08c.04-.216.082-.43.126-.645l.141-.641c.14-.7.42-1.367.823-1.96.305-.431.75-.746 1.262-.89.877-.217 1.24.629.937 1.348zm-2.244 5.44c-2.841.002-4.898 2.532-4.628 5.64.27 3.11 2.781 5.642 5.613 5.666 2.832.024 4.932-2.512 4.658-5.644-.273-3.133-2.802-5.666-5.643-5.663zm.357.57a4.707 4.707 0 013.304 1.445 5.703 5.703 0 011.643 3.49 4.841 4.841 0 01-1.141 3.705v.015a3.923 3.923 0 01-2.808 1.303 4.664 4.664 0 01-3.367-1.387 5.678 5.678 0 01-1.71-3.518 4.832 4.832 0 011.14-3.753 3.923 3.923 0 012.813-1.3h.126z"></path></svg>',azure:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M18.397 15.296H7.4a.51.51 0 00-.347.882l7.066 6.595c.206.192.477.298.758.298h6.226l-2.706-7.775z" fill-opacity=".75"></path><path d="M8.295.857c-.477 0-.9.304-1.053.756L.495 21.605a1.11 1.11 0 001.052 1.466h5.43c.477 0 .9-.304 1.053-.755l1.341-3.975-2.318-2.163a.51.51 0 01.347-.882h3L15.271.857H8.295z" fill-opacity=".5"></path><path d="M17.193 1.613a1.11 1.11 0 00-1.052-.756h-7.81.035c.477 0 .9.304 1.052.756l6.748 19.992a1.11 1.11 0 01-1.052 1.466h-.12 7.895a1.11 1.11 0 001.052-1.466L17.193 1.613z"></path></svg>',bedrock:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M13.05 15.513h3.08c.214 0 .389.177.389.394v1.82a1.704 1.704 0 011.296 1.661c0 .943-.755 1.708-1.685 1.708-.931 0-1.686-.765-1.686-1.708 0-.807.554-1.484 1.297-1.662v-1.425h-2.69v4.663a.395.395 0 01-.188.338l-2.69 1.641a.385.385 0 01-.405-.002l-4.926-3.086a.395.395 0 01-.185-.336V16.3L2.196 14.87A.395.395 0 012 14.555L2 14.528V9.406c0-.14.073-.27.192-.34l2.465-1.462V4.448c0-.129.062-.249.165-.322l.021-.014L9.77 1.058a.385.385 0 01.407 0l2.69 1.675a.395.395 0 01.185.336V7.6h3.856V5.683a1.704 1.704 0 01-1.296-1.662c0-.943.755-1.708 1.685-1.708.931 0 1.685.765 1.685 1.708 0 .807-.553 1.484-1.296 1.662v2.311a.391.391 0 01-.389.394h-4.245v1.806h6.624a1.69 1.69 0 011.64-1.313c.93 0 1.685.764 1.685 1.707 0 .943-.754 1.708-1.685 1.708a1.69 1.69 0 01-1.64-1.314H13.05v1.937h4.953l.915 1.18a1.66 1.66 0 01.84-.227c.931 0 1.685.764 1.685 1.707 0 .943-.754 1.708-1.685 1.708-.93 0-1.685-.765-1.685-1.708 0-.346.102-.668.276-.937l-.724-.935H13.05v1.806zM9.973 1.856L7.93 3.122V6.09h-.778V3.604L5.435 4.669v2.945l2.11 1.36L9.712 7.61V5.334h.778V7.83c0 .136-.07.263-.184.335L7.963 9.638v2.081l1.422 1.009-.446.646-1.406-.998-1.53 1.005-.423-.66 1.605-1.055v-1.99L5.038 8.29l-2.26 1.34v1.676l1.972-1.189.398.677-2.37 1.429V14.3l2.166 1.258 2.27-1.368.397.677-2.176 1.311V19.3l1.876 1.175 2.365-1.426.398.678-2.017 1.216 1.918 1.201 2.298-1.403v-5.78l-4.758 2.893-.4-.675 5.158-3.136V3.289L9.972 1.856zM16.13 18.47a.913.913 0 00-.908.92c0 .507.406.918.908.918a.913.913 0 00.907-.919.913.913 0 00-.907-.92zm3.63-3.81a.913.913 0 00-.908.92c0 .508.406.92.907.92a.913.913 0 00.908-.92.913.913 0 00-.908-.92zm1.555-4.99a.913.913 0 00-.908.92c0 .507.407.918.908.918a.913.913 0 00.907-.919.913.913 0 00-.907-.92zM17.296 3.1a.913.913 0 00-.907.92c0 .508.406.92.907.92a.913.913 0 00.908-.92.913.913 0 00-.908-.92z"></path></svg>',cerebras:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M14.121 2.701a9.299 9.299 0 000 18.598V22.7c-5.91 0-10.7-4.791-10.7-10.701S8.21 1.299 14.12 1.299V2.7zm4.752 3.677A7.353 7.353 0 109.42 17.643l-.901 1.074a8.754 8.754 0 01-1.08-12.334 8.755 8.755 0 0112.335-1.08l-.901 1.075zm-2.255.844a5.407 5.407 0 00-5.048 9.563l-.656 1.24a6.81 6.81 0 016.358-12.043l-.654 1.24zM14.12 8.539a3.46 3.46 0 100 6.922v1.402a4.863 4.863 0 010-9.726v1.402z"></path><path d="M15.407 10.836a2.24 2.24 0 00-.51-.409 1.084 1.084 0 00-.544-.152c-.255 0-.483.047-.684.14a1.58 1.58 0 00-.84.912c-.074.203-.11.416-.11.631 0 .218.036.43.11.631a1.594 1.594 0 00.84.913c.2.093.43.14.684.14.216 0 .417-.046.602-.135.188-.09.35-.225.475-.392l.928 1.006c-.14.14-.3.261-.482.363a3.367 3.367 0 01-1.083.38c-.17.026-.317.04-.44.04a3.315 3.315 0 01-1.182-.21 2.825 2.825 0 01-.961-.597 2.816 2.816 0 01-.644-.929 2.987 2.987 0 01-.238-1.21c0-.444.08-.847.238-1.21.15-.35.368-.666.643-.929.278-.261.605-.464.962-.596a3.315 3.315 0 011.182-.21c.355 0 .712.068 1.072.204.361.138.685.36.944.649l-.962.97z"></path></svg>',claude:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z"></path></svg>',cloudflare:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16.493 17.4c.135-.52.08-.983-.161-1.338-.215-.328-.592-.519-1.05-.519l-8.663-.109a.148.148 0 01-.135-.082c-.027-.054-.027-.109-.027-.163.027-.082.108-.164.189-.164l8.744-.11c1.05-.054 2.153-.9 2.556-1.937l.511-1.31c.027-.055.027-.11.027-.164C17.92 8.91 15.66 7 12.942 7c-2.503 0-4.628 1.638-5.381 3.903a2.432 2.432 0 00-1.803-.491c-1.21.109-2.153 1.092-2.287 2.32-.027.328 0 .628.054.9C1.56 13.688 0 15.326 0 17.319c0 .19.027.355.027.545 0 .082.08.137.161.137h15.983c.08 0 .188-.055.215-.164l.107-.437"></path><path d="M19.238 11.75h-.242c-.054 0-.108.054-.135.109l-.35 1.2c-.134.52-.08.983.162 1.338.215.328.592.518 1.05.518l1.855.11c.054 0 .108.027.135.082.027.054.027.109.027.163-.027.082-.108.164-.188.164l-1.91.11c-1.05.054-2.153.9-2.557 1.937l-.134.355c-.027.055.026.137.107.137h6.592c.081 0 .162-.055.162-.137.107-.41.188-.846.188-1.31-.027-2.62-2.153-4.777-4.762-4.777"></path></svg>',codex:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M8.086.457a6.105 6.105 0 013.046-.415c1.333.153 2.521.72 3.564 1.7a.117.117 0 00.107.029c1.408-.346 2.762-.224 4.061.366l.063.03.154.076c1.357.703 2.33 1.77 2.918 3.198.278.679.418 1.388.421 2.126a5.655 5.655 0 01-.18 1.631.167.167 0 00.04.155 5.982 5.982 0 011.578 2.891c.385 1.901-.01 3.615-1.183 5.14l-.182.22a6.063 6.063 0 01-2.934 1.851.162.162 0 00-.108.102c-.255.736-.511 1.364-.987 1.992-1.199 1.582-2.962 2.462-4.948 2.451-1.583-.008-2.986-.587-4.21-1.736a.145.145 0 00-.14-.032c-.518.167-1.04.191-1.604.185a5.924 5.924 0 01-2.595-.622 6.058 6.058 0 01-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74 7.74 0 01-.495-1.283 6.11 6.11 0 01-.017-3.064.166.166 0 00.008-.074.115.115 0 00-.037-.064 5.958 5.958 0 01-1.38-2.202 5.196 5.196 0 01-.333-1.589 6.915 6.915 0 01.188-2.132c.45-1.484 1.309-2.648 2.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129 0 00.087-.087A6.016 6.016 0 015.635 2.31C6.315 1.464 7.132.846 8.086.457zm-.804 7.85a.848.848 0 00-1.473.842l1.694 2.965-1.688 2.848a.849.849 0 001.46.864l1.94-3.272a.849.849 0 00.007-.854l-1.94-3.393zm5.446 6.24a.849.849 0 000 1.695h4.848a.849.849 0 000-1.696h-4.848z"></path></svg>',deepseek:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M23.748 4.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.329.14a5.526 5.526 0 01-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365 11.365 0 00-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055 3.055 0 01-.465.137 9.597 9.597 0 00-2.883-.102c-1.885.21-3.39 1.102-4.497 2.623C.082 8.606-.231 10.684.152 12.85c.403 2.284 1.569 4.175 3.36 5.653 1.858 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.133-.284 4.994-1.86.47.234.962.327 1.78.397.63.059 1.236-.03 1.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926 1.096-1.296 2.746-2.642 3.392-7.003.05-.347.007-.565 0-.845-.004-.17.035-.237.23-.256a4.173 4.173 0 001.545-.475c1.396-.763 1.96-2.015 2.093-3.517.02-.23-.004-.467-.247-.588zM11.581 18c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696 4.696 0 011.529-.039c2.132.312 3.946 1.265 5.468 2.774.868.86 1.525 1.887 2.202 2.891.72 1.066 1.494 2.082 2.48 2.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.614zm1-6.44a.306.306 0 01.415-.287.302.302 0 01.2.288.306.306 0 01-.31.307.303.303 0 01-.304-.308zm3.11 1.596c-.2.081-.399.151-.59.16a1.245 1.245 0 01-.798-.254c-.274-.23-.47-.358-.552-.758a1.73 1.73 0 01.016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559 0 01-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.192-.21.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.195-.019.354-.25.452z"></path></svg>',fireworks:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M14.8 5l-2.801 6.795L9.195 5H7.397l3.072 7.428a1.64 1.64 0 003.038.002L16.598 5H14.8zm1.196 10.352l5.124-5.244-.699-1.669-5.596 5.739a1.664 1.664 0 00-.343 1.807 1.642 1.642 0 001.516 1.012L16 17l8-.02-.699-1.669-7.303.041h-.002zM2.88 10.104l.699-1.669 5.596 5.739c.468.479.603 1.189.343 1.807a1.643 1.643 0 01-1.516 1.012l-8-.018-.002.002.699-1.669 7.303.042-5.122-5.246z"></path></svg>',gemini:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z"></path></svg>',githubcopilot:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M19.245 5.364c1.322 1.36 1.877 3.216 2.11 5.817.622 0 1.2.135 1.592.654l.73.964c.21.278.323.61.323.955v2.62c0 .339-.173.669-.453.868C20.239 19.602 16.157 21.5 12 21.5c-4.6 0-9.205-2.583-11.547-4.258-.28-.2-.452-.53-.453-.868v-2.62c0-.345.113-.679.321-.956l.73-.963c.392-.517.974-.654 1.593-.654l.029-.297c.25-2.446.81-4.213 2.082-5.52 2.461-2.54 5.71-2.851 7.146-2.864h.198c1.436.013 4.685.323 7.146 2.864zm-7.244 4.328c-.284 0-.613.016-.962.05-.123.447-.305.85-.57 1.108-1.05 1.023-2.316 1.18-2.994 1.18-.638 0-1.306-.13-1.851-.464-.516.165-1.012.403-1.044.996a65.882 65.882 0 00-.063 2.884l-.002.48c-.002.563-.005 1.126-.013 1.69.002.326.204.63.51.765 2.482 1.102 4.83 1.657 6.99 1.657 2.156 0 4.504-.555 6.985-1.657a.854.854 0 00.51-.766c.03-1.682.006-3.372-.076-5.053-.031-.596-.528-.83-1.046-.996-.546.333-1.212.464-1.85.464-.677 0-1.942-.157-2.993-1.18-.266-.258-.447-.661-.57-1.108-.32-.032-.64-.049-.96-.05zm-2.525 4.013c.539 0 .976.426.976.95v1.753c0 .525-.437.95-.976.95a.964.964 0 01-.976-.95v-1.752c0-.525.437-.951.976-.951zm5 0c.539 0 .976.426.976.95v1.753c0 .525-.437.95-.976.95a.964.964 0 01-.976-.95v-1.752c0-.525.437-.951.976-.951zM7.635 5.087c-1.05.102-1.935.438-2.385.906-.975 1.037-.765 3.668-.21 4.224.405.394 1.17.657 1.995.657h.09c.649-.013 1.785-.176 2.73-1.11.435-.41.705-1.433.675-2.47-.03-.834-.27-1.52-.63-1.813-.39-.336-1.275-.482-2.265-.394zm6.465.394c-.36.292-.6.98-.63 1.813-.03 1.037.24 2.06.675 2.47.968.957 2.136 1.104 2.776 1.11h.044c.825 0 1.59-.263 1.995-.657.555-.556.765-3.187-.21-4.224-.45-.468-1.335-.804-2.385-.906-.99-.088-1.875.058-2.265.394zM12 7.615c-.24 0-.525.015-.84.044.03.16.045.336.06.526l-.001.159a2.94 2.94 0 01-.014.25c.225-.022.425-.027.612-.028h.366c.187 0 .387.006.612.028-.015-.146-.015-.277-.015-.409.015-.19.03-.365.06-.526a9.29 9.29 0 00-.84-.044z"></path></svg>',groq:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M12.036 2c-3.853-.035-7 3-7.036 6.781-.035 3.782 3.055 6.872 6.908 6.907h2.42v-2.566h-2.292c-2.407.028-4.38-1.866-4.408-4.23-.029-2.362 1.901-4.298 4.308-4.326h.1c2.407 0 4.358 1.915 4.365 4.278v6.305c0 2.342-1.944 4.25-4.323 4.279a4.375 4.375 0 01-3.033-1.252l-1.851 1.818A7 7 0 0012.029 22h.092c3.803-.056 6.858-3.083 6.879-6.816v-6.5C18.907 4.963 15.817 2 12.036 2z"></path></svg>',huggingface:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16.781 3.277c2.997 1.704 4.844 4.851 4.844 8.258 0 .995-.155 1.955-.443 2.857a1.332 1.332 0 011.125.4 1.41 1.41 0 01.2 1.723c.204.165.352.385.428.632l.017.062c.06.222.12.69-.2 1.166.244.37.279.836.093 1.236-.255.57-.893 1.018-2.128 1.5l-.202.078-.131.048c-.478.173-.89.295-1.061.345l-.086.024c-.89.243-1.808.375-2.732.394-1.32 0-2.3-.36-2.923-1.067a9.852 9.852 0 01-3.18.018C9.778 21.647 8.802 22 7.494 22a11.249 11.249 0 01-2.541-.343l-.221-.06-.273-.08a16.574 16.574 0 01-1.175-.405c-1.237-.483-1.875-.93-2.13-1.501-.186-.4-.151-.867.093-1.236a1.42 1.42 0 01-.2-1.166c.069-.273.226-.516.447-.694a1.41 1.41 0 01.2-1.722c.233-.248.557-.391.917-.407l.078-.001a9.385 9.385 0 01-.44-2.85c0-3.407 1.847-6.554 4.844-8.258a9.822 9.822 0 019.687 0zM4.188 14.758c.125.687 2.357 2.35 2.14 2.707-.19.315-.796-.239-.948-.386l-.041-.04-.168-.147c-.561-.479-2.304-1.9-2.74-1.432-.43.46.119.859 1.055 1.42l.784.467.136.083c1.045.643 1.12.84.95 1.113-.188.295-3.07-2.1-3.34-1.083-.27 1.011 2.942 1.304 2.744 2.006-.2.7-2.265-1.324-2.685-.537-.425.79 2.913 1.718 2.94 1.725l.16.04.175.042c1.227.284 3.565.65 4.435-.604.673-.973.64-1.709-.248-2.61l-.057-.057c-.945-.928-1.495-2.288-1.495-2.288l-.017-.058-.025-.072c-.082-.22-.284-.639-.63-.584-.46.073-.798 1.21.12 1.933l.05.038c.977.721-.195 1.21-.573.534l-.058-.104-.143-.25c-.463-.799-1.282-2.111-1.739-2.397-.532-.332-.907-.148-.782.541zm14.842-.541c-.533.335-1.563 2.074-1.94 2.751a.613.613 0 01-.687.302.436.436 0 01-.176-.098.303.303 0 01-.049-.06l-.014-.028-.008-.02-.007-.019-.003-.013-.003-.017a.289.289 0 01-.004-.048c0-.12.071-.266.25-.427.026-.024.054-.047.084-.07l.047-.036c.022-.016.043-.032.063-.049.883-.71.573-1.81.131-1.917l-.031-.006-.056-.004a.368.368 0 00-.062.006l-.028.005-.042.014-.039.017-.028.015-.028.019-.036.027-.023.02c-.173.158-.273.428-.31.542l-.016.054s-.53 1.309-1.439 2.234l-.054.054c-.365.358-.596.69-.702 1.018-.143.437-.066.868.21 1.353.055.097.117.195.187.296.882 1.275 3.282.876 4.494.59l.286-.07.25-.074c.276-.084.736-.233 1.2-.42l.188-.077.065-.028.064-.028.124-.056.081-.038c.529-.252.964-.543.994-.827l.001-.036a.299.299 0 00-.037-.139c-.094-.176-.271-.212-.491-.168l-.045.01c-.044.01-.09.024-.136.04l-.097.035-.054.022c-.559.23-1.238.705-1.607.745h.006a.452.452 0 01-.05.003h-.024l-.024-.003-.023-.005c-.068-.016-.116-.06-.14-.142a.22.22 0 01-.005-.1c.062-.345.958-.595 1.713-.91l.066-.028c.528-.224.97-.483.985-.832v-.04a.47.47 0 00-.016-.098c-.048-.18-.175-.251-.36-.251-.785 0-2.55 1.36-2.92 1.36-.025 0-.048-.007-.058-.024a.6.6 0 01-.046-.088c-.1-.238.068-.462 1.06-1.066l.209-.126c.538-.32 1.01-.588 1.341-.831.29-.212.475-.406.503-.6l.003-.028c.008-.113-.038-.227-.147-.344a.266.266 0 00-.07-.054l-.034-.015-.013-.005a.403.403 0 00-.13-.02c-.162 0-.369.07-.595.18-.637.313-1.431.952-1.826 1.285l-.249.215-.033.033c-.08.078-.288.27-.493.386l-.071.037-.041.019a.535.535 0 01-.122.036h.005a.346.346 0 01-.031.003l.01-.001-.013.001c-.079.005-.145-.021-.19-.095a.113.113 0 01-.014-.065c.027-.465 2.034-1.991 2.152-2.642l.009-.048c.1-.65-.271-.817-.791-.493zM11.938 2.984c-4.798 0-8.688 3.829-8.688 8.55 0 .692.083 1.364.24 2.008l.008-.009c.252-.298.612-.46 1.017-.46.355.008.699.117.993.312.22.14.465.384.715.694.261-.372.69-.598 1.15-.605.852 0 1.367.728 1.562 1.383l.047.105.06.127c.192.396.595 1.139 1.143 1.68 1.06 1.04 1.324 2.115.8 3.266a8.865 8.865 0 002.024-.014c-.505-1.12-.26-2.17.74-3.186l.066-.066c.695-.684 1.157-1.69 1.252-1.912.195-.655.708-1.383 1.56-1.383.46.007.889.233 1.15.605.25-.31.495-.553.718-.694a1.87 1.87 0 01.99-.312c.357 0 .682.126.925.36.14-.61.215-1.245.215-1.898 0-4.722-3.89-8.55-8.687-8.55zm1.857 8.926l.439-.212c.553-.264.89-.383.89.152 0 1.093-.771 3.208-3.155 3.262h-.184c-2.325-.052-3.116-2.06-3.156-3.175l-.001-.087c0-1.107 1.452.586 3.25.586.716 0 1.379-.272 1.917-.526zm4.017-3.143c.45 0 .813.358.813.8 0 .441-.364.8-.813.8a.806.806 0 01-.812-.8c0-.442.364-.8.812-.8zm-11.624 0c.448 0 .812.358.812.8 0 .441-.364.8-.812.8a.806.806 0 01-.813-.8c0-.442.364-.8.813-.8zm7.79-.841c.32-.384.846-.54 1.33-.394.483.146.83.564.878 1.06.048.495-.212.97-.659 1.203-.322.168-.447-.477-.767-.585l.002-.003c-.287-.098-.772.362-.925.079a1.215 1.215 0 01.14-1.36zm-4.323 0c.322.384.377.92.14 1.36-.152.283-.64-.177-.925-.079l.003.003c-.108.036-.194.134-.273.24l-.118.165c-.11.15-.22.262-.377.18a1.226 1.226 0 01-.658-1.204c.048-.495.395-.913.878-1.059a1.262 1.262 0 011.33.394z"></path></svg>',kimi:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M21.846 0a1.923 1.923 0 110 3.846H20.15a.226.226 0 01-.227-.226V1.923C19.923.861 20.784 0 21.846 0z"></path><path d="M11.065 11.199l7.257-7.2c.137-.136.06-.41-.116-.41H14.3a.164.164 0 00-.117.051l-7.82 7.756c-.122.12-.302.013-.302-.179V3.82c0-.127-.083-.23-.185-.23H3.186c-.103 0-.186.103-.186.23V19.77c0 .128.083.23.186.23h2.69c.103 0 .186-.102.186-.23v-3.25c0-.069.025-.135.069-.178l2.424-2.406a.158.158 0 01.205-.023l6.484 4.772a7.677 7.677 0 003.453 1.283c.108.012.2-.095.2-.23v-3.06c0-.117-.07-.212-.164-.227a5.028 5.028 0 01-2.027-.807l-5.613-4.064c-.117-.078-.132-.279-.028-.381z"></path></svg>',minimax:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16.278 2c1.156 0 2.093.927 2.093 2.07v12.501a.74.74 0 00.744.709.74.74 0 00.743-.709V9.099a2.06 2.06 0 012.071-2.049A2.06 2.06 0 0124 9.1v6.561a.649.649 0 01-.652.645.649.649 0 01-.653-.645V9.1a.762.762 0 00-.766-.758.762.762 0 00-.766.758v7.472a2.037 2.037 0 01-2.048 2.026 2.037 2.037 0 01-2.048-2.026v-12.5a.785.785 0 00-.788-.753.785.785 0 00-.789.752l-.001 15.904A2.037 2.037 0 0113.441 22a2.037 2.037 0 01-2.048-2.026V18.04c0-.356.292-.645.652-.645.36 0 .652.289.652.645v1.934c0 .263.142.506.372.638.23.131.514.131.744 0a.734.734 0 00.372-.638V4.07c0-1.143.937-2.07 2.093-2.07zm-5.674 0c1.156 0 2.093.927 2.093 2.07v11.523a.648.648 0 01-.652.645.648.648 0 01-.652-.645V4.07a.785.785 0 00-.789-.78.785.785 0 00-.789.78v14.013a2.06 2.06 0 01-2.07 2.048 2.06 2.06 0 01-2.071-2.048V9.1a.762.762 0 00-.766-.758.762.762 0 00-.766.758v3.8a2.06 2.06 0 01-2.071 2.049A2.06 2.06 0 010 12.9v-1.378c0-.357.292-.646.652-.646.36 0 .653.29.653.646V12.9c0 .418.343.757.766.757s.766-.339.766-.757V9.099a2.06 2.06 0 012.07-2.048 2.06 2.06 0 012.071 2.048v8.984c0 .419.343.758.767.758.423 0 .766-.339.766-.758V4.07c0-1.143.937-2.07 2.093-2.07z"></path></svg>',mistral:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M3.428 3.4h3.429v3.428h3.429v3.429h-.002 3.431V6.828h3.427V3.4h3.43v13.714H24v3.429H13.714v-3.428h-3.428v-3.429h-3.43v3.428h3.43v3.429H0v-3.429h3.428V3.4zm10.286 13.715h3.428v-3.429h-3.427v3.429z"></path></svg>',moonshot:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M1.052 16.916l9.539 2.552a21.007 21.007 0 00.06 2.033l5.956 1.593a11.997 11.997 0 01-5.586.865l-.18-.016-.044-.004-.084-.009-.094-.01a11.605 11.605 0 01-.157-.02l-.107-.014-.11-.016a11.962 11.962 0 01-.32-.051l-.042-.008-.075-.013-.107-.02-.07-.015-.093-.019-.075-.016-.095-.02-.097-.023-.094-.022-.068-.017-.088-.022-.09-.024-.095-.025-.082-.023-.109-.03-.062-.02-.084-.025-.093-.028-.105-.034-.058-.019-.08-.026-.09-.031-.066-.024a6.293 6.293 0 01-.044-.015l-.068-.025-.101-.037-.057-.022-.08-.03-.087-.035-.088-.035-.079-.032-.095-.04-.063-.028-.063-.027a5.655 5.655 0 01-.041-.018l-.066-.03-.103-.047-.052-.024-.096-.046-.062-.03-.084-.04-.086-.044-.093-.047-.052-.027-.103-.055-.057-.03-.058-.032a6.49 6.49 0 01-.046-.026l-.094-.053-.06-.034-.051-.03-.072-.041-.082-.05-.093-.056-.052-.032-.084-.053-.061-.039-.079-.05-.07-.047-.053-.035a7.785 7.785 0 01-.054-.036l-.044-.03-.044-.03a6.066 6.066 0 01-.04-.028l-.057-.04-.076-.054-.069-.05-.074-.054-.056-.042-.076-.057-.076-.059-.086-.067-.045-.035-.064-.052-.074-.06-.089-.073-.046-.039-.046-.039a7.516 7.516 0 01-.043-.037l-.045-.04-.061-.053-.07-.062-.068-.06-.062-.058-.067-.062-.053-.05-.088-.084a13.28 13.28 0 01-.099-.097l-.029-.028-.041-.042-.069-.07-.05-.051-.05-.053a6.457 6.457 0 01-.168-.179l-.08-.088-.062-.07-.071-.08-.042-.049-.053-.062-.058-.068-.046-.056a7.175 7.175 0 01-.027-.033l-.045-.055-.066-.082-.041-.052-.05-.064-.02-.025a11.99 11.99 0 01-1.44-2.402zm-1.02-5.794l11.353 3.037a20.468 20.468 0 00-.469 2.011l10.817 2.894a12.076 12.076 0 01-1.845 2.005L.657 15.923l-.016-.046-.035-.104a11.965 11.965 0 01-.05-.153l-.007-.023a11.896 11.896 0 01-.207-.741l-.03-.126-.018-.08-.021-.097-.018-.081-.018-.09-.017-.084-.018-.094c-.026-.141-.05-.283-.071-.426l-.017-.118-.011-.083-.013-.102a12.01 12.01 0 01-.019-.161l-.005-.047a12.12 12.12 0 01-.034-2.145zm1.593-5.15l11.948 3.196c-.368.605-.705 1.231-1.01 1.875l11.295 3.022c-.142.82-.368 1.612-.668 2.365l-11.55-3.09L.124 10.26l.015-.1.008-.049.01-.067.015-.087.018-.098c.026-.148.056-.295.088-.442l.028-.124.02-.085.024-.097c.022-.09.045-.18.07-.268l.028-.102.023-.083.03-.1.025-.082.03-.096.026-.082.031-.095a11.896 11.896 0 011.01-2.232zm4.442-4.4L17.352 4.59a20.77 20.77 0 00-1.688 1.721l7.823 2.093c.267.852.442 1.744.513 2.665L2.106 5.213l.045-.065.027-.04.04-.055.046-.065.055-.076.054-.072.064-.086.05-.065.057-.073.055-.07.06-.074.055-.069.065-.077.054-.066.066-.077.053-.06.072-.082.053-.06.067-.074.054-.058.073-.078.058-.06.063-.067.168-.17.1-.098.059-.056.076-.071a12.084 12.084 0 012.272-1.677zM12.017 0h.097l.082.001.069.001.054.002.068.002.046.001.076.003.047.002.06.003.054.002.087.005.105.007.144.011.088.007.044.004.077.008.082.008.047.005.102.012.05.006.108.014.081.01.042.006.065.01.207.032.07.012.065.011.14.026.092.018.11.022.046.01.075.016.041.01L14.7.3l.042.01.065.015.049.012.071.017.096.024.112.03.113.03.113.032.05.015.07.02.078.024.073.023.05.016.05.016.076.025.099.033.102.036.048.017.064.023.093.034.11.041.116.045.1.04.047.02.06.024.041.018.063.026.04.018.057.025.11.048.1.046.074.035.075.036.06.028.092.046.091.045.102.052.053.028.049.026.046.024.06.033.041.022.052.029.088.05.106.06.087.051.057.034.053.032.096.059.088.055.098.062.036.024.064.041.084.056.04.027.062.042.062.043.023.017c.054.037.108.075.161.114l.083.06.065.048.056.043.086.065.082.064.04.03.05.041.086.069.079.065.085.071c.712.6 1.353 1.283 1.909 2.031L7.222.994l.062-.027.065-.028.081-.034.086-.035c.113-.045.227-.09.341-.131l.096-.035.093-.033.084-.03.096-.031c.087-.03.176-.058.264-.085l.091-.027.086-.025.102-.03.085-.023.1-.026L9.04.37l.09-.023.091-.022.095-.022.09-.02.098-.021.091-.02.095-.018.092-.018.1-.018.091-.016.098-.017.092-.014.097-.015.092-.013.102-.013.091-.012.105-.012.09-.01.105-.01c.093-.01.186-.018.28-.024l.106-.008.09-.005.11-.006.093-.004.1-.004.097-.002.099-.002.197-.002z"></path></svg>',nvidia:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M10.212 8.976V7.62c.127-.01.256-.017.388-.021 3.596-.117 5.957 3.184 5.957 3.184s-2.548 3.647-5.282 3.647a3.227 3.227 0 01-1.063-.175v-4.109c1.4.174 1.681.812 2.523 2.258l1.873-1.627a4.905 4.905 0 00-3.67-1.846 6.594 6.594 0 00-.729.044m0-4.476v2.025c.13-.01.259-.019.388-.024 5.002-.174 8.261 4.226 8.261 4.226s-3.743 4.69-7.643 4.69c-.338 0-.675-.031-1.007-.092v1.25c.278.038.558.057.838.057 3.629 0 6.253-1.91 8.794-4.169.421.347 2.146 1.193 2.501 1.564-2.416 2.083-8.048 3.763-11.24 3.763-.308 0-.603-.02-.894-.048V19.5H24v-15H10.21zm0 9.756v1.068c-3.356-.616-4.287-4.21-4.287-4.21a7.173 7.173 0 014.287-2.138v1.172h-.005a3.182 3.182 0 00-2.502 1.178s.615 2.276 2.507 2.931m-5.961-3.3c1.436-1.935 3.604-3.148 5.961-3.336V6.523C5.81 6.887 2 10.723 2 10.723s2.158 6.427 8.21 7.015v-1.166C5.77 16 4.25 10.958 4.25 10.958h-.002z"></path></svg>',openai:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M9.205 8.658v-2.26c0-.19.072-.333.238-.428l4.543-2.616c.619-.357 1.356-.523 2.117-.523 2.854 0 4.662 2.212 4.662 4.566 0 .167 0 .357-.024.547l-4.71-2.759a.797.797 0 00-.856 0l-5.97 3.473zm10.609 8.8V12.06c0-.333-.143-.57-.429-.737l-5.97-3.473 1.95-1.118a.433.433 0 01.476 0l4.543 2.617c1.309.76 2.189 2.378 2.189 3.948 0 1.808-1.07 3.473-2.76 4.163zM7.802 12.703l-1.95-1.142c-.167-.095-.239-.238-.239-.428V5.899c0-2.545 1.95-4.472 4.591-4.472 1 0 1.927.333 2.712.928L8.23 5.067c-.285.166-.428.404-.428.737v6.898zM12 15.128l-2.795-1.57v-3.33L12 8.658l2.795 1.57v3.33L12 15.128zm1.796 7.23c-1 0-1.927-.332-2.712-.927l4.686-2.712c.285-.166.428-.404.428-.737v-6.898l1.974 1.142c.167.095.238.238.238.428v5.233c0 2.545-1.974 4.472-4.614 4.472zm-5.637-5.303l-4.544-2.617c-1.308-.761-2.188-2.378-2.188-3.948A4.482 4.482 0 014.21 6.327v5.423c0 .333.143.571.428.738l5.947 3.449-1.95 1.118a.432.432 0 01-.476 0zm-.262 3.9c-2.688 0-4.662-2.021-4.662-4.519 0-.19.024-.38.047-.57l4.686 2.71c.286.167.571.167.856 0l5.97-3.448v2.26c0 .19-.07.333-.237.428l-4.543 2.616c-.619.357-1.356.523-2.117.523zm5.899 2.83a5.947 5.947 0 005.827-4.756C22.287 18.339 24 15.84 24 13.296c0-1.665-.713-3.282-1.998-4.448.119-.5.19-.999.19-1.498 0-3.401-2.759-5.947-5.946-5.947-.642 0-1.26.095-1.88.31A5.962 5.962 0 0010.205 0a5.947 5.947 0 00-5.827 4.757C1.713 5.447 0 7.945 0 10.49c0 1.666.713 3.283 1.998 4.448-.119.5-.19 1-.19 1.499 0 3.401 2.759 5.946 5.946 5.946.642 0 1.26-.095 1.88-.309a5.96 5.96 0 004.162 1.713z"></path></svg>',opencode:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 6H8v12h8V6zm4 16H4V2h16v20z"></path></svg>',openrouter:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M18.654 3.87a5.087 5.087 0 110 10.174L23.7 19.09c.64.641.187 1.737-.72 1.737H8.48a8.479 8.479 0 010-16.958h10.175zM8.479 7.26a5.087 5.087 0 100 10.176 5.087 5.087 0 000-10.175z"></path></svg>',qwen:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M12.604 1.34c.393.69.784 1.382 1.174 2.075a.18.18 0 00.157.091h5.552c.174 0 .322.11.446.327l1.454 2.57c.19.337.24.478.024.837-.26.43-.513.864-.76 1.3l-.367.658c-.106.196-.223.28-.04.512l2.652 4.637c.172.301.111.494-.043.77-.437.785-.882 1.564-1.335 2.34-.159.272-.352.375-.68.37-.777-.016-1.552-.01-2.327.016a.099.099 0 00-.081.05 575.097 575.097 0 01-2.705 4.74c-.169.293-.38.363-.725.364-.997.003-2.002.004-3.017.002a.537.537 0 01-.465-.271l-1.335-2.323a.09.09 0 00-.083-.049H4.982c-.285.03-.553-.001-.805-.092l-1.603-2.77a.543.543 0 01-.002-.54l1.207-2.12a.198.198 0 000-.197 550.951 550.951 0 01-1.875-3.272l-.79-1.395c-.16-.31-.173-.496.095-.965.465-.813.927-1.625 1.387-2.436.132-.234.304-.334.584-.335a338.3 338.3 0 012.589-.001.124.124 0 00.107-.063l2.806-4.895a.488.488 0 01.422-.246c.524-.001 1.053 0 1.583-.006L11.704 1c.341-.003.724.032.9.34zm-3.432.403a.06.06 0 00-.052.03L6.254 6.788a.157.157 0 01-.135.078H3.253c-.056 0-.07.025-.041.074l5.81 10.156c.025.042.013.062-.034.063l-2.795.015a.218.218 0 00-.2.116l-1.32 2.31c-.044.078-.021.118.068.118l5.716.008c.046 0 .08.02.104.061l1.403 2.454c.046.081.092.082.139 0l5.006-8.76.783-1.382a.055.055 0 01.096 0l1.424 2.53a.122.122 0 00.107.062l2.763-.02a.04.04 0 00.035-.02.041.041 0 000-.04l-2.9-5.086a.108.108 0 010-.113l.293-.507 1.12-1.977c.024-.041.012-.062-.035-.062H9.2c-.059 0-.073-.026-.043-.077l1.434-2.505a.107.107 0 000-.114L9.225 1.774a.06.06 0 00-.053-.031zm6.29 8.02c.046 0 .058.02.034.06l-.832 1.465-2.613 4.585a.056.056 0 01-.05.029.058.058 0 01-.05-.029L8.498 9.841c-.02-.034-.01-.052.028-.054l.216-.012 6.722-.012z"></path></svg>',together:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M23.197 4.503A6 6 0 0015 2.307a5.973 5.973 0 00-2.995 4.933l5.996.008v.515h-5.996c.039.937.298 1.87.8 2.74a6 6 0 1010.39-6z"></path><path d="M.805 4.5A6 6 0 003 12.697a5.972 5.972 0 005.77.127L5.779 7.627l.446-.257 2.997 5.192A6 6 0 10.804 4.5z"></path><path d="M12 23.894a6 6 0 005.999-6c0-2.13-1.1-3.996-2.775-5.06l-3.005 5.189-.444-.258 2.997-5.192A6 6 0 1012 23.894z"></path></svg>',vercel:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M12 0l12 20.785H0L12 0z"></path></svg>',vertexai:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M11.995 20.216a1.892 1.892 0 100 3.785 1.892 1.892 0 000-3.785zm0 2.806a.927.927 0 11.927-.914.914.914 0 01-.927.914z"></path><path clip-rule="evenodd" d="M21.687 14.144c.237.038.452.16.605.344a.978.978 0 01-.18 1.3l-8.24 6.082a1.892 1.892 0 00-1.147-1.508l8.28-6.08a.991.991 0 01.682-.138z"></path><path clip-rule="evenodd" d="M10.122 21.842l-8.217-6.066a.952.952 0 01-.206-1.287.978.978 0 011.287-.206l8.28 6.08a1.893 1.893 0 00-1.144 1.479z"></path><path d="M4.273 4.475a.978.978 0 01-.965-.965V1.09a.978.978 0 111.943 0v2.42a.978.978 0 01-.978.965zM4.247 13.034a.978.978 0 100-1.956.978.978 0 000 1.956zM4.247 10.19a.978.978 0 100-1.956.978.978 0 000 1.956zM4.247 7.332a.978.978 0 100-1.956.978.978 0 000 1.956z"></path><path d="M19.718 7.307a.978.978 0 01-.965-.979v-2.42a.965.965 0 011.93 0v2.42a.964.964 0 01-.965.979zM19.743 13.047a.978.978 0 100-1.956.978.978 0 000 1.956zM19.743 10.151a.978.978 0 100-1.956.978.978 0 000 1.956zM19.743 2.068a.978.978 0 100-1.956.978.978 0 000 1.956z"></path><path d="M11.995 15.917a.978.978 0 01-.965-.965v-2.459a.978.978 0 011.943 0v2.433a.976.976 0 01-.978.991zM11.995 18.762a.978.978 0 100-1.956.978.978 0 000 1.956zM11.995 10.64a.978.978 0 100-1.956.978.978 0 000 1.956zM11.995 7.783a.978.978 0 100-1.956.978.978 0 000 1.956z"></path><path d="M15.856 10.177a.978.978 0 01-.965-.965v-2.42a.977.977 0 011.702-.763.979.979 0 01.241.763v2.42a.978.978 0 01-.978.965zM15.869 4.913a.978.978 0 100-1.956.978.978 0 000 1.956zM15.869 15.853a.978.978 0 100-1.956.978.978 0 000 1.956zM15.869 12.996a.978.978 0 100-1.956.978.978 0 000 1.956z"></path><path d="M8.121 15.853a.978.978 0 100-1.956.978.978 0 000 1.956zM8.121 7.783a.978.978 0 100-1.956.978.978 0 000 1.956zM8.121 4.913a.978.978 0 100-1.957.978.978 0 000 1.957zM8.134 12.996a.978.978 0 01-.978-.94V9.611a.965.965 0 011.93 0v2.445a.966.966 0 01-.952.94z"></path></svg>',xai:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M6.469 8.776L16.512 23h-4.464L2.005 8.776H6.47zm-.004 7.9l2.233 3.164L6.467 23H2l4.465-6.324zM22 2.582V23h-3.659V7.764L22 2.582zM22 1l-9.952 14.095-2.233-3.163L17.533 1H22z"></path></svg>',xiaomimimo:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M.958 15.936a.459.459 0 01.459.44v2.729a.46.46 0 01-.918 0v-2.729a.459.459 0 01.459-.44zm4.814-2.035a.46.46 0 01.553.45v4.754a.458.458 0 11-.918 0V15.48L3.74 17.202a.462.462 0 01-.655.016.462.462 0 01-.065-.082L.628 14.67a.459.459 0 01.658-.637l2.124 2.187 2.127-2.188a.46.46 0 01.235-.13zm2.068.004a.46.46 0 01.458.445v4.755a.46.46 0 01-.458.458.459.459 0 01-.458-.458V14.35a.459.459 0 01.458-.445zm1.973 2.014a.46.46 0 01.46.457v2.729a.46.46 0 01-.784.324.46.46 0 01-.134-.324v-2.729a.46.46 0 01.458-.458zm.002-2.045a.458.458 0 01.328.157l2.127 2.19 2.125-2.19a.459.459 0 01.784.318v4.756a.46.46 0 01-.455.458.46.46 0 01-.458-.458V15.48l-1.667 1.723a.46.46 0 01-.65.008l-.005-.005c0-.002-.002-.002-.004-.003l-2.455-2.534a.46.46 0 01-.008-.667.461.461 0 01.338-.128zm6.797 1.206a.46.46 0 01.53.651A1.966 1.966 0 0019.81 18.4a.462.462 0 01.623.18.46.46 0 01-.181.624 2.863 2.863 0 01-1.38.353l-.142-.004a2.88 2.88 0 01-2.393-4.263.461.461 0 01.274-.21zm.864-.931a2.884 2.884 0 013.915 3.914.46.46 0 01-.402.24l-.057-.004a.458.458 0 01-.164-.055.46.46 0 01-.182-.622 1.967 1.967 0 00-2.669-2.67.459.459 0 11-.441-.803zM9.59 6.368c1.481 0 1.696 1.202 1.696 1.654v2.648h-.917v-.432c-.26.346-.792.535-1.36.535-.133 0-1.289-.03-1.384-1.136-.082-.932.675-1.61 2.053-1.61h.691c0-.563-.367-.886-.983-.886-.44.013-.864.174-1.2.458l-.36-.664c.484-.379 1.012-.567 1.764-.567zm4.427.1c1.263 0 2.082.97 2.083 2.15 0 1.181-.824 2.154-2.083 2.154-1.26 0-2.084-.972-2.084-2.152 0-1.18.82-2.153 2.084-2.153zm6.801.015c.68 0 1.202.465 1.197 1.548v2.642H21.1V8.29c0-.312-.002-.98-.63-.98s-.628.667-.628.838v2.524h-.89V8.148c0-.17-.001-.838-.63-.838-.628 0-.628.668-.628.98v2.383h-.917v-4.03h.917V7a1.22 1.22 0 01.947-.516c.398 0 .76.193.982.686a1.321 1.321 0 011.195-.686zm-18.093.872l1.457-1.772H5.32L3.311 8.07l2.14 2.602H4.24L2.725 8.796 1.21 10.672H0L2.138 8.07.13 5.583h1.138l1.458 1.772zm4.149 3.317h-.916V6.644h.916v4.028zm16.99 0h-.916V6.644h.916v4.028zM9.925 8.71c-1.055 0-1.359.412-1.326.742.032.329.324.537.757.537a1.013 1.013 0 001.014-.968l.002-.31h-.447zM14.018 7.3c-.663 0-1.184.487-1.184 1.32 0 .832.52 1.32 1.184 1.32.662 0 1.182-.49 1.182-1.32 0-.832-.52-1.32-1.182-1.32zM6.417 5.001a.568.568 0 01.587.582.588.588 0 01-1.175 0A.57.57 0 016.417 5zm16.991 0a.57.57 0 01.592.582.588.588 0 01-1.174 0 .57.57 0 01.357-.542.572.572 0 01.225-.04z"></path></svg>',zai:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M12.105 2L9.927 4.953H.653L2.83 2h9.276zM23.254 19.048L21.078 22h-9.242l2.174-2.952h9.244zM24 2L9.264 22H0L14.736 2H24z"></path></svg>'},Nj={"amazon-bedrock":"bedrock","ant-ling":"antgroup",anthropic:"anthropic",azure:"azure","azure-openai-responses":"azure",cerebras:"cerebras",claude:"claude","claude-code":"claude",cloudflare:"cloudflare","cloudflare-ai-gateway":"cloudflare","cloudflare-workers-ai":"cloudflare",deepseek:"deepseek",fireworks:"fireworks",gemini:"gemini","github-copilot":"githubcopilot",google:"gemini","google-vertex":"vertexai",groq:"groq",huggingface:"huggingface",kimi:"kimi","kimi-coding":"kimi",minimax:"minimax","minimax-cn":"minimax",mistral:"mistral",moonshotai:"moonshot","moonshotai-cn":"moonshot",nvidia:"nvidia",openai:"openai","openai-codex":"codex",opencode:"opencode","opencode-go":"opencode",openrouter:"openrouter",qwen:"qwen","qwen-token-plan":"qwen","qwen-token-plan-cn":"qwen",together:"together","vercel-ai-gateway":"vercel",xai:"xai",xiaomi:"xiaomimimo","xiaomi-token-plan-ams":"xiaomimimo","xiaomi-token-plan-cn":"xiaomimimo","xiaomi-token-plan-sgp":"xiaomimimo",zai:"zai","zai-coding-cn":"zai"};function sz(e){const t=Nj[e]??Nj[e.split("-",1)[0]??""];return t?iz[t]??null:null}function nh({provider:e,label:t,size:n=16}){const r=sz(e);return r?o.jsx("span",{"aria-hidden":!0,"data-provider-icon":e,style:{fontSize:n,lineHeight:0,display:"inline-flex",flex:"none"},dangerouslySetInnerHTML:{__html:r}}):o.jsx("span",{"aria-hidden":!0,"data-provider-icon":e,style:{width:n,height:n,borderRadius:"50%",flex:"none",boxSizing:"border-box",display:"inline-flex",alignItems:"center",justifyContent:"center",background:"var(--proto-alt)",border:"1px solid var(--proto-line)",fontSize:Math.round(n*.55),fontWeight:700,color:"var(--proto-muted-2)",lineHeight:1},children:(t.trim()[0]??"?").toUpperCase()})}const z0={"logged-in":{kind:"logged-in",tone:"done",labelKey:"accountsStatusLoggedIn"},expiring:{kind:"expiring",tone:"waiting",labelKey:"accountsStatusExpiring"},"logged-out":{kind:"logged-out",tone:"cancelled",labelKey:"accountsStatusLoggedOut"},expired:{kind:"invalid",tone:"failed",labelKey:"accountsStatusInvalid"},unknown:{kind:"invalid",tone:"failed",labelKey:"accountsStatusInvalid"}},az=["oauth","api_key"];function lz(e){return{...z0[e.state],source:e.source,expiresAt:e.expiresAt}}function cz(){return{...z0["logged-out"],source:null,expiresAt:null}}function dz(e,t){const n=e.credentials.filter(r=>r.authType===t);return{authType:t,credentials:n.length>0?n.map(lz):[cz()],canLogin:e.capabilities.includes(t),canLogout:n.some(r=>r.manageable)}}function uz(e){return e?{provider:e.provider,label:e.label,inUse:e.inUse,slots:az.map(t=>dz(e,t))}:null}function pz(e,t){const n=e.credentials.filter(r=>r.authType===t);return e.authType!==t?n[0]:n.find(r=>r.source===e.source)??n[0]}function fz(e){return[...new Set(e.credentials.map(n=>n.authType))].filter(n=>{var r;return(r=pz(e,n))==null?void 0:r.manageable})}function hz(e){return{backend:"pi",provider:e.provider,label:e.label,inUse:e.inUse,loginTypes:[...e.capabilities],logoutTypes:fz(e),status:z0[e.state],source:e.source,expiresAt:e.expiresAt}}function gz(e,t){return Number(t.inUse)-Number(e.inUse)||e.label.localeCompare(t.label)}function mg(e){return e==="logged-in"||e==="expiring"}function xz(e){return[["in-use","accountsGroupInUse",n=>n.inUse],["logged-in","accountsGroupLoggedIn",n=>!n.inUse&&(n.status.kind==="logged-in"||n.status.kind==="expiring")],["other","accountsGroupOther",n=>!n.inUse&&n.status.kind!=="logged-in"&&n.status.kind!=="expiring"]].map(([n,r,i])=>({key:n,labelKey:r,providers:e.filter(i)})).filter(n=>n.providers.length>0)}function mz(e,t){const n=t.trim().toLocaleLowerCase();return!n||e.provider.toLocaleLowerCase().includes(n)||e.label.toLocaleLowerCase().includes(n)}function vz(e){const t=e.find(i=>i.backend==="claude"),n=!!t&&(mg(t.state)||t.credentials.some(i=>mg(i.state))),r=e.filter(i=>i.backend==="pi"&&mg(i.state)).length;return{claudeLoggedIn:n,piLoggedInCount:r}}function B0(e,t=""){const n=e.accounts.find(i=>i.backend==="claude"),r=e.accounts.filter(i=>i.backend==="pi"&&mz(i,t)).map(hz).sort(gz);return{claude:uz(n),piProviders:r,groups:xz(r),summary:vz(e.accounts)}}const b6=["anthropic-messages","openai-completions","openai-responses","google-generative-ai"],yz=/^[a-zA-Z0-9_-]+$/;function j6(){return{name:"",api:"anthropic-messages",upstreamUrl:"",apiKey:"",models:""}}function w6(e){return{name:e.name,api:e.api,upstreamUrl:e.upstreamUrl??"",apiKey:"",models:e.models.map(t=>t.id).join(`
|
|
119
|
+
`)}}function k6(e){return e.split(/[\n,]/).map(t=>t.trim()).filter(t=>t!=="")}function S6(e,t){const n={},r=e.name.trim();r===""?n.name="name-required":yz.test(r)?t.mode==="create"&&t.existingNames.includes(r)&&(n.name="name-taken"):n.name="name-charset";const i=e.upstreamUrl.trim();i===""?n.upstreamUrl="upstream-required":/^https?:\/\/\S+$/i.test(i)||(n.upstreamUrl="upstream-scheme");const s=k6(e.models);return s.length===0?n.models="models-required":new Set(s).size!==s.length&&(n.models="model-id-duplicate"),n}function C6(e){return Object.keys(e).length===0}function T6(e){const t={name:e.name.trim(),api:e.api,upstreamUrl:e.upstreamUrl.trim(),models:k6(e.models).map(r=>({id:r}))},n=e.apiKey.trim();return n!==""&&(t.apiKey=n),t}const Cc="'IBM Plex Mono',monospace",bz={"name-required":"cpvErrNameRequired","name-charset":"cpvErrNameCharset","name-taken":"cpvErrNameTaken","upstream-required":"cpvErrUpstreamRequired","upstream-scheme":"cpvErrUpstreamScheme","models-required":"cpvErrModelsRequired","model-id-duplicate":"cpvErrModelsDuplicate"};function $j({children:e,tone:t}){return o.jsx("span",{style:{font:`600 9px ${Cc}`,color:t==="warn"?"var(--proto-amber-fg)":"var(--proto-muted-2)",border:"1px solid var(--proto-line-2)",borderRadius:999,padding:"2px 7px"},children:e})}function jz({provider:e,disabled:t,confirming:n,onEdit:r,onDelete:i}){const s=B();return o.jsxs("div",{"data-custom-provider":e.name,style:{padding:"11px 14px",borderBottom:"1px solid var(--proto-alt)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,flexWrap:"wrap"},children:[o.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:e.name}),o.jsx("span",{style:{font:`400 9px ${Cc}`,color:"var(--proto-muted-3)"},children:e.api}),e.routed?null:o.jsx($j,{tone:"warn",children:s.cpvUnrouted}),o.jsx($j,{tone:"muted",children:e.hasApiKey?s.cpvKeyStored:s.cpvNoKey})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8,flexWrap:"wrap"},children:[o.jsx("span",{style:{font:`400 9.5px ${Cc}`,color:"var(--proto-muted-2)",overflowWrap:"anywhere"},children:e.upstreamUrl??"—"}),o.jsx("span",{style:{font:`400 9.5px ${Cc}`,color:"var(--proto-muted-2)",overflowWrap:"anywhere"},children:e.models.map(a=>a.id).join(", ")}),o.jsxs("span",{style:{marginLeft:"auto",display:"flex",gap:6},children:[o.jsx(Qe,{tone:"neutral","data-cpv-action":"edit",disabled:t,onClick:r,children:s.cpvEdit}),o.jsx(Qe,{tone:"danger","data-cpv-action":"delete",disabled:t,onClick:i,children:n?s.cpvConfirmDelete:s.cpvDelete})]})]})]})}function wz({draft:e,creating:t,errors:n,onChange:r}){const i=B(),s=c=>r({...e,...c}),a=(c,d)=>{const u=n[c];return u?i[bz[u]]:d},l=c=>n[c]?"danger":"muted";return o.jsxs(o.Fragment,{children:[o.jsx(uo,{children:t?i.cpvCreateTitle:i.cpvEditTitle}),o.jsx(et,{label:i.cpvFieldName,hint:a("name",t?i.cpvNameHint:i.cpvNoRename),hintTone:l("name"),children:o.jsx("input",{"data-cpv-field":"name",value:e.name,disabled:!t,onChange:c=>s({name:c.target.value}),style:t?$e:N0})}),o.jsx(et,{label:i.cpvFieldApi,hint:i.cpvApiHint,children:o.jsx("select",{"data-cpv-field":"api",value:e.api,onChange:c=>s({api:c.target.value}),style:$e,children:b6.map(c=>o.jsx("option",{value:c,children:c},c))})}),o.jsx(et,{label:i.cpvFieldUrl,hint:a("upstreamUrl",i.cpvUrlHint),hintTone:l("upstreamUrl"),children:o.jsx("input",{"data-cpv-field":"url",value:e.upstreamUrl,onChange:c=>s({upstreamUrl:c.target.value}),style:$e})}),o.jsx(et,{label:i.cpvFieldKey,hint:i.cpvKeyHint,children:o.jsx("input",{"data-cpv-field":"key",type:"password",value:e.apiKey,placeholder:i.cpvKeyPlaceholder,onChange:c=>s({apiKey:c.target.value}),style:$e})}),o.jsx(et,{label:i.cpvFieldModels,hint:a("models",i.cpvModelsHint),hintTone:l("models"),children:o.jsx("textarea",{"data-cpv-field":"models",value:e.models,rows:3,onChange:c=>s({models:c.target.value}),style:{...$e,resize:"vertical"}})})]})}function kz(){const e=B(),t=ae(),n=je(),{toast:r}=Tn(),[i,s]=f.useState(null),[a,l]=f.useState(!1),[c,d]=f.useState(null),p=G(t.auth.customProviders.queryOptions({})).data??[],h=()=>{n.invalidateQueries(t.auth.customProviders.queryFilter({})),n.invalidateQueries(t.auth.status.queryFilter({}))},g=k=>r({title:`${e.cpvToastFailed}: ${k.message}`,tone:"failed"}),v=ue(t.auth.upsertCustomProvider.mutationOptions({onSuccess:()=>{h(),s(null),r({title:e.cpvToastSaved,tone:"done"})},onError:g})),x=ue(t.auth.removeCustomProvider.mutationOptions({onSuccess:()=>{h(),d(null),r({title:e.cpvToastDeleted,tone:"done"})},onError:g})),w=v.isPending||x.isPending,b=i?S6(i,{mode:a?"create":"update",existingNames:p.map(k=>k.name)}):{},y=()=>{l(!0),s(j6())},j=k=>{l(!1),s(w6(k))},S=k=>{if(c!==k){d(k);return}x.mutate({name:k})};return o.jsxs(He,{style:{marginTop:12,maxWidth:980,overflow:"hidden"},children:[o.jsx(_n,{title:e.cpvTitle,right:o.jsx(Qe,{tone:"accent","data-cpv-action":"new",disabled:w||i!==null,onClick:y,children:e.cpvNew})}),o.jsx("div",{style:{padding:"8px 14px 0",font:`400 10px ${Cc}`,color:"var(--proto-muted-3)"},children:e.cpvSubtitle}),p.length>0?p.map(k=>o.jsx(jz,{provider:k,disabled:w,confirming:c===k.name,onEdit:()=>j(k),onDelete:()=>S(k.name)},k.name)):o.jsx("div",{style:{padding:"12px 14px",color:"var(--proto-muted-3)",fontSize:11},children:e.cpvNone}),i?o.jsxs("div",{style:{padding:"4px 14px 14px"},children:[o.jsx(wz,{draft:i,creating:a,errors:b,onChange:s}),o.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end",marginTop:10},children:[o.jsx(Qe,{tone:"neutral","data-cpv-action":"cancel",disabled:w,onClick:()=>s(null),children:e.cpvCancel}),o.jsx(Qe,{tone:"accent","data-cpv-action":"save",disabled:w||!C6(b),onClick:()=>v.mutate(T6(i)),children:e.cpvSave})]})]}):null]})}const sd="'IBM Plex Mono',monospace",Sz={done:"var(--proto-success)",waiting:"var(--proto-amber-fg)",failed:"var(--proto-danger)",cancelled:"var(--proto-muted-2)"};function Cz({value:e}){const t=B();return o.jsxs("span",{"data-account-state":e.kind,style:{display:"inline-flex",alignItems:"center",gap:5,font:`600 10px ${sd}`,color:Sz[e.tone]},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"currentColor",flex:"none"}}),t[e.labelKey]]})}function uc(e,t,n){return t==="api_key"?e.authLoginApiKey:n==="claude"?e.authLoginSubscription:e.authLoginOAuth}function E6({value:e}){const t=B();return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[o.jsx(Cz,{value:e}),o.jsxs("span",{style:{font:`400 9.5px ${sd}`,color:"var(--proto-muted-2)"},children:[t.accountsSource,": ",e.source??"—"]}),e.expiresAt?o.jsxs("span",{style:{font:`400 9.5px ${sd}`,color:"var(--proto-muted-2)"},children:[t.accountsExpires,": ",e.expiresAt]}):null]})}function Tz({authType:e}){const t=B();return o.jsx("span",{style:{font:`600 9px ${sd}`,color:"var(--proto-accent)",background:"var(--proto-accent-bg)",borderRadius:999,padding:"2px 7px"},children:e==="api_key"?t.authLoginApiKey:t.authLoginOAuth})}function R6(e){const t=B(),n=r=>({backend:e.backend,provider:e.provider,authType:r});return o.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",justifyContent:"flex-end"},children:[e.loginTypes.map(r=>o.jsxs(Qe,{tone:"accent",disabled:e.disabled,"data-auth-action":"login","data-backend":e.backend,"data-provider":e.provider,"data-auth-type":r,"aria-label":`${t.accountsLogin} ${uc(t,r,e.backend)}`,onClick:()=>e.onLogin(n(r)),children:[t.accountsLogin," ",uc(t,r,e.backend)]},`login:${r}`)),e.logoutTypes.map(r=>o.jsxs(Qe,{tone:"danger",disabled:e.disabled,"data-auth-action":"logout","data-backend":e.backend,"data-provider":e.provider,"data-auth-type":r,"aria-label":`${t.accountsLogout} ${uc(t,r,e.backend)}`,onClick:()=>e.onLogout(n(r)),children:[t.accountsLogout," ",uc(t,r,e.backend)]},`logout:${r}`))]})}function Ez({account:e,actions:t}){const n=B();return o.jsxs(He,{style:{marginTop:12,maxWidth:980},children:[o.jsx(_n,{title:o.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:7},children:[o.jsx(nh,{provider:"claude-code",label:"Claude Code",size:15}),"Claude Code"]}),right:e.inUse?n.accountsInUse:void 0}),o.jsx("div",{style:{padding:"8px 14px"},children:e.slots.map(r=>o.jsx(et,{label:uc(n,r.authType,"claude"),children:o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:7},children:[r.credentials.map((i,s)=>o.jsx(E6,{value:i},`${i.source??"none"}:${s}`)),o.jsx(R6,{...t,backend:"claude",provider:e.provider,loginTypes:r.canLogin?[r.authType]:[],logoutTypes:r.canLogout?[r.authType]:[]})]})},r.authType))})]})}function Rz({provider:e,actions:t}){const n=B(),r={...e.status,source:e.source,expiresAt:e.expiresAt};return o.jsxs("div",{style:{padding:"11px 14px",borderBottom:"1px solid var(--proto-alt)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,flexWrap:"wrap"},children:[o.jsx(nh,{provider:e.provider,label:e.label,size:16}),o.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:e.label}),o.jsx("span",{style:{font:`400 9px ${sd}`,color:"var(--proto-muted-3)"},children:e.provider}),e.inUse?o.jsx("span",{style:{fontSize:9,fontWeight:650,color:"var(--proto-success)",background:"var(--proto-success-bg)",borderRadius:999,padding:"2px 7px"},children:n.accountsInUse}):null,e.loginTypes.map(i=>o.jsx(Tz,{authType:i},i))]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8,flexWrap:"wrap"},children:[o.jsx(E6,{value:r}),o.jsx("span",{style:{marginLeft:"auto"},children:o.jsx(R6,{...t,backend:"pi",provider:e.provider,loginTypes:e.loginTypes,logoutTypes:e.logoutTypes})})]})]})}function Pz({providers:e,filter:t,onFilter:n,actions:r}){const i=B();return o.jsxs(He,{style:{marginTop:12,maxWidth:980,overflow:"hidden"},children:[o.jsx(_n,{title:i.accountsPiProviders,right:`${e.length}`}),o.jsx("div",{style:{padding:"10px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:o.jsx("input",{"data-accounts-filter":!0,"aria-label":i.accountsFilter,value:t,onChange:s=>n(s.target.value),placeholder:i.accountsFilterPlaceholder,style:$e})}),e.length>0?e.map(s=>o.jsx(Rz,{provider:s,actions:r},s.provider)):o.jsx("div",{style:{padding:"12px 14px",color:"var(--proto-muted-3)",fontSize:11},children:i.accountsNoProviders})]})}function Iz({onLogin:e}){const t=B(),n=ae(),r=je(),{toast:i}=Tn(),{openLogin:s}=E0(),[a,l]=f.useState(""),c=G(n.auth.status.queryOptions({})),d=ue(n.auth.logout.mutationOptions({onSuccess:()=>{r.invalidateQueries(n.auth.status.queryFilter({})),i({title:t.accountsLogoutDone,tone:"done"})},onError:h=>i({title:`${t.accountsLogoutFailed}: ${h.message}`,tone:"failed"})}));if(c.isLoading)return o.jsx("div",{style:{marginTop:16},children:t.accountsLoading});if(c.isError||!c.data)return o.jsx("div",{style:{marginTop:16,color:"var(--proto-danger)"},children:t.accountsLoadFailed});const u=B0(c.data,a),p={disabled:d.isPending,onLogin:e??s,onLogout:h=>d.mutate(h)};return o.jsxs(o.Fragment,{children:[u.claude?o.jsx(Ez,{account:u.claude,actions:p}):null,o.jsx(Pz,{providers:u.piProviders,filter:a,onFilter:l,actions:p}),o.jsx(kz,{})]})}const Mz="'IBM Plex Mono',monospace",Lz={position:"fixed",inset:0,background:"rgba(25,28,34,.34)",zIndex:60},Oz={position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",width:1080,maxWidth:"94vw",height:680,maxHeight:"90vh",background:"var(--proto-card)",borderRadius:14,boxShadow:"0 24px 64px rgba(16,24,40,.3)",zIndex:61,overflow:"hidden",display:"flex",flexDirection:"column"},Dz={position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0};function Az({open:e,onClose:t}){const n=B();return o.jsx(Co,{open:e,onOpenChange:r=>{r||t()},children:o.jsxs(To,{children:[o.jsx(Eo,{style:Lz,className:"animate-cxfade motion-reduce:animate-none"}),o.jsxs(Ro,{"aria-describedby":void 0,style:Oz,className:"animate-cxmodal focus:outline-none motion-reduce:animate-none",children:[o.jsx(Oi,{style:Dz,children:n.settings}),e?o.jsx(Nz,{onClose:t}):null]})]})})}function Nz({onClose:e}){const t=B(),n=ae(),r=je(),{toast:i}=Tn(),{openLogin:s}=E0(),[a,l]=f.useState("appearance"),c=G(n.config.get.queryOptions({})),d=G(n.cost.summary.queryOptions({})),u=c.data,p=a_(t,a),h=ue(n.config.set.mutationOptions({onSuccess:(b,y)=>{r.invalidateQueries(n.config.get.queryFilter({}));const j=y.section==="profiles"?y.value.defaultProfile:"";i({title:`Default profile → ${j} · ${t.stToastDefaultProfile}`,tone:"done"})},onError:b=>i({title:`${t.stToastWriteFailed}: ${b.message}`,tone:"failed"})})),g=ue(n.approvals.request.mutationOptions({onSuccess:()=>i({title:t.stToastQueuedApproval,tone:"waiting"}),onError:b=>i({title:`${t.stToastCouldNotQueue}: ${b.message}`,tone:"failed"})})),v=b=>h.mutate({section:"profiles",value:{defaultProfile:b}}),x=b=>g.mutate({kind:"reconnect-platform",platform:b}),w=b=>g.mutate({kind:"add-machine",machineName:b});return o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{height:48,flex:"none",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:9,padding:"0 18px",background:"var(--proto-card)"},children:[o.jsx("span",{style:{fontSize:13,fontWeight:650,color:"var(--proto-ink)"},children:t.settings}),o.jsx("span",{onClick:e,role:"button",style:{marginLeft:"auto",font:`500 9.5px ${Mz}`,color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:t.stEsc})]}),o.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[o.jsx("div",{style:{width:210,flex:"none",borderRight:"1px solid var(--proto-line)",background:"var(--proto-rail)",padding:"10px 8px",overflow:"auto"},children:s_(t).map(b=>{const y=b.key===a;return o.jsx("div",{onClick:()=>l(b.key),role:"button","data-settings-nav":b.key,style:{display:"flex",alignItems:"center",gap:8,padding:"7px 10px",background:y?"var(--proto-accent-bg)":"transparent",borderRadius:8,cursor:"pointer"},children:o.jsx("span",{style:{fontSize:12,fontWeight:600,color:y?"var(--proto-accent)":"var(--proto-ink-2)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:b.label})},b.key)})}),o.jsxs("div",{style:{flex:1,minWidth:0,overflow:"auto",padding:"16px 22px",background:"var(--proto-alt)",display:a==="hooks"?"flex":void 0,flexDirection:a==="hooks"?"column":void 0},children:[o.jsx("div",{style:{fontSize:15,fontWeight:650,color:"var(--proto-ink)"},children:p.title}),o.jsx("div",{style:{fontSize:11,color:"var(--proto-muted-2)",marginTop:2},children:p.sub}),a==="appearance"?o.jsx(oz,{}):a==="accounts"?o.jsx(Iz,{onLogin:b=>{e(),s(b)}}):c.isLoading?o.jsx("div",{style:{marginTop:16,fontSize:12,color:"var(--proto-muted-3)"},children:t.stLoadingConfig}):c.isError?o.jsxs("div",{style:{marginTop:16,fontSize:12,color:"var(--proto-danger)"},children:[t.stFailedLoadConfig," ",c.error.message]}):u?o.jsx($z,{section:a,snapshot:u,cost:d.data,onSetDefaultProfile:v,onReconnect:x,onAddMachine:w}):null]})]})]})}function $z({section:e,snapshot:t,cost:n,onSetDefaultProfile:r,onReconnect:i,onAddMachine:s}){switch(e){case"platform":return o.jsx(m_,{snapshot:t,onReconnect:i});case"profiles":return o.jsx(M_,{snapshot:t,onSetDefaultProfile:r});case"budget":return o.jsx(tF,{snapshot:t,cost:n});case"machines":return o.jsx(y_,{snapshot:t,onAddMachine:s});case"templates":return o.jsx(nz,{});case"mcp":return o.jsx(b_,{snapshot:t});case"notifications":return o.jsx(__,{snapshot:t});case"hooks":return o.jsx(FF,{});case"advanced":return o.jsx(H_,{snapshot:t});default:return null}}const P6=f.createContext(null);function _z({children:e}){const[t,n]=f.useState(!1),r=f.useCallback(()=>n(!0),[]),i=f.useCallback(()=>n(!1),[]),s=f.useMemo(()=>({open:r,close:i}),[r,i]);return o.jsxs(P6.Provider,{value:s,children:[e,o.jsx(Az,{open:t,onClose:i})]})}function I6(){const e=f.useContext(P6);if(!e)throw new Error("useSettings must be used within a SettingsProvider");return e}function W0(e,t){return e.dispatches.filter(n=>n.stepIndex===t.stepIndex)}const Ms=5;function tf(e){return e.depth+2}function U0(e){let t=1;const n=r=>{for(const i of r)tf(i)>t&&(t=tf(i)),n(i.children)};return n(e),Math.min(t,Ms)}const Fz=new Set(["running","waiting"]);function M6(e){switch(e){case"running":return{bg:"#EEF0FA",fg:"#4655D4",text:"Running"};case"waiting":return{bg:"#F7ECCE",fg:"#8A5B06",text:"Waiting"};case"completed":return{bg:"#E9F4EE",fg:"#23854F",text:"Done"};case"failed":return{bg:"#FBEDEB",fg:"#C03D33",text:"Failed"};default:return{bg:"#F1F2F5",fg:"#8A93A2",text:"Cancelled"}}}function zz(e){const t=Math.max(0,Math.floor(e)),n=Math.floor(t/60),r=t%60,i=s=>String(s).padStart(2,"0");return`${i(n)}:${i(r)}`}function Bz(e){const t=new Date(e),n=r=>String(r).padStart(2,"0");return`${n(t.getHours())}:${n(t.getMinutes())}`}function Wz(e){const t=Math.round(e);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;return r===0?`${n}m`:`${n}m ${r}s`}function _j(e){const t=[];return e.durationS!=null&&t.push(Wz(e.durationS)),e.costUsd!=null&&t.push("$"+e.costUsd.toFixed(2)),t.join(" · ")}function Uz(e,t){if(!e)return"";const n=Math.max(0,Math.round((t-Date.parse(e))/1e3));if(n<60)return"just now";const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function Hz(e){return`${e.stepIndex+1} · ${e.stage??"step"}`}function qz(e){const t=M6(e.status);return{id:e.id,name:e.templateName??e.id,level:"L"+tf(e),pill:t,hasLine:!!e.activeAgent,line:e.activeAgent??"",isMax:tf(e)>=Ms||e.truncated,drillable:e.children.length>0||e.truncated}}function Vz(e){return e.map(t=>{const n=t.stage??`step ${t.stepIndex+1}`,r=t.status==="completed"?"done":t.status==="running"?"editing":"queued";return{label:`${t.stepIndex+1} ${n} · ${r}`,active:t.status==="running"}})}function Kz(e){return e.status==="completed"?"done":e.status==="running"?"running":"pending"}function Qz(e,t,n){var s,a;const r=W0(e,t)[0],i=[t.executionId??(r==null?void 0:r.executionId),(r==null?void 0:r.machine)??"local"].filter(Boolean).join(" · ");return{profile:((s=e.agentFlow)==null?void 0:s.profile)??e.activeAgent??"agent",execInfo:i,lastOutput:((a=e.agentFlow)==null?void 0:a.lastOutput)??t.outputSummary,streaming:!0,live:n}}function Gz(e,t,n,r){var l;const i=Kz(t),s=i==="running",a=s?e.children.map(qz):[];return{kind:i,title:Hz(t),note:t.outputSummary??"",meta:s?_j(t)||"running":i==="done"?_j(t):"gated",hasConnector:n>0,agent:s?Qz(e,t,r):void 0,subs:a,subCount:a.length,stepIndex:t.stepIndex,sessionId:t.sessionId,sessionName:t.sessionName,profile:s?((l=e.agentFlow)==null?void 0:l.profile)??e.activeAgent??t.agentSlotId:t.agentSlotId}}function Yz(e,t,n){return{path:e.artifacts.artifactPath,live:t,updated:Uz(e.updatedAt,n),taskId:e.artifacts.taskId,taskProject:e.artifacts.taskProject,workspacePath:e.artifacts.workspacePath,writtenBy:Vz(e.steps),content:e.artifacts.content??null}}function Xz(e,t){const n=Fz.has(e.status),r=e.endedAt?Date.parse(e.endedAt):t,i=Math.max(0,(r-Date.parse(e.createdAt))/1e3),s=U0(e.children),a=Array.from({length:Ms},(l,c)=>({filled:c<s}));return{name:e.templateName,tid:e.id,pill:M6(e.status),template:e.templateName,started:Bz(e.createdAt),elapsed:zz(i),cost:"Σ $"+e.totalCostUsd.toFixed(2),task:e.artifacts.taskId??"—",depthDots:a,depthText:`${s}/${Ms}`,live:n,steps:e.steps.map((l,c)=>Gz(e,l,c,n)),artifact:Yz(e,n,t)}}const Jz="wide";function vg(e){return Array.from(e).length}function Zz(e){if(typeof e=="string")return e;try{const t=JSON.stringify(e,null,2);return t===void 0?String(e):t}catch{return String(e)}}function yg({label:e,status:t,count:n,children:r}){const i=B();return o.jsxs("section",{className:"flex flex-col gap-1g",children:[o.jsxs("div",{className:"flex items-center gap-1g font-mono text-[10px] font-semibold tracking-[.06em] text-proto-muted",children:[o.jsx("span",{children:e}),t?o.jsx("span",{className:"rounded border border-proto-line-2 bg-proto-alt px-1g py-[1px] text-[9px]",children:t}):null,n!==void 0?o.jsxs("span",{className:"ml-auto font-normal tracking-normal text-proto-faint",children:[n," ",i.wbDebugCharacters]}):null]}),o.jsx("pre",{className:"max-h-[38vh] overflow-auto whitespace-pre-wrap break-words rounded-card border border-proto-line-2 bg-proto-alt p-2g font-mono text-[11px] leading-relaxed text-proto-ink-2",children:r})]})}function eB({detail:e}){var i;const t=B();if(e.kind==="user")return o.jsx(yg,{label:t.wbDebugAgentMessage,count:vg(e.agentMessage),children:e.agentMessage});const n=Zz(e.toolInput),r=e.toolResult?e.toolResult.isError?t.wbDebugError:t.wbDebugSuccess:t.wbDebugPending;return o.jsxs("div",{className:"flex flex-col gap-2g",children:[o.jsx(yg,{label:t.wbDebugParameters,count:vg(n),children:n}),o.jsx(yg,{label:t.wbDebugResult,status:r,count:e.toolResult?vg(e.toolResult.content):void 0,children:((i=e.toolResult)==null?void 0:i.content)??t.wbDebugPending})]})}function L6({onClick:e,compact:t=!1,className:n=""}){const i=B().wbDebugInspect,s=t?"h-[18px] min-w-[22px] px-[4px] text-[8px]":"h-[24px] min-w-[28px] px-[5px] text-[9px]";return o.jsx("button",{type:"button","aria-label":i,title:i,onClick:e,className:`pointer-events-none ${s} rounded border border-proto-line-2 bg-proto-card font-mono text-proto-muted opacity-0 shadow-sm transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 focus-visible:pointer-events-auto focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-proto-accent/30 ${n}`,children:"{ }"})}function O6({detail:e,onClose:t}){const n=B(),r=(e==null?void 0:e.kind)==="tool"?`DEBUG · ${e.toolName}`:`DEBUG · ${n.wbDebugAgentMessage}`;return o.jsx(Wf,{title:r,open:e!==null,size:Jz,layer:"nested",onOpenChange:i=>{i||t()},children:e?o.jsx(eB,{detail:e}):null})}function tB(e,t){return e.length===0?0:e.reduce((n,r)=>n+r,0)+t*(e.length-1)}function nB(e){const{availableWidth:t,chipWidths:n,overflowWidth:r,gap:i}=e;if(tB(n,i)<=t)return{visibleCount:n.length,hiddenCount:0};let s=0,a=0;for(const l of n){const c=s+(a>0?i:0)+l;if(c+i+r>t)break;s=c,a+=1}return{visibleCount:a,hiddenCount:n.length-a}}function rB(e){return e>0?`+${e}`:null}function oB(e,t){var r;const n=Array.from(e.children);return{chipWidths:n.slice(0,t).map(i=>i.getBoundingClientRect().width),overflowWidth:((r=n[t])==null?void 0:r.getBoundingClientRect().width)??0}}function iB(e,t){return e.visibleCount===t.visibleCount&&e.hiddenCount===t.hiddenCount}function sB(e,t){var s;let n=!0;const r=()=>{n&&t()};r();const i=typeof ResizeObserver>"u"?null:new ResizeObserver(r);return i==null||i.observe(e),(s=document.fonts)==null||s.ready.then(r),()=>{n=!1,i==null||i.disconnect()}}function D6(e,t){const n=f.useRef(null),r=f.useRef(null),[i,s]=f.useState({visibleCount:e.length,hiddenCount:0}),a=e.join("\0");return f.useLayoutEffect(()=>{const l=n.current,c=r.current;if(!(!l||!c))return sB(l,()=>{const d=oB(c,e.length),u=nB({availableWidth:l.clientWidth,...d,gap:t});s(p=>iB(p,u)?p:u)})},[t,e.length,a]),{containerRef:n,measureRef:r,layout:i}}const rh="'IBM Plex Mono',monospace",H0=7,aB={font:`400 10.5px ${rh}`,background:"var(--proto-alt)",border:"1px solid var(--proto-line-2)",padding:"1px 6px",borderRadius:4,flex:"none"},Fj={font:`500 10.5px ${rh}`,color:"var(--proto-muted)",flex:"none"},A6={display:"flex",alignItems:"center",gap:H0,flex:1,minWidth:0,overflow:"hidden",position:"relative"},lB={...A6,position:"absolute",visibility:"hidden",pointerEvents:"none",width:"max-content",overflow:"visible"},cB={display:"flex",alignItems:"center",gap:7,fontSize:11,color:"var(--proto-muted-3)",padding:"6px 13px"},dB={display:"flex",alignItems:"center",gap:8,padding:"5.5px 13px",borderTop:"1px solid var(--proto-line-soft)"},uB={font:`600 9px ${rh}`,color:"var(--proto-muted)",background:"var(--proto-gray)",padding:"1.5px 7px",borderRadius:5,flex:"none"},pB={font:`400 10.5px ${rh}`,color:"var(--proto-ink-2)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"};function N6(e){return e?{background:"var(--proto-amber-bg)",border:"1px solid var(--proto-amber-border)",color:"var(--proto-amber-fg)"}:{}}function fB(e){return e.debug?{kind:"tool",toolName:e.kind,toolInput:e.debug.toolInput,...e.debug.toolResult!==void 0?{toolResult:e.debug.toolResult}:{}}:null}function hB(e){return{display:"flex",alignItems:"center",gap:H0,fontSize:11.5,color:e?"var(--proto-muted)":"var(--proto-muted-3)",flexWrap:"nowrap",whiteSpace:"nowrap",overflow:"hidden",cursor:"pointer"}}function gB(e){return{background:"var(--proto-rail)",border:"1px solid "+(e?"var(--proto-line-3)":"var(--proto-line-2)"),borderRadius:8,padding:"2px 0",cursor:"pointer"}}function zj({call:e}){var t;return o.jsx("span",{style:{...aB,...N6(((t=e.debug)==null?void 0:t.overCharacterThreshold)===!0)},children:e.label})}function xB({calls:e,text:t,hover:n,onExpand:r,onHover:i}){const{containerRef:s,measureRef:a,layout:l}=D6(e.map(d=>d.label),H0),c=rB(l.hiddenCount);return o.jsx("div",{style:{margin:"-8px 0"},children:o.jsxs("div",{onClick:r,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:hB(n),children:[o.jsx("span",{style:{fontSize:9,color:"var(--proto-faint)",flex:"none"},children:"▸"}),o.jsx("span",{style:{flex:"none"},children:t}),o.jsxs("span",{ref:s,style:A6,children:[e.slice(0,l.visibleCount).map((d,u)=>o.jsx(zj,{call:d},u)),c?o.jsx("span",{style:Fj,children:c}):null,o.jsxs("span",{ref:a,"aria-hidden":"true",style:lB,children:[e.map((d,u)=>o.jsx(zj,{call:d},u)),o.jsxs("span",{style:Fj,children:["+",e.length]})]})]})]})})}function mB({call:e,onInspect:t}){var n;return o.jsxs("div",{className:e.debug?"group":void 0,style:dB,children:[o.jsx("span",{style:{...uB,...N6(((n=e.debug)==null?void 0:n.overCharacterThreshold)===!0)},children:e.kind}),o.jsx("span",{style:{...pB,...e.debug?{minWidth:0,flex:1}:{}},children:e.input}),e.debug?o.jsx(L6,{compact:!0,onClick:r=>t(r,e)}):null]})}function vB({calls:e,text:t,hover:n,selected:r,onCollapse:i,onHover:s,onInspect:a,onClose:l}){return o.jsxs(o.Fragment,{children:[o.jsxs("div",{onClick:i,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:gB(n),children:[o.jsxs("div",{style:cB,children:[o.jsx("span",{style:{fontSize:9,color:"var(--proto-faint)"},children:"▾"}),o.jsx("span",{children:t})]}),e.map((c,d)=>o.jsx(mB,{call:c,onInspect:a},d))]}),o.jsx(O6,{detail:r,onClose:l})]})}function yB({calls:e}){const t=B(),[n,r]=f.useState(!1),[i,s]=f.useState(!1),[a,l]=f.useState(null),c=e.length>1?`${e.length} ${t.toolCallsUnit}`:`1 ${t.toolCallUnit}`,d=(u,p)=>{u.stopPropagation(),l(fB(p))};return n?o.jsx(vB,{calls:e,text:c,hover:i,selected:a,onCollapse:()=>r(!1),onHover:s,onInspect:d,onClose:()=>l(null)}):o.jsx(xB,{calls:e,text:c,hover:i,onExpand:()=>r(!0),onHover:s})}function bB(e){return e.length>=2&&(e[0]==='"'&&e.endsWith('"')||e[0]==="'"&&e.endsWith("'"))?e.slice(1,-1):e}function jB(e){const t=e.replace(/\r\n/g,`
|
|
120
|
+
`);if(!t.startsWith(`---
|
|
121
|
+
`))return{frontmatter:null,body:e};const n=t.slice(4),r=n.search(/\n---[ \t]*(\n|$)/);if(r===-1)return{frontmatter:null,body:e};const i=n.slice(0,r),s=n.slice(r+1),a=s.indexOf(`
|
|
122
|
+
`),l=a===-1?"":s.slice(a+1),c=[];let d=null;for(const u of i.split(`
|
|
123
|
+
`)){const p=u.trimEnd();if(!p.trim())continue;const h=/^([A-Za-z0-9_-]+):\s?(.*)$/.exec(p);if(!h)continue;const g=h[1],v=bB(h[2].trim());if(g==="summary"){d=v;continue}c.push({key:g,value:v})}return{frontmatter:{entries:c,summary:d},body:l}}const wB=/(\*\*([^*]+)\*\*)|(`([^`]+)`)|(\[([^\]]+)\]\(([^)]+)\))|(\*([^*]+)\*)|(_([^_]+)_)/;function Ys(e){const t=[];let n=e;for(;n.length;){const r=wB.exec(n);if(!r){t.push({type:"text",text:n});break}r.index>0&&t.push({type:"text",text:n.slice(0,r.index)}),r[2]!=null?t.push({type:"bold",text:r[2]}):r[4]!=null?t.push({type:"code",text:r[4]}):r[6]!=null?t.push({type:"link",text:r[6],href:r[7]}):r[9]!=null?t.push({type:"italic",text:r[9]}):r[11]!=null&&t.push({type:"italic",text:r[11]}),n=n.slice(r.index+r[0].length)}return t.length?t:[{type:"text",text:""}]}function Bj(e){let t=e.trim();return t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|").map(n=>n.trim())}function Wj(e){return/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(e)&&e.includes("-")}function $6(e){const t=e.replace(/\r\n/g,`
|
|
124
|
+
`).split(`
|
|
125
|
+
`),n=[];let r=0;const i=s=>/^\s*([-*+]|\d+\.)\s+/.test(s);for(;r<t.length;){const s=t[r];if(!s.trim()){r++;continue}const a=/^```(\w*)\s*$/.exec(s);if(a){const d=a[1]||null,u=[];for(r++;r<t.length&&!/^```\s*$/.test(t[r]);)u.push(t[r]),r++;r++,n.push({type:"code",lang:d,text:u.join(`
|
|
126
|
+
`)});continue}const l=/^(#{1,6})\s+(.*)$/.exec(s);if(l){n.push({type:"heading",level:l[1].length,inline:Ys(l[2].trim())}),r++;continue}if(/^(-{3,}|\*{3,}|_{3,})\s*$/.test(s)){n.push({type:"hr"}),r++;continue}if(s.includes("|")&&r+1<t.length&&Wj(t[r+1])){const d=Bj(s).map(Ys);r+=2;const u=[];for(;r<t.length&&t[r].includes("|")&&t[r].trim();)u.push(Bj(t[r]).map(Ys)),r++;n.push({type:"table",header:d,rows:u});continue}if(/^>\s?/.test(s)){const d=[];for(;r<t.length&&/^>\s?/.test(t[r]);)d.push(t[r].replace(/^>\s?/,"")),r++;n.push({type:"blockquote",inline:Ys(d.join(" ").trim())});continue}if(i(s)){const d=/^\s*\d+\.\s+/.test(s),u=[];for(;r<t.length&&i(t[r]);){const p=t[r].replace(/^\s*([-*+]|\d+\.)\s+/,"");u.push(Ys(p.trim())),r++}n.push({type:"list",ordered:d,items:u});continue}const c=[];for(;r<t.length&&t[r].trim()&&!/^(#{1,6})\s+/.test(t[r])&&!/^```/.test(t[r])&&!/^>\s?/.test(t[r])&&!i(t[r])&&!/^(-{3,}|\*{3,}|_{3,})\s*$/.test(t[r])&&!(t[r].includes("|")&&r+1<t.length&&Wj(t[r+1]));)c.push(t[r].trim()),r++;n.push({type:"paragraph",inline:Ys(c.join(" "))})}return n}const _6="'IBM Plex Mono',monospace";function Xs({nodes:e}){return o.jsx(o.Fragment,{children:e.map((t,n)=>{switch(t.type){case"bold":return o.jsx("strong",{style:{fontWeight:650},children:t.text},n);case"italic":return o.jsx("em",{children:t.text},n);case"code":return o.jsx("code",{style:{font:`500 12.5px ${_6}`,background:"var(--proto-gray)",borderRadius:4,padding:"1px 5px"},children:t.text},n);case"link":return o.jsx("a",{href:t.href,target:"_blank",rel:"noreferrer",style:{color:"var(--proto-accent)",textDecoration:"underline"},children:t.text},n);default:return o.jsx(f.Fragment,{children:t.text},n)}})})}function kB({block:e}){switch(e.type){case"heading":{const t=e.level<=1?17:e.level===2?15.5:14.5;return o.jsx("div",{style:{fontSize:t,fontWeight:650,color:"var(--proto-ink)",margin:"2px 0"},children:o.jsx(Xs,{nodes:e.inline})})}case"paragraph":return o.jsx("div",{style:{whiteSpace:"pre-wrap",overflowWrap:"break-word"},children:o.jsx(Xs,{nodes:e.inline})});case"list":{const t=e.ordered?"ol":"ul";return o.jsx(t,{style:{margin:"2px 0",paddingLeft:22,display:"flex",flexDirection:"column",gap:3},children:e.items.map((n,r)=>o.jsx("li",{children:o.jsx(Xs,{nodes:n})},r))})}case"code":return o.jsx("pre",{style:{font:`500 12.5px ${_6}`,background:"var(--proto-alt)",border:"1px solid var(--proto-line)",borderRadius:8,padding:"10px 12px",overflow:"auto",margin:"2px 0"},children:o.jsx("code",{children:e.text})});case"blockquote":return o.jsx("div",{style:{borderLeft:"3px solid var(--proto-line)",paddingLeft:12,color:"var(--proto-muted)"},children:o.jsx(Xs,{nodes:e.inline})});case"table":return o.jsx("div",{style:{overflowX:"auto",maxWidth:"100%"},children:o.jsxs("table",{style:{borderCollapse:"collapse",fontSize:13},children:[o.jsx("thead",{children:o.jsx("tr",{children:e.header.map((t,n)=>o.jsx("th",{style:{border:"1px solid var(--proto-line)",padding:"4px 8px",textAlign:"left",fontWeight:650,whiteSpace:"nowrap"},children:o.jsx(Xs,{nodes:t})},n))})}),o.jsx("tbody",{children:e.rows.map((t,n)=>o.jsx("tr",{children:t.map((r,i)=>o.jsx("td",{style:{border:"1px solid var(--proto-line)",padding:"4px 8px",whiteSpace:"nowrap"},children:o.jsx(Xs,{nodes:r})},i))},n))})]})});case"hr":return o.jsx("div",{style:{height:1,background:"var(--proto-line-2)",margin:"4px 0"}});default:return null}}function Ai({text:e,dropTrailingHr:t=!1}){let n=$6(e);if(t){let r=n.length;for(;r>0&&n[r-1].type==="hr";)r--;r!==n.length&&(n=n.slice(0,r))}return o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:n.map((r,i)=>o.jsx(kB,{block:r},i))})}const SB="/api/files/download";function q0(){var e;return(e=globalThis.__TAURI__)==null?void 0:e.core}function ad(e,t="attachment"){const n=new URLSearchParams({path:e,disposition:t});return`${Xv()}${SB}?${n.toString()}`}async function Fd(e,t="inline"){const n=await fetch(ad(e,t),{headers:Rs()});if(!n.ok)throw new Error(`download failed: ${n.status}`);const r=await n.blob();return URL.createObjectURL(r)}async function Tm(e,t){const n=t??e.split("/").pop()??"download",r=on()?q0():void 0;if(r){if(Pf())return await r.invoke("plugin:cortex-download|download",{url:ad(e,"attachment"),fileName:n,token:Rs()["x-cortex-token"]}),{};const a=await fetch(ad(e,"attachment"),{headers:Rs()});if(!a.ok)throw new Error(`download failed: ${a.status}`);const l=Array.from(new Uint8Array(await a.arrayBuffer()));return{savedPath:await r.invoke("save_download",{name:n,bytes:l})}}const i=await Fd(e,"attachment"),s=document.createElement("a");return s.href=i,s.download=n,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(i),1e4),{}}async function CB(e){const t=on()?q0():void 0;t&&await t.invoke("open_path",{path:e})}async function TB(e){const t=on()?q0():void 0;t&&await t.invoke("reveal_path",{path:e})}function Il(){const e=cA(),t=gA();return f.useCallback((n,r)=>{(async()=>{if(Pf()){await Tm(n,r).catch(()=>{});return}const i=r??n.split("/").pop()??n;try{const{savedPath:s}=await Tm(n,r),a=s?[{label:t.wbFileOpenFile,onClick:()=>void CB(s)},{label:t.wbFileOpenFolder,onClick:()=>void TB(s)}]:void 0;e==null||e.toast({title:t.wbFileDownloadDone,description:s?t.wbFileSavedTo.replace("{path}",s):i,tone:"done",duration:a?1e4:void 0,actions:a})}catch(s){e==null||e.toast({title:t.wbFileDownloadFailed,description:s instanceof Error?s.message:String(s),tone:"failed"})}})()},[e,t])}function EB(e,t){let n=!1;const r=()=>{n||(n=!0,t())};return e.pushSentinel(),e.addPopListener(r),()=>{e.removePopListener(r),n||e.popSentinel()}}function RB(){return{pushSentinel:()=>{window.history.pushState({...window.history.state,__cortexOverlay:!0},"")},popSentinel:()=>window.history.back(),addPopListener:e=>window.addEventListener("popstate",e),removePopListener:e=>window.removeEventListener("popstate",e)}}function V0(e){const t=f.useRef(e);t.current=e,f.useEffect(()=>EB(RB(),()=>t.current()),[])}const Em="cortex.previewPinned",F6="cortex.previewSplit",hl=.5,Rm=.25,Pm=.75;function z6(e){return Number.isFinite(e)?Math.min(Pm,Math.max(Rm,e)):hl}function PB(e){return e===null||e.trim()===""?hl:z6(Number(e))}function IB(e){return e==="1"}const Uj=260,Hj=380;function MB(e,t,n){if(!(t>0))return hl;const r=(e+t-n)/t;let i=Rm,s=Pm;return t>=Uj+Hj&&(i=Math.max(i,Uj/t),s=Math.min(s,1-Hj/t),i>s&&([i,s]=[Rm,Pm])),Number.isFinite(r)?Math.min(s,Math.max(i,r)):hl}function qj(e){return e.kind==="pdf"||e.kind==="text"}function B6(e){return e.path??null}const W6=f.createContext({canPin:!1,active:!1,pinned:!1,item:null,split:hl,pin:()=>{},show:()=>{},unpin:()=>{},setSplit:()=>{},registerHost:()=>()=>{}});function LB(){try{return IB(window.localStorage.getItem(Em))}catch{return!1}}function OB(){try{return PB(window.localStorage.getItem(F6))}catch{return hl}}function bg(e,t){try{window.localStorage.setItem(e,t)}catch{}}function DB({children:e}){const[t,n]=f.useState(LB),[r,i]=f.useState(null),[s,a]=f.useState(OB),[l,c]=f.useState(0),d=f.useCallback(()=>(c(x=>x+1),()=>c(x=>Math.max(0,x-1))),[]),u=f.useCallback(x=>{n(!0),bg(Em,"1"),x&&i(x)},[]),p=f.useCallback(x=>i(x),[]),h=f.useCallback(()=>{n(!1),bg(Em,"0"),i(null)},[]),g=f.useCallback((x,w=!1)=>{const b=z6(x);a(b),w&&bg(F6,String(b))},[]),v=f.useMemo(()=>({canPin:l>0,active:t&&l>0,pinned:t,item:r,split:s,pin:u,show:p,unpin:h,setSplit:g,registerHost:d}),[l,t,r,s,u,p,h,g,d]);return o.jsx(W6.Provider,{value:v,children:e})}function oh(){return f.useContext(W6)}function U6(e){const[t,n]=f.useState(e.url??null),[r,i]=f.useState(!1);return f.useEffect(()=>{if(e.url){n(e.url),i(!1);return}if(!e.path)return;let s=!0,a=null;return n(null),i(!1),Fd(e.path,"inline").then(l=>{s?(a=l,n(l)):URL.revokeObjectURL(l)}).catch(()=>{s&&i(!0)}),()=>{s=!1,a&&URL.revokeObjectURL(a)}},[e.path,e.url]),{src:t,failed:r}}const Vj=.4;function AB(e,t){return e==="transform"?!0:t.ctrlKey||t.metaKey}function Kj(e,t,n,r){if(t<=1)return{scale:1,x:0,y:0};const i=t/e.scale;return{scale:t,x:e.x+(1-i)*(n.x-r.x),y:e.y+(1-i)*(n.y-r.y)}}function NB(e,t,n,r,i,s){if(i<=1)return{scale:1,x:0,y:0};const a=i/e;return{scale:i,x:t.x+(r.x-n.x)+(n.x-s.x)*(1-a),y:t.y+(r.y-n.y)+(n.y-s.y)*(1-a)}}function K0(e={}){const{minScale:t=1,maxScale:n=5,mode:r="transform"}=e,[i,s]=f.useState({scale:1,x:0,y:0}),[a,l]=f.useState(null),c=f.useRef(null),d=f.useRef(i);d.current=i;const u=f.useRef(null),p=f.useRef(null),h=f.useRef(null),g=f.useCallback(k=>Math.min(n,Math.max(t,k)),[t,n]),v=f.useCallback(()=>{!a||r!=="css-zoom"||(u.current={ox:a.clientWidth/2,oy:a.clientHeight/2,scrollLeft:a.scrollLeft,scrollTop:a.scrollTop,prevScale:d.current.scale})},[a,r]),x=f.useCallback(()=>{v(),s(k=>({...k,scale:Math.min(n,k.scale+Vj)}))},[n,v]),w=f.useCallback(()=>{v(),s(k=>{const E=Math.max(t,k.scale-Vj);return E<=1?{scale:1,x:0,y:0}:{...k,scale:E}})},[t,v]),b=f.useCallback(()=>{v(),s({scale:1,x:0,y:0})},[v]),y=f.useCallback(k=>{l(k)},[]),j=f.useCallback(k=>{c.current=k},[]);f.useLayoutEffect(()=>{if(!a||r!=="css-zoom"||!u.current)return;const{ox:k,oy:E,scrollLeft:C,scrollTop:R,prevScale:P}=u.current,L=i.scale;if(u.current=null,P===L)return;const _=L/P;a.scrollLeft=(C+k)*_-k,a.scrollTop=(R+E)*_-E},[i.scale,a,r]),f.useEffect(()=>{if(!a)return;const k=$=>{var N;if(!AB(r,$))return;$.preventDefault();const W=a.getBoundingClientRect();if(r==="css-zoom"){u.current={ox:$.clientX-W.left,oy:$.clientY-W.top,scrollLeft:a.scrollLeft,scrollTop:a.scrollTop,prevScale:d.current.scale},s(F=>{const re=1+($.deltaY<0?1:-1)*.12;return{...F,scale:g(F.scale*re)}});return}const V=(N=c.current)==null?void 0:N.getBoundingClientRect(),Z={x:(V==null?void 0:V.left)??W.left,y:(V==null?void 0:V.top)??W.top};s(F=>{const re=1+($.deltaY<0?1:-1)*.12,D=g(F.scale*re);return Kj(F,D,{x:$.clientX,y:$.clientY},Z)})},E=$=>{var W;if($.touches.length===2){$.preventDefault();const[V,Z]=[$.touches[0],$.touches[1]],N=Math.hypot(Z.clientX-V.clientX,Z.clientY-V.clientY),F={x:(V.clientX+Z.clientX)/2,y:(V.clientY+Z.clientY)/2},H=d.current,re=(W=c.current)==null?void 0:W.getBoundingClientRect();p.current={initialDist:N,initialScale:H.scale,initialMid:F,initialTranslate:{x:H.x,y:H.y},startTopLeft:{x:(re==null?void 0:re.left)??0,y:(re==null?void 0:re.top)??0}}}},C=$=>{if($.touches.length===2&&p.current){$.preventDefault();const[W,V]=[$.touches[0],$.touches[1]],Z=Math.hypot(V.clientX-W.clientX,V.clientY-W.clientY),N={x:(W.clientX+V.clientX)/2,y:(W.clientY+V.clientY)/2},F=Z/p.current.initialDist,H=g(p.current.initialScale*F);if(r==="css-zoom"){const re=a.getBoundingClientRect();u.current={ox:N.x-re.left,oy:N.y-re.top,scrollLeft:a.scrollLeft,scrollTop:a.scrollTop,prevScale:d.current.scale},s(D=>({...D,scale:H}))}else{const re=p.current;s(NB(re.initialScale,re.initialTranslate,re.initialMid,N,H,re.startTopLeft))}}},R=$=>{$.touches.length<2&&(p.current=null)};let P=0;const L=$=>{var V;if($.touches.length!==1)return;const W=Date.now();if(W-P<300){$.preventDefault();const Z=d.current;if(Z.scale>1)r==="css-zoom"&&(u.current={ox:a.clientWidth/2,oy:a.clientHeight/2,scrollLeft:a.scrollLeft,scrollTop:a.scrollTop,prevScale:Z.scale}),s({scale:1,x:0,y:0});else if(r==="css-zoom"){const N=a.getBoundingClientRect();u.current={ox:$.touches[0].clientX-N.left,oy:$.touches[0].clientY-N.top,scrollLeft:a.scrollLeft,scrollTop:a.scrollTop,prevScale:Z.scale},s({scale:2,x:0,y:0})}else{const N=a.getBoundingClientRect(),F=(V=c.current)==null?void 0:V.getBoundingClientRect(),H={x:(F==null?void 0:F.left)??N.left,y:(F==null?void 0:F.top)??N.top};s(Kj({scale:1,x:0,y:0},2,{x:$.touches[0].clientX,y:$.touches[0].clientY},H))}}P=W},_=$=>{if(r!=="transform"||$.touches.length!==1)return;const W=d.current;W.scale<=1||(h.current={startX:$.touches[0].clientX,startY:$.touches[0].clientY,startTranslateX:W.x,startTranslateY:W.y})},U=$=>{if(!h.current||$.touches.length!==1)return;$.preventDefault();const W=$.touches[0].clientX-h.current.startX,V=$.touches[0].clientY-h.current.startY;s(Z=>({...Z,x:h.current.startTranslateX+W,y:h.current.startTranslateY+V}))},K=()=>{h.current=null};return a.addEventListener("wheel",k,{passive:!1}),a.addEventListener("touchstart",E,{passive:!1}),a.addEventListener("touchstart",L,{passive:!1}),a.addEventListener("touchstart",_,{passive:!1}),a.addEventListener("touchmove",C,{passive:!1}),a.addEventListener("touchmove",U,{passive:!1}),a.addEventListener("touchend",R),a.addEventListener("touchend",K),()=>{a.removeEventListener("wheel",k),a.removeEventListener("touchstart",E),a.removeEventListener("touchstart",L),a.removeEventListener("touchstart",_),a.removeEventListener("touchmove",C),a.removeEventListener("touchmove",U),a.removeEventListener("touchend",R),a.removeEventListener("touchend",K)}},[a,g,r]);const S=r==="transform"?{transform:`translate(${i.x}px, ${i.y}px) scale(${i.scale})`,transformOrigin:"0 0",touchAction:"none"}:{transform:`scale(${i.scale})`,transformOrigin:"top left"};return{containerRef:y,contentRef:j,zoom:i,style:S,zoomIn:x,zoomOut:w,resetZoom:b,isZoomed:i.scale>1}}const H6=f.createContext({openMedia:()=>{},close:()=>{}}),jg="'IBM Plex Mono',monospace";function $B({item:e,onClose:t,onPin:n}){const{src:r,failed:i}=U6(e),s=Il(),{containerRef:a,contentRef:l,style:c,isZoomed:d,resetZoom:u}=K0({mode:"transform",minScale:1,maxScale:8});V0(t),f.useEffect(()=>{const h=v=>{v.key==="Escape"&&t()};window.addEventListener("keydown",h);const g=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",h),document.body.style.overflow=g}},[t]);const p=()=>{if(e.path)s(e.path,e.name);else if(e.url){const h=document.createElement("a");h.href=e.url,h.download=e.name,document.body.appendChild(h),h.click(),h.remove()}};return o.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":e.name,onClick:()=>{d?u():t()},style:{position:"fixed",inset:0,zIndex:4e3,background:"rgba(10,12,16,.88)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom))",boxSizing:"border-box",animation:"cxfade .18s ease both"},children:[o.jsxs("div",{onClick:h=>h.stopPropagation(),style:{position:"absolute",top:"max(14px, env(safe-area-inset-top))",right:14,display:"flex",gap:10,zIndex:2},children:[n&&o.jsx("span",{role:"button",title:"Pin preview beside the chat",onClick:n,style:{width:38,height:38,borderRadius:10,background:"rgba(255,255,255,.12)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:15,cursor:"pointer"},children:"◧"}),o.jsx("span",{role:"button",title:"Download",onClick:p,style:{width:38,height:38,borderRadius:10,background:"rgba(255,255,255,.12)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:16,cursor:"pointer"},children:"↓"}),o.jsx("span",{role:"button",title:"Close",onClick:t,style:{width:38,height:38,borderRadius:10,background:"rgba(255,255,255,.12)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:18,cursor:"pointer"},children:"×"})]}),o.jsx("div",{ref:a,onClick:h=>{h.stopPropagation()},style:{maxWidth:"94vw",maxHeight:"84vh",width:"94vw",height:"84vh",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},children:i?o.jsxs("div",{style:{color:"var(--proto-faint)",font:`500 12px ${jg}`},children:["Failed to load ",e.name]}):r?e.kind==="video"?o.jsx("video",{src:r,controls:!0,autoPlay:!0,playsInline:!0,style:{maxWidth:"94vw",maxHeight:"84vh",borderRadius:10,background:"#000"}}):o.jsx("div",{ref:l,style:{...c,display:"inline-block"},children:o.jsx("img",{src:r,alt:e.name,draggable:!1,style:{maxWidth:"94vw",maxHeight:"84vh",objectFit:"contain",display:"block"}})}):o.jsx("div",{style:{color:"var(--proto-muted-2)",font:`500 12px ${jg}`},children:"Loading…"})}),o.jsx("div",{onClick:h=>h.stopPropagation(),style:{position:"absolute",bottom:"max(16px, env(safe-area-inset-bottom))",left:0,right:0,textAlign:"center",color:"rgba(255,255,255,.72)",font:`500 11px ${jg}`,padding:"0 20px",pointerEvents:"none"},children:e.name})]})}function q6({children:e}){const[t,n]=f.useState(null),r=oh(),i=f.useCallback(c=>{if(r.active){r.show(c);return}n(c)},[r]),s=f.useCallback(()=>n(null),[]),a=f.useMemo(()=>({openMedia:i,close:s}),[i,s]),l=r.canPin?()=>{r.pin(t),n(null)}:void 0;return o.jsxs(H6.Provider,{value:a,children:[e,t&&o.jsx($B,{item:t,onClose:s,onPin:l})]})}function zd(){return f.useContext(H6)}const _B="modulepreload",FB=function(e){return"/"+e},Qj={},ih=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=Promise.allSettled(n.map(c=>{if(c=FB(c),c in Qj)return;Qj[c]=!0;const d=c.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${u}`))return;const p=document.createElement("link");if(p.rel=d?"stylesheet":_B,d||(p.as="script"),p.crossOrigin="",p.href=c,l&&p.setAttribute("nonce",l),document.head.appendChild(p),d)return new Promise((h,g)=>{p.addEventListener("load",h),p.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function s(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return i.then(a=>{for(const l of a||[])l.status==="rejected"&&s(l.reason);return t().catch(s)})},zB=new Set(["md","markdown","txt","text","log","json","jsonl","ndjson","csv","tsv","yaml","yml","toml","ini","env","xml","html","htm","css","scss","js","mjs","cjs","jsx","ts","tsx","py","rs","go","java","kt","c","h","cpp","cc","hpp","cs","rb","php","swift","sh","bash","zsh","sql","r","lua","pl","tex","diff","patch","gitignore","dockerfile","conf","cfg","properties"]);function BB(e){const t=V6(e);return t==="md"||t==="markdown"}function V6(e){const t=e.split("/").pop()??e,n=t.lastIndexOf(".");return n<=0?t.startsWith(".")&&t.length>1?t.slice(1).toLowerCase():"":t.slice(n+1).toLowerCase()}function Bd(e,t){const n=V6(e),r=(t??"").toLowerCase();return n==="pdf"||r==="application/pdf"?"pdf":zB.has(n)||r.startsWith("text/")||r==="application/json"||r==="application/xml"||r==="application/x-yaml"?"text":null}function K6(e,t){return t<=0||!Number.isFinite(e)?1:Math.min(Math.max(1,Math.floor(e)),t)}function WB(e,t,n){if(e.length===0)return 1;const r=t+n/2;for(let i=0;i<e.length;i++){const s=e[i];if(r<s.top+s.height)return i+1}return e.length}function UB(e,t){const n=parseInt(e,10);return Number.isFinite(n)?K6(n,t):null}const HB=2*1024*1024,Na="'IBM Plex Mono',monospace",Q6=f.createContext({openDoc:()=>{},close:()=>{}});function G6({item:e}){const[t,n]=f.useState(null),[r,i]=f.useState("loading");return f.useEffect(()=>{let s=!0;return i("loading"),n(null),(async()=>{const a=await fetch(ad(e.path,"inline"),{headers:Rs()});if(!a.ok)throw new Error(`download failed: ${a.status}`);const l=await a.blob();if(l.size>HB){s&&i("toolarge");return}const c=await l.text();s&&(n(c),i("ok"))})().catch(()=>{s&&i("failed")}),()=>{s=!1}},[e.path]),r==="loading"?o.jsx(Tc,{children:"Loading…"}):r==="failed"?o.jsxs(Tc,{failed:!0,children:["Failed to load ",e.name]}):r==="toolarge"?o.jsx(Tc,{children:"File too large to preview — download to view."}):BB(e.name)?o.jsx("div",{style:{padding:"22px 26px",color:"var(--proto-ink)",fontSize:13.5,lineHeight:1.6},children:o.jsx(Ai,{text:t??""})}):o.jsx("pre",{style:{margin:0,padding:"20px 22px",font:`500 12px/1.6 ${Na}`,color:"var(--proto-ink)",whiteSpace:"pre",overflowX:"auto"},children:t})}function Y6({item:e}){const t=f.useRef(null),n=f.useRef(null),r=f.useRef([]),[i,s]=f.useState("loading"),[a,l]=f.useState(0),[c,d]=f.useState(1),{containerRef:u,style:p,zoom:h,zoomIn:g,zoomOut:v,resetZoom:x}=K0({mode:"css-zoom",minScale:1,maxScale:5});f.useEffect(()=>{let j=!0,S=!1;const k=n.current;return k&&(k.innerHTML=""),r.current=[],s("loading"),l(0),d(1),(async()=>{const[{getPdfjs:E},C]=await Promise.all([ih(()=>import("./pdf-worker-DIEXcFxP.js"),[]),fetch(ad(e.path,"inline"),{headers:Rs()})]);if(!C.ok)throw new Error(`download failed: ${C.status}`);const R=await C.arrayBuffer();if(S)return;const L=await E().getDocument({data:R}).promise;if(S)return;j&&l(L.numPages);const _=n.current;if(!_)return;const U=Math.min(window.devicePixelRatio||1,2);for(let K=1;K<=L.numPages;K++){if(S)return;const $=await L.getPage(K),W=$.getViewport({scale:1.5}),V=document.createElement("div");V.style.maxWidth=`${Math.floor(W.width)}px`,V.style.margin="0 auto 12px";const Z=document.createElement("canvas"),N=Z.getContext("2d");N&&(Z.width=Math.floor(W.width*U),Z.height=Math.floor(W.height*U),Z.style.width="100%",Z.style.height="auto",Z.style.display="block",Z.style.borderRadius="6px",Z.style.background="#fff",Z.style.boxShadow="0 2px 10px rgba(0,0,0,.25)",N.scale(U,U),V.appendChild(Z),_.appendChild(V),r.current.push(V),await $.render({canvas:Z,canvasContext:N,viewport:W}).promise)}j&&!S&&s("ok")})().catch(()=>{j&&!S&&s("failed")}),()=>{j=!1,S=!0}},[e.path]);const w=f.useCallback(()=>{const j=t.current;if(!j)return[];const S=j.getBoundingClientRect().top-j.scrollTop;return r.current.map(k=>({top:k.getBoundingClientRect().top-S,height:k.offsetHeight}))},[]),b=f.useCallback(()=>{const j=t.current;if(!j)return;const S=WB(w(),j.scrollTop,j.clientHeight);d(k=>k===S?k:S)},[w]),y=f.useCallback(j=>{const S=t.current,k=r.current[K6(j,a)-1];if(!S||!k)return;const E=k.getBoundingClientRect().top-S.getBoundingClientRect().top+S.scrollTop;S.scrollTo({top:Math.max(0,E-12),behavior:"smooth"})},[a]);return o.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%"},children:[a>0&&i!=="failed"&&o.jsx(qB,{current:c,total:a,onJump:y,scale:h.scale,onZoomIn:g,onZoomOut:v,onZoomReset:x}),o.jsxs("div",{ref:j=>{t.current=j,u(j)},onScroll:b,style:{flex:1,minHeight:0,overflow:"auto",padding:"20px 16px",boxSizing:"border-box"},children:[i==="loading"&&o.jsx(Tc,{children:"Loading PDF…"}),i==="failed"&&o.jsxs(Tc,{failed:!0,children:["Failed to render ",e.name]}),o.jsx("div",{ref:n,style:{...p,maxWidth:900,margin:"0 auto"}})]})]})}function qB({current:e,total:t,onJump:n,scale:r,onZoomIn:i,onZoomOut:s,onZoomReset:a}){const[l,c]=f.useState(String(e));f.useEffect(()=>{c(String(e))},[e]);const d=()=>{const u=UB(l,t);u===null?c(String(e)):n(u)};return o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,padding:"7px 10px",borderBottom:"1px solid var(--proto-line)",background:"var(--proto-rail)",flex:"none"},children:[o.jsx("span",{role:"button",title:"Previous page","aria-disabled":e<=1,onClick:()=>{e>1&&n(e-1)},style:Du(e<=1),children:"↑"}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,font:`600 11.5px ${Na}`,color:"var(--proto-ink)"},children:[o.jsx("input",{value:l,inputMode:"numeric","aria-label":"Page number",onChange:u=>c(u.target.value.replace(/[^0-9]/g,"")),onFocus:u=>u.currentTarget.select(),onKeyDown:u=>{u.key==="Enter"&&(d(),u.currentTarget.blur())},onBlur:d,style:{width:44,textAlign:"center",padding:"3px 4px",borderRadius:6,border:"1px solid var(--proto-line)",background:"var(--proto-card)",color:"var(--proto-ink)",font:`600 11.5px ${Na}`}}),o.jsxs("span",{style:{color:"var(--proto-muted)"},children:["/ ",t]})]}),o.jsx("span",{role:"button",title:"Next page","aria-disabled":e>=t,onClick:()=>{e<t&&n(e+1)},style:Du(e>=t),children:"↓"}),o.jsxs("div",{style:{marginLeft:12,display:"flex",alignItems:"center",gap:4},children:[o.jsx("span",{role:"button",title:"Zoom out",onClick:s,style:Du(r<=1),children:"−"}),o.jsxs("span",{role:"button",title:"Reset zoom",onClick:a,style:{font:`600 10.5px ${Na}`,color:"var(--proto-muted)",cursor:"pointer",padding:"0 4px",userSelect:"none",minWidth:36,textAlign:"center"},children:[Math.round(r*100),"%"]}),o.jsx("span",{role:"button",title:"Zoom in",onClick:i,style:Du(r>=5),children:"+"})]})]})}function Du(e){return{width:28,height:28,borderRadius:8,border:"1px solid var(--proto-line)",background:"var(--proto-card)",color:"var(--proto-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,cursor:e?"default":"pointer",opacity:e?.4:1,flex:"none",userSelect:"none"}}function Tc({children:e,failed:t}){return o.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px 20px",color:t?"var(--proto-faint)":"var(--proto-muted-2)",font:`500 12px ${Na}`},children:e})}function VB({item:e,onClose:t,onPin:n}){const r=Il();return V0(t),f.useEffect(()=>{const i=a=>{a.key==="Escape"&&t()};window.addEventListener("keydown",i);const s=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",i),document.body.style.overflow=s}},[t]),o.jsx("div",{role:"dialog","aria-modal":"true","aria-label":e.name,onClick:t,style:{position:"fixed",inset:0,zIndex:4e3,background:"rgba(10,12,16,.72)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom))",boxSizing:"border-box",animation:"cxfade .18s ease both"},children:o.jsxs("div",{onClick:i=>i.stopPropagation(),style:{width:"min(920px, 96vw)",height:"min(88vh, 100%)",background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:14,display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 12px 48px rgba(0,0,0,.35)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderBottom:"1px solid var(--proto-line)",flex:"none",background:"var(--proto-rail)"},children:[o.jsx("span",{style:{font:`600 11.5px ${Na}`,color:"var(--proto-ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:e.name}),n&&o.jsx("span",{role:"button",title:"Pin preview beside the chat",onClick:n,style:wg,children:"◧"}),o.jsx("span",{role:"button",title:"Download",onClick:()=>r(e.path,e.name),style:wg,children:"↓"}),o.jsx("span",{role:"button",title:"Close",onClick:t,style:{...wg,fontSize:16},children:"×"})]}),o.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",background:e.kind==="pdf"?"var(--proto-gray)":"var(--proto-card)"},children:e.kind==="pdf"?o.jsx(Y6,{item:e}):o.jsx(G6,{item:e})})]})})}const wg={width:30,height:30,borderRadius:8,border:"1px solid var(--proto-line)",background:"var(--proto-card)",color:"var(--proto-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,cursor:"pointer",flex:"none"};function X6({children:e}){const[t,n]=f.useState(null),r=oh(),i=f.useCallback(c=>{if(r.active){r.show(c);return}n(c)},[r]),s=f.useCallback(()=>n(null),[]),a=f.useMemo(()=>({openDoc:i,close:s}),[i,s]),l=r.canPin?()=>{r.pin(t),n(null)}:void 0;return o.jsxs(Q6.Provider,{value:a,children:[e,t&&o.jsx(VB,{item:t,onClose:s,onPin:l})]})}function Wd(){return f.useContext(Q6)}function Q0(e,t=!0){const[n,r]=f.useState(null);return f.useEffect(()=>{if(!e||!t){r(null);return}let i=!0,s=null;return Fd(e,"inline").then(a=>{i?(s=a,r(a)):URL.revokeObjectURL(a)}).catch(()=>{i&&r(null)}),()=>{i=!1,s&&URL.revokeObjectURL(s)}},[e,t]),n}function Ls(e){return e==="image"?"image":e==="video"?"video":null}function KB(e,t,n=360){if(e<=0||t<=0)return{w:0,h:0};const r=Math.min(1,n/Math.max(e,t));return{w:Math.round(e*r),h:Math.round(t*r)}}function QB(e,t=.1){return!Number.isFinite(e)||e<=0?t:Math.min(t,e/2)}function GB(e){const[t,n]=f.useState(null);return f.useEffect(()=>{if(n(null),!e||typeof document>"u")return;let r=!0;const i=document.createElement("video");i.muted=!0,i.playsInline=!0,i.preload="auto",i.src=e;const s=()=>{i.removeAttribute("src");try{i.load()}catch{}},a=()=>{try{const{w:u,h:p}=KB(i.videoWidth,i.videoHeight);if(!u||!p)return;const h=document.createElement("canvas");h.width=u,h.height=p;const g=h.getContext("2d");if(!g)return;g.drawImage(i,0,0,u,p);const v=h.toDataURL("image/jpeg",.72);r&&v.startsWith("data:image/jpeg")&&n(v)}catch{}finally{s()}},l=()=>{try{i.currentTime=QB(i.duration)}catch{a()}},c=()=>a(),d=()=>s();return i.addEventListener("loadeddata",l),i.addEventListener("seeked",c),i.addEventListener("error",d),()=>{r=!1,i.removeEventListener("loadeddata",l),i.removeEventListener("seeked",c),i.removeEventListener("error",d),s()}},[e]),t}function Ud({src:e,style:t}){const n=GB(e);return n?o.jsx("img",{src:n,alt:"",style:t}):o.jsx("video",{src:e,muted:!0,playsInline:!0,preload:"metadata",style:t})}const YB=30*60*1e3;function XB(e,t){if(!e)return null;const n=Date.parse(e);return Number.isNaN(n)?null:Math.max(0,n+YB-t)}function G0(e){const t=Math.max(0,Math.floor(e)),n=String(Math.floor(t/60)).padStart(2,"0"),r=String(t%60).padStart(2,"0");return`${n}:${r}`}function J6(e){if(!e)return null;const t=Date.parse(e);if(Number.isNaN(t))return null;const n=new Date(t);return`${String(n.getHours()).padStart(2,"0")}:${String(n.getMinutes()).padStart(2,"0")}`}function Z6(e,t){var s;const n=e.payload.questions??[];if(!n.length)return null;const r=((s=e.result)==null?void 0:s.answers)??{},i=e.payload;return{requestId:e.id,shortId:e.id.slice(0,8),status:e.status,level:i.level??null,questions:n.map(a=>({question:a.question,options:(a.options??[]).map(l=>({label:l.label,description:l.description??null})),multiSelect:!!a.multiSelect,answer:r[a.question]??null})),ts:t??null,timeLabel:J6(t)}}const e3={answers:{},selected:[]};function Vo(e,t){const n=e.questions.findIndex(r=>r.answer==null&&t.answers[r.question]===void 0);return n===-1?e.questions.length:n}function Im(e,t,n){return{answers:{...e.answers,[t]:n},selected:[]}}function JB(e,t){const n=e.selected.includes(t);return{...e,selected:n?e.selected.filter(r=>r!==t):[...e.selected,t]}}function ZB(e,t){return Im(e,t,e.selected.join(", "))}function eW(e,t){return Vo(e,t)>=e.questions.length}function tW(e,t){const n={};for(const r of e.questions){const i=r.answer??t.answers[r.question];i!=null&&(n[r.question]=i)}return n}const nW={picks:{},otherText:{},otherOn:{}};function rW(e,t,n,r){const i=e.picks[t]??[];let s;r?s=i.includes(n)?i.filter(l=>l!==n):[...i,n]:s=i.includes(n)?[]:[n];const a=r?e.otherOn:{...e.otherOn,[t]:!1};return{...e,picks:{...e.picks,[t]:s},otherOn:a}}function oW(e,t,n){const r=!(e.otherOn[t]??!1),i=r&&!n?{...e.picks,[t]:[]}:e.picks;return{...e,otherOn:{...e.otherOn,[t]:r},picks:i}}function iW(e,t,n){return{...e,otherText:{...e.otherText,[t]:n}}}function t3(e,t){const n=[...e.picks[t]??[]];if(e.otherOn[t]){const r=(e.otherText[t]??"").trim();r&&n.push(r)}return n.join(", ")}function sW(e,t){return e.questions.every((n,r)=>t3(t,r)!=="")}function aW(e,t){const n={};return e.questions.forEach((r,i)=>{n[r.question]=t3(t,i)}),n}function lW(e,t){for(const n of e.split(`
|
|
127
|
+
`)){const r=n.trim();if(!r)continue;const i=/^#{1,6}\s+(.+)$/.exec(r);return i?i[1].trim():r}if(t){const n=t.split("/").pop();if(n)return n}return"Plan"}function Y0(e,t){var i;const n=e.payload.planContent??"",r=e.payload.planFilePath??null;return{requestId:e.id,status:e.status,title:lW(n,r),filePath:r,lineCount:n?n.split(`
|
|
128
|
+
`).length:0,planContent:n,feedback:((i=e.result)==null?void 0:i.feedback)??null,ts:t??null,timeLabel:J6(t)}}function Gj(e,t){switch(e){case"approved":return{tone:"done",label:"Plan approved"};case"rejected":return{tone:"rejected",label:"Plan rejected"};case"answered":return{tone:"done",label:"Answered"};case"cancelled":return{tone:"inactive",label:"Cancelled"};default:return{tone:"inactive",label:t==="plan-approval"?"Plan expired":"Expired"}}}function cW(e){const t=e.subtype==="plan-rejected"?"rejected":"done",n=e.subtype==="plan-approved"?"Plan approved":e.subtype==="plan-rejected"?"Plan rejected":"Answered";return{kind:"summary",tone:t,label:n,text:e.text}}function n3(e){const t=e.detail;if(!t)return cW(e);if(t.status==="expired"||t.status==="cancelled"){const{tone:n,label:r}=Gj(t.status,t.kind);return{kind:"summary",tone:n,label:r,text:e.text}}if(t.kind==="ask-user"){const n=Z6(t,e.ts);if(n)return{kind:"ask",model:n};const{tone:r,label:i}=Gj(t.status,t.kind);return{kind:"summary",tone:r,label:i,text:e.text}}return{kind:"plan",model:Y0(t,e.ts)}}function dW(e,t){var n;if(!e)return null;for(const r of e.turns)for(const i of r.messages)if(i.type==="interaction"&&((n=i.interaction)==null?void 0:n.id)===t)return{detail:i.interaction,ts:i.ts??null};return null}const X0={info:{bg:"var(--proto-accent-bg)",border:"var(--proto-accent-border)",fg:"var(--proto-accent)",icon:"i"},warning:{bg:"var(--proto-amber-bg)",border:"var(--proto-amber-border)",fg:"var(--proto-amber-fg)",icon:"!"},error:{bg:"var(--proto-danger-bg)",border:"var(--proto-danger)",fg:"var(--proto-danger)",icon:"×"}};function r3(e){return X0[e]}function o3(e,t){return{border:`1px solid ${e}`,borderRadius:7,background:"transparent",color:e,padding:"5px 9px",fontSize:12,fontWeight:650,cursor:t?"default":"pointer",flex:"none",alignSelf:"center",opacity:t?.5:1}}function uW({action:e,tone:t,done:n,onAction:r}){const i=B();return r?o.jsx("button",{type:"button","data-notice-action":e.kind,disabled:n,onClick:()=>r(e),style:o3(t.fg,n),children:n?i.noticeCancelResumeDone:i.noticeCancelResume}):null}function pW({action:e,label:t,onAction:n}){const r=B(),i=wC(),s=n??(i==null?void 0:i.openLogin);return s?o.jsx("button",{type:"button","data-auth-notice-action":!0,onClick:()=>s(e),style:o3(X0.error.fg,!1),children:t??r.authLoginAgain}):null}function i3({level:e,text:t,authAction:n,authActionLabel:r,onAuthAction:i,noticeAction:s,onNoticeAction:a,noticeActionDone:l=!1}){const c=X0[e],d={display:"flex",alignItems:"flex-start",gap:9,width:"100%",margin:"0 auto",padding:"9px 12px",boxSizing:"border-box",borderRadius:9,border:`1px solid ${c.border}`,background:c.bg,color:c.fg,fontSize:12.5,lineHeight:1.55,overflowWrap:"anywhere"};return o.jsxs("div",{"data-chat-notice":e,role:e==="info"?"status":"alert",style:d,children:[o.jsx("span",{"aria-hidden":"true",style:{width:17,height:17,borderRadius:"50%",border:`1px solid ${c.fg}`,display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"none",marginTop:1,font:"700 10px 'IBM Plex Mono',monospace"},children:c.icon}),o.jsx("span",{style:{flex:1},children:t}),n?o.jsx(pW,{action:n,label:r,onAction:i}):null,s?o.jsx(uW,{action:s,tone:c,done:l,onAction:a}):null]})}function J0(e,t){const[n,r]=f.useState(()=>Date.now()),i=t?XB(e,n):null,s=t&&i!=null&&i>0;return f.useEffect(()=>{if(!s)return;const a=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(a)},[s]),i==null?null:Math.floor(i/1e3)}const ur="'IBM Plex Mono',monospace",Yj={zh:{askPill:"需要你拍板",askAnsweredPill:"已回答",askTag:e=>e?"多选":"单选",otherChip:"其他…",otherPlaceholder:"补充你的答案…",askFootnote:"Agent 暂停中 · 提交后继续",submit:"提交回答",ttlPrefix:"阻塞中 · TTL",planPendingPill:"PLAN · 等待批准",planApprovedPill:"✓ 计划已批准",planRejectedPill:"已驳回",planTtl:"Agent 暂停中 · TTL",approvedBy:"由你批准",fileSub:"已写入 · 批准前建议通读全文",readLink:"阅读 ›",approveHint:"",requestChanges:"请求修改",approvePlan:"批准计划",feedbackHint:"反馈必填 · 确认后退回重新规划",feedbackPlaceholder:"说明需要修改什么…",cancel:"取消",confirmReturn:"确认退回",approvedFoot:"· Agent 继续执行",rejectedFoot:"",viewPlan:"查看计划 ›",viewOriginalPlan:"查看原计划 ›"},en:{askPill:"Your call",askAnsweredPill:"Answered",askTag:e=>e?"multi":"single",otherChip:"Other…",otherPlaceholder:"Type your answer…",askFootnote:"Agent paused · continues after submit",submit:"Submit answers",ttlPrefix:"Blocking · TTL",planPendingPill:"PLAN · awaiting approval",planApprovedPill:"✓ Plan approved",planRejectedPill:"Rejected",planTtl:"Agent paused · TTL",approvedBy:"approved by you",fileSub:"written · read the full plan before approving",readLink:"Read ›",approveHint:"",requestChanges:"Request changes",approvePlan:"Approve plan",feedbackHint:"Feedback required · confirming returns it for replanning",feedbackPlaceholder:"What needs to change…",cancel:"Cancel",confirmReturn:"Confirm return",approvedFoot:"· agent continues",rejectedFoot:"",viewPlan:"View plan ›",viewOriginalPlan:"View original plan ›"}};function fW({model:e,state:t,copy:n,onState:r,onSubmit:i,busy:s}){const a=e.status==="pending",l=J0(e.ts,a),c=a&&!s&&sW(e,t);if(!a)return o.jsxs("div",{style:{border:"1px solid var(--proto-line)",background:"var(--proto-rail)",borderRadius:10,padding:"13px 16px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[o.jsx("span",{style:{width:18,height:18,borderRadius:"50%",background:"var(--proto-accent-bg)",color:"var(--proto-accent)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,flex:"none"},children:"?"}),o.jsx("span",{style:{fontSize:10.5,fontWeight:700,padding:"2.5px 9px",borderRadius:999,background:"var(--proto-gray)",color:"var(--proto-muted-2)"},children:n.askAnsweredPill}),o.jsx("span",{style:{font:`400 10px ${ur}`,color:"var(--proto-muted-3)"},children:"AskUserQuestion"}),e.timeLabel&&o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${ur}`,color:"var(--proto-faint)"},children:e.timeLabel})]}),o.jsx("div",{style:{marginTop:10,display:"flex",flexDirection:"column",gap:6},children:e.questions.map(u=>o.jsxs("div",{style:{display:"flex",gap:8,fontSize:12,lineHeight:1.5,alignItems:"baseline"},children:[o.jsx("span",{style:{color:"var(--proto-success)",fontWeight:700,flex:"none"},children:"✓"}),o.jsxs("div",{style:{minWidth:0,display:"flex",flexWrap:"wrap",columnGap:8,rowGap:2},children:[o.jsx("span",{style:{color:"var(--proto-muted-2)",overflowWrap:"anywhere"},children:u.question}),o.jsx("span",{style:{color:"var(--proto-ink)",fontWeight:600,overflowWrap:"anywhere"},children:u.answer??"—"})]})]},u.question))})]});const d=e.level?r3(e.level):null;return o.jsxs("div",{...e.level?{"data-ask-level":e.level}:{},style:{border:`1px solid ${d?d.border:"var(--proto-accent-border)"}`,background:"var(--proto-rail)",borderRadius:10,padding:"13px 16px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[o.jsx("span",{style:{width:18,height:18,borderRadius:"50%",background:d?d.bg:"var(--proto-accent-bg)",color:d?d.fg:"var(--proto-accent)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,flex:"none"},children:d?d.icon:"?"}),o.jsx("span",{style:{fontSize:10.5,fontWeight:700,padding:"2.5px 9px",borderRadius:999,background:d?d.bg:"var(--proto-accent-bg)",color:d?d.fg:"var(--proto-accent)"},children:n.askPill}),o.jsx("span",{style:{font:`400 10px ${ur}`,color:"var(--proto-muted-3)"},children:"AskUserQuestion"}),o.jsxs("span",{style:{marginLeft:"auto",font:`400 9.5px ${ur}`,color:"var(--proto-faint)"},children:[n.ttlPrefix," ",l!=null?G0(l):"30m"]})]}),e.questions.map((u,p)=>{const h=t.picks[p]??[],g=t.otherOn[p]??!1;return o.jsxs("div",{style:{marginTop:p===0?10:13},children:[o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:7},children:[o.jsx("span",{style:{fontSize:13,fontWeight:600,color:"var(--proto-ink)"},children:u.question}),o.jsx("span",{style:{font:`500 9px ${ur}`,color:"var(--proto-muted-3)",background:"var(--proto-gray)",padding:"1px 6px",borderRadius:5},children:n.askTag(u.multiSelect)})]}),o.jsxs("div",{style:{display:"flex",gap:7,marginTop:8,flexWrap:"wrap"},children:[u.options.map(v=>{const x=h.includes(v.label),w=u.multiSelect?x?"☑":"☐":x?"●":"○";return o.jsxs("span",{role:"button",title:v.description??void 0,onClick:()=>r(rW(t,p,v.label,u.multiSelect)),style:{fontSize:12,fontWeight:x?600:500,border:`1px solid ${x?"var(--proto-accent)":"var(--proto-accent-border)"}`,background:x?"var(--proto-accent-bg)":"var(--proto-card)",color:"var(--proto-accent)",padding:"5px 12px",borderRadius:8,cursor:"pointer"},children:[w," ",v.label]},v.label)}),o.jsxs("span",{role:"button",onClick:()=>r(oW(t,p,u.multiSelect)),style:{fontSize:12,fontWeight:g?600:500,border:`1px solid ${g?"var(--proto-accent)":"var(--proto-accent-border)"}`,background:g?"var(--proto-accent-bg)":"var(--proto-card)",color:"var(--proto-accent)",padding:"5px 12px",borderRadius:8,cursor:"pointer"},children:[u.multiSelect?g?"☑":"☐":g?"●":"○"," ",n.otherChip]})]}),g&&o.jsx("input",{value:t.otherText[p]??"",onChange:v=>r(iW(t,p,v.target.value)),placeholder:n.otherPlaceholder,style:{marginTop:7,width:"100%",boxSizing:"border-box",border:"1px solid var(--proto-accent-border)",borderRadius:8,padding:"7px 11px",fontSize:12,color:"var(--proto-ink)",background:"var(--proto-card)",outline:"none"}})]},u.question)}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:13},children:[o.jsx("span",{style:{fontSize:10.5,color:"var(--proto-muted-3)",flex:1,lineHeight:1.5},children:n.askFootnote}),o.jsx("span",{role:"button",onClick:c?()=>i(aW(e,t)):void 0,style:{fontSize:12,fontWeight:600,borderRadius:8,padding:"7px 16px",color:"var(--ink-solid-fg)",background:c?"var(--proto-ink)":"var(--proto-faint)",flex:"none",cursor:c?"pointer":"not-allowed"},children:n.submit})]})]})}function hW({model:e,copy:t,feedbackOpen:n,onFeedbackOpen:r,onApprove:i,onReject:s,onOpenRead:a,busy:l}){const c=e.status==="pending",d=e.status==="approved",u=e.status==="rejected",p=J0(e.ts,c),[h,g]=f.useState(""),v=h.trim().length>0&&!l,x=e.filePath||e.planContent?o.jsxs("div",{role:"button",onClick:a,style:{marginTop:10,display:"flex",alignItems:"center",gap:10,border:"1px solid var(--proto-accent-bg)",background:"var(--proto-accent-bg)",borderRadius:8,padding:"9px 12px",cursor:"pointer"},children:[o.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 14 14",fill:"none",stroke:"var(--proto-accent)",strokeWidth:"1.4",style:{flex:"none"},children:[o.jsx("path",{d:"M3 1.5h5.5L11.5 4.5V12.5H3z"}),o.jsx("path",{d:"M5 6.5h4M5 9h4"})]}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{font:`500 11px ${ur}`,color:"var(--proto-ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.filePath??`${e.lineCount} lines`}),o.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginTop:2},children:t.fileSub})]}),o.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--proto-accent)",flex:"none"},children:t.readLink})]}):null;return c?o.jsxs("div",{style:{border:"1px solid var(--proto-accent-border)",background:"var(--proto-card)",borderRadius:10,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"10px 15px",borderBottom:"1px solid var(--proto-line-2)",background:"var(--proto-rail)"},children:[o.jsx("span",{style:{fontSize:10.5,fontWeight:700,padding:"2.5px 9px",borderRadius:999,background:"var(--proto-accent-bg)",color:"var(--proto-accent)"},children:t.planPendingPill}),o.jsx("span",{style:{font:`400 10px ${ur}`,color:"var(--proto-muted-3)"},children:"ExitPlanMode"}),o.jsxs("span",{style:{marginLeft:"auto",font:`400 9.5px ${ur}`,color:"var(--proto-faint)"},children:[t.planTtl," ",p!=null?G0(p):"30m"]})]}),o.jsxs("div",{style:{padding:"12px 16px 13px"},children:[o.jsx("div",{style:{fontSize:13.5,fontWeight:600,color:"var(--proto-ink)",overflowWrap:"break-word"},children:e.title}),x]}),n&&o.jsx("div",{style:{padding:"0 16px 11px"},children:o.jsx("textarea",{value:h,onChange:w=>g(w.target.value),placeholder:t.feedbackPlaceholder,rows:2,style:{width:"100%",boxSizing:"border-box",border:"1.5px solid var(--proto-amber)",boxShadow:"0 0 0 3px rgba(201,154,46,.08)",background:"var(--proto-card)",borderRadius:8,padding:"8px 11px",fontSize:12,lineHeight:1.55,color:"var(--proto-ink)",outline:"none",resize:"none",fontFamily:"inherit"}})}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"11px 16px",borderTop:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{fontSize:10.5,color:"var(--proto-muted-3)",flex:1,lineHeight:1.5},children:n?t.feedbackHint:t.approveHint}),n?o.jsxs(o.Fragment,{children:[o.jsx("span",{role:"button",onClick:()=>{r(!1),g("")},style:{fontSize:12,fontWeight:600,border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",color:"var(--proto-ink)",padding:"6px 13px",borderRadius:8,flex:"none",cursor:"pointer"},children:t.cancel}),o.jsx("span",{role:"button",onClick:v?()=>s(h.trim()):void 0,style:{fontSize:12,fontWeight:600,borderRadius:8,padding:"7px 16px",color:"var(--ink-solid-fg)",background:v?"var(--proto-ink)":"var(--proto-faint)",flex:"none",cursor:v?"pointer":"not-allowed"},children:t.confirmReturn})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{role:"button",onClick:()=>r(!0),style:{fontSize:12,fontWeight:600,border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",color:"var(--proto-ink)",padding:"6px 13px",borderRadius:8,flex:"none",cursor:"pointer"},children:t.requestChanges}),o.jsx("span",{role:"button",onClick:l?void 0:i,style:{fontSize:12,fontWeight:600,borderRadius:8,padding:"7px 16px",color:"var(--ink-solid-fg)",background:l?"var(--proto-faint)":"var(--proto-ink)",flex:"none",cursor:l?"not-allowed":"pointer"},children:t.approvePlan})]})]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{border:"1px solid var(--proto-line)",background:"var(--proto-rail)",borderRadius:10,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"10px 15px",borderBottom:"1px solid var(--proto-line-2)",background:"var(--proto-rail)"},children:[o.jsx("span",{style:{fontSize:10.5,fontWeight:700,padding:"2.5px 9px",borderRadius:999,background:d?"var(--proto-success-bg)":"var(--proto-gray)",color:d?"var(--proto-success)":"var(--proto-muted-2)"},children:d?t.planApprovedPill:u?t.planRejectedPill:e.status}),o.jsx("span",{style:{font:`400 10px ${ur}`,color:"var(--proto-muted-3)"},children:"ExitPlanMode"}),e.timeLabel&&o.jsxs("span",{style:{marginLeft:"auto",font:`400 9.5px ${ur}`,color:"var(--proto-faint)"},children:[e.timeLabel,d?` ${t.approvedBy}`:""]})]}),o.jsx("div",{style:{padding:"12px 16px 13px"},children:o.jsx("div",{style:{fontSize:13.5,fontWeight:600,color:d?"var(--proto-muted)":"var(--proto-muted-2)",overflowWrap:"break-word",...u?{textDecoration:"line-through",textDecorationColor:"var(--proto-line)"}:{}},children:e.title})}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"10px 16px",borderTop:"1px solid var(--proto-line-2)",font:`400 10px ${ur}`,color:"var(--proto-muted-3)"},children:[e.filePath&&o.jsx("span",{style:{color:"var(--proto-accent)",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.filePath}),o.jsx("span",{children:d?t.approvedFoot:u?t.rejectedFoot:""}),o.jsx("span",{role:"button",onClick:a,style:{marginLeft:"auto",color:"var(--proto-accent)",fontWeight:600,cursor:"pointer",flex:"none"},children:u?t.viewOriginalPlan:t.viewPlan})]})]}),u&&e.feedback&&o.jsx("div",{style:{alignSelf:"flex-end",maxWidth:"75%",background:"var(--proto-gray)",borderRadius:"14px 14px 4px 14px",padding:"9px 14px",fontSize:13.5,lineHeight:1.55,color:"var(--proto-ink)",whiteSpace:"pre-wrap",marginTop:10},children:e.feedback})]})}function s3(e,t,n){if(n<=t)return 100;const r=Math.round((e+t)/n*100);return Math.max(0,Math.min(100,r))}function a3(e,t){const n=t==="zh";switch(e){case"pending":return n?"待批":"pending";case"approved":return n?"已批准":"approved";case"rejected":return n?"已驳回":"rejected";case"cancelled":return n?"已取消":"cancelled";default:return n?"已过期":"expired"}}function l3(e,t,n,r){const i=r==="zh"?`${t} 行`:`${t} lines`;return[e,i,n].filter(Boolean).join(" · ")}function c3(e,t){return null}const Yl="'IBM Plex Mono',monospace";function gW({model:e,copy:t,lang:n="zh",onClose:r,onApprove:i,onRequestChanges:s}){const a=e.status==="pending",[l,c]=f.useState(0),d=f.useRef(null),u=()=>{const v=d.current;if(!v)return;const x=s3(v.scrollTop,v.clientHeight,v.scrollHeight);c(w=>Math.max(w,x))};f.useEffect(()=>{const v=x=>{x.key==="Escape"&&r()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[r]);const p=a3(e.status,n),h=c3(),g=e.status==="approved"?{text:`${t.planApprovedPill}${e.timeLabel?` · ${e.timeLabel} ${t.approvedBy}`:""}`,fg:"var(--proto-success)",bg:"var(--proto-success-bg)"}:e.status==="rejected"?{text:`${t.planRejectedPill}${e.timeLabel?` · ${e.timeLabel}`:""}`,fg:"var(--proto-muted-2)",bg:"var(--proto-gray)"}:{text:p,fg:"var(--proto-muted-2)",bg:"var(--proto-gray)"};return o.jsx("div",{onClick:r,style:{position:"fixed",inset:0,background:"rgba(16,20,28,.42)",zIndex:70,display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsxs("div",{onClick:v=>v.stopPropagation(),style:{width:760,maxWidth:"calc(100vw - 64px)",height:"min(720px, calc(100vh - 80px))",background:"var(--proto-card)",borderRadius:14,boxShadow:"0 24px 64px rgba(16,24,40,.28)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{flex:"none",padding:"14px 18px 12px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:15,fontWeight:650,color:"var(--proto-ink)",letterSpacing:"-.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),o.jsx("div",{style:{font:`400 10px ${Yl}`,color:"var(--proto-muted-2)",marginTop:2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:l3(e.filePath,e.lineCount,p,n)})]}),a?o.jsx("span",{style:{font:`600 9.5px ${Yl}`,color:"var(--proto-amber-fg)",background:"var(--pill-waiting-bg)",padding:"2.5px 9px",borderRadius:999,flex:"none"},children:t.planPendingPill}):o.jsx("span",{style:{font:`600 9.5px ${Yl}`,color:g.fg,background:g.bg,padding:"2.5px 9px",borderRadius:999,flex:"none"},children:p}),o.jsx("span",{role:"button","aria-label":"Close",onClick:r,style:{width:26,height:26,borderRadius:8,border:"1px solid var(--proto-line)",background:"var(--proto-rail)",color:"var(--proto-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,cursor:"pointer",flex:"none"},children:"✕"})]}),a&&o.jsx("div",{style:{height:3,borderRadius:999,background:"var(--proto-line)",overflow:"hidden",marginTop:10},children:o.jsx("div",{style:{width:`${l}%`,height:"100%",background:"var(--proto-accent)"}})})]}),o.jsxs("div",{style:{flex:1,minHeight:0,position:"relative"},children:[o.jsxs("div",{ref:d,onScroll:u,style:{position:"absolute",inset:0,overflow:"auto",padding:"18px 22px 28px",boxSizing:"border-box"},children:[e.timeLabel&&o.jsx("div",{style:{font:`400 10px ${Yl}`,color:"var(--proto-faint)",paddingBottom:8},children:e.timeLabel}),o.jsx("div",{style:{fontSize:13.5,lineHeight:1.7,color:"var(--proto-ink-2)"},children:o.jsx(Ai,{text:e.planContent})}),e.status==="rejected"&&e.feedback&&o.jsxs("div",{style:{marginTop:16,border:"1px solid var(--proto-amber-border)",background:"var(--proto-amber-bg)",borderRadius:10,padding:"10px 13px"},children:[o.jsx("div",{style:{font:`600 10px ${Yl}`,color:"var(--proto-amber-text)",paddingBottom:4},children:t.feedbackHint.split(" · ")[0]}),o.jsx("div",{style:{fontSize:12.5,lineHeight:1.6,color:"var(--proto-amber-fg)",whiteSpace:"pre-wrap"},children:e.feedback})]})]}),o.jsx("div",{style:{position:"absolute",left:0,right:0,bottom:0,height:48,background:"linear-gradient(180deg,rgba(255,255,255,0),var(--proto-card))",pointerEvents:"none"}})]}),o.jsx("div",{style:{flex:"none",borderTop:"1px solid var(--proto-line-2)",padding:"12px 18px"},children:a?o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{fontSize:10.5,color:"var(--proto-muted-3)",flex:1},children:t.approveHint}),o.jsx("span",{role:"button",onClick:s,style:{fontSize:12,fontWeight:600,border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",color:"var(--proto-ink)",padding:"7px 14px",borderRadius:8,cursor:"pointer",flex:"none"},children:t.requestChanges}),o.jsxs("span",{role:"button",onClick:i,style:{fontSize:12,fontWeight:600,borderRadius:8,padding:"8px 18px",color:"var(--ink-solid-fg)",background:"var(--proto-ink)",cursor:"pointer",flex:"none",display:"flex",flexDirection:"column",alignItems:"center",gap:1},children:[o.jsx("span",{children:t.approvePlan}),h]})]}):o.jsx("div",{style:{height:36,borderRadius:9,background:g.bg,color:g.fg,display:"flex",alignItems:"center",justifyContent:"center",fontSize:12.5,fontWeight:600},children:g.text})})]})})}function xW(e,t){const{blockId:n,text:r}=t;return typeof n!="string"||!n||typeof r!="string"||!r?e:!e||e.blockId!==n?{blockId:n,text:r}:{blockId:n,text:e.text+r}}function mW(e,t){return!e||!t||t===e.blockId?null:e}function Xj(){return{active:null,finalizedBlockIds:[]}}function vW(e,t){const n=t.blockId;if(!n||e.finalizedBlockIds.includes(n))return e;const r=xW(e.active,t);return r===e.active?e:{...e,active:r}}function kg(e,t){var s;const n=t??((s=e.active)==null?void 0:s.blockId),r=mW(e.active,t);if(!n||e.finalizedBlockIds.includes(n))return{...e,active:r};const i=[...e.finalizedBlockIds,n].slice(-32);return{active:r,finalizedBlockIds:i}}function yW(e,t){const{messageTs:n,pendingId:r}=t;if(!r&&!n)return{pending:e,committed:null};const i=r?e.findIndex(a=>a.id===r):e.findIndex(a=>a.ts===n);if(i===-1)return{pending:e,committed:null};const s=e[i];return{pending:e.filter((a,l)=>l!==i),committed:{sessionId:t.sessionId??"",role:"user",text:s.text,ts:t.committedTs||s.ts,attachments:s.attachments}}}function bW(e,t,n){if(!t)return e;if(t.pendingUserMessages!==void 0)return t.pendingUserMessages.filter(s=>!(n!=null&&n.has(s.id))).map(s=>({...s}));if(e.length===0)return e;const r=[];for(const s of t.turns)for(const a of s.messages)a.type==="user"&&r.push({text:a.text??"",ts:a.ts});const i=[];for(const s of e){const a=r.findIndex(l=>l.text===s.text&&l.ts>=s.ts);a===-1?i.push(s):r.splice(a,1)}return i.length===e.length?e:i}const Jj="[Scheduled Task]";function jW(e){const t=e.role==="tool";return{type:e.role,text:t?null:e.text??"",toolName:t?e.toolName??"":null,toolInput:t?e.toolInput??"":null,ts:e.ts,elapsedMs:null,attachments:e.attachments,...e.noticeLevel?{noticeLevel:e.noticeLevel}:{},...e.noticeAction?{noticeAction:e.noticeAction}:{},...e.authAction?{authAction:e.authAction}:{}}}function wW(e){return(e==null?void 0:e.turns.length)??0}function d3(e){if(!e||e.turns.length===0)return null;const t=e.turns[e.turns.length-1];let n=0,r=!1;for(let i=1;i<t.messages.length;i++){const s=t.messages[i].elapsedMs;s!=null&&(n+=s,r=!0)}return r?n:null}function kW(e,t,n){return e??t??n}function SW(e,t){return e??t??!1}function u3(e,t){return e??t??null}function p3(e){if(e==null)return"—";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function f3(e,t){let n=0,r=0;for(let i=t+1;i<e.length;i++){const s=e[i];s.kind==="assistant"?n++:s.kind==="tools"&&(r+=s.count)}return{replies:n,toolCalls:r}}function h3(e){const t=new Set;for(let n=0;n<e.length;n++){const r=e[n];if(!(r.kind!=="user"||!r.edited))for(let i=n+1;i<e.length;i++){const s=e[i].kind;if(s==="user")break;if(s==="assistant"){t.add(i);break}}}return t}function CW(e){var n,r;if(e.type==="interaction"&&((n=e.interaction)!=null&&n.id))return`interaction|${e.interaction.id}`;const t=((r=e.authAction)==null?void 0:r.noticeId)??"";return`${e.type}|${e.ts}|${e.text??""}|${e.toolName??""}|${e.toolInput??""}|${e.noticeLevel??""}|${t}`}function TW(e,t){const n=new Date(e),r=d=>new Date(d.getFullYear(),d.getMonth(),d.getDate()).getTime(),i=Math.round((r(t)-r(n))/864e5),s=String(n.getHours()).padStart(2,"0"),a=String(n.getMinutes()).padStart(2,"0"),l=`${s}:${a}`;return i<=0?`TODAY ${l}`:i===1?`YESTERDAY ${l}`:`${n.toLocaleString("en-US",{month:"short"}).toUpperCase()} ${n.getDate()} ${l}`}function g3(e){return(t,n)=>{const r=new Date(t),i=u=>new Date(u.getFullYear(),u.getMonth(),u.getDate()).getTime(),s=Math.round((i(n)-i(r))/864e5),a=String(r.getHours()).padStart(2,"0"),l=String(r.getMinutes()).padStart(2,"0"),c=`${a}:${l}`;return s<=0?`${e.wbSessionToday} ${c}`:s===1?`${e.wbSessionYesterday} ${c}`:`${r.toLocaleString("en-US",{month:"short"}).toUpperCase()} ${r.getDate()} ${c}`}}function x3(e,t=new Date){if(!e)return null;const n=new Date(e);if(Number.isNaN(n.getTime()))return null;const r=l=>String(l).padStart(2,"0"),i=`${r(n.getHours())}:${r(n.getMinutes())}`;if(n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate())return i;const a=`${r(n.getMonth()+1)}-${r(n.getDate())}`;return`${n.getFullYear()===t.getFullYear()?a:`${n.getFullYear()}-${a}`} ${i}`}function EW(e){const t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function Z0(e,t,n={}){var h;const r=n.now??new Date,i=[],s=new Set,a=(g,v)=>{const x=CW(g);s.has(x)||(s.add(x),i.push(v!==void 0?{...g,turnIndex:v}:g))};for(const g of e.turns)for(const v of g.messages)a(v,g.turnIndex);for(const g of t)a(jW(g));const l=[];let c=null,d=!1,u=[];const p=()=>{u.length!==0&&(l.push({kind:"tools",count:u.length,calls:u}),u=[])};for(const g of i){const v=EW(g.ts);if(v!==c){p();const x=n.formatDivider?n.formatDivider(g.ts,r):TW(g.ts,r);l.push({kind:"divider",text:x}),c=v}if(g.type==="tool"){const x=g.debug;u.push({kind:g.toolName??"",input:g.toolInput??"",...x&&(x.toolInput!==void 0||x.toolResult!==void 0)?{debug:{toolInput:x.toolInput,...x.toolResult!==void 0?{toolResult:x.toolResult}:{},...x.overCharacterThreshold===!0?{overCharacterThreshold:!0}:{}}}:{}});continue}if(p(),g.type==="interaction")l.push({kind:"interaction",subtype:g.subtype??"",text:g.text??"",detail:g.interaction,ts:g.ts??null});else if(g.type==="user"){const x=!d;d=!0;const w=g.text??"",b=x&&n.stripScheduledPrefix&&w.startsWith(Jj)?w.slice(Jj.length).trim():w;l.push({kind:"user",text:b,attachments:g.attachments,...g.turnIndex!==void 0?{turnIndex:g.turnIndex}:{},...g.ts?{ts:g.ts}:{},...g.edited!==void 0?{edited:g.edited}:{},...((h=g.debug)==null?void 0:h.agentMessage)!==void 0?{debug:{agentMessage:g.debug.agentMessage}}:{}})}else g.type==="assistant"&&g.noticeLevel?l.push({kind:"notice",level:g.noticeLevel,text:g.text??"",...g.noticeAction?{noticeAction:g.noticeAction}:{},...g.authAction?{authAction:g.authAction}:{}}):l.push({kind:"assistant",text:g.text??"",streaming:!1,attachments:g.attachments})}if(p(),n.streamingText&&l.push({kind:"assistant",text:n.streamingText,streaming:!0,preview:!0}),n.streaming)for(let g=l.length-1;g>=0;g--){const v=l[g];if(v.kind==="assistant"){l[g]={...v,streaming:!0};break}}for(const g of n.pendingUser??[])l.push({kind:"user",text:g.text,attachments:g.attachments,ts:g.ts,pending:!0});return l}const m3=92,Zj=350,ew=2*m3,RW=8*m3,PW=120;function IW(e,t,n){if(!(n>0)||e>=t)return Math.min(e,t);const r=t-e;if(r>=RW)return t;const i=r<=ew?Zj:Zj*ew/r,s=Math.max(r/i,PW/1e3);return Math.min(e+s*n,t)}function MW(e,t,n){return t.startsWith(e)?Math.min(Math.max(0,n),t.length):0}function LW(e,t){return e.streamKey!==t.streamKey?t.text.length:MW(e.text,t.text,e.revealed)}function OW(e,t){const n=Math.floor(t);return n>0?n>=e.length?e:e.slice(0,n):""}const DW=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;function v3(e,t,n){const[r]=f.useState(DW),[i,s]=f.useState(()=>({streamKey:n,text:e,revealed:0})),a=i.text!==e||i.streamKey!==n,l=a?LW(i,{streamKey:n,text:e}):i.revealed;a&&s({streamKey:n,text:e,revealed:l});const c=t&&!r,d=c&&l<e.length;return f.useEffect(()=>{if(!d)return;let u=0,p=0;const h=g=>{const v=p===0?0:g-p;p=g,s(x=>{const w=IW(x.revealed,x.text.length,v);return w===x.revealed?x:{streamKey:x.streamKey,text:x.text,revealed:w}}),u=requestAnimationFrame(h)};return u=requestAnimationFrame(h),()=>cancelAnimationFrame(u)},[d]),c?OW(e,l):e}const gl="'IBM Plex Mono',monospace",tw={zh:{copy:"复制",copied:"已复制",edit:"编辑消息",editDisabled:"运行中不可编辑 — 暂停后可用",cancel:"取消",sendRewind:"发送并回退",escHint:"Esc 取消 · ⌘↩ 发送",rewindNote:(e,t)=>`发送后回退其后 ${e} 条回复 · ${t} 次工具调用作废`,willRewind:"将被回退",edited:"已编辑",original:"原消息",regenNote:"由编辑重新生成"},en:{copy:"Copy",copied:"Copied",edit:"Edit message",editDisabled:"Running — stop the turn to edit",cancel:"Cancel",sendRewind:"Send & rewind",escHint:"Esc cancel · ⌘↩ send",rewindNote:(e,t)=>`Rewinds ${e} repl${e===1?"y":"ies"} · ${t} tool call${t===1?"":"s"} discarded`,willRewind:"will rewind",edited:"edited",original:"Original",regenNote:"Regenerated from edit"}};function AW(){return o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"var(--proto-muted)",strokeWidth:"1.4",children:[o.jsx("rect",{x:"4.5",y:"4.5",width:"8",height:"8",rx:"1.5"}),o.jsx("path",{d:"M2.5 9.5V3.5a1 1 0 0 1 1-1h6"})]})}function NW(){return o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"var(--proto-muted)",strokeWidth:"1.4",children:[o.jsx("path",{d:"M2.5 11.5l.6-2.6 6.4-6.4a1.3 1.3 0 0 1 1.8 0l.2.2a1.3 1.3 0 0 1 0 1.8L5.1 10.9z"}),o.jsx("path",{d:"M8.6 3.4l2 2"})]})}function nw({text:e,side:t="center"}){return o.jsx("span",{style:{position:"absolute",top:-27,...t==="center"?{left:"50%",transform:"translateX(-50%)"}:{right:-8},background:"var(--proto-ink)",color:"var(--ink-solid-fg)",fontSize:10,fontWeight:600,padding:"3px 8px",borderRadius:6,whiteSpace:"nowrap",zIndex:3,pointerEvents:"none"},children:e})}function $W({text:e,copy:t,onEdit:n,editDisabled:r,showCopy:i=!0,extraAction:s}){const[a,l]=f.useState(!1),[c,d]=f.useState(!1),u=f.useRef(null);f.useEffect(()=>()=>{u.current&&clearTimeout(u.current)},[]);const p=()=>{var h;(h=navigator.clipboard)==null||h.writeText(e).catch(()=>{}),l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>l(!1),1500)};return o.jsxs("div",{style:{position:"relative",display:"flex",gap:2,background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:9,padding:3,boxShadow:"0 2px 8px rgba(16,24,40,.08)",flex:"none"},children:[a&&o.jsx(nw,{text:t.copied}),c&&r&&o.jsx(nw,{text:t.editDisabled,side:"right"}),i&&o.jsx("span",{role:"button",title:a?void 0:t.copy,onClick:p,style:{width:26,height:26,borderRadius:7,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",...a?{background:"var(--proto-success-bg)"}:{}},children:a?o.jsx("span",{style:{color:"var(--proto-success)",fontSize:11,fontWeight:700},children:"✓"}):o.jsx(AW,{})}),n&&o.jsx("span",{role:"button",title:r?void 0:t.edit,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onClick:r?void 0:n,style:{width:26,height:26,borderRadius:7,display:"flex",alignItems:"center",justifyContent:"center",cursor:r?"default":"pointer",opacity:r?.3:1},children:o.jsx(NW,{})}),s]})}function _W({initialText:e,copy:t,onCancel:n,onSubmit:r,busy:i}){const[s,a]=f.useState(e),l=f.useRef(null);f.useEffect(()=>{const u=l.current;u&&(u.focus(),u.setSelectionRange(u.value.length,u.value.length),u.style.height="auto",u.style.height=`${u.scrollHeight}px`)},[]);const c=s.trim().length>0&&!i,d=()=>{c&&r(s)};return o.jsxs("div",{style:{alignSelf:"flex-end",width:"94%",boxSizing:"border-box",border:"1.5px solid var(--proto-accent)",borderRadius:"14px 14px 4px 14px",background:"var(--proto-card)",boxShadow:"0 0 0 3px rgba(70,85,212,.08)",padding:"11px 14px 9px"},children:[o.jsx("textarea",{ref:l,value:s,onChange:u=>{a(u.target.value),u.target.style.height="auto",u.target.style.height=`${u.target.scrollHeight}px`},onKeyDown:u=>{u.key==="Escape"&&(u.preventDefault(),n()),u.key==="Enter"&&(u.metaKey||u.ctrlKey)&&(u.preventDefault(),d())},rows:1,style:{width:"100%",border:"none",outline:"none",resize:"none",background:"transparent",fontSize:13.5,lineHeight:1.55,color:"var(--proto-ink)",fontFamily:"inherit",padding:0,margin:0,display:"block",overflow:"hidden",boxSizing:"border-box"}}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:10,paddingTop:9,borderTop:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{font:`400 10px ${gl}`,color:"var(--proto-faint)"},children:t.escHint}),o.jsx("span",{role:"button",onClick:n,style:{marginLeft:"auto",fontSize:12,fontWeight:600,color:"var(--proto-muted)",border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"5px 12px",cursor:"pointer"},children:t.cancel}),o.jsx("span",{role:"button",onClick:d,style:{fontSize:12,fontWeight:600,color:"var(--ink-solid-fg)",background:"var(--proto-ink)",borderRadius:8,padding:"6px 13px",cursor:c?"pointer":"default",opacity:c?1:.5},children:t.sendRewind})]})]})}function FW({replies:e,toolCalls:t,copy:n}){return o.jsxs("div",{style:{alignSelf:"flex-end",display:"flex",alignItems:"center",gap:6,font:`500 10.5px ${gl}`,color:"var(--proto-amber-text)"},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-amber)",flex:"none"}}),n.rewindNote(e,t)]})}function zW({children:e,copy:t}){return o.jsxs("div",{style:{position:"relative",marginTop:6},children:[o.jsx("span",{style:{position:"absolute",top:-4,right:0,font:`600 9px ${gl}`,color:"var(--proto-amber-fg)",background:"var(--pill-waiting-bg)",padding:"2px 7px",borderRadius:4,zIndex:1},children:t.willRewind}),o.jsx("div",{style:{opacity:.35,display:"flex",flexDirection:"column",gap:16,paddingTop:14,pointerEvents:"none"},children:e})]})}function rw(e){if(!e)return null;const t=new Date(e);return Number.isNaN(t.getTime())?null:`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function BW({edited:e,ts:t,copy:n}){const[r,i]=f.useState(!1),s=rw(t),a=rw(e.originalTs);return o.jsxs("div",{onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{position:"relative",alignSelf:"flex-end",font:`400 9.5px ${gl}`,color:"var(--proto-faint)",cursor:"default"},children:[r&&o.jsxs("div",{style:{position:"absolute",bottom:"100%",right:0,marginBottom:5,minWidth:180,maxWidth:420,background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"0 8px 24px rgba(16,24,40,.12)",padding:"9px 12px",boxSizing:"border-box",zIndex:3},children:[o.jsxs("div",{style:{font:`600 9px ${gl}`,color:"var(--proto-muted-3)",letterSpacing:".05em",paddingBottom:4},children:[n.original,a?` · ${a}`:""]}),o.jsx("div",{style:{fontSize:12,lineHeight:1.5,color:"var(--proto-muted)",whiteSpace:"pre-wrap",overflowWrap:"break-word"},children:e.originalText})]}),o.jsx("span",{style:{borderBottom:"1px dotted var(--proto-faint)"},children:n.edited}),s&&o.jsxs("span",{children:[" · ",s]})]})}function WW({copy:e}){return o.jsxs("div",{style:{font:`400 9.5px ${gl}`,color:"var(--proto-faint)",display:"flex",alignItems:"center",gap:5},children:[o.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:"var(--proto-line-3)",flex:"none"}}),e.regenNote]})}const bs="'IBM Plex Mono',monospace";function UW({text:e}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[o.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line-2)"}}),o.jsx("div",{style:{fontSize:10,fontWeight:600,letterSpacing:".06em",color:"var(--proto-faint)"},children:e}),o.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line-2)"}})]})}function y3(e){return e==="image"?{bg:"var(--proto-accent-bg)",fg:"var(--proto-accent)"}:e==="video"?{bg:"var(--proto-danger-bg)",fg:"var(--proto-danger)"}:{bg:"var(--proto-gray)",fg:"var(--proto-muted)"}}function b3(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function j3(e){const t=e.lastIndexOf(".");return t>0?e.slice(t+1).toUpperCase().slice(0,4):"FILE"}function HW({a:e,width:t,height:n}){const r=Ls(e.type),{openMedia:i}=zd(),s=Q0(e.path);return o.jsxs("div",{role:"button",title:e.name,onClick:()=>i({kind:r,name:e.name,path:e.path}),style:{position:"relative",width:t,height:n,borderRadius:12,border:"1px solid var(--proto-line)",background:s?"#000":"repeating-linear-gradient(45deg,var(--proto-line),var(--proto-line) 5px,var(--proto-line) 5px,var(--proto-line) 10px)",boxSizing:"border-box",flex:"none",overflow:"hidden",cursor:"pointer"},children:[s&&r==="image"&&o.jsx("img",{src:s,alt:e.name,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}),s&&r==="video"&&o.jsx(Ud,{src:s,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}),r==="video"&&o.jsx("span",{style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%)",width:26,height:26,borderRadius:"50%",background:"rgba(25,28,34,.82)",color:"var(--ink-solid-fg)",fontSize:9,display:"flex",alignItems:"center",justifyContent:"center",paddingLeft:2,boxSizing:"border-box"},children:"▶"}),o.jsx("span",{style:{position:"absolute",left:6,bottom:5,maxWidth:t-12,font:"500 8.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-2)",background:"rgba(255,255,255,.88)",padding:"1.5px 5px",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",boxSizing:"border-box"},children:e.name})]})}function qW({a:e}){if(e.type==="image"||e.type==="video")return o.jsx(HW,{a:e,width:150,height:98});const t=y3(e.type),n=j3(e.name),{openDoc:r}=Wd(),i=Bd(e.name,e.mimeType),s=i?()=>r({kind:i,name:e.name,path:e.path,mimeType:e.mimeType}):void 0;return o.jsxs("div",{role:s?"button":void 0,title:s?e.name:void 0,onClick:s,style:{display:"flex",alignItems:"center",gap:9,background:"var(--proto-gray)",borderRadius:10,padding:"8px 12px 8px 9px",cursor:s?"pointer":"default"},children:[o.jsx("span",{style:{width:26,height:32,borderRadius:5,background:t.bg,color:t.fg,display:"flex",alignItems:"center",justifyContent:"center",font:"700 8px 'IBM Plex Mono',monospace",flex:"none"},children:n}),o.jsxs("span",{style:{display:"flex",flexDirection:"column",gap:2},children:[o.jsx("span",{style:{font:"500 11px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:e.name}),o.jsxs("span",{style:{font:"400 9px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:[b3(e.size)," · ",e.path]})]})]})}function VW(e){const t=e.lastIndexOf("/");return t>=0?e.slice(0,t+1):e}function KW({title:e,onClick:t,children:n}){return o.jsx("span",{role:"button",title:e,onClick:t,style:{width:26,height:26,borderRadius:7,border:"1px solid var(--proto-line)",background:"var(--proto-rail)",color:"var(--proto-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,cursor:"pointer",flex:"none"},children:n})}function QW({onClick:e,children:t}){return o.jsxs("span",{role:"button",onClick:e,style:{height:26,borderRadius:7,border:"1px solid var(--proto-accent-border)",background:"var(--proto-rail)",color:"var(--proto-accent)",display:"flex",alignItems:"center",justifyContent:"center",font:`500 9.5px ${bs}`,padding:"0 9px",cursor:"pointer",flex:"none"},children:[t," ↗"]})}function GW({a:e}){const t=B(),n=Il(),{openDoc:r}=Wd(),i=y3(e.type),s=j3(e.name),a=Bd(e.name,e.mimeType),l=a?()=>r({kind:a,name:e.name,path:e.path,mimeType:e.mimeType}):void 0;return o.jsxs("div",{role:l?"button":void 0,onClick:l,style:{display:"flex",alignItems:"center",gap:10,border:"1px solid var(--proto-line)",background:"var(--proto-card)",borderRadius:10,padding:"9px 10px",boxShadow:"0 1px 2px rgba(16,24,40,.03)",boxSizing:"border-box",maxWidth:"100%",cursor:l?"pointer":"default"},children:[o.jsx("span",{style:{width:28,height:34,borderRadius:5,background:i.bg,color:i.fg,display:"flex",alignItems:"center",justifyContent:"center",font:`700 8px ${bs}`,flex:"none"},children:s}),o.jsxs("span",{style:{display:"flex",flexDirection:"column",gap:2,minWidth:0,flex:1},children:[o.jsx("span",{style:{font:`500 11.5px ${bs}`,color:"var(--proto-ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),o.jsxs("span",{style:{font:`400 9px ${bs}`,color:"var(--proto-muted-3)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[b3(e.size)," · ",VW(e.path)]})]}),o.jsxs("span",{style:{display:"flex",gap:5,flex:"none"},onClick:c=>c.stopPropagation(),children:[o.jsx(KW,{title:t.wbFileDownload,onClick:()=>n(e.path,e.name),children:"↓"}),l&&o.jsx(QW,{onClick:l,children:t.wbFileOpen})]})]})}function YW({a:e}){const t=B(),n=Il(),r=Ls(e.type),{openMedia:i}=zd(),s=Q0(e.path),[a,l]=f.useState(!1);return o.jsxs("div",{role:"button",title:e.name,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onClick:()=>i({kind:r,name:e.name,path:e.path}),style:{position:"relative",maxWidth:320,borderRadius:12,border:"1px solid var(--proto-line)",overflow:"hidden",boxSizing:"border-box",cursor:"pointer",background:s?"#000":"repeating-linear-gradient(45deg,var(--proto-line),var(--proto-line) 5px,var(--proto-line) 5px,var(--proto-line) 10px)"},children:[s&&r==="image"&&o.jsx("img",{src:s,alt:e.name,style:{display:"block",maxWidth:320,maxHeight:240,width:"auto",height:"auto"}}),s&&r==="video"&&o.jsx(Ud,{src:s,style:{display:"block",maxWidth:320,maxHeight:240,width:"auto",height:"auto"}}),!s&&o.jsx("div",{style:{width:320,height:180}}),r==="video"&&o.jsx("span",{style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%)",width:40,height:40,borderRadius:"50%",background:"rgba(25,28,34,.72)",color:"var(--ink-solid-fg)",fontSize:14,display:"flex",alignItems:"center",justifyContent:"center",paddingLeft:3,boxSizing:"border-box"},children:"▶"}),o.jsx("span",{style:{position:"absolute",left:8,bottom:7,font:`500 8.5px ${bs}`,color:"var(--proto-muted-2)",background:"rgba(255,255,255,.88)",padding:"1.5px 5px",borderRadius:4},children:e.name}),a&&o.jsx("span",{role:"button",title:t.wbFileDownload,onClick:c=>{c.stopPropagation(),n(e.path,e.name)},style:{position:"absolute",top:7,right:7,width:24,height:24,borderRadius:7,background:"rgba(25,28,34,.78)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,cursor:"pointer"},children:"↓"})]})}function XW({attachments:e}){const t=B(),n=Il(),r=e.filter(s=>Ls(s.type)!==null),i=e.filter(s=>Ls(s.type)===null);return o.jsxs("div",{style:{maxWidth:"75%",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:6,marginTop:10},children:[r.length>0&&o.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:r.map((s,a)=>o.jsx(YW,{a:s},`media-${a}`))}),i.map((s,a)=>o.jsx(GW,{a:s},`file-${a}`)),e.length>=3&&o.jsxs("div",{style:{font:`400 9.5px ${bs}`,color:"var(--proto-faint)",padding:"2px 2px 0"},children:[e.length," ",t.wbFileFiles," ·"," ",o.jsxs("span",{style:{color:"var(--proto-muted-2)",cursor:"pointer"},onClick:()=>e.forEach(s=>n(s.path,s.name)),children:[t.wbFileDownloadAll," ↓"]})]})]})}function JW({text:e,attachments:t,ts:n,edited:r,editCopy:i,onStartEdit:s,editDisabled:a,pending:l,debug:c}){const d=t&&t.length>0,[u,p]=f.useState(null),h=x3(n);return o.jsxs("div",{className:"group",style:{position:"relative",alignSelf:"flex-end",maxWidth:"75%",display:"flex",flexDirection:"column",alignItems:"flex-end",gap:6,animation:"cxmsg .34s cubic-bezier(.22,1,.36,1) both"},children:[(h||i&&(e||c))&&o.jsxs("div",{className:"pointer-events-none opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 focus-within:pointer-events-auto focus-within:opacity-100",style:{position:"absolute",right:"100%",top:"50%",transform:"translateY(-50%)",paddingRight:8,display:"flex",alignItems:"center",gap:8},children:[h&&o.jsx("span",{style:{font:`400 10px ${bs}`,color:"var(--proto-faint)",whiteSpace:"nowrap",flex:"none"},children:h}),i&&(e||c)&&o.jsx($W,{text:e,copy:i,showCopy:!!e,onEdit:e?s:void 0,editDisabled:a,extraAction:c?o.jsx(L6,{className:"!h-[26px] !min-w-[26px] !border-0 !bg-transparent !px-0 !shadow-none",onClick:g=>{g.stopPropagation(),p({kind:"user",agentMessage:c.agentMessage})}}):void 0})]}),d&&o.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",justifyContent:"flex-end"},children:t.map((g,v)=>o.jsx(qW,{a:g},v))}),e&&o.jsx("div",{style:{position:"relative",display:"flex",justifyContent:"flex-end",maxWidth:"100%"},children:o.jsx("div",{style:{background:"var(--proto-gray)",borderRadius:"14px 14px 4px 14px",padding:"9px 14px",fontSize:13.5,lineHeight:1.55,color:l?"var(--proto-muted)":"var(--proto-ink)",whiteSpace:"pre-wrap",overflowWrap:"break-word",wordBreak:"break-word",minWidth:0},children:e})}),o.jsx(O6,{detail:u,onClose:()=>p(null)}),i&&r&&o.jsx(BW,{edited:r,ts:n,copy:i})]})}function ZW({text:e,attachments:t,editCopy:n,regen:r,preview:i,streamKey:s}){const a=!!t&&t.length>0,l=v3(e,!!i,s);return o.jsxs("div",{style:{position:"relative",animation:"cxmsg .34s cubic-bezier(.22,1,.36,1) both",fontSize:14,lineHeight:1.65,color:"var(--proto-ink-2)",minWidth:0,overflowWrap:"break-word",wordBreak:"break-word"},children:[n&&r&&o.jsx("div",{style:{marginBottom:4},children:o.jsx(WW,{copy:n})}),l.trim()&&o.jsx(Ai,{text:l}),a&&o.jsx(XW,{attachments:t})]})}function eU(){const e=B();return o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:13,padding:"88px 20px 40px",textAlign:"center"},children:[o.jsx("div",{"aria-label":"Cortex",style:{width:40,height:40,borderRadius:12,background:"var(--brand-badge-bg)",border:"1px solid var(--brand-badge-border)",display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsxs("svg",{width:28,height:28,viewBox:"0 0 64 64",fill:"none","aria-hidden":"true",children:[o.jsx("circle",{cx:33,cy:32,r:5,fill:"var(--brand-badge-core)"}),o.jsx("path",{d:"M42.29 23.64A12.5 12.5 0 1 0 42.29 40.36",stroke:"var(--brand-badge-arc)",strokeWidth:5,strokeLinecap:"round"}),o.jsx("path",{d:"M48.6 17.95A21 21 0 1 0 48.6 46.05",stroke:"var(--brand-badge-arc)",strokeWidth:5,strokeLinecap:"round"})]})}),o.jsx("div",{style:{fontSize:15,fontWeight:650,color:"var(--proto-ink)"},children:e.wbEmptyTitle}),o.jsx("div",{style:{fontSize:12,color:"var(--proto-muted-2)",lineHeight:1.7,maxWidth:420},children:e.wbEmptyBody}),o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",lineHeight:1.7,maxWidth:430},children:e.wbEmptyHint})]})}function tU({tone:e,label:t,text:n}){const r=e==="rejected"?"var(--proto-danger)":e==="inactive"?"var(--proto-muted-3)":"var(--proto-success)",i=e==="rejected"?"✗":e==="inactive"?"◌":"✓";return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:10,opacity:e==="inactive"?.6:.85},children:[o.jsxs("span",{style:{fontSize:10,fontWeight:700,color:r,flexShrink:0},children:[i," ",t]}),o.jsx("span",{style:{fontSize:12,color:"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n})]})}function nU({row:e,actions:t}){const n=ft(),r=n==="zh"?Yj.zh:Yj.en,[i,s]=f.useState(nW),[a,l]=f.useState(!1),[c,d]=f.useState(!1),u=n3(e);if(u.kind==="ask"){const p=u.model;return o.jsx(fW,{model:p,state:i,copy:r,onState:s,onSubmit:h=>t==null?void 0:t.answerQuestion(p.requestId,h),busy:!!(t!=null&&t.busy)})}if(u.kind==="plan"){const p=u.model;return o.jsxs(o.Fragment,{children:[o.jsx(hW,{model:p,copy:r,feedbackOpen:a,onFeedbackOpen:l,onApprove:()=>t==null?void 0:t.approvePlan(p.requestId),onReject:h=>{t==null||t.rejectPlan(p.requestId,h),l(!1)},onOpenRead:()=>d(!0),busy:!!(t!=null&&t.busy)}),c&&o.jsx(gW,{model:p,copy:r,lang:n,onClose:()=>d(!1),onApprove:()=>{t==null||t.approvePlan(p.requestId),d(!1)},onRequestChanges:()=>{d(!1),l(!0)}})]})}return o.jsx(tU,{tone:u.tone,label:u.label,text:u.text})}function Sg({row:e,interactionActions:t,editCopy:n,onStartEdit:r,editDisabled:i,regen:s,streamKey:a}){switch(e.kind){case"divider":return o.jsx(UW,{text:e.text});case"user":return o.jsx(JW,{text:e.text,attachments:e.attachments,ts:e.ts,edited:e.edited,editCopy:n,onStartEdit:r,editDisabled:i,pending:e.pending,debug:e.debug});case"tools":return o.jsx(yB,{calls:e.calls.map(l=>({label:l.kind,kind:l.kind,input:l.input,...l.debug?{debug:l.debug}:{}}))});case"assistant":return o.jsx(ZW,{text:e.text,attachments:e.attachments,editCopy:n,regen:s,preview:e.preview,streamKey:a});case"notice":return o.jsx(i3,{level:e.level,text:e.text,authAction:e.authAction,noticeAction:e.noticeAction,onNoticeAction:t==null?void 0:t.cancelResume,noticeActionDone:t==null?void 0:t.resumeCancelled});case"interaction":return o.jsx(nU,{row:e,actions:t});default:return null}}function w3({rows:e,interactionActions:t,edit:n,streamKey:r}){const s=ft()==="zh"?tw.zh:tw.en,[a,l]=f.useState(null),c=h3(e),d=a!=null?e[a]:null,u=!!n&&!!d&&d.kind==="user"&&d.turnIndex!==void 0,p=u?f3(e,a):null,h=(g,v)=>g.kind==="interaction"&&g.detail?`int-${g.detail.id}`:v;if(u){const g=d,v=e.slice(0,a),x=e.slice(a+1);return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[v.map((w,b)=>o.jsx(Sg,{row:w,interactionActions:t,streamKey:r},h(w,b))),o.jsx(_W,{initialText:g.text,copy:s,busy:n.busy,onCancel:()=>l(null),onSubmit:w=>{n.onSubmit(g.turnIndex,w),l(null)}}),p&&o.jsx(FW,{replies:p.replies,toolCalls:p.toolCalls,copy:s}),x.length>0&&o.jsx(zW,{copy:s,children:x.map((w,b)=>o.jsx(Sg,{row:w,interactionActions:t,streamKey:r},h(w,a+1+b)))})]})}return o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:16},children:e.map((g,v)=>o.jsx(Sg,{row:g,interactionActions:t,editCopy:s,regen:c.has(v),onStartEdit:n&&g.kind==="user"&&g.turnIndex!==void 0?()=>l(v):void 0,editDisabled:(n==null?void 0:n.running)||(n==null?void 0:n.busy),streamKey:r},h(g,v)))})}function rU({rows:e,loading:t,inlineThreadCard:n,interactionActions:r,edit:i,streamKey:s}){const a=e.length>0,l=f.useRef(null),c=f.useRef(null),d=f.useRef(!0),u=()=>{const p=l.current;if(!p)return;const h=p.scrollHeight-p.scrollTop-p.clientHeight;d.current=h<40};return f.useEffect(()=>{const p=l.current;p&&d.current&&(p.scrollTop=p.scrollHeight)},[e,t]),f.useEffect(()=>{const p=l.current,h=c.current;if(!p||!h||typeof ResizeObserver>"u")return;const g=new ResizeObserver(()=>{d.current&&(p.scrollTop=p.scrollHeight)});return g.observe(h),()=>g.disconnect()},[]),o.jsx("div",{ref:l,onScroll:u,style:{flex:1,overflow:"auto",minHeight:0},children:o.jsxs("div",{ref:c,style:{width:"100%",maxWidth:756,margin:"0 auto",padding:"22px 32px 12px"},children:[!a&&!t&&o.jsx(eU,{}),o.jsx(w3,{rows:e,interactionActions:r,edit:i,streamKey:s}),n&&o.jsx("div",{style:{marginTop:16},children:n})]})})}const k3=["session.message","session.message.delivered","session.status","session.turn","session.context-usage","session.context-compacted","session.interaction","session.rewound","session.debug.updated"],oU=["session.message.delta"],ey=["thread.created","thread.step.started","thread.step.finished","thread.completed","thread.failed"],ty=["task.claimed","task.completed","task.blocked","task.dispatched"],iU=[...ty,"thread.created"],S3=["system.notice"],sU=["config.changed"],C3=["rate-limit.changed"],aU=[...k3,...ey,...ty,...S3,...sU,...C3];function lU(e){return e.type!=="config.changed"||!e.payload||typeof e.payload!="object"?!1:e.payload.section==="profiles"}function cU(e){const t=e.payload;if(!t||typeof t!="object")return null;const n=t.sessionId;return typeof n=="string"&&n?n:null}function dU(e,t,n){if(!t.includes(e.type))return!1;const r=n==null?void 0:n.sessionId;if(!r)return!0;const i=cU(e);return i===null||i===r}function uU(e,t){let n=0;for(const r of e)if(dU(t,r.types,r.scope)){n++;try{r.fn(t)}catch{}}return n}function pU(){return{hasConnected:!1,epoch:0,down:!1}}function ow(e,t){return t!=="pending"?e.hasConnected&&!e.down?{...e,down:!0}:e:e.hasConnected?e.down?{hasConnected:!0,epoch:e.epoch+1,down:!1}:e:{hasConnected:!0,epoch:e.epoch,down:!1}}const ny=f.createContext({register:()=>()=>{},connState:"connecting",hasConnected:!1,reconnectEpoch:0});function T3({children:e}){const t=Rf(),n=ae(),r=je(),[i]=f.useState(()=>n.config.get.queryFilter({})),s=f.useRef(new Set),[a,l]=f.useState(()=>({state:"connecting",accum:pU()}));f.useEffect(()=>{const u=t.subscribe.subscribe({events:[...aU]},{onConnectionStateChange:p=>{const h=p.state;l(g=>({state:h,accum:ow(g.accum,h)}))},onData:p=>{const h=p;!h||typeof h.type!="string"||(lU(h)&&r.invalidateQueries(i),uU([...s.current],h))},onError:()=>{l(p=>({state:"idle",accum:ow(p.accum,"idle")}))}});return()=>u.unsubscribe()},[t,i,r]);const c=f.useCallback(u=>(s.current.add(u),()=>{s.current.delete(u)}),[]),d=f.useMemo(()=>({register:c,connState:a.state,hasConnected:a.accum.hasConnected,reconnectEpoch:a.accum.epoch}),[c,a]);return o.jsx(ny.Provider,{value:d,children:e})}function Ni(e,t,n){const{register:r}=f.useContext(ny),i=f.useRef(t);i.current=t;const s=e.join(","),a=n==null?void 0:n.sessionId;f.useEffect(()=>r({types:s.split(","),scope:a?{sessionId:a}:void 0,fn:l=>i.current(l)}),[r,s,a])}function ry(){const{connState:e,hasConnected:t,reconnectEpoch:n}=f.useContext(ny);return{connState:e,hasConnected:t,reconnectEpoch:n}}function fU(e,t){return e??t??null}function iw(e){if(!e||typeof e!="object")return null;const t=e,n=sw(t.usedTokens),r=t.contextWindow,i=sw(t.percent),s=t.accuracy,a=t.updatedAt;return t.usedTokens!==null&&n===null||typeof r!="number"||!Number.isFinite(r)||r<=0||t.percent!==null&&i===null||s!=="exact"&&s!=="estimate"||typeof a!="string"?null:{usedTokens:n,contextWindow:r,percent:i,accuracy:s,updatedAt:a}}function E3(e){const t=(e==null?void 0:e.usedTokens)??null,n=(e==null?void 0:e.contextWindow)??null,r=(e==null?void 0:e.percent)??null;return{compact:`${aw(t)} / ${aw(n)}`,current:lw(t),maximum:lw(n),percentLabel:r===null?"—":`${fp(r)}%`,progress:r===null?null:Math.min(100,Math.max(0,r)),estimated:(e==null?void 0:e.accuracy)==="estimate"}}function sw(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:null}function aw(e){return e===null?"—":e>=1e6?`${fp(e/1e6)}m`:e>=1e3?`${fp(e/1e3)}k`:fp(e)}function lw(e){return e===null?"—":Math.round(e).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}function fp(e){return Number(e.toFixed(1)).toString()}function hU(e,t,n){const r=Rf(),i=f.useRef(n);i.current=n,f.useEffect(()=>{if(!t||!e)return;const s=r.subscribe.subscribe({events:[...oU],sessionId:e},{onData:a=>{const l=a;!l||l.type!=="session.message.delta"||!l.payload||i.current(l.payload)},onError:()=>{}});return()=>s.unsubscribe()},[r,e,t])}const Au=60,gU=2500;function sh(e,t,n,r={}){var N;const i=ae(),s=je(),[a,l]=f.useState([]),c=f.useRef([]),d=f.useCallback(F=>{const H=typeof F=="function"?F(c.current):F;c.current=H,l(H)},[]),[u,p]=f.useState(!1),[h,g]=f.useState(null),[v,x]=f.useState(null),[w,b]=f.useState(null),[y,j]=f.useState(null),[S,k]=f.useState(Xj),[E,C]=f.useState([]),R=f.useRef(null),P=f.useRef([]),L=f.useRef(new Set),_=f.useCallback(F=>{P.current=F,C(F)},[]),U=f.useCallback(()=>({liveTail:c.current,pendingUser:P.current}),[]);f.useEffect(()=>(d([]),p(!1),g(null),x(null),b(null),j(null),k(Xj()),L.current.clear(),_([]),()=>{R.current&&clearTimeout(R.current)}),[e,d,_]);const K=r.transcript;f.useEffect(()=>{if(!K||K.sessionId!==e)return;if(K.pendingUserMessages!==void 0){const H=new Set(K.pendingUserMessages.map(re=>re.id));for(const re of L.current)H.has(re)||L.current.delete(re)}const F=bW(P.current,K,L.current);F!==P.current&&_(F)},[e,K,_]),hU(e,!!r.deltas,F=>{k(H=>vW(H,F))});const{reconnectEpoch:$}=ry();f.useEffect(()=>{$===0||!e||(s.invalidateQueries(i.sessions.list.queryFilter()),s.invalidateQueries(i.sessions.transcript.queryFilter({sessionId:e})))},[$,e,s,i]),Ni(k3,F=>{if(!e)return;if(F.type==="session.status"){const D=F.payload,Q=!!(D!=null&&D.running);g(Q),x(Q&&!!(D!=null&&D.backgroundRunning)),Q?b(null):(p(!1),k(ne=>kg(ne,void 0)),R.current&&clearTimeout(R.current)),s.invalidateQueries(i.sessions.list.queryFilter());return}if(F.type==="session.context-usage"){const D=iw(F.payload);D&&j(D);return}if(F.type==="session.context-compacted"){const D=F.payload,Q=(D==null?void 0:D.contextUsage)===null?null:iw(D==null?void 0:D.contextUsage);j(Q),s.invalidateQueries(i.sessions.list.queryFilter());return}if(F.type==="session.rewound"){d([]),k(D=>kg(D,void 0)),_([]),s.invalidateQueries(i.sessions.transcript.queryFilter({sessionId:e})),s.invalidateQueries(i.sessions.list.queryFilter());return}if(F.type==="session.debug.updated"){s.invalidateQueries(i.sessions.transcript.queryFilter({sessionId:e}));return}if(F.type==="session.interaction"){s.invalidateQueries(i.sessions.transcript.queryFilter({sessionId:e})),s.invalidateQueries(i.sessions.pendingInteraction.queryFilter());return}if(F.type==="session.message.delivered"){const D=F.payload;if(!D)return;D.pendingId&&L.current.add(D.pendingId);const{pending:Q,committed:ne}=yW(P.current,{...D,sessionId:e});ne&&(_(Q),d(J=>{const te=[...J,ne];return te.length>Au?te.slice(te.length-Au):te})),s.invalidateQueries(i.sessions.transcript.queryFilter({sessionId:e}));return}if(F.type==="session.turn"){const D=F.payload;typeof(D==null?void 0:D.numTurns)=="number"&&b(D.numTurns);return}const H=F.payload;if(!H||H.role!=="user"&&H.role!=="assistant"&&H.role!=="tool")return;if(H.role==="user"&&H.pending){const D={id:H.pendingId,ts:H.ts??new Date().toISOString(),text:H.text??"",attachments:H.attachments};(D.id?P.current.some(ne=>ne.id===D.id):P.current.some(ne=>ne.ts===D.ts))||_([...P.current,D]),s.invalidateQueries(i.sessions.transcript.queryFilter({sessionId:e}));return}const re={sessionId:H.sessionId??e,role:H.role,text:H.text??"",toolName:H.toolName,toolInput:H.toolInput,noticeLevel:H.noticeLevel,noticeAction:H.noticeAction,authAction:H.authAction,ts:H.ts??new Date().toISOString(),blockId:H.blockId,attachments:H.attachments};H.role==="assistant"&&!H.noticeLevel&&k(D=>kg(D,H.blockId)),d(D=>{const Q=[...D,re];return Q.length>Au?Q.slice(Q.length-Au):Q}),H.noticeLevel||(p(!0),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>p(!1),gU)),s.invalidateQueries(i.sessions.transcript.queryFilter({sessionId:e}))},{sessionId:e});const W=kW(h,t,u),V=SW(v,n),Z=fU(y,r.contextUsage);return{liveTail:a,getMessageSnapshot:U,streaming:u,running:W,backgroundRunning:V,liveTurns:w,contextUsage:Z,streamingText:((N=S.active)==null?void 0:N.text)??null,pendingUser:E}}const xU={sessionId:"",turns:[]};function R3({sessionId:e,live:t}){const n=ae(),r=B(),i=G({...n.sessions.transcript.queryOptions({sessionId:e??""}),enabled:!!e}),{liveTail:s,streaming:a}=sh(t&&e?e:""),l=i.data??xU,c=f.useMemo(()=>Z0(l,t?s:[],{streaming:t&&a,formatDivider:g3(r)}),[l,s,a,t,r]),d={fontSize:11.5,color:"var(--proto-muted-3)",padding:"2px 0"};return e?i.isPending?o.jsx("div",{style:d,children:r.thStepLoading}):c.length===0?o.jsx("div",{style:d,children:r.thStepEmpty}):o.jsx("div",{style:{maxHeight:460,overflow:"auto",fontSize:13.5},children:o.jsx(w3,{rows:c})}):o.jsx("div",{style:d,children:r.thStepNoSession})}function P3({children:e}){return o.jsx("span",{style:{fontSize:10,fontWeight:700,letterSpacing:".07em",color:"var(--proto-muted-3)"},children:e})}function I3({kind:e}){return e==="done"?o.jsx("span",{style:{width:15,height:15,borderRadius:"50%",background:"var(--proto-success-bg)",color:"var(--proto-success)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:8.5,fontWeight:700,flex:"none"},children:"✓"}):e==="running"?o.jsx("span",{style:{width:15,height:15,borderRadius:"50%",background:"var(--proto-accent)",boxShadow:"0 0 0 3px var(--proto-accent-bg)",animation:"cxpulse 1.6s ease-in-out infinite",flex:"none"}}):o.jsx("span",{style:{width:15,height:15,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}})}function mU({step:e,onClick:t}){const[n,r]=f.useState(!1),i=e.kind==="pending";return o.jsx("div",{onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onClick:t,"data-step-kind":e.kind,style:{background:"var(--proto-card)",border:i?"1px dashed var(--proto-line-3)":"1px solid "+(n?"var(--proto-accent-border)":"var(--proto-line)"),borderRadius:10,padding:"9px 13px",boxShadow:"0 1px 2px rgba(16,24,40,.03)",cursor:"pointer"},children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx(I3,{kind:e.kind}),o.jsx("span",{style:{fontSize:12.5,fontWeight:600,color:i?"var(--proto-faint)":"var(--proto-muted)",flex:"none"},children:e.title}),o.jsx("span",{style:{fontSize:10.5,color:"var(--proto-muted-3)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.note}),o.jsx("span",{style:{marginLeft:"auto",font:"400 10px 'IBM Plex Mono',monospace",color:i?"var(--proto-line-3)":"var(--proto-faint)",flex:"none"},children:e.meta}),o.jsx("span",{style:{color:"var(--proto-line-3)",fontSize:9,flex:"none"},children:"▸"})]})})}function vU({sub:e,onOpen:t}){const n=B(),r=e.pill.text==="Running";return o.jsxs("div",{"data-sub-thread-id":e.id,style:{border:"1px solid "+(r?"var(--proto-accent-bg)":"var(--proto-line-2)"),background:"var(--proto-rail)",borderRadius:8,padding:"8px 11px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[o.jsx("span",{style:{font:"600 11px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:e.name}),o.jsx("span",{style:{font:"400 9px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},children:e.level}),o.jsx("span",{style:{marginLeft:"auto",fontSize:9.5,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:e.pill.bg,color:e.pill.fg},children:e.pill.text})]}),(e.hasLine||e.drillable)&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:10,color:"var(--proto-muted)",marginTop:5},children:[e.hasLine&&e.line,e.drillable&&o.jsxs("span",{"data-drill-thread-id":e.id,onClick:t,style:{marginLeft:"auto",fontSize:10,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:[n.thOpenSub," ›"]})]})]})}function yU({step:e,onCollapse:t,onOpenSub:n,renderChat:r}){const i=B(),s=e.kind==="running",a=e.agent,l=e.profile??(a==null?void 0:a.profile),c=(a==null?void 0:a.execInfo)||e.sessionName||"";return o.jsxs("div",{"data-active-step":s?"true":void 0,"data-expanded-step":"true",style:{background:"var(--proto-card)",border:s?"1.5px solid var(--proto-accent)":"1.5px solid var(--proto-accent-border)",borderRadius:10,boxShadow:s?"0 0 0 3px var(--proto-accent-bg)":"0 1px 2px rgba(16,24,40,.04)",overflow:"hidden"},children:[o.jsxs("div",{onClick:t,style:{display:"flex",alignItems:"center",gap:8,padding:"10px 13px",cursor:"pointer"},children:[o.jsx(I3,{kind:e.kind}),o.jsx("span",{style:{fontSize:12.5,fontWeight:650,color:"var(--proto-ink)"},children:e.title}),l&&o.jsxs("span",{style:{font:"500 9px 'IBM Plex Mono',monospace",border:"1px solid var(--proto-line)",color:"var(--proto-muted-2)",padding:"1px 6px",borderRadius:5},children:[i.thAgentLabel,": ",l]}),c&&o.jsx("span",{style:{font:"400 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:c}),o.jsx("span",{style:{marginLeft:"auto",font:"400 10px 'IBM Plex Mono',monospace",color:s?"var(--proto-accent)":"var(--proto-faint)"},children:e.meta}),o.jsx("span",{style:{color:"var(--proto-faint)",fontSize:9,flex:"none",transform:"rotate(90deg)"},children:"▸"})]}),o.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"10px 13px 12px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[o.jsx(P3,{children:i.thAgentSection}),s&&(a==null?void 0:a.live)&&o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",animation:"cxpulse 1.6s ease-in-out infinite"}})]}),r(e.sessionId,s)]}),e.subCount>0&&o.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"10px 13px 12px"},children:[o.jsxs("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".07em",color:"var(--proto-muted-3)",marginBottom:7},children:[i.thSubThreads," · ",e.subCount]}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:7},children:e.subs.map(d=>o.jsx(vU,{sub:d,onOpen:()=>n(d)},d.id))})]})]})}function bU({step:e,index:t,selected:n,select:r,onOpenSub:i,renderChat:s}){return o.jsxs("div",{children:[e.hasConnector&&o.jsx("div",{style:{width:1.5,height:12,background:"var(--proto-line)",marginLeft:20}}),n?o.jsx(yU,{step:e,onCollapse:()=>r(-1),onOpenSub:i,renderChat:s}):o.jsx(mU,{step:e,onClick:()=>r(t)})]})}function jU({vm:e,onOpenSub:t,renderStepChat:n}){const r=B(),i=n??((u,p)=>o.jsx(R3,{sessionId:u,live:p})),s=e.steps.findIndex(u=>u.kind==="running"),a=s>=0?s:e.steps.length-1,[l,c]=f.useState(null),d=l??a;return o.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column"},"data-pipeline":"true",children:[o.jsx("div",{style:{display:"flex",alignItems:"baseline",padding:"0 2px 8px"},children:o.jsx(P3,{children:r.thPipeline})}),e.steps.map((u,p)=>o.jsx(bU,{step:u,index:p,selected:p===d,select:c,onOpenSub:t,renderChat:i},p))]})}const wU=o.jsxs("svg",{width:"11",height:"13",viewBox:"0 0 11 13",fill:"none",stroke:"var(--proto-muted-2)",strokeWidth:"1.4",children:[o.jsx("path",{d:"M1 1.5h6l3 3v7H1z"}),o.jsx("path",{d:"M7 1.5v3h3"})]});function kU({label:e,value:t}){return o.jsxs("div",{style:{display:"flex",gap:8},children:[o.jsx("span",{style:{flex:"none"},children:e}),o.jsx("span",{style:{marginLeft:"auto",color:"var(--proto-ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t})]})}function SU({artifact:e}){const t=B();return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px",borderBottom:"1px solid var(--proto-line-2)",flex:"none"},children:[wU,o.jsx("span",{style:{minWidth:0,font:"600 11px 'IBM Plex Mono',monospace",color:"var(--proto-ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.path??"—"}),e.live&&o.jsx(CU,{label:t.thLive}),o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",flex:"none"},children:e.updated})]})}function CU({label:e}){return o.jsxs("span",{style:{fontSize:9.5,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:"var(--proto-accent-bg)",color:"var(--proto-accent)",flex:"none",whiteSpace:"nowrap"},children:[o.jsx("span",{style:{display:"inline-block",width:5,height:5,borderRadius:"50%",background:"var(--proto-accent)",marginRight:4,animation:"cxpulse 1.6s ease-in-out infinite"}}),e]})}function TU({artifact:e}){const t=B(),n=[e.workspacePath?{label:t.thWorkspace,value:e.workspacePath}:null,e.taskId?{label:t.thTask,value:e.taskId}:null,e.taskProject?{label:t.thProject,value:e.taskProject}:null].filter(r=>r!==null);return o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{fontSize:9,fontWeight:700,letterSpacing:".06em",color:"var(--proto-faint)"},children:t.thReferences}),n.length>0?o.jsx("div",{style:{font:"400 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",lineHeight:1.9,marginTop:3},children:n.map(r=>o.jsx(kU,{...r},r.label))}):o.jsx("div",{style:{fontSize:11.5,color:"var(--proto-muted-2)",marginTop:3},children:"—"})]})}function EU({artifact:e}){var r;const t=B(),n=((r=e.path)==null?void 0:r.split("/").pop())??t.thNoArtifact;return o.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"13px 16px"},children:[o.jsx("div",{style:{fontSize:14,fontWeight:650,color:"var(--proto-ink)",letterSpacing:"-.01em"},children:n}),o.jsxs("div",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-2)",marginTop:4},children:[t.thOwner,": ",e.taskId??"—"]}),o.jsx("div",{style:{height:1,background:"var(--proto-line-2)",margin:"10px 0"}}),o.jsx(TU,{artifact:e}),o.jsx("div",{"data-artifact-content":"true",style:{marginTop:12,color:"var(--proto-ink)",fontSize:12.5,lineHeight:1.6,overflowWrap:"anywhere"},children:e.content?o.jsx(Ai,{text:e.content}):o.jsx("span",{style:{color:"var(--proto-muted-2)"},children:"—"})})]})}function RU({artifact:e}){const t=B();return e.writtenBy.length===0?null:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:"none",borderTop:"1px solid var(--proto-line-2)",padding:"8px 14px",flexWrap:"wrap"},children:[o.jsx("span",{style:{fontSize:9,fontWeight:700,letterSpacing:".06em",color:"var(--proto-faint)",marginRight:2},children:t.thWrittenBy}),e.writtenBy.map((n,r)=>o.jsx(PU,{writer:n},r))]})}function PU({writer:e}){return o.jsxs("span",{style:{font:`${e.active?500:400} 9.5px 'IBM Plex Mono',monospace`,background:e.active?"var(--proto-accent-bg)":"var(--proto-rail)",border:`1px solid ${e.active?"var(--proto-accent-bg)":"var(--proto-line-2)"}`,color:e.active?"var(--proto-accent)":"var(--proto-muted-2)",padding:"2px 7px",borderRadius:5},children:[e.label,e.active&&" ●"]})}function IU({artifact:e}){const t=B();return o.jsxs("div",{style:{width:440,flex:"none",display:"flex",flexDirection:"column",minHeight:0},children:[o.jsx("div",{style:{display:"flex",alignItems:"baseline",padding:"0 2px 8px"},children:o.jsx("span",{style:{fontSize:10,fontWeight:700,letterSpacing:".07em",color:"var(--proto-muted-3)"},children:t.thArtifact})}),o.jsxs("div",{"data-thread-artifact":"true",style:{flex:1,minHeight:0,background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"0 1px 2px rgba(16,24,40,.03)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsx(SU,{artifact:e}),o.jsx(EU,{artifact:e}),o.jsx(RU,{artifact:e})]})]})}function MU({vm:e}){return o.jsx("span",{style:{fontSize:10.5,fontWeight:600,padding:"2px 8px",borderRadius:999,background:e.pill.bg,color:e.pill.fg},children:e.pill.text})}function LU({onCancel:e,pending:t}){const n=B();return o.jsxs(o.Fragment,{children:[o.jsx("span",{title:"Pause has no backend mutate op yet",style:{fontSize:11.5,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:7,padding:"4px 12px",color:"var(--proto-ink)",background:"var(--proto-card)",cursor:"not-allowed",opacity:.6},children:n.pause}),o.jsx("button",{type:"button",disabled:t,onClick:e,style:{fontSize:11.5,fontWeight:600,fontFamily:"inherit",border:"1px solid var(--proto-danger-bg)",borderRadius:7,padding:"4px 12px",color:"var(--proto-danger)",background:"var(--proto-card)",cursor:t?"default":"pointer",opacity:t?.6:1},children:n.cancel})]})}function OU({vm:e,onClose:t,onCancel:n,cancelPending:r}){return o.jsxs("div",{style:{height:50,flex:"none",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:9,padding:"0 20px",background:"var(--proto-card)"},children:[o.jsx("span",{style:{font:"600 12.5px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:e.name}),o.jsx("span",{style:{font:"400 10.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:e.tid}),o.jsx(MU,{vm:e}),o.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:8},children:[e.live&&o.jsx(LU,{onCancel:n,pending:r}),o.jsx("button",{"data-close-thread-detail":"true",type:"button","aria-label":"Close",onClick:t,style:{border:0,background:"transparent",color:"var(--proto-muted)",cursor:"pointer",fontSize:18,lineHeight:1,padding:4},children:"×"})]})]})}function Xl({label:e,value:t,accent:n}){return o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:9.5,color:"var(--proto-muted-3)",marginBottom:2},children:e}),o.jsx("div",{style:{font:"600 12px 'IBM Plex Mono',monospace",color:n?"var(--proto-accent)":"var(--proto-ink)"},children:t})]})}function DU({vm:e}){const t=B();return o.jsxs("div",{style:{marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:3},children:[o.jsx("span",{style:{font:"500 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",marginRight:3},children:t.depth}),e.depthDots.map((n,r)=>o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:n.filled?"var(--proto-accent)":"var(--proto-line)"}},r)),o.jsx("span",{style:{font:"500 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",marginLeft:3},children:e.depthText})]})}function AU({vm:e}){const t=B();return o.jsxs("div",{style:{flex:"none",background:"var(--proto-card)",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:32,padding:"12px 20px 14px"},children:[o.jsx(Xl,{label:t.thTemplate,value:e.template}),o.jsx(Xl,{label:t.thStarted,value:e.started}),o.jsx(Xl,{label:t.thElapsed,value:e.elapsed,accent:!0}),o.jsx(Xl,{label:t.thCostInclChildren,value:e.cost}),o.jsx(Xl,{label:t.thTask,value:e.task,accent:e.task!=="—"}),o.jsx(DU,{vm:e})]})}function NU({vm:e,onOpenThread:t,renderStepChat:n}){const r=i=>t(i.id);return o.jsxs("div",{style:{flex:1,display:"flex",gap:16,padding:"16px 20px",minHeight:0,background:"var(--proto-alt)",overflow:"auto"},children:[o.jsx(jU,{vm:e,onOpenSub:r,renderStepChat:n}),o.jsx(IU,{artifact:e.artifact})]})}function $U(e){const t=Xz(e.detail,e.now);return o.jsxs("div",{"data-thread-detail":t.tid,style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",minHeight:0},children:[o.jsx(OU,{vm:t,onClose:e.onClose,onCancel:e.onCancel,cancelPending:!!e.cancelPending}),o.jsx(AU,{vm:t}),o.jsx(NU,{vm:t,onOpenThread:e.onOpenThread,renderStepChat:e.renderStepChat})]})}const _U=[...ey,...ty];function Ml(e,t=!1){const n=ae(),r=je(),i=t?{threadId:e,includeArtifactContent:!0}:{threadId:e};Ni(_U,()=>{r.invalidateQueries(n.threads.get.queryFilter(i))})}function FU(e,t){return t.type==="open"?t.threadId:null}const M3=f.createContext({openThread:()=>{},closeThread:()=>{}});function zU(e){const[t,n]=f.useState(()=>Date.now());return f.useEffect(()=>{if(!e)return;const r=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(r)},[e]),t}function cw({children:e,failed:t}){return o.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:24,color:t?"var(--proto-danger)":"var(--proto-muted-3)",fontSize:12.5},children:e})}const BU={position:"fixed",inset:0,zIndex:70,background:"rgba(25,28,34,.4)",animation:"cxfade .18s ease"},WU={position:"fixed",left:"50%",top:"50%",zIndex:71,transform:"translate(-50%,-50%)",width:"min(1200px,94vw)",height:"min(90vh,900px)",display:"flex",flexDirection:"column",overflow:"hidden",borderRadius:14,border:"1px solid var(--proto-line)",background:"var(--proto-alt)",boxShadow:"0 24px 64px rgba(16,24,40,.3)",outline:"none",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)"};function UU({threadId:e,onClose:t,children:n}){return o.jsx(Co,{open:!0,onOpenChange:r=>{r||t()},children:o.jsxs(To,{children:[o.jsx(Eo,{style:BU}),o.jsxs(Ro,{"aria-describedby":void 0,"data-thread-detail-modal":e,style:WU,children:[o.jsxs(Oi,{className:"sr-only",children:["Thread ",e]}),n]})]})})}function HU({detail:e,loading:t,error:n,now:r,onClose:i,onOpenThread:s,onCancel:a,cancelPending:l}){const c=B();return t?o.jsx(cw,{children:c.rpLoadingThread}):n?o.jsxs(cw,{failed:!0,children:[c.thFailedLoadThread,": ",n]}):e?o.jsx($U,{detail:e,now:r,onClose:i,onOpenThread:s,onCancel:a,cancelPending:l}):null}function qU({threadId:e,onClose:t,onOpenThread:n}){var d;const r=ae(),i=je(),s=G(r.threads.get.queryOptions({threadId:e,includeArtifactContent:!0}));Ml(e,!0);const a=s.data?["running","waiting"].includes(s.data.status):!1,l=zU(a),c=ue(r.threads.cancel.mutationOptions({onSettled:()=>{i.invalidateQueries(r.threads.list.queryFilter()),i.invalidateQueries(r.threads.get.queryFilter({threadId:e,includeArtifactContent:!0}))},onSuccess:t}));return o.jsx(UU,{threadId:e,onClose:t,children:o.jsx(HU,{detail:s.data,loading:s.isPending,error:((d=s.error)==null?void 0:d.message)??null,now:l,onClose:t,onOpenThread:n,onCancel:()=>c.mutate({threadId:e}),cancelPending:c.isPending})})}function VU({children:e}){const[t,n]=f.useReducer(FU,null),r=s=>n({type:"open",threadId:s}),i=()=>n({type:"close"});return o.jsxs(M3.Provider,{value:{openThread:r,closeThread:i},children:[e,t&&o.jsx(qU,{threadId:t,onClose:i,onOpenThread:r})]})}function oy(){return f.useContext(M3)}function iy(...e){return e.filter(t=>typeof t=="string"&&t.length>0)}function KU(e){return{id:`session:${e.sessionId}`,glyph:"SE",label:e.name||e.sessionId,sub:e.projectId,kbd:"session",route:"/workbench",focusId:e.sessionId,keywords:iy(e.sessionId,e.name,e.label,e.projectId,e.backend,e.kind)}}function QU(e){return{id:`thread:${e.id}`,glyph:"TH",label:e.templateName,sub:e.id,kbd:"thread",modal:"thread",focusId:e.id,keywords:iy(e.id,e.templateName,e.status,e.projectId)}}function GU(e){return{id:`task:${e.id}`,glyph:"TK",label:e.text,sub:`${e.id} · ${e.project}`,kbd:"task",route:"/tasks",focusId:e.id,keywords:iy(e.id,e.text,e.project,e.status,e.priority)}}function YU({sessions:e,threads:t,tasks:n}){return[...e.map(KU),...t.map(QU),...n.map(GU)]}const XU=[{id:"nav:overview",glyph:"OV",label:"Overview",labelKey:"overview",sub:"project dashboard",subKey:"cpSubOverview",kbd:"page",route:"/overview",keywords:["dashboard"]},{id:"nav:workbench",glyph:"WB",label:"Workbench",labelKey:"workbench",sub:"session chat",subKey:"cpSubWorkbench",kbd:"page",route:"/workbench",keywords:["home","chat"]},{id:"nav:tasks",glyph:"TK",label:"Tasks",labelKey:"tasks",sub:"task queue",subKey:"cpSubTasks",kbd:"page",route:"/tasks",keywords:["queue"]},{id:"nav:threads",glyph:"TH",label:"Threads",labelKey:"threads",sub:"thread runs",subKey:"cpSubThreads",kbd:"page",route:"/threads",keywords:["runs"]},{id:"nav:settings",glyph:"ST",label:"Settings",labelKey:"settings",sub:"platform · profiles · budget · machines…",subKey:"cpSubSettings",kbd:"modal",modal:"settings",keywords:["config"]}];function JU(e){return{id:e.id,glyph:e.glyph,label:e.label,sub:e.sub,kbd:e.kbd,...e.route?{route:e.route}:{},...e.modal?{modal:e.modal}:{},keywords:e.keywords,labelKey:e.labelKey,subKey:e.subKey}}function ZU(e,t,n={}){const r=n.restPerKind??5,i=n.matchCap??50,s=XU.map(JU),a=YU(t),l=e.trim().toLowerCase();if(!l){const d=u=>a.filter(p=>p.glyph===u).slice(0,r);return[...s,...d("SE"),...d("TH"),...d("TK")]}const c=d=>(d.label+" "+d.sub+" "+d.keywords.join(" ")).toLowerCase().includes(l);return[...s,...a].filter(c).slice(0,i)}const eH={display:"flex",alignItems:"center",gap:10,padding:"12px 16px",borderBottom:"1px solid var(--proto-line-2)"},tH={flex:1,fontSize:13.5,color:"var(--proto-ink)",fontFamily:"inherit"},nH={font:"500 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},rH={padding:6,maxHeight:384,overflowY:"auto"},oH={display:"flex",alignItems:"center",gap:10,padding:"8px 11px",borderRadius:8,cursor:"pointer"},iH={width:20,height:20,borderRadius:6,background:"var(--proto-gray)",display:"flex",alignItems:"center",justifyContent:"center",font:"600 9px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",flex:"none"},sH={fontSize:10.5,color:"var(--proto-muted-3)",whiteSpace:"nowrap",flex:"none"},aH={marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",flex:"none",paddingLeft:10},lH={display:"flex",alignItems:"center",padding:"7px 16px",borderTop:"1px solid var(--proto-alt)",background:"var(--proto-rail)"},cH={font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},dH={padding:"18px 11px",textAlign:"center",fontSize:12.5,color:"var(--proto-muted-3)"};function uH({row:e,onSelect:t}){const n=B(),r=e.labelKey?n[e.labelKey]:e.label,i=e.subKey?n[e.subKey]:e.sub;return o.jsxs(od.Item,{value:e.id,onSelect:t,className:"cmdk-row",style:oH,children:[o.jsx("span",{style:iH,children:e.glyph}),o.jsx("span",{className:"cmdk-row-label",children:r}),o.jsx("span",{style:sH,children:i}),o.jsx("span",{style:aH,children:e.kbd})]})}const Cg=3e4;function pH(e,t){const n=ae(),r=G(n.sessions.list.queryOptions({},{enabled:e,staleTime:Cg})),i=G(n.threads.list.queryOptions({},{enabled:e,staleTime:Cg})),s=G(n.tasks.list.queryOptions({},{enabled:e,staleTime:Cg}));return f.useMemo(()=>ZU(t,{sessions:r.data??[],threads:i.data??[],tasks:s.data??[]}),[t,r.data,i.data,s.data])}function fH(e){const t=Be(),{open:n}=I6(),{openThread:r}=oy();return i=>{if(e(!1),i.modal==="settings")return n();if(i.modal==="thread"&&i.focusId)return r(i.focusId);i.route&&t(i.route,i.focusId?{state:{focusId:i.focusId}}:void 0)}}function hH({query:e,setQuery:t,close:n}){const r=B();return o.jsxs("div",{style:eH,children:[o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 12 12",fill:"none",stroke:"var(--proto-muted-3)",strokeWidth:"1.5",children:[o.jsx("circle",{cx:"5",cy:"5",r:"3.8"}),o.jsx("path",{d:"M8 8l2.6 2.6"})]}),o.jsx(od.Input,{autoFocus:!0,value:e,onValueChange:t,placeholder:r.cmdkPh,style:tH}),o.jsx("span",{style:nH,onClick:n,children:"esc"})]})}function gH({rows:e,go:t}){const n=B();return o.jsxs(od.List,{style:rH,children:[o.jsx(od.Empty,{style:dH,children:n.cpNoResults}),e.map(r=>o.jsx(uH,{row:r,onSelect:()=>t(r)},r.id))]})}function xH({open:e,onOpenChange:t}){const n=B(),[r,i]=f.useState("");f.useEffect(()=>{e&&i("")},[e]);const s=pH(e,r),a=fH(t);return o.jsxs(od.Dialog,{open:e,onOpenChange:t,label:"Command palette",shouldFilter:!1,loop:!0,overlayClassName:"cmdk-backdrop",contentClassName:"cmdk-panel",children:[o.jsx(hH,{query:r,setQuery:i,close:()=>t(!1)}),o.jsx(gH,{rows:s,go:a}),o.jsx("div",{style:lH,children:o.jsx("span",{style:cH,children:n.cpFooterHint})})]})}function mH(){const[e,t]=f.useState(!1);return f.useEffect(()=>{function n(r){r.key.toLowerCase()==="k"&&(r.metaKey||r.ctrlKey)&&(r.preventDefault(),t(i=>!i))}return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[]),{open:e,setOpen:t}}const vH={flex:"none",display:"flex",alignItems:"center",gap:9,padding:"13px 18px",borderBottom:"1px solid #2A2F3A"},yH={fontSize:9,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:"#2A2F3A",color:"var(--proto-accent-2)"},bH={flex:1,overflow:"auto",minHeight:0,padding:"13px 18px",font:"400 10.5px/2 'IBM Plex Mono',monospace"},jH={flex:"none",display:"flex",alignItems:"center",gap:10,padding:"11px 18px",borderTop:"1px solid #2A2F3A"};function wH({title:e,pill:t,meta:n,now:r,lines:i,dropped:s,notice:a,killDisabled:l,onKill:c,onClose:d,scrollRef:u,onScroll:p}){const h=B();return o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:vH,children:[o.jsx("span",{style:{font:"600 12px 'IBM Plex Mono',monospace",color:"var(--proto-line)"},children:e}),t?o.jsx("span",{style:yH,children:t}):null,o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted)"},children:n}),o.jsx("span",{onClick:d,"aria-label":"Close",role:"button",tabIndex:0,style:{color:"var(--proto-muted-2)",fontSize:13,cursor:"pointer",padding:"2px 4px"},children:"✕"})]}),o.jsxs("div",{ref:u,onScroll:p,"data-execution-log":!0,style:bH,children:[a?o.jsx("div",{style:{color:"var(--proto-muted)"},children:a}):null,s>0?o.jsxs("div",{style:{color:"var(--proto-amber)"},children:["… ",s," ",h.exLinesDropped]}):null,i.map((g,v)=>o.jsx("div",{style:{color:"var(--proto-accent-bg)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:g},v)),o.jsx("div",{children:o.jsx("span",{style:{color:"var(--proto-muted)"},children:r})})]}),o.jsxs("div",{style:jH,children:[o.jsx("span",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted)"},children:h.exFooterHeartbeat}),o.jsx("button",{type:"button",onClick:c,disabled:l,"data-action":"kill-run",style:{marginLeft:"auto",fontSize:11,fontWeight:600,color:"#E88",border:"1px solid var(--proto-danger)",borderRadius:7,padding:"4px 12px",cursor:l?"default":"pointer",background:"transparent"},children:h.exKillRun})]})]})}const dw={lines:[],dropped:0,lastSeq:null};function kH(e,t,n){if(e.lastSeq!==null&&t.seq<=e.lastSeq)return e;let r=e.dropped+(t.dropped??0),i=t.lines.length>0?[...e.lines,...t.lines]:e.lines;return i.length>n&&(r+=i.length-n,i=i.slice(i.length-n)),{lines:i,dropped:r,lastSeq:t.seq}}const SH=2e3;function CH(e,t){const n=Rf(),[r,i]=f.useState(dw);return f.useEffect(()=>{if(!t)return;i(dw);const s=n.executions.log.subscribe({executionId:e},{onData:a=>{const l=a.payload;if(!l||!Array.isArray(l.lines))return;const c={lines:l.lines,seq:typeof l.seq=="number"?l.seq:0,dropped:typeof l.dropped=="number"?l.dropped:void 0};i(d=>kH(d,c,SH))}});return()=>s.unsubscribe()},[n,e,t]),r}const Ec=e=>e<10?`0${e}`:`${e}`;function TH(e){switch(e){case"running":return"● running";case"completed":return"✓ done";case"failed":return"✕ failed";case"cancelled":return"✕ cancelled";case"stale":return"◦ stale";default:return e}}function EH(e){if(!e)return"";const t=new Date(e);return`${Ec(t.getUTCHours())}:${Ec(t.getUTCMinutes())}`}function RH(e){const t=e.runtime.endedAt??e.runtime.updatedAt,n=new Date(t);return`${Ec(n.getUTCHours())}:${Ec(n.getUTCMinutes())}:${Ec(n.getUTCSeconds())}`}function PH(e){var r,i;const t=e.runtime.endedAt;return[((r=e.dispatch)==null?void 0:r.machine)??null,((i=e.dispatch)==null?void 0:i.taskId)??null,t?`finished ${EH(t)}`:"running"].filter(s=>s!=null&&s!=="").join(" · ")}function IH(e){return e==="running"}function MH(e){var t;return((t=e.dispatch)==null?void 0:t.runName)!=null}const LH={position:"fixed",top:0,right:0,bottom:0,width:480,background:"var(--proto-ink)",zIndex:61,display:"flex",flexDirection:"column",boxShadow:"-16px 0 48px rgba(16,24,40,.3)"},OH={position:"fixed",inset:0,background:"rgba(25,28,34,.34)",zIndex:60},DH={position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0};function AH({executionId:e,onClose:t}){const n=B(),r=e!=null;return o.jsx(Co,{open:r,onOpenChange:i=>{i||t()},children:o.jsxs(To,{children:[o.jsx(Eo,{style:OH,className:"animate-cxfade motion-reduce:animate-none"}),o.jsxs(Ro,{"aria-describedby":void 0,style:LH,className:"animate-cxdrawer focus:outline-none motion-reduce:animate-none",children:[o.jsx(Oi,{style:DH,children:e?`${n.exLogTitle} ${e}`:n.exLogTitle}),r?o.jsx(NH,{executionId:e,onClose:t}):null]})]})})}function NH({executionId:e,onClose:t}){const n=ae(),r=B(),i=je(),{toast:s}=Tn(),l=G(n.executions.get.queryOptions({executionId:e},{refetchInterval:b=>{var y;return((y=b.state.data)==null?void 0:y.status)==="running"?3e3:!1}})).data,c=l?MH(l):!1,d=CH(e,c),u=ue(n.executions.cancel.mutationOptions({onSettled:()=>i.invalidateQueries(n.executions.get.queryFilter({executionId:e}))})),p=()=>{if(!l||!IH(l.status)){s({title:`${e} ${r.exAlreadyFinished}`,tone:"cancelled"});return}u.mutate({executionId:e},{onSuccess:b=>{b.cancelled&&s({title:`${e} ${r.exKilled}`,tone:"failed"})}})},h=f.useRef(null),g=f.useRef(!0);f.useEffect(()=>{const b=h.current;b&&g.current&&(b.scrollTop=b.scrollHeight)},[d.lines,d.dropped]);const v=()=>{const b=h.current;b&&(g.current=b.scrollHeight-b.scrollTop-b.clientHeight<24)},x=(l==null?void 0:l.status)==="running",w=d.lines.length>0?null:c?x?r.exWaitingOutput:r.exNoLogOutput:x?r.exWaitingOutput:r.exNoLiveLog;return o.jsx(wH,{title:(l==null?void 0:l.id)??e,pill:l?TH(l.status):null,meta:l?PH(l):"",now:l?RH(l):"",lines:d.lines,dropped:d.dropped,notice:w,killDisabled:u.isPending,onKill:p,onClose:t,scrollRef:h,onScroll:v})}const L3=f.createContext(null);function $H({children:e}){const[t,n]=f.useState(null),r=f.useCallback(a=>n(a),[]),i=f.useCallback(()=>n(null),[]),s=f.useMemo(()=>({open:r,close:i}),[r,i]);return o.jsxs(L3.Provider,{value:s,children:[e,o.jsx(AH,{executionId:t,onClose:i})]})}function O3(){const e=f.useContext(L3);if(!e)throw new Error("useExecutionLogDrawer must be used within an ExecutionLogDrawerProvider");return e}const uw=["interval","daily","weekly","once"],pw=["min","hr"],_H=["fresh","skip","wait"],FH=["current-channel","fresh","project"],zH=[{value:0,label:"Sun"},{value:1,label:"Mon"},{value:2,label:"Tue"},{value:3,label:"Wed"},{value:4,label:"Thu"},{value:5,label:"Fri"},{value:6,label:"Sat"}];function BH(e,t){const n=[];for(const r of e??[])n.includes(r)||n.push(r);return t&&!n.includes(t)&&n.push(t),n}function D3(e){return{type:"daily",message:"",profile:"claude-haiku",time:"09:00",dayOfWeek:1,intervalValue:30,intervalUnit:"min",delayValue:10,delayUnit:"min",target:"current-channel",fallback:"fresh",projectId:e}}function WH(e){return{time:e==="daily"||e==="weekly",interval:e==="interval",dayOfWeek:e==="weekly",delay:e==="once"}}function ld(e,t){return t==="hr"?e*36e5:e*6e4}const UH=/^\d{2}:\d{2}$/;function HH(e,t){if(e==="fresh")return{kind:"fresh"};if(e==="project")return{kind:"project",projectId:t??"general"}}function qH(e){const t={type:e.type,message:e.message.trim(),fallback:e.fallback};e.projectId&&(t.projectId=e.projectId),e.profile&&(t.profile=e.profile),e.type==="interval"&&(t.intervalMs=ld(e.intervalValue,e.intervalUnit)),(e.type==="daily"||e.type==="weekly")&&(t.time=e.time),e.type==="weekly"&&(t.dayOfWeek=e.dayOfWeek),e.type==="once"&&(t.delay=ld(e.delayValue,e.delayUnit));const n=HH(e.target,e.projectId);return n&&(t.target=n),t}function VH(e){var i,s;const t=D3(e.projectId||null),n=e.intervalMs??0,r=n>0&&n%36e5===0;return{...t,type:e.type,message:e.message,profile:e.profile??"",time:e.time??t.time,dayOfWeek:e.dayOfWeek??t.dayOfWeek,intervalValue:n>0?r?n/36e5:Math.round(n/6e4):t.intervalValue,intervalUnit:r?"hr":"min",target:((i=e.target)==null?void 0:i.kind)==="fresh"?"fresh":((s=e.target)==null?void 0:s.kind)==="project"?"project":"current-channel",fallback:e.fallback??"fresh"}}function KH(e,t){const n={scheduleId:e,message:t.message.trim()};return t.profile&&(n.profile=t.profile),t.projectId&&(n.projectId=t.projectId),t.type==="interval"&&(n.intervalMs=ld(t.intervalValue,t.intervalUnit)),(t.type==="daily"||t.type==="weekly")&&(n.time=t.time),t.type==="weekly"&&(n.dayOfWeek=t.dayOfWeek),n}function fw(e){const t=[];return e.message.trim().length===0&&t.push("message is required"),e.type==="interval"&&!(e.intervalValue>0)&&t.push("interval must be > 0"),(e.type==="daily"||e.type==="weekly")&&!UH.test(e.time)&&t.push("time must be HH:MM"),e.type==="weekly"&&!(e.dayOfWeek>=0&&e.dayOfWeek<=6)&&t.push("dayOfWeek must be 0..6"),e.type==="once"&&!(e.delayValue>0)&&t.push("delay must be > 0"),{ok:t.length===0,errors:t}}function QH(e,t){if(e.type==="interval")return new Date(t.getTime()+ld(e.intervalValue,e.intervalUnit));if(e.type==="once")return new Date(t.getTime()+ld(e.delayValue,e.delayUnit));const[n,r]=e.time.split(":").map(a=>parseInt(a,10)),i=new Date(t);if(i.setHours(n,r,0,0),e.type==="daily")return i.getTime()<=t.getTime()&&i.setDate(i.getDate()+1),i;let s=(e.dayOfWeek-t.getDay()+7)%7;return s===0&&i.getTime()<=t.getTime()&&(s=7),i.setDate(i.getDate()+s),i}function hw(e){return String(e).padStart(2,"0")}function sy(e){const t=Math.max(0,Math.round(e/6e4));if(t<60)return`${t}m`;const n=Math.floor(t/60),r=t%60;return n<24?r===0?`${n}h`:`${n}h ${r}m`:`${Math.floor(n/24)}d`}function GH(e,t){const n=QH(e,t);return{clock:`${hw(n.getHours())}:${hw(n.getMinutes())}`,delta:sy(n.getTime()-t.getTime())}}const Xr={fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)"},Gi={display:"flex",alignItems:"center",border:"1px solid var(--proto-line)",borderRadius:8,padding:"7px 10px"},Js={marginLeft:"auto",color:"var(--proto-muted-3)",fontSize:8};function Zs(e){return{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",appearance:"none",WebkitAppearance:"none",MozAppearance:"none",cursor:"pointer",font:e,color:"var(--proto-ink)"}}function YH({form:e,mode:t="create",onChange:n,onCancel:r,onCreate:i,valid:s,pending:a,profileOptions:l,now:c}){const d=B();f.useEffect(()=>{const y=j=>{j.key==="Escape"&&r()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[r]);const u={interval:d.scTypeInterval,daily:d.scTypeDaily,weekly:d.scTypeWeekly,once:d.scTypeOnce},p={0:d.scDaySun,1:d.scDayMon,2:d.scDayTue,3:d.scDayWed,4:d.scDayThu,5:d.scDayFri,6:d.scDaySat},h=WH(e.type),{clock:g,delta:v}=GH(e,c??new Date),x=s&&!a,w=t==="edit",b=h.dayOfWeek?"130px 130px 1fr":"130px 1fr";return o.jsxs(o.Fragment,{children:[o.jsx("div",{onClick:r,style:{position:"fixed",inset:0,background:"rgba(25,28,34,.34)",zIndex:60,animation:"cxfade .18s ease"}}),o.jsxs("div",{"data-schedule-modal":!0,"data-sched-type":e.type,style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)",width:560,background:"var(--proto-card)",borderRadius:14,boxShadow:"0 24px 64px rgba(16,24,40,.3)",zIndex:61,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"14px 20px 0"},children:[o.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--proto-ink)"},children:w?d.scEditSchedule:d.scNewSchedule}),o.jsx("span",{onClick:r,style:{marginLeft:"auto",font:"500 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),o.jsxs("div",{style:{padding:"0 20px"},children:[o.jsx("div",{style:{...Xr,margin:"13px 0 5px"},children:d.scType}),o.jsx("div",{style:{display:"flex",border:"1px solid var(--proto-line)",borderRadius:8,overflow:"hidden"},children:uw.map((y,j)=>{const S=e.type===y;return o.jsx("span",{"data-sched-type-opt":y,"aria-pressed":S,onClick:w?void 0:()=>n({type:y}),style:{flex:1,textAlign:"center",padding:"6px 0",fontSize:11.5,fontWeight:600,color:S?"var(--proto-accent)":"var(--proto-muted-2)",background:S?"var(--proto-accent-bg)":void 0,borderRight:j<uw.length-1?"1px solid var(--proto-line)":void 0,cursor:w?"default":"pointer",opacity:w&&!S?.45:1},children:u[y]},y)})}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:b,gap:12,marginTop:12},children:[o.jsxs("div",{children:[h.time&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{...Xr,marginBottom:5},children:d.scTime}),o.jsxs("div",{style:Gi,children:[o.jsx("input",{value:e.time,onChange:y=>n({time:y.target.value}),placeholder:"09:00",style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",font:"600 12px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"}}),o.jsx("span",{style:{marginLeft:"auto",font:"400 9px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},children:"24h"})]})]}),h.interval&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{...Xr,marginBottom:5},children:d.scEvery}),o.jsxs("div",{style:Gi,children:[o.jsx("input",{type:"number",min:1,value:e.intervalValue,onChange:y=>n({intervalValue:Number(y.target.value)}),style:{width:44,border:"none",outline:"none",background:"transparent",font:"600 12px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"}}),o.jsx("select",{value:e.intervalUnit,onChange:y=>n({intervalUnit:y.target.value}),style:Zs("400 10px 'IBM Plex Mono',monospace"),children:pw.map(y=>o.jsx("option",{value:y,children:y},y))}),o.jsx("span",{style:Js,children:"▾"})]})]}),h.delay&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{...Xr,marginBottom:5},children:d.scIn}),o.jsxs("div",{style:Gi,children:[o.jsx("input",{type:"number",min:1,value:e.delayValue,onChange:y=>n({delayValue:Number(y.target.value)}),style:{width:44,border:"none",outline:"none",background:"transparent",font:"600 12px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"}}),o.jsx("select",{value:e.delayUnit,onChange:y=>n({delayUnit:y.target.value}),style:Zs("400 10px 'IBM Plex Mono',monospace"),children:pw.map(y=>o.jsx("option",{value:y,children:y},y))}),o.jsx("span",{style:Js,children:"▾"})]})]})]}),h.dayOfWeek&&o.jsxs("div",{children:[o.jsx("div",{style:{...Xr,marginBottom:5},children:d.scDay}),o.jsxs("div",{style:Gi,children:[o.jsx("select",{value:e.dayOfWeek,onChange:y=>n({dayOfWeek:Number(y.target.value)}),style:Zs("500 11.5px 'IBM Plex Mono',monospace"),children:zH.map(y=>o.jsx("option",{value:y.value,children:p[y.value]??y.label},y.value))}),o.jsx("span",{style:Js,children:"▾"})]})]}),o.jsxs("div",{children:[o.jsx("div",{style:{...Xr,marginBottom:5},children:d.scProfile}),o.jsxs("div",{style:Gi,children:[o.jsx("select",{value:e.profile,onChange:y=>n({profile:y.target.value}),style:Zs("500 11.5px 'IBM Plex Mono',monospace"),children:l.map(y=>o.jsx("option",{value:y,children:y},y))}),o.jsx("span",{style:Js,children:"▾"})]})]})]}),o.jsx("div",{style:{...Xr,margin:"12px 0 5px"},children:d.scMessage}),o.jsx("div",{style:{border:"1px solid var(--proto-line)",borderRadius:8,padding:"8px 11px",minHeight:38},children:o.jsx("textarea",{value:e.message,onChange:y=>n({message:y.target.value}),placeholder:d.scMessagePh,rows:2,style:{width:"100%",border:"none",outline:"none",resize:"none",background:"transparent",fontSize:11.5,lineHeight:1.55,color:"var(--proto-ink-2)",fontFamily:"inherit"}})}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,marginTop:12,opacity:w?.55:1},children:[o.jsxs("div",{children:[o.jsx("div",{style:{...Xr,marginBottom:5},children:d.scTarget}),o.jsxs("div",{style:Gi,children:[o.jsx("select",{value:e.target,disabled:w,onChange:y=>n({target:y.target.value}),style:Zs("11.5px system-ui, sans-serif"),children:FH.map(y=>o.jsx("option",{value:y,children:y},y))}),o.jsx("span",{style:Js,children:"▾"})]})]}),o.jsxs("div",{children:[o.jsx("div",{style:{...Xr,marginBottom:5},children:d.scFallback}),o.jsxs("div",{style:Gi,children:[o.jsx("select",{value:e.fallback,disabled:w,onChange:y=>n({fallback:y.target.value}),style:Zs("11.5px system-ui, sans-serif"),children:_H.map(y=>o.jsx("option",{value:y,children:y},y))}),o.jsx("span",{style:Js,children:"▾"})]})]})]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"16px 20px 16px"},children:[o.jsxs("span",{style:{font:"500 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted)"},children:[d.scNextRun," ",o.jsx("b",{style:{color:"var(--proto-accent)"},children:g})," · ",d.scFooterIn," ",v]}),o.jsx("span",{onClick:r,style:{marginLeft:"auto",fontSize:11.5,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"6px 13px",color:"var(--proto-ink)",cursor:"pointer"},children:d.cancel}),o.jsx("span",{"data-action":"create-schedule",onClick:()=>x&&i(),style:{fontSize:11.5,fontWeight:600,borderRadius:8,padding:"7px 15px",color:"var(--ink-solid-fg)",background:"var(--proto-accent)",cursor:x?"pointer":"not-allowed",opacity:x?1:.55},children:w?d.scSaveSchedule:d.scCreateSchedule})]})]})]})}const A3=f.createContext(null);function XH({children:e}){var j,S;const t=B(),n=ae(),r=je(),{toast:i}=Tn(),[s,a]=f.useState(null),[l,c]=f.useState(null),u=(S=(j=G(n.config.get.queryOptions({})).data)==null?void 0:j.profiles)==null?void 0:S.profiles.map(k=>k.name),p=f.useCallback(()=>{a(null),c(null)},[]),h=f.useCallback(k=>{c(null),a(D3((k==null?void 0:k.projectId)??null))},[]),g=f.useCallback(k=>{c(k.id),a(VH(k))},[]),v=ue(n.schedules.add.mutationOptions({onSuccess:()=>{r.invalidateQueries(n.schedules.list.queryFilter()),i({title:t.scToastCreated,tone:"done"}),p()},onError:k=>{i({title:t.scToastCreateFailed,description:k.message,tone:"failed"})}})),x=ue(n.schedules.update.mutationOptions({onSuccess:()=>{r.invalidateQueries(n.schedules.list.queryFilter()),i({title:t.scToastUpdated,tone:"done"}),p()},onError:k=>{i({title:t.scToastUpdateFailed,description:k.message,tone:"failed"})}})),w=f.useCallback(k=>{a(E=>E&&{...E,...k})},[]),b=f.useCallback(()=>{a(k=>(k&&fw(k).ok&&(l?x.mutate(KH(l,k)):v.mutate(qH(k))),k))},[v,x,l]),y=f.useMemo(()=>({open:h,openEdit:g,close:p}),[h,g,p]);return o.jsxs(A3.Provider,{value:y,children:[e,s&&o.jsx(YH,{form:s,mode:l?"edit":"create",onChange:w,onCancel:p,onCreate:b,valid:fw(s).ok,pending:v.isPending||x.isPending,profileOptions:BH(u,s.profile)})]})}function N3(){const e=f.useContext(A3);if(!e)throw new Error("useScheduleModal must be used within a ScheduleModalProvider");return e}const Tg="—";function JH(e){switch(e){case"pending":return{text:"● pending",bg:"#F7ECCE",fg:"#8A5B06"};case"approved":return{text:"✓ approved",bg:"#E9F4EE",fg:"#23854F"};case"rejected":return{text:"✕ rejected",bg:"#FBEDEB",fg:"#C03D33"};case"failed":return{text:"failed",bg:"#FBEDEB",fg:"#C03D33"}}}function ZH(e){return`${e} ${e===1?"approval pending":"approvals pending"}`}function eq(e){return{id:e.id,title:e.title,age:e.queuedAt,origin:e.provenance,project:e.projectId}}function tq(e){const t=e.command;return{id:e.id,title:e.title,project:e.projectId,pill:JH(e.status),queued:e.queuedAt?`queued ${e.queuedAt}`:null,operation:e.operation??Tg,reason:e.reason??Tg,impact:e.impact??Tg,command:t,hasCommand:t!=null&&t.trim()!=="",feedback:e.feedback,origin:e.provenance,task:e.taskRef}}function nq(e,t){var n;return t&&e.some(r=>r.id===t)?t:((n=e[0])==null?void 0:n.id)??null}const yi="'IBM Plex Mono',monospace";function rq(e){const t=B(),{entries:n,selectedId:r,armed:i,feedback:s,pending:a}=e,l=n.length,c=l>0,d=n.find(p=>p.id===r)??n[0]??null,u=d?tq(d):null;return o.jsxs(o.Fragment,{children:[o.jsx("div",{onClick:e.onClose,style:{position:"fixed",inset:0,background:"rgba(25,28,34,.34)",zIndex:60,animation:"cxfade .18s ease"}}),o.jsxs("div",{"data-approval-center":"","data-approval-selected":(d==null?void 0:d.id)??"",style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)",width:1120,maxWidth:"94vw",height:700,maxHeight:"90vh",background:"var(--proto-card)",borderRadius:14,boxShadow:"0 24px 64px rgba(16,24,40,.3)",zIndex:61,overflow:"hidden",display:"flex",flexDirection:"column"},children:[o.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",gap:9,padding:"12px 20px",borderBottom:"1px solid var(--proto-line)"},children:[o.jsx("span",{style:{fontSize:13,fontWeight:650,color:"var(--proto-ink)"},children:t.approvals}),c&&o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,background:"var(--proto-amber-bg)",border:"1px solid var(--proto-amber-border)",borderRadius:999,padding:"3px 10px",marginLeft:4},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-amber)",animation:"cxpulse 2s ease-in-out infinite"}}),o.jsx("span",{style:{fontSize:10.5,fontWeight:600,color:"var(--proto-amber-fg)"},children:ZH(l)})]}),o.jsx("span",{style:{marginLeft:"auto",font:`400 10px ${yi}`,color:"var(--proto-muted-3)"},children:"~/.cortex/context/PENDING_APPROVALS.md"}),o.jsx("span",{onClick:e.onClose,style:{font:`500 9.5px ${yi}`,color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),o.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[!c&&o.jsx(oq,{}),c&&o.jsxs(o.Fragment,{children:[o.jsx(iq,{entries:n,selectedId:(d==null?void 0:d.id)??null,count:l,onSelect:e.onSelect}),u&&o.jsx(sq,{detail:u,armed:i,feedback:s,pending:a,onArm:e.onArm,onCancel:e.onCancel,onApprove:e.onApprove,onReject:e.onReject,onFeedback:e.onFeedback})]})]})]})]})}function oq(){const e=B();return o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:9,background:"var(--proto-rail)"},children:[o.jsx("span",{style:{width:34,height:34,borderRadius:"50%",background:"var(--proto-success-bg)",color:"var(--proto-success)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:15,fontWeight:700},children:"✓"}),o.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--proto-ink)"},children:e.aprEmptyTitle}),o.jsx("div",{style:{fontSize:11,color:"var(--proto-muted-2)"},children:e.aprEmptyDesc})]})}function iq({entries:e,selectedId:t,count:n,onSelect:r}){const i=B();return o.jsxs("div",{style:{width:370,flex:"none",borderRight:"1px solid var(--proto-line)",background:"var(--proto-rail)",display:"flex",flexDirection:"column",overflow:"auto"},children:[o.jsxs("div",{style:{padding:"13px 16px 8px",fontSize:10,fontWeight:700,letterSpacing:".06em",color:"var(--proto-muted-3)"},children:[i.apPending," · ",n]}),o.jsx("div",{style:{padding:"0 12px 12px",display:"flex",flexDirection:"column",gap:8},children:e.map(s=>{const a=eq(s),l=s.id===t;return o.jsx("div",{"data-approval-id":s.id,onClick:()=>r(s.id),style:{background:"var(--proto-card)",border:`1px solid ${l?"var(--proto-accent-border)":"var(--proto-line-2)"}`,borderRadius:10,padding:"10px 12px",boxShadow:l?"0 1px 3px rgba(70,85,212,.08)":"none",cursor:"pointer"},children:o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:9},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"var(--proto-amber)",flex:"none",marginTop:5,animation:l?"cxpulse 2s ease-in-out infinite":"none"}}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:l?"var(--proto-ink)":"var(--proto-ink-2)",lineHeight:1.4},children:a.title}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,marginTop:6,flexWrap:"wrap"},children:[a.project&&o.jsx("span",{style:{font:`600 9px ${yi}`,color:"var(--proto-muted-3)"},children:a.project}),a.origin&&o.jsx("span",{style:{font:`400 9px ${yi}`,color:"var(--proto-muted-3)"},children:a.origin}),a.age&&o.jsx("span",{style:{marginLeft:"auto",font:`400 9px ${yi}`,color:"var(--proto-faint)"},children:a.age})]})]})]})},s.id)})})]})}const Eg={fontSize:10,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",paddingTop:2};function sq({detail:e,armed:t,feedback:n,pending:r,onArm:i,onCancel:s,onApprove:a,onReject:l,onFeedback:c}){const d=B();return o.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{flex:1,overflow:"auto",minHeight:0,padding:"16px 22px 0"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[o.jsx("div",{style:{fontSize:15.5,fontWeight:650,color:"var(--proto-ink)",lineHeight:1.35,flex:1},children:e.title}),o.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 9px",borderRadius:999,background:e.pill.bg,color:e.pill.fg,flex:"none",marginTop:2},children:e.pill.text})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,marginTop:8,font:`400 10px ${yi}`,color:"var(--proto-muted-3)",flexWrap:"wrap"},children:[e.queued&&o.jsx("span",{children:e.queued}),e.project&&o.jsxs("span",{children:[d.apProject," ",o.jsx("span",{style:{color:"var(--proto-accent)"},children:e.project})]}),e.origin&&o.jsxs("span",{children:[d.apFrom," ",o.jsx("span",{style:{color:"var(--proto-accent)"},children:e.origin})]}),e.task&&o.jsxs("span",{children:[d.apTask," ",o.jsx("span",{style:{color:"var(--proto-accent)"},children:e.task})]})]}),o.jsxs("div",{style:{marginTop:14,display:"grid",gridTemplateColumns:"76px 1fr",rowGap:9,columnGap:14,fontSize:12,lineHeight:1.55},children:[o.jsx("span",{style:Eg,children:d.apOperation}),o.jsx("span",{style:{color:"var(--proto-ink-2)"},children:e.operation}),o.jsx("span",{style:Eg,children:d.apReason}),o.jsx("span",{style:{color:"var(--proto-ink-2)"},children:e.reason}),o.jsx("span",{style:Eg,children:d.apImpact}),o.jsx("span",{style:{color:"var(--proto-ink-2)"},children:e.impact})]}),e.hasCommand&&o.jsxs("div",{style:{marginTop:13},children:[o.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",marginBottom:6},children:d.apCommand}),o.jsx("div",{style:{background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:8,padding:"9px 14px",font:`400 11px/1.75 ${yi}`,color:"var(--proto-muted)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e.command})]}),e.feedback&&o.jsxs("div",{style:{margin:"13px 0 14px",background:"var(--proto-danger-bg)",border:"1px solid var(--proto-danger-bg)",borderRadius:8,padding:"10px 13px",fontSize:11.5,lineHeight:1.55,color:"var(--proto-danger)"},children:[o.jsx("b",{style:{color:"var(--proto-danger)"},children:d.apFeedbackLabel})," — ",e.feedback]})]}),t&&o.jsx("div",{style:{flex:"none",padding:"0 22px 11px"},children:o.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,border:"1px solid var(--proto-danger-bg)",background:"var(--proto-card)",borderRadius:8,padding:"7px 12px"},children:o.jsx("input",{"data-approval-feedback":"",value:n,onChange:u=>c(u.target.value),placeholder:d.apFeedbackPh,style:{flex:1,fontSize:12,color:"var(--proto-ink)",fontFamily:"inherit"}})})}),o.jsxs("div",{style:{flex:"none",borderTop:"1px solid var(--proto-line-2)",padding:"12px 22px",display:"flex",alignItems:"center",gap:10},children:[o.jsx("span",{style:{font:`400 10px ${yi}`,color:"var(--proto-faint)",lineHeight:1.6},children:d.apFootNote}),!t&&o.jsxs(o.Fragment,{children:[o.jsx(Nu,{"data-action":"arm",onClick:r?void 0:()=>i(),base:{marginLeft:"auto",fontSize:12,fontWeight:600,border:"1px solid var(--proto-danger-bg)",borderRadius:8,padding:"7px 16px",color:"var(--proto-danger)",background:"var(--proto-card)",cursor:r?"not-allowed":"pointer",flex:"none",opacity:r?.6:1},hover:{background:"var(--proto-danger-bg)"},children:d.rejectFeedback}),o.jsx(Nu,{"data-action":"approve",onClick:r?void 0:()=>a(e.id),base:{fontSize:12,fontWeight:600,borderRadius:8,padding:"8px 20px",color:"var(--ink-solid-fg)",background:"var(--proto-accent)",cursor:r?"not-allowed":"pointer",flex:"none",opacity:r?.6:1},hover:{background:"var(--proto-accent-strong)"},children:d.approve})]}),t&&o.jsxs(o.Fragment,{children:[o.jsx(Nu,{"data-action":"cancel",onClick:r?void 0:()=>s(),base:{marginLeft:"auto",fontSize:12,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"7px 16px",color:"var(--proto-ink)",background:"var(--proto-card)",cursor:r?"not-allowed":"pointer",flex:"none",opacity:r?.6:1},hover:{background:"var(--proto-alt)"},children:d.cancel}),o.jsx(Nu,{"data-action":"reject",onClick:r?void 0:()=>l(e.id),base:{fontSize:12,fontWeight:600,borderRadius:8,padding:"8px 20px",color:"var(--ink-solid-fg)",background:"var(--proto-danger)",cursor:r?"not-allowed":"pointer",flex:"none",opacity:r?.6:1},hover:{opacity:.88},children:d.denyConfirm})]})]})]})}function Nu({base:e,hover:t,onClick:n,children:r,...i}){const[s,a]=f.useState(!1);return o.jsx("span",{...i,onClick:n,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:s?{...e,...t}:e,children:r})}function aq({open:e,onClose:t}){const n=B(),r=ae(),i=je(),{toast:s}=Tn(),a=G({...r.approvals.list.queryOptions({status:"pending"}),enabled:e}),l=f.useMemo(()=>a.data??[],[a.data]),[c,d]=f.useState(null),[u,p]=f.useState(!1),[h,g]=f.useState(""),v=nq(l,c),x=()=>i.invalidateQueries(r.approvals.list.queryFilter()),w=()=>{p(!1),g("")},b=ue(r.approvals.approve.mutationOptions({onSuccess:()=>s({title:n.apToastApproved,tone:"done"}),onSettled:()=>{w(),x()}})),y=ue(r.approvals.reject.mutationOptions({onSuccess:()=>s({title:n.apToastRejected,tone:"failed"}),onSettled:()=>{w(),x()}})),j=b.isPending||y.isPending;return f.useEffect(()=>{e||w()},[e]),f.useEffect(()=>{w()},[v]),f.useEffect(()=>{if(!e)return;const S=k=>{k.key==="Escape"&&t()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[e,t]),e?o.jsx(rq,{entries:l,selectedId:v,armed:u,feedback:h,pending:j,onSelect:d,onClose:t,onArm:()=>p(!0),onCancel:w,onApprove:S=>b.mutate({id:S}),onReject:S=>y.mutate({id:S,feedback:h.trim()||void 0}),onFeedback:g}):null}const $3=f.createContext(null);function lq({children:e}){const[t,n]=f.useState(!1),r=f.useCallback(()=>n(!0),[]),i=f.useCallback(()=>n(!1),[]),s=f.useMemo(()=>({open:r,close:i}),[r,i]);return o.jsxs($3.Provider,{value:s,children:[e,o.jsx(aq,{open:t,onClose:i})]})}function cq(){const e=f.useContext($3);if(!e)throw new Error("useApprovals must be used within an ApprovalsProvider");return e}function dq(e,t){var n;if(e.length){const r=[...e].sort((i,s)=>Date.parse(s.lastUsedAt||s.createdAt)-Date.parse(i.lastUsedAt||i.createdAt))[0];if(r!=null&&r.projectId)return r.projectId}return((n=t[0])==null?void 0:n.id)??null}function _3(e,t,n){return e??dq(t,n)}const F3=f.createContext(null);function uq({children:e}){const t=ae(),n=G(t.projects.list.queryOptions({})),r=G(t.sessions.list.queryOptions({origin:"direct"})),[i,s]=f.useState(null),a=_3(i,r.data??[],n.data??[]),l=f.useCallback(d=>s(d),[]),c=f.useMemo(()=>({currentProjectId:a,setCurrentProject:l}),[a,l]);return o.jsx(F3.Provider,{value:c,children:e})}function $i(){const e=f.useContext(F3);if(!e)throw new Error("useCurrentProject must be used within a CurrentProjectProvider");return e}const cd="__draft__";function pq(e){return(e.metaKey||e.ctrlKey)&&!e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="n"}function fq(e){var t;return e.length?((t=[...e].sort((n,r)=>Date.parse(r.lastUsedAt||r.createdAt)-Date.parse(n.lastUsedAt||n.createdAt))[0])==null?void 0:t.sessionId)??null:null}function hq(e,t,n=null,r=t){return e===cd?cd:n&&e===n?n:e&&t.some(i=>i.sessionId===e)?e:fq(r)}function z3(e,t,n){return e??(!n||(t==null?void 0:t.sessionId)!==n?null:t.profileName)}const gw="cortex.composerDraft.";function Hd(e){return e.isDraft?`${gw}new.${e.projectId??"general"}`:e.sessionId?`${gw}session.${e.sessionId}`:null}function B3(e){return e?e.text.trim().length===0&&e.attachments.length===0:!0}function gq(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.name=="string"&&typeof t.path=="string"&&typeof t.size=="number"&&typeof t.mimeType=="string"&&(t.type==="image"||t.type==="video"||t.type==="file")}function xq(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!="object")return null;const n=t,r=typeof n.text=="string"?n.text:"",i=Array.isArray(n.attachments)?n.attachments.filter(gq):[],s=typeof n.draftUploadId=="string"?n.draftUploadId:void 0,a={text:r,attachments:i,...s?{draftUploadId:s}:{}};return B3(a)?null:a}function mq(e){return JSON.stringify({text:e.text,attachments:e.attachments,...e.draftUploadId?{draftUploadId:e.draftUploadId}:{}})}function ay(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function dd(e){if(!e)return null;const t=ay();if(!t)return null;try{return xq(t.getItem(e))}catch{return null}}function Os(e,t){if(!e)return;const n=ay();if(n)try{if(B3(t)){n.removeItem(e);return}n.setItem(e,mq(t))}catch{}}function vq(e,t){return{text:t,attachments:(e==null?void 0:e.attachments)??[],...e!=null&&e.draftUploadId?{draftUploadId:e.draftUploadId}:{}}}function W3(e,t){const n=[t.text,e.text].filter(s=>s.length>0).join(`
|
|
129
|
+
`),r=[...t.attachments,...e.attachments].filter((s,a,l)=>l.findIndex(c=>c.path===s.path)===a),i=e.draftUploadId??t.draftUploadId;return{text:n,attachments:r,...i?{draftUploadId:i}:{}}}function U3(e,t){const n=Hd({isDraft:!0,projectId:e});Os(n,vq(dd(n),t))}function H3(e){if(!e)return;const t=ay();if(t)try{t.removeItem(e)}catch{}}const q3=f.createContext(null);function yq({children:e}){const t=ae(),{currentProjectId:n}=$i(),r=G(t.sessions.list.queryOptions({origin:"direct",projectId:n??void 0})),i=G(t.sessions.list.queryOptions({origin:"scheduled",projectId:n??void 0})),s=G(t.config.get.queryOptions({})),[a,l]=f.useState(null),[c,d]=f.useState(null),[u,p]=f.useState(0),[h,g]=f.useState(null),v=r.data??[],x=f.useMemo(()=>[...v,...i.data??[]],[v,i.data]),w=(h==null?void 0:h.sessionId)??null,b=hq(a,x,w,v),y=b===cd;f.useEffect(()=>{w&&v.some(R=>R.sessionId===w)&&g(null)},[w,v]),f.useEffect(()=>{g(null)},[n]),f.useEffect(()=>{var R;if(y&&!c&&((R=s.data)!=null&&R.profiles)){const P=s.data.profiles.defaultProfile;P&&s.data.profiles.profiles.find(L=>L.name===P)&&d(P)}},[y,c,s.data]);const j=f.useCallback(R=>{g(null),l(R)},[]),S=f.useCallback(R=>{g({sessionId:R,profileName:c}),l(R)},[c]),k=f.useCallback(R=>{U3(n??"general",R),g(null),l(cd),p(P=>P+1)},[n]),E=f.useCallback(()=>{g(null),l(null),d(null)},[]),C=f.useMemo(()=>({selectedSessionId:b,setSelectedSession:j,selectCreatedSession:S,pendingCreatedSession:h,isDraft:y,draftProfile:c,setDraftProfile:d,draftReloadToken:u,prefillDraft:k,clearDraft:E}),[b,j,S,h,y,c,u,k,E]);return o.jsx(q3.Provider,{value:C,children:e})}function _s(){const e=f.useContext(q3);if(!e)throw new Error("useSelectedSession must be used within a SelectedSessionProvider");return e}const bq=/^\s*-\s+([^::]{1,30}?)\s*[::]\s*(.*)$/;function V3(e){const t=[],n=[];let r=null;for(const i of e.split(`
|
|
130
|
+
`)){const s=i.trim();if(s==="")continue;const a=i.match(bq);if(a){r={label:a[1].trim(),text:a[2].trim()},t.push(r);continue}if(/^\s*-\s+/.test(i)){r=null,n.push(s.replace(/^-\s+/,""));continue}r?r.text+=`
|
|
131
|
+
${s}`:n.push(s)}return{fields:t,desc:n.length>0?n.join(`
|
|
132
|
+
`):null}}function jq(e){return{id:e.id,title:e.title,date:e.date}}function wq(e){const t=V3(e.body);return{id:e.id,title:e.title,date:e.date,fields:t.fields,desc:t.desc}}function kq(e,t){var n;return t&&e.some(r=>r.id===t)?t:((n=e[0])==null?void 0:n.id)??null}function K3(e,t){const n=t.date?` (${t.date})`:"";return`处理项目 ${e} 的 ISSUES.md 中登记的 issue:
|
|
133
|
+
|
|
134
|
+
**${t.title}**${n}
|
|
135
|
+
`+(t.body?`${t.body}
|
|
136
|
+
`:"")+`
|
|
137
|
+
该条目已从 ISSUES.md 移除并交由本会话处理。请调查并解决上述问题;如需持久记录结论,写入项目上下文相应文件。`}const js="'IBM Plex Mono',monospace";function Sq(e){const t=B(),{entries:n,selectedId:r,armed:i,pending:s}=e,a=n.length,l=a>0,c=n.find(u=>u.id===r)??n[0]??null,d=c?wq(c):null;return o.jsxs(o.Fragment,{children:[o.jsx("div",{onClick:e.onClose,style:{position:"fixed",inset:0,background:"rgba(25,28,34,.32)",zIndex:60,animation:"cxfade .18s ease"}}),o.jsxs("div",{"data-issue-center":"","data-issue-selected":(c==null?void 0:c.id)??"",style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)",width:1150,maxWidth:"94vw",height:730,maxHeight:"90vh",background:"var(--proto-card)",borderRadius:14,boxShadow:"0 24px 64px rgba(16,24,40,.28)",zIndex:61,overflow:"hidden",display:"flex",flexDirection:"column"},children:[o.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",gap:9,padding:"12px 20px",borderBottom:"1px solid var(--proto-line)"},children:[o.jsx("span",{style:{fontSize:13,fontWeight:650,color:"var(--proto-ink)"},children:t.issuesTitle}),l&&o.jsx("span",{style:{font:`600 10.5px ${js}`,color:"var(--proto-muted)",background:"var(--proto-line-2)",padding:"2px 9px",borderRadius:999,marginLeft:2},children:a}),o.jsx("span",{style:{marginLeft:"auto",font:`400 10px ${js}`,color:"var(--proto-muted-3)"},children:e.projectId?`${e.projectId}/ISSUES.md`:"ISSUES.md"}),o.jsx("span",{onClick:e.onClose,style:{font:`500 9.5px ${js}`,color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),o.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[!l&&o.jsx(Cq,{}),l&&o.jsxs(o.Fragment,{children:[o.jsx(Tq,{entries:n,selectedId:(c==null?void 0:c.id)??null,count:a,onSelect:e.onSelect}),d&&o.jsx(Eq,{detail:d,armed:i,pending:s,onArm:e.onArm,onCancelArm:e.onCancelArm,onDelete:e.onDelete,onHandle:e.onHandle})]})]})]})]})}function Cq(){const e=B();return o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:9,background:"var(--proto-rail)"},children:[o.jsx("span",{style:{width:34,height:34,borderRadius:"50%",background:"var(--proto-success-bg)",color:"var(--proto-success)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:15,fontWeight:700},children:"✓"}),o.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--proto-ink)"},children:e.isEmptyTitle}),o.jsx("div",{style:{fontSize:11,color:"var(--proto-muted-2)"},children:e.isEmptyDesc})]})}function Tq({entries:e,selectedId:t,count:n,onSelect:r}){const i=B();return o.jsxs("div",{style:{width:400,flex:"none",borderRight:"1px solid var(--proto-line)",background:"var(--proto-rail)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"14px 18px 9px",fontSize:10,fontWeight:700,letterSpacing:".06em",color:"var(--proto-muted-3)",flex:"none"},children:[i.isListLabel," · ",n]}),o.jsx("div",{style:{flex:1,overflow:"auto",minHeight:0,padding:"0 12px",display:"flex",flexDirection:"column",gap:8},children:e.map(s=>{const a=jq(s),l=s.id===t;return o.jsxs("div",{"data-issue-id":s.id,onClick:()=>r(s.id),style:{background:"var(--proto-card)",border:`1px solid ${l?"var(--proto-accent-border)":"var(--proto-line-2)"}`,borderRadius:10,padding:"11px 13px",boxShadow:l?"0 1px 3px rgba(70,85,212,.08)":"none",cursor:"pointer",flex:"none"},children:[o.jsx("div",{style:{fontSize:12.5,fontWeight:600,color:l?"var(--proto-ink)":"var(--proto-ink-2)",lineHeight:1.35},children:a.title}),a.date&&o.jsx("div",{style:{display:"flex",alignItems:"center",gap:7,marginTop:6},children:o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${js}`,color:"var(--proto-faint)"},children:a.date})})]},s.id)})}),o.jsx("div",{style:{marginTop:"auto",padding:"12px 18px",borderTop:"1px solid var(--proto-line-2)",font:`400 9.5px ${js}`,color:"var(--proto-faint)",lineHeight:1.7,flex:"none"},children:i.isNoStatusNote})]})}const Q3={fontSize:10,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",paddingTop:2};function Eq({detail:e,armed:t,pending:n,onArm:r,onCancelArm:i,onDelete:s,onHandle:a}){const l=B();return o.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{flex:1,overflow:"auto",minHeight:0,padding:"18px 24px 0"},children:[o.jsx("div",{style:{fontSize:16,fontWeight:650,color:"var(--proto-ink)",lineHeight:1.35},children:e.title}),e.date&&o.jsx("div",{style:{display:"flex",alignItems:"center",gap:14,marginTop:8,font:`400 10.5px ${js}`,color:"var(--proto-muted-3)"},children:o.jsxs("span",{children:[l.isRecorded," ",e.date]})}),o.jsxs("div",{style:{margin:"16px 0 14px",display:"grid",gridTemplateColumns:"76px 1fr",rowGap:10,columnGap:14,fontSize:12,lineHeight:1.6},children:[e.desc&&o.jsxs(o.Fragment,{children:[o.jsx("span",{style:Q3,children:l.isDescLabel}),o.jsx("span",{style:{color:"var(--proto-ink-2)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e.desc})]}),e.fields.map((c,d)=>o.jsx(Rq,{label:c.label,text:c.text},`${c.label}-${d}`))]})]}),o.jsxs("div",{style:{flex:"none",borderTop:"1px solid var(--proto-line-2)",padding:"14px 22px",display:"flex",alignItems:"center",gap:10},children:[o.jsx("span",{style:{font:`400 10px ${js}`,color:"var(--proto-faint)",lineHeight:1.6,flex:1,minWidth:0},children:l.isFootNote}),!t&&o.jsxs(o.Fragment,{children:[o.jsx($u,{"data-action":"arm-delete",onClick:n?void 0:()=>r(),base:{fontSize:12,fontWeight:600,border:"1px solid var(--proto-danger-bg)",borderRadius:8,padding:"7px 16px",color:"var(--proto-danger)",background:"var(--proto-card)",cursor:n?"not-allowed":"pointer",flex:"none",opacity:n?.6:1},hover:{background:"var(--proto-danger-bg)"},children:l.isDelete}),o.jsx($u,{"data-action":"handle",onClick:n?void 0:()=>a(e.id),base:{fontSize:12,fontWeight:600,borderRadius:8,padding:"8px 22px",color:"var(--ink-solid-fg)",background:"var(--proto-accent)",cursor:n?"not-allowed":"pointer",flex:"none",opacity:n?.6:1},hover:{background:"var(--proto-accent-strong)"},children:l.isHandle})]}),t&&o.jsxs(o.Fragment,{children:[o.jsx($u,{"data-action":"cancel-delete",onClick:n?void 0:()=>i(),base:{fontSize:12,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"7px 16px",color:"var(--proto-ink)",background:"var(--proto-card)",cursor:n?"not-allowed":"pointer",flex:"none",opacity:n?.6:1},hover:{background:"var(--proto-alt)"},children:l.cancel}),o.jsx($u,{"data-action":"confirm-delete",onClick:n?void 0:()=>s(e.id),base:{fontSize:12,fontWeight:600,borderRadius:8,padding:"8px 20px",color:"var(--ink-solid-fg)",background:"var(--proto-danger)",cursor:n?"not-allowed":"pointer",flex:"none",opacity:n?.6:1},hover:{opacity:.88},children:l.isConfirmDelete})]})]})]})}function Rq({label:e,text:t}){return o.jsxs(o.Fragment,{children:[o.jsx("span",{style:Q3,children:e}),o.jsx("span",{style:{color:"var(--proto-ink-2)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})]})}function $u({base:e,hover:t,onClick:n,children:r,...i}){const[s,a]=f.useState(!1);return o.jsx("span",{...i,onClick:n,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:s?{...e,...t}:e,children:r})}function Pq({open:e,initialId:t,onClose:n}){const r=B(),i=ae(),s=je(),a=Be(),{toast:l}=Tn(),{currentProjectId:c}=$i(),{setSelectedSession:d}=_s(),u=G({...i.issues.list.queryOptions({projectId:c??""}),enabled:e&&!!c}),p=f.useMemo(()=>u.data??[],[u.data]),[h,g]=f.useState(null),[v,x]=f.useState(!1),w=kq(p,h??t),b=()=>s.invalidateQueries(i.issues.list.queryFilter()),y=ue(i.issues.delete.mutationOptions({onSettled:()=>{x(!1),b()}})),j=y.isPending;return f.useEffect(()=>{e||(x(!1),g(null))},[e]),f.useEffect(()=>{x(!1)},[w]),f.useEffect(()=>{if(!e)return;const S=k=>{k.key==="Escape"&&n()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[e,n]),e?o.jsx(Sq,{entries:p,selectedId:w,projectId:c,armed:v,pending:j,onSelect:g,onClose:n,onArm:()=>x(!0),onCancelArm:()=>x(!1),onDelete:S=>{c&&y.mutate({projectId:c,id:S},{onSuccess:()=>l({title:r.isToastDeleted,tone:"done"})})},onHandle:S=>{if(!c)return;const k=p.find(R=>R.id===S);if(!k)return;const E=K3(c,k),C=Hd({isDraft:!0,projectId:c});Os(C,{text:E,attachments:[]}),d(cd),n(),a("/workbench"),y.mutate({projectId:c,id:S},{onSuccess:()=>l({title:r.isToastHandled,tone:"done"})})}}):null}const G3=f.createContext(null);function Iq({children:e}){const[t,n]=f.useState(!1),[r,i]=f.useState(null),s=f.useCallback(c=>{i(c??null),n(!0)},[]),a=f.useCallback(()=>{n(!1),i(null)},[]),l=f.useMemo(()=>({open:s,close:a}),[s,a]);return o.jsxs(G3.Provider,{value:l,children:[e,o.jsx(Pq,{open:t,initialId:r,onClose:a})]})}function Mq(){const e=f.useContext(G3);if(!e)throw new Error("useIssues must be used within an IssuesProvider");return e}const Lq=96;function Y3(e,t=Lq){const n=(e??"").replace(/\s+/g," ").trim();return n.length<=t?n:n.slice(0,t-1).trimEnd()+"…"}function X3(e){const t=(e.sessionName??"").trim();return{id:e.id,level:e.level??"info",title:t||"New message",meta:Y3(e.text),ts:e.ts??new Date().toISOString(),sessionId:e.sessionId,projectId:e.projectId}}function J3(e){const t=(e.title??"").trim();return{id:e.id,level:e.level??"info",title:t||"System notice",meta:Y3(e.text),ts:e.ts??new Date().toISOString(),sessionId:"",projectId:null}}function Oq(e){return e==="info"}const Dq=3,xw=50;function Aq(e,t){return e.sessionId===t.sessionId&&e.meta===t.meta}function Mm(e,t){const n=e[e.length-1];if(n&&Aq(n,t))return e;const r=[...e,t];return r.length>xw?r.slice(r.length-xw):r}function nf(e,t){return e.filter(n=>n.id!==t)}function Z3(e,t=Dq){return e.length<=t?{visible:e,overflow:0}:{visible:e.slice(e.length-t),overflow:e.length-t}}const Nq={info:"bg-proto-accent-bg text-proto-accent",warning:"bg-pill-waiting-bg text-pill-waiting-fg",error:"bg-pill-failed-bg text-pill-failed-fg"},$q={info:"i",warning:"!",error:"✕"};function _q(e,t=Date.now()){const n=Date.parse(e);if(Number.isNaN(n))return"now";const r=Math.max(0,Math.floor((t-n)/1e3));if(r<45)return"now";const i=Math.floor(r/60);if(i<60)return`${i}m`;const s=Math.floor(i/60);return s<24?`${s}h`:`${Math.floor(s/24)}d`}function Fq({item:e,onDismiss:t,onActivate:n}){const r=Oq(e.level);return o.jsxs("div",{role:"status",onClick:()=>n(e),className:"group relative w-[380px] cursor-pointer overflow-hidden rounded-[11px] border border-proto-line bg-surface-card px-[13px] pb-[12px] pt-[11px] shadow-toast animate-toast-in motion-reduce:animate-none",children:[o.jsxs("div",{className:"flex items-start gap-[10px]",children:[o.jsx("span",{className:["flex h-[24px] w-[24px] flex-none items-center justify-center rounded-[7px] text-[11px] font-bold",Nq[e.level]].join(" "),"aria-hidden":!0,children:$q[e.level]}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-baseline gap-[8px]",children:[o.jsx("span",{className:"text-[12.5px] font-semibold text-proto-ink",children:e.title}),o.jsx("span",{className:"ml-auto font-mono text-[10px] text-proto-faint",children:_q(e.ts)}),o.jsx("button",{type:"button","aria-label":"Dismiss",onClick:i=>{i.stopPropagation(),t(e.id)},className:"flex-none text-[12px] leading-none text-proto-faint transition-colors hover:text-proto-muted",children:"✕"})]}),o.jsx("div",{className:"mt-[3px] truncate font-mono text-[10.5px] text-proto-muted-2",children:e.meta})]})]}),r?o.jsx("div",{className:"absolute bottom-0 left-0 h-[2px] bg-proto-accent opacity-40 animate-toastbar group-hover:[animation-play-state:paused]",onAnimationEnd:i=>{i.animationName==="toastbar"&&t(e.id)}}):null]})}function zq({items:e,onDismiss:t,onActivate:n}){const[r,i]=f.useState(!1);if(e.length===0)return null;const{visible:s,overflow:a}=Z3(e),l=r?e:s;return o.jsxs("div",{className:"pointer-events-none fixed bottom-0 right-0 z-50 m-2g flex w-[380px] max-w-[calc(100vw-2rem)] flex-col items-end gap-[10px]",children:[l.map(c=>o.jsx("div",{className:"pointer-events-auto w-full",children:o.jsx(Fq,{item:c,onDismiss:t,onActivate:n})},c.id)),a>0&&!r?o.jsxs("button",{type:"button",onClick:()=>i(!0),className:"pointer-events-auto flex items-center gap-[7px] rounded-full border border-proto-line bg-surface-card px-[12px] py-[5px] shadow-toast-pill",children:[o.jsxs("span",{className:"font-mono text-[10.5px] font-semibold text-proto-muted",children:["+",a]}),o.jsx("span",{className:"text-[11px] text-proto-muted-2",children:"more · click to expand"})]}):null]})}const Bq=["session.message","session.status"];function eT({onMessage:e,onTurnEnd:t}){Ni(Bq,n=>{if(n.type==="session.message"){const r=n.payload;if(!r||r.role!=="assistant")return;const i=(r.text??"").trim();if(!i||!r.sessionId)return;e({sessionId:r.sessionId,channel:r.channel??null,text:i,ts:r.ts??null});return}if(n.type==="session.status"){const r=n.payload;if(!r||!r.sessionId||r.running!==!1)return;t(r.sessionId)}})}function tT(e){Ni(S3,t=>{if(t.type!=="system.notice")return;const n=t.payload,r=((n==null?void 0:n.text)??"").trim();r&&e({level:(n==null?void 0:n.level)??"info",text:r,title:(n==null?void 0:n.title)??null,ts:(n==null?void 0:n.ts)??null})})}function nT(e,t,n){e.set(t,n)}function rT(e,t){const n=e.get(t)??null;return e.delete(t),n}function Wq(){const e=ae(),t=Be(),n=wr(),{selectedSessionId:r,setSelectedSession:i}=_s(),{setCurrentProject:s}=$i(),[a,l]=f.useState([]),c=f.useRef(0),d=f.useRef(new Map),u=f.useRef(r),p=f.useRef(n.pathname),h=G(e.sessions.list.queryOptions({origin:"direct"}));f.useEffect(()=>{const j=new Map;for(const S of h.data??[])j.set(S.sessionId,{name:S.label??S.name,projectId:S.projectId});d.current=j},[h.data]),f.useEffect(()=>{u.current=r},[r]),f.useEffect(()=>{p.current=n.pathname},[n.pathname]);const g=f.useRef(new Map),v=f.useCallback(j=>{nT(g.current,j.sessionId,{text:j.text,ts:j.ts??new Date().toISOString()})},[]),x=f.useCallback(j=>{const S=rT(g.current,j);if(!S)return;const k=d.current.get(j);if(!k||p.current.startsWith("/workbench")&&u.current===j)return;const E=`dmn-${c.current++}`,C=X3({id:E,sessionId:j,sessionName:k.name,projectId:k.projectId,text:S.text,ts:S.ts});l(R=>Mm(R,C))},[]);eT({onMessage:v,onTurnEnd:x});const w=f.useCallback(j=>{const S=`sysn-${c.current++}`,k=J3({id:S,level:j.level,text:j.text,title:j.title??void 0,ts:j.ts??void 0});l(E=>Mm(E,k))},[]);tT(w);const b=f.useCallback(j=>l(S=>nf(S,j)),[]),y=f.useCallback(j=>{j.sessionId&&(j.projectId&&s(j.projectId),i(j.sessionId),t("/workbench")),l(S=>nf(S,j.id))},[t,s,i]);return o.jsx(zq,{items:a,onDismiss:b,onActivate:y})}const Uq="frontend-update-staged";function mw(e){return e.slice(0,8)}function Hq(e){const t=mw(e.version),n=e.fromVersion?mw(e.fromVersion):"";return n&&n!==t?`${n} → ${t}`:t}function oT(e){return!e||e<=0?null:e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function iT(e){const t=oT(e.size),n=[Hq(e)];return t&&n.push(t),n.push("已下载"),n.join(" · ")}function ly(){return globalThis.__TAURI__}function sT(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.version!="string"||!t.version?null:{version:t.version,fromVersion:typeof t.fromVersion=="string"&&t.fromVersion?t.fromVersion:void 0,size:typeof t.size=="number"?t.size:void 0}}async function qq(e){var n;if(!on())return()=>{};const t=(n=ly())==null?void 0:n.event;if(!t)return()=>{};try{const r=await t.listen(Uq,i=>{const s=sT(i.payload);s&&e(s)});return()=>{try{r()}catch{}}}catch{return()=>{}}}async function Vq(){var t;if(!on())return null;const e=(t=ly())==null?void 0:t.core;if(!e)return null;try{const n=await e.invoke("get_staged_update");return sT(n)}catch{return null}}async function Kq(){var t;if(!on())return;const e=(t=ly())==null?void 0:t.core;if(e)try{await e.invoke("apply_frontend_update")}catch{}}const Qq="app-update-available";function vw(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.version!="string"||!t.version||typeof t.kind!="string"||!t.kind)return null;const n={version:t.version,kind:t.kind};return typeof t.releaseUrl=="string"&&t.releaseUrl&&(n.releaseUrl=t.releaseUrl),typeof t.notes=="string"&&t.notes&&(n.notes=t.notes),typeof t.size=="number"&&t.size>0&&(n.size=t.size),n}function aT(e){const t=[`Cortex ${e.version}`],n=oT(e.size);return n&&t.push(n),t.push("已下载"),t.join(" · ")}function lT(e){switch(e){case"appimage":return"重启更新";case"nsis":return"运行安装程序";case"apk":return"安装";case"dmg":case"deb":case"rpm":return"打开安装包";default:return"更新"}}function cT(e){switch(e){case"appimage":return"新版本已在后台下载并校验完成,点击后自动替换并重启。运行中的线程在服务端继续执行,不受影响。";case"nsis":return"新版本已在后台下载并校验完成。点击后将退出 App 并启动安装程序,按提示完成安装后重新打开即可。";case"apk":return"新版本已在后台下载并校验完成。点击安装后按系统提示完成升级,运行中的线程在服务端继续执行。";case"dmg":return"新版本已在后台下载并校验完成。将打开磁盘映像,把 Cortex 拖入 Applications 即完成升级。";case"deb":case"rpm":return"新版本已在后台下载并校验完成。将打开安装包,用系统安装器完成升级后重新打开 App。";default:return"新版本已在后台下载并校验完成。"}}let dT=null;const Lm=new Set;function rf(e){dT=e;for(const t of Lm)t()}function cy(e){return Lm.add(e),()=>Lm.delete(e)}function dy(){return dT}function uy(){return globalThis.__TAURI__}async function Gq(){var n;if(!on())return()=>{};const e=uy();if(!e)return()=>{};let t=()=>{};try{if(e.event){const i=await e.event.listen(Qq,s=>{const a=vw(s.payload);a&&rf(a)});t=()=>{try{i()}catch{}}}const r=vw(await((n=e.core)==null?void 0:n.invoke("get_app_update")));r&&rf(r)}catch{}return t}async function Yq(){var t;if(!on())return null;const e=(t=uy())==null?void 0:t.core;if(!e)return null;try{return await e.invoke("install_app_update")??null}catch(n){if(typeof n=="string"&&n)throw new Error(n);return null}}async function Xq(){var e,t;if(rf(null),!!on())try{await((t=(e=uy())==null?void 0:e.core)==null?void 0:t.invoke("skip_app_update"))}catch{}}function Om(e){if(!e)return!1;const t=e.tagName;if(t==="TEXTAREA")return!0;if(t==="INPUT"){const n=e.type;return!["button","checkbox","radio","submit","reset","file","range","color"].includes(n)}return e.isContentEditable===!0}function uT(){const[e,t]=f.useState(null),n=f.useRef(!1),r=f.useRef(null),i=f.useCallback(l=>{if(!n.current){if(Om(typeof document<"u"?document.activeElement:null)){r.current=l;return}t(l)}},[]);f.useEffect(()=>{let l=!1,c=()=>{};return qq(d=>i(d)).then(d=>{l?d():c=d}),Vq().then(d=>{d&&!l&&i(d)}),()=>{l=!0,c()}},[i]),f.useEffect(()=>{if(typeof document>"u")return;const l=()=>{window.setTimeout(()=>{n.current||!r.current||Om(document.activeElement)||(t(r.current),r.current=null)},0)};return document.addEventListener("focusout",l),()=>document.removeEventListener("focusout",l)},[]);const s=f.useCallback(()=>{Kq()},[]),a=f.useCallback(()=>{n.current=!0,r.current=null,t(null)},[]);return{staged:e,apply:s,dismiss:a}}const Jq="fixed inset-0 z-40 bg-state-ink/[0.44] data-[state=open]:animate-fade-in data-[state=closed]:animate-fade-out motion-reduce:animate-none",Zq="fixed left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2 w-[420px] max-w-[calc(100vw-32px)] box-border rounded-[14px] bg-surface-card p-5 pb-4 shadow-overlay-strong focus:outline-none data-[state=open]:animate-zoom-in data-[state=closed]:animate-zoom-out motion-reduce:animate-none";function eV({update:e,onApply:t,onDismiss:n}){return o.jsx(Co,{open:!0,onOpenChange:r=>{r||n()},children:o.jsxs(To,{children:[o.jsx(Eo,{className:Jq}),o.jsxs(Ro,{className:Zq,"aria-describedby":"hot-update-desc",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 flex-none items-center justify-center rounded-card bg-proto-accent-bg text-state-run",children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[o.jsx("path",{d:"M10 14V4M5.5 8.5 10 4l4.5 4.5"}),o.jsx("path",{d:"M3.5 16.5h13"})]})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx(Oi,{className:"text-body font-semibold text-state-ink",children:"新版本已就绪"}),o.jsx("div",{className:"mt-[3px] font-mono text-[10.5px] font-medium text-proto-muted-3",children:iT(e)})]})]}),o.jsx(Id,{id:"hot-update-desc",className:"mb-4 mt-3 text-[12.5px] leading-[1.65] text-proto-muted",children:"热更新已在后台下载完成,重启 App 后生效。运行中的线程在服务端继续执行,不受重启影响;未发送的草稿会保留。"}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx("button",{type:"button",onClick:n,className:"box-border flex h-9 items-center rounded-[9px] border border-proto-line px-4 text-[12.5px] font-semibold text-proto-muted transition-colors hover:bg-surface-canvas-alt focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",children:"忽略"}),o.jsx("button",{type:"button",onClick:t,className:"box-border flex h-9 items-center rounded-[9px] bg-state-ink px-4 text-[12.5px] font-semibold text-surface-card transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",children:"重启 App"})]})]})]})})}function tV(){const e=f.useSyncExternalStore(cy,dy),{staged:t,apply:n,dismiss:r}=uT();return e||!t?null:o.jsx(eV,{update:t,onApply:n,onDismiss:r})}function pT(){const e=f.useSyncExternalStore(cy,dy),[t,n]=f.useState(null),[r,i]=f.useState(!1),[s,a]=f.useState(null),l=f.useRef(null);f.useEffect(()=>{let p=!1,h=()=>{};return Gq().then(g=>{p?g():h=g}),()=>{p=!0,h()}},[]),f.useEffect(()=>{if(!e||l.current===e.version){n(null);return}const p=()=>{l.current!==e.version&&(typeof document<"u"&&Om(document.activeElement)||n(e))};if(p(),typeof document>"u")return;const h=()=>{window.setTimeout(p,0)};return document.addEventListener("focusout",h),()=>document.removeEventListener("focusout",h)},[e]);const c=f.useCallback(()=>{i(!0),a(null),Yq().then(p=>{i(!1),p!==null&&rf(null),n(null)}).catch(p=>{i(!1),a(p.message)})},[]),d=f.useCallback(()=>{Xq(),n(null)},[]),u=f.useCallback(()=>{l.current=(e==null?void 0:e.version)??(t==null?void 0:t.version)??null,n(null)},[e,t]);return{update:t,busy:r,error:s,install:c,skip:d,dismiss:u}}const nV="fixed inset-0 z-40 bg-state-ink/[0.44] data-[state=open]:animate-fade-in data-[state=closed]:animate-fade-out motion-reduce:animate-none",rV="fixed left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2 w-[420px] max-w-[calc(100vw-32px)] box-border rounded-[14px] bg-surface-card p-5 pb-4 shadow-overlay-strong focus:outline-none data-[state=open]:animate-zoom-in data-[state=closed]:animate-zoom-out motion-reduce:animate-none",yw="box-border flex h-9 items-center rounded-[9px] border border-proto-line px-4 text-[12.5px] font-semibold text-proto-muted transition-colors hover:bg-surface-canvas-alt focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40";function oV({update:e,busy:t,error:n,onInstall:r,onSkip:i,onDismiss:s}){return o.jsx(Co,{open:!0,onOpenChange:a=>{a||s()},children:o.jsxs(To,{children:[o.jsx(Eo,{className:nV}),o.jsxs(Ro,{className:rV,"aria-describedby":"app-update-desc",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 flex-none items-center justify-center rounded-card bg-proto-accent-bg text-state-run",children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[o.jsx("path",{d:"M10 14V4M5.5 8.5 10 4l4.5 4.5"}),o.jsx("path",{d:"M3.5 16.5h13"})]})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx(Oi,{className:"text-body font-semibold text-state-ink",children:"App 新版本已就绪"}),o.jsx("div",{className:"mt-[3px] font-mono text-[10.5px] font-medium text-proto-muted-3",children:aT(e)})]})]}),o.jsx(Id,{id:"app-update-desc",className:"mb-4 mt-3 text-[12.5px] leading-[1.65] text-proto-muted",children:cT(e.kind)}),n?o.jsxs("div",{className:"mb-3 text-[11.5px] leading-snug text-state-fail",children:["安装失败:",n]}):null,o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx("button",{type:"button",onClick:i,className:yw,children:"跳过此版本"}),o.jsx("button",{type:"button",onClick:s,className:yw,children:"稍后"}),o.jsx("button",{type:"button",onClick:r,disabled:t,className:"box-border flex h-9 items-center rounded-[9px] bg-state-ink px-4 text-[12.5px] font-semibold text-surface-card transition-opacity hover:opacity-90 disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",children:t?"正在处理…":lT(e.kind)})]})]})]})})}function iV(){const{update:e,busy:t,error:n,install:r,skip:i,dismiss:s}=pT();return e?o.jsx(oV,{update:e,busy:t,error:n,onInstall:r,onSkip:i,onDismiss:s}):null}function sV(e,t){return e==="pending"?"connected":e==="connecting"?t?"reconnecting":"connecting":t?"disconnected":"connecting"}function aV(e){switch(e){case"connected":return{color:"var(--proto-success)",pulse:!1};case"connecting":case"reconnecting":return{color:"var(--proto-amber)",pulse:!0};case"disconnected":return{color:"var(--proto-danger)",pulse:!1}}}function lV(e){switch(e){case"connected":return"connConnected";case"connecting":return"connConnecting";case"reconnecting":return"connReconnecting";case"disconnected":return"connDisconnected"}}const fT=f.createContext("connecting");function hT({children:e}){const{connState:t,hasConnected:n}=ry(),r=sV(t,n);return o.jsx(fT.Provider,{value:r,children:e})}function gT(){return f.useContext(fT)}function qd(e){var t;return e.claimThreadId?e.claimThreadId:(t=e.claimedBy)!=null&&t.startsWith("thr_")?e.claimedBy:null}function _u(e){return String(e).padStart(2,"0")}function ah(e){if(!e)return null;const t=new Date(e);return Number.isNaN(t.getTime())?null:`${`${t.getFullYear()}-${_u(t.getMonth()+1)}-${_u(t.getDate())}`} ${_u(t.getHours())}:${_u(t.getMinutes())}`}const cV=[{kind:"done",matches:e=>e.status==="done"},{kind:"blocked",matches:e=>e.blockedBy!=null},{kind:"in-progress",matches:e=>e.claimedBy!=null},{kind:"approval-needed",matches:e=>e.approvalNeeded===!0},{kind:"actionable",matches:e=>e.actionable}];function dV(e){var t;return((t=cV.find(n=>n.matches(e)))==null?void 0:t.kind)??"waiting"}const uV={done:{bg:"#E9F4EE",fg:"#23854F",text:"✓ done"},blocked:{bg:"#FBEDEB",fg:"#C03D33",text:"blocked"},"approval-needed":{bg:"#FFF6E5",fg:"#9A6700",text:"approval-needed"},actionable:{bg:"#EEF0FA",fg:"#4655D4",text:"actionable"},waiting:{bg:"#F1F2F5",fg:"#8A93A2",text:"waiting on deps"}};function pV(e){const t=dV(e);if(t!=="in-progress")return uV[t];const n=qd(e);return{bg:"#EEF0FA",fg:"#4655D4",text:`● in-progress${n?` · ${n}`:""}`}}function fV(e){return e==="high"?"#C03D33":e==="medium"?"#C99A2E":"#B6BDC9"}function bw(e){return e?e.status==="done"?"#23854F":e.blockedBy!=null?"#C03D33":"#4655D4":"#B6BDC9"}function hV(e){const t=e.approvalNeeded;return[{k:"approval-needed",v:t==null?"—":String(t),vColor:t===!0?"#9A6700":"var(--proto-ink)"},{k:"approved-at",v:e.approvedAt??"—",vColor:e.approvedAt?"#23854F":"#B6BDC9"}]}function gV(e){const t=qd(e),n=ah(e.completedAt);return[{k:"priority",v:e.priority,vColor:e.priority==="high"?"#C03D33":"#191C22"},{k:"status",v:e.status,vColor:"var(--proto-ink)"},...hV(e),{k:"completed-at",v:n??"—",vColor:n?"#23854F":"#B6BDC9"},{k:"template",v:e.template,vColor:"var(--proto-ink)"},{k:"gpu",v:"—",vColor:"#B6BDC9"},{k:"claimed-by",v:t??"—",vColor:t?"#4655D4":"#B6BDC9"}]}function xV(e,t){const n=new Map(t.map(s=>[s.id,s])),r=e.dependsOn.map(s=>{const a=n.get(s);return{id:s,name:(a==null?void 0:a.text)??"—",dotColor:bw(a),idColor:"#4655D4",label:(a==null?void 0:a.status)==="done"?"upstream · done":"upstream",bg:"#FBFBFC",border:"#EFF1F5"}}),i=t.filter(s=>s.id!==e.id&&s.dependsOn.includes(e.id)).map(s=>({id:s.id,name:s.text,dotColor:bw(s),idColor:"#4655D4",label:"downstream",bg:"#FBFBFC",border:"#EFF1F5"}));return[...r,...i]}function mV(e,t){const n=xV(e,t),r=e.status!=="done"&&e.blockedBy==null;return{id:e.id,title:e.text,pill:pV(e),priColor:fV(e.priority),fields:gV(e),deps:n,hasDependencies:n.length>0,canUnblock:e.blockedBy!=null,completable:r,completeBg:r?"#4655D4":"#B6BDC9",completeLabel:e.status==="done"?"Completed":"Complete"}}function vV(e){switch(e){case"completed":return"#23854F";case"failed":return"#C03D33";case"running":return"#4655D4";case"stale":return"#C99A2E";default:return"#8A93A2"}}function yV(e){if(e==null||!Number.isFinite(e)||e<0)return"—";const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),r=Math.round(t%60);return`${n}m ${r}s`}function bV(e){return e==null||!Number.isFinite(e)?"—":`$${e.toFixed(4)}`}function jV(e){if(!e)return"—";const t=Date.parse(e);if(Number.isNaN(t))return"—";const n=new Date(t),r=i=>String(i).padStart(2,"0");return`${r(n.getMonth()+1)}-${r(n.getDate())} ${r(n.getHours())}:${r(n.getMinutes())}`}function wV(e){const t=e.evidence,n=e.dispatches.map(i=>({executionId:i.executionId,type:i.type,status:i.status,statusColor:vV(i.status),machine:i.machine??"—",threadId:i.threadId,when:jV(i.startedAt),duration:yV(i.durationMs),cost:bV(i.cost),isCompleting:i.executionId===t.completingExecutionId})),r=t.completed&&(t.completedNote!=null||t.completingOutput!=null||t.completedAt!=null);return{completed:t.completed,doneWhen:t.doneWhen,completedAt:t.completedAt,completedNote:t.completedNote,completingExecutionId:t.completingExecutionId,completingOutput:t.completingOutput,hasEvidence:r,dispatches:n,hasDispatches:n.length>0}}const ua={background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"0 1px 2px rgba(16,24,40,.03)"},Rg={display:"flex",alignItems:"center",padding:"10px 15px",borderBottom:"1px solid var(--proto-line-2)"},Pg={fontSize:11.5,fontWeight:650,color:"var(--proto-ink)"};function ea({children:e}){return o.jsx("span",{style:{fontStyle:"italic",color:"var(--proto-faint)"},children:e})}function kV({label:e,reason:t}){return t==null?null:o.jsxs("div",{"data-task-blocker-card":"true",style:{...ua,padding:"10px 15px",background:"var(--proto-danger-bg)"},children:[o.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-danger)"},children:e}),o.jsx("div",{style:{marginTop:5,fontSize:11.5,lineHeight:1.6,color:"var(--proto-danger)",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:t})]})}function SV({vv:e}){return o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.dispatches.map(t=>o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 9px",background:t.isCompleting?"var(--proto-accent-bg)":"var(--proto-rail)",border:`1px solid ${t.isCompleting?"var(--proto-accent-bg)":"var(--proto-line-2)"}`,borderRadius:7},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:t.statusColor,flex:"none"}}),o.jsx("span",{style:{font:"600 10px 'IBM Plex Mono',monospace",color:"var(--proto-accent)"},children:t.executionId}),o.jsx("span",{style:{fontSize:9.5,color:"var(--proto-muted-2)"},children:t.machine}),o.jsxs("span",{style:{marginLeft:"auto",font:"400 9px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",flex:"none"},children:[t.when," · ",t.duration," · ",t.cost]})]},t.executionId))})}function CV({task:e,allTasks:t,pending:n,onClose:r,onComplete:i,onUnblock:s}){const a=B(),l=mV(e,t),c=ae(),d=G(c.tasks.verification.queryOptions({projectId:e.project,taskId:e.id})),u=d.data?wV(d.data):null;return f.useEffect(()=>{const p=h=>{h.key==="Escape"&&r()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r]),o.jsxs(o.Fragment,{children:[o.jsx("div",{onClick:r,style:{position:"fixed",inset:0,background:"rgba(25,28,34,.34)",zIndex:60,animation:"cxfade .18s ease"}}),o.jsxs("div",{"data-task-modal-id":e.id,style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)",width:760,maxHeight:"84vh",background:"var(--proto-alt)",borderRadius:14,boxShadow:"0 24px 64px rgba(16,24,40,.3)",zIndex:61,overflow:"hidden",display:"flex",flexDirection:"column"},children:[o.jsxs("div",{style:{flex:"none",background:"var(--proto-card)",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:9,padding:"12px 18px"},children:[o.jsx("span",{style:{font:"600 12.5px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:l.id}),o.jsx("span",{style:{fontSize:9.5,fontWeight:600,padding:"1.5px 8px",borderRadius:999,background:l.pill.bg,color:l.pill.fg},children:l.pill.text}),o.jsx("span",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",marginLeft:4},children:"TASKS.yaml"}),o.jsx("span",{onClick:r,style:{marginLeft:"auto",font:"500 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),o.jsxs("div",{style:{flex:1,overflow:"auto",minHeight:0,padding:"14px 18px",display:"grid",gridTemplateColumns:"1.5fr 1fr",gap:12,alignContent:"start"},children:[o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,minWidth:0},children:[o.jsxs("div",{style:{...ua,padding:"13px 16px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:l.priColor,flex:"none",marginTop:5}}),o.jsx("div",{style:{fontSize:13.5,fontWeight:650,color:"var(--proto-ink)",lineHeight:1.4},children:l.title})]}),o.jsxs("div",{style:{fontSize:11.5,lineHeight:1.6,color:"var(--proto-muted)",marginTop:7},children:[o.jsx("span",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",marginRight:7},children:a.tkWhy}),e.why!=null?o.jsx("span",{children:e.why}):o.jsxs(ea,{children:["— ",a.tkNoWhy]})]}),o.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",margin:"11px 0 5px"},children:a.tkDoneWhen}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:o.jsxs("div",{style:{display:"flex",gap:8,fontSize:11.5,lineHeight:1.5,color:"var(--proto-ink-2)",background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:7,padding:"6px 10px"},children:[o.jsx("span",{style:{width:12,height:12,borderRadius:4,border:"1.5px solid var(--proto-line-3)",background:"var(--proto-card)",boxSizing:"border-box",flex:"none",marginTop:1.5}}),e.doneWhen!=null?o.jsx("span",{children:e.doneWhen}):o.jsxs(ea,{children:["— ",a.tkNoDoneWhen]})]})})]}),o.jsx(kV,{label:a.mBlockedPill,reason:e.blockedBy}),o.jsxs("div",{style:ua,children:[o.jsxs("div",{style:Rg,children:[o.jsx("span",{style:Pg,children:a.tkDispatchHistory}),u&&u.hasDispatches&&o.jsxs("span",{style:{marginLeft:"auto",font:"400 9px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:[u.dispatches.length," run",u.dispatches.length===1?"":"s"]})]}),o.jsx("div",{style:{padding:"10px 15px",fontSize:11,lineHeight:1.55},children:d.isPending?o.jsxs(ea,{children:["— ",a.tkLoadingDispatch]}):d.isError||!u?o.jsxs(ea,{children:["— ",a.tkDispatchFailed]}):u.hasDispatches?o.jsx(SV,{vv:u}):o.jsxs(ea,{children:["— ",a.tkNoDispatches]})})]})]}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,minWidth:0},children:[o.jsxs("div",{style:ua,children:[o.jsx("div",{style:Rg,children:o.jsx("span",{style:Pg,children:a.tkFields})}),o.jsx("div",{style:{padding:"8px 15px 10px",font:"400 10px/2 'IBM Plex Mono',monospace",color:"var(--proto-muted)"},children:l.fields.map(p=>o.jsxs("div",{style:{display:"flex"},children:[o.jsx("span",{style:{color:"var(--proto-muted-3)"},children:p.k}),o.jsx("span",{style:{marginLeft:"auto",color:p.vColor,textAlign:"right"},children:p.v})]},p.k))})]}),o.jsxs("div",{style:ua,children:[o.jsx("div",{style:Rg,children:o.jsx("span",{style:Pg,children:a.tkDependencies})}),o.jsx("div",{style:{padding:"10px 15px",display:"flex",flexDirection:"column",gap:5},children:l.hasDependencies?l.deps.map(p=>o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 9px",background:p.bg,border:`1px solid ${p.border}`,borderRadius:7},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:p.dotColor,flex:"none"}}),o.jsx("span",{style:{font:"600 10.5px 'IBM Plex Mono',monospace",color:p.idColor},children:p.id}),o.jsx("span",{style:{fontSize:10.5,color:"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:p.name}),o.jsx("span",{style:{marginLeft:"auto",font:"400 8.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",flex:"none"},children:p.label})]},`${p.label}:${p.id}`)):o.jsxs(ea,{children:["— ",a.tkNoDependencies]})})]}),o.jsxs("div",{style:{...ua,padding:"11px 14px",display:"flex",gap:8},children:[l.canUnblock&&o.jsx("span",{onClick:()=>!n&&s(e),style:{flex:1,textAlign:"center",fontSize:11,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"6px 0",color:"var(--proto-ink)",cursor:n?"not-allowed":"pointer",opacity:n?.5:1},children:a.mUnblock}),o.jsx("span",{"data-complete-task-id":e.id,onClick:()=>l.completable&&!n&&i(e),style:{flex:1.3,textAlign:"center",fontSize:11,fontWeight:600,borderRadius:8,padding:"7px 0",color:"var(--ink-solid-fg)",background:l.completeBg,cursor:l.completable&&!n?"pointer":"not-allowed",opacity:n?.6:1},children:l.completeLabel})]})]})]})]})]})}function TV(e,t){return t.type==="open"?{projectId:t.projectId,taskId:t.taskId}:null}const xT=f.createContext(null);function EV(e){const t=ae(),n=je(),r=()=>n.invalidateQueries(t.tasks.list.queryFilter()),i=ue(t.tasks.complete.mutationOptions({onSettled:()=>{e(),r()}})),s=ue(t.tasks.unblock.mutationOptions({onSettled:()=>void r()}));return{completeTask:c=>i.mutate({projectId:c.project,taskId:c.id,note:"completed via Web UI"}),unblockTask:c=>s.mutate({projectId:c.project,taskId:c.id}),pending:i.isPending||s.isPending}}function RV({selection:e,onClose:t}){const n=ae(),r=G(n.tasks.list.queryOptions({projectId:e.projectId})),i=EV(t),s=r.data??[],a=s.find(l=>l.id===e.taskId);return a?o.jsx(CV,{task:a,allTasks:s,pending:i.pending,onClose:t,onComplete:i.completeTask,onUnblock:i.unblockTask}):null}function PV({children:e}){const[t,n]=f.useReducer(TV,null),r=f.useCallback((a,l)=>{n({type:"open",projectId:a,taskId:l})},[]),i=f.useCallback(()=>n({type:"close"}),[]),s=f.useMemo(()=>({openTask:r,closeTask:i}),[r,i]);return o.jsxs(xT.Provider,{value:s,children:[e,t&&o.jsx(RV,{selection:t,onClose:i})]})}function mT(){const e=f.useContext(xT);if(!e)throw new Error("useTaskModal must be used within a TaskModalProvider");return e}const py={en:{title:"Notes",inputPlaceholder:"Note something to do…",quickPlaceholder:"Quick note…",todo:"TO DO",completed:"Completed",clear:"Clear",handoff:"Hand to agent",edit:"Edit",save:"Save",cancel:"Cancel",delete:"Delete",viewAll:"View all",empty:"No open notes",privateHint:"Private reminder · agents do not read this file",enter:"↵",escape:"esc"},zh:{title:"笔记",inputPlaceholder:"记一条要干什么…",quickPlaceholder:"快速记一条…",todo:"待办",completed:"已完成",clear:"清除",handoff:"交给 agent",edit:"编辑",save:"保存",cancel:"取消",delete:"删除",viewAll:"查看全部",empty:"没有未完成笔记",privateHint:"私人备忘 · agent 不读取此文件",enter:"↵",escape:"esc"}};function IV(e,t){return e===1?t==="zh"?"昨天":"yesterday":t==="zh"?`${Math.max(2,e)} 天前`:`${Math.max(2,e)}d`}function MV(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function LV(e){const t=String(e.getHours()).padStart(2,"0"),n=String(e.getMinutes()).padStart(2,"0");return`${t}:${n}`}function OV(e,t,n){const r=Date.parse(e);if(Number.isNaN(r))return"—";const i=new Date(r);if(MV(i,new Date(t)))return LV(i);const s=Math.max(1,Math.floor((t-r)/864e5));return IV(s,n)}function DV(e,t,n){return{...e,timeLabel:OV(e.createdAt,t,n)}}function vT(e,t,n){const r=e.map(a=>DV(a,t,n)),i=r.filter(a=>!a.completed),s=r.filter(a=>a.completed);return{active:i,completed:s,previews:i.slice(0,3),activeCount:i.length,completedCount:s.length}}function AV(e){return(e.metaKey||e.ctrlKey)&&e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="n"}const yT=f.createContext(null);function NV(e){const[t,n]=f.useState(!1),[r,i]=f.useState(null),s=f.useCallback(l=>{i(l??null),n(!0)},[]),a=f.useCallback(()=>{n(!1),i(null)},[]);return f.useEffect(()=>a(),[e,a]),f.useEffect(()=>{const l=c=>{AV(c)&&(c.preventDefault(),i(null),n(d=>!d))};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[]),{isOpen:t,targetId:r,open:s,close:a}}function $V(e){const t=ae(),n=je(),r=()=>n.invalidateQueries(t.notes.list.queryFilter({projectId:e})),i=ue(t.notes.add.mutationOptions({onSettled:r})),s=ue(t.notes.update.mutationOptions({onSettled:r})),a=ue(t.notes.setCompleted.mutationOptions({onSettled:r})),l=ue(t.notes.delete.mutationOptions({onSettled:r})),c=ue(t.notes.clearCompleted.mutationOptions({onSettled:r}));return{busy:i.isPending||s.isPending||a.isPending||l.isPending||c.isPending,add:d=>i.mutateAsync({projectId:e,text:d}),update:(d,u)=>s.mutateAsync({projectId:e,id:d,text:u}),setCompleted:(d,u)=>a.mutateAsync({projectId:e,id:d,completed:u}),remove:async d=>{await l.mutateAsync({projectId:e,id:d})},clearCompleted:async()=>{await c.mutateAsync({projectId:e})}}}function _V({children:e}){const t=ae(),n=ft(),{currentProjectId:r}=$i(),{prefillDraft:i}=_s(),s=r??"",a=NV(s),l=$V(s),c=G({...t.notes.list.queryOptions({projectId:s}),enabled:!!s}),d=f.useMemo(()=>vT(c.data??[],Date.now(),n),[c.data,n]),u=f.useMemo(()=>({copy:py[n],vm:d,...a,...l,handoff:p=>{i(p),a.close()}}),[n,d,a,l,i]);return o.jsx(yT.Provider,{value:u,children:e})}function lh(){const e=f.useContext(yT);if(!e)throw new Error("useNotes must be used within NotesProvider");return e}function FV(){const{open:e,setOpen:t}=mH();return o.jsx(T3,{children:o.jsx(hT,{children:o.jsx(uq,{children:o.jsx(yq,{children:o.jsx(_V,{children:o.jsx($H,{children:o.jsx(XH,{children:o.jsx(lq,{children:o.jsx(_z,{children:o.jsx(Iq,{children:o.jsx(VU,{children:o.jsx(PV,{children:o.jsx(DB,{children:o.jsx(q6,{children:o.jsxs(X6,{children:[o.jsx(y$,{}),o.jsx(xH,{open:e,onOpenChange:t}),o.jsx(Wq,{}),o.jsx(tV,{}),o.jsx(iV,{})]})})})})})})})})})})})})})})})}function zV({title:e}){const t=B();return o.jsxs("section",{className:"flex h-full flex-col p-2g",children:[o.jsx("h1",{className:"mb-2g text-body font-medium text-state-ink",children:e}),o.jsx(lp,{title:t.shNothingHere,className:"flex-1"})]})}const bT="'IBM Plex Mono',monospace",BV="Click an image or file to preview it here.";function WV({item:e}){const{src:t,failed:n}=U6(e),{containerRef:r,contentRef:i,style:s}=K0({mode:"transform",minScale:1,maxScale:8});return n?o.jsxs(Dm,{failed:!0,children:["Failed to load ",e.name]}):t?o.jsx("div",{ref:r,style:{flex:1,minHeight:0,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",padding:12,boxSizing:"border-box"},children:e.kind==="video"?o.jsx("video",{src:t,controls:!0,playsInline:!0,style:{maxWidth:"100%",maxHeight:"100%",borderRadius:8,background:"#000"}}):o.jsx("div",{ref:i,style:{...s,display:"inline-block",maxWidth:"100%",maxHeight:"100%"},children:o.jsx("img",{src:t,alt:e.name,draggable:!1,style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain",display:"block"}})})}):o.jsx(Dm,{children:"Loading…"})}function Dm({children:e,failed:t}){return o.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"32px 20px",textAlign:"center",color:t?"var(--proto-faint)":"var(--proto-muted-2)",font:`500 12px ${bT}`},children:e})}function UV({item:e,split:t,onClose:n,onResizeStart:r,onDownload:i,rootRef:s}){const a=!!e&&qj(e),l=e?B6(e):null;return o.jsxs("div",{ref:s,"data-pane":"preview",style:{flexGrow:t,flexShrink:1,flexBasis:0,minWidth:0,display:"flex",flexDirection:"column",minHeight:0,background:"var(--proto-card)",borderLeft:"1px solid var(--proto-line)",position:"relative"},children:[o.jsx("div",{role:"separator","aria-orientation":"vertical",title:"Drag to resize",onMouseDown:r,style:{position:"absolute",left:-3,top:0,bottom:0,width:6,cursor:"col-resize",zIndex:3}}),o.jsxs("div",{style:{height:50,flex:"none",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:8,padding:"0 12px"},children:[o.jsx("span",{title:e==null?void 0:e.name,style:{flex:1,minWidth:0,font:`600 11.5px ${bT}`,color:"var(--proto-ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(e==null?void 0:e.name)??"Preview"}),l&&o.jsx("span",{role:"button",title:"Download",onClick:i,style:jw,children:"↓"}),o.jsx("span",{role:"button",title:"Unpin preview",onClick:n,style:{...jw,fontSize:16},children:"×"})]}),o.jsx("div",{style:a?{flex:1,minHeight:0,overflow:"auto",background:(e==null?void 0:e.kind)==="pdf"?"var(--proto-gray)":"var(--proto-card)"}:{flex:1,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:e?qj(e)?e.kind==="pdf"?o.jsx(Y6,{item:e}):o.jsx(G6,{item:e}):o.jsx(WV,{item:e}):o.jsx(Dm,{children:BV})})]})}const jw={width:28,height:28,borderRadius:8,border:"1px solid var(--proto-line)",background:"var(--proto-card)",color:"var(--proto-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,cursor:"pointer",flex:"none",userSelect:"none"};function HV(){const{pinned:e,item:t,split:n,unpin:r,setSplit:i,registerHost:s}=oh(),a=f.useRef(null),l=Il();f.useEffect(()=>s(),[s]);const c=u=>{u.preventDefault();const p=a.current,h=p==null?void 0:p.previousElementSibling;if(!p||!h)return;const g=p.getBoundingClientRect(),v=h.getBoundingClientRect(),x=v.left,w=v.width+g.width;let b=n;const y=S=>{b=MB(x,w,S.clientX),i(b)},j=()=>{window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",j),document.body.style.userSelect="",i(b,!0)};document.body.style.userSelect="none",window.addEventListener("mousemove",y),window.addEventListener("mouseup",j)};if(!e)return null;const d=t?B6(t):null;return o.jsx(UV,{rootRef:a,item:t,split:n,onClose:r,onResizeStart:c,onDownload:d&&t?()=>l(d,t.name):void 0})}function hp(e){const t=Date.parse(e.lastUsedAt||e.createdAt);return Number.isNaN(t)?0:t}function of(e){const t=new Date(e);return Math.floor(new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()/864e5)}function jT(e,t){const n=typeof t=="number"?t:t.getTime(),r=of(n),i={TODAY:[],YESTERDAY:[],EARLIER:[]};for(const a of e){const l=of(hp(a)),c=l>=r?"TODAY":l===r-1?"YESTERDAY":"EARLIER";i[c].push(a)}return["TODAY","YESTERDAY","EARLIER"].map(a=>({label:a,items:i[a].sort((l,c)=>+!!c.unread-+!!l.unread||hp(c)-hp(l))})).filter(a=>a.items.length>0)}function qV(e,t){switch(t){case"TODAY":return e.wbSessionToday;case"YESTERDAY":return e.wbSessionYesterday;case"EARLIER":return e.wbSessionEarlier}}function Fu(e){return e<10?"0"+e:""+e}function VV(e,t,n=Date.now()){const r=ch(t,n);return t.kind==="scheduled"?r+" · "+e.wbFromSchedule:r}function ch(e,t=Date.now()){const n=typeof t=="number"?t:t.getTime(),r=hp(e),i=new Date(r),s=Fu(i.getHours())+":"+Fu(i.getMinutes());return(of(r)<of(n)-1?(i.getFullYear()===new Date(n).getFullYear()?"":i.getFullYear()+"-")+Fu(i.getMonth()+1)+"-"+Fu(i.getDate())+" ":"")+s}function Ll(e){const t=e.split(/[-_]/).filter(Boolean);return t.length>=2?(t[0][0]+t[1][0]).toUpperCase():t.length===1?t[0].slice(0,2).toUpperCase():"?"}const KV=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function sf(e){if(e.type==="daily")return e.time?`daily ${e.time}`:"daily";if(e.type==="weekly"){const t=e.dayOfWeek!=null?KV[e.dayOfWeek]:null;return t&&e.time?`weekly ${t} ${e.time}`:"weekly"}return e.type==="interval"?e.intervalMs!=null&&e.intervalMs>0?`every ${sy(e.intervalMs)}`:"interval":"once"}function fy(e,t){if(!e)return null;const n=Date.parse(e);return Number.isNaN(n)?null:sy(n-t)}function QV(e){switch(e){case"running":return{bg:"#EEF0FA",fg:"#4655D4",text:"Running"};case"waiting":return{bg:"#F7ECCE",fg:"#8A5B06",text:"Waiting"};case"completed":return{bg:"#E9F4EE",fg:"#23854F",text:"Done"};case"failed":return{bg:"#FBEDEB",fg:"#C03D33",text:"Failed"};default:return{bg:"#F1F2F5",fg:"#8A93A2",text:"Cancelled"}}}function GV(e){return e.status==="completed"?"done":e.status==="running"?"running":"pending"}function qr(e){return"$"+e.toFixed(2)}function YV(e){const t=Math.round(e);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;return r===0?`${n}m`:`${n}m ${r}s`}function XV(e){const t=[];return e.durationS!=null&&t.push(YV(e.durationS)),e.costUsd!=null&&t.push(qr(e.costUsd)),t.join(" · ")}function JV(e){return e.runName?`cortex-run ${e.runName}`:"cortex-run"}function ZV(e){return e==="running"?{label:"Running",tone:"running"}:e==="completed"?{label:"Done",tone:"done"}:e==="failed"||e==="cancelled"?{label:"Failed",tone:"failed"}:{label:e||"Unknown",tone:"idle"}}function eK(e){return e.status==="done"?{label:"Done",tone:"done"}:e.blockedBy?{label:"Blocked",tone:"failed"}:e.claimedBy?{label:"Running",tone:"running"}:e.actionable?{label:"Open",tone:"idle"}:{label:"Waiting",tone:"idle"}}function wT(e,t){const n=Math.max(0,Math.round((t-Date.parse(e))/1e3));if(n<60)return"just now";const r=Math.floor(n/60);if(r<60)return`${r}m`;const i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function tK(e,t){const n=[e.id];return e.taskId&&n.push(`task ${e.taskId}`),e.currentStep&&n.push(`step ${e.currentStep.index+1}/${e.totalSteps}`),n.push(wT(e.createdAt,t)),n.join(" · ")}function nK(e){const t=U0(e.children);return{filled:t,total:Ms,text:`${t}/${Ms}`}}function rK(e){return e?e.filter(t=>t.online).length:0}function oK(e){return e?{bg:"#E9F4EE",fg:"#23854F",text:"Online"}:{bg:"#F1F2F5",fg:"#8A93A2",text:"Offline"}}function Am(e){const t=Date.parse(e.lastUsedAt||e.createdAt);return Number.isNaN(t)?0:t}function iK(e){const t=new Map;for(const n of e){if(n.origin!=="scheduled"||n.scheduleId==null)continue;const r=t.get(n.scheduleId)??[];r.push(n),t.set(n.scheduleId,r)}for(const n of t.values())n.sort((r,i)=>Am(i)-Am(r));return t}function ww(e){var r;if(e.latest)return Am(e.latest);const t=(r=e.schedule)==null?void 0:r.lastRun,n=t?Date.parse(t):NaN;return Number.isNaN(n)?0:n}function kT(e,t,n){var s,a;const r=iK(t),i=[];for(const l of e){const c=r.get(l.id)??[];r.delete(l.id),i.push({scheduleId:l.id,schedule:l,title:l.message.trim()||(((s=c[0])==null?void 0:s.label)??((a=c[0])==null?void 0:a.name)??l.id),kind:l.type==="once"?"once":"repeat",runs:c,latest:c[0]??null,unread:c.some(d=>d.unread)})}for(const[l,c]of r)i.push({scheduleId:l,schedule:null,title:c[0].label??c[0].name,kind:c.length>1?"repeat":"once",runs:c,latest:c[0],unread:c.some(d=>d.unread)});return i.sort((l,c)=>ww(c)-ww(l))}function hy(e){const t=[...e].sort((r,i)=>Date.parse(r.createdAt)-Date.parse(i.createdAt)),n=new Map;return t.forEach((r,i)=>n.set(r.sessionId,i+1)),n}function ST(e){return e.runs.length===0?{type:"edit"}:e.kind==="once"?{type:"open",sessionId:e.runs[0].sessionId}:{type:"modal"}}function CT(e,t){var r;if((r=e.schedule)!=null&&r.paused)return{kind:"paused",cadence:sf(e.schedule)};if(e.latest)return{kind:"run",stamp:ch(e.latest,t),cost:e.latest.costUsd!=null?qr(e.latest.costUsd):null};const n=e.schedule;return{kind:"pending",cadence:n?sf(n):"",nextDelta:n?fy(n.nextRun,t):null}}function TT(e,t,n){if(!e)return null;const r=hy(t).get(n);return r==null?null:`${e.message} · run #${r}`}function ET(e){return e.filter(t=>t.unread).length}const ta="'IBM Plex Mono',monospace",kw={display:"grid",gridTemplateColumns:"64px 1fr 76px",gap:10,padding:"9px 18px",alignItems:"center"};function sK({row:e,selectedSessionId:t,onOpenRun:n,onManage:r,onClose:i}){const s=B();f.useEffect(()=>{const p=h=>{h.key==="Escape"&&i()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[i]);const a=Date.now(),l=hy(e.runs),c=e.schedule,d=c?fy(c.nextRun,a):null,u=c?sf(c)+(c.paused?` · ${s.wbSchedPausedPill}`:d?` · ${s.wbSchedNextRun.replace("{d}",d)}`:""):null;return o.jsxs(o.Fragment,{children:[o.jsx("div",{"data-backdrop":"run-list",onClick:i,style:{position:"fixed",inset:0,background:"rgba(25,28,34,.34)",zIndex:60,animation:"cxfade .18s ease"}}),o.jsxs("div",{"data-modal":"run-list",style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",width:400,maxWidth:"calc(100vw - 40px)",background:"var(--proto-card)",borderRadius:14,boxShadow:"0 24px 60px rgba(10,14,24,.35)",zIndex:61,display:"flex",flexDirection:"column",maxHeight:"min(560px, calc(100vh - 80px))"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"15px 18px 12px",borderBottom:"1px solid var(--proto-line)",flex:"none"},children:[o.jsxs("svg",{width:13,height:13,viewBox:"0 0 14 14",fill:"none",stroke:"var(--proto-accent)",strokeWidth:1.6,style:{flex:"none"},children:[o.jsx("circle",{cx:"7",cy:"7",r:"5.6"}),o.jsx("path",{d:"M7 4v3.2l2.2 1.3"})]}),o.jsxs("div",{style:{minWidth:0},children:[o.jsx("div",{style:{fontSize:13.5,fontWeight:650,color:"var(--proto-ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),u&&o.jsx("div",{style:{font:`400 10px ${ta}`,color:"var(--proto-muted-3)",marginTop:2},children:u})]}),c&&r&&o.jsx("span",{"data-action":"run-list-manage",onClick:r,style:{marginLeft:"auto",fontSize:10.5,fontWeight:600,color:"var(--proto-accent)",flex:"none",cursor:"pointer"},children:s.wbSchedManage}),o.jsx("span",{"data-action":"run-list-close",onClick:i,style:{marginLeft:c&&r?0:"auto",fontSize:12,color:"var(--proto-muted-3)",flex:"none",cursor:"pointer",padding:"0 2px"},children:"✕"})]}),o.jsxs("div",{style:{...kw,padding:"8px 18px 6px",font:`600 9.5px ${ta}`,color:"var(--proto-muted-3)",letterSpacing:".05em",flex:"none"},children:[o.jsx("span",{children:"RUN"}),o.jsx("span",{children:"FIRED"}),o.jsx("span",{style:{textAlign:"right"},children:"COST"})]}),o.jsx("div",{style:{overflowY:"auto",minHeight:0},children:e.runs.map((p,h)=>{const g=p.sessionId===t;return o.jsxs("div",{"data-run-row":p.sessionId,onClick:()=>n(p.sessionId),style:{...kw,cursor:"pointer",background:g?"var(--proto-accent-bg)":"transparent",borderTop:h===0?"none":"1px solid var(--proto-gray)"},children:[o.jsxs("span",{style:{font:`${p.unread?600:400} 11px ${ta}`,color:p.unread?"var(--proto-ink)":"var(--proto-muted)",display:"flex",alignItems:"center",gap:6},children:["#",l.get(p.sessionId),p.unread&&o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)"}})]}),o.jsx("span",{style:{font:`400 11px ${ta}`,color:"var(--proto-muted-2)"},children:ch(p,a)}),o.jsx("span",{style:{font:`400 11px ${ta}`,color:"var(--proto-muted-3)",textAlign:"right"},children:p.costUsd!=null?qr(p.costUsd):"—"})]},p.sessionId)})}),o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 18px 13px",borderTop:"1px solid var(--proto-line)",flex:"none"},children:[o.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--proto-muted-2)"},children:s.wbAllRuns.replace("{n}",String(e.runs.length))}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${ta}`,color:"var(--proto-muted-3)"},children:s.wbSchedRunListHint})]})]})]})}const aK=new Set(["running","waiting"]);function lK(e){const t={};for(const n of e)aK.has(n.status)&&(t[n.projectId]=(t[n.projectId]??0)+1);return t}function RT(e){const t={};for(const n of e)n.unread&&(t[n.projectId]=(t[n.projectId]??0)+1);return t}function PT(e){const t={};for(const n of e)n.awaitingInput&&(t[n.projectId]=(t[n.projectId]??0)+1);return t}function IT(e,t){const n=e+t;return{count:n,tone:t>0?"action":n>0?"unread":null}}function cK(e,t){const n=Math.max(0,t-e);return n<6e4?"now":n<36e5?Math.floor(n/6e4)+"m":n<864e5?Math.floor(n/36e5)+"h":Math.floor(n/864e5)+"d"}function MT(e){const t={};for(const n of e){const r=Date.parse(n.lastUsedAt||n.createdAt);Number.isNaN(r)||(!(n.projectId in t)||r>t[n.projectId])&&(t[n.projectId]=r)}return t}function LT(e,t){const n=r=>typeof t[r]=="number"?t[r]:-1/0;return[...e].sort((r,i)=>{const s=n(r.id),a=n(i.id);return s===a?0:a-s})}function dK(e){const t=e.split(/[-_]/).filter(Boolean);return t.length<=2?e:t[0]+"-"+t[1]}function uK(e){return e.length!==1||e<"1"||e>"9"?null:e.charCodeAt(0)-49}const Nm=322,pK=120,fK=560;function OT(e){return Number.isFinite(e)?Math.min(fK,Math.max(pK,e)):Nm}function hK(e,t,n,r,i,s,a={}){return e.map((l,c)=>{const d=l.id===t,u=n[l.id]??0,p=r[l.id]??0,h=a[l.id]??0,g=IT(p,h),v=u>0||g.count>0,x=i[l.id],w=!d&&!v&&typeof x=="number"?cK(x,s):null;return{id:l.id,initials:Ll(l.id),active:d,running:u,unread:p,actionRequired:h,badgeCount:g.count,badgeTone:g.tone,hotkey:w===null&&c<9?"⌘"+(c+1):null,idleAge:w}})}const gK="context/projects/",xK="nimbus";function Sw(e){return e.trim().length>0}function mK(e){const t=e&&typeof e=="object"&&"message"in e?e.message:void 0;return typeof t=="string"&&t.trim().length>0?t:"Could not create project."}const Ig="'IBM Plex Mono',monospace";function vK({onClose:e}){const t=ae(),n=B(),r=je(),[i,s]=f.useState(""),[a,l]=f.useState(null),[c,d]=f.useState(!1),u=f.useRef(null),p=ue(t.projects.create.mutationOptions({onSuccess:()=>{r.invalidateQueries(t.projects.list.queryFilter()),e()},onError:v=>l(mK(v))})),h=()=>{!Sw(i)||p.isPending||(l(null),p.mutate({name:i.trim()}))};f.useEffect(()=>{const v=x=>{x.key==="Escape"&&e()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[e]);const g=Sw(i);return o.jsxs(o.Fragment,{children:[o.jsx("div",{onClick:e,style:{position:"fixed",inset:0,background:"rgba(25,28,34,.34)",zIndex:60,animation:"cxfade .18s ease"}}),o.jsxs("div",{"data-modal":"newproj",style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)",width:540,background:"var(--proto-card)",borderRadius:14,boxShadow:"0 24px 64px rgba(16,24,40,.3)",zIndex:61,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"14px 20px 0"},children:[o.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--proto-ink)"},children:n.newProject}),o.jsx("span",{style:{font:`400 10px ${Ig}`,color:"var(--proto-muted-3)",marginLeft:10},children:gK}),o.jsx("span",{onClick:e,style:{marginLeft:"auto",font:`500 9.5px ${Ig}`,color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),o.jsxs("div",{style:{padding:"16px 20px 0"},children:[o.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",marginBottom:6},children:n.npProjectName}),o.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,border:"1.5px solid var(--proto-accent-border)",borderRadius:9,padding:"9px 12px"},children:o.jsx("input",{ref:u,value:i,onChange:v=>{s(v.target.value),a&&l(null)},onKeyDown:v=>{v.key==="Enter"&&h()},autoFocus:!0,placeholder:xK,style:{flex:1,font:`500 13px ${Ig}`,color:"var(--proto-ink)"}})}),o.jsx("div",{style:{fontSize:10.5,color:a?"var(--proto-danger)":"var(--proto-muted-3)",marginTop:8,lineHeight:1.6},children:a??n.npHint})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"16px 20px 16px",justifyContent:"flex-end"},children:[o.jsx("span",{onClick:e,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),style:{fontSize:11.5,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"6px 13px",color:"var(--proto-ink)",cursor:"pointer",background:c?"var(--proto-alt)":"transparent"},children:n.cancel}),o.jsx("span",{onClick:h,style:{fontSize:11.5,fontWeight:600,borderRadius:8,padding:"7px 15px",color:"var(--ink-solid-fg)",background:g?"#4655D4":"#C9CFF2",cursor:g&&!p.isPending?"pointer":"default"},children:n.npCreate})]})]})]})}const yK="connect.html";function bK(){var e;return(e=globalThis.__TAURI__)==null?void 0:e.core}async function jK(e){var t;try{await((t=e.invoke)==null?void 0:t.call(e,"disconnect"))}catch{}finally{e.navigate(yK)}}async function DT(){if(!on())return;const e=bK();await jK({invoke:e?t=>e.invoke(t):void 0,navigate:t=>{window.location.href=t}})}function Cw(e){return e==="running"?"var(--proto-success)":e==="unknown"?"var(--proto-amber)":"var(--proto-danger)"}function wK(e){return e==="running"?"var(--proto-success-bg)":e==="unknown"?"var(--pill-waiting-bg)":"var(--proto-danger-bg)"}function kK({open:e,onClose:t}){const n=ae(),r=je(),i=B(),[s,a]=f.useState(!1),l=G({...n.system.daemonStatus.queryOptions({}),enabled:e,refetchInterval:e?5e3:!1}),c=ue({...n.system.restart.mutationOptions({onSuccess:()=>{a(!1),r.invalidateQueries(n.system.daemonStatus.queryFilter())},onError:()=>{a(!1)}})}),d=l.data,u=(d==null?void 0:d.processes)??[],p=d==null?void 0:d.lastRestart,h=()=>c.mutate({kind:"soft"}),g=()=>c.mutate({kind:"hard"});return e?o.jsxs(o.Fragment,{children:[o.jsx("div",{onClick:t,style:{position:"fixed",inset:0,zIndex:40,background:"rgba(25, 28, 34, 0.40)"}}),o.jsxs("div",{style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)",zIndex:50,width:470,background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:14,boxShadow:"0 8px 24px rgba(16,24,40,.10)",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"16px 20px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("div",{"aria-label":"Cortex",style:{width:28,height:28,borderRadius:8,background:"var(--brand-badge-bg)",border:"1px solid var(--brand-badge-border)",display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsxs("svg",{width:20,height:20,viewBox:"0 0 64 64",fill:"none","aria-hidden":"true",children:[o.jsx("circle",{cx:33,cy:32,r:6,fill:"var(--brand-badge-core)"}),o.jsx("path",{d:"M42.29 23.64A12.5 12.5 0 1 0 42.29 40.36",stroke:"var(--brand-badge-arc)",strokeWidth:6,strokeLinecap:"round"}),o.jsx("path",{d:"M48.6 17.95A21 21 0 1 0 48.6 46.05",stroke:"var(--brand-badge-arc)",strokeWidth:6,strokeLinecap:"round"})]})}),o.jsxs("div",{style:{minWidth:0},children:[o.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--proto-ink)"},children:i.dmDaemon}),o.jsx("div",{style:{font:"400 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",marginTop:1},children:"local"})]}),o.jsx("span",{onClick:t,style:{marginLeft:"auto",font:"500 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),o.jsxs("div",{style:{padding:"14px 20px",display:"flex",flexDirection:"column",gap:10},children:[l.isLoading&&o.jsx("div",{style:{fontSize:12,color:"var(--proto-muted-3)",textAlign:"center",padding:20},children:"Loading…"}),l.isError&&o.jsx("div",{style:{fontSize:12,color:"var(--proto-danger)",textAlign:"center",padding:20},children:"Failed to load daemon status"}),u.map(v=>{const x=v.status;return o.jsxs("div",{style:{border:"1px solid var(--proto-line)",borderRadius:10,padding:"11px 14px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:Cw(x),flex:"none",...x==="unknown"?{animation:"cxpulse 2s ease-in-out infinite"}:{}}}),o.jsx("span",{style:{font:"600 12px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:v.name}),o.jsx("span",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:v.label}),o.jsx("span",{style:{marginLeft:"auto",fontSize:10.5,fontWeight:600,padding:"2px 8px",borderRadius:999,background:wK(x),color:Cw(x)},children:x})]}),o.jsxs("div",{style:{display:"flex",gap:14,marginTop:8,font:"400 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",flexWrap:"wrap"},children:[v.uptime&&o.jsxs("span",{children:[o.jsxs("span",{style:{color:"var(--proto-muted-3)"},children:[i.dmUp," "]}),v.uptime]}),v.pid!=null&&o.jsxs("span",{children:[o.jsxs("span",{style:{color:"var(--proto-muted-3)"},children:[i.dmPid," "]}),v.pid]}),v.port!=null&&o.jsxs("span",{children:[o.jsxs("span",{style:{color:"var(--proto-muted-3)"},children:[i.dmPort," "]}),":",v.port]}),v.extras&&Object.entries(v.extras).map(([w,b])=>o.jsxs("span",{children:[o.jsxs("span",{style:{color:"var(--proto-muted-3)"},children:[w," "]}),b]},w))]})]},v.name)}),(p==null?void 0:p.at)&&o.jsxs("div",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",padding:"0 2px"},children:[i.dmLastRestart," ",new Date(p.at).toLocaleDateString()," ",new Date(p.at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),p.reason?` · ${i.dmReason}: ${p.reason}`:""]})]}),!s&&o.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"12px 20px",display:"flex",flexDirection:"column",gap:8},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--proto-ink)"},children:i.dmSoftRestart}),o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-muted-2)",marginTop:1},children:i.dmSoftRestartDesc})]}),o.jsx("span",{onClick:h,style:{flex:"none",fontSize:11.5,fontWeight:600,color:"var(--proto-ink)",border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",borderRadius:8,padding:"6px 14px",cursor:c.isPending?"default":"pointer",opacity:c.isPending?.5:1},children:i.dmSoftRestart})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--proto-danger)"},children:i.dmHardRestart}),o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-muted-2)",marginTop:1},children:i.dmHardRestartDesc})]}),o.jsx("span",{onClick:()=>a(!0),style:{flex:"none",fontSize:11.5,fontWeight:600,color:"var(--proto-danger)",border:"1px solid var(--proto-danger-bg)",background:"var(--proto-danger-bg)",borderRadius:8,padding:"6px 14px",cursor:"pointer"},children:i.dmHardRestart})]})]}),s&&o.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"12px 20px",display:"flex",flexDirection:"column",gap:10},children:[o.jsxs("div",{style:{border:"1px solid var(--proto-amber-border)",background:"var(--proto-amber-bg)",borderRadius:9,padding:"10px 14px"},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--proto-amber-fg)"},children:i.dmHardConfirm}),o.jsx("div",{style:{fontSize:11.5,color:"var(--proto-muted)",marginTop:4,lineHeight:1.5},children:i.dmHardConfirmDetail})]}),o.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[o.jsx("span",{onClick:()=>a(!1),style:{fontSize:11.5,fontWeight:600,color:"var(--proto-ink)",border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",borderRadius:8,padding:"6px 14px",cursor:"pointer"},children:i.dmConfirmCancel}),o.jsx("span",{onClick:g,style:{fontSize:11.5,fontWeight:600,color:"var(--ink-solid-fg)",background:"var(--proto-danger)",borderRadius:8,padding:"6px 14px",cursor:c.isPending?"default":"pointer",opacity:c.isPending?.5:1},children:c.isPending?"...":i.dmConfirmProceed})]})]}),c.isSuccess&&o.jsx("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"10px 20px",fontSize:11.5,color:"var(--proto-success)",fontWeight:600},children:i.dmRestartSent}),c.isError&&o.jsx("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"10px 20px",fontSize:11.5,color:"var(--proto-danger)",fontWeight:600},children:i.dmRestartFailed}),on()&&o.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"12px 20px",display:"flex",alignItems:"center",gap:10},children:[o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--proto-ink)"},children:i.dmDisconnect}),o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-muted-2)",marginTop:1},children:i.dmDisconnectDesc})]}),o.jsx("span",{onClick:()=>void DT(),style:{flex:"none",fontSize:11.5,fontWeight:600,color:"var(--proto-ink)",border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",borderRadius:8,padding:"6px 14px",cursor:"pointer"},children:i.dmDisconnect})]})]})]}):null}const SK=["session.status","session.interaction","session.context-usage","session.context-compacted"];function gy(){const e=ae(),t=je();Ni(SK,()=>{t.invalidateQueries(e.sessions.list.queryFilter())})}const $m="0806-1741·5b3f695";function CK(e){return e==="five_hour"?"5h":e==="seven_day"||e==="seven_day_overage_included"?"7d":e.replaceAll("_"," ")}function _m(e){const t=Math.max(1,Math.ceil(e/60)),n=Math.floor(t/1440),r=Math.floor(t%1440/60),i=t%60;return n>0?r>0?`${n}d ${r}h`:`${n}d`:r>0?i>0?`${r}h ${i}m`:`${r}h`:`${i}m`}function TK(e,t,n){return n==="zh"?`${e} 个会话 · ${t} 个线程等待恢复`:`${e} ${e===1?"session":"sessions"} · ${t} ${t===1?"thread":"threads"} waiting`}function EK(e,t,n){const r=e.windows.filter(l=>l.resetsAt>t).sort((l,c)=>l.resetsAt-c.resetsAt||l.type.localeCompare(c.type)).map(l=>({type:l.type,typeLabel:CK(l.type),utilization:l.utilization,resetsAt:l.resetsAt,countdown:_m(l.resetsAt-t)}));if(r.length===0)return null;const i=Math.max(...r.map(l=>l.resetsAt)),s=e.waitingSessions??0,a=e.waitingThreads??0;return{provider:e.provider,displayName:e.displayName,recoveryAt:i,recoveryCountdown:_m(i-t),waitingSessions:s,waitingThreads:a,waitingLabel:TK(s,a,n),windows:r}}function RK(e){return`${e.displayName} · ${e.recoveryCountdown}`}function PK(e,t,n){return n==="zh"?`${e} 个 provider 限流 · 首个 ${t}`:`${e} providers limited · first ${t}`}function IK(e,t,n){const r=((e==null?void 0:e.providers)??[]).map(a=>EK(a,t,n)).filter(a=>a!==null).sort((a,l)=>a.displayName.localeCompare(l.displayName)||a.provider.localeCompare(l.provider));if(r.length===0)return null;const i=Math.min(...r.map(a=>a.recoveryAt)),s=_m(i-t);return{lang:n,firstRecoveryAt:i,providers:r,label:r.length===1?RK(r[0]):PK(r.length,s,n)}}function Mg(){return Math.floor(Date.now()/1e3)}function AT(){var d;const e=ae(),t=je(),n=ft(),r=G(e.system.rateLimitStatus.queryOptions({})),{reconnectEpoch:i}=ry(),[s,a]=f.useState(Mg),l=()=>{t.invalidateQueries(e.system.rateLimitStatus.queryFilter())};Ni(C3,l),f.useEffect(()=>{i>0&&l()},[i]);const c=(((d=r.data)==null?void 0:d.providers.length)??0)>0;return f.useEffect(()=>{if(!c)return;a(Mg());const u=window.setInterval(()=>a(Mg()),3e4);return()=>window.clearInterval(u)},[c]),IK(r.data,s,n)}const m={canvas:"var(--m-canvas)",card:"var(--m-card)",ink:"var(--m-ink)",sub:"var(--m-sub)",body:"var(--m-body)",muted:"var(--m-muted)",faint:"var(--m-faint)",hairline:"var(--m-hairline)",divider:"var(--m-divider)",cardBorder:"var(--m-card-border)",run:"var(--m-run)",runBg:"var(--m-run-bg)",runBorder:"var(--m-run-border)",amber:"var(--m-amber)",amberInk:"var(--m-amber-ink)",amberText:"var(--m-amber-text)",amberBg:"var(--m-amber-bg)",amberBorder:"var(--m-amber-border)",amberCard:"var(--m-amber-card)",done:"var(--m-done)",doneBg:"var(--m-done-bg)",fail:"var(--m-fail)",failBg:"var(--m-fail-bg)",failBorder:"var(--m-fail-border)",gray:"var(--m-gray)",grayInk:"var(--m-gray-ink)",inkSolid:"var(--ink-solid-bg)",inkSolidFg:"var(--ink-solid-fg)",inkSolidFgDim:"var(--ink-solid-fg-dim)"},A="'IBM Plex Mono', ui-monospace, Menlo, monospace";function vt({header:e,footer:t,children:n,label:r,style:i}){return o.jsxs("div",{"data-screen-label":r,style:{height:"100%",display:"flex",flexDirection:"column",boxSizing:"border-box",background:m.canvas,...i},children:[e,o.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",background:m.canvas},children:n}),t]})}function dh({title:e,qn:t,trailing:n,below:r}){return o.jsxs("div",{style:{flex:"none",borderBottom:`1px solid ${m.hairline}`,background:m.canvas,padding:"6px 14px 10px",paddingTop:"calc(6px + env(safe-area-inset-top))"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[o.jsx("span",{style:{fontSize:22,fontWeight:700,color:m.ink,letterSpacing:"-.02em",flex:"none"},children:e}),t&&o.jsx("span",{style:{font:`600 9.5px ${A}`,color:m.run,background:m.runBg,padding:"2px 7px",borderRadius:4,marginLeft:9,flex:"none"},children:t}),n&&o.jsx("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center"},children:n})]}),r]})}function zn({onBack:e,children:t,trailing:n}){return o.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",gap:9,borderBottom:`1px solid ${m.hairline}`,background:m.canvas,padding:"8px 14px 10px",paddingTop:"calc(8px + env(safe-area-inset-top))"},children:[o.jsx("button",{type:"button","aria-label":"Back",onClick:e,style:{border:"none",background:"transparent",color:m.run,fontSize:22,lineHeight:1,padding:"0 2px",margin:0,cursor:"pointer",flex:"none",minHeight:44,minWidth:30,display:"flex",alignItems:"center"},children:"‹"}),t,n&&o.jsx("div",{style:{marginLeft:"auto",flex:"none"},children:n})]})}function NT({onClick:e}){return o.jsx("button",{type:"button","aria-label":"More",onClick:e,style:{width:34,height:34,borderRadius:"50%",background:m.card,border:`1px solid ${m.hairline}`,display:"flex",alignItems:"center",justifyContent:"center",color:m.muted,fontSize:14,letterSpacing:1,cursor:"pointer"},children:"⋯"})}function En({children:e,gap:t=10}){return o.jsxs("div",{style:{padding:"12px 14px 0",display:"flex",flexDirection:"column",gap:t},children:[e,o.jsx("div",{style:{height:"calc(20px + env(safe-area-inset-bottom))",flex:"none"}})]})}const MK={default:m.cardBorder,blue:m.runBorder,amber:m.amberBorder,fail:m.failBorder};function Oe({tone:e="default",radius:t=12,padding:n="11px 13px",onClick:r,children:i,style:s}){return o.jsx("div",{onClick:r,style:{background:m.card,border:`1px solid ${MK[e]}`,borderRadius:t,padding:n,boxSizing:"border-box",cursor:r?"pointer":void 0,...s},children:i})}const LK={running:{bg:m.runBg,fg:m.run},waiting:{bg:m.amberBg,fg:m.amberInk},done:{bg:m.doneBg,fg:m.done},failed:{bg:m.failBg,fg:m.fail},cancelled:{bg:m.gray,fg:m.grayInk}};function Gt({tone:e,children:t}){const n=LK[e];return o.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:999,background:n.bg,color:n.fg,flex:"none",whiteSpace:"nowrap"},children:t})}function $T(e){switch(e){case"running":return"running";case"waiting":case"rate_limited":return"waiting";case"completed":case"done":return"done";case"failed":case"aborted":return"failed";case"cancelled":return"cancelled";default:return"running"}}function ho({color:e,size:t=6,pulse:n=!1,style:r}){return o.jsx("span",{style:{width:t,height:t,borderRadius:"50%",background:e,flex:"none",display:"inline-block",animation:n?"cxpulse 1.6s ease-in-out infinite":void 0,...r}})}function xl({children:e,style:t}){return o.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".07em",color:m.faint,padding:"0 2px 2px",...t},children:e})}const Lg=300,Tw="cubic-bezier(.32,.72,0,1)";function OK(e,t,n){return e>t*.28||n>.55}function Vr({onClose:e,children:t,behind:n}){var S;const r=f.useRef(null),[i,s]=f.useState("enter"),[a,l]=f.useState(0),[c,d]=f.useState(!1),u=f.useRef(null),p=f.useRef(!1);f.useEffect(()=>{let k=0;const E=requestAnimationFrame(()=>{k=requestAnimationFrame(()=>s("open"))});return()=>{cancelAnimationFrame(E),cancelAnimationFrame(k)}},[]);const h=f.useCallback(()=>{p.current||(p.current=!0,d(!1),s("exit"),window.setTimeout(e,Lg))},[e]);V0(h);const g=f.useCallback(k=>{var C,R;if(p.current)return;(R=(C=k.currentTarget).setPointerCapture)==null||R.call(C,k.pointerId);const E=performance.now();u.current={startY:k.clientY,lastY:k.clientY,lastT:E,v:0},d(!0)},[]),v=f.useCallback(k=>{const E=u.current;if(!E)return;const C=performance.now(),R=Math.max(0,k.clientY-E.startY),P=C-E.lastT;P>0&&(E.v=(k.clientY-E.lastY)/P),E.lastY=k.clientY,E.lastT=C,l(R)},[]),x=f.useCallback(()=>{var C;const k=u.current;u.current=null,d(!1);const E=((C=r.current)==null?void 0:C.offsetHeight)??320;OK(a,E,(k==null?void 0:k.v)??0)?h():l(0)},[a,h]),w=i==="enter"||i==="exit",b=w?"100%":`${a}px`,y=((S=r.current)==null?void 0:S.offsetHeight)??1,j=w?0:Math.max(0,.38*(1-a/y));return o.jsxs("div",{style:{position:"absolute",inset:0,boxSizing:"border-box"},children:[n&&o.jsx("div",{style:{position:"absolute",inset:0},children:n}),o.jsx("div",{onClick:h,style:{position:"absolute",inset:0,background:"rgba(25,28,34,1)",opacity:j,transition:c?"none":`opacity ${Lg}ms ${Tw}`}}),o.jsxs("div",{ref:r,style:{position:"absolute",left:0,right:0,bottom:0,background:"var(--proto-alt)",borderRadius:"18px 18px 0 0",boxShadow:"0 -14px 44px rgba(16,24,40,.28)",padding:"8px 14px 36px",paddingBottom:"calc(36px + env(safe-area-inset-bottom))",boxSizing:"border-box",transform:`translateY(${b})`,transition:c?"none":`transform ${Lg}ms ${Tw}`,touchAction:"none",willChange:"transform"},children:[o.jsx("div",{onPointerDown:g,onPointerMove:v,onPointerUp:x,onPointerCancel:x,style:{margin:"-8px -14px 0",padding:"10px 14px 6px",cursor:"grab",touchAction:"none"},children:o.jsx("div",{style:{width:36,height:5,borderRadius:999,background:"var(--proto-line-3)",margin:"0 auto 12px"}})}),t]})]})}function _T(e){return e===""?1:e.split(`
|
|
138
|
+
`).length}function DK(e){return[...e].length}function AK(e,t,n){return`${_T(e)} ${t} · ${DK(e)} ${n}`}const FT=20,zT=12,BT=46,Ew=5*FT+2*zT;function NK(){return o.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:m.muted,strokeWidth:"1.5",children:o.jsx("path",{d:"M6 1h3v3M4 9H1V6M9 1 5.8 4.2M1 9l3.2-3.2"})})}function $K(){return o.jsx("svg",{width:"11",height:"11",viewBox:"0 0 10 10",fill:"none",stroke:m.muted,strokeWidth:"1.5",children:o.jsx("path",{d:"M9 1 5.8 4.2m0 0H8.6M5.8 4.2V1.4M1 9l3.2-3.2m0 0H1.4m2.8 0v2.8"})})}function WT({size:e=16}){return o.jsx("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"var(--ink-solid-fg)",strokeWidth:"1.8",children:o.jsx("path",{d:"M8 13V3M3.5 7.5 8 3l4.5 4.5"})})}function _K({enabled:e,onSend:t}){return o.jsx("button",{type:"button","aria-label":"Send",disabled:!e,onClick:t,style:{flex:"none",width:38,height:38,marginBottom:4,borderRadius:12,background:m.card,border:`1.5px solid ${e?m.ink:"var(--proto-line-3)"}`,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",opacity:e?1:.45,cursor:e?"pointer":"default"},children:o.jsx("svg",{width:15,height:15,viewBox:"0 0 16 16",fill:"none",stroke:m.ink,strokeWidth:"1.8",children:o.jsx("path",{d:"M8 13V3M3.5 7.5 8 3l4.5 4.5"})})})}function FK(e,t,n,r){f.useEffect(()=>{const i=e.current;if(!i)return;i.style.height="auto";const s=i.scrollHeight;i.style.height=`${Math.min(s,n)}px`,i.style.overflowY=s>n?"auto":"hidden",r(s>BT+2)},[e,t,n,r])}function zK({placeholder:e,above:t,leading:n,sendEnabled:r=!0,value:i,onChange:s,onSend:a,running:l=!1,onStop:c,stopEnabled:d=!0,lineUnit:u="行",charUnit:p="字",onPlus:h,tone:g="default"}){const v=f.useRef(null),[x,w]=f.useState(!1),[b,y]=f.useState(!1),[j,S]=f.useState(()=>_T(i??"")>1);FK(v,i,Ew,S);const k=j&&!b;return o.jsxs("div",{style:{flex:"none",padding:"6px 14px 34px",paddingBottom:"calc(14px + env(safe-area-inset-bottom))",background:m.canvas},children:[t,o.jsxs("div",{style:{display:"flex",alignItems:"flex-end",gap:8},children:[n,o.jsxs("div",{style:{flex:1,minWidth:0,position:"relative",display:"flex",alignItems:"center",minHeight:BT,border:`1.5px solid ${g==="amber"?m.amber:g==="accent"||x?m.run:"var(--proto-line-3)"}`,borderRadius:j?16:14,background:m.card,boxShadow:g==="amber"?"0 0 0 3px rgba(201,154,46,.10)":g==="accent"||x?"0 0 0 3px rgba(70,85,212,.08)":void 0,boxSizing:"border-box",padding:`0 ${k?34:14}px 0 14px`},children:[o.jsx("textarea",{ref:v,rows:1,value:i,onChange:E=>s==null?void 0:s(E.target.value),onFocus:()=>w(!0),onBlur:()=>w(!1),placeholder:e,style:{flex:1,minWidth:0,resize:"none",border:"none",outline:"none",background:"transparent",padding:`${zT}px 0`,margin:0,maxHeight:Ew,fontSize:13.5,lineHeight:`${FT}px`,color:m.ink,fontFamily:"inherit",boxSizing:"border-box"}}),k&&o.jsx("button",{type:"button","aria-label":"Expand",onClick:()=>y(!0),style:{position:"absolute",top:9,right:9,width:22,height:22,borderRadius:7,background:"var(--m-gray)",border:"none",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:o.jsx(NK,{})})]}),l&&o.jsx(_K,{enabled:r,onSend:a}),l?o.jsx("button",{type:"button","aria-label":"Stop",disabled:!d,onClick:c,style:{flex:"none",width:46,height:46,borderRadius:14,background:m.inkSolid,border:"none",display:"flex",alignItems:"center",justifyContent:"center",opacity:d?1:.45,cursor:d?"pointer":"default"},children:o.jsx("span",{style:{width:14,height:14,background:m.inkSolidFg,borderRadius:3}})}):o.jsx("button",{type:"button","aria-label":"Send",disabled:!r,onClick:a,style:{flex:"none",width:46,height:46,borderRadius:14,background:m.inkSolid,border:"none",display:"flex",alignItems:"center",justifyContent:"center",opacity:r?1:.45,cursor:r?"pointer":"default"},children:o.jsx(WT,{})})]}),b&&o.jsx(BK,{value:i??"",placeholder:e,onChange:s,onSend:()=>{a==null||a(),y(!1)},sendEnabled:r,running:l,onStop:c,stopEnabled:d,onCollapse:()=>y(!1),onPlus:h,lineUnit:u,charUnit:p})]})}function BK({value:e,placeholder:t,onChange:n,onSend:r,sendEnabled:i=!0,running:s=!1,onStop:a,stopEnabled:l=!0,onCollapse:c,onPlus:d,onSlash:u,lineUnit:p="行",charUnit:h="字"}){const g=f.useRef(null);f.useEffect(()=>{const w=g.current;if(!w)return;w.focus();const b=w.value.length;w.setSelectionRange(b,b)},[]);const v=u??(()=>n==null?void 0:n(e?`${e}/`:"/")),x={flex:"none",width:30,height:30,borderRadius:10,border:`1px solid ${m.hairline}`,background:m.card,display:"flex",alignItems:"center",justifyContent:"center",color:m.muted,cursor:"pointer"};return o.jsx("div",{style:{position:"absolute",inset:0,zIndex:4,background:m.canvas,padding:"8px 10px",paddingBottom:"calc(8px + env(safe-area-inset-bottom))",boxSizing:"border-box",display:"flex"},children:o.jsxs("div",{style:{flex:1,minWidth:0,position:"relative",display:"flex",flexDirection:"column",overflow:"hidden",border:`1.5px solid ${m.run}`,borderRadius:18,background:m.card,boxShadow:"0 0 0 3px rgba(70,85,212,.08),0 8px 28px rgba(25,28,34,.10)",boxSizing:"border-box"},children:[o.jsx("textarea",{ref:g,value:e,onChange:w=>n==null?void 0:n(w.target.value),placeholder:t,style:{flex:1,minHeight:0,resize:"none",border:"none",outline:"none",background:"transparent",padding:"14px 40px 8px 16px",margin:0,fontSize:14.5,lineHeight:"22px",color:m.ink,fontFamily:"inherit",boxSizing:"border-box"}}),o.jsx("button",{type:"button","aria-label":"Collapse",onClick:c,style:{position:"absolute",top:11,right:11,width:26,height:26,borderRadius:8,background:"var(--m-gray)",border:"none",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:o.jsx($K,{})}),o.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",gap:10,padding:"8px 10px 8px 14px",borderTop:`1px solid ${m.divider}`},children:[o.jsx("button",{type:"button","aria-label":"Attach",onClick:d,style:{...x,fontSize:15,fontWeight:400},children:"+"}),o.jsx("button",{type:"button","aria-label":"Slash command",onClick:v,style:{...x,font:`600 13px ${A}`},children:"/"}),o.jsx("span",{style:{marginLeft:"auto",flex:"none",whiteSpace:"nowrap",font:`400 10px ${A}`,color:m.faint},children:AK(e,p,h)}),s&&o.jsx("button",{type:"button","aria-label":"Send",disabled:!i,onClick:r,style:{flex:"none",width:34,height:34,borderRadius:11,background:m.card,border:`1.5px solid ${i?m.ink:"var(--proto-line-3)"}`,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",opacity:i?1:.45,cursor:i?"pointer":"default"},children:o.jsx("svg",{width:14,height:14,viewBox:"0 0 16 16",fill:"none",stroke:m.ink,strokeWidth:"1.8",children:o.jsx("path",{d:"M8 13V3M3.5 7.5 8 3l4.5 4.5"})})}),s?o.jsx("button",{type:"button","aria-label":"Stop",disabled:!l,onClick:a,style:{flex:"none",width:38,height:38,borderRadius:12,background:m.inkSolid,border:"none",display:"flex",alignItems:"center",justifyContent:"center",opacity:l?1:.45,cursor:l?"pointer":"default"},children:o.jsx("span",{style:{width:12,height:12,background:m.inkSolidFg,borderRadius:3}})}):o.jsx("button",{type:"button","aria-label":"Send",disabled:!i,onClick:r,style:{flex:"none",width:38,height:38,borderRadius:12,background:m.inkSolid,border:"none",display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:.45,cursor:i?"pointer":"default"},children:o.jsx(WT,{size:15})})]})]})})}const WK=f.forwardRef(function({label:t,...n},r){return o.jsx("button",{ref:r,type:"button",...n,"aria-label":"Rate limit status",title:t,style:{border:"1px solid var(--pill-waiting-bg)",background:"var(--pill-waiting-bg)",color:"var(--pill-waiting-fg)",borderRadius:999,padding:"3px 7px",maxWidth:178,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",font:"600 9px 'IBM Plex Mono',monospace",cursor:"pointer"},children:t})});function UK({status:e}){return e?o.jsx(X4,{trigger:o.jsx(WK,{label:e.label}),side:"bottom",align:"center",children:o.jsx(UT,{status:e})}):null}function HK({status:e,onOpen:t}){return e?o.jsx("button",{type:"button","aria-label":"Rate limit status",title:e.label,onClick:t,style:{border:`1px solid ${m.amberBorder}`,background:m.amberBg,color:m.amberText,borderRadius:999,padding:"3px 7px",maxWidth:190,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",font:`600 8.5px ${A}`,cursor:"pointer"},children:e.label}):null}function qK(e){return e.lang==="zh"?{title:"限流详情",recovers:"后恢复"}:{title:"Rate limits",recovers:"to reset"}}function VK(e,t){return e==="zh"?t?"清除中…":"立即清除":t?"Clearing…":"Clear now"}function KK({provider:e,lang:t,mobile:n=!1}){const r=ae(),i=je(),s=ue({...r.system.clearRateLimit.mutationOptions({onSuccess:()=>{i.invalidateQueries(r.system.rateLimitStatus.queryFilter())}})}),a=s.isPending,l=n?m.amberBorder:"var(--pill-waiting-bg)",c=n?m.amberText:"var(--pill-waiting-fg)";return o.jsx("button",{type:"button",disabled:a,title:t==="zh"?"立即结束此限流,恢复等待中的工作":"Lift this rate limit now and resume paused work",onClick:()=>s.mutate({provider:e}),style:{border:`1px solid ${l}`,background:"transparent",color:c,borderRadius:999,padding:"2px 8px",font:"600 9px 'IBM Plex Mono',monospace",cursor:a?"progress":"pointer",opacity:a?.6:1},children:VK(t,a)})}function UT({status:e,mobile:t=!1}){const n=qK(e),r=t?m.ink:"var(--proto-ink)",i=t?m.muted:"var(--proto-muted-2)",s=t?m.hairline:"var(--proto-line)",a=t?m.amberText:"var(--pill-waiting-fg)";return o.jsxs("div",{style:{minWidth:t?0:230,color:r},children:[o.jsx("div",{style:{fontSize:12,fontWeight:700,marginBottom:8},children:n.title}),e.providers.map((l,c)=>o.jsxs("div",{style:{borderTop:c>0?`1px solid ${s}`:"none",paddingTop:c>0?9:0,marginTop:c>0?9:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[o.jsx("span",{style:{fontSize:11,fontWeight:700},children:l.displayName}),o.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:8},children:[o.jsx(KK,{provider:l.provider,lang:e.lang,mobile:t}),o.jsx("span",{style:{font:`600 9px ${A}`,color:a},children:l.recoveryCountdown})]})]}),o.jsx("div",{style:{marginTop:4,color:i,font:`500 9px ${A}`},children:l.waitingLabel}),l.windows.map(d=>o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:6,color:i},children:[o.jsx("span",{style:{font:`600 9.5px ${A}`},children:d.typeLabel}),o.jsxs("span",{style:{marginLeft:"auto",font:`500 9.5px ${A}`},children:[d.countdown," ",n.recovers]})]},`${d.type}:${d.resetsAt}`))]},l.provider))]})}function QK({status:e,onClose:t}){return o.jsx(Vr,{onClose:t,children:o.jsx("div",{style:{padding:"2px 18px 24px"},children:o.jsx(UT,{status:e,mobile:!0})})})}const Rt="'IBM Plex Mono',monospace",HT="cortex.railProjectsH",Rw="cortex.railSchedOpen";function GK(){try{const e=window.localStorage.getItem(HT);return e===null?Nm:OT(Number(e))}catch{return Nm}}function YK({size:e,color:t}){return o.jsxs("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",stroke:t,strokeWidth:1.6,style:{flex:"none"},children:[o.jsx("circle",{cx:"7",cy:"7",r:"5.6"}),o.jsx("path",{d:"M7 4v3.2l2.2 1.3"})]})}function uh(){var an,nr;const e=Be(),t=wr(),n=ae(),r=k0(),i=S0(),{open:s}=I6(),a=B(),l=gT(),c=AT(),d=aV(l),u=a[lV(l)],p=G(n.projects.list.queryOptions({})),{currentProjectId:h,setCurrentProject:g}=$i(),v=G(n.sessions.list.queryOptions({origin:"direct",projectId:h??void 0})),x=G(n.sessions.list.queryOptions({origin:"scheduled",projectId:h??void 0})),w=G(n.schedules.list.queryOptions({projectId:h??void 0})),b=N3();gy();const j=(an=G({...n.cost.summary.queryOptions({projectId:h??void 0}),enabled:!!h}).data)==null?void 0:an.today,S=typeof j=="number"?qr(j):"—",k=p.data??[],E=v.data??[],R=G(n.threads.list.queryOptions({})).data??[],P=f.useMemo(()=>lK(R),[R]),L=G(n.sessions.list.queryOptions({origin:"direct"})),_=f.useMemo(()=>RT(L.data??[]),[L.data]),U=f.useMemo(()=>PT(L.data??[]),[L.data]),K=f.useMemo(()=>MT(L.data??[]),[L.data]),$=f.useMemo(()=>LT(k,K),[k,K]),W=f.useMemo(()=>hK($,h,P,_,K,Date.now(),U),[$,h,P,_,K,U]),[V,Z]=f.useState(!1),N=Y=>{Y!==h&&g(Y),e("/workbench")},F=f.useRef(W);F.current=W;const H=f.useRef(N);H.current=N,f.useEffect(()=>{const Y=me=>{if(!(me.metaKey||me.ctrlKey)||me.altKey||me.shiftKey)return;const Ve=uK(me.key);if(Ve===null)return;const nt=F.current[Ve];nt&&(me.preventDefault(),H.current(nt.id))};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[]);const re=f.useRef(null);f.useEffect(()=>{var me;if(!h)return;const Y=(me=re.current)==null?void 0:me.querySelector(`[data-project-row="${CSS.escape(h)}"]`);Y==null||Y.scrollIntoView({block:"nearest"})},[h,W.length]);const[D,Q]=f.useState(GK),ne=f.useRef(null),J=Y=>{Y.preventDefault(),ne.current={startY:Y.clientY,startH:D};const me=nt=>{const At=ne.current;At&&Q(OT(At.startH+(nt.clientY-At.startY)))},Ve=()=>{ne.current=null,window.removeEventListener("mousemove",me),window.removeEventListener("mouseup",Ve),Q(nt=>{try{window.localStorage.setItem(HT,String(nt))}catch{}return nt})};window.addEventListener("mousemove",me),window.addEventListener("mouseup",Ve)},{groups:te,scheduleRows:fe,now:ve}=f.useMemo(()=>{const Y=Date.now();return{groups:jT(E,Y),scheduleRows:kT(w.data??[],x.data??[]),now:Y}},[E,x.data,w.data]),[ke,Ct]=f.useState(()=>{try{return window.localStorage.getItem(Rw)==="1"}catch{return!1}}),we=()=>{Ct(Y=>{const me=!Y;try{window.localStorage.setItem(Rw,me?"1":"0")}catch{}return me})},[Ee,Xe]=f.useState(null),Tt=Ee?fe.find(Y=>Y.scheduleId===Ee)??null:null,{selectedSessionId:ht,setSelectedSession:lt}=_s(),Kr=cq(),Ot=((nr=G(n.approvals.list.queryOptions({status:"pending"})).data)==null?void 0:nr.length)??0,hn=Ot>0,Mo=Ot+" "+(Ot>1?a.approvalsPending:a.approvalPending),Bt=()=>{lt("__draft__"),e("/workbench")},kr=Y=>{lt(Y),e("/workbench")},sn=f.useRef(Bt);sn.current=Bt,f.useEffect(()=>{const Y=me=>{pq(me)&&(me.preventDefault(),sn.current())};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[]);const yt=[{key:"overview",label:a.overview,to:"/overview"}],[Wt,Yt]=f.useState(null),[gt,Ut]=f.useState(!1),Ht=Y=>({onMouseEnter:()=>Yt(Y),onMouseLeave:()=>Yt(me=>me===Y?null:me)}),qt=Y=>Wt===Y,Lo=Y=>{const me=Y.sessionId===ht,Ve=Y.running,nt=Y.awaitingInput,At="sess:"+Y.sessionId,Oo=me?"var(--proto-line-2)":qt(At)?"var(--proto-gray)":"transparent";return o.jsxs("div",{...Ht(At),className:"sess-row","data-session-id":Y.sessionId,onClick:()=>kr(Y.sessionId),style:{borderRadius:8,padding:"8px 10px",cursor:"pointer",background:Oo,position:"relative"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[(Ve||nt)&&o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:nt?"var(--proto-amber)":"var(--proto-accent)",flex:"none",animation:"cxpulse 1.6s ease-in-out infinite"}}),o.jsx("span",{style:{flex:1,minWidth:0,fontSize:12.5,fontWeight:me||Y.unread?600:400,color:Y.unread||me?"var(--proto-ink)":"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Y.label??Y.name}),o.jsx("span",{className:"sess-more",style:{flex:"none",color:"var(--proto-muted-3)",fontSize:13,letterSpacing:1,padding:"0 4px",borderRadius:5,lineHeight:1.2},children:"⋯"})]}),o.jsx("div",{style:{font:`400 10px ${Rt}`,color:me?"var(--proto-muted-2)":"var(--proto-faint)",marginTop:3,paddingLeft:Ve?14:0},children:VV(a,Y,ve)})]},Y.sessionId)},Dt=Y=>{const me=ST(Y);me.type==="modal"?Xe(Y.scheduleId):me.type==="open"?kr(me.sessionId):Y.schedule&&b.openEdit(Y.schedule)},Qr=Y=>{const me=CT(Y,ve),Ve=Y.runs.some(At=>At.sessionId===ht),nt="sched:"+Y.scheduleId;return o.jsxs("div",{...Ht(nt),"data-schedule-row":Y.scheduleId,onClick:()=>Dt(Y),style:{borderRadius:8,padding:"8px 10px",cursor:"pointer",background:Ve?"var(--proto-line-2)":qt(nt)?"var(--proto-gray)":"transparent"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[o.jsx(YK,{size:11,color:Y.unread?"var(--proto-accent)":"var(--proto-muted-3)"}),o.jsx("span",{style:{flex:1,minWidth:0,fontSize:12.5,fontWeight:Y.unread?600:400,color:Y.unread?"var(--proto-ink)":"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Y.title}),o.jsx("span",{style:{font:`500 9px ${Rt}`,color:"var(--proto-muted-3)",flex:"none"},children:Y.kind==="repeat"?`×${Y.runs.length}`:a.wbSchedOnce}),Y.unread&&o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",flex:"none"}})]}),o.jsxs("div",{style:{font:`400 10px ${Rt}`,color:"var(--proto-faint)",marginTop:3,paddingLeft:18},children:[me.kind==="run"&&o.jsxs(o.Fragment,{children:[me.stamp,me.cost&&o.jsxs(o.Fragment,{children:[" · ",o.jsx("span",{style:{color:"var(--proto-muted-2)"},children:me.cost})]})]}),me.kind==="pending"&&o.jsxs(o.Fragment,{children:[me.cadence,me.nextDelta&&o.jsxs(o.Fragment,{children:[" · ",a.wbSchedNextRun.replace("{d}",me.nextDelta)]})]}),me.kind==="paused"&&o.jsxs(o.Fragment,{children:[me.cadence," · ",o.jsx("span",{style:{color:"var(--proto-amber)"},children:a.wbSchedPausedPill})]})]})]},nt)},Un=ET(fe),Hn=()=>fe.length===0?null:o.jsxs("div",{"data-zone":"scheduled",style:{borderTop:"1px solid var(--proto-line)",marginTop:8,paddingBottom:6},children:[o.jsxs("div",{...Ht("schedhead"),onClick:we,style:{display:"flex",alignItems:"center",gap:6,padding:"12px 4px 6px",cursor:"pointer"},children:[o.jsx("span",{style:{fontSize:8,color:"var(--proto-muted-3)",flex:"none"},children:ke?"▾":"▸"}),o.jsx("span",{style:{fontSize:10,fontWeight:700,letterSpacing:".07em",color:"var(--proto-faint)"},children:a.wbSchedSection}),o.jsx("span",{style:{font:`400 9.5px ${Rt}`,color:"var(--proto-muted-3)"},children:fe.length}),ke?o.jsx("span",{"data-action":"scheduled-manage",onClick:Y=>{Y.stopPropagation(),e("/overview")},style:{marginLeft:"auto",font:`500 9px ${Rt}`,color:"var(--proto-accent)",flex:"none"},children:a.wbSchedManage}):Un>0&&o.jsx("span",{style:{marginLeft:"auto",font:`500 9.5px ${Rt}`,color:"var(--proto-accent)",flex:"none"},children:a.wbSchedUnread.replace("{n}",String(Un))})]}),ke&&fe.map(Qr)]});return o.jsxs("div",{"data-pane":"left",style:{width:340,flex:"none",display:"flex",flexDirection:"column",background:"var(--proto-rail)",borderRight:"1px solid var(--proto-line)",minHeight:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"16px 16px 10px",flex:"none"},children:[o.jsx("div",{"aria-label":"Cortex",style:{width:26,height:26,borderRadius:7,background:"var(--brand-badge-bg)",border:"1px solid var(--brand-badge-border)",display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsxs("svg",{width:19,height:19,viewBox:"0 0 64 64",fill:"none","aria-hidden":"true",children:[o.jsx("circle",{cx:33,cy:32,r:6,fill:"var(--brand-badge-core)"}),o.jsx("path",{d:"M42.29 23.64A12.5 12.5 0 1 0 42.29 40.36",stroke:"var(--brand-badge-arc)",strokeWidth:6,strokeLinecap:"round"}),o.jsx("path",{d:"M48.6 17.95A21 21 0 1 0 48.6 46.05",stroke:"var(--brand-badge-arc)",strokeWidth:6,strokeLinecap:"round"})]})}),o.jsx("div",{style:{fontWeight:650,fontSize:14,color:"var(--proto-ink)",letterSpacing:"-.01em"},children:"Cortex"}),o.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:6,minWidth:0},children:[o.jsx(UK,{status:c}),o.jsxs("div",{onClick:()=>Ut(!0),title:a.dmDaemon,style:{display:"flex",alignItems:"center",gap:5,fontSize:10,color:d.color,fontWeight:600,cursor:"pointer",flex:"none"},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:d.color,...d.pulse?{animation:"cxpulse 1.6s ease-in-out infinite"}:{}}}),u]})]})]}),o.jsxs("div",{"data-zone":"projects",style:{flex:"none",padding:"2px 12px 0"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"0 4px 5px"},children:[o.jsx("span",{style:{fontSize:10,fontWeight:700,letterSpacing:".07em",color:"var(--proto-faint)"},children:a.wbProjects}),o.jsx("span",{style:{font:`500 9.5px ${Rt}`,color:"var(--proto-line-3)",marginLeft:5},children:k.length}),o.jsx("span",{...Ht("newproj"),onClick:()=>Z(!0),title:a.newProject,style:{marginLeft:"auto",fontSize:13,color:qt("newproj")?"var(--proto-ink)":"var(--proto-muted-2)",lineHeight:1,cursor:"pointer",padding:"0 2px"},children:"+"})]}),o.jsx("div",{ref:re,style:{maxHeight:D,overflowY:"auto"},children:W.map(Y=>{const me="proj:"+Y.id;return Y.active?o.jsxs("div",{"data-project-row":Y.id,style:{background:"var(--proto-line-2)",borderRadius:8,padding:"7px 9px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("div",{style:{width:20,height:20,borderRadius:6,background:"var(--proto-accent)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",font:`600 9px ${Rt}`,flex:"none"},children:Y.initials}),o.jsx("span",{style:{fontSize:12.5,fontWeight:650,color:"var(--proto-ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Y.id}),o.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:5,flex:"none"},children:[Y.running>0&&o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:3,font:`600 9.5px ${Rt}`,color:"var(--proto-accent)"},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",animation:"cxpulse 1.6s ease-in-out infinite"}}),Y.running]}),Y.badgeCount>0&&o.jsx("span",{"data-project-attention-badge":Y.id,style:{minWidth:14,height:14,padding:"0 4px",borderRadius:7,background:Y.badgeTone==="action"?"var(--proto-amber)":"var(--proto-accent)",color:"var(--ink-solid-fg)",font:`600 9px ${Rt}`,display:"inline-flex",alignItems:"center",justifyContent:"center"},children:Y.badgeCount})]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"5px 0 1px 28px",fontSize:10.5,fontWeight:600,color:"var(--proto-muted)"},children:[yt.map(Ve=>{const nt=t.pathname.startsWith(Ve.to),At="sub:"+Ve.key;return o.jsx("span",{...Ht(At),onClick:()=>e(Ve.to),style:{color:nt?"var(--proto-accent)":qt(At)?"var(--proto-ink)":"var(--proto-muted)",cursor:"pointer"},children:Ve.label},Ve.key)}),o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[o.jsx("span",{style:{color:"var(--proto-muted-2)",fontWeight:600},children:a.today}),o.jsx("span",{style:{font:`600 10px ${Rt}`,color:"var(--proto-accent)"},children:S})]}),Y.hotkey&&o.jsx("span",{style:{marginLeft:"auto",font:`500 9px ${Rt}`,color:"var(--proto-faint)",fontWeight:400},children:Y.hotkey})]})]},Y.id):o.jsxs("div",{...Ht(me),"data-project-row":Y.id,onClick:()=>N(Y.id),style:{display:"flex",alignItems:"center",gap:8,padding:"7px 9px",borderRadius:8,cursor:"pointer",background:qt(me)?"var(--proto-gray)":"transparent"},children:[o.jsx("div",{style:{width:20,height:20,borderRadius:6,background:"var(--proto-accent-bg)",color:"var(--proto-accent)",display:"flex",alignItems:"center",justifyContent:"center",font:`600 9px ${Rt}`,flex:"none"},children:Y.initials}),o.jsx("span",{style:{fontSize:12.5,color:Y.unread>0?"var(--proto-ink)":"var(--proto-ink-2)",fontWeight:Y.unread>0?600:400,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Y.id}),o.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:5,flex:"none"},children:[Y.running>0&&o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:3,font:`600 9.5px ${Rt}`,color:"var(--proto-accent)"},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",animation:"cxpulse 1.6s ease-in-out infinite"}}),Y.running]}),Y.badgeCount>0&&o.jsx("span",{"data-project-attention-badge":Y.id,style:{minWidth:14,height:14,padding:"0 4px",borderRadius:7,background:Y.badgeTone==="action"?"var(--proto-amber)":"var(--proto-accent)",color:"var(--ink-solid-fg)",font:`600 9px ${Rt}`,display:"inline-flex",alignItems:"center",justifyContent:"center"},children:Y.badgeCount}),Y.idleAge!==null?o.jsx("span",{style:{font:`400 9.5px ${Rt}`,color:"var(--proto-faint)"},children:Y.idleAge}):Y.hotkey&&o.jsx("span",{style:{font:`400 9px ${Rt}`,color:"var(--proto-line-3)"},children:Y.hotkey})]})]},Y.id)})})]}),o.jsxs("div",{"data-divider":"rail",onMouseDown:J,title:"drag to resize",style:{flex:"none",display:"flex",alignItems:"center",gap:8,padding:"7px 12px 5px",cursor:"row-resize",userSelect:"none"},children:[o.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}}),o.jsxs("div",{style:{display:"flex",gap:3},children:[o.jsx("span",{style:{width:3,height:3,borderRadius:"50%",background:"var(--proto-line-3)"}}),o.jsx("span",{style:{width:3,height:3,borderRadius:"50%",background:"var(--proto-line-3)"}}),o.jsx("span",{style:{width:3,height:3,borderRadius:"50%",background:"var(--proto-line-3)"}})]}),o.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}})]}),o.jsxs("div",{"data-zone":"sessions",style:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column",padding:"0 12px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"2px 4px 6px",flex:"none"},children:[o.jsx("span",{style:{fontSize:10,fontWeight:700,letterSpacing:".07em",color:"var(--proto-faint)"},children:a.wbSessions}),h&&o.jsx("span",{style:{font:`500 9.5px ${Rt}`,color:"var(--proto-accent-border)",marginLeft:5},children:dK(h)}),o.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:5},children:[o.jsxs("span",{...Ht("newsess"),onClick:Bt,style:{fontSize:12,fontWeight:600,color:qt("newsess")?"var(--proto-accent-strong)":"var(--proto-accent)",cursor:"pointer"},children:["+ ",a.wbNewShort]}),o.jsx("span",{style:{font:`500 9.5px ${Rt}`,color:"var(--proto-faint)"},children:"⌘N"})]})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto"},children:[te.map((Y,me)=>o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".07em",color:"var(--proto-faint)",padding:me===0?"2px 4px 5px":"10px 4px 6px"},children:qV(a,Y.label)}),Y.items.map(Lo)]},Y.label)),Hn()]})]}),hn&&o.jsxs("div",{...Ht("approval"),onClick:()=>Kr.open(),style:{margin:"0 12px 10px",padding:"9px 12px",background:"var(--proto-amber-bg)",border:"1px solid "+(qt("approval")?"var(--proto-amber)":"var(--proto-amber-border)"),borderRadius:9,display:"flex",alignItems:"center",gap:8,cursor:"pointer",flex:"none"},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"var(--proto-amber)",flex:"none",animation:"cxpulse 2s ease-in-out infinite"}}),o.jsx("div",{style:{fontSize:11.5,color:"var(--proto-amber-fg)",fontWeight:600},children:Mo}),o.jsx("div",{style:{marginLeft:"auto",color:"var(--proto-amber-accent)",fontSize:11},children:"→"})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 16px 14px",borderTop:"1px solid var(--proto-line-2)",flex:"none"},children:[o.jsxs("div",{style:{display:"flex",border:"1px solid var(--proto-line)",borderRadius:6,overflow:"hidden"},children:[o.jsx("span",{onClick:()=>i("light"),title:a.stThemeLight,"aria-label":a.stThemeLight,style:{fontSize:10,fontWeight:600,padding:"2.5px 7px",cursor:"pointer",background:r==="light"?"var(--ink-solid-bg)":"transparent",color:r==="light"?"var(--ink-solid-fg)":"var(--proto-muted-2)"},children:"☀"}),o.jsx("span",{onClick:()=>i("dark"),title:a.stThemeDark,"aria-label":a.stThemeDark,style:{fontSize:10,fontWeight:600,padding:"2.5px 7px",cursor:"pointer",background:r==="dark"?"var(--ink-solid-bg)":"transparent",color:r==="dark"?"var(--ink-solid-fg)":"var(--proto-muted-2)"},children:"☾"})]}),o.jsx("span",{title:`frontend build ${$m}`,style:{marginLeft:"auto",fontFamily:"'IBM Plex Mono',monospace",fontSize:9.5,color:"var(--proto-muted-2)",opacity:.7,userSelect:"text"},children:$m}),o.jsx("span",{...Ht("settings"),onClick:s,style:{fontSize:11.5,color:qt("settings")?"var(--proto-ink)":"var(--proto-muted-2)",cursor:"pointer"},children:a.settings})]}),V&&o.jsx(vK,{onClose:()=>Z(!1)}),Tt&&o.jsx(sK,{row:Tt,selectedSessionId:ht??null,onOpenRun:Y=>{Xe(null),kr(Y)},onManage:Tt.schedule?()=>{Xe(null),b.openEdit(Tt.schedule)}:void 0,onClose:()=>Xe(null)}),o.jsx(kK,{open:gt,onClose:()=>Ut(!1)})]})}function qT(e){return e.backend==null||e.backend==="claude"||e.backend==="pi"}function af(e){return e.backend??"claude"}function XK(e){return[e.model,e.thinking,af(e)].filter(Boolean).join(" · ")}function JK(e,t){const n=e.find(r=>r.name===t&&qT(r));return n?af(n):null}function ZK(e,t,n){return e.filter(qT).map(r=>({name:r.name,sub:XK(r),active:r.name===t,backend:af(r),disabled:n.hasHistory&&n.currentBackend!==null&&af(r)!==n.currentBackend}))}const Pw="'IBM Plex Mono',monospace";function eQ({options:e,onPick:t}){const n=B(),[r,i]=f.useState(null);return o.jsx("div",{"data-menu":"profile",style:{position:"absolute",left:0,top:26,background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:9,boxShadow:"0 10px 28px rgba(16,24,40,.14)",zIndex:59,overflow:"hidden",minWidth:200},children:e.map(s=>o.jsxs("div",{onMouseEnter:()=>i(s.name),onMouseLeave:()=>i(a=>a===s.name?null:a),onClick:()=>{s.disabled||t(s.name)},"data-profile":s.name,"data-disabled":s.disabled?"true":void 0,title:s.disabled?`${n.wbSwitchTo} ${s.backend} ${n.wbNeedsNewSession}`:void 0,style:{display:"flex",alignItems:"center",gap:8,padding:"7.5px 12px",cursor:s.disabled?"not-allowed":"pointer",opacity:s.disabled?.42:1,background:s.disabled?"transparent":r===s.name?"var(--proto-gray)":s.active?"var(--proto-accent-bg)":"transparent"},children:[o.jsx("span",{style:{font:`600 11px ${Pw}`,color:"var(--proto-ink)"},children:s.name}),o.jsx("span",{style:{font:`400 9.5px ${Pw}`,color:"var(--proto-muted-3)"},children:s.sub}),s.active&&o.jsx("span",{style:{marginLeft:"auto",color:"var(--proto-accent)",fontSize:10,fontWeight:700},children:"✓"})]},s.name))})}const Iw="—";function VT(e){var t,n;return[{key:"cortexId",label:e.cortexIdLabel,value:((t=e.cortexId)==null?void 0:t.trim())||Iw},{key:"backendUuid",label:e.backendUuidLabel,value:((n=e.backendUuid)==null?void 0:n.trim())||Iw}]}const Og="'IBM Plex Mono',monospace";function tQ({cortexId:e,backendUuid:t,onClose:n}){const r=B(),i=VT({cortexId:e,backendUuid:t,cortexIdLabel:r.wbCortexId,backendUuidLabel:r.wbBackendUuid}),[s,a]=f.useState(null);f.useEffect(()=>{const c=d=>{d.key==="Escape"&&n()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[n]);const l=(c,d)=>{var u;d!=="—"&&((u=navigator.clipboard)==null||u.writeText(d).catch(()=>{}),a(c),window.setTimeout(()=>a(p=>p===c?null:p),1400))};return o.jsxs(o.Fragment,{children:[o.jsx("div",{onClick:n,style:{position:"fixed",inset:0,background:"rgba(25,28,34,.34)",zIndex:60,animation:"cxfade .18s ease"}}),o.jsxs("div",{"data-modal":"session-id",style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)",width:480,background:"var(--proto-card)",borderRadius:14,boxShadow:"0 24px 64px rgba(16,24,40,.3)",zIndex:61,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"14px 20px 0"},children:[o.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--proto-ink)"},children:r.wbSessionId}),o.jsx("span",{onClick:n,style:{marginLeft:"auto",font:`500 9.5px ${Og}`,color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),o.jsx("div",{style:{padding:"14px 20px 18px",display:"flex",flexDirection:"column",gap:12},children:i.map(c=>o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",marginBottom:6},children:c.label}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,border:"1px solid var(--proto-line)",borderRadius:9,padding:"9px 12px",background:"var(--proto-alt)"},children:[o.jsx("span",{style:{flex:1,font:`500 12.5px ${Og}`,color:"var(--proto-ink)",userSelect:"all",wordBreak:"break-all"},children:c.value}),o.jsx("span",{onClick:()=>l(c.key,c.value),style:{flex:"none",font:`500 9.5px ${Og}`,color:s===c.key?"var(--proto-accent)":"var(--proto-muted-2)",border:"1px solid var(--proto-line-3)",borderRadius:6,padding:"3px 8px",cursor:c.value==="—"?"default":"pointer",opacity:c.value==="—"?.4:1},children:s===c.key?r.wbCopied:r.wbCopy})]})]},c.key))})]})]})}function nQ(e){return{display:"inline-flex",alignItems:"center",gap:6,border:e?"1.5px solid var(--proto-accent)":"1px solid var(--proto-line)",borderRadius:7,padding:"4px 9px",background:e?"var(--proto-accent-bg)":"var(--proto-card)",color:e?"var(--proto-accent)":"var(--proto-ink)",fontFamily:"inherit",cursor:"pointer"}}function rQ(){return o.jsx("svg",{width:"11",height:"11",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:o.jsx("path",{d:"M9.8 1.8l2.4 2.4L4.6 11.8l-3 .6.6-3z"})})}function KT({count:e,active:t,copy:n,onClick:r}){return o.jsxs("button",{type:"button","data-notes-button":"","aria-pressed":t,onClick:r,title:`${n.title} · ⌘⇧N`,style:nQ(t),children:[o.jsx(rQ,{}),o.jsx("span",{style:{fontSize:10.5,fontWeight:600},children:n.title}),o.jsx("span",{style:{font:"600 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-accent)"},children:e})]})}const Mw="'IBM Plex Mono',monospace";function oQ({title:e,running:t,onCmdK:n,sessionId:r,backendSessionId:i,sessionName:s,currentProfile:a,hasHistory:l,isDraft:c=!1}){var H,re,D,Q,ne,J;const d=ae(),u=B(),p=je(),h=lh(),g=G(d.config.get.queryOptions({})),v=((re=(H=g.data)==null?void 0:H.profiles)==null?void 0:re.profiles)??[],x=((Q=(D=g.data)==null?void 0:D.profiles)==null?void 0:Q.defaultProfile)??null,{draftProfile:w,setDraftProfile:b,pendingCreatedSession:y}=_s(),j=z3(a,y,r),S=c?w??x??((ne=v[0])==null?void 0:ne.name)??"—":j??x??((J=v[0])==null?void 0:J.name)??"—",k=f.useMemo(()=>JK(v,S),[v,S]),E=f.useMemo(()=>ZK(v,S,{currentBackend:k,hasHistory:c?!1:l}),[v,S,k,l,c]),C=ue(d.sessions.setProfile.mutationOptions({onSuccess:()=>{p.invalidateQueries(d.sessions.list.queryFilter())}})),[R,P]=f.useState(!1),[L,_]=f.useState(!1),[U,K]=f.useState(!1),[$,W]=f.useState(!1),[V,Z]=f.useState(!1),[N,F]=f.useState(!1);return f.useEffect(()=>{if(!$)return;const te=ve=>{ve.key==="Escape"&&W(!1)},fe=()=>W(!1);return window.addEventListener("keydown",te),window.addEventListener("click",fe),()=>{window.removeEventListener("keydown",te),window.removeEventListener("click",fe)}},[$]),f.useEffect(()=>{if(!V)return;const te=ve=>{ve.key==="Escape"&&Z(!1)},fe=()=>Z(!1);return window.addEventListener("keydown",te),window.addEventListener("click",fe),()=>{window.removeEventListener("keydown",te),window.removeEventListener("click",fe)}},[V]),o.jsxs("div",{style:{height:50,flex:"none",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:10,padding:"0 20px"},children:[o.jsx("div",{style:{fontSize:13.5,fontWeight:600,color:"var(--proto-ink)",maxWidth:320,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e}),o.jsxs("span",{style:{position:"relative"},children:[o.jsxs("span",{"data-chip":"profile",onMouseEnter:()=>P(!0),onMouseLeave:()=>P(!1),onClick:te=>{te.stopPropagation(),W(fe=>!fe)},style:{font:`500 10.5px ${Mw}`,border:"1px solid "+(R?"var(--proto-accent-border)":"var(--proto-line)"),color:R?"var(--proto-accent)":"var(--proto-muted)",padding:"2px 7px",borderRadius:6,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:5},children:[u.wbProfile," · ",S,o.jsx("span",{style:{fontSize:8,color:"var(--proto-faint)"},children:"▾"})]}),$&&o.jsx("span",{onClick:te=>te.stopPropagation(),children:o.jsx(eQ,{options:E,onPick:te=>{if(W(!1),te===S)return;const fe=E.find(ve=>ve.name===te);if(!(!fe||fe.disabled))if(c)b(te);else{if(!r)return;C.mutate({sessionId:r,profileName:te})}}})})]}),t?o.jsxs("span",{style:{fontSize:10.5,fontWeight:600,padding:"2px 8px",borderRadius:999,background:"var(--proto-accent-bg)",color:"var(--proto-accent)"},children:[o.jsx("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",marginRight:4,animation:"cxpulse 1.6s ease-in-out infinite"}}),u.pillRunning]}):o.jsx("span",{style:{fontSize:10.5,fontWeight:600,padding:"2px 8px",borderRadius:999,background:"var(--proto-gray)",color:"var(--proto-muted-2)"},children:u.wbIdle}),o.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:14,color:"var(--proto-muted-2)"},children:[o.jsx("span",{onClick:n,onMouseEnter:()=>_(!0),onMouseLeave:()=>_(!1),style:{font:`500 11px ${Mw}`,cursor:"pointer",color:L?"var(--proto-ink)":void 0},children:"⌘K"}),o.jsx("span",{style:{width:1,height:18,background:"var(--proto-line)",flex:"none"}}),o.jsx(KT,{count:h.vm.activeCount,active:h.isOpen,copy:h.copy,onClick:()=>h.isOpen?h.close():h.open()}),o.jsxs("span",{style:{position:"relative",display:"inline-flex"},children:[o.jsx("span",{"data-chip":"more","aria-label":"Session menu",onMouseEnter:()=>K(!0),onMouseLeave:()=>K(!1),onClick:te=>{te.stopPropagation(),Z(fe=>!fe)},style:{fontSize:15,lineHeight:1,letterSpacing:1,cursor:"pointer",color:U||V?"var(--proto-ink)":void 0},children:"⋯"}),V&&o.jsx("span",{onClick:te=>te.stopPropagation(),style:{position:"absolute",right:0,top:24,minWidth:132,background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:9,boxShadow:"0 14px 40px rgba(16,24,40,.2)",overflow:"hidden",zIndex:40},children:o.jsx("div",{onClick:()=>{Z(!1),F(!0)},style:{padding:"9px 13px",fontSize:12.5,color:"var(--proto-ink)",cursor:"pointer",whiteSpace:"nowrap"},children:u.wbSessionId})})]})]}),N&&o.jsx(tQ,{cortexId:s,backendUuid:i,onClose:()=>F(!1)})]})}function xy(e){switch(e){case"running":return{bg:"#EEF0FA",color:"#4655D4",text:"Running"};case"waiting":return{bg:"#F7ECCE",color:"#8A5B06",text:"Waiting"};case"completed":return{bg:"#E9F4EE",color:"#23854F",text:"Done"};case"failed":return{bg:"#FBEDEB",color:"#C03D33",text:"Failed"};default:return{bg:"#F1F2F5",color:"#8A93A2",text:"Cancelled"}}}function iQ(e){const t=Math.round(e);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;return r===0?`${n}m`:`${n}m ${r}s`}function QT(e){return"L"+(e+2)}function Lw(e){const t=[];return e.durationS!=null&&t.push(iQ(e.durationS)),e.costUsd!=null&&t.push("$"+e.costUsd.toFixed(2)),t.join(" · ")}function sQ(e){const t=e.children[0];return t?{name:t.templateName??t.id,level:QT(t.depth),running:t.status==="running",meta:t.status==="running"?"running":"done"}:null}function aQ(e){const t=e.status==="running",n=xy(e.status),r=sQ(e);return{name:e.templateName??e.id,level:QT(e.depth),chev:t?"▾":"▸",border:t?"#E3E6F5":"#EFF1F5",bg:t?"#FBFBFE":"#FBFBFC",iconColor:t?"#4655D4":"#8A93A2",nameColor:t?"#191C22":"#5B6472",pillBg:n.bg,pillColor:n.color,pillText:t?"Running":n.text,hasLine:r!=null,line:e.activeAgent??"",meta:e.costUsd?"$"+e.costUsd.toFixed(2):"",nested:r}}function lQ(e){const t=e.steps,n=t.map((s,a)=>{const l=s.status==="completed"?"done":s.status==="running"?"running":"pending",c=l==="running",d=l==="done",u=c?e.children.map(aQ):[],p=a<t.length-1;return{node:l,hasTail:p,padB:p?"8px":"2px",name:s.stage??`Step ${s.stepIndex+1}`,fw:c?600:500,color:c?"#191C22":d?"#5B6472":"#B6BDC9",sub:c?e.activeStage??"":s.outputSummary??"",subColor:c?"#98A1B0":"#B6BDC9",meta:c?Lw(s)||"running":d?Lw(s):"gated",metaColor:c?"#4655D4":d?"#B6BDC9":"#D9DCE3",chev:d,expanded:c,subs:u}}),r=xy(e.status),i=e.status==="running"&&e.currentStep?`Step ${e.currentStep.index+1}/${e.totalSteps}`:r.text;return{id:e.id,name:e.templateName,pill:r,pillText:i,meta:"$"+e.totalCostUsd.toFixed(2),rows:n}}const ao="'IBM Plex Mono',monospace";function cQ({row:e}){return o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[e.node==="done"&&o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:"var(--proto-success-bg)",color:"var(--proto-success)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700,flex:"none"},children:"✓"}),e.node==="running"&&o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:"var(--proto-accent)",flex:"none",boxShadow:"0 0 0 3px var(--proto-accent-bg)",animation:"cxpulse 1.6s ease-in-out infinite"}}),e.node==="pending"&&o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}}),e.hasTail&&o.jsx("span",{style:{flex:1,width:1.5,background:"var(--proto-line-2)",margin:"3px 0"}})]})}function dQ({sub:e,onOpenNested:t}){return o.jsxs("div",{style:{border:"1px solid "+e.border,background:e.bg,borderRadius:8},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"7px 10px"},children:[o.jsx("span",{style:{color:"var(--proto-muted-2)",fontSize:9},children:e.chev}),o.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 14 14",fill:"none",stroke:e.iconColor,strokeWidth:"1.8",children:[o.jsx("path",{d:"M7 1.5v5M7 6.5 3.5 10M7 6.5l3.5 3.5"}),o.jsx("circle",{cx:"7",cy:"1.5",r:"1.4",fill:e.iconColor,stroke:"none"}),o.jsx("circle",{cx:"3.5",cy:"11",r:"1.4",fill:e.iconColor,stroke:"none"}),o.jsx("circle",{cx:"10.5",cy:"11",r:"1.4",fill:e.iconColor,stroke:"none"})]}),o.jsx("span",{style:{font:`600 11px ${ao}`,color:e.nameColor},children:e.name}),o.jsx("span",{style:{font:`400 9px ${ao}`,color:"var(--proto-faint)"},children:e.level}),o.jsx("span",{style:{marginLeft:"auto",fontSize:9.5,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:e.pillBg,color:e.pillColor},children:e.pillText})]}),e.hasLine&&o.jsxs("div",{style:{padding:"0 10px 8px 27px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:10,color:"var(--proto-muted)"},children:[o.jsx("span",{children:e.line}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${ao}`,color:"var(--proto-muted-3)"},children:e.meta})]}),e.nested&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,border:"1px solid var(--proto-line-2)",background:"var(--proto-card)",borderRadius:7,padding:"5.5px 9px",marginTop:6},children:[o.jsx("span",{style:{color:"var(--proto-faint)",fontSize:9},children:"▸"}),o.jsx("span",{style:{font:`600 10.5px ${ao}`,color:"var(--proto-ink-2)"},children:e.nested.name}),o.jsx("span",{style:{font:`400 9px ${ao}`,color:"var(--proto-faint)"},children:e.nested.level}),e.nested.running&&o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",animation:"cxpulse 1.6s ease-in-out infinite"}}),o.jsx("span",{style:{fontSize:9.5,color:"var(--proto-muted-3)"},children:e.nested.meta}),o.jsx("span",{onClick:t,style:{marginLeft:"auto",fontSize:10,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:"Open ›"})]})]})]})}function uQ({card:e,onOpen:t}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"8px 13px",background:"var(--proto-rail)",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"var(--proto-accent)",strokeWidth:"1.6",children:[o.jsx("circle",{cx:"3.5",cy:"3",r:"1.9"}),o.jsx("circle",{cx:"3.5",cy:"11",r:"1.9"}),o.jsx("circle",{cx:"10.5",cy:"7",r:"1.9"}),o.jsx("path",{d:"M3.5 5v4M5.4 3.7 8.7 6.1M5.4 10.3 8.7 7.9"})]}),o.jsx("span",{style:{font:`600 12px ${ao}`,color:"var(--proto-ink)"},children:e.name}),o.jsx("span",{style:{font:`400 10.5px ${ao}`,color:"var(--proto-muted-3)"},children:e.id}),o.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:e.pill.bg,color:e.pill.color},children:e.pillText}),o.jsx("span",{style:{marginLeft:"auto",font:`400 10.5px ${ao}`,color:"var(--proto-muted-3)"},children:e.meta}),o.jsx("span",{onClick:t,style:{fontSize:11.5,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:"Open →"})]})}function pQ({row:e,onOpenNested:t}){return o.jsxs(f.Fragment,{children:[o.jsx(cQ,{row:e}),o.jsxs("div",{style:{paddingBottom:e.padB},children:[o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:7},children:[o.jsx("span",{style:{fontSize:11.5,fontWeight:e.fw,color:e.color,flex:"none"},children:e.name}),o.jsx("span",{style:{fontSize:9.5,color:e.subColor,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.sub}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${ao}`,color:e.metaColor,flex:"none"},children:e.meta}),e.chev&&o.jsx("span",{style:{color:"var(--proto-line-3)",fontSize:8,flex:"none"},children:"▸"})]}),e.expanded&&e.subs.length>0&&o.jsx("div",{style:{marginTop:7,display:"flex",flexDirection:"column",gap:6},children:e.subs.map((n,r)=>o.jsx(dQ,{sub:n,onOpenNested:t},r))})]})]})}function fQ({card:e,onOpen:t}){return o.jsxs("div",{"data-inline-thread-id":e.id,style:{border:"1px solid var(--proto-line)",borderRadius:10,overflow:"hidden"},children:[o.jsx(uQ,{card:e,onOpen:t}),o.jsx("div",{style:{padding:"10px 14px 6px"},children:o.jsx("div",{style:{display:"grid",gridTemplateColumns:"16px 1fr",columnGap:9},children:e.rows.map((n,r)=>o.jsx(pQ,{row:n,onOpenNested:t},r))})})]})}function hQ({sessionId:e}){var l;const{openThread:t}=oy(),n=ae(),i=G({...n.threads.list.queryOptions({status:["running","waiting"],sessionId:e}),enabled:!!e}).data??[],s=((l=i.find(c=>c.status==="running")??i[0])==null?void 0:l.id)??"";Ml(s);const a=G({...n.threads.get.queryOptions({threadId:s}),enabled:!!s});return!s||!a.data||a.isError?null:o.jsx(fQ,{card:lQ(a.data),onOpen:()=>t(s)})}const Ow=[{cmd:"/dispatch",desc:"Dispatch a task to a remote machine"},{cmd:"/diff",desc:"Show pending repo changes at the commit gate"},{cmd:"/devices",desc:"gpu-01 · lab-4090 · mac-m3"},{cmd:"/pause",desc:"Pause the current thread"},{cmd:"/status",desc:"Session status summary"}];function gQ(e){const t=e.trim();return t.startsWith("/")?{text:t}:null}const xQ="'IBM Plex Mono',monospace";function mQ({running:e,text:t,accessory:n}){return o.jsxs("div",{"data-composer-status-line":"true",style:{display:"flex",alignItems:"center",gap:8,font:`500 11px ${xQ}`,color:e?"var(--proto-muted-2)":"var(--proto-faint)",padding:"8px 2px 10px"},children:[o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:e?"var(--proto-accent)":"var(--proto-line-3)",animation:e?"cxpulse 1.6s ease-in-out infinite":void 0,flex:"none"}}),o.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t})]}),n?o.jsx("span",{"data-context-usage-position":"composer-status",style:{marginLeft:"auto",display:"inline-flex",flex:"none"},children:n}):null]})}function vQ(e){return[e.name,e.size,e.mimeType,e.type].join("\0")}function ph(e,t){return JSON.stringify([e,(t??[]).map(vQ)])}function my(e){return`${e.ts}\0${e.fingerprint}`}function yQ(e,t,n){const r=my(n),i=t.get(r);if(i!==void 0){n.allowClockSkew&&(e[i]={...e[i],allowClockSkew:!0});return}t.set(r,e.length),e.push(n)}function vy(e,t){const n=[],r=new Map,i=(s,a,l,c)=>{yQ(n,r,{fingerprint:ph(s,a),ts:l,allowClockSkew:c})};if(e.transcript.sessionId===t)for(const s of e.transcript.turns)for(const a of s.messages)a.type==="user"&&i(a.text??"",a.attachments,a.ts,!1);for(const s of e.liveTail)s.sessionId===t&&s.role==="user"&&i(s.text,s.attachments,s.ts,!0);return n}function GT(e,t){const n=Date.parse(e),r=Date.parse(t);return Number.isFinite(n)&&Number.isFinite(r)?n>=r:e>=t}const bQ=5*60*1e3;function jQ(e,t){const n=Date.parse(e),r=Date.parse(t);return!Number.isFinite(n)||!Number.isFinite(r)?e>=t:n>=r-bQ}function YT(e,t,n){if(e.transcript.sessionId!==t)return[];const r=[...n];return e.pendingUser.filter(i=>{const s=ph(i.text,i.attachments),a=r.findIndex(l=>l.fingerprint===s&>(l.ts,i.ts));return a===-1?!0:(r.splice(a,1),!1)})}function XT(e,t){const n=vy(e,t),r=YT(e,t,n).map(i=>({fingerprint:ph(i.text,i.attachments),ts:i.ts,allowClockSkew:!0}));return[...n,...r]}function wQ(e,t,n){return XT(e,t).filter(r=>r.fingerprint===n)}function kQ(e,t){return e.kind!==t.kind?!1:e.kind==="session"?e.sessionId===t.sessionId:e.projectId===t.projectId}function SQ(e,t,n){const r=ph(e.text,e.attachments),i=e.target.kind==="session"?wQ(n,e.target.sessionId,r):[],s=t.filter(l=>kQ(l.target,e.target)&&l.fingerprint===r),a=Math.max(i.length,...s.map(l=>l.authorityOrdinal),0)+1;return{...e,fingerprint:r,authorityBaselineKeys:i.map(my),authorityOrdinal:a,phase:"sending"}}function CQ(e,t){return e==null?void 0:e.map(n=>({...n,path:`attachments/${t}/${n.path.split("/").pop()||n.name}`}))}function TQ(e,t,n){return e.map(r=>r.clientId===t?{...r,target:{kind:"session",sessionId:n},phase:"accepted",attachments:CQ(r.attachments,n)}:r)}function EQ(e,t,n){return n&&e.target.kind==="draft"&&e.target.projectId===t}function JT(e,t){return e.map(n=>n.clientId===t?{...n,phase:"accepted"}:n)}function RQ(e,t){return e.filter(n=>n.clientId!==t)}function PQ(e,t,n){return e.find(i=>i.clientId===t)?Fm(e,n,!1).includes(t)?{messages:JT(e,t),restore:!1}:{messages:RQ(e,t),restore:!0}:{messages:e,restore:!1}}function IQ(e){const t=new Map;for(const n of e){const r=t.get(n.fingerprint)??[];r.push(n),t.set(n.fingerprint,r)}return t}function MQ(e,t,n){const r=e.get(t);if(r)return r;const i=IQ(n(t));return e.set(t,i),i}function LQ(e,t,n){const r=new Set(e.authorityBaselineKeys);return t.findIndex((i,s)=>n.has(s)||r.has(my(i))?!1:i.allowClockSkew?jQ(i.ts,e.ts):GT(i.ts,e.ts))}function Fm(e,t,n){const r=new Map,i=new Map,s=[];for(const a of e){if(a.target.kind==="draft")continue;const l=a.target.sessionId,d=MQ(r,l,g=>n?vy(t,g):XT(t,g)).get(a.fingerprint)??[],u=`${l}\0${a.fingerprint}`,p=i.get(u)??new Set,h=LQ(a,d,p);h!==-1&&(p.add(h),i.set(u,p),s.push(a.clientId))}return s}function OQ(e,t){const n=t.transcript.sessionId,r=vy(t,n),i=YT(t,n,r),s=Fm(e,t,!1),a=Fm(e,t,!0),l=new Set(s),c=e.filter(d=>!l.has(d.clientId)).map(d=>({id:d.clientId,text:d.text,ts:d.ts,attachments:d.attachments}));return{pendingUser:[...i,...c],matchedClientIds:s,settledClientIds:a}}function DQ(e){return e instanceof Error?e:new Error(String(e))}async function ZT(e){e.onEnqueue(e.message);try{const t=await e.mutate();return e.onAccepted(e.message,t),{ok:!0,data:t}}catch(t){const n=DQ(t);return{ok:!1,error:n,restore:e.onRejected(e.message,n)}}}const Zt="'IBM Plex Mono',monospace",Dw="—",AQ="/api/attachments/upload";function NQ({error:e}){const t=B();return o.jsxs("div",{"data-send-error":!0,role:"alert",style:{marginTop:7,padding:"0 2px",font:`500 10.5px ${Zt}`,color:"var(--proto-danger)"},children:[t.wbSendFailed," · ",t.wbDraftRestored,": ",e]})}function eE(e){var t,n;return((t=e.file)==null?void 0:t.type)??((n=e.meta)==null?void 0:n.mimeType)??""}function $Q(e){var t,n;return((t=e.file)==null?void 0:t.name)??((n=e.meta)==null?void 0:n.name)??"file"}function _Q(e){var t,n;return((t=e.file)==null?void 0:t.size)??((n=e.meta)==null?void 0:n.size)??0}function FQ(e){const t=eE(e);return t.startsWith("image/")?"image":t.startsWith("video/")?"video":"file"}function zQ(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function BQ(e){const t=e.lastIndexOf(".");return t>0?e.slice(t+1).toUpperCase().slice(0,4):"FILE"}function WQ(e){return e==="image"?{bg:"var(--proto-accent-bg)",fg:"var(--proto-accent)"}:e==="video"?{bg:"var(--proto-danger-bg)",fg:"var(--proto-danger)"}:{bg:"var(--proto-gray)",fg:"var(--proto-muted)"}}async function UQ(e,t,n,r){const i={"X-Session-Id":t,"X-File-Name":encodeURIComponent(e.name),"Content-Type":e.type||"application/octet-stream",...Rs()};return new Promise((s,a)=>{const l=new XMLHttpRequest;l.open("POST",`${Xv()}${AQ}`),Object.entries(i).forEach(([c,d])=>l.setRequestHeader(c,d)),l.responseType="json",r.addEventListener("abort",()=>l.abort()),l.upload.addEventListener("progress",c=>{c.lengthComputable&&n(Math.round(c.loaded/c.total*100))}),l.addEventListener("load",()=>{if(l.status>=200&&l.status<300){const c=l.response;c!=null&&c.ok&&c.data?s(c.data):a(new Error((c==null?void 0:c.message)||`Upload failed (${l.status})`))}else l.status===413?a(new Error("File too large")):a(new Error(`Upload failed (${l.status})`))}),l.addEventListener("error",()=>a(new Error("Network error"))),l.addEventListener("abort",()=>a(new Error("Upload cancelled"))),l.send(e)})}let HQ=0;function zm(){return`att_${++HQ}_${Date.now()}`}function qQ(e){return e.filter(t=>t.status==="done"&&t.meta).map(t=>t.meta)}function VQ(e,t){const n=new Set(e.flatMap(i=>{var s;return(s=i.meta)!=null&&s.path?[i.meta.path]:[]}));return[...t.filter(i=>!n.has(i.path)).map(i=>({id:zm(),status:"done",progress:100,meta:i})),...e]}function KQ({sessionId:e,running:t,backgroundRunning:n=!1,turns:r,cost:i,elapsed:s,isDraft:a=!1,draftProfile:l=null,draftReloadToken:c=0,projectId:d="general",prepareOptimistic:u,enqueueOptimistic:p,acceptOptimistic:h,rejectOptimistic:g,statusAccessory:v}){const x=ae(),w=B(),b=je(),{openMedia:y}=zd(),{openDoc:j}=Wd(),{selectCreatedSession:S}=_s(),k=ue(x.sessions.send.mutationOptions()),E=ue(x.sessions.cancel.mutationOptions()),C=ue(x.sessions.createAndSend.mutationOptions()),[R,P]=f.useState(""),[L,_]=f.useState(null),U=f.useRef(null),K=f.useRef(null),$=f.useRef(null),W=f.useRef(null);a&&!W.current&&(W.current=crypto.randomUUID());const V=a?W.current??"":e,Z=T=>{T&&(T.style.height="auto",T.style.height=Math.min(T.scrollHeight,160)+"px")};f.useLayoutEffect(()=>{Z(U.current)},[R]);const[N,F]=f.useState(!1),[H,re]=f.useState(null),[D,Q]=f.useState(!1),[ne,J]=f.useState(!1),[te,fe]=f.useState(!1),[ve,ke]=f.useState([]),Ct=f.useRef(R),we=f.useRef(ve);Ct.current=R,we.current=ve;const[Ee,Xe]=f.useState(!1),Tt=f.useRef(0),ht=f.useRef(0),lt=f.useRef(new Map),Kr=ve.length>0;f.useLayoutEffect(()=>{Z(U.current)},[Kr]);const zt=Hd({isDraft:a,sessionId:e,projectId:d}),Ot=`${zt??""}:${a?c:0}`,hn=f.useRef(Ot);hn.current=Ot;const Mo=f.useRef(void 0);f.useEffect(()=>{if(Mo.current!==Ot){if(Mo.current=Ot,!zt)return;const T=dd(zt);a&&(T!=null&&T.draftUploadId)&&(W.current=T.draftUploadId),P((T==null?void 0:T.text)??"");const I=((T==null?void 0:T.attachments)??[]).map(O=>({id:zm(),status:"done",progress:100,meta:O}));ke(O=>(O.forEach(z=>{z.previewUrl&&URL.revokeObjectURL(z.previewUrl)}),I));return}Os(zt,{text:R,attachments:ve.filter(T=>T.status==="done"&&T.meta).map(T=>T.meta),...a&&W.current?{draftUploadId:W.current}:{}})},[zt,Ot,R,ve,a]),f.useEffect(()=>{let T=!1;return ve.filter(I=>!I.file&&!I.previewUrl&&I.status==="done"&&I.meta&&(I.meta.type==="image"||I.meta.type==="video")).forEach(I=>{Fd(I.meta.path,"inline").then(O=>{if(T){URL.revokeObjectURL(O);return}ke(z=>z.map(X=>X.id===I.id?{...X,previewUrl:O}:X))}).catch(()=>{})}),()=>{T=!0}},[ve]);const Bt=ve.length>0,kr=ve.filter(T=>T.status==="done"),yt=(!!R.trim()||kr.length>0)&&(!!e||a)&&!k.isPending&&!C.isPending,Wt=N||Ee?"var(--proto-accent)":"var(--proto-line-3)",Yt=t?`⏎ ${w.wbSend} · ${w.wbEscToStop}`:`⏎ ${w.wbSend} · ⇧⏎ ${w.wbNewline}`,gt=yt?"var(--proto-ink)":"var(--proto-line-3)",Ut=r==null?Dw:`${r} ${w.wbTurnsUnit}`,Ht=i==null?Dw:qr(i),qt=!a&&r!=null,Lo=R.startsWith("/")?R.slice(1).toLowerCase():"",Dt=Ow.filter(T=>T.cmd.slice(1).startsWith(Lo)),Qr=Dt.length?Dt:Ow,Un=f.useCallback(T=>{if(!T.file)return;const I=T.file,O=new AbortController;lt.current.set(T.id,O),ke(z=>z.map(X=>X.id===T.id?{...X,status:"uploading",progress:0}:X)),UQ(I,V,z=>ke(X=>X.map(oe=>oe.id===T.id?{...oe,progress:z}:oe)),O.signal).then(z=>{ke(X=>X.map(oe=>oe.id===T.id?{...oe,status:"done",progress:100,meta:z}:oe)),lt.current.delete(T.id)}).catch(z=>{z.message!=="Upload cancelled"&&(ke(X=>X.map(oe=>oe.id===T.id?{...oe,status:"error",errorMsg:z.message}:oe)),lt.current.delete(T.id))})},[V]),Hn=f.useCallback(T=>{const I=Array.from(T).map(O=>({id:zm(),file:O,status:"pending",progress:0,previewUrl:O.type.startsWith("image/")||O.type.startsWith("video/")?URL.createObjectURL(O):void 0}));ke(O=>[...O,...I]),I.forEach(O=>Un(O))},[Un]),an=f.useCallback(T=>{const I=lt.current.get(T);I&&I.abort(),lt.current.delete(T),ke(O=>{const z=O.find(X=>X.id===T);return z!=null&&z.previewUrl&&URL.revokeObjectURL(z.previewUrl),O.filter(X=>X.id!==T)})},[]),nr=f.useCallback(T=>{ke(I=>{const O=I.find(z=>z.id===T);return O&&Un({...O,status:"pending",progress:0}),I})},[Un]),Y=f.useCallback(T=>{T.preventDefault(),T.stopPropagation(),Tt.current++,T.dataTransfer.types.includes("Files")&&(ht.current=T.dataTransfer.items.length,Xe(!0))},[]),me=f.useCallback(T=>{T.preventDefault(),T.stopPropagation(),Tt.current--,Tt.current<=0&&(Tt.current=0,Xe(!1))},[]),Ve=f.useCallback(T=>{T.preventDefault(),T.stopPropagation(),T.dataTransfer.types.includes("Files")&&T.dataTransfer.items.length>0&&(ht.current=T.dataTransfer.items.length)},[]),nt=f.useCallback(T=>{T.preventDefault(),T.stopPropagation(),Tt.current=0,Xe(!1),T.dataTransfer.files.length>0&&Hn(T.dataTransfer.files)},[Hn]),At=f.useCallback(T=>{var z;const I=(z=T.clipboardData)==null?void 0:z.items;if(!I)return;const O=[];for(let X=0;X<I.length;X++){const oe=I[X];if(oe.kind==="file"){const ce=oe.getAsFile();ce&&O.push(ce)}}O.length>0&&(T.preventDefault(),Hn(O))},[Hn]),Oo=(T,I,O,z)=>{const X=hn.current===O,oe=X?{text:Ct.current,attachments:qQ(we.current),...W.current?{draftUploadId:W.current}:{}}:dd(I)??{text:"",attachments:[]},ce=W3(oe,T);Os(I,ce),X&&(ce.draftUploadId&&(W.current=ce.draftUploadId),P(ce.text),ke(de=>VQ(de,T.attachments)),_(z.message))},_i=()=>{H3(zt),P(""),ke(T=>(T.forEach(I=>{I.previewUrl&&URL.revokeObjectURL(I.previewUrl)}),[])),F(!1),lt.current.forEach(T=>T.abort()),lt.current.clear(),U.current&&(U.current.style.height="auto")},Fi=T=>{const I=T.trim(),O=kr.map(se=>se.meta);if(!I&&O.length===0||!a&&!e)return;const z={text:I,attachments:O,...a&&W.current?{draftUploadId:W.current}:{}},X=u(I,O),oe=zt,ce=Ot;_(null);const de=ZT({message:X,mutate:()=>a?C.mutateAsync({projectId:d,profileName:l??void 0,text:I,draftUploadId:z.draftUploadId,...O.length>0?{attachments:O}:{}}):k.mutateAsync({sessionId:e,text:I,...O.length>0?{attachments:O}:{}}),onEnqueue:p,onAccepted:(se,ie)=>{if("sessionId"in ie){const pe=h(se.clientId,ie.sessionId);b.invalidateQueries(x.sessions.list.queryFilter()),pe&&(W.current=null,S(ie.sessionId))}else h(se.clientId)},onRejected:(se,ie)=>g(se.clientId,ie)});_i(),de.then(se=>{!se.ok&&se.restore&&Oo(z,oe,ce,se.error)})},Sr=()=>{yt&&Fi(R)},Cr=()=>{!e||E.isPending||E.mutate({sessionId:e})},zi=T=>{if(T.key==="Enter"&&!T.shiftKey)T.preventDefault(),Sr();else if(T.key==="Escape"){if(N){F(!1);return}t&&(T.preventDefault(),Cr())}},Fs=T=>{var Ce;const I=eE(T),O=I.startsWith("image/"),z=I.startsWith("video/"),X=FQ(T),oe=WQ(X),ce=$Q(T),de=BQ(ce),se=Ls(X),ie=!!T.previewUrl&&T.status!=="uploading"&&T.status!=="error";if(O||z)return o.jsxs("div",{style:{position:"relative",width:54,height:54,flex:"none"},children:[o.jsxs("div",{role:ie?"button":void 0,title:ie?ce:void 0,onClick:ie&&se?()=>y({kind:se,name:ce,url:T.previewUrl}):void 0,style:{position:"absolute",inset:0,borderRadius:8,border:T.status==="error"?"1px solid var(--proto-danger)":"1px solid var(--proto-line)",background:T.previewUrl?"#000":"repeating-linear-gradient(45deg,var(--proto-line),var(--proto-line) 5px,var(--proto-line) 5px,var(--proto-line) 10px)",boxSizing:"border-box",overflow:"hidden",cursor:ie?"pointer":"default"},children:[T.previewUrl&&O&&o.jsx("img",{src:T.previewUrl,alt:ce,style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),T.previewUrl&&z&&o.jsx(Ud,{src:T.previewUrl,style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),o.jsx("span",{style:{position:"absolute",left:4,bottom:3,font:`500 8px ${Zt}`,color:"var(--proto-muted-2)",background:"rgba(255,255,255,.88)",padding:"1px 4px",borderRadius:3},children:de}),z&&T.status!=="uploading"&&o.jsx(o.Fragment,{children:o.jsx("span",{style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%)",width:19,height:19,borderRadius:"50%",background:"rgba(25,28,34,.82)",color:"var(--ink-solid-fg)",fontSize:7,display:"flex",alignItems:"center",justifyContent:"center",paddingLeft:1.5,boxSizing:"border-box"},children:"▶"})}),T.status==="uploading"&&o.jsxs(o.Fragment,{children:[o.jsxs("span",{style:{position:"absolute",inset:0,background:"rgba(255,255,255,.65)",display:"flex",alignItems:"center",justifyContent:"center",font:`600 9px ${Zt}`,color:"var(--proto-accent)"},children:[T.progress,"%"]}),o.jsx("span",{style:{position:"absolute",left:0,bottom:0,height:3,width:`${T.progress}%`,background:"var(--proto-accent)"}})]}),T.status==="error"&&o.jsx("span",{onClick:Je=>{Je.stopPropagation(),nr(T.id)},style:{position:"absolute",inset:0,background:"rgba(255,255,255,.75)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",font:`600 8px ${Zt}`,color:"var(--proto-danger)"},children:"retry"})]}),o.jsx("span",{onClick:Je=>{Je.stopPropagation(),an(T.id)},style:{position:"absolute",top:-5,right:-5,width:16,height:16,borderRadius:"50%",background:"var(--proto-ink)",color:"var(--ink-solid-fg)",fontSize:9,display:"flex",alignItems:"center",justifyContent:"center",border:"1.5px solid var(--proto-card)",boxSizing:"border-box",cursor:"pointer"},children:"×"})]},T.id);const pe=Bd(ce,I),ye=pe&&T.status==="done"&&((Ce=T.meta)!=null&&Ce.path)?()=>j({kind:pe,name:ce,path:T.meta.path,mimeType:I}):void 0;return o.jsxs("div",{role:ye?"button":void 0,title:ye?ce:void 0,onClick:ye,style:{position:"relative",display:"flex",alignItems:"center",gap:8,height:54,border:T.status==="error"?"1px solid var(--proto-danger)":"1px solid var(--proto-line)",background:"var(--proto-rail)",borderRadius:8,padding:"0 12px 0 8px",flex:"none",boxSizing:"border-box",cursor:ye?"pointer":"default"},children:[o.jsx("span",{style:{width:26,height:32,borderRadius:5,background:oe.bg,color:oe.fg,display:"flex",alignItems:"center",justifyContent:"center",font:`700 8px ${Zt}`,flex:"none"},children:de}),o.jsxs("span",{style:{display:"flex",flexDirection:"column",gap:2},children:[o.jsx("span",{style:{font:`500 10.5px ${Zt}`,color:"var(--proto-ink)",maxWidth:140,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ce}),o.jsx("span",{style:{font:`400 9px ${Zt}`,color:T.status==="uploading"?"var(--proto-accent)":T.status==="error"?"var(--proto-danger)":"var(--proto-muted-3)"},children:T.status==="uploading"?`${T.progress}%`:T.status==="error"?T.errorMsg||"Failed":zQ(_Q(T))})]}),o.jsx("span",{onClick:Je=>{Je.stopPropagation(),an(T.id)},style:{position:"absolute",top:-5,right:-5,width:16,height:16,borderRadius:"50%",background:"var(--proto-ink)",color:"var(--ink-solid-fg)",fontSize:9,display:"flex",alignItems:"center",justifyContent:"center",border:"1.5px solid var(--proto-card)",boxSizing:"border-box",cursor:"pointer"},children:"×"})]},T.id)};return o.jsx("div",{style:{flex:"none"},children:o.jsxs("div",{ref:$,onDragEnter:Y,onDragLeave:me,onDragOver:Ve,onDrop:nt,style:{maxWidth:756,margin:"0 auto",padding:"0 32px 18px",position:"relative"},children:[N&&o.jsxs("div",{style:{position:"absolute",left:32,right:32,bottom:"100%",marginBottom:-2,border:"1px solid var(--proto-line)",borderRadius:12,boxShadow:"0 6px 24px rgba(16,24,40,.08)",background:"var(--proto-card)",overflow:"hidden",zIndex:10},children:[Qr.map((T,I)=>o.jsxs("div",{onMouseEnter:()=>re(I),onMouseLeave:()=>re(O=>O===I?null:O),onClick:()=>{const O=gQ(T.cmd);O&&Fi(O.text)},style:{display:"flex",alignItems:"center",padding:"8px 14px",background:H===I||I===0?"var(--proto-accent-bg)":"var(--proto-card)",cursor:"pointer"},children:[o.jsx("span",{style:{font:`600 12px ${Zt}`,color:I===0?"var(--proto-accent)":"var(--proto-muted)"},children:T.cmd}),o.jsx("span",{style:{fontSize:11.5,color:"var(--proto-muted-2)",marginLeft:12},children:T.desc})]},T.cmd)),o.jsx("div",{style:{display:"flex",alignItems:"center",padding:"7px 14px",borderTop:"1px solid var(--proto-alt)",background:"var(--proto-rail)"},children:o.jsxs("span",{style:{font:`400 10px ${Zt}`,color:"var(--proto-faint)"},children:["↑↓ ",w.wbNavigate," · ⏎ ",w.wbRun," · ",w.wbEscDismiss]})})]}),o.jsx(mQ,{running:t,text:t?`${n?w.pillBackground:w.pillRunning} · ${s} · ${Ut}`:qt?`${w.wbIdle} · ${s} · ${Ut} · ${Ht}`:w.wbIdle,accessory:v}),o.jsx("div",{style:{position:"relative",border:Ee?"1.5px dashed var(--proto-accent)":"1.5px solid "+Wt,borderRadius:12,background:Ee?"var(--proto-rail)":"var(--proto-card)",boxShadow:Ee?"none":"0 1px 2px rgba(16,24,40,.04)",padding:"10px 12px 10px 14px"},children:Ee&&!Bt?o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:4,padding:"22px 12px"},children:[o.jsx("span",{style:{font:`600 11.5px ${Zt}`,color:"var(--proto-accent)"},children:ht.current>0?w.wbDropFilesPlural.replace("{n}",String(ht.current)):w.wbDropFilesSingular}),o.jsx("span",{style:{font:`400 10px ${Zt}`,color:"var(--proto-muted-3)"},children:w.wbAttachPath})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{opacity:Ee?.4:1,pointerEvents:Ee?"none":"auto"},children:o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:14},children:[o.jsxs("div",{style:{flex:1,minWidth:0},children:[Bt&&o.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,padding:"2px 2px 10px",borderBottom:"1px solid var(--proto-line-2)"},children:ve.map(Fs)}),o.jsx("textarea",{ref:U,"data-composer-input":!0,rows:1,value:R,onChange:T=>{const I=T.target.value;P(I),_(null),F(I.startsWith("/"))},onKeyDown:zi,onPaste:At,placeholder:Bt?w.wbAttachPlaceholder:w.composerPh,style:{width:"100%",fontSize:13.5,lineHeight:1.5,color:"var(--proto-ink)",fontFamily:"inherit",padding:Bt?"11px 2px":"2px 0",border:"none",outline:"none",resize:"none",background:"transparent",maxHeight:160,overflowY:"auto"}}),o.jsxs("div",{style:{display:"flex",alignItems:"center",marginTop:0},children:[o.jsx("span",{onClick:()=>{var T;return(T=K.current)==null?void 0:T.click()},onMouseEnter:()=>J(!0),onMouseLeave:()=>J(!1),style:{font:`500 10.5px ${Zt}`,border:"1px solid "+(ne?"var(--proto-accent-border)":"var(--proto-line)"),color:ne?"var(--proto-accent)":"var(--proto-muted-2)",padding:"2px 7px",borderRadius:6,cursor:"pointer"},children:w.wbAttach}),o.jsxs("span",{onClick:()=>{P("/"),F(!0)},onMouseEnter:()=>Q(!0),onMouseLeave:()=>Q(!1),style:{font:`500 10.5px ${Zt}`,border:"1px solid "+(D?"var(--proto-accent-border)":"var(--proto-line)"),color:D?"var(--proto-accent)":"var(--proto-muted-2)",padding:"2px 7px",borderRadius:6,cursor:"pointer",marginLeft:8},children:["/ ",w.commands]}),o.jsx("span",{style:{marginLeft:"auto",font:`400 10.5px ${Zt}`,color:"var(--proto-faint)"},children:Bt?w.wbAttachHint:Yt})]})]}),o.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",gap:6,marginTop:Bt?2:0},children:[o.jsx("button",{type:"button","data-action":"send","aria-label":w.wbSend,title:t?`${w.wbSend} · ⏎`:void 0,disabled:!yt,onClick:Sr,style:{flex:"none",width:t?30:34,height:t?30:34,padding:0,borderRadius:t?9:10,background:t?"transparent":gt,border:t?`1.5px solid ${yt?"var(--proto-accent-border)":"var(--proto-line)"}`:"none",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",cursor:yt?"pointer":"default"},children:o.jsx("svg",{width:t?12:14,height:t?12:14,viewBox:"0 0 14 14",fill:"none",stroke:t?yt?"var(--proto-accent)":"var(--proto-line-3)":"var(--ink-solid-fg)",strokeWidth:"1.8",children:o.jsx("path",{d:"M7 12V2M3 6l4-4 4 4"})})}),t&&o.jsx("div",{"data-action":"stop",title:`${w.stop} · esc`,onClick:Cr,onMouseEnter:()=>fe(!0),onMouseLeave:()=>fe(!1),style:{flex:"none",width:34,height:34,borderRadius:10,background:te?"var(--ink-solid-hover)":"var(--proto-ink)",display:"flex",alignItems:"center",justifyContent:"center",cursor:E.isPending?"default":"pointer"},children:o.jsx("span",{style:{width:11,height:11,background:"var(--proto-card)",borderRadius:2}})})]})]})}),Ee&&Bt&&o.jsxs("div",{style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%)",display:"flex",flexDirection:"column",alignItems:"center",gap:3,background:"rgba(251,251,254,.94)",border:"1px solid var(--proto-accent-border)",borderRadius:10,padding:"10px 18px",boxShadow:"0 2px 8px rgba(70,85,212,.10)",zIndex:2},children:[o.jsx("span",{style:{font:`600 11.5px ${Zt}`,color:"var(--proto-accent)"},children:ht.current>0?w.wbDropAddMoreN.replace("{n}",String(ht.current)):w.wbDropAddMore}),o.jsx("span",{style:{font:`400 10px ${Zt}`,color:"var(--proto-muted-3)"},children:w.wbDragOverCount.replace("{n}",String(ve.length)).replace("{m}",String(ve.length+ht.current))})]})]})}),L&&o.jsx(NQ,{error:L}),o.jsx("input",{ref:K,type:"file",multiple:!0,onChange:T=>{T.target.files&&T.target.files.length>0&&(Hn(T.target.files),T.target.value="")},style:{display:"none"}})]})})}const Vd={en:{title:"Context usage",current:"Current context",limit:"Context limit",usage:"Usage",tokens:"tokens",estimate:"The backend reports this value as an estimate.",waiting:"Context usage becomes available after the next turn completes.",compact:"Compact",compacting:"Compacting…",compacted:"Context compacted.",notNeeded:"Nothing to compact.",running:"Stop the current turn before compacting.",noHistory:"No conversation history to compact."},zh:{title:"上下文用量",current:"当前上下文",limit:"上下文上限",usage:"使用率",tokens:"tokens",estimate:"此数值由后端估算。",waiting:"下一次 turn 完成后将显示上下文用量。",compact:"压缩",compacting:"压缩中…",compacted:"上下文已压缩。",notNeeded:"当前没有可压缩内容。",running:"请先停止当前 turn,再压缩上下文。",noHistory:"当前没有可压缩的会话历史。"}};function tE(e){return Vd[e].title}function QQ({usage:e,supported:t,variant:n,lang:r,compactAction:i}){return!t&&e===null?null:o.jsx(Wf,{title:tE(r),trigger:o.jsx(nE,{usage:e,variant:n,lang:r,"data-context-compact-enabled":i?"true":void 0}),footer:i?o.jsx(rE,{action:i,lang:r}):void 0,children:o.jsx(oE,{usage:e,lang:r})})}const GQ={border:0,background:"transparent",padding:0,display:"inline-flex",alignItems:"center",gap:7,color:"var(--proto-muted)",cursor:"pointer",flex:"none"},YQ={minWidth:26,font:"600 10px 'IBM Plex Mono', ui-monospace, Menlo, monospace",color:"var(--proto-muted)",textAlign:"right",whiteSpace:"nowrap"},nE=f.forwardRef(function({usage:t,variant:n,lang:r,style:i,...s},a){const l=Vd[r],c=E3(t);return o.jsxs("button",{...s,ref:a,type:"button","data-context-usage-bar":n,"data-context-usage-presentation":n==="mobile"?"sheet-trigger":"modal-trigger","aria-label":`${l.usage}: ${c.percentLabel}`,style:{...GQ,...i},children:[o.jsx("span",{"data-context-usage-track":n,role:"progressbar","aria-label":l.usage,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":c.progress??void 0,style:{display:"block",width:n==="desktop"?64:48,height:4,borderRadius:999,background:"var(--proto-line-3)",overflow:"hidden"},children:o.jsx("span",{style:{display:"block",height:"100%",width:`${c.progress??0}%`,borderRadius:999,background:"var(--proto-accent)"}})}),o.jsx("span",{style:YQ,children:c.percentLabel})]})});function XQ(e,t){const n=Vd[t];return e.error?e.error:e.status==="compacted"?n.compacted:e.status==="not-needed"?n.notNeeded:e.disabledReason==="running"?n.running:e.disabledReason==="no-history"?n.noHistory:null}function rE({action:e,lang:t}){const n=Vd[t];return o.jsxs(o.Fragment,{children:[o.jsx("span",{"aria-live":"polite",style:{marginRight:"auto",color:"var(--proto-muted)",fontSize:12},children:XQ(e,t)}),o.jsx(jt,{"data-context-compact-action":!0,variant:"primary",size:"sm",disabled:e.pending||e.disabled,onClick:e.onCompact,children:e.pending?n.compacting:n.compact})]})}function oE({usage:e,lang:t}){const n=Vd[t],r=E3(e),i=[[n.current,r.current==="—"?r.current:`${r.current} ${n.tokens}`],[n.limit,r.maximum==="—"?r.maximum:`${r.maximum} ${n.tokens}`],[n.usage,r.percentLabel]],s=e?r.estimated?n.estimate:null:n.waiting;return o.jsxs("div",{"data-context-usage-details":!0,style:{display:"grid",gap:10},children:[i.map(([a,l])=>o.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:20,borderBottom:"1px solid var(--proto-line-2)",paddingBottom:8},children:[o.jsx("span",{style:{color:"var(--proto-muted)"},children:a}),o.jsx("span",{style:{font:"600 12px 'IBM Plex Mono', ui-monospace, Menlo, monospace",color:"var(--proto-ink)",textAlign:"right"},children:l})]},a)),s?o.jsx("p",{style:{margin:0,color:"var(--proto-muted)",fontSize:12,lineHeight:1.5},children:s}):null]})}function iE(e,t){const n=ae(),r=je(),[i,s]=f.useState(null),[a,l]=f.useState(null),c=t.running?"running":t.hasBackendHistory?null:"no-history",d=ue(n.sessions.compact.mutationOptions({onSuccess:p=>{s(p.status),l(null),r.invalidateQueries(n.sessions.list.queryFilter())},onError:p=>{s(null),l(p.message)}}));return f.useEffect(()=>{s(null),l(null)},[e]),{onCompact:f.useCallback(()=>{!e||d.isPending||c||(s(null),l(null),d.mutate({sessionId:e}))},[c,d,e]),pending:d.isPending,disabled:!e||c!==null,status:i,error:a,disabledReason:c}}function yy(e){const t=ae(),n=je(),r=ue(t.sessions.answerQuestion.mutationOptions()),i=ue(t.sessions.respondPlan.mutationOptions()),s=ue(t.sessions.cancelResume.mutationOptions()),[a,l]=f.useState(null),c=f.useCallback(()=>{n.invalidateQueries(t.sessions.transcript.queryFilter({sessionId:e})),n.invalidateQueries(t.sessions.pendingInteraction.queryFilter())},[n,t,e]),d=f.useCallback((g,v)=>{r.isPending||r.mutate({requestId:g,answers:v},{onSettled:c})},[r,c]),u=f.useCallback(g=>{i.isPending||i.mutate({requestId:g,approved:!0},{onSettled:c})},[i,c]),p=f.useCallback((g,v)=>{i.isPending||i.mutate({requestId:g,approved:!1,feedback:v??""},{onSettled:c})},[i,c]),h=f.useCallback(()=>{s.isPending||s.mutate({sessionId:e},{onSettled:()=>{l(e),c()}})},[s,c,e]);return{answerQuestion:d,approvePlan:u,rejectPlan:p,cancelResume:h,resumeCancelled:a===e,busy:r.isPending||i.isPending}}const JQ=800;function sE(e,t){const n=ae(),r=je(),i=ue(n.sessions.markRead.mutationOptions({onSuccess:()=>{r.invalidateQueries(n.sessions.list.queryFilter())}})),s=f.useRef(i.mutate);s.current=i.mutate;const a=f.useRef(null);f.useEffect(()=>{if(!e)return;const l=()=>{document.visibilityState==="visible"&&(a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{s.current({sessionId:e})},JQ))};l();const c=()=>{document.visibilityState==="visible"&&l()};return document.addEventListener("visibilitychange",c),()=>{document.removeEventListener("visibilitychange",c),a.current&&clearTimeout(a.current)}},[e,t])}function aE(e){const{sessionId:t,isDraft:n,projectId:r,transcript:i,liveTail:s,pendingUser:a,getMessageSnapshot:l}=e,[c,d]=f.useState([]),u=f.useRef([]),p=f.useRef(r),h=f.useRef(n);p.current=r,h.current=n;const g=f.useMemo(()=>({transcript:i??{sessionId:t,turns:[],pendingUserMessages:[]},liveTail:s,pendingUser:a}),[i,t,s,a]),v=f.useRef(g);v.current=g;const x=f.useCallback(()=>({...v.current,...l()}),[l]),w=f.useCallback(C=>{d(R=>{const P=C(R);return u.current=P,P})},[]),b=f.useMemo(()=>c.filter(C=>n?C.target.kind==="draft"&&C.target.projectId===r:C.target.kind==="session"&&C.target.sessionId===t),[c,n,r,t]),y=f.useMemo(()=>OQ(b,g),[b,g]);f.useEffect(()=>{if(y.settledClientIds.length===0)return;const C=new Set(y.settledClientIds);w(R=>R.filter(P=>!C.has(P.clientId)))},[y.settledClientIds,w]);const j=f.useCallback((C,R)=>{const P=n?{kind:"draft",projectId:r}:{kind:"session",sessionId:t};return SQ({clientId:crypto.randomUUID(),target:P,text:C,attachments:R,ts:new Date().toISOString()},u.current,x())},[n,r,t,x]),S=f.useCallback(C=>{w(R=>[...R,C])},[w]),k=f.useCallback((C,R)=>{const P=u.current.find(_=>_.clientId===C),L=!!R&&!!P&&EQ(P,p.current,h.current);return w(_=>R?TQ(_,C,R):JT(_,C)),R?L:!0},[w]),E=f.useCallback(C=>{const R=PQ(u.current,C,x());return w(()=>R.messages),R.restore},[x,w]);return{pendingUser:y.pendingUser,prepare:j,enqueue:S,accept:k,reject:E}}const ZQ={sessionId:"",turns:[]};function eG({grow:e=1}={}){const t=B(),n=ft(),r=ae(),{currentProjectId:i}=$i(),{selectedSessionId:s,isDraft:a,draftProfile:l,draftReloadToken:c}=_s(),d=G(r.sessions.list.queryOptions({origin:"direct",projectId:i??void 0})),u=G(r.sessions.list.queryOptions({origin:"scheduled",projectId:i??void 0})),p=f.useMemo(()=>[...d.data??[],...u.data??[]].find(te=>te.sessionId===s)??null,[d.data,u.data,s]),h=G({...r.schedules.list.queryOptions({}),enabled:!!(p!=null&&p.scheduleId)}),g=f.useMemo(()=>p!=null&&p.scheduleId?(h.data??[]).find(J=>J.id===p.scheduleId)??null:null,[h.data,p==null?void 0:p.scheduleId]),v=(p==null?void 0:p.origin)==="scheduled",x=f.useMemo(()=>{if(!v||!(p!=null&&p.scheduleId))return null;const J=(u.data??[]).filter(te=>te.scheduleId===p.scheduleId);return TT(g,J,p.sessionId)},[v,p==null?void 0:p.scheduleId,p==null?void 0:p.sessionId,g,u.data]),w=(p==null?void 0:p.sessionId)??(a?"":s??""),b=a?t.wbNewConversation:p?x??p.label??p.name:"No session",y=G({...r.sessions.transcript.queryOptions({sessionId:w}),enabled:!!w}),{liveTail:j,getMessageSnapshot:S,streaming:k,running:E,backgroundRunning:C,liveTurns:R,contextUsage:P,streamingText:L,pendingUser:_}=sh(w,p==null?void 0:p.running,p==null?void 0:p.backgroundRunning,{deltas:!0,transcript:y.data??null,contextUsage:(p==null?void 0:p.contextUsage)??null}),U=aE({sessionId:w,isDraft:a,projectId:i??"general",transcript:y.data??null,liveTail:j,pendingUser:_,getMessageSnapshot:S}),K=yy(w);sE(w,`${j.length}:${E}`);const $=y.data??ZQ,W=f.useMemo(()=>Z0($,j,{streaming:k,streamingText:L,pendingUser:U.pendingUser,formatDivider:g3(t),stripScheduledPrefix:!!(p!=null&&p.scheduleId)||v}),[$,j,k,L,U.pendingUser,t,p==null?void 0:p.scheduleId,v]),V=wW(y.data),Z=u3(R,(p==null?void 0:p.numTurns)??null),N=f.useMemo(()=>p3(d3(y.data)),[y.data]),F=V>0||j.length>0,H=iE(w,{running:E,hasBackendHistory:!!(p!=null&&p.backendSessionId)}),re=je(),D=ue(r.sessions.rewind.mutationOptions({onSettled:()=>{w&&(re.invalidateQueries(r.sessions.transcript.queryFilter({sessionId:w})),re.invalidateQueries(r.sessions.list.queryFilter()))}})),Q=f.useMemo(()=>{if(w)return{running:E,busy:D.isPending,onSubmit:(J,te)=>D.mutate({sessionId:w,turnIndex:J,text:te})}},[w,E,D]),ne=()=>{window.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,bubbles:!0}))};return o.jsxs("div",{"data-pane":"center",style:{flexGrow:e,flexShrink:1,flexBasis:0,minWidth:0,display:"flex",flexDirection:"column",background:"var(--proto-card)",minHeight:0},children:[o.jsx(oQ,{title:b,running:E,onCmdK:ne,sessionId:w,backendSessionId:(p==null?void 0:p.backendSessionId)??null,sessionName:(p==null?void 0:p.name)??null,currentProfile:(p==null?void 0:p.profileName)??null,hasHistory:F,isDraft:a}),o.jsx(rU,{rows:W,loading:!!w&&y.isPending,inlineThreadCard:w?o.jsx(hQ,{sessionId:w}):void 0,interactionActions:K,edit:Q,streamKey:w}),o.jsx(KQ,{sessionId:w,running:E,backgroundRunning:C,turns:Z,cost:(p==null?void 0:p.costUsd)??null,elapsed:N,isDraft:a,draftProfile:l,draftReloadToken:c,projectId:i??"general",prepareOptimistic:U.prepare,enqueueOptimistic:U.enqueue,acceptOptimistic:U.accept,rejectOptimistic:U.reject,statusAccessory:p!=null&&p.contextCompactionSupported||P!==null?o.jsx(QQ,{usage:P,supported:!!(p!=null&&p.contextCompactionSupported),variant:"desktop",lang:n,compactAction:p!=null&&p.contextCompactionSupported?H:void 0}):void 0}),v&&o.jsx("div",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",maxWidth:760,margin:"0 auto",width:"100%",boxSizing:"border-box",padding:"0 24px 10px",flex:"none"},children:t.wbSchedReplyHint})]})}function fh(e,t){return e.unmetDependencyIds!==void 0?e.unmetDependencyIds:t?e.dependsOn.filter(n=>t.get(n)==="open"):e.dependsOn}const tG=["in-progress","actionable","approval-needed","waiting-deps","blocked","done"],nG=[{kind:"done",matches:e=>e.status==="done"},{kind:"blocked",matches:e=>e.blockedBy!=null},{kind:"in-progress",matches:e=>e.claimedBy!=null},{kind:"approval-needed",matches:e=>e.approvalNeeded===!0},{kind:"waiting-deps",matches:(e,t)=>t},{kind:"actionable",matches:e=>e.actionable}];function rG(e,t){var r;const n=fh(e,t).length>0;return((r=nG.find(i=>i.matches(e,n)))==null?void 0:r.kind)??"waiting-deps"}function Aw(e){const t=Date.parse(e.completedAt??"");return Number.isNaN(t)?null:t}function lE(e){return[...e].sort((t,n)=>{const r=Aw(t),i=Aw(n);return r===null&&i===null?0:r===null?1:i===null?-1:i-r})}function oG(e){const t=new Map(e.map(n=>[n.id,n.status]));return tG.map(n=>{const r=e.filter(i=>rG(i,t)===n);return{kind:n,tasks:n==="done"?lE(r):r}}).filter(n=>n.tasks.length>0)}function iG(e){return e.filter(t=>t.status==="open").length}const sG={"in-progress":"var(--proto-danger)",actionable:"var(--proto-amber)","approval-needed":"var(--proto-amber)","waiting-deps":"var(--proto-faint)",blocked:"var(--proto-amber)",done:"var(--proto-success)"},aG={background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:9,padding:"9px 12px",boxShadow:"0 1px 2px rgba(16,24,40,.03)",cursor:"pointer"},lG={claim:{color:"var(--proto-accent)",background:"var(--proto-accent-bg)"},approval:{color:"var(--proto-amber-text)",background:"var(--proto-amber-bg)"},blocked:{color:"var(--proto-danger)",background:"var(--proto-danger-bg)"},waiting:{color:"var(--proto-muted-2)",background:"var(--proto-gray)"},done:{color:"var(--proto-success)",background:"var(--proto-success-bg)"}},cG={boxSizing:"border-box",maxWidth:"100%",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function dG(e,t,n){const r=qd(e),i=fh(e),s=ah(e.completedAt);return[t==="done"&&s?{kind:"done",text:`${n.tkCompletedAt} · ${s}`}:null,t==="blocked"&&e.blockedBy?{kind:"blocked",text:`${n.mBlockedPill} · ${e.blockedBy}`}:null,t==="in-progress"?{kind:"claim",text:r?`claimed · ${r}`:"claimed"}:null,t==="approval-needed"?{kind:"approval",text:n.tkApprovalNeeded}:null,t==="waiting-deps"&&i.length>0?{kind:"waiting",text:`${n.mDependsOn} ${i.join(", ")}`}:null].find(l=>l!=null)??null}function uG({task:e}){return o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:7,minWidth:0},children:[o.jsx("span",{style:{color:"var(--proto-faint)",fontSize:8.5,flex:"none"},children:"▸"}),o.jsx("span",{style:{font:"500 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:e.id}),o.jsx("span",{style:{fontSize:12,color:"var(--proto-ink-2)",lineHeight:1.45,flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:e.text,children:e.text})]})}function pG({meta:e}){return o.jsx("div",{style:{display:"flex",alignItems:"center",marginTop:5},children:o.jsx("span",{"data-task-blocker":e.kind==="blocked"?"true":void 0,style:{font:"500 9.5px 'IBM Plex Mono',monospace",padding:"1.5px 7px",borderRadius:999,...lG[e.kind],...e.kind==="blocked"?cG:{}},children:e.text})})}function fG({task:e,kind:t,onOpen:n}){const r=B(),i=dG(e,t,r);return o.jsx("div",{"data-task-id":e.id,"data-status":e.status,onClick:()=>n(e),style:aG,children:o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:sG[t],flex:"none",marginTop:5}}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx(uG,{task:e}),i&&o.jsx(pG,{meta:i})]})]})})}function by(){const e=ae(),t=je();Ni(iU,()=>{t.invalidateQueries(e.tasks.list.queryFilter())})}const hG={fontSize:11.5,fontWeight:700,letterSpacing:".06em",textTransform:"uppercase",color:"var(--proto-muted)",padding:"8px 2px 4px"},gG={borderRadius:10,border:"1px solid var(--proto-line)",background:"var(--proto-danger-bg)",padding:"6px 10px",fontSize:12,color:"var(--proto-danger)"};function xG({kind:e,tasks:t,onOpen:n}){const r=B(),i={"in-progress":r.tkInProgress,actionable:r.tkActionable,"approval-needed":r.tkApprovalNeeded,"waiting-deps":r.tkWaitingDeps,blocked:r.mBlocked,done:r.tkDone};return o.jsxs("section",{children:[o.jsxs("div",{style:hG,children:[i[e]," · ",t.length]}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:t.map(s=>o.jsx(fG,{task:s,kind:e,onOpen:n},s.id))})]})}function mG({groups:e,onOpen:t}){const n=B();return e.length===0?o.jsx("div",{style:{fontSize:12,color:"var(--proto-muted-2)",padding:"24px 0",textAlign:"center"},children:n.mNoTasks}):o.jsx(o.Fragment,{children:e.map(r=>o.jsx(xG,{...r,onOpen:t},r.kind))})}function vG({tasks:e,groups:t}){var i;const n=B(),r=((i=t.find(s=>s.kind==="done"))==null?void 0:i.tasks.length)??0;return o.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",padding:"8px 2px 0",borderTop:"1px solid var(--proto-line-2)",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},children:[o.jsxs("span",{children:["TASKS.yaml · ",n.synced]}),o.jsxs("span",{style:{marginLeft:"auto"},children:[e.length," total · ",r," done"]})]})}function cE({projectId:e}){const t=B(),n=ae(),{openTask:r}=mT(),i=G(n.tasks.list.queryOptions(e?{projectId:e}:{}));by();const s=i.data??[],a=f.useMemo(()=>oG(s),[s]);return i.isPending?o.jsx("div",{style:{fontSize:12,color:"var(--proto-muted-2)",padding:12},children:t.tkLoading}):i.isError?o.jsxs("div",{style:gG,children:[t.tkLoadFailed,": ",i.error.message]}):o.jsxs("div",{style:{minHeight:0,flex:1,display:"flex",flexDirection:"column"},children:[o.jsx("div",{style:{flex:1,overflow:"auto",minHeight:0},children:o.jsx(mG,{groups:a,onOpen:l=>r(l.project,l.id)})}),o.jsx(vG,{tasks:s,groups:a})]})}function yG(e){return e.artifacts.taskProject??e.projectId}const bG=o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",strokeWidth:"1.6",children:[o.jsx("circle",{cx:"3.5",cy:"3",r:"1.9"}),o.jsx("circle",{cx:"3.5",cy:"11",r:"1.9"}),o.jsx("circle",{cx:"10.5",cy:"7",r:"1.9"}),o.jsx("path",{d:"M3.5 5v4M5.4 3.7 8.7 6.1M5.4 10.3 8.7 7.9"})]});function jG({kind:e,hasTail:t}){return o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[e==="done"&&o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:"var(--proto-success-bg)",color:"var(--proto-success)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700,flex:"none"},children:"✓"}),e==="running"&&o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:"var(--proto-accent)",flex:"none",boxShadow:"0 0 0 3px var(--proto-accent-bg)",animation:"cxpulse 1.6s ease-in-out infinite"}}),e==="pending"&&o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}}),t&&o.jsx("span",{style:{flex:1,width:1.5,background:"var(--proto-line-2)",margin:"3px 0"}})]})}const jy={running:"var(--proto-accent)",done:"var(--proto-success)",failed:"var(--proto-danger)",idle:"var(--proto-faint)"};function dE({tone:e}){return o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:jy[e],flex:"none",animation:e==="running"?"cxpulse 1.6s ease-in-out infinite":void 0}})}function wG({run:e,onOpen:t}){const n=ZV(e.status),r=[e.machine,e.taskId?`task ${e.taskId}`:null].filter(Boolean).join(" · ");return o.jsxs("div",{"data-cortex-run":e.runName??"",onClick:()=>t(e.executionId),style:{display:"flex",alignItems:"center",gap:7,border:`1px solid ${n.tone==="running"?"var(--proto-accent-bg)":"var(--proto-line-2)"}`,background:"var(--proto-rail)",borderRadius:8,padding:"7px 10px",cursor:"pointer"},children:[o.jsx(dE,{tone:n.tone}),o.jsx("span",{style:{minWidth:0,font:"600 10.5px 'IBM Plex Mono',monospace",color:"var(--proto-ink-2)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:JV(e)}),r&&o.jsx("span",{style:{flex:"none",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:r}),o.jsx("span",{style:{marginLeft:"auto",flex:"none",font:"500 9.5px 'IBM Plex Mono',monospace",color:jy[n.tone]},children:e.cost!=null?qr(e.cost):n.label})]})}function kG({task:e,onOpen:t}){const n=eK(e);return o.jsxs("div",{"data-subtask-id":e.id,onClick:()=>t(e.id),style:{display:"flex",alignItems:"center",gap:7,border:"1px solid var(--proto-line-2)",background:"var(--proto-rail)",borderRadius:8,padding:"7px 10px",cursor:"pointer"},children:[o.jsx(dE,{tone:n.tone}),o.jsxs("span",{style:{flex:"none",font:"600 10.5px 'IBM Plex Mono',monospace",color:"var(--proto-ink-2)"},children:["task ",e.id]}),o.jsx("span",{style:{minWidth:0,fontSize:9.5,color:"var(--proto-muted-3)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.text}),o.jsx("span",{style:{marginLeft:"auto",flex:"none",fontSize:9.5,fontWeight:600,color:jy[n.tone]},children:n.label})]})}function SG({runs:e,subtasks:t,onOpenRun:n,onOpenTask:r}){return e.length===0&&t.length===0?null:o.jsxs("div",{style:{marginTop:7,display:"flex",flexDirection:"column",gap:6},children:[e.map(i=>o.jsx(wG,{run:i,onOpen:n},i.executionId)),t.map(i=>o.jsx(kG,{task:i,onOpen:r},i.id))]})}function CG({label:e,meta:t,active:n,done:r}){const i=n?"var(--proto-ink)":r?"var(--proto-muted)":"var(--proto-faint)";return o.jsxs("div",{style:{display:"flex",alignItems:"baseline"},children:[o.jsx("span",{style:{fontSize:11.5,fontWeight:n?600:500,color:i},children:e}),o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:n?"var(--proto-accent)":"var(--proto-faint)"},children:t})]})}function TG({step:e,isLast:t,detail:n,onOpenRun:r,onOpenTask:i}){const s=B(),a=GV(e),l=a==="running",c=l?W0(n,e):[],d=l?n.subtasks??[]:[],u=c.length>0||d.length>0,p=e.stage??`${s.rpStep} ${e.stepIndex+1}`;return o.jsxs(o.Fragment,{children:[o.jsx(jG,{kind:a,hasTail:!t}),o.jsxs("div",{style:{minWidth:0,paddingBottom:t?4:9},children:[o.jsx(CG,{label:p,meta:XV(e),active:l,done:a==="done"}),u&&o.jsx(SG,{runs:c,subtasks:d,onOpenRun:r,onOpenTask:i})]})]})}function EG({threadId:e,cost:t}){const n=B(),r=ae(),{openThread:i}=oy(),s=je(),a=ue(r.threads.cancel.mutationOptions({onSettled:()=>{s.invalidateQueries(r.threads.list.queryFilter()),s.invalidateQueries(r.threads.get.queryFilter({threadId:e}))}}));return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:13,padding:"8px 14px",borderTop:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{title:"Pause has no backend mutate op yet",style:{fontSize:11.5,fontWeight:600,color:"var(--proto-muted)",cursor:"not-allowed",opacity:.6},children:n.pause}),o.jsx("span",{"data-cancel-thread-id":e,onClick:()=>a.mutate({threadId:e}),style:{fontSize:11.5,fontWeight:600,color:"var(--proto-danger)",cursor:"pointer"},children:n.cancel}),o.jsx("span",{onClick:()=>i(e),style:{fontSize:11.5,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:n.open}),o.jsxs("span",{style:{marginLeft:"auto",font:"500 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:["Σ ",qr(t)]})]})}function RG({detail:e,threadId:t}){const{open:n}=O3(),{openTask:r}=mT();return Ml(t),o.jsxs(o.Fragment,{children:[e.steps.length>0&&o.jsx("div",{style:{padding:"10px 14px 4px"},children:o.jsx("div",{style:{display:"grid",gridTemplateColumns:"16px 1fr",columnGap:9},children:e.steps.map(i=>o.jsx(TG,{step:i,isLast:i.stepIndex===e.steps.length-1,detail:e,onOpenRun:n,onOpenTask:s=>r(yG(e),s)},i.stepIndex))})}),o.jsx(EG,{threadId:t,cost:e.totalCostUsd})]})}function PG({thread:e,now:t}){const n=B(),[r,i]=f.useState(e.status==="running"),s=ae(),a=G({...s.threads.get.queryOptions({threadId:e.id}),enabled:r}),l=QV(e.status),c=e.status==="running"?"var(--proto-accent)":"var(--proto-muted-2)",d=r?a.data:void 0,u=d?nK(d):null,p=!!u&&u.filled>1;return o.jsxs("div",{style:{background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"0 1px 2px rgba(16,24,40,.03)"},children:[o.jsxs("div",{onClick:()=>i(h=>!h),style:{padding:"11px 14px 9px",cursor:"pointer",borderBottom:"1px solid "+(r?"var(--proto-line-soft)":"transparent")},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{display:"inline-flex",color:c,stroke:c},children:bG}),o.jsx("span",{style:{font:"600 12.5px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:e.templateName}),o.jsx("span",{style:{marginLeft:"auto",fontSize:10.5,fontWeight:600,padding:"2px 8px",borderRadius:999,background:l.bg,color:l.fg},children:l.text})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:5},children:[o.jsx("span",{style:{font:"400 10.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:tK(e,t)}),p&&u&&o.jsxs("span",{style:{marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:3},children:[o.jsx("span",{style:{font:"500 9px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",marginRight:2},children:n.rpDepth}),Array.from({length:u.total}).map((h,g)=>o.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:g<u.filled?"var(--proto-accent)":"var(--proto-line)"}},g)),o.jsx("span",{style:{font:"500 9px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",marginLeft:2},children:u.text})]})]})]}),r&&a.isPending&&o.jsx("div",{style:{padding:"10px 14px",fontSize:11,color:"var(--proto-muted-3)"},children:n.rpLoadingThread}),r&&a.isError&&o.jsx("div",{style:{padding:"10px 14px",fontSize:11,color:"var(--proto-danger)"},children:n.rpFailedLoadThread}),r&&d&&o.jsx(RG,{detail:d,threadId:e.id})]})}const IG=1024,Nw=5;function gp(e,t){return t>0?Math.min(100,Math.max(0,Math.round(e/t*100))):0}function Rc(e){return(e/IG).toFixed(1)}function MG(e){return e.replace(/^NVIDIA\s+/i,"").replace(/^GeForce\s+/i,"").replace(/\s+Generation$/i,"").trim()}function uE(e){if(e<0)return"";const t=Math.floor(e/86400),n=Math.floor(e%86400/3600);if(t>0)return`${t}d ${n}h`;const r=Math.floor(e%3600/60);return n>0?`${n}h ${r}m`:`${r}m`}function pE(e){return e===null?"":uE(e)}function lf(e,t=Date.now()){if(!e)return"";const n=Date.parse(e);return Number.isNaN(n)?"":uE(Math.floor((t-n)/1e3))}function LG(e){if(!e)return[];const t=[],{cpuCores:n,loadAvg1:r,memUsedMb:i,memTotalMb:s,diskFreeGb:a,diskTotalGb:l}=e;return n!==null&&r!==null&&t.push({key:"cpu",label:"CPU",percent:gp(r,n),text:`${r.toFixed(2)} / ${n}`}),i!==null&&s!==null&&t.push({key:"mem",label:"RAM",percent:gp(i,s),text:`${Rc(i)} / ${Rc(s)} GB`}),a!==null&&l!==null&&t.push({key:"disk",label:"DISK",percent:gp(l-a,l),text:`${a.toFixed(1)} GB free`}),t}function fE(e){return e.runName??e.taskId??e.executionId}function OG(e,t){const n=[...e.processes].sort((r,i)=>i.memoryMb-r.memoryMb);return{index:e.index,name:MG(e.name),utilPercent:Math.min(100,Math.max(0,e.utilPercent)),utilText:`${e.utilPercent}%`,memPercent:gp(e.memUsedMb,e.memTotalMb),memText:`${Rc(e.memUsedMb)} / ${Rc(e.memTotalMb)} GB`,tempText:`${e.tempC}°C`,powerText:`${e.powerW}W`,owners:t.filter(r=>r.gpuIndices.includes(e.index)).map(fE),processes:n.slice(0,Nw).map(r=>({pid:r.pid,name:r.name.split(/[/\\]/).pop()||r.name,memText:`${Rc(r.memoryMb)} GB`})),hiddenProcessCount:Math.max(0,n.length-Nw)}}function hE(e,t=Date.now()){return{meters:LG(e.vitals),gpus:e.gpus.map(n=>OG(n,e.liveRuns)),liveRuns:e.liveRuns.map(n=>({key:n.executionId,label:fE(n),taskId:n.taskId,gpuText:n.gpuIndices.length>0?`GPU ${n.gpuIndices.join(",")}`:"",duration:lf(n.startedAt,t)})),probeError:e.probeError}}const DG=1e4,AG=5e3,NG=o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",strokeWidth:"1.6",children:[o.jsx("rect",{x:"1.5",y:"2",width:"11",height:"4",rx:"1",stroke:"currentColor"}),o.jsx("rect",{x:"1.5",y:"8",width:"11",height:"4",rx:"1",stroke:"currentColor"}),o.jsx("circle",{cx:"11",cy:"4",r:"0.9",fill:"currentColor",stroke:"none"}),o.jsx("circle",{cx:"11",cy:"10",r:"0.9",fill:"currentColor",stroke:"none"})]}),cf="'IBM Plex Mono',monospace",po=`400 10px ${cf}`;function $G({open:e}){return o.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",style:{transform:e?"rotate(90deg)":"none",transition:"transform .15s",flexShrink:0},children:o.jsx("path",{d:"M3.5 2L6.5 5L3.5 8",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function _G(e){return e>=90?"var(--proto-danger)":e>=75?"var(--proto-amber)":"var(--proto-accent)"}function gE({percent:e,width:t=46}){return o.jsx("span",{style:{width:t,height:5,borderRadius:3,background:"var(--proto-line-2)",overflow:"hidden",flexShrink:0,display:"inline-block"},children:o.jsx("span",{style:{display:"block",width:`${e}%`,height:"100%",background:_G(e)}})})}function FG({meters:e}){return o.jsx("div",{style:{display:"flex",gap:14,flexWrap:"wrap",padding:"8px 14px"},children:e.map(t=>o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5,font:po,color:"var(--proto-muted-2)"},children:[o.jsx("span",{style:{color:"var(--proto-muted-3)"},children:t.label}),o.jsx(gE,{percent:t.percent,width:34}),o.jsx("span",{style:{color:"var(--proto-muted)"},children:t.text})]},t.key))})}function zG({gpu:e}){return o.jsxs("div",{style:{padding:"6px 14px",borderTop:"1px solid var(--proto-line-soft)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,font:po,color:"var(--proto-muted)"},children:[o.jsx("span",{style:{color:"var(--proto-ink-3)",fontWeight:600},children:e.index}),o.jsx("span",{style:{color:"var(--proto-muted-2)",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),o.jsx(gE,{percent:e.utilPercent,width:34}),o.jsx("span",{style:{width:30,textAlign:"right"},children:e.utilText}),o.jsx("span",{style:{color:"var(--proto-muted-3)"},children:e.memText}),o.jsx("span",{style:{color:"var(--proto-faint)"},children:e.tempText})]}),e.owners.length>0&&o.jsxs("div",{style:{font:po,color:"var(--proto-accent)",marginTop:3,paddingLeft:14},children:["↳ ",e.owners.join(" · ")]}),e.processes.map(t=>o.jsxs("div",{style:{font:po,color:"var(--proto-faint)",marginTop:2,paddingLeft:14},children:[t.pid," ",t.name," · ",t.memText]},t.pid)),e.hiddenProcessCount>0&&o.jsxs("div",{style:{font:po,color:"var(--proto-faint)",marginTop:2,paddingLeft:14},children:["+",e.hiddenProcessCount]})]})}function BG({run:e}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,font:po,color:"var(--proto-muted)"},children:[o.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:"var(--proto-accent)",flexShrink:0,animation:"cxpulse 1.6s ease-in-out infinite"}}),o.jsx("span",{style:{color:"var(--proto-ink-3)",fontWeight:600},children:e.label}),e.gpuText&&o.jsx("span",{style:{color:"var(--proto-muted-3)"},children:e.gpuText}),e.duration&&o.jsx("span",{style:{marginLeft:"auto",color:"var(--proto-faint)"},children:e.duration})]})}function $w({machine:e,uptime:t}){const n=B(),r=[];return e.connectedAt&&r.push(`${n.mConnectedFor} ${lf(e.connectedAt)}`),e.lastHeartbeat&&r.push(`${n.mHeartbeat} ${lf(e.lastHeartbeat)}`),t&&r.push(`${n.mUptime} ${t}`),e.sshConfigured&&r.push(`${n.mSsh} ✓`),e.capabilities.length>0&&r.push(e.capabilities.join(",")),o.jsxs("div",{style:{padding:"7px 14px 9px",borderTop:"1px solid var(--proto-line-soft)"},children:[o.jsx("div",{style:{font:po,color:"var(--proto-faint)",lineHeight:1.7},children:r.join(" · ")}),e.cortexPath&&o.jsxs("div",{style:{font:po,color:"var(--proto-faint)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[n.mPath," ",e.cortexPath]})]})}function Jl({text:e,tone:t}){return o.jsx("div",{style:{padding:"8px 14px",font:po,color:t==="danger"?"var(--proto-danger)":"var(--proto-muted-3)"},children:e})}function WG({machine:e}){var s;const t=B(),n=ae(),r=G({...n.machines.detail.queryOptions({machine:e.name}),enabled:e.online,refetchInterval:e.online?AG:!1});if(!e.online)return o.jsxs(o.Fragment,{children:[o.jsx(Jl,{text:t.mOfflineNoTelemetry,tone:"muted"}),o.jsx($w,{machine:e,uptime:""})]});if(r.isPending)return o.jsx(Jl,{text:t.mProbing,tone:"muted"});if(r.isError)return o.jsx(Jl,{text:t.mProbeFailed,tone:"danger"});const i=hE(r.data);return o.jsxs(o.Fragment,{children:[i.probeError&&o.jsx(Jl,{text:`${t.mProbeFailed}: ${i.probeError}`,tone:"danger"}),i.meters.length>0&&o.jsx(FG,{meters:i.meters}),i.gpus.map(a=>o.jsx(zG,{gpu:a},a.index)),!i.probeError&&i.gpus.length===0&&o.jsx(Jl,{text:t.mNoGpuReported,tone:"muted"}),i.liveRuns.length>0&&o.jsx("div",{style:{padding:"8px 14px",borderTop:"1px solid var(--proto-line-soft)",display:"flex",flexDirection:"column",gap:5},children:i.liveRuns.map(a=>o.jsx(BG,{run:a},a.key))}),o.jsx($w,{machine:e,uptime:pE(((s=r.data.vitals)==null?void 0:s.uptimeSec)??null)})]})}function UG({machine:e}){const t=B(),[n,r]=f.useState(!1),i=oK(e.online),s=e.online?"var(--proto-accent)":"var(--proto-muted-2)",a=[];return e.gpuCount!=null&&a.push(`${t.mGpu} ×${e.gpuCount}`),a.push(e.os),e.liveRuns>0&&a.push(`${e.liveRuns} ${t.mLiveRuns}`),o.jsxs("div",{style:{background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"0 1px 2px rgba(16,24,40,.03)"},children:[o.jsxs("div",{role:"button","aria-expanded":n,onClick:()=>r(l=>!l),style:{padding:"11px 14px 9px",cursor:"pointer",borderBottom:`1px solid ${n?"var(--proto-line-soft)":"transparent"}`},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{display:"inline-flex",color:"var(--proto-muted-3)"},children:o.jsx($G,{open:n})}),o.jsx("span",{style:{display:"inline-flex",color:s},children:NG}),o.jsx("span",{style:{font:`600 12.5px ${cf}`,color:"var(--proto-ink)"},children:e.name}),o.jsx("span",{style:{marginLeft:"auto",fontSize:10.5,fontWeight:600,padding:"2px 8px",borderRadius:999,background:i.bg,color:i.fg},children:i.text})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:5},children:[o.jsx("span",{style:{font:`400 10.5px ${cf}`,color:"var(--proto-muted-3)",paddingLeft:17},children:a.join(" · ")}),e.liveRuns>0&&o.jsx("span",{style:{marginLeft:"auto",width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",flexShrink:0,animation:"cxpulse 1.6s ease-in-out infinite"}})]})]}),n&&o.jsx(WG,{machine:e})]})}function HG(){const e=B(),t=ae(),n=G({...t.machines.list.queryOptions({}),refetchInterval:DG}),r=n.data??[],i=n.isSuccess?String(r.length):"—";return o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 18px",borderBottom:"1px solid var(--proto-line-2)",flex:"none"},children:[o.jsx("span",{style:{fontSize:10.5,color:"var(--proto-muted)"},children:e.machines}),o.jsx("span",{style:{marginLeft:"auto",font:`500 10.5px ${cf}`,color:"var(--proto-muted)"},children:i})]}),o.jsxs("div",{style:{flex:1,padding:"12px 16px",display:"flex",flexDirection:"column",gap:10,overflow:"auto",minHeight:0},children:[r.map(s=>o.jsx(UG,{machine:s},s.name)),n.isSuccess&&r.length===0&&o.jsxs("div",{style:{textAlign:"center",padding:"26px 12px",border:"1px dashed var(--proto-line)",borderRadius:10},children:[o.jsx("div",{style:{fontSize:11.5,fontWeight:600,color:"var(--proto-muted-2)"},children:e.mNoMachines}),o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",marginTop:4,lineHeight:1.6},children:e.rpNoMachinesHint})]}),n.isPending&&o.jsx("div",{style:{textAlign:"center",fontSize:11,color:"var(--proto-muted-3)",padding:"24px 0"},children:e.rpLoadingMachines}),n.isError&&o.jsx("div",{style:{textAlign:"center",fontSize:11,color:"var(--proto-danger)",padding:"24px 0"},children:e.rpFailedLoadMachines})]})]})}const qG=["active","history"],VG=["running","waiting","completed","failed","cancelled","aborted"],xE={running:"active",waiting:"active",completed:"history",failed:"history",cancelled:"history",aborted:"history"};function KG(e){return VG.filter(t=>xE[t]===e)}function mE(e){return qG.map(t=>({kind:t,threads:e.filter(n=>xE[n.status]===t)})).filter(t=>t.threads.length>0)}const QG=6e4;function GG(e,t=(r,i)=>window.setInterval(r,i),n=r=>window.clearInterval(r)){const r=t(e,QG);return()=>n(r)}function vE(e){const[t,n]=f.useState(()=>Date.now());return f.useEffect(()=>{if(e)return n(Date.now()),GG(()=>n(Date.now()))},[e]),t}function wy(){const e=ae(),t=je();Ni(ey,()=>{t.invalidateQueries(e.threads.list.queryFilter())})}function yE({completed:e,onClick:t,disabled:n}){return o.jsx("button",{type:"button",disabled:n,"aria-label":e?"reopen note":"complete note",onClick:r=>{r.stopPropagation(),t()},style:{width:15,height:15,borderRadius:"50%",border:e?0:"1.5px solid var(--proto-line-3)",background:e?"var(--proto-success)":"transparent",color:"white",padding:0,flex:"none",fontSize:9,cursor:"pointer"},children:e?"✓":""})}function YG({copy:e,busy:t,onAdd:n}){const[r,i]=f.useState(""),s=async a=>{a.preventDefault();const l=r.trim();!l||t||(await n(l),i(""))};return o.jsx("form",{onSubmit:s,style:{margin:"12px 16px 0"},children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,border:"1.5px solid var(--proto-accent)",borderRadius:10,boxShadow:"0 0 0 3px var(--proto-accent-bg)",padding:"9px 12px"},children:[o.jsx("span",{style:{width:15,height:15,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}}),o.jsx("input",{value:r,onChange:a=>i(a.target.value),placeholder:e.inputPlaceholder,"aria-label":e.inputPlaceholder,style:{flex:1,minWidth:0,border:0,outline:0,background:"transparent",fontSize:12.5,color:"var(--proto-ink)"}}),o.jsx("span",{style:{font:"500 9px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",border:"1px solid var(--proto-line-2)",borderRadius:4,padding:"1px 5px"},children:e.enter})]})})}function XG({row:e,copy:t,busy:n,actions:r,onCancel:i}){const[s,a]=f.useState(e.text),l=async()=>{const c=s.trim();!c||n||(await r.onUpdate(e.id,c),i())};return o.jsxs("div",{style:{border:"1px solid var(--proto-accent-border)",borderRadius:9,padding:10},children:[o.jsx("input",{value:s,onChange:c=>a(c.target.value),autoFocus:!0,style:{width:"100%",boxSizing:"border-box",border:"1px solid var(--proto-line-3)",borderRadius:7,padding:"7px 9px",fontSize:12.5,outline:0}}),o.jsxs("div",{style:{display:"flex",gap:6,marginTop:8},children:[o.jsx(Pc,{label:t.save,onClick:l,primary:!0,disabled:n}),o.jsx(Pc,{label:t.cancel,onClick:i,disabled:n})]})]})}function Pc({label:e,onClick:t,primary:n=!1,danger:r=!1,disabled:i=!1}){const s=r?"var(--proto-danger)":n?"white":"var(--proto-muted)";return o.jsx("button",{type:"button",disabled:i,onClick:a=>{a.stopPropagation(),t()},style:{border:n?0:"1px solid var(--proto-line)",borderRadius:7,padding:"4px 10px",background:n?"var(--proto-accent)":"var(--proto-card)",color:s,fontSize:10.5,fontWeight:600,cursor:i?"not-allowed":"pointer"},children:e})}function JG({row:e,copy:t,busy:n,actions:r,targeted:i,onSelect:s}){const[a,l]=f.useState(!1);return a?o.jsx(XG,{row:e,copy:t,busy:n,actions:r,onCancel:()=>l(!1)}):o.jsxs("div",{id:`note-${e.id}`,"data-note-target":e.id,onClick:()=>s(e.id),style:{border:i?"1px solid var(--proto-accent-border)":"1px solid transparent",borderRadius:10,background:i?"var(--proto-accent-bg)":"transparent",padding:"9px 10px",cursor:"pointer"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:9},children:[o.jsx(yE,{completed:!1,disabled:n,onClick:()=>void r.onSetCompleted(e.id,!0)}),o.jsx("span",{style:{fontSize:12.5,fontWeight:600,color:"var(--proto-ink)",lineHeight:1.45,minWidth:0},children:e.text}),o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",flex:"none"},children:e.timeLabel})]}),i&&o.jsxs("div",{"data-note-actions":e.id,style:{display:"flex",gap:6,marginTop:8,paddingLeft:24},children:[o.jsx(Pc,{label:t.handoff,onClick:()=>r.onHandoff(e.text),primary:!0,disabled:n}),o.jsx(Pc,{label:t.edit,onClick:()=>l(!0),disabled:n}),o.jsx(Pc,{label:t.delete,onClick:()=>void r.onDelete(e.id),danger:!0,disabled:n})]})]})}function ZG({row:e,busy:t,onReopen:n}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"8px 10px",opacity:.75},children:[o.jsx(yE,{completed:!0,disabled:t,onClick:n}),o.jsx("span",{style:{fontSize:12.5,color:"var(--proto-muted-2)",textDecoration:"line-through",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.text}),o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",flex:"none"},children:e.timeLabel})]})}function eY(e,t){f.useEffect(()=>{var n;e&&((n=document.getElementById(`note-${e}`))==null||n.scrollIntoView({block:"center"}))},[e]),f.useEffect(()=>{const n=r=>{r.key==="Escape"&&t()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t])}function tY(e){const[t,n]=f.useState(!0);eY(e.targetId,e.onClose);const r=e;return o.jsxs("aside",{"data-notes-pane":"",style:{width:400,flex:"none",background:"var(--proto-card)",borderLeft:"1px solid var(--proto-line)",boxShadow:"-8px 0 24px rgba(16,24,40,.04)",display:"flex",flexDirection:"column",minHeight:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"13px 16px 11px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{fontSize:13,fontWeight:650,color:"var(--proto-ink)"},children:e.copy.title}),o.jsx("span",{style:{font:"600 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",background:"var(--proto-line-2)",padding:"2px 8px",borderRadius:999},children:e.vm.activeCount}),o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:"context/NOTES.md"}),o.jsx("button",{type:"button",onClick:e.onClose,style:{font:"500 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",background:"transparent",cursor:"pointer"},children:e.copy.escape})]}),o.jsx(YG,{copy:e.copy,busy:e.busy,onAdd:e.onAdd}),o.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"10px 14px 14px"},children:[o.jsxs("div",{style:{padding:"6px 2px 7px",fontSize:10,fontWeight:700,letterSpacing:".06em",color:"var(--proto-muted-3)"},children:[e.copy.todo," · ",e.vm.activeCount]}),e.vm.active.map(i=>o.jsx(JG,{row:i,copy:e.copy,busy:e.busy,actions:r,targeted:i.id===e.targetId,onSelect:e.onSelect},i.id)),e.vm.active.length===0&&o.jsx("div",{style:{padding:"14px 10px",fontSize:11,color:"var(--proto-faint)"},children:e.copy.empty}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"12px 2px 7px",borderTop:"1px solid var(--proto-line-2)",marginTop:6},children:[o.jsxs("button",{type:"button",onClick:()=>n(i=>!i),style:{border:0,background:"transparent",padding:0,fontSize:10,fontWeight:700,letterSpacing:".06em",color:"var(--proto-muted-3)",cursor:"pointer"},children:[e.copy.completed," · ",e.vm.completedCount," ",t?"▾":"▸"]}),e.vm.completedCount>0&&o.jsx("button",{type:"button",disabled:e.busy,onClick:()=>void e.onClearCompleted(),style:{marginLeft:"auto",border:0,background:"transparent",color:"var(--proto-danger)",fontSize:10.5,fontWeight:600,cursor:"pointer"},children:e.copy.clear})]}),t&&e.vm.completed.map(i=>o.jsx(ZG,{row:i,busy:e.busy,onReopen:()=>void e.onSetCompleted(i.id,!1)},i.id))]}),o.jsx("div",{style:{padding:"9px 16px",borderTop:"1px solid var(--proto-line-2)",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},children:e.copy.privateHint})]})}function nY(){const e=lh(),t=Be();return o.jsx(tY,{vm:e.vm,copy:e.copy,busy:e.busy,targetId:e.targetId,onSelect:e.open,onClose:e.close,onAdd:e.add,onUpdate:e.update,onSetCompleted:e.setCompleted,onDelete:e.remove,onHandoff:n=>{e.handoff(n),t("/workbench")},onClearCompleted:e.clearCompleted})}function Dg({label:e,count:t,countColor:n,active:r,dot:i,onClick:s}){return o.jsxs("div",{onClick:s,style:{fontSize:12.5,fontWeight:r?600:500,color:r?"var(--proto-ink)":"var(--proto-muted-2)",padding:"13px 0 11px",borderBottom:"2px solid "+(r?"var(--proto-ink)":"transparent"),marginBottom:-1,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:5},children:[e," ",i&&o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",display:"inline-block"}}),o.jsx("span",{style:{font:"500 10px 'IBM Plex Mono',monospace",color:n},children:t})]})}const rY={fontSize:11.5,fontWeight:700,letterSpacing:".06em",textTransform:"uppercase",color:"var(--proto-muted)",padding:"8px 2px 4px"};function oY({group:e,label:t,now:n}){return o.jsxs("section",{children:[o.jsxs("div",{style:rY,children:[t," · ",e.threads.length]}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:e.threads.map(r=>o.jsx(PG,{thread:r,now:n},r.id))})]})}function hh(){const{isOpen:e}=lh();return e?o.jsx(nY,{}):o.jsx(iY,{})}function iY(){var b,y;const e=B(),t=ae(),[n,r]=f.useState("threads"),i=vE(n==="threads");wy();const{currentProjectId:s}=$i(),a=G({...t.cost.summary.queryOptions({projectId:s??void 0}),enabled:!!s}),l=s??void 0,c=G(t.threads.list.queryOptions({projectId:l})),d=mE(c.data??[]),u=G(t.tasks.list.queryOptions({...l?{projectId:l}:{}})),p=G({...t.machines.list.queryOptions({}),refetchInterval:1e4}),h=((b=d.find(j=>j.kind==="active"))==null?void 0:b.threads.length)??0,g=u.data?iG(u.data):0,v=rK(p.data),x=(y=a.data)==null?void 0:y.today,w=typeof x=="number"?qr(x):"—";return o.jsxs("div",{"data-pane":"right",style:{width:400,flex:"none",background:"var(--proto-rail)",borderLeft:"1px solid var(--proto-line)",display:"flex",flexDirection:"column",minHeight:0},children:[o.jsxs("div",{style:{display:"flex",gap:16,padding:"0 18px",borderBottom:"1px solid var(--proto-line)",flex:"none"},children:[o.jsx(Dg,{label:e.threads,count:String(h),countColor:"var(--proto-accent)",active:n==="threads",onClick:()=>r("threads")}),o.jsx(Dg,{label:e.tasks,count:String(g),countColor:"var(--proto-muted-2)",active:n==="tasks",onClick:()=>r("tasks")}),o.jsx(Dg,{label:e.machines,count:String(v),countColor:"var(--proto-muted-2)",active:n==="machines",dot:!0,onClick:()=>r("machines")})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 18px",borderBottom:"1px solid var(--proto-line-2)",flex:"none"},children:[o.jsx("span",{style:{fontSize:10.5,fontWeight:600,color:"var(--proto-muted-2)"},children:e.today}),o.jsx("div",{style:{flex:1,height:4,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden"},children:o.jsx("div",{style:{width:"0%",height:"100%",borderRadius:999,background:"var(--proto-accent)"}})}),o.jsxs("span",{style:{font:"500 10.5px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:[w," / —"]})]}),n==="threads"&&o.jsxs("div",{style:{flex:1,padding:"12px 16px",display:"flex",flexDirection:"column",gap:6,overflow:"auto",minHeight:0},children:[d.map(j=>o.jsx(oY,{group:j,label:j.kind==="active"?e.active:e.history,now:i},j.kind)),c.isSuccess&&d.length===0&&o.jsxs("div",{style:{textAlign:"center",padding:"26px 12px",border:"1px dashed var(--proto-line)",borderRadius:10},children:[o.jsx("div",{style:{fontSize:11.5,fontWeight:600,color:"var(--proto-muted-2)"},children:e.rpNoActiveThreads}),o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",marginTop:4,lineHeight:1.6},children:e.rpNoActiveThreadsHint})]})]}),n==="tasks"&&o.jsx("div",{style:{flex:1,padding:"12px 16px",display:"flex",flexDirection:"column",gap:6,overflow:"auto",minHeight:0},children:o.jsx(cE,{projectId:l})}),n==="machines"&&o.jsx(HG,{})]})}function sY(){const{active:e,split:t}=oh();return o.jsxs("div",{style:{height:"100vh",minHeight:640,minWidth:1280,display:"flex",background:"var(--proto-card)",overflow:"hidden"},children:[o.jsx(uh,{}),o.jsx(eG,{grow:e?1-t:1}),o.jsx(HV,{}),o.jsx(hh,{})]})}function aY(){const e=B();return o.jsxs("section",{className:"flex h-full flex-col p-2g",children:[o.jsx("h1",{className:"mb-2g text-body font-medium text-state-ink",children:e.tasks}),o.jsx(cE,{})]})}function lY(){return o.jsx(Ff,{severity:"waiting",pulse:!0,title:"Rate limit reached — 3 items auto-paused",meta:"resets 14:00 · 2h 08m",children:o.jsxs("div",{className:"flex flex-col gap-1g",children:[o.jsx(Ag,{label:"session morning-review — paused",note:"auto-resumes after reset"}),o.jsx(Ag,{label:"schedule inbox-sweep — paused",note:"pausedBy: rate-limit"}),o.jsx(Ag,{label:"task dispatch — held by guard, queue kept",note:"beforeRunGuard",muted:!0})]})})}function Ag({label:e,note:t,muted:n}){return o.jsxs("div",{className:"flex items-center gap-1g rounded-card border border-card px-1.5g py-1g",children:[o.jsx("span",{className:["h-0.5g w-0.5g flex-none rounded-full",n?"bg-state-gray":"bg-state-wait"].join(" ")}),o.jsx("span",{className:"text-ui text-state-ink/80",children:e}),o.jsx(bn,{muted:!0,className:"ml-auto text-ui",children:t})]})}function cY(){return o.jsxs(Ff,{severity:"info",title:"step 3 · executor:analyze",meta:"fallback chain from profiles.json",children:[o.jsxs("div",{className:"flex flex-col gap-0.5g font-mono text-ui",children:[o.jsxs("div",{className:"flex gap-1g",children:[o.jsx("span",{className:"flex-none text-pill-failed-fg",children:"✕"}),o.jsx("span",{className:"text-state-ink/70",children:"claude · print — transient backend error (exit 1)"})]}),o.jsxs("div",{className:"flex gap-1g",children:[o.jsx("span",{className:"flex-none text-pill-done-fg",children:"→"}),o.jsxs("span",{className:"text-state-ink/80",children:["fallback ",o.jsx("span",{className:"text-pill-running-fg",children:"pi"})," — inherits main profile, step re-run"]})]}),o.jsxs("div",{className:"flex gap-1g",children:[o.jsx("span",{className:"flex-none text-state-ink/30",children:" "}),o.jsx("span",{className:"text-state-ink/40",children:"artifact.md untouched · completed steps not re-run"})]})]}),o.jsx("div",{className:"flex items-center gap-1g",children:o.jsx(qp,{tone:"running",label:"● retrying"})})]})}function dY(){return o.jsx(Ff,{severity:"human",title:o.jsxs("span",{className:"flex items-center gap-1g",children:[o.jsx(bn,{children:"gpu-01"}),o.jsx(qp,{tone:"failed",label:"offline"})]}),meta:"last seen 09:12 · ws closed",detail:o.jsxs("div",{className:"flex flex-col gap-1g",children:[o.jsxs("div",{className:"rounded-card border border-card bg-surface-canvas-alt px-1.5g py-1g font-mono text-ui text-state-ink/70",children:["exec_31c2 → ",o.jsx("span",{className:"text-pill-failed-fg",children:"lost"})," (3 missed heartbeats) · thread notified"]}),o.jsx("div",{className:"rounded-card border border-card bg-surface-canvas-alt px-1.5g py-1g font-mono text-ui text-state-ink/70",children:"T-045 pending held · 4h no callback auto-clears tracking · reopenable"})]}),actions:o.jsxs(o.Fragment,{children:[o.jsx(jt,{variant:"primary",size:"sm",children:"Reopen task"}),o.jsx("span",{className:"self-center text-ui text-state-ink/50",children:"cortex-client auto-reconnects; run state re-read from state file"})]})})}function uY(){return o.jsx(Ff,{severity:"waiting",pulse:!0,title:"Thread paused — would exceed today's budget",meta:"waiting",detail:o.jsxs("span",{children:["Next dispatch est. ",o.jsx(bn,{children:"$6.40"}),", remaining today"," ",o.jsx(bn,{className:"text-pill-failed-fg",children:"$1.10"})," — pre-check held it before dispatch; approval queued ",o.jsx(em,{value:"APR-0008"})]}),actions:o.jsxs(o.Fragment,{children:[o.jsx(jt,{variant:"primary",size:"sm",children:"Approve once"}),o.jsx(jt,{variant:"secondary",size:"sm",children:"Reject"}),o.jsx(jt,{variant:"secondary",size:"sm",children:"Adjust budget…"})]})})}function pY(){return o.jsxs("div",{className:"grid grid-cols-1 gap-2g md:grid-cols-2",children:[o.jsx(lY,{}),o.jsx(cY,{}),o.jsx(dY,{}),o.jsx(uY,{})]})}const fY=["running","waiting","completed","failed","cancelled","aborted","stale","open","done"],_w=["primary","secondary","ghost","danger"];function na({title:e,children:t}){return o.jsxs("section",{className:"flex flex-col gap-2g",children:[o.jsx(la,{title:e}),o.jsx(tm,{padded:!0,children:o.jsx("div",{className:"flex flex-wrap items-center gap-2g",children:t})})]})}function hY(){return o.jsxs("div",{className:"flex h-full flex-col gap-4g overflow-auto p-2g pb-6g",children:[o.jsx(la,{title:"Design Kit",description:"Token-driven core primitives (design §5). All colors from tailwind tokens."}),o.jsx(na,{title:"StatusPill — tones",children:pM.map(e=>o.jsx(qp,{tone:e,label:e},e))}),o.jsx(na,{title:"StatusPill — contract statuses",children:fY.map(e=>o.jsx(qp,{status:e},e))}),o.jsxs(na,{title:"MonoText & ID",children:[o.jsx(bn,{children:"mono-text"}),o.jsx(bn,{muted:!0,children:"mono-text muted"}),o.jsx(em,{value:"thr_99a13064"}),o.jsx(em,{value:"e794",copyable:!0})]}),o.jsxs(na,{title:"Button — variants × sizes",children:[_w.map(e=>o.jsx(jt,{variant:e,size:"md",children:e},e)),_w.map(e=>o.jsxs(jt,{variant:e,size:"sm",children:[e," sm"]},`${e}-sm`)),o.jsx(jt,{variant:"primary",disabled:!0,children:"disabled"})]}),o.jsx(na,{title:"Tooltip",children:o.jsx(iO,{content:"I am a token-styled tooltip",children:o.jsx(jt,{variant:"secondary",children:"Hover me"})})}),o.jsxs("section",{className:"flex flex-col gap-2g",children:[o.jsx(la,{title:"Card + header/body",count:2}),o.jsxs(tm,{children:[o.jsx(mM,{children:o.jsx(bn,{children:"card-header"})}),o.jsx(vM,{children:o.jsx("p",{className:"text-ui text-state-ink/70",children:"Card body content sits on the white surface."})})]})]}),o.jsxs("section",{className:"flex flex-col gap-2g",children:[o.jsx(la,{title:"Tabs"}),o.jsx(tm,{padded:!0,children:o.jsx(d7,{items:[{value:"one",label:"Overview",content:o.jsx(bn,{children:"panel one"})},{value:"two",label:"Details",content:o.jsx(bn,{children:"panel two"})},{value:"three",label:"Logs",content:o.jsx(bn,{children:"panel three"})}]})})]}),o.jsxs("section",{className:"flex flex-col gap-2g",children:[o.jsx(la,{title:"Degraded states (10c)",description:"Unified exception language — amber=waiting, red=needs-human, blue=transient note."}),o.jsx(pY,{})]}),o.jsxs("section",{className:"flex flex-col gap-2g",children:[o.jsx(la,{title:"Empty states (10d)",description:"Every empty panel points to a next action — no dead wall."}),o.jsxs("div",{className:"grid grid-cols-1 gap-2g md:grid-cols-3",children:[o.jsx(lp,{title:"Give Cortex a mission",description:"Describe a goal and success criteria — planning, dispatch and record-keeping follow.",action:o.jsxs("div",{className:"flex w-full flex-col gap-1g",children:[o.jsx("span",{className:"rounded-card border border-card bg-surface-canvas-alt px-1.5g py-1g text-left text-ui text-state-ink/60",children:'"Scan arXiv sim2real each morning and summarize"'}),o.jsx("span",{className:"rounded-card border border-card bg-surface-canvas-alt px-1.5g py-1g text-left text-ui text-state-ink/60",children:'"Finish the σ ablation and find the seed-variance root cause"'})]})}),o.jsx(lp,{title:"No tasks yet",description:"Set a goal in chat and Cortex decomposes a queue with priority, deps and done-when.",action:o.jsx(jt,{variant:"primary",children:"+ Add task"})}),o.jsx(lp,{title:"No threads yet",description:"Complex work runs as multi-agent relay pipelines here — created on dispatch.",action:o.jsx(bn,{muted:!0,children:"!thread experiment-pipeline 〈goal〉"})})]})]}),o.jsx(na,{title:"Overlays — Modal / Drawer / Toast / Popover (esc closes, focus trapped)",children:o.jsx(gY,{})})]})}function gY(){const{toast:e}=Tn();return o.jsxs(o.Fragment,{children:[o.jsx(Wf,{title:"Task detail",description:"Radix Dialog: focus is trapped while open, Esc closes, focus returns to the trigger.",trigger:o.jsx(jt,{variant:"primary",children:"Open Modal"}),footer:o.jsx(fD,{asChild:!0,children:o.jsx(jt,{variant:"secondary",children:"Close"})}),children:o.jsx("p",{children:"Body content on the white token surface. Try Tab / Shift-Tab and Esc."})}),o.jsx(xD,{title:"Details drawer",description:"Side sheet on Radix Dialog — slides in from the right, Esc closes.",trigger:o.jsx(jt,{variant:"secondary",children:"Open Drawer"}),footer:o.jsx(mD,{asChild:!0,children:o.jsx(jt,{variant:"secondary",children:"Close"})}),children:o.jsx("p",{children:"Full-height drawer content. Same a11y as Modal."})}),o.jsx(jt,{variant:"secondary",onClick:()=>e({title:"Task completed",description:"c407 moved open → done",tone:"done"}),children:"Fire Toast"}),o.jsx(X4,{trigger:o.jsx(jt,{variant:"secondary",children:"Open Popover"}),children:o.jsxs("div",{className:"flex flex-col gap-1g",children:[o.jsx(bn,{children:"popover content"}),o.jsx("p",{className:"text-state-ink/70",children:"Positioned by Radix; Esc closes, focus returns."})]})})]})}const xY=[{name:"base",hex:"var(--surface-base)"},{name:"card",hex:"var(--proto-card)"},{name:"rail",hex:"var(--proto-rail)"},{name:"alt",hex:"var(--proto-alt)"},{name:"gray",hex:"var(--proto-gray)"},{name:"ink",hex:"var(--proto-ink)",dark:!0},{name:"ink-2",hex:"var(--proto-ink-2)",dark:!0},{name:"ink-3",hex:"var(--proto-ink-3)",dark:!0},{name:"muted",hex:"var(--proto-muted)",dark:!0},{name:"muted-2",hex:"var(--proto-muted-2)",dark:!0},{name:"muted-3",hex:"var(--proto-muted-3)",dark:!0},{name:"faint",hex:"var(--proto-faint)"},{name:"line",hex:"var(--proto-line)"},{name:"line-2",hex:"var(--proto-line-2)"},{name:"line-3",hex:"var(--proto-line-3)"},{name:"line-4",hex:"var(--proto-line-4)"},{name:"accent",hex:"var(--proto-accent)",dark:!0},{name:"accent-bg",hex:"var(--proto-accent-bg)"},{name:"accent-border",hex:"var(--proto-accent-border)"},{name:"accent-2",hex:"var(--proto-accent-2)",dark:!0},{name:"accent-strong",hex:"var(--proto-accent-strong)",dark:!0},{name:"amber",hex:"var(--proto-amber)",dark:!0},{name:"amber-fg",hex:"var(--proto-amber-fg)",dark:!0},{name:"amber-bg",hex:"var(--proto-amber-bg)"},{name:"amber-border",hex:"var(--proto-amber-border)"},{name:"amber-accent",hex:"var(--proto-amber-accent)",dark:!0},{name:"success",hex:"var(--proto-success)",dark:!0},{name:"success-bg",hex:"var(--proto-success-bg)"},{name:"danger",hex:"var(--proto-danger)",dark:!0},{name:"danger-bg",hex:"var(--proto-danger-bg)"}],mY=["cxblink","cxpulse","cxtoast","cxfade","cxmodal","cxcmdk","cxpop","cxpopup","cxpopover","cxdrawer","cxmodalout","cxcmdkout","cxdrawerout","cxfadeout","cxmsg","cxrise"],vY=["9px","10px","10.5px","11px","12px","15px"];function zu({children:e}){return o.jsx("div",{style:{fontSize:"10px",fontWeight:700,letterSpacing:"0.07em",color:"var(--proto-faint)",textTransform:"uppercase",margin:"28px 0 12px"},children:e})}function yY(){return o.jsxs("div",{style:{padding:"24px 28px",background:"var(--proto-card)",minHeight:"100%",overflow:"auto"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"9px"},children:[o.jsx("div",{style:{width:26,height:26,borderRadius:7,background:"var(--proto-ink)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",font:"600 12px 'IBM Plex Mono',monospace"},children:"cx"}),o.jsx("div",{style:{fontWeight:650,fontSize:14,color:"var(--proto-ink)",letterSpacing:"-0.01em"},children:"Cortex — base specimen"})]}),o.jsx(zu,{children:"Sans (UI)"}),o.jsxs("div",{style:{fontFamily:"inherit",color:"var(--proto-ink)"},children:[o.jsx("div",{style:{fontSize:14,fontWeight:650,letterSpacing:"-0.01em"},children:"Interface heading — 14px / 650"}),o.jsx("div",{style:{fontSize:13,fontWeight:600,marginTop:4},children:"Section label — 13px / 600"}),o.jsx("div",{style:{fontSize:12.5,fontWeight:400,color:"var(--proto-muted)",marginTop:4},children:"Body copy — 12.5px / 400 · The quick brown fox jumps over the lazy dog. 中文界面文字样张。"})]}),o.jsx(zu,{children:"Mono (data / IDs) — IBM Plex Mono"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:vY.map(e=>o.jsxs("div",{style:{font:`500 ${e} 'IBM Plex Mono',monospace`,color:"var(--proto-ink)"},children:["thr_502fb888 · 6d21 · $2.64 · 3m 27s — ",e]},e))}),o.jsx(zu,{children:"Palette (audited prototype colors)"}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(120px, 1fr))",gap:8},children:xY.map(e=>o.jsxs("div",{style:{border:"1px solid var(--proto-line)",borderRadius:8,overflow:"hidden"},children:[o.jsx("div",{style:{height:40,background:e.hex,display:"flex",alignItems:"flex-end",justifyContent:"flex-end",padding:5},children:o.jsx("span",{style:{font:"500 8.5px 'IBM Plex Mono',monospace",color:e.dark?"var(--proto-card)":"var(--proto-muted-3)"},children:e.hex})}),o.jsx("div",{style:{padding:"5px 7px",fontSize:11,fontWeight:600,color:"var(--proto-ink-2)",background:"var(--proto-card)"},children:e.name})]},e.name))}),o.jsx(zu,{children:"Animations — running dot · caret · enter set"}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:20,marginBottom:16},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"var(--proto-accent)",display:"inline-block",animation:"cxpulse 1.6s ease-in-out infinite"}}),o.jsx("span",{style:{fontSize:12,color:"var(--proto-accent)",fontWeight:600},children:"running (cxpulse)"})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"var(--proto-amber)",display:"inline-block",animation:"cxpulse 2s ease-in-out infinite"}}),o.jsx("span",{style:{fontSize:12,color:"var(--proto-amber-fg)",fontWeight:600},children:"approval (cxpulse 2s)"})]}),o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:2},children:[o.jsx("span",{style:{font:"500 12px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:"cortex"}),o.jsx("span",{style:{display:"inline-block",width:7,height:14,background:"var(--proto-ink)",animation:"cxblink 1.1s steps(1) infinite"}}),o.jsx("span",{style:{fontSize:12,color:"var(--proto-muted-3)",marginLeft:6},children:"caret (cxblink)"})]})]}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(110px, 1fr))",gap:8},children:mY.map(e=>o.jsx("div",{style:{border:"1px solid var(--proto-line)",borderRadius:8,padding:"10px 8px",textAlign:"center",background:"var(--proto-rail)",animation:`${e} 1.6s ease-in-out infinite`},children:o.jsx("span",{style:{font:"500 10px 'IBM Plex Mono',monospace",color:"var(--proto-ink-2)"},children:e})},e))})]})}function bY({copy:e,onAdd:t}){const[n,r]=f.useState(""),i=async s=>{s.preventDefault(),s.stopPropagation();const a=n.trim();a&&(await t(a),r(""))};return o.jsx("form",{onSubmit:i,onClick:s=>s.stopPropagation(),style:{margin:"10px 14px 2px"},children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"7px 10px"},children:[o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}}),o.jsx("input",{value:n,onChange:s=>r(s.target.value),placeholder:e.inputPlaceholder,"aria-label":e.inputPlaceholder,style:{flex:1,minWidth:0,border:0,outline:0,background:"transparent",fontSize:11.5,color:"var(--proto-ink)"}}),o.jsx("span",{style:{font:"500 9px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",border:"1px solid var(--proto-line-2)",borderRadius:4,padding:"1px 5px"},children:e.enter})]})})}function jY({row:e,onOpen:t}){return o.jsxs("div",{onClick:n=>{n.stopPropagation(),t(e.id)},style:{display:"flex",alignItems:"center",gap:9,padding:"8px 0",borderBottom:"1px solid var(--proto-alt)",cursor:"pointer"},children:[o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}}),o.jsx("span",{style:{fontSize:11.5,fontWeight:600,color:"var(--proto-ink-2)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:e.text}),o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",flex:"none"},children:e.timeLabel})]})}function wY({vm:e,copy:t,onOpen:n,onAdd:r}){return o.jsxs("div",{"data-notes-overview-card":"",onClick:()=>n(),style:{background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"0 1px 2px rgba(16,24,40,.03)",cursor:"pointer",minWidth:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:t.title}),o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:"context/NOTES.md"})]}),o.jsx(bY,{copy:t,onAdd:r}),o.jsxs("div",{style:{padding:"2px 14px 6px"},children:[e.previews.map(i=>o.jsx(jY,{row:i,onOpen:n},i.id)),e.activeCount===0&&o.jsx("div",{style:{padding:"12px 0",color:"var(--proto-faint)",fontSize:10.5},children:t.empty})]}),o.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"9px 14px",display:"flex",alignItems:"center",fontSize:11,fontWeight:600,color:"var(--proto-accent)"},children:[o.jsxs("span",{children:[t.viewAll," ",e.activeCount," ›"]}),o.jsxs("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},children:[t.completed," ",e.completedCount]})]})]})}function tn(e){return"$"+(e??0).toFixed(2)}const kY=5;function bE(e,t){if(t==null||t<=0)return null;const n=(e??0)/t*100;return Math.max(0,Math.min(100,n))}function SY(e){return e==null||e<=0?"—":tn(e)}function CY(e){if(!e||e.length===0)return[];const t=e.reduce((r,i)=>Math.max(r,i.cost),0),n=e.length-1;return e.map((r,i)=>({pct:t>0?r.cost/t*100:0,date:r.date,cost:r.cost,isToday:i===n}))}function TY(e){return!e||e.length===0?null:e.reduce((n,r)=>n+r.cost,0)/e.length}function EY(e,t="week"){if(!e)return[];const n=Object.entries(e).map(([i,s])=>({label:i,cost:s[t]})).filter(i=>i.cost>0).sort((i,s)=>s.cost-i.cost).slice(0,kY),r=n.reduce((i,s)=>i+s.cost,0);return n.map(i=>({label:i.label,cost:i.cost,pct:r>0?i.cost/r*100:0}))}function RY(e,t){var n;if(e.length){const r=[...e].sort((i,s)=>Date.parse(s.lastUsedAt||s.createdAt)-Date.parse(i.lastUsedAt||i.createdAt))[0];if(r!=null&&r.projectId)return r.projectId}return((n=t[0])==null?void 0:n.id)??null}function PY(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0");return`${n}:${r}`}function IY(e){return(e.type==="daily"||e.type==="weekly")&&e.nextRun?`${e.type} ${PY(e.nextRun)}`:e.type}function Fw(e){return e.profile??""}function jE(e){const t=Math.round(e/6e4);if(t<1)return"<1m";if(t<60)return`${t}m`;const n=Math.round(e/36e5);return n<24?`${n}h`:`${Math.round(e/864e5)}d`}function MY(e,t){if(!e)return"—";const n=Date.parse(e)-t;return n<=0?"due":`next in ${jE(n)}`}function zw(e,t){if(!e)return"never run";const n=t-Date.parse(e);return`last ${jE(Math.max(0,n))} ago`}function LY(e,t){return typeof e.durationMs=="number"?e.durationMs:e.startedAt?Math.max(0,t-Date.parse(e.startedAt)):null}function OY(e){if(e==null)return"—";if(e>=36e5){const t=Math.floor(e/36e5),n=Math.round(e%36e5/6e4);return`${t}h ${n}m`}return e>=6e4?`${Math.round(e/6e4)}m`:`${Math.round(e/1e3)}s`}function DY(e){return e.machine??"local"}function AY(e){return e==null?"—":"$"+e.toFixed(2)}function NY(e){switch(e){case"running":return{text:"running",bg:"#EEF0FA",color:"#4655D4",dot:!0};case"completed":return{text:"done",bg:"#E9F4EE",color:"#23854F",dot:!1};case"failed":return{text:"failed",bg:"#FBEDEB",color:"#C03D33",dot:!1};case"cancelled":return{text:"cancelled",bg:"#F1F2F5",color:"#8A93A2",dot:!1};case"stale":default:return{text:"stale",bg:"#F1F2F5",color:"#8A93A2",dot:!1}}}function $Y(e){return e.taskId?`task ${e.taskId}`:e.sessionId?`session ${e.sessionId}`:`${e.type} execution`}const ra={background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"0 1px 2px rgba(16,24,40,.03)",minWidth:0};function Bu({title:e,right:t}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:e}),t!=null&&o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:t})]})}function _Y(){var R;const e=B(),t=Be(),n=ae(),r=je(),{open:i}=O3(),{open:s}=N3(),{open:a}=Mq(),l=lh(),c=Date.now(),{currentProjectId:d}=$i(),u=d??"—",h=G({...n.cost.summary.queryOptions({projectId:d??void 0}),enabled:!!d}).data,g=bE(h==null?void 0:h.today,h==null?void 0:h.dailyBudget),v=f.useMemo(()=>CY(h==null?void 0:h.dailyCost),[h==null?void 0:h.dailyCost]),x=f.useMemo(()=>TY(h==null?void 0:h.dailyCost),[h==null?void 0:h.dailyCost]),w=f.useMemo(()=>EY(h==null?void 0:h.byTriggerScoped,"week"),[h==null?void 0:h.byTriggerScoped]),y=G({...n.schedules.list.queryOptions({projectId:d??void 0}),enabled:!!d}).data??[],j=G(n.executions.list.queryOptions({limit:50})),S=f.useMemo(()=>{const P=j.data??[];return(d?P.filter(_=>_.projectId===d):P).slice(0,6)},[j.data,d]),k=G({...n.issues.list.queryOptions({projectId:d??""}),enabled:!!d}),E=f.useMemo(()=>k.data??[],[k.data]),C=ue(n.schedules.resume.mutationOptions({onSuccess:()=>{r.invalidateQueries(n.schedules.list.queryFilter())}}));return o.jsxs("div",{"data-pane":"center",style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",minHeight:0,background:"var(--proto-card)"},children:[o.jsxs("div",{style:{height:50,flex:"none",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:9,padding:"0 20px",background:"var(--proto-card)"},children:[o.jsx("span",{onClick:()=>t("/workbench"),style:{fontSize:14,color:"var(--proto-muted)",cursor:"pointer",padding:"4px 8px 4px 0"},children:"‹"}),o.jsx("span",{style:{font:"500 12px 'IBM Plex Mono',monospace",color:"var(--proto-muted-2)"},children:u}),o.jsx("span",{style:{color:"var(--proto-line-3)"},children:"/"}),o.jsx("span",{style:{fontSize:12.5,fontWeight:600,color:"var(--proto-ink)"},children:e.overview}),o.jsxs("span",{style:{position:"relative",marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:8},children:[E.length>0&&o.jsxs("span",{"data-issues-stat":"",onClick:()=>a(),style:{display:"inline-flex",alignItems:"center",gap:4,font:"500 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",padding:"3px 8px",cursor:"pointer"},children:[o.jsx("b",{style:{color:"var(--proto-accent)"},children:E.length})," ",e.issuesStat]}),o.jsx("span",{style:{width:1,height:18,background:"var(--proto-line)",flex:"none"}}),o.jsx(KT,{count:l.vm.activeCount,active:l.isOpen,copy:l.copy,onClick:()=>l.isOpen?l.close():l.open()}),o.jsx("span",{style:{fontSize:11.5,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:7,padding:"4px 12px",color:"var(--proto-ink)",background:"var(--proto-card)",cursor:"pointer"},children:e.adjustBudget}),o.jsx("span",{style:{color:"var(--proto-muted-2)",fontSize:15,letterSpacing:1,padding:"2px 6px",borderRadius:6,cursor:"pointer"},children:"⋯"})]})]}),o.jsxs("div",{style:{flex:"none",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:30,padding:"12px 20px 14px",background:"var(--proto-card)"},children:[o.jsxs("div",{style:{minWidth:180},children:[o.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginBottom:3},children:e.today}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("span",{style:{font:"600 22px 'IBM Plex Mono',monospace",color:"var(--proto-ink)",letterSpacing:"-.02em"},children:tn(h==null?void 0:h.today)}),o.jsx("div",{style:{flex:1,height:5,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden",marginTop:2},children:o.jsx("div",{style:{width:`${g??0}%`,height:"100%",background:"var(--proto-accent)"}})})]})]}),o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginBottom:3},children:e.thisWeek}),o.jsx("div",{style:{font:"600 15px 'IBM Plex Mono',monospace",color:"var(--proto-ink-2)"},children:tn(h==null?void 0:h.week)})]}),o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginBottom:3},children:e.month}),o.jsx("div",{style:{font:"600 15px 'IBM Plex Mono',monospace",color:"var(--proto-ink-2)"},children:tn(h==null?void 0:h.month)})]}),o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginBottom:3},children:e.budgetPerDay}),o.jsxs("div",{style:{font:"600 15px 'IBM Plex Mono',monospace",color:"var(--proto-ink-2)"},children:[SY(h==null?void 0:h.dailyBudget),o.jsxs("span",{style:{fontSize:10,color:"var(--proto-muted-3)",fontWeight:400},children:[" ",e.perDay]})]})]}),o.jsxs("div",{style:{marginLeft:"auto",textAlign:"right"},children:[o.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginBottom:3},children:e.forecastToday}),o.jsx("div",{style:{font:"600 15px 'IBM Plex Mono',monospace",color:"var(--proto-amber-text)"},children:tn(h==null?void 0:h.forecastToday)})]})]}),o.jsxs("div",{style:{flex:1,overflow:"auto",minHeight:0,padding:"14px 20px",display:"grid",gridTemplateColumns:"1fr 1fr",gridAutoRows:"min-content",gap:12,background:"var(--proto-alt)",alignContent:"start"},children:[o.jsxs("div",{style:ra,children:[o.jsx(Bu,{title:e.ovLast14Days,right:`${e.ovAvg} ${x==null?"—":tn(x)}${e.perDay}`}),o.jsxs("div",{style:{padding:"14px 14px 10px"},children:[o.jsx("div",{style:{display:"flex",alignItems:"flex-end",gap:5,height:96},children:v.map(P=>P.isToday?o.jsx("div",{title:`${P.date} · ${tn(P.cost)}`,style:{flex:1,position:"relative",background:"var(--proto-accent)",borderRadius:"3px 3px 0 0",height:`${P.pct}%`},children:o.jsx("div",{style:{position:"absolute",bottom:"100%",left:"50%",transform:"translateX(-50%)",marginBottom:5,font:"600 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-accent)",whiteSpace:"nowrap"},children:tn(P.cost)})},P.date):o.jsx("div",{title:`${P.date} · ${tn(P.cost)}`,style:{flex:1,background:"var(--proto-line-4)",borderRadius:"3px 3px 0 0",height:`${P.pct}%`}},P.date))}),o.jsxs("div",{style:{display:"flex",alignItems:"center",marginTop:7,font:"400 9px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},children:[o.jsx("span",{children:((R=v[0])==null?void 0:R.date)??"—"}),o.jsx("span",{style:{marginLeft:"auto",color:"var(--proto-accent)",fontWeight:600},children:e.today})]})]})]}),o.jsxs("div",{style:{...ra,cursor:"pointer"},onClick:()=>t("/memory"),children:[o.jsx(Bu,{title:e.projectMemory,right:e.ovGitBacked}),o.jsxs("div",{style:{padding:"18px 14px",display:"flex",flexDirection:"column",alignItems:"center",gap:4,textAlign:"center"},children:[o.jsxs("div",{style:{fontSize:11.5,fontWeight:600,color:"var(--proto-accent)"},children:[e.ovOpenMemoryViewer," ›"]}),o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",lineHeight:1.5},children:e.ovMemoryDesc})]})]}),o.jsx(wY,{vm:l.vm,copy:l.copy,onOpen:l.open,onAdd:l.add}),E.length>0&&o.jsxs("div",{style:ra,"data-issues-card":"",children:[o.jsx(Bu,{title:e.issuesTitle,right:"ISSUES.md"}),o.jsx("div",{style:{padding:"4px 14px 6px"},children:E.slice(0,3).map((P,L)=>o.jsxs("div",{onClick:()=>a(P.id),style:{display:"flex",alignItems:"center",gap:9,padding:"8px 0",borderBottom:L<Math.min(E.length,3)-1?"1px solid var(--proto-alt)":"none",cursor:"pointer"},children:[o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"var(--proto-muted-2)",strokeWidth:"1.5",style:{flex:"none"},children:[o.jsx("circle",{cx:"7",cy:"7",r:"5.5"}),o.jsx("path",{d:"M7 4.2v3.3"}),o.jsx("circle",{cx:"7",cy:"9.8",r:".4",fill:"var(--proto-muted-2)"})]}),o.jsx("span",{style:{fontSize:11.5,fontWeight:600,color:"var(--proto-ink-2)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:P.title}),P.date&&o.jsx("span",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",flex:"none"},children:P.date}),o.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--proto-accent)",flex:"none"},children:"↗"})]},P.id))}),o.jsxs("div",{onClick:()=>a(),style:{borderTop:"1px solid var(--proto-line-2)",padding:"9px 14px",fontSize:11,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:[e.isViewAll," ",E.length," ›"]})]}),o.jsxs("div",{style:ra,children:[o.jsx(Bu,{title:e.ovWhereItGoes,right:e.thisWeek}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,padding:"13px 14px 14px"},children:[w.length===0&&o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",padding:"2px 0"},children:e.ovNoSpend}),w.map((P,L)=>o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[o.jsx("span",{title:P.label,style:{fontSize:10.5,color:"var(--proto-muted)",width:56,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:P.label}),o.jsx("div",{style:{flex:1,height:6,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden"},children:o.jsx("div",{style:{width:`${P.pct}%`,height:"100%",background:["var(--proto-accent)","var(--proto-accent-2)","var(--proto-accent-bg)"][L%3]}})}),o.jsx("span",{style:{font:"500 10px 'IBM Plex Mono',monospace",color:"var(--proto-ink)",width:40,textAlign:"right"},children:tn(P.cost)})]},P.label))]})]}),o.jsxs("div",{style:ra,children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:e.scheduleCard}),o.jsxs("span",{onClick:()=>s({projectId:d}),style:{marginLeft:"auto",fontSize:11,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:["+ ",e.newSchedule]})]}),o.jsxs("div",{style:{padding:"9px 14px 11px",display:"flex",flexDirection:"column",gap:9},children:[y.length===0&&o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",padding:"4px 0"},children:e.ovNoSchedules}),y.map((P,L)=>o.jsxs("div",{children:[L>0&&o.jsx("div",{style:{height:1,background:"var(--proto-line-soft)",margin:"0 0 9px"}}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[o.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 14 14",fill:"none",stroke:P.paused?"var(--proto-muted-2)":"var(--proto-muted)",strokeWidth:"1.5",children:[o.jsx("circle",{cx:"7",cy:"7",r:"5.6"}),o.jsx("path",{d:"M7 4v3.2l2.2 1.3"})]}),o.jsx("span",{title:P.message,style:{flex:1,minWidth:0,fontSize:11.5,fontWeight:600,color:P.paused?"var(--proto-muted-2)":"var(--proto-ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:P.message}),P.paused&&o.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"1px 6px",borderRadius:999,background:"var(--proto-gray)",color:"var(--proto-muted-2)"},children:e.paused}),o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:IY(P)})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",fontSize:10,color:"var(--proto-muted-2)",marginTop:2,paddingLeft:18},children:[o.jsx("span",{children:P.paused?`${zw(P.lastRun,c)}`:`${MY(P.nextRun,c)} · ${zw(P.lastRun,c)}`}),Fw(P)&&o.jsx("span",{title:"profile",style:{marginLeft:7,font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:Fw(P)}),P.paused&&o.jsx("span",{onClick:()=>!C.isPending&&C.mutate({scheduleId:P.id}),style:{marginLeft:"auto",fontSize:10.5,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:e.resume})]})]},P.id))]})]}),o.jsxs("div",{style:{...ra,gridColumn:"span 2",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:e.execFlow}),o.jsx("span",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",marginLeft:8},children:e.ovExecSubtitle}),o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},children:"executions.json"})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"88px 1fr 76px 52px 56px 86px 46px",padding:"6px 14px",borderBottom:"1px solid var(--proto-line-soft)",fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)"},children:[o.jsx("span",{children:e.ovColId}),o.jsx("span",{children:e.ovColSummary}),o.jsx("span",{children:e.ovColMachine}),o.jsx("span",{children:e.ovColDur}),o.jsx("span",{children:e.ovColCost}),o.jsx("span",{children:e.ovColStatus}),o.jsx("span",{})]}),S.length===0&&o.jsx("div",{style:{padding:"10px 14px",fontSize:10.5,color:"var(--proto-faint)"},children:e.ovNoExecutions}),S.map(P=>{const L=NY(P.status);return o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"88px 1fr 76px 52px 56px 86px 46px",padding:"7.5px 14px",borderBottom:"1px solid var(--proto-alt)",alignItems:"center",fontSize:11,color:"var(--proto-ink-2)"},children:[o.jsx("span",{title:P.id,style:{font:"400 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",paddingRight:8},children:P.id}),o.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",paddingRight:12},children:$Y(P)}),o.jsx("span",{style:{font:"400 10px 'IBM Plex Mono',monospace"},children:DY(P)}),o.jsx("span",{style:{font:"400 10px 'IBM Plex Mono',monospace"},children:OY(LY(P,c))}),o.jsx("span",{style:{font:"400 10px 'IBM Plex Mono',monospace"},children:AY(P.cost)}),o.jsx("span",{children:o.jsxs("span",{style:{fontSize:9,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:L.bg,color:L.color},children:[L.dot?"• ":"",L.text]})}),o.jsx("span",{onClick:()=>i(P.id),style:{fontSize:10.5,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:e.ovLogs})]},P.id)})]})]})]})}function FY(){return o.jsxs("div",{style:{height:"100vh",minHeight:640,minWidth:1280,display:"flex",background:"var(--proto-card)",overflow:"hidden"},children:[o.jsx(uh,{}),o.jsx(_Y,{}),o.jsx(hh,{})]})}function zY(e,t){const n=e.files.map(i=>({name:i.name,kind:"file",path:i.name,selectable:!0,selected:i.name===t,right:null})),r=e.dirs.map(i=>({name:`${i.name}/`,kind:"dir",path:null,selectable:!1,selected:!1,right:String(i.entryCount)}));return[...n,...r]}function BY(e){var t;return((t=e.files[0])==null?void 0:t.name)??null}function WY(e,t){if(!e)return"updated —";const n=Date.parse(e);if(Number.isNaN(n))return"updated —";const r=Math.max(0,t-n),i=Math.round(r/6e4);if(i<1)return"updated <1m ago";if(i<60)return`updated ${i}m ago`;const s=Math.round(r/36e5);return s<24?`updated ${s}h ago`:`updated ${Math.round(r/864e5)}d ago`}function UY(e){return e?{label:"Viewing diff",color:"#fff",bg:"#4655D4",border:"#4655D4"}:{label:"Diff hidden",color:"#4655D4",bg:"#fff",border:"#C9CFF2"}}function HY(e){return e?{added:`+${e.added}`,removed:`−${e.removed}`}:null}function qY(e,t){if(!e)return null;const n=new Map;for(const s of e)n.set(s.line,s);const r=t.split(`
|
|
139
|
+
`);r.length>1&&r[r.length-1]===""&&r.pop();let i;return r.map((s,a)=>{const l=a+1,c=n.get(l)??null,d=c?c.commit:null,u=d!==i;return i=d,{lineNo:l,text:s,commit:d,taskRef:c?c.taskRef:null,groupStart:u}})}const df="'IBM Plex Mono',monospace";function oa(e){return e.map((t,n)=>{switch(t.type){case"bold":return o.jsx("span",{style:{fontWeight:650,color:"var(--proto-ink-2)"},children:t.text},n);case"italic":return o.jsx("em",{style:{fontStyle:"italic"},children:t.text},n);case"code":return o.jsx("code",{style:{font:`400 .92em ${df}`,background:"var(--proto-gray)",color:"var(--proto-accent-strong)",padding:"1px 4px",borderRadius:4},children:t.text},n);case"link":return o.jsx("a",{href:t.href,style:{color:"var(--proto-accent)",textDecoration:"none"},children:t.text},n);default:return o.jsx(f.Fragment,{children:t.text},n)}})}const VY={fontSize:12.5,fontWeight:650,color:"var(--proto-ink)",margin:"15px 0 5px"},KY={fontSize:11.5,lineHeight:1.65,color:"var(--proto-ink-3)",margin:"4px 0 0"};function QY(e,t){switch(e.type){case"heading":return o.jsx("div",{style:{...VY,fontSize:e.level>=3?11.5:12.5},children:oa(e.inline)},t);case"paragraph":return o.jsx("div",{style:KY,children:oa(e.inline)},t);case"list":return o.jsx("div",{style:{fontSize:11.5,lineHeight:1.75,color:"var(--proto-ink-3)",margin:"4px 0 0"},children:e.items.map((n,r)=>o.jsxs("div",{style:{display:"flex",gap:9},children:[o.jsx("span",{style:{color:"var(--proto-faint)",flex:"none"},children:e.ordered?`${r+1}.`:"·"}),o.jsx("span",{children:oa(n)})]},r))},t);case"table":{const n=Math.max(e.header.length,...e.rows.map(i=>i.length),1),r=`repeat(${n}, minmax(0,1fr))`;return o.jsxs("div",{style:{border:"1px solid var(--proto-line-2)",borderRadius:8,overflow:"hidden",fontSize:11,margin:"7px 0 0"},children:[o.jsx("div",{style:{display:"grid",gridTemplateColumns:r,padding:"6px 12px",background:"var(--proto-rail)",borderBottom:"1px solid var(--proto-line-2)",fontSize:9,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)"},children:e.header.map((i,s)=>o.jsx("span",{children:oa(i)},s))}),e.rows.map((i,s)=>o.jsx("div",{style:{display:"grid",gridTemplateColumns:r,padding:"6px 12px",borderBottom:"1px solid var(--proto-alt)",color:"var(--proto-ink-3)"},children:Array.from({length:n}).map((a,l)=>o.jsx("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",paddingRight:8},children:i[l]?oa(i[l]):null},l))},s))]},t)}case"code":return o.jsx("pre",{style:{background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:8,padding:"10px 13px",font:`400 10.5px ${df}`,color:"var(--proto-ink-2)",overflow:"auto",margin:"7px 0 0",whiteSpace:"pre"},children:e.text},t);case"blockquote":return o.jsx("div",{style:{borderLeft:"2px solid var(--proto-line-3)",padding:"2px 0 2px 9px",margin:"7px 0 0",fontSize:11.5,lineHeight:1.65,color:"var(--proto-muted)"},children:oa(e.inline)},t);case"hr":return o.jsx("div",{style:{height:1,background:"var(--proto-line-2)",margin:"12px 0"}},t);default:return null}}function GY({content:e}){const t=B(),{frontmatter:n,body:r}=jB(e),i=$6(r);return o.jsxs("div",{children:[n&&(n.entries.length>0||n.summary)&&o.jsxs("div",{style:{background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:8,padding:"10px 13px"},children:[o.jsx("div",{style:{display:"flex",alignItems:"center",gap:13,font:`400 10px ${df}`,color:"var(--proto-muted)",flexWrap:"wrap"},children:n.entries.map((s,a)=>o.jsxs("span",{children:[o.jsx("span",{style:{color:"var(--proto-muted-3)"},children:s.key})," ",s.value]},a))}),n.summary&&o.jsxs("div",{style:{fontSize:11,color:"var(--proto-ink-2)",marginTop:6},children:[o.jsx("span",{style:{font:`400 10px ${df}`,color:"var(--proto-muted-3)"},children:t.memSummary})," ",n.summary]})]}),i.map((s,a)=>QY(s,a))]})}const no="'IBM Plex Mono',monospace";function YY({rows:e}){let t=-1;return o.jsx("div",{style:{font:`400 11px ${no}`,lineHeight:1.55},children:e.map(n=>{n.groupStart&&(t+=1);const r=t%2===0?"var(--proto-rail)":"var(--proto-accent-bg)";return o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:10,background:r,borderLeft:n.groupStart?"2px solid var(--proto-accent)":"2px solid transparent",padding:"0 8px"},children:[o.jsx("span",{style:{width:34,flex:"none",textAlign:"right",color:"var(--proto-line)",fontSize:9.5},children:n.lineNo}),o.jsx("span",{style:{width:66,flex:"none",color:"var(--proto-muted-2)",fontSize:9.5},children:n.groupStart&&n.commit?n.commit:""}),o.jsx("span",{style:{width:52,flex:"none"},children:n.groupStart&&n.taskRef&&o.jsx("span",{style:{fontSize:9,fontWeight:600,color:"var(--proto-accent)",background:"var(--proto-accent-bg)",border:"1px solid var(--proto-accent-border)",borderRadius:999,padding:"1px 6px"},children:n.taskRef})}),o.jsx("span",{style:{flex:1,minWidth:0,color:"var(--proto-ink-2)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:n.text||" "})]},n.lineNo)})})}function XY({row:e,onPick:t}){const[n,r]=f.useState(!1),i=e.selected?"var(--proto-accent-bg)":n&&e.selectable?"var(--proto-gray)":"transparent",s=e.selected||e.kind==="dir"?600:500,a=e.selected?"var(--proto-accent)":"var(--proto-ink-2)";return o.jsxs("div",{onClick:e.selectable&&e.path?()=>t(e.path):void 0,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{display:"flex",alignItems:"center",gap:7,padding:"5px 8px",background:i,borderRadius:7,cursor:e.selectable?"pointer":"default"},children:[o.jsx("span",{style:{font:`${s} 10.5px ${no}`,color:a,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.name}),e.right!=null&&o.jsx("span",{style:{marginLeft:"auto",font:`400 8.5px ${no}`,color:"var(--proto-faint)",flex:"none"},children:e.right})]})}const JY={flex:1,minWidth:0,display:"flex",flexDirection:"column",minHeight:0,background:"var(--proto-card)"};function ZY(){const e=Be(),t=ae(),n=B(),r=Date.now(),[i,s]=f.useState(null),[a,l]=f.useState(!0),c=G(t.projects.list.queryOptions({})),d=G(t.sessions.list.queryOptions({})),u=c.data??[],p=d.data??[],h=f.useMemo(()=>RY(p,u),[p,u]),g=h??"—",v=G({...t.memory.tree.queryOptions({projectId:h??""}),enabled:!!h}),x=v.data,w=i??(x?BY(x):null),b=G({...t.memory.file.queryOptions({projectId:h??"",path:w??""}),enabled:!!h&&!!w}),y=b.data,j=x?zY(x,w):[],S=UY(a),k=HY(y==null?void 0:y.lineDiff),E=qY(y==null?void 0:y.blame,(y==null?void 0:y.content)??"");return o.jsxs("div",{"data-pane":"center",style:JY,children:[o.jsxs("div",{style:{height:50,flex:"none",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:9,padding:"0 20px",background:"var(--proto-card)"},children:[o.jsx("span",{onClick:()=>e("/overview"),style:{fontSize:14,color:"var(--proto-muted)",cursor:"pointer",padding:"4px 8px 4px 0"},children:"‹"}),o.jsx("span",{onClick:()=>e("/overview"),style:{font:`500 12px ${no}`,color:"var(--proto-muted-2)",cursor:"pointer"},children:g}),o.jsx("span",{style:{color:"var(--proto-line-3)"},children:"/"}),o.jsx("span",{style:{fontSize:12.5,fontWeight:600,color:"var(--proto-ink)"},children:n.memMemory}),o.jsx("span",{style:{color:"var(--proto-line-3)"},children:"/"}),o.jsx("span",{style:{font:`500 12px ${no}`,color:"var(--proto-muted)"},children:w??"—"}),o.jsx("span",{style:{marginLeft:"auto",font:`400 10px ${no}`,color:"var(--proto-muted-3)"},children:n.ovGitBacked})]}),o.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{width:200,flex:"none",borderRight:"1px solid var(--proto-line)",background:"var(--proto-rail)",padding:"8px 6px",overflow:"auto"},children:[v.isLoading&&o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",padding:"6px 8px"},children:n.memLoading}),!v.isLoading&&j.length===0&&o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",padding:"6px 8px"},children:n.memNoFiles}),j.map(C=>o.jsx(XY,{row:C,onPick:s},C.name))]}),o.jsxs("div",{style:{flex:1,minWidth:0,background:"var(--proto-card)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",gap:8,padding:"8px 20px",background:"var(--proto-accent-bg)",borderBottom:"1px solid var(--proto-accent-bg)"},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",flex:"none"}}),o.jsx("span",{style:{fontSize:11,color:"var(--proto-accent-strong)"},children:WY(y==null?void 0:y.modifiedAt,r)}),k?o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{font:`600 10px ${no}`,color:"var(--proto-success)"},children:k.added}),o.jsx("span",{style:{font:`600 10px ${no}`,color:"var(--proto-danger)"},children:k.removed})]}):o.jsx("span",{style:{font:`400 9.5px ${no}`,color:"var(--proto-muted-3)"},children:n.memDiffUnavailable}),o.jsx("span",{onClick:()=>l(C=>!C),style:{marginLeft:"auto",fontSize:10,fontWeight:600,color:S.color,background:S.bg,border:`1px solid ${S.border}`,borderRadius:999,padding:"2px 10px",cursor:"pointer"},children:S.label})]}),o.jsxs("div",{style:{flex:1,overflow:"auto",minHeight:0,padding:"18px 24px 24px"},children:[a&&o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-amber-fg)",background:"var(--proto-amber-bg)",border:"1px solid var(--proto-amber-border)",borderRadius:7,padding:"6px 11px",marginBottom:12,lineHeight:1.5},children:E?o.jsxs(o.Fragment,{children:[k?`${k.added} / ${k.removed} ${n.memLinesChanged} `:"",n.memBlameNote]}):o.jsx(o.Fragment,{children:n.memBlameUnavailable})}),b.isLoading&&o.jsx("div",{style:{fontSize:11.5,color:"var(--proto-faint)"},children:n.memLoadingFile}),b.isError&&o.jsx("div",{style:{fontSize:11.5,color:"var(--proto-danger)"},children:n.memReadError}),y&&a&&E?o.jsx(YY,{rows:E}):y&&o.jsx(GY,{content:y.content}),!b.isLoading&&!b.isError&&!y&&o.jsx("div",{style:{fontSize:11.5,color:"var(--proto-faint)"},children:n.memSelectFile})]})]})]})]})}function eX(){return o.jsxs("div",{style:{height:"100vh",minHeight:640,minWidth:1280,display:"flex",background:"var(--proto-card)",overflow:"hidden"},children:[o.jsx(uh,{}),o.jsx(ZY,{}),o.jsx(hh,{})]})}const Ic="'IBM Plex Mono', monospace";function tX({name:e}){return o.jsxs("span",{style:{display:"inline-flex",alignItems:"center",fontSize:11,fontWeight:500,color:"var(--proto-accent)",background:"var(--proto-accent-bg)",border:"1px solid var(--proto-accent-border)",borderRadius:999,padding:"2px 10px",fontFamily:Ic,letterSpacing:.1},children:["/",e]})}function nX({group:e}){const t=B(),n=e.plugin??t.skUserSkills;return o.jsxs("div",{style:{marginBottom:28},children:[o.jsxs("div",{style:{fontSize:10.5,fontWeight:700,color:"var(--proto-muted-2)",letterSpacing:.8,textTransform:"uppercase",marginBottom:10,fontFamily:Ic},children:[n,o.jsxs("span",{style:{marginLeft:8,fontSize:10,fontWeight:500,color:"var(--proto-line)",letterSpacing:0,textTransform:"none"},children:[e.skills.length," ",e.skills.length===1?"skill":"skills"]})]}),o.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:7},children:e.skills.map(r=>o.jsx(tX,{name:r},r))})]})}function rX(){const e=ae(),t=B(),{data:n,isLoading:r,isError:i}=G(e.skills.list.queryOptions({})),s=n??[],a=s.reduce((l,c)=>l+c.skills.length,0);return o.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--proto-rail)"},children:[o.jsxs("div",{style:{padding:"20px 28px 16px",borderBottom:"1px solid var(--proto-line-2)",background:"var(--proto-card)",flex:"none"},children:[o.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--proto-ink)",letterSpacing:-.3},children:t.skTitle}),o.jsx("div",{style:{fontSize:11.5,color:"var(--proto-muted-2)",marginTop:3},children:r?t.skScanning:i?t.skLoadError:`${a} skill${a!==1?"s":""} across ${s.length} group${s.length!==1?"s":""}`})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"24px 28px"},children:[r&&o.jsx("div",{style:{fontSize:12,color:"var(--proto-line)",fontFamily:Ic},children:t.skLoadingBody}),i&&o.jsx("div",{style:{fontSize:12,color:"var(--proto-danger)",fontFamily:Ic},children:t.skFailedBody}),!r&&!i&&s.length===0&&o.jsx("div",{style:{fontSize:12,color:"var(--proto-line)",fontFamily:Ic},children:t.skEmpty}),s.map(l=>o.jsx(nX,{group:l},l.plugin??"__user__"))]})]})}function oX(){return o.jsxs("div",{style:{height:"100vh",minHeight:640,minWidth:1280,display:"flex",background:"var(--proto-card)",overflow:"hidden"},children:[o.jsx(uh,{}),o.jsx(rX,{}),o.jsx(hh,{})]})}const iX=on()?UC:WC,sX=iX([{path:"/",element:o.jsx(FV,{}),children:[{index:!0,element:o.jsx(xm,{to:"/workbench",replace:!0})},{path:"workbench",element:o.jsx(sY,{})},{path:"tasks",element:o.jsx(aY,{})},{path:"threads",element:o.jsx(zV,{title:"Threads"})},{path:"overview",element:o.jsx(FY,{})},{path:"memory",element:o.jsx(eX,{})},{path:"skills",element:o.jsx(oX,{})},{path:"kit",element:o.jsx(hY,{})},{path:"base",element:o.jsx(yY,{})}]}]),gh=[{id:"sessions",path:"/m/sessions",labelKey:"sessions"},{id:"threads",path:"/m/threads",labelKey:"threads"},{id:"tasks",path:"/m/tasks",labelKey:"tasks"},{id:"project",path:"/m/project",labelKey:"project"}];function ml(e){return e.length>1?e.replace(/\/+$/,""):e}const aX=[{prefix:"/m/session/",tab:"sessions"},{prefix:"/m/thread/",tab:"threads"},{prefix:"/m/task/",tab:"tasks"},{prefix:"/m/approvals",tab:"project"},{prefix:"/m/issues",tab:"project"},{prefix:"/m/notes",tab:"project"},{prefix:"/m/memory",tab:"project"},{prefix:"/m/machines",tab:"project"},{prefix:"/m/settings",tab:"project"},{prefix:"/m/daemon",tab:"project"}];function lX(e){const t=ml(e),n=gh.find(i=>t===i.path||t.startsWith(i.path+"/"));if(n)return n.id;const r=aX.find(i=>t===i.prefix||t.startsWith(i.prefix));return r?r.tab:"sessions"}function $a(e){const t=ml(e);return gh.some(n=>t===n.path)}function cX(e){const t=ml(e);return gh.some(n=>t===n.path||t.startsWith(n.path+"/"))}function dX(e,t){return e==="project"&&t.needsYouCount>0?{count:t.needsYouCount}:{}}function uX(e,t,n,r,i=!1){return n||r?{animate:!1}:i?{animate:!0,dir:"back"}:e==="REPLACE"?{animate:!1}:{animate:!0,dir:e==="POP"?"back":"forward"}}function wE(e,t){return ml(e)===ml(t)}function pX(e,t,n){return t&&wE(t.key,n.key)?{current:t,retainedTab:null,returningToRetained:!0}:$a(e.key)&&!$a(n.key)?{current:n,retainedTab:e,returningToRetained:!1}:{current:n,retainedTab:$a(n.key)?null:t,returningToRetained:!1}}function fX(e){return e==="forward"?{incoming:"animate-slide-in-right",outgoing:"animate-slide-out-left"}:{incoming:"animate-slide-in-left",outgoing:"animate-slide-out-right"}}function hX(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const kE={position:"absolute",inset:0,background:m.canvas},gX={...kE,visibility:"hidden",pointerEvents:"none"};function xX(e,t,n){const[r,i]=f.useState({key:e,element:n}),[s,a]=f.useState(null),[l,c]=f.useState(null),[d,u]=f.useState("forward");return f.useLayoutEffect(()=>{if(wE(e,r.key))return;const h=pX(r,s,{key:e,element:n}),g=$a(r.key)&&$a(e),v=uX(t,!1,hX(),g,h.returningToRetained);a(h.retainedTab),c(v.animate?r:null),v.animate&&u(v.dir),i(h.current)},[e]),{current:r,retainedTab:s,previous:l,dir:d,onSettled:()=>c(null)}}function Ng({frame:e,role:t,className:n,hidden:r,onAnimationEnd:i}){return o.jsx("div",{"data-route-layer":t,"data-route-key":e.key,className:n,style:r?gX:kE,"aria-hidden":t==="current"?void 0:!0,onAnimationEnd:i,children:e.element})}function mX({current:e,retainedTab:t,previous:n,dir:r,onSettled:i}){const s=fX(r),a=t&&t.key!==(n==null?void 0:n.key)&&t.key!==e.key;return o.jsxs("div",{style:{position:"relative",height:"100%",overflow:"hidden"},children:[a&&o.jsx(Ng,{frame:t,role:"retained",hidden:!0},t.key),n&&o.jsx(Ng,{frame:n,role:"previous",className:s.outgoing},n.key),o.jsx(Ng,{frame:e,role:"current",className:n?s.incoming:void 0,onAnimationEnd:n?i:void 0},e.key)]})}function vX(){const e=wr(),t=r$(),n=$C(),r=xX(e.pathname,t,n);return o.jsx(mX,{...r})}const yX="var(--proto-ink)",bX="var(--proto-muted-3)";function jX({id:e,color:t}){switch(e){case"sessions":return o.jsx("svg",{width:"21",height:"21",viewBox:"0 0 22 22",fill:"none",stroke:t,strokeWidth:"1.7",children:o.jsx("path",{d:"M4 4.5h14a1.5 1.5 0 0 1 1.5 1.5v8a1.5 1.5 0 0 1-1.5 1.5H9.5L5.5 19v-3.5H4A1.5 1.5 0 0 1 2.5 14V6A1.5 1.5 0 0 1 4 4.5z"})});case"threads":return o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 14 14",fill:"none",stroke:t,strokeWidth:"1.4",children:[o.jsx("circle",{cx:"3.5",cy:"3",r:"1.9"}),o.jsx("circle",{cx:"3.5",cy:"11",r:"1.9"}),o.jsx("circle",{cx:"10.5",cy:"7",r:"1.9"}),o.jsx("path",{d:"M3.5 5v4M5.4 3.7 8.7 6.1M5.4 10.3 8.7 7.9"})]});case"tasks":return o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:t,strokeWidth:"1.6",children:[o.jsx("path",{d:"M4 5.5l1.5 1.5L8 4.5"}),o.jsx("path",{d:"M4 12.5l1.5 1.5L8 11.5"}),o.jsx("path",{d:"M10.5 6h6M10.5 13h6"})]});case"project":return o.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:t,strokeWidth:"1.6",children:o.jsx("path",{d:"M3 5.5h5l1.5 2H17a1 1 0 0 1 1 1V15a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1z"})})}}function wX({vocab:e,activeId:t,needsYouCount:n,onNavigate:r}){return o.jsx("div",{style:{flex:"none",borderTop:"1px solid var(--proto-line)",background:"var(--proto-rail)",display:"flex",padding:"8px 6px",paddingBottom:"calc(8px + env(safe-area-inset-bottom))"},children:gh.map(i=>{const s=i.id===t,a=s?yX:bX,l=dX(i.id,{needsYouCount:n});return o.jsxs("button",{type:"button","data-tab-id":i.id,"data-active":s?"true":"false","aria-current":s?"page":void 0,onClick:()=>r(i.path),style:{flex:1,minHeight:44,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:3,border:"none",background:"transparent",padding:0,cursor:"pointer"},children:[o.jsxs("div",{style:{position:"relative"},children:[o.jsx(jX,{id:i.id,color:a}),l.count!==void 0&&o.jsx("span",{style:{position:"absolute",top:-4,right:-9,background:"var(--proto-amber)",color:"var(--ink-solid-fg)",font:"600 8px 'IBM Plex Mono', monospace",padding:"1px 4.5px",borderRadius:999},children:l.count})]}),o.jsx("span",{style:{fontSize:10,fontWeight:600,color:a},children:e[i.labelKey]})]},i.id)})})}const kX=[{pattern:/^\/m\/session\/([^/]+)\/plan\/[^/]+$/,parent:e=>`/m/session/${e[1]}`},{pattern:/^\/m\/session\/[^/]+$/,parent:"/m/sessions"},{pattern:/^\/m\/thread\/[^/]+$/,parent:"/m/threads"},{pattern:/^\/m\/task\/[^/]+$/,parent:"/m/tasks"},{pattern:/^\/m\/memory\/file$/,parent:"/m/memory"},{pattern:/^\/m\/settings\/(accounts|hooks)$/,parent:"/m/settings"},{pattern:/^\/m\/daemon$/,parent:"/m/settings"},{pattern:/^\/m\/(approvals|issues|notes|memory|machines|settings)$/,parent:"/m/project"}];function SX(e){const t=ml(e);for(const n of kX){const r=t.match(n.pattern);if(r)return typeof n.parent=="string"?n.parent:n.parent(r)}return"/m/sessions"}function CX(e,t,n=!1){return t?{kind:"history"}:$a(e)?{kind:"exit"}:n?{kind:"history"}:{kind:"navigate",to:SX(e)}}function TX(e,t){return e&&typeof(t==null?void 0:t.idx)=="number"&&t.idx>0}async function EX(e,t,n,r){const i=CX(e,t,n);if(i.kind==="history")return r.historyBack();if(i.kind==="exit")return void await r.exit();r.navigate(i.to,{replace:!0})}function RX(e,t){t(e,{replace:!0})}function PX(){const e=globalThis.__TAURI__;return!(e!=null&&e.app)||!e.core?null:{listen:t=>e.app.onBackButtonPress(t),exit:()=>e.core.invoke("plugin:app|exit")}}function IX(){const e=window.history.state;return(e==null?void 0:e.__cortexOverlay)===!0}function MX(e,t){let n=!1,r=null;return e.listen(t).then(i=>{n?i.unregister().catch(()=>{}):r=i}).catch(()=>{}),()=>{n=!0,r&&r.unregister().catch(()=>{})}}function LX(e,t){const n=f.useRef({pathname:e,navigate:t});n.current={pathname:e,navigate:t},f.useEffect(()=>{const r=PX();if(r)return MX(r,i=>{const s=n.current,a=window.history.state,l=TX(i.canGoBack,a);EX(s.pathname,IX(),l,{historyBack:()=>window.history.back(),exit:r.exit,navigate:s.navigate}).catch(()=>{})})},[])}const SE=f.createContext(null);function OX({children:e}){const t=ae(),n=G(t.projects.list.queryOptions({})),r=G(t.sessions.list.queryOptions({origin:"direct"})),[i,s]=f.useState(null),a=_3(i,r.data??[],n.data??[]),l=f.useCallback(d=>s(d),[]),c=f.useMemo(()=>({currentProjectId:a,setCurrentProject:l}),[a,l]);return o.jsx(SE.Provider,{value:c,children:e})}function tr(){const e=f.useContext(SE);if(!e)throw new Error("useMobileProject must be used within a MobileProjectProvider");return e}function DX(e){return{title:e.title,body:e.meta}}function ky(){return on()}let Wu=null;async function CE(){if(!ky())return!1;if(Wu!==null)return Wu;try{const{isPermissionGranted:e,requestPermission:t}=await ih(async()=>{const{isPermissionGranted:r,requestPermission:i}=await import("./index-DCgngTJG.js");return{isPermissionGranted:r,requestPermission:i}},[]);let n=await e();return n||(n=await t()==="granted"),Wu=n,n}catch{return Wu=!1,!1}}async function AX(e,t){if(!ky())return!1;try{if(!await CE())return!1;const{sendNotification:r}=await ih(async()=>{const{sendNotification:i}=await import("./index-DCgngTJG.js");return{sendNotification:i}},[]);return r({title:e.title,body:e.body,extra:t,autoCancel:!0}),!0}catch{return!1}}async function NX(e){if(!ky())return()=>{};try{const{onAction:t}=await ih(async()=>{const{onAction:r}=await import("./index-DCgngTJG.js");return{onAction:r}},[]),n=await t(r=>e(r.extra));return()=>{n.unregister()}}catch{return()=>{}}}function Br(e,t=Date.now()){if(!e)return"";const n=Date.parse(e);if(Number.isNaN(n))return"";const r=t-n;if(r<0)return"现在";const i=Math.floor(r/6e4);if(i<1)return"现在";if(i<60)return`${i} 分钟`;const s=Math.floor(i/60);if(s<24)return`${s} 小时`;const a=Math.floor(s/24);return a===1?"昨天":a<7?`${a} 天前`:`${Math.floor(a/7)} 周前`}function ud(e){return e==null||Number.isNaN(e)?"—":`$${e.toFixed(2)}`}function Lt(e,t){return e==="zh"?t.zh:t.en}function $X({items:e,now:t=Date.now(),onDismiss:n,onActivate:r}){return e.length===0?null:o.jsx("div",{style:{position:"fixed",top:"calc(10px + env(safe-area-inset-top))",left:10,right:10,zIndex:1e3,display:"flex",flexDirection:"column",gap:8,pointerEvents:"none"},children:e.map(i=>o.jsxs("div",{role:"button",onClick:()=>r(i),style:{pointerEvents:"auto",background:"rgba(250,250,252,.98)",border:"1px solid rgba(0,0,0,.06)",borderRadius:20,boxShadow:"0 12px 36px rgba(16,24,40,.24)",padding:"11px 13px",display:"flex",gap:10,alignItems:"center",cursor:"pointer"},children:[o.jsx("div",{"aria-label":"Cortex",style:{width:36,height:36,borderRadius:9,background:"var(--brand-badge-bg)",border:"1px solid var(--brand-badge-border)",display:"flex",alignItems:"center",justifyContent:"center",flex:"none"},children:o.jsxs("svg",{width:25,height:25,viewBox:"0 0 64 64",fill:"none","aria-hidden":"true",children:[o.jsx("circle",{cx:33,cy:32,r:5,fill:"var(--brand-badge-core)"}),o.jsx("path",{d:"M42.29 23.64A12.5 12.5 0 1 0 42.29 40.36",stroke:"var(--brand-badge-arc)",strokeWidth:5,strokeLinecap:"round"}),o.jsx("path",{d:"M48.6 17.95A21 21 0 1 0 48.6 46.05",stroke:"var(--brand-badge-arc)",strokeWidth:5,strokeLinecap:"round"})]})}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:12.5,fontWeight:650,color:m.ink,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i.title}),o.jsx("div",{style:{fontSize:11,color:m.sub,marginTop:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i.meta})]}),o.jsx("span",{style:{font:`400 10px ${A}`,color:m.faint,flex:"none",alignSelf:"flex-start"},children:Br(i.ts,t)||"现在"}),o.jsx("button",{type:"button","aria-label":"Dismiss",onClick:s=>{s.stopPropagation(),n(i.id)},style:{border:"none",background:"transparent",color:m.faint,fontSize:12,cursor:"pointer",flex:"none",padding:"0 2px"},children:"✕"})]},i.id))})}function _X(){const e=ae(),t=Be(),n=wr(),{setCurrentProject:r}=tr(),[i,s]=f.useState([]),a=f.useRef(0),l=f.useRef(new Map),c=f.useRef(n.pathname),d=G(e.sessions.list.queryOptions({origin:"direct"}));f.useEffect(()=>{const j=new Map;for(const S of d.data??[])j.set(S.sessionId,{name:S.label??S.name,projectId:S.projectId});l.current=j},[d.data]),f.useEffect(()=>{c.current=n.pathname},[n.pathname]),f.useEffect(()=>{CE()},[]);const u=f.useCallback((j,S)=>{j&&(S&&r(S),t(`/m/session/${j}`))},[t,r]);f.useEffect(()=>{let j=()=>{};return NX(S=>{const k=typeof(S==null?void 0:S.sessionId)=="string"?S.sessionId:"",E=typeof(S==null?void 0:S.projectId)=="string"&&S.projectId?S.projectId:null;u(k,E)}).then(S=>{j=S}),()=>j()},[u]);const p=f.useCallback(j=>{const S=j.sessionId?{sessionId:j.sessionId,projectId:j.projectId??""}:void 0;(async()=>await AX(DX(j),S)||s(E=>Mm(E,j)))()},[]),h=f.useRef(new Map),g=f.useCallback(j=>{nT(h.current,j.sessionId,{text:j.text,ts:j.ts??new Date().toISOString()})},[]),v=f.useCallback(j=>{const S=rT(h.current,j);if(!S)return;const k=l.current.get(j);if(!k||c.current===`/m/session/${j}`)return;const E=`dmn-${a.current++}`,C=X3({id:E,sessionId:j,sessionName:k.name,projectId:k.projectId,text:S.text,ts:S.ts});p(C)},[p]);eT({onMessage:g,onTurnEnd:v});const x=f.useCallback(j=>{const S=`sysn-${a.current++}`,k=J3({id:S,level:j.level,text:j.text,title:j.title??void 0,ts:j.ts??void 0});p(k)},[p]);tT(x);const w=f.useCallback(j=>s(S=>nf(S,j)),[]),b=f.useCallback(j=>{u(j.sessionId,j.projectId),s(S=>nf(S,j.id))},[u]),{visible:y}=Z3(i);return o.jsx($X,{items:y,onDismiss:w,onActivate:b})}const FX="'IBM Plex Mono', monospace";function zX({update:e,onApply:t,onDismiss:n}){return o.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"新版本已就绪",style:{position:"fixed",inset:0,zIndex:60,background:"rgba(25,28,34,.44)",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 36px",boxSizing:"border-box"},children:o.jsxs("div",{style:{width:"100%",background:"var(--proto-card)",borderRadius:18,boxShadow:"0 24px 64px rgba(16,24,40,.32)",padding:"24px 20px 14px",boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center"},children:[o.jsx("div",{style:{width:46,height:46,borderRadius:14,background:"var(--proto-accent-bg)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:14},children:o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"var(--proto-accent)",strokeWidth:"1.8",children:[o.jsx("path",{d:"M10 14V4M5.5 8.5 10 4l4.5 4.5"}),o.jsx("path",{d:"M3.5 16.5h13"})]})}),o.jsx("div",{style:{fontSize:17,fontWeight:700,color:"var(--proto-ink)",letterSpacing:"-.01em"},children:"新版本已就绪"}),o.jsx("div",{style:{font:`500 10.5px ${FX}`,color:"var(--proto-muted-3)",marginTop:6},children:iT(e)}),o.jsx("div",{style:{fontSize:13,lineHeight:1.6,color:"var(--proto-muted)",textAlign:"center",margin:"10px 0 18px"},children:"热更新已在后台下载完成,重启 App 后生效。运行中的线程在服务端继续执行,不受重启影响。"}),o.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[o.jsx("button",{type:"button",onClick:t,style:{height:48,border:"none",borderRadius:13,background:"var(--proto-ink)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14.5,fontWeight:600,cursor:"pointer",width:"100%"},children:"退出 App"}),o.jsx("button",{type:"button",onClick:n,style:{height:44,border:"none",background:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13.5,fontWeight:600,color:"var(--proto-muted-2)",cursor:"pointer",width:"100%"},children:"忽略"})]})]})})}function BX(){const e=f.useSyncExternalStore(cy,dy),{staged:t,apply:n,dismiss:r}=uT();return e||!t?null:o.jsx(zX,{update:t,onApply:n,onDismiss:r})}const WX="'IBM Plex Mono', monospace";function UX({update:e,busy:t,error:n,onInstall:r,onSkip:i,onDismiss:s}){return o.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"App 新版本已就绪",style:{position:"fixed",inset:0,zIndex:60,background:"rgba(25,28,34,.44)",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 36px",boxSizing:"border-box"},children:o.jsxs("div",{style:{width:"100%",background:"var(--proto-card)",borderRadius:18,boxShadow:"0 24px 64px rgba(16,24,40,.32)",padding:"24px 20px 14px",boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center"},children:[o.jsx("div",{style:{width:46,height:46,borderRadius:14,background:"var(--proto-accent-bg)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:14},children:o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"var(--proto-accent)",strokeWidth:"1.8",children:[o.jsx("path",{d:"M10 14V4M5.5 8.5 10 4l4.5 4.5"}),o.jsx("path",{d:"M3.5 16.5h13"})]})}),o.jsx("div",{style:{fontSize:17,fontWeight:700,color:"var(--proto-ink)",letterSpacing:"-.01em"},children:"App 新版本已就绪"}),o.jsx("div",{style:{font:`500 10.5px ${WX}`,color:"var(--proto-muted-3)",marginTop:6},children:aT(e)}),o.jsx("div",{style:{fontSize:13,lineHeight:1.6,color:"var(--proto-muted)",textAlign:"center",margin:"10px 0 18px"},children:cT(e.kind)}),n?o.jsxs("div",{style:{fontSize:12,color:"var(--proto-danger, #d92d20)",marginBottom:10,textAlign:"center"},children:["安装失败:",n]}):null,o.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[o.jsx("button",{type:"button",onClick:r,disabled:t,style:{height:48,border:"none",borderRadius:13,background:"var(--proto-ink)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14.5,fontWeight:600,cursor:"pointer",width:"100%",opacity:t?.6:1},children:t?"正在处理…":lT(e.kind)}),o.jsxs("div",{style:{display:"flex",width:"100%"},children:[o.jsx("button",{type:"button",onClick:i,style:{height:44,border:"none",background:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13.5,fontWeight:600,color:"var(--proto-muted-2)",cursor:"pointer",flex:1},children:"跳过此版本"}),o.jsx("button",{type:"button",onClick:s,style:{height:44,border:"none",background:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13.5,fontWeight:600,color:"var(--proto-muted-2)",cursor:"pointer",flex:1},children:"稍后"})]})]})]})})}function HX(){const{update:e,busy:t,error:n,install:r,skip:i,dismiss:s}=pT();return e?o.jsx(UX,{update:e,busy:t,error:n,onInstall:r,onSkip:i,onDismiss:s}):null}const Bw="--cortex-vvh",Ww="--cortex-vvt";function qX(e,t){const n=()=>{e.setProperty(Bw,`${t.height}px`),e.setProperty(Ww,`${t.offsetTop}px`)};return n(),t.addEventListener("resize",n),t.addEventListener("scroll",n),()=>{t.removeEventListener("resize",n),t.removeEventListener("scroll",n),e.removeProperty(Bw),e.removeProperty(Ww)}}function VX(){f.useEffect(()=>{const e=window.visualViewport;if(e)return qX(document.documentElement.style,e)},[])}const KX={position:"fixed",top:0,left:0,right:0,height:"var(--cortex-vvh, 100dvh)",transform:"translateY(var(--cortex-vvt, 0px))",display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--proto-alt)"};function QX({pathname:e,vocab:t,needsYouCount:n,onTab:r}){return o.jsxs("div",{style:KX,children:[o.jsx("div",{style:{flex:1,minHeight:0,overflow:"hidden"},children:o.jsx(vX,{})}),cX(e)&&o.jsx(wX,{vocab:t,activeId:lX(e),needsYouCount:n,onNavigate:r})]})}function GX({children:e}){return o.jsx(T3,{children:o.jsx(hT,{children:o.jsx(OX,{children:o.jsx(q6,{children:o.jsxs(X6,{children:[e,o.jsx(_X,{}),o.jsx(BX,{}),o.jsx(HX,{})]})})})})})}function YX(){var a;const e=B(),t=wr(),n=Be(),r=ae();VX(),LX(t.pathname,n);const s=((a=G(r.approvals.list.queryOptions({status:"pending"})).data)==null?void 0:a.length)??0;return o.jsx(GX,{children:o.jsx(QX,{pathname:t.pathname,vocab:e,needsYouCount:s,onTab:l=>RX(l,n)})})}function XX(e){return e.awaitingInput?{kind:"awaiting",text:"等待操作"}:e.running&&e.backgroundRunning?{kind:"background",text:"后台运行"}:e.running?{kind:"running",text:e.numTurns!=null?`running · ${e.numTurns} turns`:"running"}:{kind:"idle",text:"空闲"}}function JX(e,t){return{id:e.sessionId,title:e.label||e.name||e.sessionId,time:Br(e.lastUsedAt||e.createdAt,t),running:e.running,numTurns:e.numTurns,unread:e.unread}}function ZX(e,t=Date.now()){return jT(e,t).map(n=>({key:n.label,rows:n.items.map(r=>JX(r,t))}))}function eJ(e,t){return t==="TODAY"?e.today:t==="YESTERDAY"?e.yesterday:e.earlier}function tJ({onClick:e}){return o.jsx("button",{type:"button","aria-label":"New session",onClick:e,style:{width:34,height:34,borderRadius:"50%",background:m.ink,border:"none",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--ink-solid-fg)",fontSize:17,fontWeight:400,cursor:"pointer"},children:"+"})}function nJ({unread:e,onClick:t}){return o.jsxs("div",{style:{position:"relative",flex:"none"},children:[o.jsx("button",{type:"button","aria-label":"Scheduled",onClick:t,style:{width:34,height:34,borderRadius:"50%",background:m.card,border:`1px solid ${m.hairline}`,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0},children:o.jsxs("svg",{width:16,height:16,viewBox:"0 0 14 14",fill:"none",stroke:m.sub,strokeWidth:1.5,children:[o.jsx("circle",{cx:"7",cy:"7",r:"5.6"}),o.jsx("path",{d:"M7 4v3.2l2.2 1.3"})]})}),e>0&&o.jsx("span",{"aria-label":`${e} unread scheduled`,style:{position:"absolute",top:-3,right:-4,background:m.run,color:"var(--ink-solid-fg)",font:`600 8.5px ${A}`,padding:"1px 4.5px",borderRadius:999,border:`1.5px solid ${m.canvas}`},children:e})]})}function rJ({row:e,byId:t,onOpen:n}){const r=t.get(e.id),i=r?XX(r):{kind:"idle",text:"空闲"};return o.jsxs(Oe,{radius:12,padding:"12px 13px",onClick:()=>n(e.id),children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[e.unread&&o.jsx("span",{"aria-label":"unread",style:{width:7,height:7,borderRadius:"50%",background:m.run,flex:"none"}}),o.jsx("span",{style:{fontSize:14,fontWeight:e.unread?600:400,color:e.unread?m.ink:"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${A}`,color:m.faint,flex:"none"},children:e.time})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginTop:4},children:[i.kind==="running"&&o.jsx(ho,{color:m.run,pulse:!0}),i.kind==="background"&&o.jsx(ho,{color:m.run,pulse:!0}),i.kind==="awaiting"&&o.jsx(ho,{color:m.amber,pulse:!0}),o.jsx("span",{style:{font:`400 10px ${A}`,color:m.muted},children:i.text})]})]})}function oJ({groups:e,sessions:t,scope:n,copy:r,scheduled:i,onOpen:s,onNew:a}){const l=new Map(t.map(c=>[c.sessionId,c]));return o.jsx(vt,{label:"1a 会话列表",header:o.jsx(dh,{title:r.title,qn:n,trailing:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i&&o.jsx(nJ,{unread:i.unread,onClick:i.onOpen}),o.jsx(tJ,{onClick:a})]})}),children:o.jsxs(En,{gap:6,children:[e.length===0&&o.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:m.faint,fontSize:13},children:r.empty}),e.map(c=>o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[o.jsx(xl,{style:{padding:"6px 2px 2px"},children:eJ(r,c.key)}),c.rows.map(d=>o.jsx(rJ,{row:d,byId:l,onOpen:s},d.id))]},c.key))]})})}function Bm({size:e,color:t}){return o.jsxs("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",stroke:t,strokeWidth:1.6,style:{flex:"none"},children:[o.jsx("circle",{cx:"7",cy:"7",r:"5.6"}),o.jsx("path",{d:"M7 4v3.2l2.2 1.3"})]})}function iJ({row:e,copy:t,now:n}){const r=CT(e,n);return o.jsxs("div",{style:{font:`400 10px ${A}`,color:m.muted,marginTop:2},children:[r.kind==="run"&&o.jsxs(o.Fragment,{children:[r.stamp,r.cost&&o.jsxs(o.Fragment,{children:[" · ",r.cost]})]}),r.kind==="pending"&&o.jsxs(o.Fragment,{children:[r.cadence,r.nextDelta&&o.jsxs(o.Fragment,{children:[" · ",t.nextIn.replace("{d}",r.nextDelta)]})]}),r.kind==="paused"&&o.jsxs(o.Fragment,{children:[r.cadence," · ",o.jsx("span",{style:{color:m.amberText},children:t.paused})]})]})}function sJ({rows:e,copy:t,now:n,onRow:r}){return o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"0 2px 10px"},children:[o.jsx(Bm,{size:14,color:m.run}),o.jsx("span",{style:{fontSize:17,fontWeight:700,color:m.ink,letterSpacing:"-.01em"},children:t.title}),o.jsx("span",{style:{font:`400 9.5px ${A}`,color:m.faint},children:t.countUnit.replace("{n}",String(e.length))})]}),o.jsx("div",{style:{background:m.card,border:`1px solid ${m.hairline}`,borderRadius:13,overflow:"hidden"},children:e.map((i,s)=>o.jsxs("div",{"data-schedule-row":i.scheduleId,onClick:()=>r(i),style:{display:"flex",alignItems:"center",gap:9,padding:13,minHeight:44,boxSizing:"border-box",cursor:"pointer",borderBottom:s===e.length-1?"none":`1px solid ${m.divider}`},children:[o.jsx(Bm,{size:13,color:i.unread?m.run:m.faint}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:14,fontWeight:i.unread?600:400,color:i.unread?m.ink:"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i.title}),o.jsx(iJ,{row:i,copy:t,now:n})]}),o.jsx("span",{style:{font:`500 10px ${A}`,color:m.muted,flex:"none"},children:i.kind==="repeat"?`×${i.runs.length}`:t.once}),i.unread&&o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:m.run,flex:"none"}}),o.jsx("span",{style:{fontSize:13,color:m.faint,flex:"none"},children:"›"})]},i.scheduleId))})]})}function aJ({row:e,copy:t,now:n,onBack:r,onOpenRun:i}){const s=hy(e.runs),a=e.schedule,l=a?fy(a.nextRun,n):null,c=a?sf(a)+(a.paused?` · ${t.paused}`:l?` · ${t.nextIn.replace("{d}",l)}`:""):null;return o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"0 2px 10px"},children:[o.jsx("span",{"data-action":"sheet-back",onClick:r,style:{fontSize:15,color:m.run,flex:"none",cursor:"pointer",padding:"0 2px"},children:"‹"}),o.jsx(Bm,{size:14,color:m.run}),o.jsxs("div",{style:{minWidth:0},children:[o.jsx("div",{style:{fontSize:17,fontWeight:700,color:m.ink,letterSpacing:"-.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),c&&o.jsx("div",{style:{font:`400 10px ${A}`,color:m.muted,marginTop:1},children:c})]})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"64px 1fr 70px",gap:10,padding:"4px 15px 6px",font:`600 9.5px ${A}`,color:m.faint,letterSpacing:".05em"},children:[o.jsx("span",{children:"RUN"}),o.jsx("span",{children:"FIRED"}),o.jsx("span",{style:{textAlign:"right"},children:"COST"})]}),o.jsx("div",{style:{background:m.card,border:`1px solid ${m.hairline}`,borderRadius:13,overflow:"hidden",maxHeight:"46vh",overflowY:"auto"},children:e.runs.map((d,u)=>o.jsxs("div",{"data-run-row":d.sessionId,onClick:()=>i(d.sessionId),style:{display:"grid",gridTemplateColumns:"64px 1fr 70px",gap:10,padding:13,minHeight:44,boxSizing:"border-box",alignItems:"center",cursor:"pointer",borderTop:u===0?"none":`1px solid ${m.divider}`},children:[o.jsxs("span",{style:{font:`${d.unread?600:400} 12px ${A}`,color:d.unread?m.ink:"var(--proto-muted)",display:"flex",alignItems:"center",gap:6},children:["#",s.get(d.sessionId),d.unread&&o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:m.run}})]}),o.jsx("span",{style:{font:`400 12px ${A}`,color:"var(--proto-muted-2)"},children:ch(d,n)}),o.jsx("span",{style:{font:`400 12px ${A}`,color:m.muted,textAlign:"right"},children:d.costUsd!=null?qr(d.costUsd):"—"})]},d.sessionId))}),o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 4px 0"},children:[o.jsx("span",{style:{fontSize:12,fontWeight:600,color:m.muted},children:t.allRuns.replace("{n}",String(e.runs.length))}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${A}`,color:m.faint},children:t.runListHint})]})]})}function lJ({rows:e,copy:t,onOpenSession:n,onEditPending:r,onClose:i}){const[s,a]=f.useState(null),l=s?e.find(u=>u.scheduleId===s)??null:null,c=Date.now(),d=u=>{const p=ST(u);p.type==="modal"?a(u.scheduleId):p.type==="open"?n(p.sessionId):r==null||r(u)};return o.jsx(Vr,{onClose:i,children:l?o.jsx(aJ,{row:l,copy:t,now:c,onBack:()=>a(null),onOpenRun:n}):o.jsx(sJ,{rows:e,copy:t,now:c,onRow:d})})}const cJ={en:{title:"Sessions",today:"Today",yesterday:"Yesterday",earlier:"Earlier",empty:"No sessions yet"},zh:{title:"会话",today:"今天",yesterday:"昨天",earlier:"更早",empty:"暂无会话"}},dJ={en:{title:"Scheduled",countUnit:"{n}",once:"once",paused:"paused",nextIn:"next in {d}",allRuns:"all {n} runs",runListHint:"tap a run → opens that session"},zh:{title:"Scheduled",countUnit:"{n} 个",once:"单次",paused:"已暂停",nextIn:"{d} 后运行",allRuns:"全部 {n} runs",runListHint:"点击任意 run → 打开该次会话"}};function uJ(){const e=ae(),t=Be(),n=ft(),r=Lt(n,cJ),i=Lt(n,dJ),{currentProjectId:s}=tr();gy();const a=G(e.sessions.list.queryOptions({origin:"direct",projectId:s??void 0})),l=G(e.sessions.list.queryOptions({origin:"scheduled",projectId:s??void 0})),c=G(e.schedules.list.queryOptions({projectId:s??void 0})),d=a.data??[],u=f.useMemo(()=>ZX(d),[d]),p=f.useMemo(()=>kT(c.data??[],l.data??[]),[c.data,l.data]),h=s?Ll(s):void 0,[g,v]=f.useState(!1);return a.isLoading?o.jsx(vt,{label:"1a 会话列表",children:o.jsx("div",{style:{padding:16,color:m.muted,fontSize:13},children:r.empty})}):o.jsxs(o.Fragment,{children:[o.jsx(oJ,{groups:u,sessions:d,scope:h,copy:r,scheduled:p.length>0?{unread:ET(p),onOpen:()=>v(!0)}:void 0,onOpen:x=>t(`/m/session/${x}`),onNew:()=>t("/m/session/new")}),g&&o.jsx(lJ,{rows:p,copy:i,onOpenSession:x=>{v(!1),t(`/m/session/${x}`)},onClose:()=>v(!1)})]})}function pJ(e){return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`}function fJ(e,t){const n=new Date(e),r=a=>new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),i=Math.round((r(t)-r(n))/864e5),s=pJ(n);return i<=0?`今天 ${s}`:i===1?`昨天 ${s}`:`${n.getMonth()+1}月${n.getDate()}日 ${s}`}function hJ(e){return e==="completed"?"done":e==="running"?"running":"pending"}function gJ(e){const t=Math.max(0,Math.round(e/6e4));if(t<60)return`${t}m`;const n=Math.floor(t/60),r=t%60;return r===0?`${n}h`:`${n}h ${r}m`}function xJ(e){const t=e.steps.map((i,s)=>({label:i.stage??`Step ${i.stepIndex+1}`,state:hJ(i.status),lineDone:s>0&&e.steps[s-1].status==="completed"})),n=e.status==="running"&&e.currentStep?`${e.currentStep.name} ${e.currentStep.index+1}/${e.totalSteps}`:e.status,r=new Date(e.updatedAt).getTime()-new Date(e.createdAt).getTime();return{name:e.templateName,pillText:n,nodes:t,footer:{elapsed:gJ(r),cost:`$${e.totalCostUsd.toFixed(2)}`,subCount:e.children.length}}}function mJ(e,t){return{names:e.slice(0,t.visibleCount).map(n=>n.kind),overflow:t.hiddenCount}}const Uw="'IBM Plex Mono',monospace";function vJ({state:e}){return e==="done"?o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:"var(--proto-success-bg)",color:"var(--proto-success)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700},children:"✓"}):e==="running"?o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:"var(--proto-accent)",boxShadow:"0 0 0 3px var(--proto-accent-bg)",animation:"cxpulse 1.6s ease-in-out infinite"}}):o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box"}})}function yJ(e){return e==="running"?"var(--proto-ink)":e==="done"?"var(--proto-muted)":"var(--proto-faint)"}function bJ({card:e,pill:t,subthreadsLabel:n,openLabel:r,onOpen:i}){return o.jsxs("div",{style:{border:"1px solid var(--proto-line)",borderRadius:12,overflow:"hidden",background:"var(--proto-card)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"9px 12px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"var(--proto-accent)",strokeWidth:"1.6",children:[o.jsx("circle",{cx:"3.5",cy:"3",r:"1.9"}),o.jsx("circle",{cx:"3.5",cy:"11",r:"1.9"}),o.jsx("circle",{cx:"10.5",cy:"7",r:"1.9"}),o.jsx("path",{d:"M3.5 5v4M5.4 3.7 8.7 6.1M5.4 10.3 8.7 7.9"})]}),o.jsx("span",{style:{font:`600 12px ${Uw}`,color:"var(--proto-ink)"},children:e.name}),o.jsx("span",{style:{marginLeft:"auto",fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:999,background:t.bg,color:t.color},children:e.pillText})]}),o.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px 12px"},children:e.nodes.map((s,a)=>o.jsxs(f.Fragment,{children:[a>0&&o.jsx("div",{style:{flex:1,height:1.5,background:s.lineDone?"var(--proto-success-bg)":"var(--proto-line)",margin:"0 6px"}}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[o.jsx(vJ,{state:s.state}),o.jsx("span",{style:{fontSize:10.5,color:yJ(s.state),fontWeight:s.state==="running"?600:void 0},children:s.label})]})]},a))}),o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",borderTop:"1px solid var(--proto-line-2)"},children:[o.jsxs("span",{style:{font:`400 10px ${Uw}`,color:"var(--proto-muted-3)"},children:[e.footer.elapsed," · ",e.footer.cost," · ",e.footer.subCount," ",n]}),o.jsxs("span",{onClick:i,style:{marginLeft:"auto",fontSize:11.5,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:[r," →"]})]})]})}const TE={zh:{askPill:"Agent 提问",answeredPill:"✓ 已回答",defaultBadge:"默认",customOption:"自定义…",confirm:"确认",queued:"待答",multiTag:"多选",askFooter:"答一题进一题 · 全答完继续",ttlSuffix:"后按默认继续",planPendingPill:"计划待批",planApprovedPill:"✓ 计划已批准",planRejectedPill:"已驳回",approvedBy:"由你批准",readHint:"批准前建议通读全文",readLink:"阅读 ›",approve:"批准并执行",reject:"驳回并反馈",approveHint:"",viewFullPlan:"查看完整计划 ›",viewOriginalPlan:"查看原计划 ›",rewriteNote:""},en:{askPill:"Agent question",answeredPill:"✓ answered",defaultBadge:"default",customOption:"Custom…",confirm:"Confirm",queued:"queued",multiTag:"multi",askFooter:"one at a time · continues when all answered",ttlSuffix:"until defaults apply",planPendingPill:"Plan pending",planApprovedPill:"✓ Plan approved",planRejectedPill:"Rejected",approvedBy:"approved by you",readHint:"read the full plan before approving",readLink:"Read ›",approve:"Approve & run",reject:"Reject with note",approveHint:"",viewFullPlan:"View full plan ›",viewOriginalPlan:"View original plan ›",rewriteNote:""}};function Mc({bg:e,fg:t,text:n}){return o.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"2px 8px",borderRadius:999,background:e,color:t,flex:"none"},children:n})}function xp(e,t,n){return{border:`1px solid ${e&&!t?m.runBorder:m.hairline}`,background:"var(--proto-card)",borderRadius:14,overflow:"hidden",boxShadow:e&&!t?"0 1px 3px rgba(70,85,212,.08)":void 0,...t?{opacity:.55}:n?{opacity:.9}:{}}}const jJ=o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 14 14",fill:"none",stroke:m.run,strokeWidth:"1.4",style:{flex:"none"},children:[o.jsx("path",{d:"M3 1.5h5.5L11.5 4.5V12.5H3z"}),o.jsx("path",{d:"M5 6.5h4M5 9h4"})]});function wJ({model:e,state:t,copy:n,onPick:r,onToggle:i,onConfirmMulti:s,onCustom:a}){const l=e.status==="pending",c=Vo(e,t),d=e.questions.length,u=J0(e.ts,l),[p,h]=f.useState(!1),g=x=>x.answer??t.answers[x.question]??null,v=e.level?r3(e.level):null;return o.jsxs("div",{...e.level?{"data-ask-level":e.level}:{},style:xp(l,!1,!1),onClick:l?void 0:()=>h(x=>!x),children:[o.jsx("div",{style:{padding:"12px 14px 0"},children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[l?o.jsx(Mc,{bg:v?v.bg:m.runBg,fg:v?v.fg:m.run,text:d>1?`${n.askPill} · ${Math.min(c+1,d)}/${d}`:n.askPill}):o.jsx(Mc,{bg:m.doneBg,fg:m.done,text:n.answeredPill}),o.jsx("span",{style:{font:`400 10px ${A}`,color:m.faint},children:e.shortId}),l&&u!=null?o.jsxs("span",{style:{marginLeft:"auto",font:`500 10px ${A}`,color:m.amberText},children:[G0(u)," ",n.ttlSuffix]}):e.timeLabel?o.jsx("span",{style:{marginLeft:"auto",font:`400 10px ${A}`,color:m.faint},children:e.timeLabel}):null]})}),e.questions.map((x,w)=>{const b=g(x),y=l&&w===c,j=l&&w>c,S=w===d-1;return b!=null&&!y?o.jsxs("div",{style:{padding:`10px 14px ${S?"14px":"0"}`},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,background:"var(--proto-alt)",border:"1px solid var(--proto-line-2)",borderRadius:11,padding:"9px 13px"},children:[o.jsx("span",{style:{width:16,height:16,borderRadius:"50%",background:m.done,color:"var(--ink-solid-fg)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:9,fontWeight:700,flex:"none"},children:"✓"}),o.jsxs("span",{style:{fontSize:12,color:m.sub,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[x.question," → ",o.jsx("b",{style:{color:m.ink},children:b})]})]}),!l&&p&&x.options.length>0&&o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"8px 0 0"},children:x.options.map(k=>o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,border:`1px solid ${b.includes(k.label)?m.runBorder:"var(--proto-line-2)"}`,borderRadius:9,padding:"6px 11px"},children:[o.jsx("span",{style:{fontSize:11.5,color:b.includes(k.label)?m.ink:m.muted},children:k.label}),b.includes(k.label)&&o.jsx("span",{style:{marginLeft:"auto",fontSize:10,fontWeight:700,color:m.done},children:"✓"})]},k.label))})]},x.question):y?o.jsxs("div",{style:{padding:`12px 14px ${S?"14px":"0"}`},children:[o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[o.jsxs("span",{style:{font:`600 10px ${A}`,color:m.run,flex:"none"},children:["Q",w+1]}),o.jsx("span",{style:{fontSize:14.5,fontWeight:600,color:m.ink,lineHeight:1.4},children:x.question}),x.multiSelect&&o.jsx("span",{style:{font:`500 9px ${A}`,color:m.muted,background:m.gray,padding:"1px 6px",borderRadius:5,flex:"none"},children:n.multiTag})]}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:"10px 0 0"},children:[x.options.map((k,E)=>{const C=x.multiSelect&&t.selected.includes(k.label),R=!x.multiSelect&&E===0;return o.jsxs("button",{type:"button",onClick:()=>x.multiSelect?i(k.label):r(k.label),style:{minHeight:44,border:`1.5px solid ${C||R?m.run:"var(--proto-line-3)"}`,borderRadius:11,display:"flex",alignItems:"center",gap:8,padding:"8px 13px",boxSizing:"border-box",background:"var(--proto-card)",cursor:"pointer",textAlign:"left",width:"100%"},children:[x.multiSelect&&o.jsx("span",{style:{fontSize:12,fontWeight:700,color:C?m.run:m.faint,flex:"none"},children:C?"☑":"☐"}),o.jsx("span",{style:{fontSize:13.5,fontWeight:600,color:m.ink,minWidth:0,flex:1,overflowWrap:"anywhere"},children:k.label}),R?o.jsx("span",{style:{marginLeft:"auto",fontSize:9.5,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:m.runBg,color:m.run,flex:"none"},children:n.defaultBadge}):k.description?o.jsx("span",{style:{marginLeft:"auto",minWidth:0,maxWidth:"55%",font:`400 10px ${A}`,color:"var(--proto-muted-3)",flex:"0 1 auto",textAlign:"right",lineHeight:1.35,whiteSpace:"normal",overflowWrap:"anywhere"},children:k.description}):null]},k.label)}),o.jsx("button",{type:"button",onClick:a,style:{minHeight:44,border:"1.5px solid var(--proto-line-3)",borderRadius:11,display:"flex",alignItems:"center",padding:"8px 13px",boxSizing:"border-box",background:"var(--proto-card)",cursor:"pointer",textAlign:"left",width:"100%"},children:o.jsx("span",{style:{fontSize:13.5,fontWeight:600,color:m.sub},children:n.customOption})}),x.multiSelect&&o.jsx("button",{type:"button",onClick:s,disabled:t.selected.length===0,style:{height:44,borderRadius:11,background:m.ink,color:"var(--ink-solid-fg)",border:"none",fontSize:14,fontWeight:600,cursor:"pointer",opacity:t.selected.length===0?.45:1,width:"100%"},children:n.confirm})]})]},x.question):j?o.jsx("div",{style:{padding:`12px 14px ${S?"14px":"0"}`},children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,border:"1px dashed var(--proto-line-3)",borderRadius:11,padding:"9px 13px",opacity:.6},children:[o.jsxs("span",{style:{font:`600 10px ${A}`,color:"var(--proto-muted-3)",flex:"none"},children:["Q",w+1]}),o.jsx("span",{style:{fontSize:12,color:m.grayInk,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.question}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${A}`,color:m.faint,flex:"none"},children:n.queued})]})},x.question):null}),l&&o.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"9px 14px",borderTop:"1px solid var(--proto-line-2)",font:`400 10px ${A}`,color:"var(--proto-muted-3)",marginTop:12},children:o.jsx("span",{style:{marginLeft:"auto"},children:n.askFooter})})]})}function kJ({model:e,copy:t,dimmed:n=!1,onApprove:r,onRejectStart:i,onOpenRead:s}){const a=e.status==="pending",l=e.status==="rejected",c=e.status==="approved",d=o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[c?o.jsx(Mc,{bg:m.doneBg,fg:m.done,text:t.planApprovedPill}):l?o.jsx(Mc,{bg:m.gray,fg:m.grayInk,text:t.planRejectedPill}):o.jsx(Mc,{bg:m.runBg,fg:m.run,text:t.planPendingPill}),o.jsx("span",{style:{font:`400 10px ${A}`,color:m.faint},children:"ExitPlanMode"}),e.timeLabel&&o.jsxs("span",{style:{marginLeft:"auto",font:`400 10px ${A}`,color:m.faint},children:[e.timeLabel,c?` ${t.approvedBy}`:""]})]}),u=o.jsx("div",{style:{fontSize:a&&!n?14.5:13.5,fontWeight:600,color:c?m.sub:l?m.grayInk:m.ink,lineHeight:1.4,marginTop:8,overflowWrap:"break-word",...l?{textDecoration:"line-through",textDecorationColor:"var(--proto-line)"}:{}},children:e.title});return a&&n?o.jsx("div",{style:xp(!0,!0,!1),children:o.jsxs("div",{style:{padding:"11px 14px 12px"},children:[d,u,o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:"var(--proto-alt)",border:"1px solid var(--proto-line-2)",borderRadius:11,padding:"9px 13px",marginTop:9},children:[o.jsx("span",{style:{font:`500 10.5px ${A}`,color:m.sub,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.filePath??""}),o.jsx("span",{role:"button",onClick:s,style:{marginLeft:"auto",fontSize:11,fontWeight:600,color:m.run,flex:"none",cursor:"pointer"},children:t.viewFullPlan})]})]})}):a?o.jsxs("div",{style:xp(!0,!1,!1),children:[o.jsxs("div",{style:{padding:"12px 14px 0"},children:[d,u]}),o.jsx("div",{style:{padding:"11px 14px 12px"},children:o.jsxs("div",{role:"button",onClick:s,style:{minHeight:52,border:"1px solid var(--proto-accent-bg)",background:"var(--proto-accent-bg)",borderRadius:11,display:"flex",alignItems:"center",gap:10,padding:"9px 13px",boxSizing:"border-box",cursor:"pointer"},children:[jJ,o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{font:`500 11px ${A}`,color:m.ink,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.filePath??`${e.lineCount} lines`}),o.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginTop:2},children:t.readHint})]}),o.jsx("span",{style:{fontSize:12,fontWeight:600,color:m.run,flex:"none"},children:t.readLink})]})}),o.jsxs("div",{style:{display:"flex",gap:8,padding:"0 14px 12px"},children:[o.jsx("button",{type:"button",onClick:r,style:{flex:1.3,height:44,borderRadius:11,background:m.ink,color:"var(--ink-solid-fg)",border:"none",fontSize:14,fontWeight:600,cursor:"pointer"},children:t.approve}),o.jsx("button",{type:"button",onClick:i,style:{flex:1,height:44,borderRadius:11,border:"1.5px solid var(--proto-line-3)",background:"var(--proto-card)",color:m.ink,fontSize:14,fontWeight:600,boxSizing:"border-box",cursor:"pointer"},children:t.reject})]}),o.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"9px 14px",borderTop:"1px solid var(--proto-line-2)",font:`400 10px ${A}`,color:"var(--proto-muted-3)"},children:o.jsx("span",{style:{marginLeft:"auto",color:m.faint},children:t.approveHint})})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:xp(!1,!1,l),children:[o.jsxs("div",{style:{padding:"11px 14px 12px"},children:[d,u]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"9px 14px",borderTop:"1px solid var(--proto-line-2)",font:`400 10px ${A}`,color:"var(--proto-muted-3)"},children:[e.filePath&&o.jsx("span",{style:{color:m.run,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.filePath}),l&&o.jsx("span",{children:t.rewriteNote}),o.jsx("span",{role:"button",onClick:s,style:{marginLeft:"auto",color:m.run,fontWeight:600,cursor:"pointer",flex:"none"},children:l?t.viewOriginalPlan:t.viewFullPlan})]})]}),l&&e.feedback&&o.jsx("div",{style:{alignSelf:"flex-end",maxWidth:"82%",background:m.ink,color:"var(--ink-solid-fg)",borderRadius:"16px 16px 4px 16px",padding:"9px 13px",fontSize:13.5,lineHeight:1.55,whiteSpace:"pre-wrap",overflowWrap:"break-word"},children:e.feedback})]})}function SJ(e,t,n={}){return Z0(e,t,{streaming:n.streaming,streamingText:n.streamingText,pendingUser:n.pendingUser,stripScheduledPrefix:n.stripScheduledPrefix,formatDivider:fJ,...n.now?{now:n.now}:{}})}const Hw="—";function CJ(e){return"$"+e.toFixed(2)}function TJ(e,t,n,r,i){const s=t==null?Hw:`${t} turns`;if(e)return{running:!0,tone:"running",text:`running · ${n} · ${s}`};if(!i)return{running:!1,tone:"idle",text:"idle"};const a=r==null?Hw:CJ(r);return{running:!1,tone:"idle",text:`idle · ${n} · ${s} · ${a}`}}function EJ(e,t,n,r){const i=r==="zh";if(e==="plan-approval")return{running:!1,tone:"waiting",text:i?"计划待批 · Agent 已暂停":"plan pending · agent paused"};const s=n>1?` ${Math.min(t+1,n)}/${n}`:"";return{running:!1,tone:"waiting",text:i?`等待你的回答${s} · Agent 已暂停`:`awaiting your answer${s} · agent paused`}}function RJ(e,t,n){var r;return e??n??((r=t[0])==null?void 0:r.name)??"—"}function PJ(e,t){const n=t.find(i=>i.name===e),r=(n==null?void 0:n.model)??(n==null?void 0:n.backend)??null;return r?`${e} · ${r}`:e}function IJ(e){return[e.model,e.thinking,e.backend].filter(Boolean).join(" · ")}function EE(e,t){return e.map(n=>({name:n.name,sub:IJ(n),current:n.name===t}))}const Lc=12,RE=16;function MJ(e){const t=e.overlayHeight-RE-e.groupHeight;return e.anchorTop==null||t<=Lc?Lc:Math.max(Lc,Math.min(e.anchorTop-e.overlayTop,t))}function LJ(e){let t=null;const n=r=>r.getBoundingClientRect().top;return{onTouchStart:r=>{const i=r.currentTarget;t=setTimeout(()=>e(n(i)),450)},onTouchEnd:()=>{t&&clearTimeout(t)},onTouchMove:()=>{t&&clearTimeout(t)},onContextMenu:r=>{r.preventDefault(),e(n(r.currentTarget))}}}function OJ({kind:e}){return o.jsx("svg",{width:"15",height:"15",viewBox:"0 0 14 14",fill:"none",stroke:m.muted,strokeWidth:"1.4",style:{marginLeft:"auto"},children:e==="copy"?o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"4.5",y:"4.5",width:"8",height:"8",rx:"1.5"}),o.jsx("path",{d:"M2.5 9.5V3.5a1 1 0 0 1 1-1h6"})]}):o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M2.5 11.5l.6-2.6 6.4-6.4a1.3 1.3 0 0 1 1.8 0l.2.2a1.3 1.3 0 0 1 0 1.8L5.1 10.9z"}),o.jsx("path",{d:"M8.6 3.4l2 2"})]})})}function qw({label:e,icon:t,onTap:n,onClose:r,disabled:i,divided:s}){return o.jsxs("div",{role:"button",onClick:i?void 0:()=>{n==null||n(),r()},style:{display:"flex",alignItems:"center",height:46,padding:"0 15px",fontSize:14.5,color:m.ink,opacity:i?.35:1,cursor:i?"default":"pointer",borderTop:s?"1px solid rgba(0,0,0,.07)":void 0},children:[e,o.jsx(OJ,{kind:t})]})}function DJ({isUser:e,text:t}){const n={flex:"0 1 auto",minHeight:0,overflow:"hidden",padding:"9px 13px",fontSize:13.5,boxShadow:"0 14px 40px rgba(0,0,0,.4)",whiteSpace:"pre-wrap",overflowWrap:"break-word"};return e?o.jsx("div",{style:{...n,maxWidth:"82%",background:m.ink,color:"var(--ink-solid-fg)",borderRadius:"16px 16px 4px 16px",lineHeight:1.55},children:t}):o.jsx("div",{style:{...n,maxWidth:"88%",background:"var(--proto-card)",color:m.body,borderRadius:14,lineHeight:1.6},children:t})}function AJ(e){const t=f.useRef(null),n=f.useRef(null),[r,i]=f.useState(null);return f.useLayoutEffect(()=>{const s=t.current,a=n.current;if(!s||!a)return;const l=s.getBoundingClientRect();i(MJ({anchorTop:e??null,overlayTop:l.top,overlayHeight:l.height,groupHeight:a.getBoundingClientRect().height}))},[e]),{overlayRef:t,groupRef:n,top:r}}function NJ({row:e,menu:t,copy:n}){const r=e.kind==="user",i=e.kind==="user"||e.kind==="assistant"?e.text:"",s=x3(e.kind==="user"?e.ts:void 0),{overlayRef:a,groupRef:l,top:c}=AJ(t.anchorTop);return o.jsx("div",{ref:a,onClick:t.onClose,style:{position:"absolute",inset:0,zIndex:8,background:"rgba(25,28,34,.38)",backdropFilter:"blur(1.5px)",WebkitBackdropFilter:"blur(1.5px)",overflow:"hidden"},children:o.jsxs("div",{ref:l,"data-msg-menu-group":"true",style:{position:"absolute",left:14,right:14,top:c??Lc,maxHeight:`calc(100% - ${Lc+RE}px)`,visibility:c==null?"hidden":"visible",display:"flex",flexDirection:"column",alignItems:r?"flex-end":"flex-start",gap:9,WebkitUserSelect:"none",userSelect:"none",WebkitTouchCallout:"none"},children:[o.jsx(DJ,{isUser:r,text:i}),s&&o.jsx("div",{style:{flex:"none",font:`500 10.5px ${A}`,color:"rgba(255,255,255,.92)",background:"rgba(0,0,0,.42)",padding:"3px 8px",borderRadius:6,letterSpacing:".02em"},children:s}),o.jsxs("div",{onClick:d=>d.stopPropagation(),style:{flex:"none",width:196,background:"rgba(250,250,252,.98)",border:"1px solid rgba(0,0,0,.06)",borderRadius:13,boxShadow:"0 14px 40px rgba(16,24,40,.25)",overflow:"hidden"},children:[o.jsx(qw,{label:n.menuCopy,icon:"copy",onTap:t.onCopy,onClose:t.onClose}),t.onEdit&&o.jsx(qw,{label:n.menuEdit,icon:"edit",onTap:t.onEdit,onClose:t.onClose,disabled:t.editDisabled,divided:!0})]})]})})}function $J({title:e,onCancel:t}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:"var(--proto-alt)",border:"1px solid var(--proto-accent-border)",borderRadius:11,padding:"8px 8px 8px 12px",marginBottom:7},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:m.run,flex:"none"}}),o.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--proto-accent-strong)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e}),o.jsx("div",{role:"button","aria-label":"Cancel edit",onClick:t,style:{marginLeft:"auto",width:26,height:26,borderRadius:8,background:"var(--proto-card)",border:"1px solid var(--proto-accent-border)",display:"flex",alignItems:"center",justifyContent:"center",color:m.run,fontSize:12,flex:"none",cursor:"pointer"},children:"×"})]})}function _J(e){return o.jsx(zn,{onBack:e.onBack,trailing:o.jsx(NT,{onClick:e.onMore}),children:o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:15,fontWeight:650,color:m.ink,letterSpacing:"-.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),o.jsx(FJ,{...e})]})})}function FJ({status:e}){return o.jsx("div",{"data-chat-status-line":"true",style:{display:"flex",alignItems:"center",gap:8,font:`400 10px ${A}`,color:e.tone==="waiting"?m.amberText:m.muted,marginTop:1},children:o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5,minWidth:0},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:e.tone==="waiting"?m.amber:e.running?m.run:"var(--proto-line-3)",animation:e.running?"cxpulse 1.6s ease-in-out infinite":void 0,flex:"none"}}),o.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.text})]})})}function zJ({copy:e,onClose:t,onSessionId:n}){const r=[{label:e.menuSessionId,onTap:n},{label:e.menuRename,onTap:t},{label:e.menuExport,onTap:t},{label:e.menuArchive,onTap:t}];return o.jsxs(o.Fragment,{children:[o.jsx("div",{onClick:t,style:{position:"absolute",inset:0,zIndex:5}}),o.jsx("div",{style:{position:"absolute",top:"calc(52px + env(safe-area-inset-top))",right:14,width:148,background:"rgba(250,250,252,.98)",border:"1px solid rgba(0,0,0,.06)",borderRadius:13,boxShadow:"0 14px 40px rgba(16,24,40,.2)",overflow:"hidden",zIndex:6},children:r.map((i,s)=>o.jsx("div",{onClick:i.onTap,style:{padding:"11px 14px",fontSize:13,color:m.ink,borderBottom:s<r.length-1?"1px solid var(--proto-line-2)":void 0,cursor:"pointer"},children:i.label},i.label))})]})}function BJ({copy:e,cortexId:t,backendUuid:n,onClose:r}){const i=VT({cortexId:t,backendUuid:n,cortexIdLabel:e.cortexIdLabel,backendUuidLabel:e.backendUuidLabel}),[s,a]=f.useState(null),l=(c,d)=>{var u;d!=="—"&&((u=navigator.clipboard)==null||u.writeText(d).catch(()=>{}),a(c),window.setTimeout(()=>a(p=>p===c?null:p),1400))};return o.jsxs(Vr,{onClose:r,children:[o.jsx("div",{style:{fontSize:17,fontWeight:700,color:m.ink,letterSpacing:"-.01em",padding:"0 2px 12px"},children:e.sessionIdTitle}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:11},children:i.map(c=>o.jsxs("div",{children:[o.jsx("div",{style:{font:`600 9.5px ${A}`,letterSpacing:".05em",color:m.muted,padding:"0 2px 5px"},children:c.label}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:"var(--proto-card)",border:`1px solid ${m.hairline}`,borderRadius:11,padding:"10px 12px"},children:[o.jsx("span",{style:{flex:1,font:`500 12px ${A}`,color:m.ink,wordBreak:"break-all",userSelect:"all"},children:c.value}),o.jsx("span",{role:"button",onClick:()=>l(c.key,c.value),style:{flex:"none",font:`600 9.5px ${A}`,color:s===c.key?m.run:m.muted,border:`1px solid ${s===c.key?m.runBorder:"var(--proto-line-3)"}`,borderRadius:7,padding:"4px 9px",cursor:c.value==="—"?"default":"pointer",opacity:c.value==="—"?.4:1},children:s===c.key?e.copied:e.copy})]})]},c.key))})]})}const WJ="repeating-linear-gradient(45deg,var(--proto-line) 0 6px,var(--proto-rail) 6px 12px)";function UJ({a:e}){const t=Ls(e.type),{openMedia:n}=zd(),{openDoc:r}=Wd(),i=Bd(e.name,e.mimeType),s=Q0(e.path,t!==null);if(t!==null)return o.jsxs("div",{role:"button",onClick:()=>n({kind:t,name:e.name,path:e.path}),style:{width:e.type==="video"?104:74,height:74,borderRadius:12,background:s?"#000":WJ,position:"relative",overflow:"hidden",flex:"none",cursor:"pointer"},children:[s&&t==="image"&&o.jsx("img",{src:s,alt:e.name,style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),s&&t==="video"&&o.jsx(Ud,{src:s,style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),t==="video"&&o.jsx("span",{style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%)",width:26,height:26,borderRadius:"50%",background:"rgba(25,28,34,.72)",color:"var(--ink-solid-fg)",fontSize:9,display:"flex",alignItems:"center",justifyContent:"center",paddingLeft:2,boxSizing:"border-box"},children:"▶"}),o.jsx("span",{style:{position:"absolute",left:7,bottom:6,maxWidth:(e.type==="video"?104:74)-14,font:`500 8px ${A}`,color:m.muted,background:"rgba(255,255,255,.85)",padding:"1px 5px",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",boxSizing:"border-box"},children:e.name})]});const a=i?()=>r({kind:i,name:e.name,path:e.path,mimeType:e.mimeType}):()=>void Tm(e.path,e.name);return o.jsxs("div",{role:"button",onClick:a,style:{display:"flex",alignItems:"center",gap:6,background:"var(--proto-card)",border:`1px solid ${m.hairline}`,borderRadius:9,padding:"6px 10px",flex:"none",cursor:"pointer"},children:[o.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 14 14",fill:"none",stroke:m.muted,strokeWidth:"1.5",children:[o.jsx("path",{d:"M3 1.5h5.5L11.5 4v8.5h-8.5z"}),o.jsx("path",{d:"M8.5 1.5V4H11"})]}),o.jsx("span",{style:{font:`500 10.5px ${A}`,color:m.body},children:e.name})]})}function Vw({attachments:e,side:t="right"}){const n=t==="left"?"flex-start":"flex-end";return o.jsx("div",{style:{alignSelf:n,display:"flex",gap:6,flexWrap:"wrap",justifyContent:n},children:e.map((r,i)=>o.jsx(UJ,{a:r},i))})}const Wm=6,HJ={font:`400 10px ${A}`,background:"var(--proto-card)",border:"1px solid var(--proto-line-2)",padding:"1px 6px",borderRadius:4,flex:"none"},PE={display:"flex",alignItems:"center",gap:Wm,flex:1,minWidth:0,overflow:"hidden",position:"relative"},qJ={...PE,position:"absolute",visibility:"hidden",pointerEvents:"none",width:"max-content",overflow:"visible"};function Kw({name:e}){return o.jsx("span",{style:HJ,children:e})}function VJ({count:e,calls:t,unit:n,onExpand:r}){const i=t.map(d=>d.kind),{containerRef:s,measureRef:a,layout:l}=D6(i,Wm),c=mJ(t,l);return o.jsxs("div",{onClick:r,style:{display:"flex",alignItems:"center",gap:Wm,fontSize:11,color:"var(--proto-muted-3)",flexWrap:"nowrap",whiteSpace:"nowrap",overflow:"hidden",cursor:"pointer"},children:[o.jsx("span",{style:{fontSize:8.5,flex:"none"},children:"▸"}),o.jsxs("span",{style:{flex:"none"},children:[e," ",n]}),o.jsxs("span",{ref:s,style:PE,children:[c.names.map((d,u)=>o.jsx(Kw,{name:d},u)),c.overflow>0?o.jsxs("span",{style:{flex:"none"},children:["+",c.overflow]}):null,o.jsxs("span",{ref:a,"aria-hidden":"true",style:qJ,children:[i.map((d,u)=>o.jsx(Kw,{name:d},u)),o.jsxs("span",{style:{flex:"none"},children:["+",t.length]})]})]})]})}function KJ({count:e,calls:t,unit:n,onCollapse:r}){return o.jsxs("div",{style:{background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:8,overflow:"hidden"},children:[o.jsxs("div",{onClick:r,style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--proto-muted-3)",padding:"6px 11px",cursor:"pointer"},children:[o.jsx("span",{style:{fontSize:8.5},children:"▾"}),o.jsxs("span",{children:[e," ",n]})]}),t.map((i,s)=>o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5.5px 11px",borderTop:"1px solid var(--proto-line-soft)"},children:[o.jsx("span",{style:{font:`600 9px ${A}`,color:"var(--proto-muted)",background:"var(--proto-gray)",padding:"1.5px 7px",borderRadius:5,flex:"none"},children:i.kind}),o.jsx("span",{style:{font:`400 10.5px ${A}`,color:m.body,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:i.input})]},s))]})}function QJ({count:e,calls:t,unit:n}){const[r,i]=f.useState(!1);return r?o.jsx(KJ,{count:e,calls:t,unit:n,onCollapse:()=>i(!1)}):o.jsx(VJ,{count:e,calls:t,unit:n,onExpand:()=>i(!0)})}const $g=()=>{};function GJ({text:e,preview:t,streamKey:n}){const r=v3(e,!!t,n);return r.trim()?o.jsx(Ai,{text:r,dropTrailingHr:!0}):null}function YJ({row:e,interactions:t}){const n=n3(e),r=(t==null?void 0:t.copy)??TE.zh;if(n.kind==="ask"){const a=n.model;return o.jsx(wJ,{model:a,state:(t==null?void 0:t.askState(a.requestId))??e3,copy:r,onPick:l=>t==null?void 0:t.onAskPick(a,l),onToggle:l=>t==null?void 0:t.onAskToggle(a,l),onConfirmMulti:()=>t==null?void 0:t.onAskConfirmMulti(a),onCustom:()=>t==null?void 0:t.onAskCustom(a)})}if(n.kind==="plan"){const a=n.model;return o.jsx(kJ,{model:a,copy:r,dimmed:(t==null?void 0:t.rejectingId)===a.requestId,onApprove:t?()=>t.onApprove(a):$g,onRejectStart:t?()=>t.onRejectStart(a):$g,onOpenRead:t?()=>t.onOpenRead(a):$g})}const i=n.tone==="rejected"?"var(--proto-danger)":n.tone==="inactive"?"var(--proto-muted-3)":m.done,s=n.tone==="rejected"?"✗":n.tone==="inactive"?"◌":"✓";return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 11px",background:"var(--proto-card)",border:"1px solid var(--proto-line-2)",borderRadius:10,opacity:n.tone==="inactive"?.6:.75},children:[o.jsxs("span",{style:{fontSize:10,fontWeight:700,color:i,flexShrink:0},children:[s," ",n.label]}),o.jsx("span",{style:{fontSize:11.5,color:m.sub,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n.text})]})}function XJ({rows:e,toolCallsUnit:t,interactions:n,editCopy:r,editing:i,onLongPress:s,onShowOriginal:a,streamKey:l}){const c=r?h3(e):null,d=(i==null?void 0:i.rowIndex)??null;return o.jsx(o.Fragment,{children:e.map((u,p)=>{const h=d!=null&&p>d,g=d===p,v=!!r&&!!s&&d==null&&u.kind==="user",x=v?LJ(w=>s(p,w)):null;return o.jsxs(f.Fragment,{children:[u.kind==="divider"&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,...h?{opacity:.35}:{}},children:[o.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}}),o.jsx("div",{style:{fontSize:9.5,fontWeight:600,letterSpacing:".06em",color:m.faint},children:u.text}),o.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}})]}),u.kind==="user"&&o.jsxs(o.Fragment,{children:[u.attachments&&u.attachments.length>0&&o.jsx(Vw,{attachments:u.attachments}),o.jsxs("div",{style:{alignSelf:"flex-end",display:"flex",flexDirection:"column",alignItems:"flex-end",gap:5,maxWidth:"82%",...h?{opacity:.35,pointerEvents:"none"}:{}},children:[g&&r&&o.jsx("span",{style:{font:`600 9.5px ${A}`,color:m.run,background:"var(--proto-accent-bg)",padding:"2px 7px",borderRadius:4},children:r.editingBadge}),o.jsx("div",{...x??{},"data-msg-bubble":v?p:void 0,style:{background:m.ink,color:u.pending?m.inkSolidFgDim:m.inkSolidFg,borderRadius:"16px 16px 4px 16px",padding:"9px 13px",fontSize:13.5,lineHeight:1.55,whiteSpace:"pre-wrap",overflowWrap:"break-word",wordBreak:"break-word",WebkitUserSelect:v?"none":void 0,userSelect:v?"none":void 0,WebkitTouchCallout:v?"none":void 0,...g?{boxShadow:`0 0 0 2px ${m.canvas}, 0 0 0 3.5px ${m.run}`}:{}},children:u.text}),r&&u.edited&&!g&&o.jsx("span",{role:"button",onClick:a?()=>a(u.edited):void 0,style:{font:`400 9.5px ${A}`,color:m.faint,cursor:"pointer"},children:o.jsx("span",{style:{borderBottom:`1px dotted ${m.faint}`},children:r.edited})})]}),g&&r&&i&&o.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:o.jsx("span",{style:{font:`600 9px ${A}`,color:"var(--m-amber-ink)",background:m.amberBg,padding:"2px 7px",borderRadius:4},children:r.willRewind(i.replies,i.toolCalls)})})]}),u.kind==="tools"&&o.jsx("div",{style:h?{opacity:.35,pointerEvents:"none"}:void 0,children:o.jsx(QJ,{count:u.count,calls:u.calls,unit:t})}),u.kind==="notice"&&o.jsx("div",{style:h?{opacity:.35,pointerEvents:"none"}:void 0,children:o.jsx(i3,{level:u.level,text:u.text,authAction:u.authAction,noticeAction:u.noticeAction,onNoticeAction:n==null?void 0:n.onCancelResume,noticeActionDone:n==null?void 0:n.resumeCancelled})}),u.kind==="assistant"&&o.jsxs("div",{...x??{},style:{fontSize:13.5,lineHeight:1.65,color:m.body,minWidth:0,overflowWrap:"break-word",wordBreak:"break-word",...h?{opacity:.35,pointerEvents:"none"}:{},WebkitUserSelect:v?"none":void 0,userSelect:v?"none":void 0,WebkitTouchCallout:v?"none":void 0},children:[r&&(c==null?void 0:c.has(p))&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,font:`400 9.5px ${A}`,color:m.faint,marginBottom:4},children:[o.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:"var(--proto-line-3)",flex:"none"}}),r.regenNote]}),o.jsx(GJ,{text:u.text,preview:u.preview,streamKey:l}),u.attachments&&u.attachments.length>0&&o.jsx("div",{style:{marginTop:8},children:o.jsx(Vw,{attachments:u.attachments,side:"left"})})]}),u.kind==="interaction"&&o.jsx("div",{style:{display:"flex",flexDirection:"column",...h?{opacity:.35,pointerEvents:"none"}:{}},children:o.jsx(YJ,{row:u,interactions:n})})]},u.kind==="interaction"&&u.detail?`int-${u.detail.id}`:p)})})}function JJ({text:e}){return o.jsxs("div",{style:{alignSelf:"center",display:"flex",alignItems:"center",gap:6,font:`400 9.5px ${A}`,color:m.faint,background:"var(--proto-card)",border:"1px solid var(--proto-line-2)",padding:"3px 10px",borderRadius:999},children:[o.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:m.run}}),e]})}function ZJ({copy:e,onClose:t,onCamera:n,onLibrary:r,onFile:i}){const s=(a,l,c,d)=>o.jsxs("div",{onClick:()=>{l(),t()},style:{display:"flex",alignItems:"center",gap:9,padding:"11px 14px",borderBottom:d?void 0:"1px solid var(--proto-line-2)",cursor:"pointer"},children:[c,o.jsx("span",{style:{fontSize:13,color:m.ink},children:a})]});return o.jsxs(o.Fragment,{children:[o.jsx("div",{onClick:t,style:{position:"absolute",inset:0,zIndex:5}}),o.jsxs("div",{style:{position:"absolute",left:14,bottom:90,width:196,background:"rgba(250,250,252,.98)",border:"1px solid rgba(0,0,0,.06)",borderRadius:13,boxShadow:"0 14px 40px rgba(16,24,40,.2)",overflow:"hidden",zIndex:6},children:[s(e.attachCamera,n,o.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:m.ink,strokeWidth:"1.5",children:[o.jsx("rect",{x:"1.5",y:"4",width:"13",height:"9.5",rx:"2"}),o.jsx("circle",{cx:"8",cy:"8.7",r:"2.6"}),o.jsx("path",{d:"M5.5 4l1-1.7h3l1 1.7"})]})),s(e.attachLibrary,r,o.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:m.ink,strokeWidth:"1.5",children:[o.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2.5"}),o.jsx("circle",{cx:"6",cy:"6",r:"1.3"}),o.jsx("path",{d:"M2.5 11.5 6 8.5l2.5 2 3-3 2 2"})]})),s(e.attachFile,i,o.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 14 14",fill:"none",stroke:m.ink,strokeWidth:"1.4",children:[o.jsx("path",{d:"M3 1.5h5.5L11.5 4v8.5h-8.5z"}),o.jsx("path",{d:"M8.5 1.5V4H11"})]}),!0)]})]})}function eZ({a:e,onRemove:t}){const n=e.status==="uploading",{openMedia:r}=zd(),i=e.type?Ls(e.type):null,s=!!e.previewUrl&&i!==null;return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:n?7:6,background:"var(--proto-card)",border:`1px solid ${n?m.runBorder:m.hairline}`,borderRadius:9,padding:"5px 9px",flex:"none"},children:[s&&o.jsxs("span",{role:"button",onClick:()=>r({kind:i,name:e.name,url:e.previewUrl}),style:{position:"relative",width:26,height:26,borderRadius:6,overflow:"hidden",background:"#000",flex:"none",cursor:"pointer"},children:[i==="image"?o.jsx("img",{src:e.previewUrl,alt:e.name,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}):o.jsx(Ud,{src:e.previewUrl,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}),i==="video"&&o.jsx("span",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--ink-solid-fg)",fontSize:8,textShadow:"0 0 3px rgba(0,0,0,.8)"},children:"▶"})]}),o.jsx("span",{style:{font:`500 10px ${A}`,color:m.body},children:e.name}),n?o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{width:34,height:4,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden"},children:o.jsx("div",{style:{width:`${e.progress}%`,height:"100%",background:m.run}})}),o.jsxs("span",{style:{font:`400 9px ${A}`,color:m.run},children:[e.progress,"%"]})]}):e.status==="done"?o.jsx("span",{style:{fontSize:10,color:m.done,fontWeight:700},children:"✓"}):e.status==="error"?o.jsx("span",{style:{fontSize:10,color:m.fail,fontWeight:700},children:"!"}):null,o.jsx("span",{onClick:t,style:{color:m.faint,fontSize:11,cursor:"pointer"},children:"✕"})]})}function tZ({usage:e,lang:t,compactAction:n,onClose:r}){return o.jsx(Vr,{onClose:r,children:o.jsxs("div",{"data-mobile-context-usage-sheet":"true",children:[o.jsx("div",{style:{fontSize:17,fontWeight:700,color:m.ink,letterSpacing:"-.01em",padding:"0 2px 10px"},children:tE(t)}),o.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${m.hairline}`,borderRadius:13,padding:"12px 13px"},children:o.jsx(oE,{usage:e,lang:t})}),n?o.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 2px 0"},children:o.jsx(rE,{action:n,lang:t})}):null]})})}function nZ({items:e,copy:t,onClose:n,onPick:r}){return o.jsxs(Vr,{onClose:n,children:[o.jsxs("div",{style:{display:"flex",alignItems:"baseline",padding:"0 2px 10px"},children:[o.jsx("span",{style:{fontSize:17,fontWeight:700,color:m.ink,letterSpacing:"-.01em"},children:t.profileTitle}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${A}`,color:m.faint},children:t.profileSubtitle})]}),o.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${m.hairline}`,borderRadius:13,overflow:"hidden"},children:e.map((i,s)=>o.jsxs("div",{onClick:()=>r(i.name),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 13px",borderBottom:s<e.length-1?"1px solid var(--proto-line-soft)":void 0,cursor:"pointer"},children:[o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[o.jsx("span",{style:{font:`600 13px ${A}`,color:m.ink},children:i.name}),i.current&&o.jsx("span",{style:{fontSize:9.5,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:m.runBg,color:m.run},children:t.profileCurrent})]}),o.jsx("div",{style:{font:`400 10px ${A}`,color:m.muted,marginTop:3},children:i.sub})]}),i.current&&o.jsx("span",{style:{fontSize:15,fontWeight:700,color:m.run,flex:"none"},children:"✓"})]},i.name))}),o.jsx("div",{style:{font:`400 9.5px ${A}`,color:m.faint,padding:"9px 4px 0"},children:t.profileFooter})]})}function rZ({onClick:e}){return o.jsx("button",{type:"button","aria-label":"Attach",onClick:e,style:{flex:"none",width:46,height:46,borderRadius:14,border:`1.5px solid ${m.run}`,background:"var(--proto-card)",display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",color:m.run,fontSize:22,fontWeight:300,cursor:"pointer"},children:"+"})}function oZ({label:e,onClick:t}){return o.jsxs("button",{type:"button",onClick:t,style:{display:"flex",alignItems:"center",gap:6,border:"1px solid var(--proto-accent-bg)",background:"var(--proto-card)",borderRadius:999,padding:"4px 10px",flex:"none",cursor:"pointer"},children:[o.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:m.run}}),o.jsx("span",{style:{font:`600 10px ${A}`,color:m.run},children:e}),o.jsx("span",{style:{fontSize:7.5,color:m.muted},children:"▾"})]})}function iZ(e){var u;const{copy:t}=e,n=f.useRef(null),r=f.useRef(null),i=f.useRef(!0),s=f.useRef(0),a=()=>{const p=n.current;p&&(i.current=p.scrollHeight-p.scrollTop-p.clientHeight<40)},l=()=>{s.current=Date.now()+800};f.useEffect(()=>{const p=n.current;p&&i.current&&Date.now()>=s.current&&(p.scrollTop=p.scrollHeight)},[e.rows,e.systemLines]),f.useEffect(()=>{const p=n.current,h=r.current;if(!p||!h||typeof ResizeObserver>"u")return;const g=new ResizeObserver(()=>{i.current&&Date.now()>=s.current&&(p.scrollTop=p.scrollHeight)});return g.observe(h),()=>g.disconnect()},[]);const d=e.editing&&e.editCopy?o.jsx($J,{title:e.editCopy.editBarTitle,onCancel:e.editing.onCancel}):e.rejectBar?o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:m.amberCard,border:`1px solid ${m.amberBorder}`,borderRadius:11,padding:"8px 8px 8px 12px",marginBottom:7},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:m.amber,flex:"none"}}),o.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--proto-amber-fg)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.rejectBar.title}),o.jsx("div",{role:"button","aria-label":"Cancel reject",onClick:e.rejectBar.onCancel,style:{marginLeft:"auto",width:26,height:26,borderRadius:8,background:"var(--proto-card)",border:`1px solid ${m.amberBorder}`,display:"flex",alignItems:"center",justifyContent:"center",color:m.amberText,fontSize:11,flex:"none",cursor:"pointer"},children:"✕"})]}),o.jsx("div",{style:{display:"flex",gap:6,padding:"0 2px 8px",overflowX:"auto"},children:e.rejectBar.chips.map(p=>o.jsx("span",{role:"button",onClick:()=>e.rejectBar.onChipTap(p),style:{flex:"none",fontSize:11,fontWeight:600,color:m.sub,border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",borderRadius:999,padding:"5px 11px",cursor:"pointer"},children:p},p))})]}):o.jsxs(o.Fragment,{children:[e.attachments.length>0&&o.jsx("div",{style:{display:"flex",gap:6,padding:"0 2px 7px",overflowX:"auto"},children:e.attachments.map(p=>o.jsx(eZ,{a:p,onRemove:()=>e.onRemoveAttachment(p.id)},p.id))}),o.jsxs("div",{"data-mobile-composer-meta-row":"true",style:{display:"flex",alignItems:"center",gap:8,padding:"0 2px 7px"},children:[o.jsx(oZ,{label:e.profileChipLabel,onClick:e.onOpenProfile}),e.contextUsageSupported||e.contextUsage!=null?o.jsx("span",{"data-context-usage-position":"composer-profile",style:{marginLeft:"auto",display:"inline-flex",flex:"none"},children:o.jsx(nE,{usage:e.contextUsage??null,variant:"mobile",lang:e.contextUsageLang??"en",onClick:e.onContextUsageOpen,"data-context-compact-enabled":e.contextCompactAction?"true":void 0})}):null]})]});return o.jsxs("div",{"data-screen-label":"1b 会话详情",style:{height:"100%",position:"relative",display:"flex",flexDirection:"column",boxSizing:"border-box",background:m.canvas},children:[o.jsx(_J,{title:e.title,status:e.status,onBack:e.onBack,onMore:e.onMoreToggle}),o.jsxs("div",{style:{position:"relative",flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[o.jsx("div",{ref:n,onScroll:a,onClick:l,style:{flex:1,minHeight:0,overflow:"auto",background:m.canvas},children:o.jsxs("div",{ref:r,style:{padding:"14px 14px 0",display:"flex",flexDirection:"column",gap:12},children:[o.jsx(XJ,{rows:e.rows,toolCallsUnit:t.toolCallsUnit,interactions:e.interactions,editCopy:e.editCopy,editing:e.editing,onLongPress:e.onLongPress,onShowOriginal:e.onShowOriginal,streamKey:e.streamKey}),e.inlineThreadCard,(u=e.systemLines)==null?void 0:u.map((p,h)=>o.jsx(JJ,{text:p},h)),o.jsx("div",{style:{height:"calc(8px + env(safe-area-inset-bottom))",flex:"none"}})]})}),o.jsx(zK,{placeholder:e.composerPlaceholder??(e.attachments.length>0?t.attachPlaceholder:t.composerPh),value:e.composerValue,onChange:e.onComposerChange,onSend:e.onSend,sendEnabled:e.sendEnabled,running:e.status.running,onStop:e.onStop,stopEnabled:e.stopEnabled,leading:e.editing||e.rejectBar?void 0:o.jsx(rZ,{onClick:e.onPlus}),above:d,onPlus:e.onPlus,lineUnit:t.lineUnit,charUnit:t.charUnit,tone:e.editing?"accent":e.rejectBar?"amber":"default"}),e.msgMenu&&e.editCopy&&e.rows[e.msgMenu.rowIndex]&&o.jsx(NJ,{row:e.rows[e.msgMenu.rowIndex],menu:e.msgMenu,copy:e.editCopy})]}),e.moreOpen&&o.jsx(zJ,{copy:t,onClose:e.onMoreClose,onSessionId:()=>{e.onMoreClose(),e.onSessionIdOpen()}}),e.sessionIdOpen&&o.jsx(BJ,{copy:t,cortexId:e.cortexId,backendUuid:e.backendUuid,onClose:e.onSessionIdClose}),e.originalSheet&&e.editCopy&&o.jsxs(Vr,{onClose:e.originalSheet.onClose,children:[o.jsx("div",{style:{font:`600 10px ${A}`,color:m.muted,letterSpacing:".05em",padding:"0 2px 8px"},children:e.editCopy.original}),o.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${m.hairline}`,borderRadius:13,padding:"11px 13px",fontSize:13,lineHeight:1.6,color:m.body,whiteSpace:"pre-wrap",overflowWrap:"break-word",maxHeight:"50vh",overflow:"auto"},children:e.originalSheet.text})]}),e.attachMenuOpen&&o.jsx(ZJ,{copy:t,onClose:e.onAttachClose,onCamera:e.onCamera,onLibrary:e.onLibrary,onFile:e.onFile}),e.profileSheet&&o.jsx(nZ,{items:e.profileSheet.items,copy:t,onClose:e.profileSheet.onClose,onPick:e.profileSheet.onPick}),e.contextUsageOpen&&(e.contextUsageSupported||e.contextUsage!=null)?o.jsx(tZ,{usage:e.contextUsage??null,lang:e.contextUsageLang??"en",compactAction:e.contextCompactAction,onClose:e.onContextUsageClose}):null]})}const sZ={sessionId:"",turns:[]},aZ="/api/attachments/upload",lZ={zh:{composerPh:"输入消息,/ 调用命令",toolCallsUnit:"次工具调用",menuRename:"重命名",menuExport:"导出",menuArchive:"归档",menuSessionId:"会话 ID",sessionIdTitle:"会话 ID",cortexIdLabel:"Cortex ID",backendUuidLabel:"后端 UUID",copy:"复制",copied:"已复制",attachCamera:"拍照",attachLibrary:"照片图库",attachFile:"选择文件",attachPlaceholder:"补充说明…",profileTitle:"Profile",profileSubtitle:"仅本会话 · 热更新",profileCurrent:"当前",profileFooter:"切换仅影响本会话后续 turn · 运行中线程不受影响 · 全局默认在设置",lineUnit:"行",charUnit:"字"},en:{composerPh:"Message, / for commands",toolCallsUnit:"tool calls",menuRename:"Rename",menuExport:"Export",menuArchive:"Archive",menuSessionId:"Session ID",sessionIdTitle:"Session ID",cortexIdLabel:"Cortex ID",backendUuidLabel:"Backend UUID",copy:"Copy",copied:"Copied",attachCamera:"Take photo",attachLibrary:"Photo library",attachFile:"Choose file",attachPlaceholder:"Add a note…",profileTitle:"Profile",profileSubtitle:"This session · hot-swap",profileCurrent:"current",profileFooter:"Applies to this session’s next turns only · running threads unaffected · global default in Settings",lineUnit:"lines",charUnit:"chars"}},cZ={zh:{menuCopy:"复制",menuEdit:"编辑消息",editingBadge:"编辑中",willRewind:(e,t)=>`将被回退 · ${e} 条回复 · ${t} 次工具调用`,editBarTitle:"编辑消息 — 发送将回退后续回复",edited:"已编辑",original:"原消息",regenNote:"由编辑重新生成"},en:{menuCopy:"Copy",menuEdit:"Edit message",editingBadge:"Editing",willRewind:(e,t)=>`Will rewind · ${e} repl${e===1?"y":"ies"} · ${t} tool call${t===1?"":"s"}`,editBarTitle:"Editing message — send rewinds later replies",edited:"edited",original:"Original message",regenNote:"Regenerated from edit"}};function dZ({sessionId:e,subthreadsLabel:t,openLabel:n}){const r=Be(),i=ae(),a=G({...i.threads.list.queryOptions({status:["running","waiting"],sessionId:e}),enabled:!!e}).data??[],l=a.find(p=>p.status==="running")??a[0]??null,c=(l==null?void 0:l.id)??"";Ml(c);const d=G({...i.threads.get.queryOptions({threadId:c}),enabled:!!c});if(!c||d.isPending||d.isError||!d.data)return null;const u=d.data;return o.jsx(bJ,{card:xJ(u),pill:xy(u.status),subthreadsLabel:t,openLabel:n,onOpen:()=>r(`/m/thread/${c}`)})}function uZ(e){return e.type.startsWith("image/")?"image":e.type.startsWith("video/")?"video":"file"}let pZ=0;const _g=()=>`att_${++pZ}_${Date.now()}`;function fZ(e,t,n){return new Promise((r,i)=>{const s=new XMLHttpRequest;s.open("POST",`${Xv()}${aZ}`),s.setRequestHeader("X-Session-Id",t),s.setRequestHeader("X-File-Name",encodeURIComponent(e.name)),s.setRequestHeader("Content-Type",e.type||"application/octet-stream"),Object.entries(Rs()).forEach(([a,l])=>s.setRequestHeader(a,l)),s.responseType="json",s.upload.addEventListener("progress",a=>{a.lengthComputable&&n(Math.round(a.loaded/a.total*100))}),s.addEventListener("load",()=>{const a=s.response;s.status>=200&&s.status<300&&(a!=null&&a.ok)&&a.data?r(a.data):i(new Error((a==null?void 0:a.message)||`Upload failed (${s.status})`))}),s.addEventListener("error",()=>i(new Error("Network error"))),s.send(e)})}function hZ(){var Nl,Kd,Cy,Ty;const e=ae(),t=Be(),n=je(),r=ft(),i=Lt(r,lZ),{currentProjectId:s}=tr(),{sessionId:a}=Qf(),l=a==="new",c=G(e.sessions.list.queryOptions({origin:"direct",projectId:s??void 0})),d=G(e.sessions.list.queryOptions({origin:"scheduled",projectId:s??void 0})),u=f.useMemo(()=>[...c.data??[],...d.data??[]].find(he=>he.sessionId===a)??null,[c.data,d.data,a]),p=l?"":(u==null?void 0:u.sessionId)??a??"",h=(u==null?void 0:u.origin)==="scheduled",g=G({...e.schedules.list.queryOptions({projectId:s??void 0}),enabled:!!(u!=null&&u.scheduleId)}),v=f.useMemo(()=>{if(!h||!(u!=null&&u.scheduleId))return null;const q=(g.data??[]).find(be=>be.id===u.scheduleId)??null,he=(d.data??[]).filter(be=>be.scheduleId===u.scheduleId);return TT(q,he,u.sessionId)},[h,u==null?void 0:u.scheduleId,u==null?void 0:u.sessionId,g.data,d.data]),x=G({...e.sessions.transcript.queryOptions({sessionId:p}),enabled:!!p}),{liveTail:w,getMessageSnapshot:b,streaming:y,running:j,liveTurns:S,contextUsage:k,streamingText:E,pendingUser:C}=sh(p,u==null?void 0:u.running,u==null?void 0:u.backgroundRunning,{deltas:!0,transcript:x.data??null,contextUsage:(u==null?void 0:u.contextUsage)??null}),R=aE({sessionId:p,isDraft:l,projectId:s??"general",transcript:x.data??null,liveTail:w,pendingUser:C,getMessageSnapshot:b}),P=iE(p,{running:j,hasBackendHistory:!!(u!=null&&u.backendSessionId)}),L=yy(p);sE(p,`${w.length}:${j}`);const _=x.data??sZ,U=f.useMemo(()=>SJ(_,w,{streaming:y,streamingText:E,pendingUser:R.pendingUser,stripScheduledPrefix:!!(u!=null&&u.scheduleId)||h}),[_,w,y,E,R.pendingUser,u==null?void 0:u.scheduleId,h]),K=u3(S,(u==null?void 0:u.numTurns)??null),$=f.useMemo(()=>p3(d3(x.data)),[x.data]),W=f.useMemo(()=>{var q;for(const he of U)if(he.kind==="interaction"&&((q=he.detail)==null?void 0:q.status)==="pending")return{detail:he.detail,ts:he.ts??null};return null},[U]),V=(W==null?void 0:W.detail.kind)==="ask-user"?Z6(W.detail,W.ts):null,Z=(W==null?void 0:W.detail.kind)==="plan-approval"?Y0(W.detail,W.ts):null,[N,F]=f.useState({}),H=q=>N[q]??e3,re=(q,he)=>{F(be=>({...be,[q.requestId]:he})),eW(q,he)&&L.answerQuestion(q.requestId,tW(q,he))},D=(q,he)=>{const be=H(q.requestId),We=q.questions[Vo(q,be)];We&&re(q,Im(be,We.question,he))},Q=(q,he)=>{F(be=>({...be,[q.requestId]:JB(H(q.requestId),he)}))},ne=q=>{const he=H(q.requestId),be=q.questions[Vo(q,he)];be&&he.selected.length>0&&re(q,ZB(he,be.question))},[J,te]=f.useState(null),fe=wr();f.useEffect(()=>{const q=fe.state;q!=null&&q.rejectPlan&&(te(q.rejectPlan),t(fe.pathname,{replace:!0}))},[fe.state]);const ve=(Z==null?void 0:Z.requestId)??null;f.useEffect(()=>{J&&J!==ve&&te(null)},[J,ve]);const ke=q=>t(`/m/session/${p}/plan/${q.requestId}`),Ct=G(e.config.get.queryOptions({})),we=((Kd=(Nl=Ct.data)==null?void 0:Nl.profiles)==null?void 0:Kd.profiles)??[],Ee=((Ty=(Cy=Ct.data)==null?void 0:Cy.profiles)==null?void 0:Ty.defaultProfile)??null,[Xe,Tt]=f.useState(null),[ht,lt]=f.useState(null),Kr=z3(u==null?void 0:u.profileName,ht,p),zt=RJ(l?Xe:Kr,we,Ee);f.useEffect(()=>{if(!ht)return;const q=(u==null?void 0:u.sessionId)===ht.sessionId,he=!l&&p!==ht.sessionId;(q||he)&<(null)},[u==null?void 0:u.sessionId,l,ht,p]);const Ot=ue(e.sessions.send.mutationOptions()),hn=ue(e.sessions.createAndSend.mutationOptions()),Mo=ue(e.sessions.setProfile.mutationOptions({onSuccess:()=>n.invalidateQueries(e.sessions.list.queryFilter())})),Bt=ue(e.sessions.cancel.mutationOptions()),kr=()=>{!p||Bt.isPending||Bt.mutate({sessionId:p})},sn=ue(e.sessions.rewind.mutationOptions({onSettled:()=>{p&&(n.invalidateQueries(e.sessions.transcript.queryFilter({sessionId:p})),n.invalidateQueries(e.sessions.list.queryFilter()))}})),[yt,Wt]=f.useState(""),[Yt,gt]=f.useState([]),[Ut,Ht]=f.useState(!1),[qt,Lo]=f.useState(!1),[Dt,Qr]=f.useState(null),[Un,Hn]=f.useState(null),[an,nr]=f.useState(null),[Y,me]=f.useState(null),Ve=f.useRef(""),[nt,At]=f.useState(!1),[Oo,_i]=f.useState(!1),[Fi,Sr]=f.useState(!1),[Cr,zi]=f.useState([]),Fs=f.useRef(null),T=f.useRef(null);l&&!T.current&&(T.current=crypto.randomUUID());const I=l?T.current??"":p,O=Hd({isDraft:l,sessionId:p,projectId:s}),z=f.useRef(void 0);f.useEffect(()=>{if(z.current!==O){if(z.current=O,!O)return;const q=dd(O);l&&(q!=null&&q.draftUploadId)&&(T.current=q.draftUploadId),Wt((q==null?void 0:q.text)??"");const he=((q==null?void 0:q.attachments)??[]).map(be=>({id:_g(),status:"done",progress:100,meta:be,type:be.type}));gt(be=>(be.forEach(We=>{We.previewUrl&&URL.revokeObjectURL(We.previewUrl)}),he));return}Os(O,{text:yt,attachments:Yt.filter(q=>q.status==="done"&&q.meta).map(q=>q.meta),...l&&T.current?{draftUploadId:T.current}:{}})},[O,yt,Yt,l]),f.useEffect(()=>{let q=!1;return Yt.filter(he=>!he.file&&!he.previewUrl&&he.status==="done"&&he.meta&&(he.type==="image"||he.type==="video")).forEach(he=>{Fd(he.meta.path,"inline").then(be=>{if(q){URL.revokeObjectURL(be);return}gt(We=>We.map(Fe=>Fe.id===he.id?{...Fe,previewUrl:be}:Fe))}).catch(()=>{})}),()=>{q=!0}},[Yt]);const X=q=>{const he=Array.from(q);for(const be of he){const We=_g(),Fe=uZ(be),gn=Fe==="image"||Fe==="video"?URL.createObjectURL(be):void 0;gt(Tr=>[...Tr,{id:We,file:be,status:"uploading",progress:0,type:Fe,previewUrl:gn}]),fZ(be,I,Tr=>gt(Hi=>Hi.map(qi=>qi.id===We?{...qi,progress:Tr}:qi))).then(Tr=>gt(Hi=>Hi.map(qi=>qi.id===We?{...qi,status:"done",progress:100,meta:Tr}:qi))).catch(()=>gt(Tr=>Tr.map(Hi=>Hi.id===We?{...Hi,status:"error"}:Hi)))}},oe=(q,he)=>{const be=Fs.current;be&&(be.accept=q,he?be.setAttribute("capture",he):be.removeAttribute("capture"),be.click())},ce=Yt.filter(q=>q.status==="done"&&q.meta).map(q=>q.meta),de=Yt.some(q=>q.status==="uploading"),se=!!yt.trim(),ie=an!=null?U[an]:null,pe=!!ie&&ie.kind==="user"&&ie.turnIndex!==void 0,ye=()=>{nr(null),Wt(Ve.current),Ve.current=""},Ce=q=>{const he=U[q];!he||he.kind!=="user"||he.turnIndex===void 0||j||(Ve.current=yt,te(null),nr(q),Wt(he.text))};f.useEffect(()=>{if(an==null)return;const q=U[an];(!(!!q&&q.kind==="user"&&q.turnIndex!==void 0)||j)&&ye()},[U,j,an]);const Je=pe?{rowIndex:an,...f3(U,an),onCancel:ye}:null,Ae=Dt!=null?U[Dt]:null,Ne=Ae&&(Ae.kind==="user"||Ae.kind==="assistant")?{rowIndex:Dt,anchorTop:Un,onCopy:()=>{var q;(q=navigator.clipboard)==null||q.writeText(Ae.text).catch(()=>{})},...Ae.kind==="user"&&Ae.turnIndex!==void 0?{onEdit:()=>Ce(Dt),editDisabled:j||sn.isPending}:{},onClose:()=>Qr(null)}:null,Ke=!pe&&!!J&&J===ve,Do=pe?se&&!sn.isPending:Ke||!!V?se&&!L.busy:(se||ce.length>0)&&(!!p||l)&&!de&&!Ot.isPending&&!hn.isPending,rr=(q,he,be)=>{if(z.current!==he){Os(he,W3(dd(he)??{text:"",attachments:[]},q));return}q.draftUploadId&&(T.current=q.draftUploadId),Wt(We=>[q.text,We].filter(Fe=>Fe.length>0).join(`
|
|
140
|
+
`)),gt(We=>[...q.attachments.filter(Fe=>!We.some(gn=>{var Tr;return((Tr=gn.meta)==null?void 0:Tr.path)===Fe.path})).map(Fe=>({id:_g(),status:"done",progress:100,meta:Fe,type:Fe.type})),...We]),zi(We=>[...We,r==="zh"?`发送失败 · ${be.message} · 内容已退回输入框`:`send failed · ${be.message} · text restored to the composer`])},qn=()=>{const q=yt.trim();if(!Do)return;if(pe){const Fe=ie;sn.mutate({sessionId:p,turnIndex:Fe.turnIndex,text:q}),nr(null),Wt(Ve.current),Ve.current="";return}if(Ke){L.rejectPlan(J,q),te(null),Wt("");return}if(V){const Fe=H(V.requestId),gn=V.questions[Vo(V,Fe)];gn&&re(V,Im(Fe,gn.question,q)),Wt("");return}const he={text:q,attachments:ce,...l&&T.current?{draftUploadId:T.current}:{}},be=O,We=ZT({message:R.prepare(q,ce),mutate:()=>l?hn.mutateAsync({projectId:s??"general",profileName:Xe??void 0,text:q,draftUploadId:he.draftUploadId,...ce.length>0?{attachments:ce}:{}}):Ot.mutateAsync({sessionId:p,text:q,...ce.length>0?{attachments:ce}:{}}),onEnqueue:R.enqueue,onAccepted:(Fe,gn)=>{if(!("sessionId"in gn)){R.accept(Fe.clientId);return}R.accept(Fe.clientId,gn.sessionId),lt({sessionId:gn.sessionId,profileName:Xe}),n.invalidateQueries(e.sessions.list.queryFilter()),t(`/m/session/${gn.sessionId}`,{replace:!0})},onRejected:Fe=>R.reject(Fe.clientId)});H3(O),l&&(T.current=null),Wt(""),gt(Fe=>(Fe.forEach(gn=>{gn.previewUrl&&URL.revokeObjectURL(gn.previewUrl)}),[])),We.then(Fe=>{!Fe.ok&&Fe.restore&&rr(he,be,Fe.error)})},Dl=q=>{if(_i(!1),q===zt)return;const he=zt,be=r==="zh"?`profile 切换 ${he} → ${q} · 下一 turn 生效`:`profile ${he} → ${q} · takes effect next turn`;l?(Tt(q),zi(We=>[...We,be])):p&&Mo.mutate({sessionId:p,profileName:q},{onSuccess:()=>zi(We=>[...We,be])})},Wi=(u==null?void 0:u.costUsd)??null,Gr=!l&&K!=null,zs=W?EJ(W.detail.kind,V?Vo(V,H(V.requestId)):0,(V==null?void 0:V.questions.length)??1,r):TJ(j,K,$,Wi,Gr),De={copy:Lt(r,TE),askState:H,onAskPick:D,onAskToggle:Q,onAskConfirmMulti:ne,onAskCustom:()=>{},rejectingId:Ke?J:null,onApprove:q=>L.approvePlan(q.requestId),onRejectStart:q=>te(q.requestId),onOpenRead:ke,onCancelResume:L.cancelResume,resumeCancelled:L.resumeCancelled},rt=Ke&&Z?{title:r==="zh"?`驳回「${Z.title}」— 说明原因后发送`:`Rejecting "${Z.title}" — explain, then send`,chips:r==="zh"?["范围太大","先做 dry-run","成本超预期","步骤顺序不对"]:["Scope too big","Dry-run first","Over budget","Wrong step order"],onChipTap:q=>Wt(he=>he?`${he}${r==="zh"?";":"; "}${q}`:q),onCancel:()=>te(null)}:void 0,Ao=Ke?r==="zh"?"说明驳回原因…":"Reason for rejecting…":V?r==="zh"?`点选项,或直接输入回答 Q${Math.min(Vo(V,H(V.requestId))+1,V.questions.length)}…`:`Tap an option, or type your answer to Q${Math.min(Vo(V,H(V.requestId))+1,V.questions.length)}…`:void 0,Ui=l?r==="zh"?"新会话":"New session":v??(u==null?void 0:u.label)??(u==null?void 0:u.name)??a??"",ct=h?r==="zh"?"发送消息后提取为普通会话 · schedule 下次 run 不受影响":"Replying converts this run into a normal session · the schedule's next run is unaffected":null,No=Yt.map(q=>{var he,be;return{id:q.id,name:((he=q.file)==null?void 0:he.name)??((be=q.meta)==null?void 0:be.name)??"file",progress:q.progress,status:q.status,type:q.type,previewUrl:q.previewUrl}});return o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:Fs,type:"file",multiple:!0,style:{display:"none"},onChange:q=>{q.target.files&&q.target.files.length>0&&X(q.target.files),q.target.value=""}}),o.jsx(iZ,{title:Ui,status:zs,rows:U,copy:i,onBack:()=>t("/m/sessions"),moreOpen:Ut,onMoreToggle:()=>Ht(q=>!q),onMoreClose:()=>Ht(!1),sessionIdOpen:qt,onSessionIdOpen:()=>Lo(!0),onSessionIdClose:()=>Lo(!1),cortexId:(u==null?void 0:u.name)??null,backendUuid:(u==null?void 0:u.backendSessionId)??null,inlineThreadCard:p?o.jsx(dZ,{sessionId:p,subthreadsLabel:r==="zh"?"子线程":"sub-threads",openLabel:r==="zh"?"打开":"Open"}):void 0,systemLines:ct?[...Cr,ct]:Cr,interactions:De,rejectBar:rt,editCopy:Lt(r,cZ),msgMenu:Ne,onLongPress:(q,he)=>{Hn(he),Qr(q)},editing:Je,onShowOriginal:q=>me({text:q.originalText}),originalSheet:Y?{text:Y.text,onClose:()=>me(null)}:null,streamKey:p,composerValue:yt,onComposerChange:Wt,onSend:qn,sendEnabled:Do,composerPlaceholder:Ao,onStop:kr,stopEnabled:!Bt.isPending,profileChipLabel:PJ(zt,we),onOpenProfile:()=>_i(!0),contextUsage:k,contextUsageSupported:!!(u!=null&&u.contextCompactionSupported),contextUsageLang:r,contextCompactAction:u!=null&&u.contextCompactionSupported?P:void 0,contextUsageOpen:Fi,onContextUsageOpen:()=>Sr(!0),onContextUsageClose:()=>Sr(!1),attachments:No,onRemoveAttachment:q=>gt(he=>{const be=he.find(We=>We.id===q);return be!=null&&be.previewUrl&&URL.revokeObjectURL(be.previewUrl),he.filter(We=>We.id!==q)}),onPlus:()=>At(q=>!q),attachMenuOpen:nt,onAttachClose:()=>At(!1),onCamera:()=>oe("image/*","environment"),onLibrary:()=>oe("image/*,video/*"),onFile:()=>oe("*/*"),profileSheet:Oo?{items:EE(we,zt),onClose:()=>_i(!1),onPick:Dl}:void 0})]})}const gZ={zh:{lang:"zh",pendingPill:"计划待批",approvedStamp:"✓ 计划已批准",rejectedStamp:"已驳回",cancelledStamp:"已取消",expiredStamp:"已过期",approve:"批准并执行",reject:"驳回并反馈",approvedBy:"由你批准",feedbackLabel:"驳回反馈"},en:{lang:"en",pendingPill:"Plan pending",approvedStamp:"✓ Plan approved",rejectedStamp:"Rejected",cancelledStamp:"Cancelled",expiredStamp:"Expired",approve:"Approve & run",reject:"Reject with note",approvedBy:"approved by you",feedbackLabel:"Reject feedback"}};function xZ({model:e,copy:t,onBack:n,onApprove:r,onReject:i}){const s=e.status==="pending",[a,l]=f.useState(0),c=f.useRef(null),d=()=>{const g=c.current;if(!g)return;const v=s3(g.scrollTop,g.clientHeight,g.scrollHeight);l(x=>Math.max(x,v))},u=a3(e.status,t.lang),p=c3(a,t.lang),h=e.status==="approved"?{text:`${t.approvedStamp}${e.timeLabel?` · ${e.timeLabel} ${t.approvedBy}`:""}`,fg:m.done,bg:m.doneBg}:e.status==="rejected"?{text:`${t.rejectedStamp}${e.timeLabel?` · ${e.timeLabel}`:""}`,fg:m.grayInk,bg:m.gray}:e.status==="cancelled"?{text:t.cancelledStamp,fg:m.grayInk,bg:m.gray}:{text:t.expiredStamp,fg:m.grayInk,bg:m.gray};return o.jsxs("div",{"data-screen-label":"6b 计划全文阅读页",style:{height:"100%",display:"flex",flexDirection:"column",boxSizing:"border-box",position:"relative",background:m.canvas},children:[o.jsxs("div",{style:{flex:"none",padding:"8px 14px 10px",paddingTop:"calc(8px + env(safe-area-inset-top))",borderBottom:`1px solid ${m.hairline}`,background:m.canvas},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[o.jsx("button",{type:"button","aria-label":"Back",onClick:n,style:{border:"none",background:"transparent",color:m.run,fontSize:15,lineHeight:1,padding:"0 2px",margin:0,cursor:"pointer",flex:"none",minHeight:44,minWidth:30,display:"flex",alignItems:"center"},children:"‹"}),o.jsxs("div",{style:{minWidth:0},children:[o.jsx("div",{style:{fontSize:15,fontWeight:650,color:m.ink,letterSpacing:"-.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),o.jsx("div",{style:{font:`400 10px ${A}`,color:m.muted,marginTop:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:l3(e.filePath,e.lineCount,u,t.lang)})]}),s?o.jsx("span",{style:{marginLeft:"auto",font:`600 9.5px ${A}`,color:m.amberInk,background:m.amberBg,padding:"2px 8px",borderRadius:999,flex:"none"},children:t.pendingPill}):o.jsx("span",{style:{marginLeft:"auto",font:`600 9.5px ${A}`,color:h.fg,background:h.bg,padding:"2px 8px",borderRadius:999,flex:"none"},children:u})]}),s&&o.jsx("div",{style:{height:3,borderRadius:999,background:"var(--proto-line)",overflow:"hidden",marginTop:9},children:o.jsx("div",{style:{width:`${a}%`,height:"100%",background:m.run}})})]}),o.jsxs("div",{style:{flex:1,minHeight:0,position:"relative",background:"var(--proto-card)"},children:[o.jsxs("div",{ref:c,onScroll:d,style:{position:"absolute",inset:0,overflow:"auto",padding:"16px 18px 24px",boxSizing:"border-box"},children:[e.timeLabel&&o.jsx("div",{style:{font:`400 10px ${A}`,color:m.faint,paddingBottom:8},children:e.timeLabel}),o.jsx("div",{style:{fontSize:13,lineHeight:1.7,color:m.body},children:o.jsx(Ai,{text:e.planContent})}),e.status==="rejected"&&e.feedback&&o.jsxs("div",{style:{marginTop:16,border:`1px solid ${m.amberBorder}`,background:m.amberCard,borderRadius:11,padding:"10px 13px"},children:[o.jsx("div",{style:{font:`600 10px ${A}`,color:m.amberText,paddingBottom:4},children:t.feedbackLabel}),o.jsx("div",{style:{fontSize:12.5,lineHeight:1.6,color:"var(--proto-amber-fg)",whiteSpace:"pre-wrap"},children:e.feedback})]})]}),o.jsx("div",{style:{position:"absolute",left:0,right:0,bottom:0,height:56,background:"linear-gradient(180deg,rgba(255,255,255,0),var(--proto-card))",pointerEvents:"none"}})]}),o.jsx("div",{style:{flex:"none",background:"var(--proto-card)",borderTop:"1px solid var(--proto-line-2)",padding:"10px 14px",paddingBottom:"calc(14px + env(safe-area-inset-bottom))"},children:s?o.jsxs("div",{style:{display:"flex",gap:8},children:[o.jsxs("button",{type:"button",onClick:r,style:{flex:1.3,height:48,borderRadius:13,background:m.ink,color:"var(--ink-solid-fg)",border:"none",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:1,cursor:"pointer"},children:[o.jsx("span",{style:{fontSize:14,fontWeight:600},children:t.approve}),p]}),o.jsx("button",{type:"button",onClick:i,style:{flex:1,height:48,borderRadius:13,border:"1.5px solid var(--proto-line-3)",background:"var(--proto-card)",color:m.ink,fontSize:14,fontWeight:600,boxSizing:"border-box",cursor:"pointer"},children:t.reject})]}):o.jsx("div",{style:{height:48,borderRadius:13,background:h.bg,color:h.fg,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13.5,fontWeight:600},children:h.text})})]})}function mZ(){const{sessionId:e="",requestId:t=""}=Qf(),n=Be(),r=ae(),i=ft(),s=Lt(i,gZ),a=G({...r.sessions.transcript.queryOptions({sessionId:e}),enabled:!!e});sh(e,void 0);const l=yy(e),c=dW(a.data,t),d=()=>n(`/m/session/${e}`);if(!c)return o.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10,background:m.canvas},children:[o.jsx("div",{style:{font:`400 11px ${A}`,color:m.faint},children:a.isPending?"…":i==="zh"?"未找到该计划":"Plan not found"}),o.jsx("button",{type:"button",onClick:d,style:{border:`1px solid ${m.hairline}`,background:"var(--proto-card)",borderRadius:999,padding:"7px 16px",fontSize:12.5,fontWeight:600,color:m.ink,cursor:"pointer"},children:i==="zh"?"返回会话":"Back to chat"})]});const u=Y0(c.detail,c.ts);return o.jsx(xZ,{model:u,copy:s,onBack:d,onApprove:()=>{u.status==="pending"&&l.approvePlan(u.requestId)},onReject:()=>n(`/m/session/${e}`,{state:{rejectPlan:t}})})}function vZ(e,t){const n=typeof t=="number"&&t>0,r=typeof e=="number"?e:0;return{numerator:ud(typeof e=="number"?e:null),denominator:n?ud(t):"—",pct:n?Math.max(0,Math.min(100,r/t*100)):0}}function yZ(e){return e==="running"||e==="waiting"}function bZ(e,t){var n;if(t&&t.steps.length>0)return t.steps.map((r,i)=>({label:r.stage??`#${i+1}`,state:r.status==="completed"?"done":r.status==="running"?"active":"pending"}));if(e.totalSteps>0){const r=((n=e.currentStep)==null?void 0:n.index)??-1;return Array.from({length:e.totalSteps},(i,s)=>{var a;return{label:s===r&&((a=e.currentStep)!=null&&a.name)?e.currentStep.name:`#${s+1}`,state:s<r?"done":s===r?"active":"pending"}})}return[]}function jZ(e,t,n,r){const i=[e.id];if(e.taskId&&i.push(`task ${e.taskId}`),i.push(wT(e.createdAt,n)),t){i.push(qr(t.totalCostUsd));const s=t.children.length;s>0&&i.push(`${s} ${r}`)}return i.join(" · ")}function wZ(e,t){switch(e){case"running":return{tone:"running",label:t.running};case"waiting":return{tone:"waiting",label:t.waiting};case"completed":return{tone:"done",label:t.done};case"failed":case"aborted":return{tone:"failed",label:t.failed};case"cancelled":return{tone:"cancelled",label:t.cancelled};default:return{tone:$T(e),label:t.running}}}function kZ({color:e}){return o.jsxs("svg",{width:13,height:13,viewBox:"0 0 14 14",fill:"none",stroke:e,strokeWidth:1.6,style:{flex:"none"},children:[o.jsx("circle",{cx:"3.5",cy:"3",r:"1.9"}),o.jsx("circle",{cx:"3.5",cy:"11",r:"1.9"}),o.jsx("circle",{cx:"10.5",cy:"7",r:"1.9"}),o.jsx("path",{d:"M3.5 5v4M5.4 3.7 8.7 6.1M5.4 10.3 8.7 7.9"})]})}function SZ({copy:e,qn:t,band:n}){return o.jsx(dh,{title:e.title,qn:t,below:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:9},children:[o.jsx("span",{style:{fontSize:10,fontWeight:600,color:m.muted},children:e.today}),o.jsx("div",{style:{flex:1,height:4,borderRadius:999,background:"var(--proto-line)",overflow:"hidden"},children:o.jsx("div",{style:{width:`${n.pct}%`,height:"100%",background:m.run}})}),o.jsxs("span",{style:{font:`500 10px ${A}`,color:m.ink},children:[n.numerator," / ",n.denominator]})]})})}function CZ({groups:e,copy:t,renderThread:n}){return o.jsx(o.Fragment,{children:e.map((r,i)=>o.jsxs("section",{style:{display:"flex",flexDirection:"column",gap:9},children:[o.jsxs(xl,{style:{padding:i===0?"0 2px 2px":"6px 2px 2px"},children:[t[r.kind]," · ",r.threads.length]}),r.threads.map(n)]},r.kind))})}function TZ({state:e}){return e==="done"?o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:m.doneBg,color:m.done,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700,flex:"none"},children:"✓"}):e==="active"?o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:m.run,boxShadow:`0 0 0 3px ${m.runBg}`,animation:"cxpulse 1.6s ease-in-out infinite",flex:"none"}}):o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}})}const Qw=4;function EZ({step:e}){const t=e.state==="active"?m.ink:e.state==="done"?m.sub:m.faint;return o.jsx("span",{title:e.label,style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:10.5,color:t,fontWeight:e.state==="active"?600:400},children:e.label})}function RZ({step:e,connected:t}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",minWidth:0,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,minWidth:0,flex:"0 1 auto"},children:[o.jsx(TZ,{state:e.state}),o.jsx(EZ,{step:e})]}),t&&o.jsx("div",{style:{flex:1,minWidth:2,height:1.5,margin:"0 6px",background:e.state==="done"?"var(--proto-success-bg)":m.hairline}})]})}function PZ({steps:e}){const t=Math.min(Qw,e.length);return o.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${t}, minmax(0, 1fr))`,rowGap:8,padding:"10px 0 4px"},children:e.map((n,r)=>o.jsx(RZ,{step:n,connected:r<e.length-1&&(r+1)%Qw!==0},r))})}function IE({info:e,detail:t,now:n,copy:r,onOpen:i}){const s=bZ(e,t),a=wZ(e.status,r),l=e.status==="running"?m.run:e.status==="waiting"?m.amber:m.muted;return o.jsxs(Oe,{onClick:i,children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx(kZ,{color:l}),o.jsx("span",{style:{font:`600 12.5px ${A}`,color:m.ink},children:e.templateName}),o.jsx("span",{style:{marginLeft:"auto"},children:o.jsx(Gt,{tone:a.tone,children:a.label})})]}),s.length>0&&o.jsx(PZ,{steps:s}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:4},children:[o.jsx("span",{style:{font:`400 10px ${A}`,color:"var(--proto-muted-3)"},children:jZ(e,t,n,r.subthread)}),o.jsxs("span",{style:{marginLeft:"auto",fontSize:11.5,fontWeight:600,color:m.run},children:[r.open," ›"]})]})]})}const IZ={en:{title:"Threads",active:"Active",history:"History",today:"Today",open:"Open",subthread:"subthreads",empty:"No threads",running:"Running",waiting:"Waiting",done:"Done",failed:"Failed",cancelled:"Cancelled"},zh:{title:"线程",active:"活跃",history:"历史",today:"今日",open:"打开",subthread:"子线程",empty:"暂无线程",running:"运行中",waiting:"等待中",done:"已完成",failed:"失败",cancelled:"已取消"}};function MZ({info:e,now:t,copy:n,onOpen:r}){const i=ae();Ml(e.id);const s=G(i.threads.get.queryOptions({threadId:e.id}));return o.jsx(IE,{info:e,detail:s.data,now:t,copy:n,onOpen:r})}function LZ(){var h,g;const e=ae(),t=Be(),n=ft(),r=Lt(n,IZ),{currentProjectId:i}=tr(),s=vE(!0);wy();const a=i??void 0,l=G(e.threads.list.queryOptions({projectId:a})),c=G(e.cost.summary.queryOptions({projectId:a})),d=mE(l.data??[]),u=f.useMemo(()=>{var v,x;return vZ((v=c.data)==null?void 0:v.today,(x=c.data)==null?void 0:x.dailyBudget)},[(h=c.data)==null?void 0:h.today,(g=c.data)==null?void 0:g.dailyBudget]),p=i?Ll(i):void 0;return o.jsx(vt,{label:"1c 线程",header:o.jsx(SZ,{copy:r,qn:p,band:u}),children:o.jsxs(En,{children:[l.isSuccess&&d.length===0&&o.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:m.faint,fontSize:13},children:r.empty}),o.jsx(CZ,{groups:d,copy:r,renderThread:v=>{const x=()=>t(`/m/thread/${v.id}`);return yZ(v.status)?o.jsx(MZ,{info:v,now:s,copy:r,onOpen:x},v.id):o.jsx(IE,{info:v,detail:void 0,now:s,copy:r,onOpen:x},v.id)}})]})})}function OZ(e,t){return fh(e,t).length>0}const DZ=[{kind:"done",matches:e=>e.status==="done"},{kind:"blocked",matches:e=>e.blockedBy!=null},{kind:"in-progress",matches:e=>e.claimedBy!=null},{kind:"approval-needed",matches:e=>e.approvalNeeded===!0},{kind:"waiting-deps",matches:(e,t)=>t},{kind:"actionable",matches:e=>e.actionable}];function AZ(e,t){var n;return((n=DZ.find(r=>r.matches(e,t)))==null?void 0:n.kind)??"waiting-deps"}const NZ={"in-progress":"inProgress",actionable:"actionable","approval-needed":"approvalNeeded","waiting-deps":"waitingDeps",blocked:"blocked",done:"done"};function $Z(e){const t=new Map(e.map(r=>[r.id,r.status])),n={inProgress:[],actionable:[],approvalNeeded:[],waitingDeps:[],blocked:[],done:[]};for(const r of e){const i=AZ(r,OZ(r,t));n[NZ[i]].push(r)}return n.done=lE(n.done),n}const _Z={"in-progress":"inProgress",actionable:"actionable","approval-needed":"approvalNeeded","waiting-deps":"waiting",blocked:"blocked",done:"done"},ME={flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"};function Ol({task:e,textColor:t=m.body}){return o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6,minWidth:0,flex:1},children:[o.jsx("span",{style:{font:`500 10px ${A}`,color:m.muted,flex:"none"},children:e.id}),o.jsx("span",{style:{fontSize:12.5,color:t,lineHeight:1.45,...ME},title:e.text,children:e.text})]})}function Sy({text:e,color:t,dot:n,onClick:r,singleLine:i=!1}){return o.jsxs("div",{onClick:r,style:{display:"flex",alignItems:"center",gap:5,marginTop:5,minWidth:0,cursor:r?"pointer":"default"},children:[n&&o.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:n,flex:"none"}}),o.jsx("span",{"data-task-blocker":i?"true":void 0,style:{font:`400 9.5px ${A}`,color:t,...i?ME:{}},children:e})]})}function FZ({task:e,copy:t,onOpenTask:n,onOpenThread:r}){const i=qd(e),s=i,a=l=>{l.stopPropagation(),s&&r(s)};return o.jsxs(Oe,{radius:11,padding:"10px 13px",onClick:()=>n(e.id),children:[o.jsx(Ol,{task:e}),o.jsx("div",{style:{display:"flex",alignItems:"center",gap:7,marginTop:5},children:o.jsxs("span",{onClick:a,style:{font:`500 9.5px ${A}`,color:m.run,background:m.runBg,padding:"2px 7px",borderRadius:999,cursor:s?"pointer":"default"},children:[t.claim,i?` · ${i}`:"",s?" ›":""]})})]})}function zZ({task:e,copy:t,expanded:n,onToggle:r,onOpenTask:i}){return o.jsxs(Oe,{radius:11,padding:"10px 13px",onClick:()=>i(e.id),children:[o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6,minWidth:0},children:[o.jsx(Ol,{task:e}),o.jsx("span",{role:"button","aria-label":"Toggle done-when","aria-expanded":n,onClick:s=>{s.stopPropagation(),r(e.id)},style:{marginLeft:"auto",color:m.faint,fontSize:8.5,flex:"none",cursor:"pointer",padding:"2px 2px 2px 8px"},children:n?"▾":"▸"})]}),n&&o.jsxs("div",{style:{marginTop:7,padding:"8px 10px",background:"var(--proto-alt)",borderRadius:8,font:`400 10px/1.6 ${A}`,color:m.sub},children:[t.doneWhen,": ",e.doneWhen??t.doneWhenGap]})]})}function BZ({task:e,copy:t,onOpenTask:n,onOpenApprovals:r}){const i=s=>{s.stopPropagation(),r()};return o.jsxs(Oe,{radius:11,padding:"10px 13px",onClick:()=>n(e.id),children:[o.jsx(Ol,{task:e}),o.jsx(Sy,{text:`${t.approvalNeeded} · ${t.openApprovals}`,color:m.amberText,dot:m.amber,onClick:i})]})}function WZ({task:e,copy:t,onOpenTask:n}){const r=fh(e),i=r.length>0?`${t.needs} ${r.join(", ")}`:t.waiting;return o.jsxs(Oe,{radius:11,padding:"10px 13px",onClick:()=>n(e.id),style:{opacity:.8},children:[o.jsx(Ol,{task:e,textColor:m.sub}),o.jsx(Sy,{text:i,color:m.muted})]})}function UZ({task:e,copy:t,onOpenTask:n}){const r=e.blockedBy?`${t.blocked} · ${e.blockedBy}`:t.blocked;return o.jsxs(Oe,{radius:11,padding:"10px 13px",onClick:()=>n(e.id),style:{opacity:.75},children:[o.jsx(Ol,{task:e,textColor:m.sub}),o.jsx(Sy,{text:r,color:m.amberText,dot:m.amber,singleLine:!0})]})}function HZ({task:e,onOpenTask:t}){const n=ah(e.completedAt);return o.jsx(Oe,{radius:11,padding:"10px 13px",onClick:()=>t(e.id),style:{opacity:.7},children:o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6,minWidth:0},children:[o.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:m.done,flex:"none"}}),o.jsx(Ol,{task:e,textColor:m.sub}),n&&o.jsx("span",{style:{font:`400 9.5px ${A}`,color:m.muted,flex:"none"},children:n})]})})}const qZ={"in-progress":FZ,actionable:zZ,"approval-needed":BZ,"waiting-deps":WZ,blocked:UZ,done:HZ};function VZ({groups:e,scope:t,copy:n,expandedIds:r,onToggleExpand:i,onOpenTask:s,onOpenThread:a,onOpenApprovals:l}){return o.jsx(vt,{label:"1d 任务",header:o.jsx(dh,{title:n.title,qn:t}),children:o.jsxs(En,{gap:6,children:[e.length===0&&o.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:m.faint,fontSize:13},children:n.empty}),e.map((c,d)=>{const u=qZ[c.key];return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[o.jsxs(xl,{style:{padding:d===0?"0 2px 2px":"6px 2px 2px"},children:[n[_Z[c.key]]," · ",c.tasks.length]}),c.tasks.map(p=>o.jsx(u,{task:p,copy:n,expanded:r.has(p.id),onToggle:i,onOpenTask:s,onOpenThread:a,onOpenApprovals:l},p.id))]},c.key)})]})})}function KZ(e){return[{key:"in-progress",tasks:e.inProgress},{key:"actionable",tasks:e.actionable},{key:"approval-needed",tasks:e.approvalNeeded},{key:"waiting-deps",tasks:e.waitingDeps},{key:"blocked",tasks:e.blocked},{key:"done",tasks:e.done}].filter(n=>n.tasks.length>0)}const QZ={en:{title:"Tasks",inProgress:"In progress",actionable:"Actionable",approvalNeeded:"Approval needed",waiting:"Waiting",blocked:"Blocked",claim:"claimed",needs:"needs",doneWhen:"done-when",doneWhenGap:"no done-when recorded",openApprovals:"open approvals",done:"Done",empty:"No tasks"},zh:{title:"任务",inProgress:"进行中",actionable:"可执行",approvalNeeded:"需要审批",waiting:"等待",blocked:"阻塞",claim:"认领",needs:"依赖",doneWhen:"done-when",doneWhenGap:"done-when 未记录",openApprovals:"打开审批",done:"完成",empty:"暂无任务"}};function GZ(){const[e,t]=f.useState(()=>new Set);return{expandedIds:e,toggle:r=>t(i=>{const s=new Set(i);return s.has(r)?s.delete(r):s.add(r),s})}}function YZ(e){const t=ae();by();const n=G(t.tasks.list.queryOptions({projectId:e??void 0})),r=n.data??[],i=f.useMemo(()=>KZ($Z(r)),[r]);return{query:n,groups:i}}function XZ(){const e=Be(),t=Lt(ft(),QZ),{currentProjectId:n}=tr(),{query:r,groups:i}=YZ(n),s=GZ(),a=n?Ll(n):void 0;return r.isLoading?o.jsx(vt,{label:"1d 任务",children:o.jsx("div",{style:{padding:16,color:m.muted,fontSize:13},children:t.empty})}):o.jsx(VZ,{groups:i,scope:a,copy:t,expandedIds:s.expandedIds,onToggleExpand:s.toggle,onOpenTask:l=>e(`/m/task/${l}`),onOpenThread:l=>e(`/m/thread/${l}`),onOpenApprovals:()=>e("/m/approvals")})}function JZ({copy:e,busy:t,onAdd:n}){const[r,i]=f.useState(""),s=async a=>{a.preventDefault(),a.stopPropagation();const l=r.trim();!l||t||(await n(l),i(""))};return o.jsxs("form",{onSubmit:s,onClick:a=>a.stopPropagation(),style:{display:"flex",alignItems:"center",gap:8,marginTop:9,border:`1px solid ${m.divider}`,borderRadius:9,padding:"6px 10px"},children:[o.jsx("svg",{width:"10",height:"10",viewBox:"0 0 14 14",fill:"none",stroke:m.muted,strokeWidth:"1.6",children:o.jsx("path",{d:"M9.8 1.8l2.4 2.4L4.6 11.8l-3 .6.6-3z"})}),o.jsx("input",{value:r,onChange:a=>i(a.target.value),placeholder:e.quickPlaceholder,"aria-label":e.quickPlaceholder,style:{flex:1,minWidth:0,border:0,outline:0,background:"transparent",fontSize:11,color:m.ink}})]})}function ZZ({vm:e,copy:t,busy:n,onOpen:r,onAdd:i}){return o.jsx("div",{"data-mobile-notes-card":"",children:o.jsxs(Oe,{tone:"blue",radius:14,padding:"12px 14px",onClick:r,style:{cursor:"pointer"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{fontSize:13.5,fontWeight:650,color:m.ink},children:t.title}),o.jsx("span",{style:{font:`600 10px ${A}`,color:m.sub,background:"var(--proto-line-2)",padding:"2px 8px",borderRadius:999},children:e.activeCount}),o.jsx("span",{style:{marginLeft:"auto",fontSize:13,color:m.faint},children:"›"})]}),e.previews.map(s=>o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,marginTop:5},children:[o.jsx("span",{style:{width:13,height:13,borderRadius:"50%",border:`1.5px solid ${m.hairline}`,boxSizing:"border-box",flex:"none"}}),o.jsx("span",{style:{fontSize:12,lineHeight:1.55,color:m.sub,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.text})]},s.id)),o.jsx(JZ,{copy:t,busy:n,onAdd:i})]})})}function eee({label:e,onClick:t}){return o.jsx("button",{type:"button","aria-label":e,onClick:t,style:{display:"flex",alignItems:"center",justifyContent:"center",width:30,height:30,border:"none",background:"transparent",color:m.sub,cursor:"pointer",padding:0},children:o.jsxs("svg",{width:"19",height:"19",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"12",cy:"12",r:"3.2"}),o.jsx("path",{d:"M19.4 15a1.7 1.7 0 0 0 .34 1.87l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.7 1.7 0 0 0-1.87-.34 1.7 1.7 0 0 0-1 1.55V21a2 2 0 1 1-4 0v-.09a1.7 1.7 0 0 0-1-1.55 1.7 1.7 0 0 0-1.87.34l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.7 1.7 0 0 0 .34-1.87 1.7 1.7 0 0 0-1.55-1H3a2 2 0 1 1 0-4h.09a1.7 1.7 0 0 0 1.55-1 1.7 1.7 0 0 0-.34-1.87l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.7 1.7 0 0 0 1.87.34h.09a1.7 1.7 0 0 0 1-1.55V3a2 2 0 1 1 4 0v.09a1.7 1.7 0 0 0 1 1.55 1.7 1.7 0 0 0 1.87-.34l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.7 1.7 0 0 0-.34 1.87v.09a1.7 1.7 0 0 0 1.55 1H21a2 2 0 1 1 0 4h-.09a1.7 1.7 0 0 0-1.55 1z"})]})})}function tee({current:e,copy:t}){const n=e.cost,r=n?bE(n.today,n.dailyBudget):null;return o.jsxs(Oe,{tone:"blue",radius:14,padding:"13px 14px",style:{boxShadow:"0 1px 3px rgba(70,85,212,.08)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("div",{style:{width:36,height:36,borderRadius:9,background:m.runBg,color:m.run,display:"flex",alignItems:"center",justifyContent:"center",font:`600 12px ${A}`,flex:"none"},children:e.initials}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[o.jsx("span",{style:{fontSize:15,fontWeight:650,color:m.ink},children:e.id}),o.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"1.5px 7px",borderRadius:999,background:m.runBg,color:m.run,flex:"none"},children:t.current})]}),o.jsxs("div",{style:{font:`400 10px ${A}`,color:m.muted,marginTop:2},children:[e.runningThreads," ",t.threadsRunning," · ",e.needsYou," ",t.needsYou]})]})]}),n&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:12},children:[o.jsx("span",{style:{font:`600 20px ${A}`,color:m.ink,letterSpacing:"-.02em"},children:tn(n.today)}),o.jsx("div",{style:{flex:1,height:6,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden"},children:o.jsx("div",{style:{width:`${r??0}%`,height:"100%",background:m.run}})}),o.jsxs("span",{style:{font:`400 10px ${A}`,color:m.faint},children:["/ ",tn(n.dailyBudget)," ",t.perDay]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,marginTop:7,font:`400 10px ${A}`,color:m.faint},children:[o.jsxs("span",{children:[t.week," ",o.jsx("b",{style:{color:m.body},children:tn(n.week)})]}),o.jsxs("span",{children:[t.month," ",o.jsx("b",{style:{color:m.body},children:tn(n.month)})]}),o.jsxs("span",{style:{marginLeft:"auto",color:"var(--proto-amber-text)"},children:[t.forecastToday," ",tn(n.forecastToday)]})]})]})]})}function nee({pending:e,globalPending:t,waitingThreads:n,copy:r,onClick:i}){return o.jsxs("div",{onClick:i,style:{display:"flex",alignItems:"center",gap:8,border:`1px solid ${m.amberBorder}`,background:m.amberCard,borderRadius:13,padding:"12px 13px",cursor:"pointer"},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:m.amber,flex:"none"}}),o.jsxs("span",{style:{fontSize:13,fontWeight:600,color:"var(--proto-amber-fg)"},children:[r.approvals," · ",e," ",r.pending]}),o.jsxs("span",{style:{font:`400 9.5px ${A}`,color:"var(--proto-amber-accent)"},children:[t>0?`${t} ${r.globalPending} · `:"",n," ",r.threadsWaiting]}),o.jsxs("span",{style:{marginLeft:"auto",fontSize:11.5,fontWeight:600,color:m.amberInk},children:[r.handle," ›"]})]})}function ree({issues:e,copy:t,onClick:n}){const r=e.count-e.previews.length;return o.jsxs(Oe,{radius:14,padding:"12px 14px",onClick:n,style:{cursor:"pointer"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{fontSize:13.5,fontWeight:650,color:m.ink},children:t.issuesTitle}),o.jsx("span",{style:{font:`600 10px ${A}`,color:m.sub,background:"var(--proto-line-2)",padding:"2px 8px",borderRadius:999},children:e.count}),o.jsx("span",{style:{marginLeft:"auto",fontSize:13,color:m.faint},children:"›"})]}),e.previews.map(i=>o.jsx("div",{style:{fontSize:12,lineHeight:1.55,color:m.sub,marginTop:4,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i},i)),r>0&&o.jsxs("div",{style:{font:`400 10px ${A}`,color:m.faint,marginTop:7},children:["+ ",r," more"]})]})}function oee({label:e,onClick:t,divider:n}){return o.jsxs("div",{onClick:t,style:{display:"flex",alignItems:"center",gap:9,padding:"11px 13px",borderBottom:n?`1px solid ${m.divider}`:void 0,cursor:"pointer"},children:[o.jsx("span",{style:{fontSize:13,color:m.sub,flex:"none"},children:e}),o.jsx("span",{style:{marginLeft:"auto",fontSize:13,color:m.faint,flex:"none"},children:"›"})]})}function iee({label:e}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"4px 2px 0"},children:[o.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}}),o.jsx("div",{style:{fontSize:9.5,fontWeight:600,letterSpacing:".06em",color:m.faint},children:e}),o.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}})]})}function see({row:e,copy:t,onSwitch:n,divider:r}){const i=e.todayCost!=null?`${t.today} ${tn(e.todayCost)}`:null;return o.jsxs("div",{onClick:()=>n(e.id),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 13px",borderBottom:r?`1px solid ${m.divider}`:void 0,cursor:"pointer"},children:[o.jsx("div",{style:{width:34,height:34,borderRadius:9,background:m.gray,color:m.sub,display:"flex",alignItems:"center",justifyContent:"center",font:`600 12px ${A}`,flex:"none"},children:e.initials}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:14,fontWeight:600,color:m.ink},children:e.id}),o.jsx("div",{style:{display:"flex",alignItems:"center",gap:5,font:`400 10px ${A}`,color:m.muted,marginTop:2},children:e.running>0?o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:m.run,flex:"none"}}),o.jsxs("span",{children:[e.running," ",t.running,i?` · ${i}`:""]})]}):o.jsxs("span",{children:[t.idle,i?` · ${i}`:""]})})]}),e.badgeCount>0&&o.jsx("span",{"aria-label":"project attention",style:{minWidth:18,height:18,padding:"0 6px",borderRadius:999,background:e.badgeTone==="action"?m.amber:m.run,color:"var(--ink-solid-fg)",font:`600 10px ${A}`,display:"flex",alignItems:"center",justifyContent:"center",flex:"none"},children:e.badgeCount}),o.jsx("span",{style:{fontSize:13,color:m.faint,flex:"none"},children:"›"})]})}function aee({props:e}){const{copy:t,current:n,pendingApprovals:r,globalPendingApprovals:i,issues:s}=e;return o.jsxs(o.Fragment,{children:[n&&o.jsx(tee,{current:n,copy:t}),r>0&&o.jsx(nee,{pending:r,globalPending:i,waitingThreads:(n==null?void 0:n.waitingThreads)??0,copy:t,onClick:e.onApprovals}),s.count>0&&o.jsx(ree,{issues:s,copy:t,onClick:e.onIssues}),o.jsx(ZZ,{vm:e.notesVm,copy:e.notesCopy,busy:e.notesBusy,onOpen:e.onNotes,onAdd:e.onAddNote}),o.jsx(Oe,{radius:13,padding:0,style:{overflow:"hidden"},children:o.jsx(oee,{label:t.memory,onClick:e.onMemory,divider:!1})})]})}function lee({props:e}){return e.switchRows.length===0?null:o.jsxs(o.Fragment,{children:[o.jsx(iee,{label:e.copy.switchProject}),o.jsx(Oe,{radius:13,padding:0,style:{overflow:"hidden"},children:e.switchRows.map((t,n)=>o.jsx(see,{row:t,copy:e.copy,onSwitch:e.onSwitch,divider:n<e.switchRows.length-1},t.id))})]})}const cee={display:"flex",alignItems:"center",gap:9,background:"var(--proto-card)",border:`1.5px dashed ${m.runBorder}`,borderRadius:13,padding:13,cursor:"pointer"};function dee({copy:e,onClick:t}){return o.jsxs("div",{onClick:t,style:cee,children:[o.jsx("span",{style:{fontSize:15,color:m.run,fontWeight:400},children:"+"}),o.jsx("span",{style:{fontSize:13.5,fontWeight:600,color:m.run},children:e.newProject})]})}function uee(e){const t=o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},children:[o.jsx(HK,{status:e.rateLimitStatus,onOpen:e.onOpenRateLimit}),o.jsx(eee,{label:e.copy.settings,onClick:e.onSettings})]});return o.jsx(vt,{label:"1e 项目",header:o.jsx(dh,{title:e.copy.title,trailing:t}),children:o.jsxs(En,{gap:10,children:[o.jsx(aee,{props:e}),o.jsx(lee,{props:e}),o.jsx(dee,{copy:e.copy,onClick:e.onNewProject})]})})}const LE=new Set(["running","waiting"]);function pee(e,t){let n=0,r=0;if(!t)return{running:n,waiting:r};for(const i of e)i.projectId===t&&(LE.has(i.status)&&n++,i.status==="waiting"&&r++);return{running:n,waiting:r}}function fee(e){return e.reduce((t,n)=>t+(n.online?1:0),0)}function hee(e){const t={byProject:{},global:0,total:0};for(const n of e)n.status==="pending"&&(t.total++,n.projectId==null?t.global++:t.byProject[n.projectId]=(t.byProject[n.projectId]??0)+1);return t}function gee(e,t,n,r,i={},s={},a={},l={}){const c=e.filter(d=>d.id!==t);return LT(c,s).map(d=>{const u=n.reduce((x,w)=>x+(w.projectId===d.id&&LE.has(w.status)?1:0),0),p=r==null?void 0:r[d.id],h=i[d.id]??0,g=(a[d.id]??0)+(l[d.id]??0),v=IT(h,g);return{id:d.id,initials:Ll(d.id),running:u,todayCost:p?p.today:null,unread:h,actionRequired:g,badgeCount:v.count,badgeTone:v.tone}})}function OE(e){return e.trim().length>0}function xee({name:e,onNameChange:t,onCreate:n,onClose:r,copy:i,behind:s}){const a=OE(e);return o.jsxs(Vr,{onClose:r,behind:s,children:[o.jsxs("div",{style:{display:"flex",alignItems:"baseline",padding:"0 2px 12px"},children:[o.jsx("span",{style:{fontSize:17,fontWeight:700,color:m.ink,letterSpacing:"-.01em"},children:i.title}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${A}`,color:m.faint},children:i.tag})]}),o.jsx("input",{value:e,onChange:l=>t(l.target.value),onKeyDown:l=>{l.key==="Enter"&&a&&n()},placeholder:i.placeholder,autoFocus:!0,style:{width:"100%",height:48,border:"1.5px solid var(--proto-line-3)",borderRadius:13,background:"var(--proto-card)",padding:"0 14px",font:`400 13.5px ${A}`,color:m.ink,boxSizing:"border-box",outline:"none"}}),o.jsx("button",{type:"button",onClick:n,disabled:!a,style:{width:"100%",height:48,border:"none",borderRadius:13,background:m.ink,color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,marginTop:12,opacity:a?1:.45,cursor:a?"pointer":"default"},children:i.create})]})}function DE(e,t,n){const r=vT(e,t,n);return{...r,previews:r.active.slice(0,2)}}const mee={en:{title:"Projects",current:"Current",threadsRunning:"running",needsYou:"need you",perDay:"day",week:"Week",month:"Month",forecastToday:"Forecast",approvals:"Approvals",pending:"pending",globalPending:"global",threadsWaiting:"threads paused",handle:"Review",memory:"Project memory",settings:"Settings",switchProject:"SWITCH PROJECT",running:"running",today:"today",idle:"idle",newProject:"New project",issuesTitle:"Issues"},zh:{title:"项目",current:"当前",threadsRunning:"线程运行中",needsYou:"需要你",perDay:"日",week:"本周",month:"本月",forecastToday:"预测今日",approvals:"审批",pending:"待处理",globalPending:"全局",threadsWaiting:"线程暂停等待",handle:"处理",memory:"项目记忆",settings:"设置",switchProject:"切换项目",running:"运行中",today:"今日",idle:"空闲",newProject:"新建项目",issuesTitle:"Issues"}};function vee(e,t){const n=ae(),r=je(),i=G({...n.notes.list.queryOptions({projectId:e}),enabled:!!e}),s=ue(n.notes.add.mutationOptions({onSettled:()=>r.invalidateQueries(n.notes.list.queryFilter({projectId:e}))}));return{vm:DE(i.data??[],Date.now(),t),copy:py[t],busy:s.isPending,add:a=>s.mutateAsync({projectId:e,text:a})}}const yee={en:{title:"New project",tag:"projects/",placeholder:"Project name, e.g. rl-locomotion",create:"Create and start a chat"},zh:{title:"新建项目",tag:"projects/",placeholder:"项目名字,如 rl-locomotion",create:"创建并开始对话"}};function bee(e){const t=ae();return{projects:G(t.projects.list.queryOptions({})).data??[],sessions:G(t.sessions.list.queryOptions({origin:"direct"})).data??[],scopedCost:G({...t.cost.summary.queryOptions({projectId:e||void 0}),enabled:!!e}).data??null,globalCost:G(t.cost.summary.queryOptions({})).data,threads:G(t.threads.list.queryOptions({})).data??[],approvals:G(t.approvals.list.queryOptions({status:"pending"})).data??[],issues:G({...t.issues.list.queryOptions({projectId:e}),enabled:!!e}).data??[]}}function jee(e,t,n){return f.useMemo(()=>{if(!e)return null;const r=pee(t.threads,e);return{id:e,initials:Ll(e),runningThreads:r.running,waitingThreads:r.waiting,needsYou:n,cost:t.scopedCost}},[e,t.threads,n,t.scopedCost])}function wee(e,t,n){const r=f.useMemo(()=>RT(t.sessions),[t.sessions]),i=f.useMemo(()=>PT(t.sessions),[t.sessions]),s=f.useMemo(()=>MT(t.sessions),[t.sessions]);return f.useMemo(()=>{var a;return gee(t.projects,e,t.threads,(a=t.globalCost)==null?void 0:a.byProject,r,s,i,n)},[t.projects,e,t.threads,t.globalCost,r,s,i,n])}function kee(e,t){const n=ae(),r=je(),[i,s]=f.useState(!1),[a,l]=f.useState(""),c=ue(n.projects.create.mutationOptions({onSuccess:()=>{r.invalidateQueries(n.projects.list.queryFilter()),s(!1),t("/m/session/new")}}));return{open:i,name:a,setName:l,submit:()=>{!OE(a)||c.isPending||c.mutate({name:a.trim()})},close:()=>s(!1),show:()=>{l(""),s(!0)},copy:Lt(e,yee)}}function See({rate:e,rateOpen:t,closeRate:n,project:r}){return o.jsxs(o.Fragment,{children:[t&&e&&o.jsx(QK,{status:e,onClose:n}),r.open&&o.jsx(xee,{name:r.name,onNameChange:r.setName,onCreate:r.submit,onClose:r.close,copy:r.copy})]})}function Cee(){const e=Be(),t=ft(),{currentProjectId:n,setCurrentProject:r}=tr(),i=n??"";gy(),wy();const s=bee(i),a=vee(i,t),l=f.useMemo(()=>hee(s.approvals),[s.approvals]),c=i?l.byProject[i]??0:0,d=jee(i,s,c),u=wee(i,s,l.byProject),p=AT(),[h,g]=f.useState(!1);f.useEffect(()=>{p||g(!1)},[p]);const v=kee(t,e),x=f.useMemo(()=>({count:s.issues.length,previews:s.issues.slice(0,2).map(y=>y.title)}),[s.issues]),w=y=>{r(y),e("/m/sessions")},b={copy:Lt(t,mee),current:d,pendingApprovals:c+l.global,globalPendingApprovals:l.global,issues:x,notesVm:a.vm,notesCopy:a.copy,notesBusy:a.busy,switchRows:u,rateLimitStatus:p,onOpenRateLimit:()=>g(!0),onIssues:()=>e("/m/issues"),onNotes:()=>e("/m/notes"),onAddNote:a.add,onApprovals:()=>e("/m/approvals"),onMemory:()=>e("/m/memory"),onSettings:()=>e("/m/settings"),onSwitch:w,onNewProject:v.show};return o.jsxs(o.Fragment,{children:[o.jsx(uee,{...b}),o.jsx(See,{rate:p,rateOpen:h,closeRate:()=>g(!1),project:v})]})}function Tee({vm:e,copy:t,expandedId:n,busy:r,onBack:i,onExpand:s,onApprove:a,onReject:l}){return o.jsx(vt,{label:"1f 审批",header:o.jsxs(zn,{onBack:i,trailing:o.jsx("span",{style:{font:`400 9.5px ${A}`,color:m.faint},children:"PENDING_APPROVALS.md"}),children:[o.jsx("div",{style:{fontSize:16,fontWeight:650,color:m.ink,letterSpacing:"-.01em",flex:"none"},children:t.title}),o.jsxs(Gt,{tone:"waiting",children:[e.pendingCount," ",t.toProcess]})]}),children:o.jsxs(En,{gap:10,children:[e.cards.length===0&&o.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:m.faint,fontSize:13},children:t.empty}),e.groups.map(c=>o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[o.jsx(Eee,{label:c.projectId??t.globalGroup}),c.cards.map(d=>d.id===n?o.jsx(Ree,{card:d,copy:t,busy:r,onApprove:a,onReject:l},d.id):o.jsx(Pee,{card:d,copy:t,onExpand:s},d.id))]},c.projectId??"__global__"))]})})}function Eee({label:e}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"2px 2px 0"},children:[o.jsx("div",{style:{fontSize:9.5,fontWeight:600,letterSpacing:".06em",color:m.faint},children:e}),o.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}})]})}function AE({copy:e,operation:t}){return o.jsxs("span",{style:{fontSize:10,fontWeight:700,padding:"2px 8px",borderRadius:999,background:m.amberBg,color:m.amberInk,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[e.tier," · ",t]})}function Ree({card:e,copy:t,busy:n,onApprove:r,onReject:i}){return o.jsxs(Oe,{tone:"amber",radius:14,padding:0,style:{overflow:"hidden",boxShadow:"0 1px 3px rgba(16,24,40,.05)"},children:[o.jsxs("div",{style:{padding:"12px 14px 0"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,overflow:"hidden"},children:[e.operation&&o.jsx(AE,{copy:t,operation:e.operation}),o.jsx("span",{style:{font:`400 10px ${A}`,color:"var(--proto-amber-accent)",flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.id}),e.time&&o.jsx("span",{style:{font:`400 10px ${A}`,color:m.faint,flex:"none"},children:e.time})]}),o.jsx("div",{style:{fontSize:14.5,fontWeight:600,color:m.ink,lineHeight:1.4,marginTop:8},children:e.title}),e.reason&&o.jsx("div",{style:{fontSize:12,lineHeight:1.55,color:m.sub,marginTop:4},children:e.reason}),e.impact&&o.jsx("div",{style:{fontSize:12,lineHeight:1.55,color:m.sub,marginTop:4},children:e.impact}),e.command&&o.jsx("div",{style:{marginTop:8,padding:"8px 10px",background:m.amberCard,border:`1px solid ${m.amberBg}`,borderRadius:9,font:`400 10.5px ${A}`,color:"var(--proto-amber-fg)",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:e.command}),o.jsxs("div",{style:{fontSize:12,lineHeight:1.55,color:m.sub,marginTop:4},children:[e.provenance&&o.jsxs(o.Fragment,{children:[t.from," ",o.jsx("span",{style:{font:`400 11px ${A}`,color:m.run},children:e.provenance})," · "]}),t.paused]})]}),o.jsxs("div",{style:{display:"flex",gap:8,padding:"12px 14px 14px"},children:[o.jsx(Gw,{kind:"outline",busy:n,onClick:()=>i(e.id),children:t.reject}),o.jsx(Gw,{kind:"ink",busy:n,onClick:()=>r(e.id),children:t.approve})]})]})}function Gw({kind:e,busy:t,onClick:n,children:r}){const i=e==="ink";return o.jsx("button",{type:"button",disabled:t,onClick:n,style:{flex:1,height:44,borderRadius:11,background:i?m.ink:"var(--proto-card)",color:i?"var(--proto-card)":m.ink,border:i?"none":"1.5px solid var(--proto-line-3)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,boxSizing:"border-box",fontFamily:"inherit",cursor:t?"not-allowed":"pointer",opacity:t?.6:1},children:r})}function Pee({card:e,copy:t,onExpand:n}){const r=[e.id,e.provenance?`${t.from} ${e.provenance}`:null,t.seeDiff].filter(Boolean).join(" · ");return o.jsxs(Oe,{radius:14,padding:"11px 14px",onClick:()=>n(e.id),children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,overflow:"hidden"},children:[e.operation&&o.jsx(AE,{copy:t,operation:e.operation}),o.jsx("span",{style:{fontSize:13,fontWeight:600,color:m.body,flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),e.time&&o.jsx("span",{style:{font:`400 10px ${A}`,color:m.faint,flex:"none"},children:e.time})]}),o.jsx("div",{style:{font:`400 10px ${A}`,color:m.muted,marginTop:5,paddingLeft:2},children:r})]})}function Iee(e,t=Date.now(),n=null){const r=e.filter(c=>c.status==="pending"),i=c=>({id:c.id,projectId:c.projectId,operation:c.operation,title:c.title,time:Br(c.queuedAt,t),reason:c.reason,impact:c.impact,command:c.command,provenance:c.provenance}),s=new Map;for(const c of r){const d=c.projectId??"";s.has(d)||s.set(d,[]),s.get(d).push(i(c))}const l=[...s.keys()].sort((c,d)=>{const u=p=>p===n?0:p===""?1:2;return u(c)-u(d)||c.localeCompare(d)}).map(c=>({projectId:c===""?null:c,cards:s.get(c)}));return{pendingCount:r.length,groups:l,cards:l.flatMap(c=>c.cards)}}const Mee={en:{title:"Approvals",toProcess:"pending",tier:"Approval",from:"from",paused:"thread paused, waiting",approve:"Approve",reject:"Reject with feedback",seeDiff:"tap for diff ›",empty:"No pending approvals",globalGroup:"GLOBAL"},zh:{title:"审批",toProcess:"待处理",tier:"审批",from:"来自",paused:"线程已暂停等待",approve:"批准",reject:"拒绝并反馈",seeDiff:"点开看 diff ›",empty:"没有待处理的审批",globalGroup:"全局"}};function Lee(){const e=ae(),t=Be(),n=je(),r=ft(),i=Lt(r,Mee),{currentProjectId:s}=tr(),a=G(e.approvals.list.queryOptions({status:"pending"})),l=f.useMemo(()=>a.data??[],[a.data]),c=f.useMemo(()=>Iee(l,Date.now(),s),[l,s]),[d,u]=f.useState(null);f.useEffect(()=>{u(x=>{var w;return x&&c.cards.some(b=>b.id===x)?x:((w=c.cards[0])==null?void 0:w.id)??null})},[c.cards]);const p=()=>n.invalidateQueries(e.approvals.list.queryFilter()),h=ue(e.approvals.approve.mutationOptions({onSettled:p})),g=ue(e.approvals.reject.mutationOptions({onSettled:p})),v=h.isPending||g.isPending;return o.jsx(Tee,{vm:c,copy:i,expandedId:d,busy:v,onBack:()=>t("/m/project"),onExpand:u,onApprove:x=>h.mutate({id:x}),onReject:x=>g.mutate({id:x})})}function Oee({vm:e,copy:t,expandedId:n,busy:r,onBack:i,onExpand:s,onDelete:a,onHandle:l}){return o.jsx(vt,{label:"24c Issues",header:o.jsxs(zn,{onBack:i,trailing:o.jsx("span",{style:{font:`400 9.5px ${A}`,color:m.faint},children:"ISSUES.md"}),children:[o.jsx("div",{style:{fontSize:16,fontWeight:650,color:m.ink,letterSpacing:"-.01em",flex:"none"},children:t.title}),e.count>0&&o.jsx("span",{style:{font:`600 10px ${A}`,color:m.sub,background:"var(--proto-line-2)",padding:"2px 8px",borderRadius:999,flex:"none"},children:e.count})]}),children:o.jsxs(En,{gap:10,children:[e.cards.length===0&&o.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:m.faint,fontSize:13},children:t.empty}),e.cards.map(c=>c.id===n?o.jsx(Dee,{card:c,copy:t,busy:r,onDelete:a,onHandle:l},c.id):o.jsx(Aee,{card:c,onExpand:s},c.id)),e.cards.length>0&&o.jsx("div",{style:{marginTop:"auto",display:"flex",alignItems:"center",justifyContent:"center",padding:"10px 0 12px"},children:o.jsx("span",{style:{fontSize:10.5,color:m.faint},children:t.footer})})]})})}function Dee({card:e,copy:t,busy:n,onDelete:r,onHandle:i}){return o.jsxs(Oe,{tone:"blue",radius:14,padding:0,style:{overflow:"hidden",boxShadow:"0 1px 3px rgba(16,24,40,.05)"},children:[o.jsxs("div",{style:{padding:"12px 14px 0"},children:[e.date&&o.jsx("div",{style:{display:"flex",alignItems:"center",gap:7},children:o.jsx("span",{style:{marginLeft:"auto",font:`400 10px ${A}`,color:m.faint},children:e.date})}),o.jsx("div",{style:{fontSize:14.5,fontWeight:600,color:m.ink,lineHeight:1.4,marginTop:e.date?8:0},children:e.title}),e.desc&&o.jsx("div",{style:{fontSize:12,lineHeight:1.55,color:m.sub,marginTop:4,whiteSpace:"pre-wrap"},children:e.desc}),e.fields.map((s,a)=>o.jsxs("div",{style:{fontSize:12,lineHeight:1.55,color:m.sub,marginTop:4,whiteSpace:"pre-wrap"},children:[o.jsx("b",{style:{color:m.body},children:s.label}),":",s.text]},`${s.label}-${a}`))]}),o.jsxs("div",{style:{display:"flex",gap:8,padding:"12px 14px 14px"},children:[o.jsx(Yw,{kind:"danger-outline",busy:n,onClick:()=>r(e.id),width:104,children:t.del}),o.jsx(Yw,{kind:"accent",busy:n,onClick:()=>i(e.id),children:t.handle})]})]})}function Yw({kind:e,busy:t,onClick:n,width:r,children:i}){const s=e==="accent";return o.jsx("button",{type:"button",disabled:t,onClick:n,style:{flex:r?"none":1,width:r,height:44,borderRadius:11,background:s?m.run:"var(--proto-card)",color:s?"var(--ink-solid-fg)":"var(--proto-danger)",border:s?"none":"1.5px solid var(--proto-danger-bg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,boxSizing:"border-box",fontFamily:"inherit",cursor:t?"not-allowed":"pointer",opacity:t?.6:1},children:i})}function Aee({card:e,onExpand:t}){return o.jsx(Oe,{radius:14,padding:"11px 14px",onClick:()=>t(e.id),children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[o.jsx("span",{style:{fontSize:13,fontWeight:600,color:m.body,flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),e.date&&o.jsx("span",{style:{font:`400 10px ${A}`,color:m.faint,flex:"none"},children:e.date})]})})}function Nee(e){const t=e.map(n=>{const r=V3(n.body);return{id:n.id,title:n.title,date:n.date,fields:r.fields,desc:r.desc}});return{count:e.length,cards:t}}const $ee={en:{title:"Issues",del:"Delete",handle:"Handle",empty:"No issues",footer:"Handle = new session carrying this issue · handle / delete removes it"},zh:{title:"Issues",del:"删除",handle:"处理",empty:"没有 issue",footer:"处理 = 新建会话携带此 issue · 处理 / 删除后即离场"}};function _ee(){const e=ae(),t=Be(),n=je(),r=ft(),i=Lt(r,$ee),{currentProjectId:s}=tr(),a=G({...e.issues.list.queryOptions({projectId:s??""}),enabled:!!s}),l=f.useMemo(()=>a.data??[],[a.data]),c=f.useMemo(()=>Nee(l),[l]),[d,u]=f.useState(null);f.useEffect(()=>{u(v=>{var x;return v&&c.cards.some(w=>w.id===v)?v:((x=c.cards[0])==null?void 0:x.id)??null})},[c.cards]);const p=()=>n.invalidateQueries(e.issues.list.queryFilter()),h=ue(e.issues.delete.mutationOptions({onSettled:p})),g=h.isPending;return o.jsx(Oee,{vm:c,copy:i,expandedId:d,busy:g,onBack:()=>t("/m/project"),onExpand:u,onDelete:v=>s&&h.mutate({projectId:s,id:v}),onHandle:v=>{if(!s)return;const x=l.find(y=>y.id===v);if(!x)return;const w=K3(s,x),b=Hd({isDraft:!0,projectId:s});Os(b,{text:w,attachments:[]}),t("/m/session/new"),h.mutate({projectId:s,id:v})}})}const Xw=8;function Fee(e){return Math.max(-78,Math.min(0,e))}function zee(e){return Math.abs(e.deltaX)>Math.abs(e.deltaY)&&e.deltaX<=-48?"delete-open":"closed"}function Bee(e){return Math.abs(e.deltaX)>Xw||Math.abs(e.deltaY)>Xw}function Jw(e,t){return{deltaX:t.clientX-e.x,deltaY:t.clientY-e.y}}function Wee(e,t,n,r){const i=f.useRef(null),s=f.useRef(!1),[a,l]=f.useState(0);return{offset:t?-78:a,onPointerDown:g=>{var v,x;(x=(v=g.currentTarget).setPointerCapture)==null||x.call(v,g.pointerId),s.current=!1,i.current={x:g.clientX,y:g.clientY}},onPointerMove:g=>{if(!i.current)return;const v=Jw(i.current,g);Math.abs(v.deltaX)>Math.abs(v.deltaY)&&l(Fee(v.deltaX))},onPointerUp:g=>{if(!i.current)return;const v=Jw(i.current,g);s.current=Bee(v),zee(v)==="delete-open"?r(e):t||r(null),l(0),i.current=null},onPointerCancel:()=>{s.current=!0,l(0),i.current=null},onClick:()=>{if(s.current){s.current=!1;return}r(null),t||n()}}}function NE({completed:e,busy:t,onClick:n}){return o.jsx("button",{type:"button",disabled:t,onClick:r=>{r.stopPropagation(),n()},style:{width:22,height:22,borderRadius:"50%",border:e?0:`2px solid ${m.hairline}`,background:e?m.done:"transparent",color:"white",padding:0,flex:"none",fontSize:10},children:e?"✓":""})}function Uee({row:e,copy:t,busy:n,onSave:r,onCancel:i}){const[s,a]=f.useState(e.text),l=async()=>{const c=s.trim();!c||n||(await r(c),i())};return o.jsxs("div",{style:{border:`1px solid ${m.runBorder}`,background:m.card,borderRadius:14,padding:13},children:[o.jsx("input",{value:s,onChange:c=>a(c.target.value),autoFocus:!0,style:{width:"100%",boxSizing:"border-box",height:40,borderRadius:10,border:`1.5px solid ${m.hairline}`,padding:"0 12px",fontSize:14}}),o.jsxs("div",{style:{display:"flex",gap:8,marginTop:9},children:[o.jsx("button",{type:"button",disabled:n,onClick:()=>void l(),style:{flex:1,height:40,border:0,borderRadius:10,background:m.run,color:"white",fontSize:13,fontWeight:600},children:t.save}),o.jsx("button",{type:"button",disabled:n,onClick:i,style:{width:76,height:40,border:`1px solid ${m.hairline}`,borderRadius:10,background:m.card,color:m.ink,fontSize:13,fontWeight:600},children:t.cancel})]})]})}function Hee({row:e,copy:t,busy:n,actions:r,onEdit:i}){return o.jsxs("div",{style:{display:"flex",gap:8,marginTop:11},children:[o.jsx("button",{type:"button",disabled:n,onClick:()=>r.onHandoff(e.text),style:{flex:1,height:40,border:0,borderRadius:10,background:m.run,color:"white",fontSize:13,fontWeight:600},children:t.handoff}),o.jsx("button",{type:"button",disabled:n,onClick:i,style:{width:76,height:40,borderRadius:10,border:`1.5px solid ${m.hairline}`,background:m.card,color:m.ink,fontSize:13,fontWeight:600},children:t.edit})]})}function qee({row:e,copy:t,busy:n,actionOpen:r,swipeOpen:i,actions:s,onActions:a,onSwipe:l,onEdit:c}){const{offset:d,...u}=Wee(e.id,i,()=>a(e.id),l);return o.jsxs("div",{"data-note-click":e.id,"data-note-swipe":e.id,style:{borderRadius:14,overflow:"hidden",background:"var(--proto-danger)",position:"relative"},children:[o.jsx("button",{type:"button",disabled:n,onClick:()=>void s.onDelete(e.id),style:{position:"absolute",right:0,top:0,bottom:0,width:78,border:0,background:"var(--proto-danger)",color:"white",fontSize:13,fontWeight:600},children:t.delete}),o.jsxs("div",{...u,style:{transform:`translateX(${d}px)`,transition:d===0||i?"transform 180ms ease":"none",touchAction:"pan-y",border:`1px solid ${r?m.runBorder:m.divider}`,background:m.card,borderRadius:14,padding:"12px 14px",position:"relative"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[o.jsx(NE,{completed:!1,busy:n,onClick:()=>void s.onSetCompleted(e.id,!0)}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:14,fontWeight:600,color:m.ink,lineHeight:1.4},children:e.text}),o.jsx("div",{style:{font:`400 10px ${A}`,color:m.faint,marginTop:4},children:e.timeLabel})]})]}),r&&o.jsx(Hee,{row:e,copy:t,busy:n,actions:s,onEdit:c})]})]})}function Vee({row:e,busy:t,onReopen:n}){return o.jsxs("div",{style:{border:`1px solid ${m.hairline}`,background:m.card,borderRadius:14,padding:"11px 14px",display:"flex",alignItems:"center",gap:10,opacity:.7},children:[o.jsx(NE,{completed:!0,busy:t,onClick:n}),o.jsx("span",{style:{fontSize:14,color:m.muted,textDecoration:"line-through",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.text}),o.jsx("span",{style:{marginLeft:"auto",font:`400 10px ${A}`,color:m.faint,flex:"none"},children:e.timeLabel})]})}function Kee({copy:e,busy:t,onAdd:n}){const[r,i]=f.useState(""),s=async a=>{a.preventDefault();const l=r.trim();!l||t||(await n(l),i(""))};return o.jsxs("form",{"data-notes-fixed-composer":"",onSubmit:s,style:{flex:"none",borderTop:`1px solid ${m.divider}`,background:m.card,display:"flex",alignItems:"center",gap:8,padding:"10px 14px calc(10px + env(safe-area-inset-bottom))"},children:[o.jsxs("div",{style:{flex:1,height:44,borderRadius:12,border:`1.5px solid ${m.hairline}`,background:m.card,display:"flex",alignItems:"center",gap:9,padding:"0 14px",boxSizing:"border-box"},children:[o.jsx("span",{style:{width:16,height:16,borderRadius:"50%",border:`1.5px solid ${m.hairline}`,boxSizing:"border-box"}}),o.jsx("input",{value:r,onChange:a=>i(a.target.value),placeholder:e.inputPlaceholder,"aria-label":e.inputPlaceholder,style:{flex:1,minWidth:0,border:0,outline:0,background:"transparent",fontSize:14,color:m.ink}})]}),o.jsx("button",{type:"submit",disabled:t||!r.trim(),style:{width:44,height:44,borderRadius:12,border:0,background:m.run,color:"white",fontSize:17,opacity:t||!r.trim()?.45:1},children:"↑"})]})}function Qee(e){const[t,n]=f.useState(null),[r,i]=f.useState(null),[s,a]=f.useState(null),[l,c]=f.useState(!0),d=e;return o.jsx(vt,{label:"26c 移动端笔记",header:o.jsxs(zn,{onBack:e.onBack,trailing:o.jsx("span",{style:{font:`400 9.5px ${A}`,color:m.faint},children:"context/NOTES.md"}),children:[o.jsx("span",{style:{fontSize:16,fontWeight:650,color:m.ink},children:e.copy.title}),o.jsx("span",{style:{font:`600 10px ${A}`,color:m.sub,background:m.hairline,padding:"2px 8px",borderRadius:999},children:e.vm.activeCount})]}),footer:o.jsx(Kee,{copy:e.copy,busy:e.busy,onAdd:e.onAdd}),children:o.jsxs(En,{gap:9,children:[e.vm.active.map(u=>s===u.id?o.jsx(Uee,{row:u,copy:e.copy,busy:e.busy,onSave:p=>e.onUpdate(u.id,p),onCancel:()=>a(null)},u.id):o.jsx(qee,{row:u,copy:e.copy,busy:e.busy,actionOpen:t===u.id,swipeOpen:r===u.id,actions:d,onActions:n,onSwipe:i,onEdit:()=>a(u.id)},u.id)),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 4px 0"},children:[o.jsxs("button",{type:"button",onClick:()=>c(u=>!u),style:{border:0,padding:0,background:"transparent",fontSize:10,fontWeight:700,letterSpacing:".06em",color:m.muted},children:[e.copy.completed," · ",e.vm.completedCount," ",l?"▾":"▸"]}),e.vm.completedCount>0&&o.jsx("button",{type:"button",disabled:e.busy,onClick:()=>void e.onClearCompleted(),style:{marginLeft:"auto",border:0,background:"transparent",color:"var(--proto-danger)",fontSize:11,fontWeight:600},children:e.copy.clear})]}),l&&e.vm.completed.map(u=>o.jsx(Vee,{row:u,busy:e.busy,onReopen:()=>void e.onSetCompleted(u.id,!1)},u.id))]})})}function Gee(e){const t=ae(),n=je(),r=()=>n.invalidateQueries(t.notes.list.queryFilter({projectId:e})),i=ue(t.notes.add.mutationOptions({onSettled:r})),s=ue(t.notes.update.mutationOptions({onSettled:r})),a=ue(t.notes.setCompleted.mutationOptions({onSettled:r})),l=ue(t.notes.delete.mutationOptions({onSettled:r})),c=ue(t.notes.clearCompleted.mutationOptions({onSettled:r}));return{busy:i.isPending||s.isPending||a.isPending||l.isPending||c.isPending,add:d=>i.mutateAsync({projectId:e,text:d}),update:(d,u)=>s.mutateAsync({projectId:e,id:d,text:u}),setCompleted:(d,u)=>a.mutateAsync({projectId:e,id:d,completed:u}),remove:d=>l.mutateAsync({projectId:e,id:d}),clearCompleted:()=>c.mutateAsync({projectId:e})}}function Yee(){const e=ae(),t=Be(),n=ft(),{currentProjectId:r}=tr(),i=r??"",s=G({...e.notes.list.queryOptions({projectId:i}),enabled:!!i}),a=Gee(i),l=f.useMemo(()=>DE(s.data??[],Date.now(),n),[s.data,n]);return o.jsx(Qee,{vm:l,copy:py[n],busy:a.busy,onBack:()=>t("/m/project"),onAdd:a.add,onUpdate:a.update,onSetCompleted:a.setCompleted,onDelete:a.remove,onClearCompleted:a.clearCompleted,onHandoff:c=>{U3(i,c),t("/m/session/new")}})}function Xee(){return o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:m.muted,strokeWidth:"1.5",children:[o.jsx("path",{d:"M3 1.5h5.5L11.5 4v8.5h-8.5z"}),o.jsx("path",{d:"M8.5 1.5V4H11"})]})}function Jee({vm:e,copy:t,onBack:n,onMore:r}){const i=$T(e.status);return o.jsxs("div",{style:{flex:"none",padding:"8px 14px 0",paddingTop:"calc(8px + env(safe-area-inset-top))",borderBottom:`1px solid ${m.hairline}`,background:m.canvas},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[o.jsx("button",{type:"button","aria-label":"Back",onClick:n,style:{border:"none",background:"transparent",color:m.run,fontSize:15,lineHeight:1,padding:"0 2px",margin:0,cursor:"pointer",flex:"none",minHeight:34,display:"flex",alignItems:"center"},children:"‹"}),o.jsx("span",{style:{font:`600 15px ${A}`,color:m.ink},children:e.name}),o.jsx(Gt,{tone:i,children:t.status[i]}),o.jsx("div",{style:{marginLeft:"auto",flex:"none"},children:o.jsx(NT,{onClick:r})})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,font:`400 9.5px ${A}`,color:"var(--proto-muted-3)",padding:"6px 0 9px 24px",whiteSpace:"nowrap",overflow:"hidden"},children:[e.crumbs.map((s,a)=>o.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[o.jsx("span",{style:{color:m.run},children:s.name}),o.jsx("span",{children:"›"})]},a)),o.jsx("span",{style:{color:m.ink,fontWeight:600},children:e.name}),o.jsxs("span",{children:[e.selfLevel!=null?` · L${e.selfLevel}`:""," · ",t.depth," ",e.depthText]})]})]})}function Zee({kind:e,hasConnector:t}){return o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[e==="done"&&o.jsx("span",{style:{width:13,height:13,borderRadius:"50%",background:m.doneBg,color:m.done,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:7.5,fontWeight:700,flex:"none"},children:"✓"}),e==="running"&&o.jsx("span",{style:{width:13,height:13,borderRadius:"50%",background:m.run,flex:"none",boxShadow:`0 0 0 3px ${m.runBg}`,animation:"cxpulse 1.6s ease-in-out infinite"}}),e==="pending"&&o.jsx("span",{style:{width:13,height:13,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}}),t&&o.jsx("span",{style:{flex:1,width:1.5,background:"var(--proto-line-2)",margin:"3px 0"}})]})}function ete({agent:e}){return o.jsxs("div",{style:{border:"1px solid var(--proto-accent-bg)",background:"var(--proto-rail)",borderRadius:9,padding:"9px 11px",marginTop:6,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,font:`400 9px ${A}`,color:"var(--proto-muted-3)"},children:[e.live&&o.jsx(ho,{color:m.run,size:5,pulse:!0}),o.jsx("span",{children:e.turnLabel}),e.cost&&o.jsx("span",{style:{marginLeft:"auto"},children:e.cost})]}),e.text&&o.jsx("div",{style:{fontSize:11,lineHeight:1.65,color:m.sub,marginTop:6,overflowWrap:"break-word",wordBreak:"break-word"},children:o.jsx(Ai,{text:e.text})})]})}function tte({step:e,copy:t,selected:n,onSelect:r}){const i=e.kind==="running",s=n&&(e.kind==="done"||e.kind==="running"),a=i?m.ink:e.kind==="done"?m.sub:m.faint,l=e.kind==="pending"?t.pending:e.time,c=e.kind!=="pending";return o.jsxs(o.Fragment,{children:[o.jsx(Zee,{kind:e.kind,hasConnector:e.hasConnector}),o.jsxs("div",{onClick:c?r:void 0,style:{paddingBottom:e.hasConnector?9:4,minWidth:0,cursor:c?"pointer":void 0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"baseline"},children:[o.jsx("span",{style:{fontSize:11.5,fontWeight:i||n?600:500,color:n?m.ink:a},children:e.name}),e.note&&!s&&o.jsx("span",{style:{fontSize:9,color:"var(--proto-muted-3)",marginLeft:6,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0},children:e.note}),l&&o.jsx("span",{style:{marginLeft:"auto",font:`400 9px ${A}`,color:i?m.run:m.faint,flex:"none"},children:l}),c&&o.jsx("span",{style:{color:m.faint,fontSize:8,flex:"none",marginLeft:4,transform:s?"rotate(90deg)":void 0,transition:"transform .15s"},children:"▸"})]}),e.agent&&n&&o.jsx(ete,{agent:e.agent}),e.kind==="done"&&n&&e.sessionId&&o.jsx("div",{style:{border:"1px solid var(--proto-line-2)",background:"var(--proto-rail)",borderRadius:9,padding:"9px 11px",marginTop:6,overflow:"hidden",maxHeight:400,overflowY:"auto",WebkitOverflowScrolling:"touch"},children:o.jsx(R3,{sessionId:e.sessionId,live:!1})})]})]})}function nte({vm:e,copy:t,onArtifactClick:n}){return o.jsxs("div",{style:{background:"var(--proto-card)",border:`1px solid ${m.hairline}`,borderRadius:12,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"9px 13px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{fontSize:12,fontWeight:650,color:m.ink},children:t.artifacts}),o.jsx("span",{style:{font:`400 9.5px ${A}`,color:m.faint,marginLeft:7},children:e.artifactCount})]}),e.artifacts.length===0?o.jsx("div",{style:{padding:"9px 13px",font:`400 10px ${A}`,color:m.faint},children:t.noArtifacts}):e.artifacts.map((r,i)=>o.jsxs("div",{onClick:n?()=>n(r):void 0,style:{display:"flex",alignItems:"center",gap:9,padding:"9px 13px",borderBottom:i<e.artifacts.length-1?"1px solid var(--proto-alt)":void 0,cursor:n?"pointer":void 0},children:[o.jsx(Xee,{}),o.jsx("span",{style:{font:`500 12px ${A}`,color:m.body},children:r.filename}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${A}`,color:m.faint},children:r.meta}),n&&o.jsx("span",{style:{color:m.run,fontSize:8,flex:"none"},children:"▸"})]},i))]})}function rte({vm:e,copy:t,onCancel:n}){return o.jsxs("div",{style:{flex:"none",borderTop:`1px solid ${m.hairline}`,background:"var(--proto-rail)",display:"flex",alignItems:"center",gap:8,padding:"10px 14px 34px",paddingBottom:"calc(14px + env(safe-area-inset-bottom))",minHeight:44,boxSizing:"border-box"},children:[e.live&&o.jsxs(o.Fragment,{children:[o.jsx("div",{title:"Pause has no backend op yet",style:{flex:1,height:44,borderRadius:11,border:"1.5px solid var(--proto-line-3)",background:"var(--proto-card)",color:m.ink,display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,boxSizing:"border-box",cursor:"not-allowed",opacity:.6},children:t.pause}),o.jsx("button",{type:"button","data-cancel-thread-id":e.tid,onClick:n,style:{flex:1,height:44,borderRadius:11,border:"1.5px solid var(--proto-danger-bg)",background:"var(--proto-card)",color:m.fail,display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,boxSizing:"border-box",cursor:"pointer"},children:t.cancel})]}),o.jsxs("span",{style:{font:`500 10.5px ${A}`,color:"var(--proto-muted-3)",flex:"none",marginLeft:"auto",paddingLeft:4},children:["Σ ",e.cost]})]})}function ote({vm:e,copy:t,onBack:n,onMore:r,onCancel:i,onArtifactClick:s}){const a=e.steps.findIndex(p=>p.kind==="running"),l=a>=0?a:e.steps.length-1,[c,d]=f.useState(null),u=c??l;return o.jsx(vt,{label:"1g 线程详情",header:o.jsx(Jee,{vm:e,copy:t,onBack:n,onMore:r}),footer:o.jsx(rte,{vm:e,copy:t,onCancel:i}),children:o.jsxs("div",{style:{padding:"12px 14px 0",display:"flex",flexDirection:"column",gap:10},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,font:`400 10px ${A}`,color:"var(--proto-muted-3)",padding:"0 2px"},children:[o.jsx("span",{children:e.metaParts.join(" · ")}),o.jsx("span",{style:{marginLeft:"auto",color:m.run},children:e.elapsed})]}),o.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${m.hairline}`,borderRadius:12,padding:"11px 13px 7px"},children:o.jsx("div",{style:{display:"grid",gridTemplateColumns:"15px 1fr",columnGap:8},children:e.steps.map((p,h)=>o.jsx(tte,{step:p,copy:t,selected:h===u,onSelect:()=>d(h===u?-1:h)},h))})}),o.jsx(nte,{vm:e,copy:t,onArtifactClick:s}),o.jsx("div",{style:{height:4,flex:"none"}})]})})}const ite=new Set(["running","waiting"]);function Zw(e){return String(e).padStart(2,"0")}function e2(e){const t=Math.max(0,Math.floor(e));return`${Zw(Math.floor(t/60))}:${Zw(t%60)}`}function ste(e){const t=Math.round(e);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;return r===0?`${n}m`:`${n}m ${r}s`}function ate(e){const t=e.split("/").filter(Boolean);return t[t.length-1]??e}function lte(e,t){if(t){const n=W0(e,t).map(r=>r.machine).find(Boolean);if(n)return n}return e.dispatches.map(n=>n.machine).find(Boolean)??null}function cte(e,t,n){const r=ite.has(e.status),i=t.map(x=>({name:x.name,accent:!0})),s=t.length>0?t.length+1:null,a=`${U0(e.children)}/${Ms}`,l=e.steps.find(x=>x.status==="running"),c=lte(e,l),d=[e.id,e.activeAgent?`agent ${e.activeAgent}`:null,c].filter(x=>!!x),u=e.endedAt?Date.parse(e.endedAt):n,p=e2((u-Date.parse(e.createdAt))/1e3),h=e.steps.length-1,g=e.steps.map((x,w)=>{var k,E;const b=x.status==="completed"?"done":x.status==="running"?"running":"pending",y=b==="running";let j="";y?j=x.startedAt?e2((n-Date.parse(x.startedAt))/1e3):"":b==="done"&&x.durationS!=null&&(j=ste(x.durationS));let S;if(y){const C=((k=e.agentFlow)==null?void 0:k.profile)??e.activeAgent??x.agentSlotId,R=((E=e.agentFlow)==null?void 0:E.lastOutput)??x.outputSummary??"";S={turnLabel:x.numTurns!=null?`turn ${x.numTurns} · ${C}`:C,cost:x.costUsd!=null?`$${x.costUsd.toFixed(2)}`:"",lines:R.split(`
|
|
141
|
+
`).map(P=>P.trim()).filter(Boolean),text:R,live:r}}return{kind:b,name:x.stage??`#${x.stepIndex+1}`,note:b==="done"?x.outputSummary??"":"",time:j,hasConnector:w<h,agent:S,sessionId:x.sessionId??null}}),v=[];if(e.artifacts.artifactPath){const x=ate(e.artifacts.artifactPath);v.push({filename:x,meta:Br(e.updatedAt,n),wsRelPath:`workspace/threads/${e.id}/${x}`})}return{name:e.templateName,tid:e.id,status:e.status,live:r,crumbs:i,selfLevel:s,depthText:a,metaParts:d,elapsed:p,cost:`$${e.totalCostUsd.toFixed(2)}`,steps:g,artifacts:v,artifactCount:v.length}}const dte={en:{pause:"Pause",cancel:"Cancel",artifacts:"Artifacts",noArtifacts:"No artifacts",pending:"wait",depth:"depth",status:{running:"Running",waiting:"Waiting",done:"Done",failed:"Failed",cancelled:"Cancelled"}},zh:{pause:"暂停",cancel:"取消",artifacts:"产物",noArtifacts:"暂无产物",pending:"待",depth:"深度",status:{running:"运行中",waiting:"等待",done:"完成",failed:"失败",cancelled:"已取消"}}};function ute(e){const[t,n]=f.useState(()=>Date.now());return f.useEffect(()=>{if(!e)return;const r=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(r)},[e]),t}function pte(){var x;const{threadId:e=""}=Qf(),t=Be(),n=wr(),r=ft(),i=Lt(r,dte),s=(((x=n.state)==null?void 0:x.trail)??[]).filter(w=>w.id!==e),a=ae(),l=je(),c=G(a.threads.get.queryOptions({threadId:e}));Ml(e);const d=c.data?["running","waiting"].includes(c.data.status):!1,u=ute(d),p=ue(a.threads.cancel.mutationOptions({onSettled:()=>{l.invalidateQueries(a.threads.get.queryFilter({threadId:e})),l.invalidateQueries(a.threads.list.queryFilter())},onSuccess:()=>t("/m/threads")})),{openDoc:h}=Wd(),g=f.useCallback(w=>{const b=Bd(w.filename);b&&h({kind:b,name:w.filename,path:w.wsRelPath})},[h]);if(c.isPending)return o.jsx(vt,{label:"1g 线程详情",children:o.jsx("div",{style:{padding:16,color:m.muted,fontSize:13},children:"…"})});if(c.isError)return o.jsx(vt,{label:"1g 线程详情",children:o.jsxs("div",{style:{margin:14,background:m.failBg,border:`1px solid ${m.failBorder}`,borderRadius:10,padding:"10px 14px",fontSize:12.5,color:m.fail},children:[e,": ",c.error.message]})});const v=cte(c.data,s,u);return o.jsx(ote,{vm:v,copy:i,onBack:()=>t(-1),onMore:()=>{},onCancel:()=>p.mutate({threadId:e}),onArtifactClick:g})}const fte={tasksTag:"tasks.json",doneWhen:"DONE-WHEN",doneWhenGap:"done-when 未记录",blockerLabel:"阻塞原因",claimPrefix:"认领",open:"打开 ›",priorityLabel:"优先级",statusLabel:"状态",approvalNeededLabel:"需要审批",approvedAtLabel:"批准时间",completedAtLabel:"完成时间",templateLabel:"模板",depsLabel:"依赖",depsEmpty:"无依赖",historyLabel:"历史",historyEmpty:"暂无派发历史",footer:"只读 — 编辑 / 派发 / 取消在桌面或对话内完成",notFound:"任务未找到",status:{"in-progress":"进行中","approval-needed":"approval-needed",actionable:"可执行",blocked:"阻塞",done:"完成",waiting:"等待"},priority:{high:"P高",medium:"P中",low:"P低"},dispatchStatus:{running:"运行中",completed:"完成",failed:"失败",cancelled:"已取消",stale:"停滞"},dispatchType:{local:"本地",dispatch:"派发"}},hte={tasksTag:"tasks.json",doneWhen:"DONE-WHEN",doneWhenGap:"no done-when recorded",blockerLabel:"Blocked",claimPrefix:"claimed",open:"open ›",priorityLabel:"Priority",statusLabel:"Status",approvalNeededLabel:"Approval needed",approvedAtLabel:"Approved at",completedAtLabel:"Completed at",templateLabel:"Template",depsLabel:"Depends",depsEmpty:"No dependencies",historyLabel:"History",historyEmpty:"No dispatch history",footer:"Read-only — edit / dispatch / cancel on desktop or in chat",notFound:"Task not found",status:{"in-progress":"In progress","approval-needed":"approval-needed",actionable:"Executable",blocked:"Blocked",done:"Done",waiting:"Waiting"},priority:{high:"High",medium:"Med",low:"Low"},dispatchStatus:{running:"running",completed:"completed",failed:"failed",cancelled:"cancelled",stale:"stale"},dispatchType:{local:"local",dispatch:"dispatch"}},gte={"in-progress":"running","approval-needed":"waiting",actionable:"running",blocked:"failed",done:"done",waiting:"waiting"},xte={"in-progress":m.run,"approval-needed":m.amberText,actionable:m.run,blocked:m.fail,done:m.done,waiting:m.amberText};function mte(){return o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:m.run,strokeWidth:"1.6",style:{flex:"none"},children:[o.jsx("circle",{cx:"3.5",cy:"3",r:"1.9"}),o.jsx("circle",{cx:"3.5",cy:"11",r:"1.9"}),o.jsx("circle",{cx:"10.5",cy:"7",r:"1.9"}),o.jsx("path",{d:"M3.5 5v4M5.4 3.7 8.7 6.1M5.4 10.3 8.7 7.9"})]})}const vte={display:"flex",alignItems:"center",gap:9,padding:"10px 13px"};function yte({label:e,reason:t}){return t==null?null:o.jsx("div",{"data-task-blocker-card":"true",children:o.jsxs(Oe,{tone:"fail",style:{background:m.failBg},children:[o.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".07em",color:m.fail},children:e}),o.jsx("div",{style:{font:`400 11px/1.7 ${A}`,color:m.fail,marginTop:6,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:t})]})})}function bte({vm:e,copy:t,onBack:n,onOpenThread:r}){if(!e.found)return o.jsx(vt,{label:"1h 任务详情",header:o.jsx(zn,{onBack:n,children:o.jsx("span",{style:{font:`600 15px ${A}`,color:m.ink},children:"—"})}),children:o.jsx("div",{style:{padding:16,color:m.muted,fontSize:13},children:t.notFound})});const i=o.jsxs(zn,{onBack:n,trailing:o.jsx("span",{style:{font:`400 9.5px ${A}`,color:m.faint},children:t.tasksTag}),children:[o.jsx("span",{style:{font:`600 15px ${A}`,color:m.ink,flex:"none"},children:e.displayId}),o.jsx(Gt,{tone:gte[e.statusKind],children:t.status[e.statusKind]})]}),s=[{key:"priority",node:o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{fontSize:12,color:m.muted,width:62,flex:"none"},children:t.priorityLabel}),o.jsx("span",{style:{fontSize:12,color:m.body,fontWeight:600},children:t.priority[e.priority]})]})},{key:"status",node:o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{fontSize:12,color:m.muted,width:62,flex:"none"},children:t.statusLabel}),o.jsx("span",{style:{font:`500 11px ${A}`,color:m.body},children:e.status})]})},{key:"approval-needed",node:o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{fontSize:12,color:m.muted,width:62,flex:"none"},children:t.approvalNeededLabel}),o.jsx("span",{style:{font:`500 11px ${A}`,color:m.body},children:e.approvalNeeded==null?"—":String(e.approvalNeeded)})]})},{key:"approved-at",node:o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{fontSize:12,color:m.muted,width:62,flex:"none"},children:t.approvedAtLabel}),o.jsx("span",{style:{font:`500 11px ${A}`,color:m.body},children:e.approvedAt??"—"})]})},{key:"completed-at",node:o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{fontSize:12,color:m.muted,width:62,flex:"none"},children:t.completedAtLabel}),o.jsx("span",{style:{font:`500 11px ${A}`,color:e.completedAt?m.done:m.body},children:ah(e.completedAt)??"—"})]})},{key:"template",node:o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{fontSize:12,color:m.muted,width:62,flex:"none"},children:t.templateLabel}),o.jsx("span",{style:{font:`500 11px ${A}`,color:m.body,overflowWrap:"anywhere"},children:e.template})]})},{key:"deps",node:o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{fontSize:12,color:m.muted,width:62,flex:"none"},children:t.depsLabel}),o.jsx("span",{style:{display:"flex",flexDirection:"column",gap:3,minWidth:0},children:e.deps.length===0?o.jsx("span",{style:{fontSize:11,color:m.faint},children:t.depsEmpty}):e.deps.map(a=>o.jsxs("span",{style:{font:`500 11px ${A}`,color:a.known?xte[a.statusKind]:m.faint},children:[a.displayId,a.known?` · ${t.status[a.statusKind]}`:""]},a.id))})]})}];return o.jsx(vt,{label:"1h 任务详情",header:i,children:o.jsxs(En,{gap:10,children:[o.jsx("div",{style:{fontSize:16,fontWeight:650,color:m.ink,lineHeight:1.45,padding:"0 2px"},children:e.text}),o.jsxs(Oe,{children:[o.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".07em",color:m.faint},children:t.doneWhen}),o.jsx("div",{style:{font:`400 11px/1.7 ${A}`,color:e.doneWhen?m.sub:m.faint,marginTop:6,whiteSpace:"pre-wrap"},children:e.doneWhen??t.doneWhenGap})]}),o.jsx(yte,{label:t.blockerLabel,reason:e.blockedBy}),e.claim&&o.jsxs(Oe,{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx(mte,{}),o.jsx("span",{style:{font:`600 12.5px ${A}`,color:m.ink},children:e.claim.template}),o.jsxs("span",{style:{font:`400 9.5px ${A}`,color:m.muted},children:[t.claimPrefix," · ",e.claim.threadId??e.claim.claimedBy]}),e.claim.threadId&&o.jsx("span",{onClick:()=>r(e.claim.threadId),style:{marginLeft:"auto",fontSize:11.5,fontWeight:600,color:m.run,cursor:"pointer",flex:"none"},children:t.open})]}),e.claim.meta&&o.jsx("div",{style:{font:`400 10px ${A}`,color:m.muted,marginTop:4},children:e.claim.meta})]}),o.jsx(Oe,{padding:0,style:{overflow:"hidden"},children:s.map((a,l)=>o.jsx("div",{style:{...vte,borderBottom:l<s.length-1?`1px solid ${m.divider}`:void 0},children:a.node},a.key))}),o.jsxs(Oe,{padding:0,style:{overflow:"hidden"},children:[o.jsx("div",{style:{display:"flex",alignItems:"center",padding:"9px 13px",borderBottom:"1px solid var(--proto-line-2)"},children:o.jsx("span",{style:{fontSize:12,fontWeight:650,color:m.ink},children:t.historyLabel})}),e.history.length===0?o.jsx("div",{style:{padding:"10px 13px",font:`400 10px ${A}`,color:m.faint},children:t.historyEmpty}):o.jsx("div",{style:{padding:"9px 13px",display:"flex",flexDirection:"column",gap:7,font:`400 10px/1.5 ${A}`},children:e.history.map((a,l)=>o.jsx(jte,{h:a,copy:t},l))})]}),o.jsx("div",{style:{font:`400 9.5px ${A}`,color:m.faint,padding:"0 4px"},children:t.footer})]})})}function jte({h:e,copy:t}){const n=Br(e.startedAt),r=`${t.dispatchType[e.type]} · ${t.dispatchStatus[e.status]}`;return o.jsxs("div",{style:{display:"flex",gap:8},children:[o.jsx("span",{style:{color:m.faint,flex:"none"},children:n}),o.jsxs("span",{style:{color:m.sub},children:[r,e.isCompleting?" ✓":""]})]})}function wte(e){if(e==null||!Number.isFinite(e)||e<0)return null;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}const kte=[{kind:"done",matches:e=>e.status==="done"},{kind:"blocked",matches:e=>e.blockedBy!=null},{kind:"in-progress",matches:e=>e.claimedBy!=null},{kind:"approval-needed",matches:e=>e.approvalNeeded===!0},{kind:"actionable",matches:e=>e.actionable}];function $E(e){var t;return((t=kte.find(n=>n.matches(e)))==null?void 0:t.kind)??"waiting"}const Ste={found:!1,displayId:"",text:"",status:"open",template:"",statusKind:"waiting",priority:"medium",approvalNeeded:null,approvedAt:null,completedAt:null,doneWhen:null,blockedBy:null,claim:null,deps:[],history:[]};function Cte(e,t){if(e.claimedBy==null)return null;const n=t[0]??null,r=[],i=wte((n==null?void 0:n.durationMs)??null);return i&&r.push(i),(n==null?void 0:n.cost)!=null&&r.push(ud(n.cost)),{template:e.template,threadId:qd(e),claimedBy:null,meta:r.length>0?r.join(" · "):null}}function Tte(e,t){return e.dependsOn.map(n=>{const r=t.get(n);return{id:n,displayId:`T-${n}`,statusKind:r?$E(r):"waiting",known:r!=null}})}function Ete(e,t){return e.map(n=>({startedAt:n.startedAt,type:n.type,status:n.status,isCompleting:t!=null&&n.executionId===t}))}function Rte(e,t,n,r=Date.now()){const i=new Map(t.map(c=>[c.id,c])),s=i.get(e);if(!s)return Ste;const a=(n==null?void 0:n.dispatches)??[],l=(n==null?void 0:n.evidence.completingExecutionId)??null;return{found:!0,displayId:`T-${s.id}`,text:s.text,status:s.status,template:s.template,statusKind:$E(s),priority:s.priority,approvalNeeded:s.approvalNeeded??null,approvedAt:s.approvedAt??null,completedAt:s.completedAt??(n==null?void 0:n.evidence.completedAt)??null,doneWhen:s.doneWhen,blockedBy:s.blockedBy??null,claim:Cte(s,a),deps:Tte(s,i),history:Ete(a,l)}}function Pte(){const e=ae(),t=Be(),r=ft()==="zh"?fte:hte,{taskId:i}=Qf(),{currentProjectId:s}=tr();by();const a=G(e.tasks.list.queryOptions({projectId:s??void 0})),l=G({...e.tasks.verification.queryOptions({projectId:s??"",taskId:i??""}),enabled:!!s&&!!i}),c=a.data??[],d=f.useMemo(()=>Rte(i??"",c,l.data??null),[i,c,l.data]);return a.isLoading?o.jsx(vt,{label:"1h 任务详情",children:o.jsx("div",{style:{padding:16,color:m.muted,fontSize:13},children:r.notFound})}):o.jsx(bte,{vm:d,copy:r,onBack:()=>t(-1),onOpenThread:u=>t(`/m/thread/${u}`)})}function Ite(){return o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:m.muted,strokeWidth:"1.5",style:{flex:"none"},children:[o.jsx("path",{d:"M3 1.5h5.5L11.5 4v8.5h-8.5z"}),o.jsx("path",{d:"M8.5 1.5V4H11"})]})}function _E({open:e=!1,color:t=m.faint}){return o.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:t,strokeWidth:"1.6",style:{flex:"none",transform:e?"rotate(90deg)":"none",transition:"transform .15s ease"},children:o.jsx("path",{d:"M3.5 1.5 7 5 3.5 8.5"})})}function FE({row:e,last:t,onOpen:n}){return o.jsxs("div",{role:"button",onClick:()=>n(e.path),style:{display:"flex",alignItems:"center",gap:9,padding:"10px 13px",borderBottom:t?void 0:"1px solid var(--proto-alt)",cursor:"pointer"},children:[o.jsx(Ite,{}),o.jsx("span",{style:{font:`500 12px ${A}`,color:m.body,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${A}`,color:m.faint,flex:"none"},children:e.time}),o.jsx(_E,{color:m.faint})]})}function zE({children:e}){return o.jsx(Oe,{tone:"default",padding:0,style:{overflow:"hidden"},children:e})}function Mte({dir:e,copy:t,open:n,onToggle:r,onOpen:i}){return o.jsxs(zE,{children:[o.jsxs("div",{role:"button","aria-expanded":n,onClick:()=>r(e.name),style:{display:"flex",alignItems:"center",padding:"9px 13px",borderBottom:n?"1px solid var(--proto-line-2)":void 0,cursor:"pointer"},children:[o.jsxs("span",{style:{fontSize:12,fontWeight:650,color:m.ink},children:[e.name,"/"]}),o.jsx("span",{style:{font:`400 9.5px ${A}`,color:m.faint,marginLeft:7},children:e.entryCount}),o.jsx("span",{style:{marginLeft:"auto",flex:"none"},children:o.jsx(_E,{open:n})})]}),n&&(e.entries.length===0?o.jsx("div",{style:{padding:"10px 13px",font:`400 11px ${A}`,color:m.faint},children:t.emptyDir}):e.entries.map((s,a)=>o.jsx(FE,{row:s,last:a===e.entries.length-1,onOpen:i},s.path)))]})}function Lte({vm:e,copy:t,openDirs:n,onToggleDir:r,onBack:i,onOpenFile:s}){return o.jsxs(o.Fragment,{children:[o.jsx(zn,{onBack:i,trailing:o.jsxs("span",{style:{font:`400 9.5px ${A}`,color:m.faint},children:["memory/ · ",e.fileCount," ",t.filesUnit]}),children:o.jsx("div",{style:{fontSize:16,fontWeight:650,color:m.ink,letterSpacing:"-.01em"},children:t.title})}),o.jsx(En,{gap:10,children:e.isEmpty?o.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:m.faint,fontSize:13},children:t.empty}):o.jsxs(o.Fragment,{children:[e.core.length>0&&o.jsxs(zE,{children:[o.jsx("div",{style:{display:"flex",alignItems:"center",padding:"9px 13px",borderBottom:"1px solid var(--proto-line-2)"},children:o.jsx("span",{style:{fontSize:12,fontWeight:650,color:m.ink},children:t.core})}),e.core.map((a,l)=>o.jsx(FE,{row:a,last:l===e.core.length-1,onOpen:s},a.path))]}),e.dirs.map(a=>o.jsx(Mte,{dir:a,copy:t,open:n.has(a.name),onToggle:r,onOpen:s},a.name)),o.jsx("div",{style:{font:`400 9.5px ${A}`,color:m.faint,padding:"0 4px"},children:t.footer})]})})]})}function Ote(e,t=Date.now()){const n=(e==null?void 0:e.files)??[],r=(e==null?void 0:e.dirs)??[],i=n.map(l=>({name:l.name,path:l.name,time:Br(l.modifiedAt,t)})),s=r.map(l=>({name:l.name,entryCount:l.entryCount,entries:(l.entries??[]).map(c=>({name:c.name,path:`${l.name}/${c.name}`,time:Br(c.modifiedAt,t)}))}));return{fileCount:n.length+r.reduce((l,c)=>l+c.entryCount,0),core:i,dirs:s,isEmpty:i.length===0&&s.length===0}}const Dte={en:{title:"Project memory",core:"Core",filesUnit:"files",emptyDir:"Empty",footer:"Tap a file for a read-only preview · agent writes to behavioral content (rules/skills) go through approval",empty:"No project memory yet"},zh:{title:"项目记忆",core:"核心",filesUnit:"个文件",emptyDir:"空",footer:"点文件只读预览 · agent 写入行为性内容(规则/技能)走审批",empty:"暂无项目记忆"}};function Ate(){const e=ae(),t=Be(),n=ft(),r=Lt(n,Dte),i=Date.now(),{currentProjectId:s}=tr(),a=G({...e.memory.tree.queryOptions({projectId:s??""}),enabled:!!s}),l=f.useMemo(()=>Ote(a.data,i),[a.data,i]),[c,d]=f.useState(()=>new Set),u=f.useCallback(p=>{d(h=>{const g=new Set(h);return g.has(p)?g.delete(p):g.add(p),g})},[]);return o.jsx(vt,{label:"1j 项目记忆",children:a.isLoading?o.jsx("div",{style:{padding:16,color:m.muted,fontSize:13},children:r.empty}):o.jsx(Lte,{vm:l,copy:r,openDirs:c,onToggleDir:u,onBack:()=>t("/m/project"),onOpenFile:p=>t(`/m/memory/file?path=${encodeURIComponent(p)}`)})})}function Nte({basename:e,metaLine:t,content:n,status:r,copy:i,onBack:s}){return o.jsxs("div",{"data-screen-label":"1j 项目记忆 · 文件",style:{height:"100%",display:"flex",flexDirection:"column",boxSizing:"border-box",background:m.canvas},children:[o.jsx(zn,{onBack:s,children:o.jsxs("div",{style:{minWidth:0},children:[o.jsx("div",{style:{font:`600 14px ${A}`,color:m.ink,letterSpacing:"-.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e}),t&&o.jsx("div",{style:{font:`400 10px ${A}`,color:m.faint,marginTop:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t})]})}),o.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",background:"var(--proto-card)"},children:[r==="loading"&&o.jsx("div",{style:{padding:16,font:`400 12px ${A}`,color:m.faint},children:i.loading}),r==="error"&&o.jsx("div",{style:{padding:16,fontSize:12.5,color:m.fail},children:i.error}),r==="empty"&&o.jsx("div",{style:{padding:16,font:`400 12px ${A}`,color:m.faint},children:i.empty}),r==="ready"&&o.jsx("div",{style:{padding:"16px 18px calc(28px + env(safe-area-inset-bottom))",fontSize:13,lineHeight:1.7,color:m.body},children:o.jsx(Ai,{text:n})})]})]})}function $te(e){const t=e.split("/").filter(Boolean);return t.length?t[t.length-1]:e}function _te(e){if(e==null||!Number.isFinite(e)||e<0)return"";if(e<1024)return`${e} B`;const t=e/1024;return t<1024?`${t2(t)} KB`:`${t2(t/1024)} MB`}function t2(e){const t=e.toFixed(1);return t.endsWith(".0")?t.slice(0,-2):t}function Fte(e,t=Date.now()){if(!e)return"";const n=Br(e.modifiedAt,t),r=_te(e.sizeBytes);return[e.path,n,r].filter(i=>i&&i.length>0).join(" · ")}const zte={en:{loading:"Loading file…",error:"Couldn't read this file",empty:"(empty file)"},zh:{loading:"正在加载文件…",error:"无法读取该文件",empty:"(空文件)"}};function Bte(){const e=ae(),t=Be(),n=ft(),r=Lt(n,zte),i=Date.now(),[s]=O$(),a=s.get("path")??"",{currentProjectId:l}=tr(),c=G({...e.memory.file.queryOptions({projectId:l??"",path:a}),enabled:!!l&&!!a}),d=c.data,u=$te(a),p=f.useMemo(()=>Fte(d,i),[d,i]),h=!a||c.isError?"error":c.isLoading||!d?"loading":d.content.length===0?"empty":"ready";return o.jsx(Nte,{basename:u,metaLine:p,content:(d==null?void 0:d.content)??"",status:h,copy:r,onBack:()=>t("/m/memory")})}const Fr={font:`400 9.5px ${A}`,color:m.muted};function Wte({vm:e,copy:t}){return o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5,fontSize:10,fontWeight:600,color:m.done},children:[o.jsx(ho,{color:m.done,size:6}),t.daemon," · ",e.onlineCount,"/",e.total," ",t.onlineWord]})}function Ute(e){return e>=90?m.fail:e>=75?m.amber:m.run}function BE({percent:e,width:t=40}){return o.jsx("span",{style:{width:t,height:4,borderRadius:2,background:m.divider,overflow:"hidden",flexShrink:0},children:o.jsx("span",{style:{display:"block",width:`${e}%`,height:"100%",background:Ute(e)}})})}function Hte({gpu:e}){return o.jsxs("div",{style:{marginTop:6},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,...Fr},children:[o.jsx("span",{style:{color:m.body,fontWeight:600},children:e.index}),o.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),o.jsx(BE,{percent:e.utilPercent}),o.jsx("span",{style:{color:m.sub},children:e.utilText})]}),o.jsxs("div",{style:{...Fr,color:m.faint,paddingLeft:14,marginTop:2},children:[e.memText," · ",e.tempText," · ",e.powerText,e.owners.length>0&&o.jsxs("span",{style:{color:m.run},children:[" · ",e.owners.join(" ")]})]}),e.processes.length>0&&o.jsxs("div",{style:{...Fr,color:m.faint,paddingLeft:14,marginTop:2},children:[e.processes.map(t=>`${t.name} ${t.memText}`).join(" · "),e.hiddenProcessCount>0&&` +${e.hiddenProcessCount}`]})]})}function qte({run:e}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,...Fr,marginTop:5},children:[o.jsx(ho,{color:m.run,size:5,pulse:!0}),o.jsx("span",{style:{color:m.body,fontWeight:600},children:e.label}),e.gpuText&&o.jsx("span",{style:{color:m.sub},children:e.gpuText}),e.duration&&o.jsx("span",{style:{marginLeft:"auto",color:m.faint},children:e.duration})]})}function Ta({text:e,tone:t}){return o.jsx("div",{style:{...Fr,color:t==="fail"?m.fail:m.faint,marginTop:6},children:e})}function WE({card:e,copy:t,uptime:n}){const r=[];return e.connectedFor&&r.push(`${t.up} ${e.connectedFor}`),n&&r.push(`${t.uptime} ${n}`),e.sshConfigured&&r.push("ssh ✓"),e.capabilities.length>0&&r.push(e.capabilities.join(",")),o.jsxs("div",{style:{marginTop:8,paddingTop:7,borderTop:`1px solid ${m.divider}`},children:[o.jsx("div",{style:{...Fr,color:m.faint},children:r.join(" · ")}),e.cortexPath&&o.jsxs("div",{style:{...Fr,color:m.faint,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[t.path," ",e.cortexPath]})]})}function Vte({panel:e,copy:t}){if(e.status==="probing")return o.jsx(Ta,{text:t.probing});if(e.status==="error"||!e.vm)return o.jsx(Ta,{text:t.probeFailed,tone:"fail"});const{meters:n,gpus:r,liveRuns:i,probeError:s}=e.vm;return o.jsxs(o.Fragment,{children:[s&&o.jsx(Ta,{text:`${t.probeFailed}: ${s}`,tone:"fail"}),n.length>0&&o.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap",marginTop:6},children:n.map(a=>o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,...Fr},children:[o.jsx("span",{style:{color:m.faint},children:a.label}),o.jsx(BE,{percent:a.percent,width:30}),o.jsx("span",{children:a.text})]},a.key))}),r.map(a=>o.jsx(Hte,{gpu:a},a.index)),!s&&r.length===0&&o.jsx(Ta,{text:t.noGpu}),i.map(a=>o.jsx(qte,{run:a},a.key))]})}function Kte({card:e,copy:t,expanded:n,panel:r,onToggle:i}){return o.jsx(Oe,{tone:"default",padding:0,style:{overflow:"hidden"},children:o.jsxs("div",{role:"button","aria-expanded":n,onClick:()=>i(e.name),style:{padding:"11px 13px 9px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{font:`600 12.5px ${A}`,color:m.ink},children:e.name}),o.jsx("span",{style:{font:`400 9.5px ${A}`,color:m.faint},children:e.os}),o.jsx("span",{style:{marginLeft:"auto",flex:"none"},children:o.jsx(Gt,{tone:"done",children:t.online})})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,...Fr,marginTop:4},children:[o.jsxs("span",{children:[t.hb," ",e.heartbeat,e.gpuCount!==null&&e.gpuCount>0&&` · ${e.gpuCount} ${t.gpu}`,e.liveRuns>0&&` · ${e.liveRuns} ${t.running}`]}),e.liveRuns>0&&o.jsx("span",{style:{marginLeft:"auto",display:"inline-flex"},children:o.jsx(ho,{color:m.run,size:6,pulse:!0})})]}),n&&o.jsxs(o.Fragment,{children:[r?o.jsx(Vte,{panel:r,copy:t}):o.jsx(Ta,{text:t.probing}),o.jsx(WE,{card:e,copy:t,uptime:(r==null?void 0:r.uptime)??""})]})]})})}function n2({children:e,onClick:t}){return o.jsx("button",{type:"button",onClick:t,style:{flex:1,height:38,borderRadius:10,border:"1.5px solid var(--proto-line-3)",background:"var(--proto-card)",color:m.ink,fontSize:12.5,fontWeight:600,boxSizing:"border-box",cursor:"pointer"},children:e})}function Qte({card:e,copy:t,expanded:n,onToggle:r,onRetry:i,onLogs:s}){return o.jsxs(Oe,{tone:"fail",padding:"11px 13px",children:[o.jsxs("div",{role:"button","aria-expanded":n,onClick:()=>r(e.name),children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{font:`600 12.5px ${A}`,color:m.sub},children:e.name}),o.jsx("span",{style:{font:`400 9.5px ${A}`,color:m.faint},children:e.os}),o.jsx("span",{style:{marginLeft:"auto",flex:"none"},children:o.jsx(Gt,{tone:"failed",children:t.offline})})]}),o.jsxs("div",{style:{...Fr,marginTop:4},children:[t.lastHb," ",e.heartbeat]}),n&&o.jsxs(o.Fragment,{children:[o.jsx(Ta,{text:t.offlineNoTelemetry}),o.jsx(WE,{card:e,copy:t,uptime:""})]})]}),o.jsxs("div",{style:{display:"flex",gap:8,marginTop:10},children:[o.jsx(n2,{onClick:i?()=>i(e.name):void 0,children:t.retry}),o.jsx(n2,{onClick:s?()=>s(e.name):void 0,children:t.logs})]})]})}function Gte({vm:e,copy:t}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"2px 4px",font:`400 9.5px ${A}`,color:m.faint},children:[o.jsxs("span",{children:["machines.json · ",e.total," ",t.registered]}),o.jsx("span",{style:{marginLeft:"auto",color:m.muted},children:t.editDesktop})]})}function Yte({vm:e,copy:t,onBack:n,expanded:r,onToggle:i,panel:s,onRetry:a,onLogs:l}){return o.jsxs(o.Fragment,{children:[o.jsx(zn,{onBack:n,trailing:o.jsx(Wte,{vm:e,copy:t}),children:o.jsx("div",{style:{fontSize:16,fontWeight:650,color:m.ink,letterSpacing:"-.01em"},children:t.title})}),o.jsxs(En,{gap:10,children:[e.cards.length===0&&o.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:m.faint,fontSize:13},children:t.empty}),e.cards.map(c=>c.online?o.jsx(Kte,{card:c,copy:t,expanded:r===c.name,panel:r===c.name?s:null,onToggle:i},c.name):o.jsx(Qte,{card:c,copy:t,expanded:r===c.name,onToggle:i,onRetry:a,onLogs:l},c.name)),e.cards.length>0&&o.jsx(Gte,{vm:e,copy:t})]})]})}function Xte(e,t){if(!e)return"—";const n=Date.parse(e);if(Number.isNaN(n))return"—";const r=t-n;if(r<0)return"—";const i=Math.floor(r/1e3);if(i<60)return`${i}s 前`;const s=Math.floor(i/60);if(s<60)return`${s}m 前`;const a=Math.floor(s/60);return a<24?`${a}h 前`:`${Math.floor(a/24)}d 前`}function Jte(e){return{name:e.name,online:e.online,liveRuns:e.liveRuns,gpuCount:e.gpuCount,os:e.os,connectedAt:e.online?e.connectedAt:null}}function Zte(e,t=Date.now()){const n=e.map(r=>{const i=Jte(r);return{name:i.name,online:i.online,os:i.os,gpuCount:i.gpuCount,liveRuns:i.liveRuns,heartbeat:Xte(r.lastHeartbeat,t),connectedFor:lf(r.connectedAt,t),capabilities:r.capabilities,cortexPath:r.cortexPath,sshConfigured:r.sshConfigured}});return{cards:n,onlineCount:n.filter(r=>r.online).length,total:n.length}}const ene=1e4,tne=5e3,nne={en:{title:"Machines",online:"Online",offline:"Offline",hb:"HB",lastHb:"last HB",gpu:"GPU",running:"running",daemon:"daemon",onlineWord:"online",retry:"Retry",logs:"Logs",registered:"registered",editDesktop:"edit on desktop",empty:"No machines",probing:"Probing…",probeFailed:"Probe failed",noGpu:"No GPU reported",offlineNoTelemetry:"Offline — no live telemetry",up:"up",uptime:"uptime",path:"path"},zh:{title:"机器",online:"在线",offline:"离线",hb:"心跳",lastHb:"上次心跳",gpu:"GPU",running:"运行中",daemon:"daemon",onlineWord:"在线",retry:"重试连接",logs:"查看日志",registered:"台注册",editDesktop:"编辑走桌面设置",empty:"暂无机器",probing:"探测中…",probeFailed:"探测失败",noGpu:"未检测到 GPU",offlineNoTelemetry:"离线 — 无实时数据",up:"已连接",uptime:"运行时长",path:"路径"}};function rne(){const e=ae(),t=Be(),n=ft(),r=Lt(n,nne),i=Date.now(),[s,a]=f.useState(null),l=G({...e.machines.list.queryOptions({}),refetchInterval:ene}),c=f.useMemo(()=>l.data??[],[l.data]),d=f.useMemo(()=>Zte(c,i),[c,i]),u=c.some(g=>g.name===s&&g.online),p=G({...e.machines.detail.queryOptions({machine:s??""}),enabled:u,refetchInterval:u?tne:!1}),h=f.useMemo(()=>{var g;return u?p.isError?{status:"error",vm:null,uptime:""}:p.data?{status:"ready",vm:hE(p.data,i),uptime:pE(((g=p.data.vitals)==null?void 0:g.uptimeSec)??null)}:{status:"probing",vm:null,uptime:""}:null},[u,p.isError,p.data,i]);return o.jsx(vt,{label:"1k 机器",children:l.isLoading?o.jsx("div",{style:{padding:16,color:m.muted,fontSize:13},children:r.empty}):o.jsx(Yte,{vm:d,copy:r,onBack:()=>t("/m/settings"),expanded:s,onToggle:g=>a(v=>v===g?null:g),panel:h})})}function one({copy:e}){return o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5,fontSize:10,color:m.done,fontWeight:600},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:m.done}}),e.daemonStatus]})}function Uu({children:e,opacity:t}){return o.jsx("div",{style:{background:m.card,border:`1px solid ${m.hairline}`,borderRadius:13,overflow:"hidden",opacity:t},children:e})}function Vn(e){return{display:"flex",alignItems:"center",gap:10,padding:"12px 13px",borderBottom:e?`1px solid ${m.divider}`:void 0}}const Fo={fontSize:14,fontWeight:600,color:m.ink},Hu={font:`400 10px ${A}`,color:m.muted,marginTop:2},Zi={fontSize:13,color:m.faint,flex:"none"};function r2({on:e,label:t}){return o.jsx("div",{role:"switch","aria-checked":e,"aria-readonly":!0,"aria-label":t,title:"Reflects the real env flag — read-only (no config.set for .env)",style:{width:44,height:26,borderRadius:999,background:e?m.done:"var(--proto-line-3)",position:"relative",flex:"none",cursor:"default"},children:o.jsx("span",{style:{position:"absolute",top:2,[e?"right":"left"]:2,width:22,height:22,borderRadius:"50%",background:"var(--ink-solid-bg)",boxShadow:"0 1px 3px rgba(16,24,40,.2)"}})})}function Um({children:e}){return o.jsx("span",{style:{marginLeft:"auto",fontSize:9.5,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:m.gray,color:m.grayInk,flex:"none"},children:e})}function UE({value:e,options:t,onChange:n,ariaLabel:r}){return o.jsx("div",{role:"group","aria-label":r,style:{display:"flex",border:`1px solid ${m.hairline}`,borderRadius:6,overflow:"hidden",flex:"none"},children:t.map(i=>{const s=e===i.id;return o.jsx("span",{role:"button","aria-pressed":s,onClick:()=>n(i.id),style:{fontSize:11,fontWeight:600,padding:"3px 10px",cursor:"pointer",background:s?"var(--ink-solid-bg)":"transparent",color:s?"var(--ink-solid-fg)":m.muted},children:i.label},i.id)})})}function ine({lang:e,onSetLang:t}){return o.jsx(UE,{ariaLabel:"Language",value:e,options:[{id:"en",label:"EN"},{id:"zh",label:"中"}],onChange:t})}function sne({theme:e,onSetTheme:t,lightLabel:n,darkLabel:r}){return o.jsx(UE,{ariaLabel:"Theme",value:e,options:[{id:"light",label:n},{id:"dark",label:r}],onChange:t})}function ane({vm:e,copy:t,onOpenHooks:n}){return o.jsxs("div",{role:"button","aria-label":t.hooks,onClick:n,style:{...Vn(!1),gap:9,cursor:"pointer"},children:[o.jsxs("span",{style:{fontSize:13,color:m.sub},children:[t.hooks," · ",e.hooks.length]}),o.jsx(Um,{children:t.desktopEdit}),o.jsx("span",{style:Zi,children:"›"})]})}function lne({vm:e,copy:t,lang:n,onSetLang:r,theme:i,onSetTheme:s,onBack:a,onOpenDaemon:l,onlineMachines:c,onOpenMachines:d,onOpenHooks:u,accountsSummary:p,onOpenAccounts:h,profileSheet:g,onOpenProfile:v,onCloseProfile:x,onPickProfile:w}){const b=B(),y=[e.profileName,e.profileModel,e.profileThinking].filter(Boolean).join(" · "),j=t.platform+(e.platforms.length?`(${e.platforms.join(", ")})`:"");return o.jsxs(vt,{label:"1l 设置",header:o.jsx(zn,{onBack:a,trailing:o.jsx(one,{copy:t}),children:o.jsx("div",{style:{fontSize:16,fontWeight:650,color:m.ink,letterSpacing:"-.01em"},children:t.title})}),children:[o.jsxs(En,{gap:10,children:[o.jsxs(Uu,{children:[o.jsxs("div",{style:Vn(!0),onClick:l,children:[o.jsx("div",{style:{width:34,height:34,borderRadius:9,background:m.doneBg,display:"flex",alignItems:"center",justifyContent:"center",flex:"none"},children:o.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:m.done}})}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:Fo,children:t.daemon}),e.daemonHost&&o.jsx("div",{style:Hu,children:e.daemonHost})]}),o.jsx("span",{style:{...Zi,cursor:"pointer"},children:"›"})]}),o.jsxs("div",{role:"button","aria-label":t.machines,onClick:d,style:{...Vn(!0),gap:9,cursor:"pointer"},children:[o.jsxs("span",{style:{fontSize:13,color:m.sub},children:[t.machines," · ",c," ",t.machinesOk]}),o.jsx("span",{style:{marginLeft:"auto",...Zi},children:"›"})]}),o.jsxs("div",{style:Vn(!1),children:[o.jsx("div",{style:{width:34,height:34,borderRadius:9,background:m.runBg,color:m.run,display:"flex",alignItems:"center",justifyContent:"center",font:`600 11px ${A}`,flex:"none"},children:"P"}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:Fo,children:t.profileTitle}),y&&o.jsx("div",{style:Hu,children:y})]}),o.jsx("span",{role:"button",onClick:v,style:{font:`500 10px ${A}`,color:m.run,flex:"none",cursor:"pointer"},children:t.switchLabel})]})]}),o.jsxs(Uu,{children:[o.jsxs("div",{style:{...Vn(!0),gap:0},children:[o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:Fo,children:t.budget}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:6},children:[o.jsx("div",{style:{flex:1,height:5,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden"},children:o.jsx("div",{style:{width:e.budgetBarPct,height:"100%",background:m.run}})}),o.jsxs("span",{style:{font:`500 10px ${A}`,color:m.ink,flex:"none"},children:[e.budgetSpendLabel," ",t.budgetUnit]})]})]}),o.jsx("span",{style:{...Zi,paddingLeft:10},children:"›"})]}),o.jsxs("div",{style:Vn(!0),children:[o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:Fo,children:t.notify}),o.jsx("div",{style:Hu,children:t.notifySub})]}),o.jsx(r2,{on:e.notifyOn,label:t.notify})]}),o.jsxs("div",{style:Vn(!0),children:[o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:Fo,children:t.autoResume}),o.jsx("div",{style:Hu,children:t.autoResumeSub})]}),o.jsx(r2,{on:e.autoResumeOn,label:t.autoResume})]}),o.jsxs("div",{style:Vn(!0),children:[o.jsx("div",{style:{minWidth:0,flex:1},children:o.jsx("div",{style:Fo,children:t.language})}),o.jsx(ine,{lang:n,onSetLang:r})]}),o.jsxs("div",{style:Vn(!1),children:[o.jsx("div",{style:{minWidth:0,flex:1},children:o.jsx("div",{style:Fo,children:t.theme})}),o.jsx(sne,{theme:i,onSetTheme:s,lightLabel:t.themeLight,darkLabel:t.themeDark})]})]}),o.jsx(Uu,{children:o.jsxs("button",{type:"button","data-accounts-entry":"mobile","aria-label":b.accountsTitle,onClick:h,style:{...Vn(!1),cursor:"pointer",width:"100%",border:0,background:"transparent",textAlign:"left",font:"inherit"},children:[o.jsx("div",{style:{minWidth:0,flex:1},children:o.jsxs("div",{style:Fo,children:[b.accountsTitle," · CC ",p.claudeLoggedIn?b.accountsConnectedMark:b.accountsDisconnected," · ",b.accountsPiSummary.replace("{count}",String(p.piLoggedInCount))]})}),o.jsx("span",{style:Zi,children:"›"})]})}),o.jsxs(Uu,{opacity:.92,children:[o.jsxs("div",{style:{...Vn(!0),gap:9},children:[o.jsx("span",{style:{fontSize:13,color:m.sub},children:j}),o.jsx(Um,{children:t.desktopEdit}),o.jsx("span",{style:Zi,children:"›"})]}),o.jsxs("div",{style:{...Vn(!0),gap:9},children:[o.jsxs("span",{style:{fontSize:13,color:m.sub},children:[t.templates," · ",e.templatesCount]}),o.jsx(Um,{children:t.desktopEdit}),o.jsx("span",{style:Zi,children:"›"})]}),o.jsx(ane,{vm:e,copy:t,onOpenHooks:u})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"2px 4px",font:`400 9.5px ${A}`,color:m.faint},children:[o.jsx("span",{children:t.footerBrand}),o.jsxs("span",{style:{marginLeft:"auto"},children:["build ",$m]})]})]}),g&&o.jsxs(Vr,{onClose:x,children:[o.jsx("div",{style:{display:"flex",alignItems:"baseline",padding:"0 2px 10px"},children:o.jsx("span",{style:{fontSize:17,fontWeight:700,color:m.ink,letterSpacing:"-.01em"},children:t.profileSheetTitle})}),o.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${m.hairline}`,borderRadius:13,overflow:"hidden"},children:g.map((S,k)=>o.jsxs("div",{onClick:()=>w(S.name),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 13px",borderBottom:k<g.length-1?"1px solid var(--proto-line-soft)":void 0,cursor:"pointer"},children:[o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[o.jsx("span",{style:{font:`600 13px ${A}`,color:m.ink},children:S.name}),S.current&&o.jsx("span",{style:{fontSize:9.5,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:m.runBg,color:m.run},children:t.profileSheetCurrent})]}),o.jsx("div",{style:{font:`400 10px ${A}`,color:m.muted,marginTop:3},children:S.sub})]}),S.current&&o.jsx("span",{style:{fontSize:15,fontWeight:700,color:m.run,flex:"none"},children:"✓"})]},S.name))}),o.jsx("div",{style:{font:`400 9.5px ${A}`,color:m.faint,padding:"9px 4px 0"},children:t.profileSheetFooter})]})]})}const cne="CORTEX_TURN_NOTIFY",dne="CORTEX_AUTO_RESUME";function o2(e,t){return e.some(n=>n.key===t&&n.present)}function une(e,t){var c;const n=e.profiles,r=(n==null?void 0:n.defaultProfile)??null,i=r?(n==null?void 0:n.profiles.find(d=>d.name===r))??null:null,s=((c=e.budget)==null?void 0:c.daily_usd)??null,a=(t==null?void 0:t.today)??0,l=[];return ul(e.env,"SLACK_")&&l.push("slack"),ul(e.env,"FEISHU_")&&l.push("feishu"),{daemonHost:null,profileName:r,profileModel:(i==null?void 0:i.model)??null,profileThinking:(i==null?void 0:i.thinking)??null,profiles:(n==null?void 0:n.profiles)??[],budgetSpendLabel:`${ud(a)} / ${ud(s)}`,budgetBarPct:Cm(a,s),notifyOn:o2(e.env,cne),autoResumeOn:o2(e.env,dne),platforms:l,templatesCount:e.threadTemplates.templates.length,hooks:e.hooks}}const pne={en:{title:"Settings",daemonStatus:"daemon · connected",daemon:"Daemon",machines:"Machines",machinesOk:"online",profileTitle:"Profile (global default)",switchLabel:"Switch",profileSheetTitle:"Global default profile",profileSheetCurrent:"current",profileSheetFooter:"Applies to new sessions and new threads",theme:"Theme",themeLight:"Light",themeDark:"Dark",budget:"Budget",budgetUnit:"/day",notify:"Notifications",notifySub:"push on · long task > 10m · approvals instant",autoResume:"Auto-resume on limit",autoResumeSub:"resume threads after rate-limit clears",language:"Language",platform:"Platform",desktopEdit:"Edit on desktop",templates:"Thread templates",hooks:"Hooks",footerBrand:"cortex mobile"},zh:{title:"设置",daemonStatus:"daemon · 已连接",daemon:"Daemon",machines:"机器",machinesOk:"台正常",profileTitle:"Profile(全局默认)",switchLabel:"切换",profileSheetTitle:"全局默认 Profile",profileSheetCurrent:"当前",profileSheetFooter:"切换后新会话 / 新线程使用",theme:"主题",themeLight:"浅色",themeDark:"深色",budget:"预算",budgetUnit:"日",notify:"通知",notifySub:"推送开 · 长任务 > 10m · 审批即时",autoResume:"限额自动续跑",autoResumeSub:"rate-limit 解除后自动恢复线程",language:"语言",platform:"Platform",desktopEdit:"桌面编辑",templates:"Thread templates",hooks:"钩子",footerBrand:"cortex mobile"}},fne={budget:null,profiles:null,threadTemplates:{agents:[],templates:[],shells:[]},hooks:[],env:[]};function hne(){const e=ae(),t=je(),n=Be(),r=ft(),i=gC(),s=k0(),a=S0(),l=Lt(r,pne),c=G(e.config.get.queryOptions({})),d=G(e.cost.summary.queryOptions({})),u=G(e.auth.status.queryOptions({})),p=G(e.machines.list.queryOptions({})),h=fee(p.data??[]),g=f.useMemo(()=>une(c.data??fne,d.data),[c.data,d.data]),v=f.useMemo(()=>u.data?B0(u.data).summary:{claudeLoggedIn:!1,piLoggedInCount:0},[u.data]),[x,w]=f.useState(!1),b=ue(e.config.set.mutationOptions({onSuccess:()=>t.invalidateQueries(e.config.get.queryFilter({}))})),y=x?EE(g.profiles,g.profileName??""):null,j=S=>{w(!1),S!==g.profileName&&b.mutate({section:"profiles",value:{defaultProfile:S}})};return c.isLoading?o.jsx(vt,{label:"1l 设置",children:o.jsx("div",{style:{padding:16,color:m.muted,fontSize:13},children:l.title})}):o.jsx(lne,{vm:g,copy:l,lang:r,onSetLang:i,theme:s,onSetTheme:a,onBack:()=>n("/m/project"),onOpenDaemon:()=>n("/m/daemon"),onlineMachines:h,onOpenMachines:()=>n("/m/machines"),onOpenHooks:()=>n("/m/settings/hooks"),accountsSummary:v,onOpenAccounts:()=>n("/m/settings/accounts"),profileSheet:y,onOpenProfile:()=>w(!0),onCloseProfile:()=>w(!1),onPickProfile:j})}function Hm(e,t,n){return t==="api_key"?e.authLoginApiKey:n==="claude"?e.authLoginSubscription:e.authLoginOAuth}function HE({value:e}){const t=B();return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,minWidth:0},children:[o.jsx("span",{children:o.jsx(Gt,{tone:e.tone,children:t[e.labelKey]})}),o.jsxs("span",{style:{font:`400 9.5px ${A}`,color:m.muted,overflowWrap:"anywhere"},children:[t.accountsSource,": ",e.source??"—"]}),e.expiresAt?o.jsxs("span",{style:{font:`400 9.5px ${A}`,color:m.muted,overflowWrap:"anywhere"},children:[t.accountsExpires,": ",e.expiresAt]}):null]})}function i2({children:e,target:t,action:n,disabled:r,onClick:i}){return o.jsx("button",{type:"button","data-auth-action":n,"data-backend":t.backend,"data-provider":t.provider,"data-auth-type":t.authType,disabled:r,onClick:()=>i(t),style:{border:`1px solid ${n==="logout"?"var(--proto-danger-bg)":m.run}`,borderRadius:8,padding:"6px 9px",background:m.card,color:n==="logout"?m.fail:m.run,fontSize:10.5,fontWeight:650,cursor:r?"not-allowed":"pointer",opacity:r?.45:1},children:e})}function qE({backend:e,provider:t,loginTypes:n,logoutTypes:r,disabled:i,onLogin:s,onLogout:a}){const l=B(),c=d=>({backend:e,provider:t,authType:d});return o.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginTop:8},children:[n.map(d=>o.jsxs(i2,{target:c(d),action:"login",disabled:i,onClick:s,children:[l.accountsLogin," ",Hm(l,d,e)]},`login:${d}`)),r.map(d=>o.jsxs(i2,{target:c(d),action:"logout",disabled:i,onClick:a,children:[l.accountsLogout," ",Hm(l,d,e)]},`logout:${d}`))]})}function gne({account:e,actionsDisabled:t,onLogin:n,onLogout:r}){const i=B();return o.jsxs(Oe,{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,marginBottom:9},children:[o.jsx(nh,{provider:"claude-code",label:"Claude Code",size:16}),o.jsx("span",{style:{fontSize:14,fontWeight:700,color:m.ink},children:"Claude Code"}),e.inUse?o.jsx(Gt,{tone:"done",children:i.accountsInUse}):null]}),e.slots.map((s,a)=>o.jsxs("div",{style:{padding:"9px 0",borderTop:a>0?`1px solid ${m.divider}`:void 0},children:[o.jsx("div",{style:{font:`600 11px ${A}`,color:m.ink,marginBottom:7},children:Hm(i,s.authType,"claude")}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:7},children:s.credentials.map((l,c)=>o.jsx(HE,{value:l},`${l.source??"none"}:${c}`))}),o.jsx(qE,{backend:"claude",provider:e.provider,loginTypes:s.canLogin?[s.authType]:[],logoutTypes:s.canLogout?[s.authType]:[],disabled:t,onLogin:n,onLogout:r})]},s.authType))]})}function xne({provider:e,actionsDisabled:t,onLogin:n,onLogout:r}){const i=B(),s={...e.status,source:e.source,expiresAt:e.expiresAt};return o.jsxs(Oe,{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[o.jsx(nh,{provider:e.provider,label:e.label,size:15}),o.jsx("span",{style:{fontSize:13,fontWeight:700,color:m.ink},children:e.label}),o.jsx("span",{style:{font:`400 9px ${A}`,color:m.muted},children:e.provider}),e.loginTypes.map(a=>o.jsx(Gt,{tone:"running",children:a==="api_key"?i.authLoginApiKey:i.authLoginOAuth},a))]}),o.jsx("div",{style:{marginTop:8},children:o.jsx(HE,{value:s})}),o.jsx(qE,{backend:"pi",provider:e.provider,loginTypes:e.loginTypes,logoutTypes:e.logoutTypes,disabled:t,onLogin:n,onLogout:r})]})}function mne({provider:e,disabled:t,confirming:n,onEdit:r,onDelete:i}){const s=B();return o.jsxs(Oe,{children:[o.jsxs("div",{"data-custom-provider":e.name,style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[o.jsx("span",{style:{fontSize:13,fontWeight:700,color:m.ink},children:e.name}),o.jsx("span",{style:{font:`400 9px ${A}`,color:m.muted},children:e.api}),e.routed?null:o.jsx(Gt,{tone:"waiting",children:s.cpvUnrouted}),o.jsx(Gt,{tone:"cancelled",children:e.hasApiKey?s.cpvKeyStored:s.cpvNoKey})]}),o.jsxs("div",{style:{marginTop:8,display:"flex",flexDirection:"column",gap:4},children:[o.jsx("span",{style:{font:`400 9.5px ${A}`,color:m.muted,overflowWrap:"anywhere"},children:e.upstreamUrl??"—"}),o.jsx("span",{style:{font:`400 9.5px ${A}`,color:m.muted,overflowWrap:"anywhere"},children:e.models.map(a=>a.id).join(", ")})]}),o.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginTop:8},children:[o.jsx("button",{type:"button","data-cpv-action":"edit","data-cpv-provider":e.name,disabled:t,onClick:r,style:{border:`1px solid ${m.run}`,borderRadius:8,padding:"6px 9px",background:m.card,color:m.run,fontSize:10.5,fontWeight:650,cursor:t?"not-allowed":"pointer",opacity:t?.45:1},children:s.cpvEdit}),o.jsx("button",{type:"button","data-cpv-action":"delete","data-cpv-provider":e.name,disabled:t,onClick:i,style:{border:"1px solid var(--proto-danger-bg)",borderRadius:8,padding:"6px 9px",background:m.card,color:m.fail,fontSize:10.5,fontWeight:650,cursor:t?"not-allowed":"pointer",opacity:t?.45:1},children:n?s.cpvConfirmDelete:s.cpvDelete})]})]})}function vne({vm:e,onBack:t,onLogin:n,onLogout:r,actionsDisabled:i,custom:s}){const a=B();return o.jsxs(o.Fragment,{children:[o.jsx(zn,{onBack:t,trailing:o.jsxs("span",{style:{font:`500 10px ${A}`,color:m.muted},children:[e.piProviders.length," PI"]}),children:o.jsx("div",{style:{fontSize:16,fontWeight:650,color:m.ink},children:a.accountsTitle})}),o.jsxs(En,{gap:14,children:[e.claude?o.jsx(gne,{account:e.claude,actionsDisabled:i,onLogin:n,onLogout:r}):null,e.groups.map(l=>o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[o.jsxs(xl,{children:[a[l.labelKey]," · ",l.providers.length]}),l.providers.map(c=>o.jsx(xne,{provider:c,actionsDisabled:i,onLogin:n,onLogout:r},c.provider))]},l.key)),e.piProviders.length===0?o.jsx(Oe,{children:o.jsx("span",{style:{fontSize:12,color:m.muted},children:a.accountsNoProviders})}):null,s?o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[o.jsxs(xl,{children:[a.cpvTitle," · ",s.providers.length,o.jsx("button",{type:"button","data-cpv-action":"new",onClick:s.onNew,style:{marginLeft:8,border:`1px solid ${m.run}`,borderRadius:8,padding:"3px 8px",background:m.card,color:m.run,fontSize:10,fontWeight:650,cursor:"pointer"},children:a.cpvNew})]}),s.providers.length>0?s.providers.map(l=>o.jsx(mne,{provider:l,disabled:i,confirming:s.confirmingDelete===l.name,onEdit:()=>s.onEdit(l),onDelete:()=>s.onDelete(l.name)},l.name)):o.jsx(Oe,{children:o.jsx("span",{style:{fontSize:12,color:m.muted},children:a.cpvNone})})]}):null]})]})}const yne={"name-required":"cpvErrNameRequired","name-charset":"cpvErrNameCharset","name-taken":"cpvErrNameTaken","upstream-required":"cpvErrUpstreamRequired","upstream-scheme":"cpvErrUpstreamScheme","models-required":"cpvErrModelsRequired","model-id-duplicate":"cpvErrModelsDuplicate"},Zl={width:"100%",border:"1.5px solid var(--proto-line-3)",borderRadius:13,background:"var(--proto-card)",padding:"11px 14px",font:`400 13.5px ${A}`,color:m.ink,boxSizing:"border-box",outline:"none"};function ec({label:e,hint:t,danger:n,children:r}){return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5,marginBottom:11},children:[o.jsx("span",{style:{font:`600 10px ${A}`,color:m.muted},children:e}),r,t?o.jsx("span",{style:{font:`400 9.5px ${A}`,color:n?m.fail:m.faint},children:t}):null]})}function bne({draft:e,creating:t,errors:n,onChange:r,onSave:i,onClose:s,behind:a}){const l=B(),c=p=>r({...e,...p}),d=(p,h)=>{const g=n[p];return g?l[yne[g]]:h},u=C6(n);return o.jsxs(Vr,{onClose:s,behind:a,children:[o.jsx("div",{style:{display:"flex",alignItems:"baseline",padding:"0 2px 12px"},children:o.jsx("span",{style:{fontSize:17,fontWeight:700,color:m.ink,letterSpacing:"-.01em"},children:t?l.cpvCreateTitle:l.cpvEditTitle})}),o.jsx(ec,{label:l.cpvFieldName,hint:d("name",t?l.cpvNameHint:l.cpvNoRename),danger:!!n.name,children:o.jsx("input",{"data-cpv-field":"name",value:e.name,disabled:!t,onChange:p=>c({name:p.target.value}),style:{...Zl,opacity:t?1:.55}})}),o.jsx(ec,{label:l.cpvFieldApi,hint:l.cpvApiHint,children:o.jsx("select",{"data-cpv-field":"api",value:e.api,onChange:p=>c({api:p.target.value}),style:Zl,children:b6.map(p=>o.jsx("option",{value:p,children:p},p))})}),o.jsx(ec,{label:l.cpvFieldUrl,hint:d("upstreamUrl",l.cpvUrlHint),danger:!!n.upstreamUrl,children:o.jsx("input",{"data-cpv-field":"url",value:e.upstreamUrl,onChange:p=>c({upstreamUrl:p.target.value}),style:Zl})}),o.jsx(ec,{label:l.cpvFieldKey,hint:l.cpvKeyHint,children:o.jsx("input",{"data-cpv-field":"key",type:"password",value:e.apiKey,placeholder:l.cpvKeyPlaceholder,onChange:p=>c({apiKey:p.target.value}),style:Zl})}),o.jsx(ec,{label:l.cpvFieldModels,hint:d("models",l.cpvModelsHint),danger:!!n.models,children:o.jsx("textarea",{"data-cpv-field":"models",value:e.models,rows:3,onChange:p=>c({models:p.target.value}),style:{...Zl,resize:"vertical"}})}),o.jsx("button",{type:"button","data-cpv-action":"save",onClick:i,disabled:!u,style:{width:"100%",height:48,border:"none",borderRadius:13,background:m.ink,color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,marginTop:2,opacity:u?1:.45,cursor:u?"pointer":"default"},children:l.cpvSave})]})}const jne={accounts:[]};function wne(){const e=B(),t=ae(),n=Be(),r=je(),{toast:i}=Tn(),{openLogin:s}=E0(),a=G(t.auth.status.queryOptions({})),l=f.useMemo(()=>B0(a.data??jne),[a.data]),c=ue(t.auth.logout.mutationOptions({onSuccess:()=>{r.invalidateQueries(t.auth.status.queryFilter({})),i({title:e.accountsLogoutDone,tone:"done"})},onError:P=>i({title:`${e.accountsLogoutFailed}: ${P.message}`,tone:"failed"})})),d=P=>c.mutate(P),[u,p]=f.useState(null),[h,g]=f.useState(!1),[v,x]=f.useState(null),b=G(t.auth.customProviders.queryOptions({})).data??[],y=()=>{r.invalidateQueries(t.auth.customProviders.queryFilter({})),r.invalidateQueries(t.auth.status.queryFilter({}))},j=P=>i({title:`${e.cpvToastFailed}: ${P.message}`,tone:"failed"}),S=ue(t.auth.upsertCustomProvider.mutationOptions({onSuccess:()=>{y(),p(null),i({title:e.cpvToastSaved,tone:"done"})},onError:j})),k=ue(t.auth.removeCustomProvider.mutationOptions({onSuccess:()=>{y(),x(null),i({title:e.cpvToastDeleted,tone:"done"})},onError:j})),E=u?S6(u,{mode:h?"create":"update",existingNames:b.map(P=>P.name)}):{},C={providers:b,confirmingDelete:v,onNew:()=>{g(!0),p(j6())},onEdit:P=>{g(!1),p(w6(P))},onDelete:P=>{v!==P?x(P):k.mutate({name:P})}},R=c.isPending||S.isPending||k.isPending;return o.jsxs(vt,{label:e.accountsTitle,children:[a.isLoading?o.jsx("div",{style:{padding:16,color:m.muted},children:e.accountsLoading}):a.isError?o.jsx("div",{style:{padding:16,color:m.fail},children:e.accountsLoadFailed}):o.jsx(vne,{vm:l,onBack:()=>n("/m/settings"),onLogin:s,onLogout:d,actionsDisabled:R,custom:C}),u?o.jsx(bne,{draft:u,creating:h,errors:E,onChange:p,onClose:()=>p(null),onSave:()=>S.mutate(T6(u))}):null]})}const kne={font:`600 12.5px ${A}`,color:m.ink,overflowWrap:"anywhere"},Sne={font:`400 9.5px ${A}`,color:m.muted,marginTop:3,overflowWrap:"anywhere"};function VE({targets:e}){return o.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:e.map(t=>o.jsx(Gt,{tone:"running",children:t},t))})}function Cne({row:e,copy:t,onOpen:n}){return o.jsxs(Oe,{onClick:()=>n(e.key),children:[o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:kne,children:e.id}),o.jsxs("div",{style:Sne,children:[e.event," · ",e.source]})]}),o.jsx("span",{style:{flex:"none"},children:o.jsx(Gt,{tone:e.enabled?"done":"cancelled",children:e.enabled?t.enabled:t.disabled})})]}),(e.mountsOn.length>0||e.scriptMissing)&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:8,flexWrap:"wrap"},children:[o.jsx(VE,{targets:e.mountsOn}),e.scriptMissing&&o.jsx("span",{style:{marginLeft:"auto",flex:"none"},children:o.jsx(Gt,{tone:"failed",children:t.scriptMissing})})]})]})}function Tne({group:e,copy:t,onOpenHook:n}){return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[o.jsxs(xl,{children:[t.group[e.key]," · ",e.rows.length]}),e.rows.map(r=>o.jsx(Cne,{row:r,copy:t,onOpen:n},r.key))]})}function Ene({label:e,children:t,divider:n=!0}){return o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"9px 13px",borderBottom:n?`1px solid ${m.divider}`:void 0},children:[o.jsx("span",{style:{fontSize:11,color:m.muted,flex:"none",width:92},children:e}),o.jsx("span",{style:{font:`500 10.5px ${A}`,color:m.ink,minWidth:0,flex:1,overflowWrap:"anywhere"},children:t})]})}function Rne(e,t){var r,i;const n=[{label:t.field.event,value:e.event}];return((r=e.matcher)==null?void 0:r.kind)==="regex"&&n.push({label:t.field.matcher,value:e.matcher.value}),((i=e.matcher)==null?void 0:i.kind)==="filters"&&n.push({label:t.field.filters,value:o.jsx("span",{style:{display:"flex",flexDirection:"column",gap:2},children:e.matcher.entries.map(s=>o.jsxs("span",{children:[s.key," = ",s.value]},s.key))})}),e.run.kind==="none"?n.push({label:t.field.run,value:t.none}):n.push({label:e.run.kind==="script"?t.field.script:t.field.command,value:o.jsxs(o.Fragment,{children:[e.run.value,e.run.missing&&o.jsx("span",{style:{marginLeft:6},children:o.jsx(Gt,{tone:"failed",children:t.scriptMissing})})]})}),e.timeoutSec!==null&&n.push({label:t.field.timeout,value:`${e.timeoutSec}${t.secondUnit}`}),e.backends!==null&&n.push({label:t.field.backends,value:e.backends.join(", ")}),e.requiresTool!==null&&n.push({label:t.field.requiresTool,value:e.requiresTool}),e.result!==null&&n.push({label:t.field.result,value:e.result}),e.blocking!==null&&n.push({label:t.field.blocking,value:`${e.blocking.mode} · ${e.blocking.ttlMin}${t.minuteUnit}`}),n.push({label:t.field.mountsOn,value:o.jsx(VE,{targets:e.mountsOn})}),n.push({label:t.field.appliesAt,value:t.applies[e.appliesAt]}),n.push({label:t.field.source,value:e.source}),e.version!==null&&n.push({label:t.field.version,value:e.version}),e.fileName!==null&&n.push({label:t.field.fileName,value:e.fileName}),e.template!==null&&n.push({label:t.field.template,value:e.template}),e.phase!==null&&n.push({label:t.field.phase,value:e.phase}),n.push({label:t.field.order,value:String(e.order)}),n}function Pne({row:e,copy:t,onClose:n}){const r=Rne(e.detail,t);return o.jsxs(Vr,{onClose:n,children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"0 2px 10px"},children:[o.jsx("span",{style:{font:`700 15px ${A}`,color:m.ink,minWidth:0,overflowWrap:"anywhere"},children:e.id}),o.jsx("span",{style:{marginLeft:"auto",flex:"none"},children:o.jsx(Gt,{tone:e.enabled?"done":"cancelled",children:e.enabled?t.enabled:t.disabled})})]}),o.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${m.hairline}`,borderRadius:13,overflow:"hidden"},children:r.map((i,s)=>o.jsx(Ene,{label:i.label,divider:s<r.length-1,children:i.value},i.label))}),o.jsx("div",{style:{font:`400 9.5px ${A}`,color:m.faint,padding:"9px 4px 0"},children:t.sheetFooter})]})}function Ine({vm:e,copy:t,sheetRow:n,onBack:r,onOpenHook:i,onCloseSheet:s}){return o.jsxs(o.Fragment,{children:[o.jsx(zn,{onBack:r,trailing:o.jsxs("span",{style:{font:`500 10px ${A}`,color:m.muted},children:[e.enabledCount,"/",e.total," ",t.enabledWord]}),children:o.jsx("div",{style:{fontSize:16,fontWeight:650,color:m.ink,letterSpacing:"-.01em"},children:t.title})}),o.jsxs(En,{gap:14,children:[e.groups.length===0&&o.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:m.faint,fontSize:13},children:t.empty}),e.groups.map(a=>o.jsx(Tne,{group:a,copy:t,onOpenHook:i},a.key)),e.groups.length>0&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"2px 4px",font:`400 9.5px ${A}`,color:m.faint},children:[o.jsxs("span",{children:[e.total," ",t.countUnit]}),o.jsx("span",{style:{marginLeft:"auto",color:m.muted},children:t.editDesktop})]})]}),n&&o.jsx(Pne,{row:n,copy:t,onClose:s})]})}const Mne=["agent","cc","pi","cortex","template","other"],Lne=[{prefix:"agent:",key:"agent"},{prefix:"cc:",key:"cc"},{prefix:"pi:",key:"pi"},{prefix:"cortex:",key:"cortex"}];function One(e){var t;return e.source==="template-scoped"?"template":((t=Lne.find(n=>e.event.startsWith(n.prefix)))==null?void 0:t.key)??"other"}function Dne(e){return e.matcher!==null?{kind:"regex",value:e.matcher}:e.matcherFilters===null?null:{kind:"filters",entries:Object.entries(e.matcherFilters).map(([t,n])=>({key:t,value:n===null?"null":String(n)}))}}function Ane(e){return e.run.script!==null?{kind:"script",value:e.run.script,missing:e.scriptExists===!1}:e.run.command!==null?{kind:"command",value:e.run.command,missing:!1}:{kind:"none"}}function Nne(e){var t,n;return{id:e.id,event:e.event,matcher:Dne(e),run:Ane(e),timeoutSec:e.run.timeoutSec,backends:((t=e.scope)==null?void 0:t.backends)??null,requiresTool:((n=e.scope)==null?void 0:n.requiresTool)??null,result:e.result,blocking:e.blocking,source:e.source,version:e.version,fileName:e.fileName,order:e.order,mountsOn:e.mountsOn,appliesAt:e.appliesAt,template:e.template,phase:e.phase}}function s2(e){return{key:`${e.id}#${e.order}`,id:e.id,event:e.event,source:e.source,enabled:e.enabled,mountsOn:e.mountsOn,scriptMissing:e.scriptExists===!1,detail:Nne(e)}}function $ne(e){const t=new Map;for(const r of e.hooks){const i=One(r),s=t.get(i);s?s.push(s2(r)):t.set(i,[s2(r)])}const n=[];for(const r of Mne){const i=t.get(r);i&&n.push({key:r,rows:i.sort((s,a)=>s.detail.order-a.detail.order)})}return{groups:n,total:e.hooks.length,enabledCount:e.hooks.filter(r=>r.enabled).length,missingScriptCount:e.hooks.filter(r=>r.scriptExists===!1).length}}const _ne={en:{title:"Hooks",enabledWord:"enabled",countUnit:"hooks",group:{agent:"AGENT EVENTS",cc:"CLAUDE CODE EVENTS",pi:"PI EVENTS",cortex:"CORTEX BUS EVENTS",template:"TEMPLATE-SCOPED",other:"OTHER EVENTS"},enabled:"Enabled",disabled:"Disabled",scriptMissing:"script missing",empty:"No mounted hooks",editDesktop:"Edit on desktop",none:"—",secondUnit:"s",minuteUnit:"min",field:{event:"Event",matcher:"Matcher",filters:"Filters",script:"Script",command:"Command",run:"Run",timeout:"Timeout",backends:"Backends",requiresTool:"Requires tool",result:"Result",blocking:"Blocking",source:"Source",version:"Version",fileName:"File",order:"Load order",mountsOn:"Mounts on",appliesAt:"Applies",template:"Template",phase:"Phase"},applies:{"next-agent":"Next agent start","server-restart":"Server restart"},sheetFooter:"Read-only on mobile — edit on desktop"},zh:{title:"钩子",enabledWord:"已启用",countUnit:"条钩子",group:{agent:"AGENT 事件",cc:"CLAUDE CODE 事件",pi:"PI 事件",cortex:"CORTEX 总线事件",template:"模板内联",other:"其他事件"},enabled:"已启用",disabled:"已停用",scriptMissing:"脚本缺失",empty:"暂无已挂载钩子",editDesktop:"桌面编辑",none:"—",secondUnit:"秒",minuteUnit:"分钟",field:{event:"事件",matcher:"匹配",filters:"过滤条件",script:"脚本",command:"命令",run:"执行",timeout:"超时",backends:"后端",requiresTool:"限定工具",result:"结果",blocking:"阻塞",source:"来源",version:"版本",fileName:"文件",order:"加载顺序",mountsOn:"挂载到",appliesAt:"生效",template:"模板",phase:"阶段"},applies:{"next-agent":"下次 agent 启动","server-restart":"需重启 server"},sheetFooter:"移动端只读 — 编辑请到桌面端"}},Fne={hooks:[]};function zne(){const e=ae(),t=Be(),n=ft(),r=Lt(n,_ne),i=G(e.hooks.list.queryOptions({})),s=f.useMemo(()=>$ne(i.data??Fne),[i.data]),[a,l]=f.useState(null),c=f.useMemo(()=>a===null?null:s.groups.flatMap(d=>d.rows).find(d=>d.key===a)??null,[a,s]);return o.jsx(vt,{label:"1l-h 钩子",children:i.isLoading?o.jsx("div",{style:{padding:16,color:m.muted,fontSize:13},children:r.title}):o.jsx(Ine,{vm:s,copy:r,sheetRow:c,onBack:()=>t("/m/settings"),onOpenHook:l,onCloseSheet:()=>l(null)})})}function Bne(e){return e==="connected"?"done":e==="disconnected"?"failed":"waiting"}function Wne(e){return e==="connecting"||e==="reconnecting"}function Une(e){return e==="running"?m.done:e==="unknown"?m.amber:m.fail}function Hne({proc:e,copy:t,border:n}){const r=t.dash;return o.jsxs("div",{style:{padding:"11px 13px 9px",borderBottom:n?`1px solid ${m.divider}`:void 0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:Une(e.status),flex:"none"}}),o.jsx("span",{style:{font:`600 12.5px ${A}`,color:m.ink},children:e.name}),e.label&&o.jsx("span",{style:{font:`400 9.5px ${A}`,color:m.muted},children:e.label}),o.jsxs("span",{style:{marginLeft:"auto",font:`400 9.5px ${A}`,color:m.muted},children:["pid ",e.pid??r,e.port!=null?` · :${e.port}`:""]})]}),o.jsxs("div",{style:{font:`400 9.5px ${A}`,color:m.muted,marginTop:4,paddingLeft:15},children:[t.uptimeLabel," ",e.uptime??r,e.extras.map(i=>` · ${i.k} ${i.v}`).join("")]})]})}const a2=2e3;function qne({label:e,hint:t,disabled:n,onConfirm:r}){const[i,s]=f.useState(0),a=f.useRef(null),l=f.useRef(null),c=f.useRef(0),d=()=>{a.current&&clearTimeout(a.current),l.current&&cancelAnimationFrame(l.current),a.current=null,l.current=null,s(0)},u=()=>{if(n)return;c.current=Date.now();const h=()=>{const g=Math.min(1,(Date.now()-c.current)/a2);s(g),g<1&&(l.current=requestAnimationFrame(h))};l.current=requestAnimationFrame(h),a.current=setTimeout(()=>{d(),r()},a2)},p=i>0;return o.jsxs("button",{type:"button",disabled:n,onPointerDown:u,onPointerUp:d,onPointerLeave:d,onPointerCancel:d,style:{position:"relative",flex:1,height:44,borderRadius:11,border:`1.5px solid ${m.failBorder}`,background:"var(--proto-card)",color:m.fail,display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,boxSizing:"border-box",overflow:"hidden",cursor:n?"default":"pointer",opacity:n?.5:1,touchAction:"none",userSelect:"none"},children:[o.jsx("span",{"aria-hidden":!0,style:{position:"absolute",left:0,top:0,bottom:0,width:`${i*100}%`,background:m.failBg,transition:p?void 0:"width .15s ease"}}),o.jsx("span",{style:{position:"relative"},children:p?t:e})]})}const l2={flex:1,height:44,borderRadius:11,border:"1.5px solid var(--proto-line-3)",background:"var(--proto-card)",color:m.ink,display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,boxSizing:"border-box",cursor:"pointer"};function Vne({ev:e,copy:t}){return o.jsxs("div",{style:{display:"flex",gap:8},children:[o.jsx("span",{style:{color:m.faint,flex:"none"},children:e.time}),o.jsxs("span",{style:{color:e.tone==="fail"?m.amberText:m.sub},children:[e.ref," · ",t.status[e.status]]})]})}const Kne={connected:"connConnected",connecting:"connConnecting",reconnecting:"connReconnecting",disconnected:"connDisconnected"};function Qne({vm:e,copy:t,connStatus:n,restartState:r,showDisconnect:i,onBack:s,onSoftRestart:a,onHardRestart:l,onDisconnect:c}){const d=r==="pending";return o.jsxs(vt,{label:"1r Daemon 状态",children:[o.jsx(zn,{onBack:s,children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[o.jsx("span",{style:{fontSize:16,fontWeight:650,color:m.ink,letterSpacing:"-.01em"},children:t.title}),o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5},children:[Wne(n)&&o.jsx(ho,{color:m.amber,pulse:!0}),o.jsx(Gt,{tone:Bne(n),children:t[Kne[n]]})]})]})}),o.jsxs(En,{gap:10,children:[o.jsxs(Oe,{padding:0,style:{overflow:"hidden"},children:[e.processes.map((u,p)=>o.jsx(Hne,{proc:u,copy:t,border:p<e.processes.length-1},u.name)),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"10px 13px",font:`400 10px ${A}`,color:m.muted,flexWrap:"wrap",borderTop:`1px solid ${m.divider}`},children:[o.jsx("span",{children:t.threadsRunning(e.threadCount)}),o.jsx("span",{children:"·"}),o.jsx("span",{children:t.schedules(e.scheduleCount)})]})]}),o.jsxs(Oe,{padding:0,style:{overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 13px",borderBottom:`1px solid ${m.divider}`},children:[o.jsx("span",{style:{fontSize:12,fontWeight:650,color:m.ink},children:t.recentTitle}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${A}`,color:m.faint},children:"executions.list"})]}),e.lastRestart===null&&e.events.length===0?o.jsx("div",{style:{padding:"14px 13px",font:`400 10px ${A}`,color:m.faint},children:t.recentEmpty}):o.jsxs("div",{style:{padding:"9px 13px",display:"flex",flexDirection:"column",gap:7,font:`400 10px/1.5 ${A}`},children:[e.lastRestart&&o.jsxs("div",{style:{display:"flex",gap:8},children:[o.jsx("span",{style:{color:m.faint,flex:"none"},children:e.lastRestart.time}),o.jsxs("span",{style:{color:m.sub},children:[t.lastRestartLabel,e.lastRestart.reason?` · ${e.lastRestart.reason}`:""]})]}),e.events.map(u=>o.jsx(Vne,{ev:u,copy:t},u.id))]}),o.jsx("div",{style:{padding:"0 13px 10px",font:`400 9px ${A}`,color:m.faint},children:t.recentGap})]}),o.jsxs(Oe,{padding:"12px 13px",children:[o.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[o.jsx("span",{style:{fontSize:13,fontWeight:600,color:m.ink},children:t.softRestart}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${A}`,color:m.faint},children:t.softNote(e.threadCount)})]}),o.jsxs("div",{style:{display:"flex",gap:8,marginTop:10},children:[o.jsx("button",{type:"button",disabled:d,onClick:a,style:{...l2,opacity:d?.5:1,cursor:d?"default":"pointer"},children:t.softRestart}),o.jsx(qne,{label:t.forceKill,hint:t.holdHint,disabled:d,onConfirm:l})]}),o.jsx("div",{style:{font:`400 9px ${A}`,color:m.faint,marginTop:8},children:t.footerNote}),r==="success"&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:8},children:[o.jsx(ho,{color:m.done}),o.jsx("span",{style:{fontSize:11,fontWeight:600,color:m.done},children:t.sent})]}),r==="error"&&o.jsx("div",{style:{marginTop:8,fontSize:11,fontWeight:600,color:m.fail},children:t.failed})]}),i&&o.jsxs(Oe,{padding:"12px 13px",children:[o.jsx("button",{type:"button",onClick:c,style:{...l2,width:"100%"},children:t.disconnect}),o.jsx("div",{style:{font:`400 9px ${A}`,color:m.faint,marginTop:8,textAlign:"center"},children:t.disconnectNote})]})]})]})}const Gne=5,Yne=new Set(["failed","cancelled","stale"]);function Xne(e,t){if(e&&e.processes.length>0)return e.processes.map(r=>({name:r.name,label:r.label,status:r.status,pid:r.pid,port:r.port,uptime:r.uptime,extras:r.extras?Object.entries(r.extras).map(([i,s])=>({k:i,v:s})):[]}));const n=t?"running":"unknown";return[{name:"cortex-server",label:"",status:n,pid:null,port:null,uptime:null,extras:[]},{name:"cortex-daemon",label:"",status:n,pid:null,port:null,uptime:null,extras:[]}]}function Jne(e){var s,a,l,c;const t=e.now??Date.now(),n=e.executions.slice(0,Gne).map(d=>({id:d.id,time:Br(d.startedAt,t),ref:d.taskId?`${d.type} · ${d.taskId}`:d.type,status:d.status,tone:Yne.has(d.status)?"fail":"default"})),r=((a=(s=e.daemon)==null?void 0:s.lastRestart)==null?void 0:a.at)??null,i=r?{time:Br(r,t),reason:((c=(l=e.daemon)==null?void 0:l.lastRestart)==null?void 0:c.reason)??null}:null;return{ok:e.ok,threadCount:e.threads.length,scheduleCount:e.schedules.length,processes:Xne(e.daemon,e.ok),lastRestart:i,events:n}}const Zne={en:{title:"Daemon",connConnected:"connected",connConnecting:"connecting",connReconnecting:"reconnecting",connDisconnected:"disconnected",threadsRunning:e=>`${e} threads running`,schedules:e=>`schedules ${e}`,uptimeLabel:"uptime",dash:"—",lastRestartLabel:"Last restart",recentTitle:"Recent events",recentGap:"daemon event log not exposed on web — showing recent executions",recentEmpty:"No recent activity",status:{running:"running",completed:"completed",failed:"failed",cancelled:"cancelled",stale:"stale"},softRestart:"Soft restart",forceKill:"Force kill",softNote:e=>`pauses ${e} running thread(s)`,holdHint:"Keep holding…",footerNote:"Soft restart keeps thread state and auto-resumes · Force kill needs a 2s long-press; running threads are marked interrupted",sent:"Restart signal sent",failed:"Restart failed",disconnect:"Disconnect",disconnectNote:"Clears the saved server & token, returns to the login screen"},zh:{title:"Daemon",connConnected:"已连接",connConnecting:"连接中",connReconnecting:"正在重连",connDisconnected:"已断开",threadsRunning:e=>`${e} 线程运行中`,schedules:e=>`schedules ${e}`,uptimeLabel:"uptime",dash:"—",lastRestartLabel:"上次重启",recentTitle:"最近事件",recentGap:"Web 未提供 daemon 事件日志,以下为最近执行",recentEmpty:"暂无最近活动",status:{running:"运行中",completed:"已完成",failed:"失败",cancelled:"已取消",stale:"过期"},softRestart:"软重启",forceKill:"强制终止",softNote:e=>`先暂停 ${e} 个运行中线程`,holdHint:"继续按住…",footerNote:"软重启不丢线程状态,恢复后自动续跑 · 强制终止需长按 2s 确认,运行中线程标记 interrupted",sent:"重启信号已发送",failed:"重启失败",disconnect:"断开连接",disconnectNote:"清除已保存的服务器与令牌,返回登录页"}};function ere(){const e=ae(),t=Be(),n=je(),r=ft(),i=Lt(r,Zne),s=G(e.threads.list.queryOptions({status:KG("active")})),a=G(e.schedules.list.queryOptions({})),l=G(e.executions.list.queryOptions({limit:5})),c=G(e.system.daemonStatus.queryOptions({})),d=!s.isError&&!a.isError,u=gT(),p=f.useMemo(()=>Jne({threads:s.data??[],schedules:a.data??[],executions:l.data??[],daemon:c.data??null,ok:d}),[s.data,a.data,l.data,c.data,d]),h=ue(e.system.restart.mutationOptions({onSuccess:()=>{n.invalidateQueries(e.threads.list.queryFilter()),n.invalidateQueries(e.system.daemonStatus.queryFilter())}})),g=h.isPending?"pending":h.isSuccess?"success":h.isError?"error":"idle";return o.jsx(Qne,{vm:p,copy:i,connStatus:u,restartState:g,showDisconnect:on(),onBack:()=>t("/m/settings"),onSoftRestart:()=>h.mutate({kind:"soft"}),onHardRestart:()=>h.mutate({kind:"hard"}),onDisconnect:()=>void DT()})}const tre=[{path:"/",element:o.jsx(YX,{}),children:[{index:!0,element:o.jsx(xm,{to:"/m/sessions",replace:!0})},{path:"/m/sessions",element:o.jsx(uJ,{})},{path:"/m/threads",element:o.jsx(LZ,{})},{path:"/m/tasks",element:o.jsx(XZ,{})},{path:"/m/project",element:o.jsx(Cee,{})},{path:"/m/session/:sessionId",element:o.jsx(hZ,{})},{path:"/m/session/:sessionId/plan/:requestId",element:o.jsx(mZ,{})},{path:"/m/thread/:threadId",element:o.jsx(pte,{})},{path:"/m/task/:taskId",element:o.jsx(Pte,{})},{path:"/m/approvals",element:o.jsx(Lee,{})},{path:"/m/issues",element:o.jsx(_ee,{})},{path:"/m/notes",element:o.jsx(Yee,{})},{path:"/m/memory",element:o.jsx(Ate,{})},{path:"/m/memory/file",element:o.jsx(Bte,{})},{path:"/m/machines",element:o.jsx(rne,{})},{path:"/m/settings",element:o.jsx(hne,{})},{path:"/m/settings/accounts",element:o.jsx(wne,{})},{path:"/m/settings/hooks",element:o.jsx(zne,{})},{path:"/m/daemon",element:o.jsx(ere,{})},{path:"*",element:o.jsx(xm,{to:"/m/sessions",replace:!0})}]}],nre=on()?UC:WC,rre=nre(tre);function ore(){const e=xA();return o.jsx(I$,{router:e?rre:sX})}const KE=document.getElementById("root");if(!KE)throw new Error("#root element not found");DS(KE).render(o.jsx(f.StrictMode,{children:o.jsx(sN,{children:o.jsx(ore,{})})}));
|