@growthub/cli 0.3.35 → 0.3.37

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/README.md CHANGED
@@ -18,13 +18,16 @@ npx create-growthub-local --profile gtm
18
18
 
19
19
  ## Worker Kits V1
20
20
 
21
- The CLI also ships a bundled Worker Kit export surface for local working-directory artifacts:
21
+ The CLI ships a bundled Worker Kit export surface for local adapter environments.
22
+ These kits are not server installs or database records. They are frozen, working-directory-ready
23
+ artifacts that local adapters can run inside directly.
22
24
 
23
25
  ```bash
24
26
  growthub kit list
25
27
  growthub kit inspect creative-strategist-v1
26
28
  growthub kit download creative-strategist-v1
27
29
  growthub kit path creative-strategist-v1
30
+ growthub kit validate /absolute/path/to/kit
28
31
  ```
29
32
 
30
33
  V1 is intentionally narrow:
@@ -35,7 +38,21 @@ V1 is intentionally narrow:
35
38
  - public `solawave` example brand included
36
39
  - no heartbeat wiring, app install flow, server registry, plugin lifecycle, or database kit records
37
40
 
38
- The exported folder is a machine artifact produced by the CLI for existing Working Directory path support.
41
+ ### How local adapters use worker kits
42
+
43
+ Local adapters such as Claude, Codex, Cursor, Gemini, and OpenCode execute inside the agent
44
+ `Working directory` path.
45
+
46
+ Growthub worker kits are designed to plug into that path directly:
47
+
48
+ 1. Export a kit with `growthub kit download <kit-id>` or resolve its folder with `growthub kit path <kit-id>`.
49
+ 2. Take the expanded folder on disk.
50
+ 3. Put that absolute path into the agent's `Working directory` field.
51
+ 4. Run the local adapter against that exported environment.
52
+
53
+ This is the current integration surface for worker kits in Growthub. In other words, the worker kit
54
+ becomes a specialized local execution environment that an agent can access and work within through
55
+ its configured working directory.
39
56
 
40
57
  ## What this is
41
58
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "schemaVersion": 1,
2
+ "schemaVersion": 2,
3
3
  "bundle": {
4
4
  "id": "creative-strategist-v1",
5
5
  "version": "1.0.0",
@@ -42,5 +42,6 @@
42
42
  "export": {
43
43
  "folderName": "growthub-agent-worker-kit-creative-strategist-v1",
44
44
  "zipFileName": "growthub-agent-worker-kit-creative-strategist-v1.zip"
45
- }
45
+ },
46
+ "activationModes": ["export"]
46
47
  }
@@ -11,4 +11,8 @@ For V1:
11
11
  - confidential brand kits are intentionally excluded from the frozen public payload
12
12
  - the exported artifact is a local working-directory-ready bundle, not a server install
13
13
 
14
+ Operationally, this means local adapters use the exported kit by setting the agent `Working directory`
15
+ to the expanded folder on disk. The kit acts as a specialized local execution environment that the
16
+ agent can run inside directly.
17
+
14
18
  See `kit-standard.md` for the locked contract.
@@ -1,10 +1,11 @@
1
1
  {
2
- "schemaVersion": 1,
2
+ "schemaVersion": 2,
3
3
  "kit": {
4
4
  "id": "creative-strategist-v1",
5
5
  "version": "1.0.0",
6
6
  "name": "Growthub Agent Worker Kit — Creative Strategist",
7
7
  "description": "Frozen Creative Strategist worker kit for exporting a working-directory-ready video creative brief worker.",
8
+ "type": "worker",
8
9
  "visibility": "public-open-source",
9
10
  "sourceRepo": "claude-workers"
10
11
  },
@@ -68,5 +69,14 @@
68
69
  "version": "1.0.0",
69
70
  "path": "bundles/creative-strategist-v1.json"
70
71
  }
71
- ]
72
+ ],
73
+ "executionMode": "export",
74
+ "activationModes": ["export"],
75
+ "compatibility": {
76
+ "cliMinVersion": "0.3.35"
77
+ },
78
+ "provenance": {
79
+ "sourceRepo": "claude-workers",
80
+ "frozenAt": "2026-04-09T00:00:00.000Z"
81
+ }
72
82
  }
@@ -675,7 +675,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${e.do
675
675
  * See the LICENSE file in the root directory of this source tree.
676
676
  */const Tle=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Nle=_e("zap",Tle);function Vb({...t}){return d.jsx(Z_,{"data-slot":"dialog",...t})}function RPe({...t}){return d.jsx(UO,{"data-slot":"dialog-trigger",...t})}function v8({...t}){return d.jsx(Y_,{"data-slot":"dialog-portal",...t})}function Ale({className:t,...e}){return d.jsx(Q_,{"data-slot":"dialog-overlay",className:Z("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 duration-100",t),...e})}function r5({className:t,children:e,showCloseButton:n=!0,...r}){return d.jsxs(v8,{"data-slot":"dialog-portal",children:[d.jsx(Ale,{}),d.jsxs(X_,{"data-slot":"dialog-content",className:Z("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-[0.97] data-[state=open]:zoom-in-[0.97] data-[state=closed]:slide-out-to-top-[1%] data-[state=open]:slide-in-from-top-[1%] fixed top-[max(1rem,env(safe-area-inset-top))] md:top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-0 md:translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-150 ease-[cubic-bezier(0.16,1,0.3,1)] outline-none sm:max-w-lg",t),...r,children:[e,n&&d.jsxs(ab,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[d.jsx(Pa,{}),d.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function w8({className:t,...e}){return d.jsx("div",{"data-slot":"dialog-header",className:Z("flex flex-col gap-2 text-center sm:text-left",t),...e})}function Ile({className:t,showCloseButton:e=!1,children:n,...r}){return d.jsxs("div",{"data-slot":"dialog-footer",className:Z("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...r,children:[n,e&&d.jsx(ab,{asChild:!0,children:d.jsx(Oe,{variant:"outline",children:"Close"})})]})}function k8({className:t,...e}){return d.jsx(eS,{"data-slot":"dialog-title",className:Z("text-lg leading-none font-semibold",t),...e})}function jle({className:t,...e}){return d.jsx(WO,{"data-slot":"dialog-description",className:Z("text-muted-foreground text-sm",t),...e})}const Mle=JS("inline-flex items-center justify-center rounded-full border border-transparent px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function PPe({className:t,variant:e="default",asChild:n=!1,...r}){const i=n?z_:"span";return d.jsx(i,{"data-slot":"badge","data-variant":e,className:Z(Mle({variant:e}),t),...r})}function C8({className:t,...e}){return d.jsx("div",{"data-slot":"card",className:Z("bg-card text-card-foreground flex flex-col gap-6 border py-6 shadow-sm",t),...e})}function _8({className:t,...e}){return d.jsx("div",{"data-slot":"card-header",className:Z("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...e})}function S8({className:t,...e}){return d.jsx("div",{"data-slot":"card-title",className:Z("leading-none font-semibold",t),...e})}function E8({className:t,...e}){return d.jsx("div",{"data-slot":"card-description",className:Z("text-muted-foreground text-sm",t),...e})}function T8({className:t,...e}){return d.jsx("div",{"data-slot":"card-content",className:Z("px-6",t),...e})}function OPe({className:t,...e}){return d.jsx("div",{"data-slot":"card-footer",className:Z("flex items-center px-6 [.border-t]:pt-6",t),...e})}const Rle={get:async()=>{const t=await fetch("/api/health",{credentials:"include",headers:{Accept:"application/json"}});if(!t.ok){const e=await t.json().catch(()=>null);throw new Error((e==null?void 0:e.error)??`Failed to load health (${t.status})`)}return t.json()}},LPe={getProfile:()=>re.get("/gtm/profile"),getKnowledge:()=>re.get("/gtm/knowledge"),getConnectors:()=>re.get("/gtm/connectors"),getConnection:()=>re.get("/gtm/connection"),saveConnectionConfig:t=>re.post("/gtm/connection/config",t),testConnection:()=>re.post("/gtm/connection/test",{}),disconnectConnection:()=>re.post("/gtm/connection/disconnect",{}),getWorkflow:()=>re.get("/gtm/workflow"),launchWorkflow:()=>re.post("/gtm/workflow/run",{}),listAgents:t=>re.get(`/gtm/companies/${t}/agents`),createAgent:(t,e)=>re.post(`/gtm/companies/${t}/agents`,e),invokeAgent:(t,e)=>re.post(`/gtm/agents/${t}/invoke?companyId=${encodeURIComponent(e)}`,{}),pauseAgent:(t,e)=>re.post(`/gtm/agents/${t}/pause?companyId=${encodeURIComponent(e)}`,{}),resumeAgent:(t,e)=>re.post(`/gtm/agents/${t}/resume?companyId=${encodeURIComponent(e)}`,{}),listTickets:t=>re.get(`/gtm/companies/${t}/tickets`),createTicket:(t,e)=>re.post(`/gtm/companies/${t}/tickets`,e),createCampaignDraft:(t,e)=>re.post(`/gtm/companies/${t}/campaign-drafts`,e),listIssues:t=>re.get(`/gtm/companies/${t}/issues`),createIssue:(t,e)=>re.post(`/gtm/companies/${t}/issues`,e),listInbox:t=>re.get(`/gtm/companies/${t}/inbox`),listRuns:t=>re.get(`/gtm/companies/${t}/runs`),enforceHeartbeat:(t,e)=>re.post(`/gtm/companies/${t}/campaigns/${e}/heartbeat`,{}),triggerPerformanceReview:(t,e)=>re.post(`/gtm/companies/${t}/campaigns/${e}/performance-review`,{}),getWorkspaceConfig:t=>re.get(`/gtm/companies/${t}/workspace-config`),upsertWorkspaceClaudeBrowser:(t,e)=>re.post(`/gtm/companies/${t}/workspace-config/claude-browser`,e),listKnowledgeTables:()=>re.get("/gtm/knowledge-base/tables"),getKnowledgeTable:(t,e)=>re.get(`/gtm/knowledge-base/tables/${encodeURIComponent(t)}${e?`?limit=${e.limit??50}&offset=${e.offset??0}`:""}`),createKnowledgeTable:(t,e)=>re.post("/gtm/knowledge-base/tables",{name:t,columns:e}),executeKnowledgeQuery:t=>re.post("/gtm/knowledge-base/query",{query:t})},N8={uploadImage:async(t,e,n)=>{const r=await e.arrayBuffer(),i=new File([r],e.name,{type:e.type}),s=new FormData;return n&&n.trim().length>0&&s.append("namespace",n.trim()),s.append("file",i),re.postForm(`/companies/${t}/assets/images`,s)},uploadCompanyLogo:async(t,e)=>{const n=await e.arrayBuffer(),r=new File([n],e.name,{type:e.type}),i=new FormData;return i.append("file",r),re.postForm(`/companies/${t}/logo`,i)}};function Ple(t,e){if(!e)return t;const n=t.includes("?")?"&":"?";return`${t}${n}companyId=${encodeURIComponent(e)}`}function Un(t,e,n=""){return Ple(`/agents/${encodeURIComponent(t)}${n}`,e)}const Gt={list:t=>re.get(`/companies/${t}/agents`),org:t=>re.get(`/companies/${t}/org`),listConfigurations:t=>re.get(`/companies/${t}/agent-configurations`),get:async(t,e)=>{try{return await re.get(Un(t,e))}catch(n){if(!(n instanceof Pf)||n.status!==409||!e||F6(t))throw n;const r=Ay(t);if(!r)throw n;const s=(await re.get(`/companies/${e}/agents`)).filter(o=>o.status!=="terminated"&&Ay(o.urlKey)===r);if(s.length!==1)throw n;return re.get(Un(s[0].id,e))}},getConfiguration:(t,e)=>re.get(Un(t,e,"/configuration")),listConfigRevisions:(t,e)=>re.get(Un(t,e,"/config-revisions")),getConfigRevision:(t,e,n)=>re.get(Un(t,n,`/config-revisions/${e}`)),rollbackConfigRevision:(t,e,n)=>re.post(Un(t,n,`/config-revisions/${e}/rollback`),{}),create:(t,e)=>re.post(`/companies/${t}/agents`,e),hire:(t,e)=>re.post(`/companies/${t}/agent-hires`,e),update:(t,e,n)=>re.patch(Un(t,n),e),updatePermissions:(t,e,n)=>re.patch(Un(t,n,"/permissions"),e),pause:(t,e)=>re.post(Un(t,e,"/pause"),{}),resume:(t,e)=>re.post(Un(t,e,"/resume"),{}),terminate:(t,e)=>re.post(Un(t,e,"/terminate"),{}),remove:(t,e)=>re.delete(Un(t,e)),listKeys:(t,e)=>re.get(Un(t,e,"/keys")),createKey:(t,e,n)=>re.post(Un(t,n,"/keys"),{name:e}),revokeKey:(t,e,n)=>re.delete(Un(t,n,`/keys/${encodeURIComponent(e)}`)),runtimeState:(t,e)=>re.get(Un(t,e,"/runtime-state")),taskSessions:(t,e)=>re.get(Un(t,e,"/task-sessions")),resetSession:(t,e,n)=>re.post(Un(t,n,"/runtime-state/reset-session"),{taskKey:e??null}),adapterModels:(t,e)=>re.get(`/companies/${encodeURIComponent(t)}/adapters/${encodeURIComponent(e)}/models`),testEnvironment:(t,e,n)=>re.post(`/companies/${t}/adapters/${e}/test-environment`,n),invoke:(t,e)=>re.post(Un(t,e,"/heartbeat/invoke"),{}),wakeup:(t,e,n)=>re.post(Un(t,n,"/wakeup"),e),loginWithClaude:(t,e)=>re.post(Un(t,e,"/claude-login"),{}),availableSkills:()=>re.get("/skills/available")},bd={createCompanyInvite:(t,e={})=>re.post(`/companies/${t}/invites`,e),createOpenClawInvitePrompt:(t,e={})=>re.post(`/companies/${t}/openclaw/invite-prompt`,e),getInvite:t=>re.get(`/invites/${t}`),getInviteOnboarding:t=>re.get(`/invites/${t}/onboarding`),acceptInvite:(t,e)=>re.post(`/invites/${t}/accept`,e),listJoinRequests:(t,e="pending_approval")=>re.get(`/companies/${t}/join-requests?status=${e}`),approveJoinRequest:(t,e)=>re.post(`/companies/${t}/join-requests/${e}/approve`,{}),rejectJoinRequest:(t,e)=>re.post(`/companies/${t}/join-requests/${e}/reject`,{}),claimJoinRequestApiKey:(t,e)=>re.post(`/join-requests/${t}/claim-api-key`,{claimSecret:e}),getBoardClaimStatus:(t,e)=>re.get(`/board-claim/${t}?code=${encodeURIComponent(e)}`),claimBoard:(t,e)=>re.post(`/board-claim/${t}/claim`,{code:e})},$r={list:(t,e,n)=>{const r=new URLSearchParams;e&&r.set("agentId",e),n&&r.set("limit",String(n));const i=r.toString();return re.get(`/companies/${t}/heartbeat-runs${i?`?${i}`:""}`)},get:t=>re.get(`/heartbeat-runs/${t}`),events:(t,e=0,n=200)=>re.get(`/heartbeat-runs/${t}/events?afterSeq=${encodeURIComponent(String(e))}&limit=${encodeURIComponent(String(n))}`),log:(t,e=0,n=256e3)=>re.get(`/heartbeat-runs/${t}/log?offset=${encodeURIComponent(String(e))}&limitBytes=${encodeURIComponent(String(n))}`),workspaceOperations:t=>re.get(`/heartbeat-runs/${t}/workspace-operations`),workspaceOperationLog:(t,e=0,n=256e3)=>re.get(`/workspace-operations/${t}/log?offset=${encodeURIComponent(String(e))}&limitBytes=${encodeURIComponent(String(n))}`),cancel:t=>re.post(`/heartbeat-runs/${t}/cancel`,{}),liveRunsForIssue:t=>re.get(`/issues/${t}/live-runs`),activeRunForIssue:t=>re.get(`/issues/${t}/active-run`),liveRunsForCompany:(t,e)=>re.get(`/companies/${t}/live-runs${e?`?minCount=${e}`:""}`),listInstanceSchedulerAgents:()=>re.get("/instance/scheduler-heartbeats")};function A8(t){var n,r;const e=t.split("/").filter(Boolean);return e.length===1?((n=e[0])==null?void 0:n.toLowerCase())==="onboarding":e.length===2?((r=e[1])==null?void 0:r.toLowerCase())==="onboarding":!1}function Ole(t){const{pathname:e,companyPrefix:n,companies:r}=t;if(!A8(e))return null;if(!n)return{initialStep:1};const i=r.find(s=>s.issuePrefix.toUpperCase()===n.toUpperCase())??null;return i?{initialStep:2,companyId:i.id}:{initialStep:1}}function DPe(t){return!t.hasCompanies&&!A8(t.pathname)}const IA=[" ",".","·","▪","▫","○"],Lle=24,Dle=1e3/Lle,Eg=[[" ╭────╮ "," ╭╯╭──╮│ "," │ │ ││ "," │ │ ││ "," │ │ ││ "," │ │ ││ "," │ ╰──╯│ "," ╰─────╯ "],[" ╭─────╮ "," │╭──╮╰╮ "," ││ │ │ "," ││ │ │ "," ││ │ │ "," ││ │ │ "," │╰──╯ │ "," ╰────╯ "]];function jA(t){const e=document.createElement("span");e.textContent="M",e.style.cssText="position:absolute;visibility:hidden;white-space:pre;font-size:11px;font-family:monospace;line-height:1;",t.appendChild(e);const n=e.getBoundingClientRect();return t.removeChild(e),{w:n.width,h:n.height}}function Fle(t){let e=0;for(const n of t)e=Math.max(e,n.length);return{width:e,height:t.length}}function I8(){const t=x.useRef(null),e=x.useRef(null);return x.useEffect(()=>{if(!t.current)return;const n=t.current,r=window.matchMedia("(prefers-reduced-motion: reduce)");let i=document.visibilityState!=="hidden",s=!1,o=0,a=0,l=0,c=0,u=7,f=11,h=new Float32Array(0),p=new Float32Array(0),m=new Float32Array(0),g=new Uint16Array(0),b=[],v="";function y(R){const M=Math.max(0,Math.min(.999,R)),F=Math.floor(M*IA.length);return IA[F]??" "}function w(){const R=Math.max(0,Math.ceil(n.clientWidth/Math.max(1,u))),M=Math.max(0,Math.ceil(n.clientHeight/Math.max(1,f)));if(R===l&&M===c)return;l=R,c=M;const F=l*c;h=new Float32Array(F),p=new Float32Array(l),m=new Float32Array(c),g=new Uint16Array(F),b=b.filter(q=>q.x>-q.width-2&&q.x<l+2&&q.y>-q.height-2&&q.y<c+2),v=""}function k(){if(l<=0||c<=0){n.textContent="";return}const R=Array.from({length:c},()=>Array.from({length:l},()=>" "));for(let z=0;z<c;z++)for(let D=0;D<l;D++){const W=(Math.sin(D*.11+z*.04)+Math.cos(z*.08-D*.02))*.18+.22;R[z][D]=y(W)}const M=18,F=13;for(let z=1;z<c-9;z+=F){const D=Math.floor(z/F)%2===0?2:10;for(let W=D;W<l-10;W+=M){const N=Eg[(W+z)%Eg.length];for(let $=0;$<N.length;$++){const X=N[$];for(let L=0;L<X.length;L++){const te=X[L]??" ";if(te===" ")continue;const ye=z+$,le=W+L;ye<0||ye>=c||le<0||le>=l||(R[ye][le]=te)}}}}const q=R.map(z=>z.join("")).join(`
677
677
  `);n.textContent=q,v=q}function C(){const R=Eg[Math.floor(Math.random()*Eg.length)],M=Fle(R),F=Math.random();let q=0,z=0,D=0,W=0;F<.68?(q=Math.random()<.5?-M.width-1:l+1,z=Math.random()*Math.max(1,c-M.height),D=q<0?.04+Math.random()*.05:-(.04+Math.random()*.05),W=(Math.random()-.5)*.014):(q=Math.random()*Math.max(1,l-M.width),z=Math.random()<.5?-M.height-1:c+1,D=(Math.random()-.5)*.014,W=z<0?.028+Math.random()*.034:-(.028+Math.random()*.034)),b.push({x:q,y:z,vx:D,vy:W,life:0,maxLife:260+Math.random()*220,drift:(Math.random()-.5)*1.2,sprite:R,width:M.width,height:M.height})}function _(R,M){const F=Math.round(R.x),q=Math.round(R.y);for(let z=0;z<R.sprite.length;z++){const D=R.sprite[z],W=q+z;if(!(W<0||W>=c))for(let N=0;N<D.length;N++){const $=D[N]??" ";if($===" ")continue;const X=F+N;if(X<0||X>=l)continue;const L=W*l+X,te=$==="│"||$==="─"?.8:.92;h[L]=Math.max(h[L]??0,M*te),g[L]=$.charCodeAt(0)}}}function E(R){if(!s||(e.current=requestAnimationFrame(E),R-o<Dle||l<=0||c<=0))return;const M=Math.min(2,o===0?1:(R-o)/16.6667);o=R,a+=M;const F=l*c,q=Math.max(3,Math.floor(F/2200));for(;b.length<q;)C();for(let D=0;D<h.length;D++)h[D]*=.92;g.fill(0);for(let D=b.length-1;D>=0;D--){const W=b[D];W.life+=M;const N=Math.sin((W.y+W.drift+a*.12)*.09)*.0018,$=Math.cos((W.x-W.drift-a*.09)*.08)*.0014;if(W.vx=(W.vx+N)*.998,W.vy=(W.vy+$)*.998,W.x+=W.vx*M,W.y+=W.vy*M,W.life>=W.maxLife||W.x<-W.width-2||W.x>l+2||W.y<-W.height-2||W.y>c+2){b.splice(D,1);continue}const X=W.life/W.maxLife,L=X<.12?X/.12:X>.88?(1-X)/.12:1;_(W,L)}for(let D=0;D<l;D++)p[D]=Math.sin(D*.08+a*.06);for(let D=0;D<c;D++)m[D]=Math.cos(D*.1-a*.05);let z="";for(let D=0;D<c;D++){for(let W=0;W<l;W++){const N=D*l+W,$=g[N];if($>0){z+=String.fromCharCode($);continue}const X=(p[W]+m[D])*.08+.1,L=Math.max(h[N]??0,X*.45);z+=y(L)}D<c-1&&(z+=`
678
- `)}z!==v&&(n.textContent=z,v=z)}function S(){const R=l>0&&c>0;if(r.matches){s&&(s=!1,e.current!==null&&cancelAnimationFrame(e.current),e.current=null),R&&k();return}if(!i||!R){s&&(s=!1,e.current!==null&&cancelAnimationFrame(e.current),e.current=null);return}s||(s=!0,o=0,e.current=requestAnimationFrame(E))}const T=new ResizeObserver(()=>{const R=jA(n);u=R.w,f=R.h,w(),S()});T.observe(n);const A=()=>{i=document.visibilityState!=="hidden",S()};document.addEventListener("visibilitychange",A);const P=()=>{S()};r.addEventListener("change",P);const O=jA(n);return u=O.w,f=O.h,w(),S(),()=>{s=!1,e.current!==null&&cancelAnimationFrame(e.current),T.disconnect(),document.removeEventListener("visibilitychange",A),r.removeEventListener("change",P)}},[]),d.jsx("pre",{ref:t,className:"w-full h-full m-0 p-0 overflow-hidden text-muted-foreground/60 select-none leading-none",style:{fontSize:"11px",fontFamily:"monospace"},"aria-hidden":"true"})}function FPe(){const t=ur(),e=Ru(),[n]=W4(),[r,i]=x.useState("sign_in"),[s,o]=x.useState(""),[a,l]=x.useState(""),[c,u]=x.useState(""),[f,h]=x.useState(null),p=x.useMemo(()=>n.get("next")||"/",[n]),{data:m,isLoading:g}=st({queryKey:ie.auth.session,queryFn:()=>Ds.getSession(),retry:!1});x.useEffect(()=>{m&&e(p,{replace:!0})},[m,e,p]);const b=Bt({mutationFn:async()=>{if(r==="sign_in"){await Ds.signInEmail({email:a.trim(),password:c});return}await Ds.signUpEmail({name:s.trim(),email:a.trim(),password:c})},onSuccess:async()=>{h(null),await t.invalidateQueries({queryKey:ie.auth.session}),await t.invalidateQueries({queryKey:ie.companies.all}),e(p,{replace:!0})},onError:y=>{h(y instanceof Error?y.message:"Authentication failed")}}),v=a.trim().length>0&&c.trim().length>0&&(r==="sign_in"||s.trim().length>0&&c.trim().length>=8);return g?d.jsx("div",{className:"fixed inset-0 flex items-center justify-center",children:d.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"})}):d.jsxs("div",{className:"fixed inset-0 flex bg-background",children:[d.jsx("div",{className:"w-full md:w-1/2 flex flex-col overflow-y-auto",children:d.jsxs("div",{className:"w-full max-w-md mx-auto my-auto px-8 py-12",children:[d.jsxs("div",{className:"flex items-center gap-2 mb-8",children:[d.jsx(n5,{className:"h-4 w-4 text-muted-foreground"}),d.jsx("span",{className:"text-sm font-medium",children:"Growthub"})]}),d.jsx("h1",{className:"text-xl font-semibold",children:r==="sign_in"?"Sign in to Growthub":"Create your Growthub account"}),d.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:r==="sign_in"?"Use your email and password to access this instance.":"Create an account for this instance. Email confirmation is not required in v1."}),d.jsxs("form",{className:"mt-6 space-y-4",onSubmit:y=>{if(y.preventDefault(),!b.isPending){if(!v){h("Please fill in all required fields.");return}b.mutate()}},children:[r==="sign_up"&&d.jsxs("div",{children:[d.jsx("label",{className:"text-xs text-muted-foreground mb-1 block",children:"Name"}),d.jsx("input",{className:"w-full rounded-md border border-border bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50",value:s,onChange:y=>o(y.target.value),autoComplete:"name",autoFocus:!0})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-xs text-muted-foreground mb-1 block",children:"Email"}),d.jsx("input",{className:"w-full rounded-md border border-border bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50",type:"email",value:a,onChange:y=>l(y.target.value),autoComplete:"email",autoFocus:r==="sign_in"})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-xs text-muted-foreground mb-1 block",children:"Password"}),d.jsx("input",{className:"w-full rounded-md border border-border bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50",type:"password",value:c,onChange:y=>u(y.target.value),autoComplete:r==="sign_in"?"current-password":"new-password"})]}),f&&d.jsx("p",{className:"text-xs text-destructive",children:f}),d.jsx(Oe,{type:"submit",disabled:b.isPending,"aria-disabled":!v||b.isPending,className:`w-full ${!v&&!b.isPending?"opacity-50":""}`,children:b.isPending?"Working…":r==="sign_in"?"Sign In":"Create Account"})]}),d.jsxs("div",{className:"mt-5 text-sm text-muted-foreground",children:[r==="sign_in"?"Need an account?":"Already have an account?"," ",d.jsx("button",{type:"button",className:"font-medium text-foreground underline underline-offset-2",onClick:()=>{h(null),i(r==="sign_in"?"sign_up":"sign_in")},children:r==="sign_in"?"Create one":"Sign in"})]})]})}),d.jsx("div",{className:"hidden md:block w-1/2 overflow-hidden",children:d.jsx(I8,{})})]})}function $Pe(){const t=ur(),e=Mf(),[n]=W4(),r=(e.token??"").trim(),i=(n.get("code")??"").trim(),s=x.useMemo(()=>`/board-claim/${encodeURIComponent(r)}${i?`?code=${encodeURIComponent(i)}`:""}`,[r,i]),o=st({queryKey:ie.auth.session,queryFn:()=>Ds.getSession(),retry:!1}),a=st({queryKey:["board-claim",r,i],queryFn:()=>bd.getBoardClaimStatus(r,i),enabled:r.length>0&&i.length>0,retry:!1}),l=Bt({mutationFn:()=>bd.claimBoard(r,i),onSuccess:async()=>{await t.invalidateQueries({queryKey:ie.auth.session}),await t.invalidateQueries({queryKey:ie.health}),await t.invalidateQueries({queryKey:ie.companies.all}),await t.invalidateQueries({queryKey:ie.companies.stats}),await a.refetch()}});if(!r||!i)return d.jsx("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Invalid board claim URL."});if(a.isLoading||o.isLoading)return d.jsx("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading claim challenge..."});if(a.error)return d.jsx("div",{className:"mx-auto max-w-xl py-10",children:d.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[d.jsx("h1",{className:"text-lg font-semibold",children:"Claim challenge unavailable"}),d.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:a.error instanceof Error?a.error.message:"Challenge is invalid or expired."})]})});const c=a.data;return c?c.status==="claimed"?d.jsx("div",{className:"mx-auto max-w-xl py-10",children:d.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[d.jsx("h1",{className:"text-lg font-semibold",children:"Board ownership claimed"}),d.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"This instance is now linked to your authenticated user."}),d.jsx(Oe,{asChild:!0,className:"mt-4",children:d.jsx(Ut,{to:"/",children:"Open board"})})]})}):o.data?d.jsx("div",{className:"mx-auto max-w-xl py-10",children:d.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[d.jsx("h1",{className:"text-xl font-semibold",children:"Claim Board ownership"}),d.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"This will promote your user to instance admin and migrate company ownership access from local trusted mode."}),l.error&&d.jsx("p",{className:"mt-3 text-sm text-destructive",children:l.error instanceof Error?l.error.message:"Failed to claim board ownership"}),d.jsx(Oe,{className:"mt-5",onClick:()=>l.mutate(),disabled:l.isPending,children:l.isPending?"Claiming…":"Claim ownership"})]})}):d.jsx("div",{className:"mx-auto max-w-xl py-10",children:d.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[d.jsx("h1",{className:"text-lg font-semibold",children:"Sign in required"}),d.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Sign in or create an account, then return to this page to claim Board ownership."}),d.jsx(Oe,{asChild:!0,className:"mt-4",children:d.jsx(Ut,{to:`/auth?next=${encodeURIComponent(s)}`,children:"Sign in / Create account"})})]})}):d.jsx("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Claim challenge unavailable."})}const $le=[...Nm],Ble={claude_local:"Claude (local)",codex_local:"Codex (local)",gemini_local:"Gemini CLI (local)",opencode_local:"OpenCode (local)",openclaw_gateway:"OpenClaw Gateway",cursor:"Cursor (local)",process:"Process",http:"HTTP"},MA=new Set(["claude_local","codex_local","gemini_local","opencode_local","cursor"]);function Vle(t){return new Date(t).toLocaleString()}function lh(t,e){let n=t;for(const r of e){if(!n||typeof n!="object")return null;n=n[r]}return typeof n=="string"&&n.trim().length>0?n:null}function BPe(){var E;const t=ur(),n=(Mf().token??"").trim(),[r,i]=x.useState("human"),[s,o]=x.useState(""),[a,l]=x.useState("claude_local"),[c,u]=x.useState(""),[f,h]=x.useState(null),[p,m]=x.useState(null),g=st({queryKey:ie.health,queryFn:()=>Rle.get(),retry:!1}),b=st({queryKey:ie.auth.session,queryFn:()=>Ds.getSession(),retry:!1}),v=st({queryKey:ie.access.invite(n),queryFn:()=>bd.getInvite(n),enabled:n.length>0,retry:!1}),y=v.data,w=(y==null?void 0:y.allowedJoinTypes)??"both",k=x.useMemo(()=>(y==null?void 0:y.inviteType)==="bootstrap_ceo"?["human"]:w==="both"?["human","agent"]:[w],[y==null?void 0:y.inviteType,w]);x.useEffect(()=>{k.includes(r)||i(k[0]??"human")},[k,r]);const C=r==="human"&&((E=g.data)==null?void 0:E.deploymentMode)==="authenticated"&&!b.data,_=Bt({mutationFn:async()=>{if(!y)throw new Error("Invite not found");return y.inviteType==="bootstrap_ceo"?bd.acceptInvite(n,{requestType:"human"}):r==="human"?bd.acceptInvite(n,{requestType:"human"}):bd.acceptInvite(n,{requestType:"agent",agentName:s.trim(),adapterType:a,capabilities:c.trim()||null})},onSuccess:async S=>{m(null),await t.invalidateQueries({queryKey:ie.auth.session}),await t.invalidateQueries({queryKey:ie.companies.all});const T=S&&typeof S=="object"&&"bootstrapAccepted"in S;h({kind:T?"bootstrap":"join",payload:S})},onError:S=>{m(S instanceof Error?S.message:"Failed to accept invite")}});if(!n)return d.jsx("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Invalid invite token."});if(v.isLoading||g.isLoading||b.isLoading)return d.jsx("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading invite..."});if(v.error||!y)return d.jsx("div",{className:"mx-auto max-w-xl py-10",children:d.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[d.jsx("h1",{className:"text-lg font-semibold",children:"Invite not available"}),d.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"This invite may be expired, revoked, or already used."})]})});if((f==null?void 0:f.kind)==="bootstrap")return d.jsx("div",{className:"mx-auto max-w-xl py-10",children:d.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[d.jsx("h1",{className:"text-lg font-semibold",children:"Bootstrap complete"}),d.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"The first instance admin is now configured. You can continue to the board."}),d.jsx(Oe,{asChild:!0,className:"mt-4",children:d.jsx(Ut,{to:"/",children:"Open board"})})]})});if((f==null?void 0:f.kind)==="join"){const S=f.payload,T=typeof S.claimSecret=="string"?S.claimSecret:null,A=typeof S.claimApiKeyPath=="string"?S.claimApiKeyPath:null,P=lh(S.onboarding,["skill","url"]),O=lh(S.onboarding,["skill","path"]),R=lh(S.onboarding,["skill","installPath"]),M=lh(S.onboarding,["textInstructions","url"]),F=lh(S.onboarding,["textInstructions","path"]),q=Array.isArray(S.diagnostics)?S.diagnostics:[];return d.jsx("div",{className:"mx-auto max-w-xl py-10",children:d.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[d.jsx("h1",{className:"text-lg font-semibold",children:"Join request submitted"}),d.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Your request is pending admin approval. You will not have access until approved."}),d.jsxs("div",{className:"mt-4 rounded-md border border-border bg-muted/30 p-3 text-xs text-muted-foreground",children:["Request ID: ",d.jsx("span",{className:"font-mono",children:S.id})]}),T&&A&&d.jsxs("div",{className:"mt-3 space-y-1 rounded-md border border-border bg-muted/30 p-3 text-xs text-muted-foreground",children:[d.jsx("p",{className:"font-medium text-foreground",children:"One-time claim secret (save now)"}),d.jsx("p",{className:"font-mono break-all",children:T}),d.jsxs("p",{className:"font-mono break-all",children:["POST ",A]})]}),(P||O||R)&&d.jsxs("div",{className:"mt-3 space-y-1 rounded-md border border-border bg-muted/30 p-3 text-xs text-muted-foreground",children:[d.jsx("p",{className:"font-medium text-foreground",children:"Growthub skill bootstrap"}),P&&d.jsxs("p",{className:"font-mono break-all",children:["GET ",P]}),!P&&O&&d.jsxs("p",{className:"font-mono break-all",children:["GET ",O]}),R&&d.jsxs("p",{className:"font-mono break-all",children:["Install to ",R]})]}),(M||F)&&d.jsxs("div",{className:"mt-3 space-y-1 rounded-md border border-border bg-muted/30 p-3 text-xs text-muted-foreground",children:[d.jsx("p",{className:"font-medium text-foreground",children:"Agent-readable onboarding text"}),M&&d.jsxs("p",{className:"font-mono break-all",children:["GET ",M]}),!M&&F&&d.jsxs("p",{className:"font-mono break-all",children:["GET ",F]})]}),q.length>0&&d.jsxs("div",{className:"mt-3 space-y-1 rounded-md border border-border bg-muted/30 p-3 text-xs text-muted-foreground",children:[d.jsx("p",{className:"font-medium text-foreground",children:"Connectivity diagnostics"}),q.map((z,D)=>d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("p",{className:z.level==="warn"?"text-amber-600 dark:text-amber-400":void 0,children:["[",z.level,"] ",z.message]}),z.hint&&d.jsx("p",{className:"font-mono break-all",children:z.hint})]},`${z.code}:${D}`))]})]})})}return d.jsx("div",{className:"mx-auto max-w-xl py-10",children:d.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[d.jsx("h1",{className:"text-xl font-semibold",children:y.inviteType==="bootstrap_ceo"?"Bootstrap your Growthub instance":"Join this Growthub company"}),d.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["Invite expires ",Vle(y.expiresAt),"."]}),y.inviteType!=="bootstrap_ceo"&&d.jsx("div",{className:"mt-5 flex gap-2",children:k.map(S=>d.jsxs("button",{type:"button",onClick:()=>i(S),className:`rounded-md border px-3 py-1.5 text-sm ${r===S?"border-foreground bg-foreground text-background":"border-border bg-background text-foreground"}`,children:["Join as ",S]},S))}),r==="agent"&&y.inviteType!=="bootstrap_ceo"&&d.jsxs("div",{className:"mt-4 space-y-3",children:[d.jsxs("label",{className:"block text-sm",children:[d.jsx("span",{className:"mb-1 block text-muted-foreground",children:"Agent name"}),d.jsx("input",{className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm",value:s,onChange:S=>o(S.target.value)})]}),d.jsxs("label",{className:"block text-sm",children:[d.jsx("span",{className:"mb-1 block text-muted-foreground",children:"Adapter type"}),d.jsx("select",{className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm",value:a,onChange:S=>l(S.target.value),children:$le.map(S=>d.jsxs("option",{value:S,disabled:!MA.has(S),children:[Ble[S],MA.has(S)?"":" (Coming soon)"]},S))})]}),d.jsxs("label",{className:"block text-sm",children:[d.jsx("span",{className:"mb-1 block text-muted-foreground",children:"Capabilities (optional)"}),d.jsx("textarea",{className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm",rows:4,value:c,onChange:S=>u(S.target.value)})]})]}),C&&d.jsxs("div",{className:"mt-4 rounded-md border border-border bg-muted/30 p-3 text-sm",children:["Sign in or create an account before submitting a human join request.",d.jsx("div",{className:"mt-2",children:d.jsx(Oe,{asChild:!0,size:"sm",variant:"outline",children:d.jsx(Ut,{to:`/auth?next=${encodeURIComponent(`/invite/${n}`)}`,children:"Sign in / Create account"})})})]}),p&&d.jsx("p",{className:"mt-3 text-sm text-destructive",children:p}),d.jsx(Oe,{className:"mt-5",disabled:_.isPending||r==="agent"&&y.inviteType!=="bootstrap_ceo"&&s.trim().length===0||C,onClick:()=>_.mutate(),children:_.isPending?"Submitting…":y.inviteType==="bootstrap_ceo"?"Accept bootstrap invite":"Submit join request"})]})})}function VPe({scope:t="global",requestedPrefix:e}){const n=Ur(),{setBreadcrumbs:r}=Am(),{companies:i,selectedCompany:s}=Ys();x.useEffect(()=>{r([{label:"Not Found"}])},[r]);const o=s??i[0]??null,a=o?`/${o.issuePrefix}/dashboard`:"/",l=`${n.pathname}${n.search}${n.hash}`,c=e==null?void 0:e.toUpperCase(),u=t==="invalid_company_prefix"?"Company not found":"Page not found",f=t==="invalid_company_prefix"?`No company matches prefix "${c??"unknown"}".`:"This route does not exist.";return d.jsx("div",{className:"mx-auto max-w-2xl py-10",children:d.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 p-2",children:d.jsx(Bb,{className:"h-5 w-5 text-destructive"})}),d.jsxs("div",{children:[d.jsx("h1",{className:"text-xl font-semibold",children:u}),d.jsx("p",{className:"text-sm text-muted-foreground",children:f})]})]}),d.jsxs("div",{className:"mt-4 rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:["Requested path: ",d.jsx("code",{className:"font-mono",children:l})]}),d.jsxs("div",{className:"mt-5 flex flex-wrap gap-2",children:[d.jsx(Oe,{asChild:!0,children:d.jsxs(Ut,{to:a,children:[d.jsx(goe,{className:"mr-1.5 h-4 w-4"}),"Open dashboard"]})}),d.jsx(Oe,{variant:"outline",asChild:!0,children:d.jsx(Ut,{to:"/",children:"Go home"})})]})]})})}const RA={overview:t=>re.get(`/companies/${t}/budgets/overview`),upsertPolicy:(t,e)=>re.post(`/companies/${t}/budgets/policies`,e),resolveIncident:(t,e,n)=>re.post(`/companies/${t}/budget-incidents/${encodeURIComponent(e)}/resolve`,n)};function zb(){return Array.from({length:14},(t,e)=>{const n=new Date;return n.setDate(n.getDate()-(13-e)),n.toISOString().slice(0,10)})}function zle(t){const e=new Date(t+"T12:00:00");return`${e.getMonth()+1}/${e.getDate()}`}function Hb({days:t}){return d.jsx("div",{className:"flex gap-[3px] mt-1.5",children:t.map((e,n)=>d.jsx("div",{className:"flex-1 text-center",children:n===0||n===6||n===13?d.jsx("span",{className:"text-[9px] text-muted-foreground tabular-nums",children:zle(e)}):null},e))})}function j8({items:t}){return d.jsx("div",{className:"flex flex-wrap gap-x-2.5 gap-y-0.5 mt-2",children:t.map(e=>d.jsxs("span",{className:"flex items-center gap-1 text-[9px] text-muted-foreground",children:[d.jsx("span",{className:"h-1.5 w-1.5 rounded-full shrink-0",style:{backgroundColor:e.color}}),e.label]},e.label))})}function Tg({title:t,subtitle:e,children:n}){return d.jsxs("div",{className:"border border-border rounded-lg p-4 space-y-3",children:[d.jsxs("div",{children:[d.jsx("h3",{className:"text-xs font-medium text-muted-foreground",children:t}),e&&d.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:e})]}),n]})}function Hle({runs:t}){const e=zb(),n=new Map;for(const s of e)n.set(s,{succeeded:0,failed:0,other:0});for(const s of t){const o=new Date(s.createdAt).toISOString().slice(0,10),a=n.get(o);a&&(s.status==="succeeded"?a.succeeded++:s.status==="failed"||s.status==="timed_out"?a.failed++:a.other++)}const r=Math.max(...Array.from(n.values()).map(s=>s.succeeded+s.failed+s.other),1);return Array.from(n.values()).some(s=>s.succeeded+s.failed+s.other>0)?d.jsxs("div",{children:[d.jsx("div",{className:"flex items-end gap-[3px] h-20",children:e.map(s=>{const o=n.get(s),a=o.succeeded+o.failed+o.other,l=a/r*100;return d.jsx("div",{className:"flex-1 h-full flex flex-col justify-end",title:`${s}: ${a} runs`,children:a>0?d.jsxs("div",{className:"flex flex-col-reverse gap-px overflow-hidden",style:{height:`${l}%`,minHeight:2},children:[o.succeeded>0&&d.jsx("div",{className:"bg-emerald-500",style:{flex:o.succeeded}}),o.failed>0&&d.jsx("div",{className:"bg-red-500",style:{flex:o.failed}}),o.other>0&&d.jsx("div",{className:"bg-neutral-500",style:{flex:o.other}})]}):d.jsx("div",{className:"bg-muted/30 rounded-sm",style:{height:2}})},s)})}),d.jsx(Hb,{days:e})]}):d.jsx("p",{className:"text-xs text-muted-foreground",children:"No runs yet"})}const PA={critical:"#ef4444",high:"#f97316",medium:"#eab308",low:"#6b7280"},OA=["critical","high","medium","low"];function Ule({issues:t}){const e=zb(),n=new Map;for(const s of e)n.set(s,{critical:0,high:0,medium:0,low:0});for(const s of t){const o=new Date(s.createdAt).toISOString().slice(0,10),a=n.get(o);a&&s.priority in a&&a[s.priority]++}const r=Math.max(...Array.from(n.values()).map(s=>Object.values(s).reduce((o,a)=>o+a,0)),1);return Array.from(n.values()).some(s=>Object.values(s).reduce((o,a)=>o+a,0)>0)?d.jsxs("div",{children:[d.jsx("div",{className:"flex items-end gap-[3px] h-20",children:e.map(s=>{const o=n.get(s),a=Object.values(o).reduce((c,u)=>c+u,0),l=a/r*100;return d.jsx("div",{className:"flex-1 h-full flex flex-col justify-end",title:`${s}: ${a} issues`,children:a>0?d.jsx("div",{className:"flex flex-col-reverse gap-px overflow-hidden",style:{height:`${l}%`,minHeight:2},children:OA.map(c=>o[c]>0?d.jsx("div",{style:{flex:o[c],backgroundColor:PA[c]}},c):null)}):d.jsx("div",{className:"bg-muted/30 rounded-sm",style:{height:2}})},s)})}),d.jsx(Hb,{days:e}),d.jsx(j8,{items:OA.map(s=>({color:PA[s],label:s.charAt(0).toUpperCase()+s.slice(1)}))})]}):d.jsx("p",{className:"text-xs text-muted-foreground",children:"No issues"})}const LA={todo:"#3b82f6",in_progress:"#8b5cf6",in_review:"#a855f7",done:"#10b981",blocked:"#ef4444",cancelled:"#6b7280",backlog:"#64748b"},Wle={todo:"To Do",in_progress:"In Progress",in_review:"In Review",done:"Done",blocked:"Blocked",cancelled:"Cancelled",backlog:"Backlog"};function Kle({issues:t}){const e=zb(),n=new Set,r=new Map;for(const a of e)r.set(a,{});for(const a of t){const l=new Date(a.createdAt).toISOString().slice(0,10),c=r.get(l);c&&(c[a.status]=(c[a.status]??0)+1,n.add(a.status))}const i=["todo","in_progress","in_review","done","blocked","cancelled","backlog"].filter(a=>n.has(a)),s=Math.max(...Array.from(r.values()).map(a=>Object.values(a).reduce((l,c)=>l+c,0)),1);return n.size>0?d.jsxs("div",{children:[d.jsx("div",{className:"flex items-end gap-[3px] h-20",children:e.map(a=>{const l=r.get(a),c=Object.values(l).reduce((f,h)=>f+h,0),u=c/s*100;return d.jsx("div",{className:"flex-1 h-full flex flex-col justify-end",title:`${a}: ${c} issues`,children:c>0?d.jsx("div",{className:"flex flex-col-reverse gap-px overflow-hidden",style:{height:`${u}%`,minHeight:2},children:i.map(f=>(l[f]??0)>0?d.jsx("div",{style:{flex:l[f],backgroundColor:LA[f]??"#6b7280"}},f):null)}):d.jsx("div",{className:"bg-muted/30 rounded-sm",style:{height:2}})},a)})}),d.jsx(Hb,{days:e}),d.jsx(j8,{items:i.map(a=>({color:LA[a]??"#6b7280",label:Wle[a]??a}))})]}):d.jsx("p",{className:"text-xs text-muted-foreground",children:"No issues"})}function qle({runs:t}){const e=zb(),n=new Map;for(const i of e)n.set(i,{succeeded:0,total:0});for(const i of t){const s=new Date(i.createdAt).toISOString().slice(0,10),o=n.get(s);o&&(o.total++,i.status==="succeeded"&&o.succeeded++)}return Array.from(n.values()).some(i=>i.total>0)?d.jsxs("div",{children:[d.jsx("div",{className:"flex items-end gap-[3px] h-20",children:e.map(i=>{const s=n.get(i),o=s.total>0?s.succeeded/s.total:0,a=s.total===0?void 0:o>=.8?"#10b981":o>=.5?"#eab308":"#ef4444";return d.jsx("div",{className:"flex-1 h-full flex flex-col justify-end",title:`${i}: ${s.total>0?Math.round(o*100):0}% (${s.succeeded}/${s.total})`,children:s.total>0?d.jsx("div",{style:{height:`${o*100}%`,minHeight:2,backgroundColor:a}}):d.jsx("div",{className:"bg-muted/30 rounded-sm",style:{height:2}})},i)})}),d.jsx(Hb,{days:e})]}):d.jsx("p",{className:"text-xs text-muted-foreground",children:"No runs yet"})}const tC={list:t=>re.get(`/companies/${t}/activity`),forIssue:t=>re.get(`/issues/${t}/activity`),runsForIssue:t=>re.get(`/issues/${t}/runs`),issuesForRun:t=>re.get(`/heartbeat-runs/${t}/issues`)},Tn={list:(t,e)=>{const n=new URLSearchParams;e!=null&&e.status&&n.set("status",e.status),e!=null&&e.projectId&&n.set("projectId",e.projectId),e!=null&&e.assigneeAgentId&&n.set("assigneeAgentId",e.assigneeAgentId),e!=null&&e.assigneeUserId&&n.set("assigneeUserId",e.assigneeUserId),e!=null&&e.touchedByUserId&&n.set("touchedByUserId",e.touchedByUserId),e!=null&&e.unreadForUserId&&n.set("unreadForUserId",e.unreadForUserId),e!=null&&e.labelId&&n.set("labelId",e.labelId),e!=null&&e.q&&n.set("q",e.q);const r=n.toString();return re.get(`/companies/${t}/issues${r?`?${r}`:""}`)},listLabels:t=>re.get(`/companies/${t}/labels`),createLabel:(t,e)=>re.post(`/companies/${t}/labels`,e),deleteLabel:t=>re.delete(`/labels/${t}`),get:t=>re.get(`/issues/${t}`),markRead:t=>re.post(`/issues/${t}/read`,{}),create:(t,e)=>re.post(`/companies/${t}/issues`,e),update:(t,e)=>re.patch(`/issues/${t}`,e),remove:t=>re.delete(`/issues/${t}`),checkout:(t,e)=>re.post(`/issues/${t}/checkout`,{agentId:e,expectedStatuses:["todo","backlog","blocked"]}),release:t=>re.post(`/issues/${t}/release`,{}),openLocal:t=>re.post(`/issues/${t}/open-local`,{}),listComments:t=>re.get(`/issues/${t}/comments`),addComment:(t,e,n,r)=>re.post(`/issues/${t}/comments`,{body:e,...n===void 0?{}:{reopen:n},...r===void 0?{}:{interrupt:r}}),listDocuments:t=>re.get(`/issues/${t}/documents`),getDocument:(t,e)=>re.get(`/issues/${t}/documents/${encodeURIComponent(e)}`),upsertDocument:(t,e,n)=>re.put(`/issues/${t}/documents/${encodeURIComponent(e)}`,n),listDocumentRevisions:(t,e)=>re.get(`/issues/${t}/documents/${encodeURIComponent(e)}/revisions`),deleteDocument:(t,e)=>re.delete(`/issues/${t}/documents/${encodeURIComponent(e)}`),listAttachments:t=>re.get(`/issues/${t}/attachments`),uploadAttachment:(t,e,n,r)=>{const i=new FormData;return i.append("file",n),r&&i.append("issueCommentId",r),re.postForm(`/companies/${t}/issues/${e}/attachments`,i)},deleteAttachment:t=>re.delete(`/attachments/${t}`),listApprovals:t=>re.get(`/issues/${t}/approvals`),linkApproval:(t,e)=>re.post(`/issues/${t}/approvals`,{approvalId:e}),unlinkApproval:(t,e)=>re.delete(`/issues/${t}/approvals/${e}`),listArchived:t=>re.get(`/companies/${t}/issues/archived`),bulkArchive:(t,e)=>re.post(`/companies/${t}/issues/bulk-archive`,{ids:e}),bulkRestore:(t,e)=>re.post(`/companies/${t}/issues/bulk-restore`,{ids:e}),listWorkProducts:t=>re.get(`/issues/${t}/work-products`),createWorkProduct:(t,e)=>re.post(`/issues/${t}/work-products`,e),updateWorkProduct:(t,e)=>re.patch(`/work-products/${t}`,e),deleteWorkProduct:t=>re.delete(`/work-products/${t}`)},DA={list:t=>re.get(`/companies/${t}/secrets`),providers:t=>re.get(`/companies/${t}/secret-providers`),create:(t,e)=>re.post(`/companies/${t}/secrets`,e),rotate:(t,e)=>re.post(`/secrets/${t}/rotate`,e),update:(t,e)=>re.patch(`/secrets/${t}`,e),remove:t=>re.delete(`/secrets/${t}`)},bp="gpt-5.3-codex",Py=!0,vp="auto",wp="auto";function ni({...t}){return d.jsx(Cb,{"data-slot":"popover",...t})}function ri({...t}){return d.jsx(dX,{"data-slot":"popover-trigger",...t})}function ii({className:t,align:e="center",sideOffset:n=4,disablePortal:r=!1,...i}){const s=d.jsx(SL,{"data-slot":"popover-content",align:e,sideOffset:n,className:Z("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...i});return r?s:d.jsx(_b,{children:s})}function nC(t){const e=t.trim();return e.includes("/")&&e.slice(0,e.indexOf("/")).trim()||null}function Kh(t,e="other"){return nC(t)??e}function M8(t){const e=t.trim();return e.includes("/")?e.slice(e.indexOf("/")+1).trim():e}const Yt={name:"Display name for this agent.",title:"Job title shown in the org chart.",capabilities:"Describes what this agent can do. Shown in the org chart and used for task routing.",adapterType:"How this agent runs: local CLI (Claude/Codex/OpenCode), OpenClaw Gateway, spawned process, or generic HTTP webhook.",cwd:"Default working directory fallback for local adapters. Use an absolute path on the machine running Growthub.",promptTemplate:"Sent on every heartbeat. Keep this small and dynamic. Use it for current-task framing, not large static instructions. Supports {{ agent.id }}, {{ agent.name }}, {{ agent.role }} and other template variables.",model:"Override the default model used by the adapter.",thinkingEffort:"Control model reasoning depth. Supported values vary by adapter/model.",chrome:"Enable Claude's Chrome integration by passing --chrome.",dangerouslySkipPermissions:"Run Claude without permission prompts. Required for unattended operation.",dangerouslyBypassSandbox:"Run Codex without sandbox restrictions. Required for filesystem/network access.",search:"Enable Codex web search capability during runs.",maxTurnsPerRun:"Maximum number of agentic turns (tool calls) per heartbeat run.",command:"The command to execute (e.g. node, python).",localCommand:"Override the path to the CLI command you want the adapter to call (e.g. /usr/local/bin/claude, codex, opencode).",args:"Command-line arguments, comma-separated.",extraArgs:"Extra CLI arguments for local adapters, comma-separated.",envVars:"Environment variables injected into the adapter process. Use plain values or secret references.",bootstrapPrompt:"Only sent when Growthub starts a fresh session. Use this for stable setup guidance that should not be repeated on every heartbeat.",payloadTemplateJson:"Optional JSON merged into remote adapter request payloads before Growthub adds its standard wake and workspace fields.",webhookUrl:"The URL that receives POST requests when the agent is invoked.",heartbeatInterval:"Run this agent automatically on a timer. Useful for periodic tasks like checking for new work.",intervalSec:"Seconds between automatic heartbeat invocations.",timeoutSec:"Maximum seconds a run can take before being terminated. 0 means no timeout.",graceSec:"Seconds to wait after sending interrupt before force-killing the process.",wakeOnDemand:"Allow this agent to be woken by assignments, API calls, UI actions, or automated systems.",cooldownSec:"Minimum seconds between consecutive heartbeat runs.",maxConcurrentRuns:"Maximum number of heartbeat runs that can execute simultaneously for this agent."},R8={claude_local:"Claude (local)",codex_local:"Codex (local)",gemini_local:"Gemini CLI (local)",opencode_local:"OpenCode (local)",openclaw_gateway:"OpenClaw Gateway",cursor:"Cursor (local)",process:"Process",http:"HTTP"},Gle=m6;function kp({text:t}){return d.jsxs(sie,{children:[d.jsx(oie,{asChild:!0,children:d.jsx("button",{type:"button",className:"inline-flex text-muted-foreground/50 hover:text-muted-foreground transition-colors",children:d.jsx(ooe,{className:"h-3 w-3"})})}),d.jsx(aie,{side:"top",className:"max-w-xs",children:t})]})}function Et({label:t,hint:e,children:n}){return d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[d.jsx("label",{className:"text-xs text-muted-foreground",children:t}),e&&d.jsx(kp,{text:e})]}),n]})}function Cp({label:t,hint:e,checked:n,onChange:r}){return d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e&&d.jsx(kp,{text:e})]}),d.jsx("button",{className:Z("relative inline-flex h-5 w-9 items-center rounded-full transition-colors",n?"bg-green-600":"bg-muted"),onClick:()=>r(!n),children:d.jsx("span",{className:Z("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",n?"translate-x-4.5":"translate-x-0.5")})})]})}function FA({label:t,hint:e,checked:n,onCheckedChange:r,number:i,onNumberChange:s,numberLabel:o,numberHint:a,numberPrefix:l,showNumber:c}){return d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between gap-3",children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e&&d.jsx(kp,{text:e})]}),d.jsx("button",{className:Z("relative inline-flex h-5 w-9 items-center rounded-full transition-colors shrink-0",n?"bg-green-600":"bg-muted"),onClick:()=>r(!n),children:d.jsx("span",{className:Z("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",n?"translate-x-4.5":"translate-x-0.5")})})]}),c&&d.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[l&&d.jsx("span",{children:l}),d.jsx("input",{type:"number",className:"w-16 rounded-md border border-border px-2 py-0.5 bg-transparent outline-none text-xs font-mono text-center",value:i,onChange:u=>s(Number(u.target.value))}),d.jsx("span",{children:o}),a&&d.jsx(kp,{text:a})]})]})}function Jle({title:t,icon:e,open:n,onToggle:r,bordered:i,children:s}){return d.jsxs("div",{className:Z(i&&"border-t border-border"),children:[d.jsxs("button",{className:"flex items-center gap-2 w-full px-4 py-2 text-xs font-medium text-muted-foreground hover:bg-accent/30 transition-colors",onClick:r,children:[n?d.jsx(_i,{className:"h-3 w-3"}):d.jsx(Vi,{className:"h-3 w-3"}),e,t]}),n&&d.jsx("div",{className:"px-4 pb-3",children:s})]})}function Mn({value:t,onCommit:e,immediate:n,className:r,...i}){const[s,o]=x.useState(t);return x.useEffect(()=>o(t),[t]),d.jsx("input",{className:r,value:s,onChange:a=>{o(a.target.value),n&&e(a.target.value)},onBlur:()=>{s!==t&&e(s)},...i})}function Fh({value:t,onCommit:e,immediate:n,className:r,...i}){const[s,o]=x.useState(String(t));return x.useEffect(()=>o(String(t)),[t]),d.jsx("input",{type:"number",className:r,value:s,onChange:a=>{o(a.target.value),n&&e(Number(a.target.value)||0)},onBlur:()=>{const a=Number(s)||0;a!==t&&e(a)},...i})}const rC={adapterType:"claude_local",cwd:"",instructionsFilePath:"",promptTemplate:"",model:"",thinkingEffort:"",chrome:!1,dangerouslySkipPermissions:!0,search:!1,dangerouslyBypassSandbox:!1,command:"",args:"",extraArgs:"",envVars:"",envBindings:{},url:"",bootstrapPrompt:"",payloadTemplateJson:"",workspaceStrategyType:"project_primary",workspaceBaseRef:"",workspaceBranchTemplate:"",worktreeParentDir:"",runtimeServicesJson:"",maxTurnsPerRun:300,heartbeatEnabled:!1,intervalSec:300};function ul(t){return typeof t!="object"||t===null||Array.isArray(t)?null:t}function Ng(t){return typeof t=="number"&&Number.isFinite(t)?t:0}function Zle(t){if(typeof t=="string")return t;const e=ul(t);if(!e)return"";const n=typeof e.message=="string"&&e.message||typeof e.error=="string"&&e.error||typeof e.code=="string"&&e.code||"";if(n)return n;try{return JSON.stringify(e)}catch{return""}}function Yle(t){try{return JSON.parse(t)}catch{return null}}function Qle(t,e){const n=ul(Yle(t));if(!n)return[{kind:"stdout",ts:e,text:t}];const r=typeof n.type=="string"?n.type:"";if(r==="system"&&n.subtype==="init")return[{kind:"init",ts:e,model:typeof n.model=="string"?n.model:"unknown",sessionId:typeof n.session_id=="string"?n.session_id:""}];if(r==="assistant"){const i=ul(n.message)??{},s=Array.isArray(i.content)?i.content:[],o=[];for(const a of s){const l=ul(a);if(!l)continue;const c=typeof l.type=="string"?l.type:"";if(c==="text"){const u=typeof l.text=="string"?l.text:"";u&&o.push({kind:"assistant",ts:e,text:u})}else if(c==="thinking"){const u=typeof l.thinking=="string"?l.thinking:"";u&&o.push({kind:"thinking",ts:e,text:u})}else c==="tool_use"&&o.push({kind:"tool_call",ts:e,name:typeof l.name=="string"?l.name:"unknown",toolUseId:typeof l.id=="string"?l.id:typeof l.tool_use_id=="string"?l.tool_use_id:void 0,input:l.input??{}})}return o.length>0?o:[{kind:"stdout",ts:e,text:t}]}if(r==="user"){const i=ul(n.message)??{},s=Array.isArray(i.content)?i.content:[],o=[];for(const a of s){const l=ul(a);if(!l)continue;const c=typeof l.type=="string"?l.type:"";if(c==="text"){const u=typeof l.text=="string"?l.text:"";u&&o.push({kind:"user",ts:e,text:u})}else if(c==="tool_result"){const u=typeof l.tool_use_id=="string"?l.tool_use_id:"",f=l.is_error===!0;let h="";if(typeof l.content=="string")h=l.content;else if(Array.isArray(l.content)){const p=[];for(const m of l.content){const g=ul(m);g&&typeof g.text=="string"&&p.push(g.text)}h=p.join(`
678
+ `)}z!==v&&(n.textContent=z,v=z)}function S(){const R=l>0&&c>0;if(r.matches){s&&(s=!1,e.current!==null&&cancelAnimationFrame(e.current),e.current=null),R&&k();return}if(!i||!R){s&&(s=!1,e.current!==null&&cancelAnimationFrame(e.current),e.current=null);return}s||(s=!0,o=0,e.current=requestAnimationFrame(E))}const T=new ResizeObserver(()=>{const R=jA(n);u=R.w,f=R.h,w(),S()});T.observe(n);const A=()=>{i=document.visibilityState!=="hidden",S()};document.addEventListener("visibilitychange",A);const P=()=>{S()};r.addEventListener("change",P);const O=jA(n);return u=O.w,f=O.h,w(),S(),()=>{s=!1,e.current!==null&&cancelAnimationFrame(e.current),T.disconnect(),document.removeEventListener("visibilitychange",A),r.removeEventListener("change",P)}},[]),d.jsx("pre",{ref:t,className:"w-full h-full m-0 p-0 overflow-hidden text-muted-foreground/60 select-none leading-none",style:{fontSize:"11px",fontFamily:"monospace"},"aria-hidden":"true"})}function FPe(){const t=ur(),e=Ru(),[n]=W4(),[r,i]=x.useState("sign_in"),[s,o]=x.useState(""),[a,l]=x.useState(""),[c,u]=x.useState(""),[f,h]=x.useState(null),p=x.useMemo(()=>n.get("next")||"/",[n]),{data:m,isLoading:g}=st({queryKey:ie.auth.session,queryFn:()=>Ds.getSession(),retry:!1});x.useEffect(()=>{m&&e(p,{replace:!0})},[m,e,p]);const b=Bt({mutationFn:async()=>{if(r==="sign_in"){await Ds.signInEmail({email:a.trim(),password:c});return}await Ds.signUpEmail({name:s.trim(),email:a.trim(),password:c})},onSuccess:async()=>{h(null),await t.invalidateQueries({queryKey:ie.auth.session}),await t.invalidateQueries({queryKey:ie.companies.all}),e(p,{replace:!0})},onError:y=>{h(y instanceof Error?y.message:"Authentication failed")}}),v=a.trim().length>0&&c.trim().length>0&&(r==="sign_in"||s.trim().length>0&&c.trim().length>=8);return g?d.jsx("div",{className:"fixed inset-0 flex items-center justify-center",children:d.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"})}):d.jsxs("div",{className:"fixed inset-0 flex bg-background",children:[d.jsx("div",{className:"w-full md:w-1/2 flex flex-col overflow-y-auto",children:d.jsxs("div",{className:"w-full max-w-md mx-auto my-auto px-8 py-12",children:[d.jsxs("div",{className:"flex items-center gap-2 mb-8",children:[d.jsx(n5,{className:"h-4 w-4 text-muted-foreground"}),d.jsx("span",{className:"text-sm font-medium",children:"Growthub"})]}),d.jsx("h1",{className:"text-xl font-semibold",children:r==="sign_in"?"Sign in to Growthub":"Create your Growthub account"}),d.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:r==="sign_in"?"Use your email and password to access this instance.":"Create an account for this instance. Email confirmation is not required in v1."}),d.jsxs("form",{className:"mt-6 space-y-4",onSubmit:y=>{if(y.preventDefault(),!b.isPending){if(!v){h("Please fill in all required fields.");return}b.mutate()}},children:[r==="sign_up"&&d.jsxs("div",{children:[d.jsx("label",{className:"text-xs text-muted-foreground mb-1 block",children:"Name"}),d.jsx("input",{className:"w-full rounded-md border border-border bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50",value:s,onChange:y=>o(y.target.value),autoComplete:"name",autoFocus:!0})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-xs text-muted-foreground mb-1 block",children:"Email"}),d.jsx("input",{className:"w-full rounded-md border border-border bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50",type:"email",value:a,onChange:y=>l(y.target.value),autoComplete:"email",autoFocus:r==="sign_in"})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-xs text-muted-foreground mb-1 block",children:"Password"}),d.jsx("input",{className:"w-full rounded-md border border-border bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50",type:"password",value:c,onChange:y=>u(y.target.value),autoComplete:r==="sign_in"?"current-password":"new-password"})]}),f&&d.jsx("p",{className:"text-xs text-destructive",children:f}),d.jsx(Oe,{type:"submit",disabled:b.isPending,"aria-disabled":!v||b.isPending,className:`w-full ${!v&&!b.isPending?"opacity-50":""}`,children:b.isPending?"Working…":r==="sign_in"?"Sign In":"Create Account"})]}),d.jsxs("div",{className:"mt-5 text-sm text-muted-foreground",children:[r==="sign_in"?"Need an account?":"Already have an account?"," ",d.jsx("button",{type:"button",className:"font-medium text-foreground underline underline-offset-2",onClick:()=>{h(null),i(r==="sign_in"?"sign_up":"sign_in")},children:r==="sign_in"?"Create one":"Sign in"})]})]})}),d.jsx("div",{className:"hidden md:block w-1/2 overflow-hidden",children:d.jsx(I8,{})})]})}function $Pe(){const t=ur(),e=Mf(),[n]=W4(),r=(e.token??"").trim(),i=(n.get("code")??"").trim(),s=x.useMemo(()=>`/board-claim/${encodeURIComponent(r)}${i?`?code=${encodeURIComponent(i)}`:""}`,[r,i]),o=st({queryKey:ie.auth.session,queryFn:()=>Ds.getSession(),retry:!1}),a=st({queryKey:["board-claim",r,i],queryFn:()=>bd.getBoardClaimStatus(r,i),enabled:r.length>0&&i.length>0,retry:!1}),l=Bt({mutationFn:()=>bd.claimBoard(r,i),onSuccess:async()=>{await t.invalidateQueries({queryKey:ie.auth.session}),await t.invalidateQueries({queryKey:ie.health}),await t.invalidateQueries({queryKey:ie.companies.all}),await t.invalidateQueries({queryKey:ie.companies.stats}),await a.refetch()}});if(!r||!i)return d.jsx("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Invalid board claim URL."});if(a.isLoading||o.isLoading)return d.jsx("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading claim challenge..."});if(a.error)return d.jsx("div",{className:"mx-auto max-w-xl py-10",children:d.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[d.jsx("h1",{className:"text-lg font-semibold",children:"Claim challenge unavailable"}),d.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:a.error instanceof Error?a.error.message:"Challenge is invalid or expired."})]})});const c=a.data;return c?c.status==="claimed"?d.jsx("div",{className:"mx-auto max-w-xl py-10",children:d.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[d.jsx("h1",{className:"text-lg font-semibold",children:"Board ownership claimed"}),d.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"This instance is now linked to your authenticated user."}),d.jsx(Oe,{asChild:!0,className:"mt-4",children:d.jsx(Ut,{to:"/",children:"Open board"})})]})}):o.data?d.jsx("div",{className:"mx-auto max-w-xl py-10",children:d.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[d.jsx("h1",{className:"text-xl font-semibold",children:"Claim Board ownership"}),d.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"This will promote your user to instance admin and migrate company ownership access from local trusted mode."}),l.error&&d.jsx("p",{className:"mt-3 text-sm text-destructive",children:l.error instanceof Error?l.error.message:"Failed to claim board ownership"}),d.jsx(Oe,{className:"mt-5",onClick:()=>l.mutate(),disabled:l.isPending,children:l.isPending?"Claiming…":"Claim ownership"})]})}):d.jsx("div",{className:"mx-auto max-w-xl py-10",children:d.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[d.jsx("h1",{className:"text-lg font-semibold",children:"Sign in required"}),d.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Sign in or create an account, then return to this page to claim Board ownership."}),d.jsx(Oe,{asChild:!0,className:"mt-4",children:d.jsx(Ut,{to:`/auth?next=${encodeURIComponent(s)}`,children:"Sign in / Create account"})})]})}):d.jsx("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Claim challenge unavailable."})}const $le=[...Nm],Ble={claude_local:"Claude (local)",codex_local:"Codex (local)",gemini_local:"Gemini CLI (local)",opencode_local:"OpenCode (local)",openclaw_gateway:"OpenClaw Gateway",cursor:"Cursor (local)",process:"Process",http:"HTTP"},MA=new Set(["claude_local","codex_local","gemini_local","opencode_local","cursor"]);function Vle(t){return new Date(t).toLocaleString()}function lh(t,e){let n=t;for(const r of e){if(!n||typeof n!="object")return null;n=n[r]}return typeof n=="string"&&n.trim().length>0?n:null}function BPe(){var E;const t=ur(),n=(Mf().token??"").trim(),[r,i]=x.useState("human"),[s,o]=x.useState(""),[a,l]=x.useState("claude_local"),[c,u]=x.useState(""),[f,h]=x.useState(null),[p,m]=x.useState(null),g=st({queryKey:ie.health,queryFn:()=>Rle.get(),retry:!1}),b=st({queryKey:ie.auth.session,queryFn:()=>Ds.getSession(),retry:!1}),v=st({queryKey:ie.access.invite(n),queryFn:()=>bd.getInvite(n),enabled:n.length>0,retry:!1}),y=v.data,w=(y==null?void 0:y.allowedJoinTypes)??"both",k=x.useMemo(()=>(y==null?void 0:y.inviteType)==="bootstrap_ceo"?["human"]:w==="both"?["human","agent"]:[w],[y==null?void 0:y.inviteType,w]);x.useEffect(()=>{k.includes(r)||i(k[0]??"human")},[k,r]);const C=r==="human"&&((E=g.data)==null?void 0:E.deploymentMode)==="authenticated"&&!b.data,_=Bt({mutationFn:async()=>{if(!y)throw new Error("Invite not found");return y.inviteType==="bootstrap_ceo"?bd.acceptInvite(n,{requestType:"human"}):r==="human"?bd.acceptInvite(n,{requestType:"human"}):bd.acceptInvite(n,{requestType:"agent",agentName:s.trim(),adapterType:a,capabilities:c.trim()||null})},onSuccess:async S=>{m(null),await t.invalidateQueries({queryKey:ie.auth.session}),await t.invalidateQueries({queryKey:ie.companies.all});const T=S&&typeof S=="object"&&"bootstrapAccepted"in S;h({kind:T?"bootstrap":"join",payload:S})},onError:S=>{m(S instanceof Error?S.message:"Failed to accept invite")}});if(!n)return d.jsx("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Invalid invite token."});if(v.isLoading||g.isLoading||b.isLoading)return d.jsx("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading invite..."});if(v.error||!y)return d.jsx("div",{className:"mx-auto max-w-xl py-10",children:d.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[d.jsx("h1",{className:"text-lg font-semibold",children:"Invite not available"}),d.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"This invite may be expired, revoked, or already used."})]})});if((f==null?void 0:f.kind)==="bootstrap")return d.jsx("div",{className:"mx-auto max-w-xl py-10",children:d.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[d.jsx("h1",{className:"text-lg font-semibold",children:"Bootstrap complete"}),d.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"The first instance admin is now configured. You can continue to the board."}),d.jsx(Oe,{asChild:!0,className:"mt-4",children:d.jsx(Ut,{to:"/",children:"Open board"})})]})});if((f==null?void 0:f.kind)==="join"){const S=f.payload,T=typeof S.claimSecret=="string"?S.claimSecret:null,A=typeof S.claimApiKeyPath=="string"?S.claimApiKeyPath:null,P=lh(S.onboarding,["skill","url"]),O=lh(S.onboarding,["skill","path"]),R=lh(S.onboarding,["skill","installPath"]),M=lh(S.onboarding,["textInstructions","url"]),F=lh(S.onboarding,["textInstructions","path"]),q=Array.isArray(S.diagnostics)?S.diagnostics:[];return d.jsx("div",{className:"mx-auto max-w-xl py-10",children:d.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[d.jsx("h1",{className:"text-lg font-semibold",children:"Join request submitted"}),d.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Your request is pending admin approval. You will not have access until approved."}),d.jsxs("div",{className:"mt-4 rounded-md border border-border bg-muted/30 p-3 text-xs text-muted-foreground",children:["Request ID: ",d.jsx("span",{className:"font-mono",children:S.id})]}),T&&A&&d.jsxs("div",{className:"mt-3 space-y-1 rounded-md border border-border bg-muted/30 p-3 text-xs text-muted-foreground",children:[d.jsx("p",{className:"font-medium text-foreground",children:"One-time claim secret (save now)"}),d.jsx("p",{className:"font-mono break-all",children:T}),d.jsxs("p",{className:"font-mono break-all",children:["POST ",A]})]}),(P||O||R)&&d.jsxs("div",{className:"mt-3 space-y-1 rounded-md border border-border bg-muted/30 p-3 text-xs text-muted-foreground",children:[d.jsx("p",{className:"font-medium text-foreground",children:"Growthub skill bootstrap"}),P&&d.jsxs("p",{className:"font-mono break-all",children:["GET ",P]}),!P&&O&&d.jsxs("p",{className:"font-mono break-all",children:["GET ",O]}),R&&d.jsxs("p",{className:"font-mono break-all",children:["Install to ",R]})]}),(M||F)&&d.jsxs("div",{className:"mt-3 space-y-1 rounded-md border border-border bg-muted/30 p-3 text-xs text-muted-foreground",children:[d.jsx("p",{className:"font-medium text-foreground",children:"Agent-readable onboarding text"}),M&&d.jsxs("p",{className:"font-mono break-all",children:["GET ",M]}),!M&&F&&d.jsxs("p",{className:"font-mono break-all",children:["GET ",F]})]}),q.length>0&&d.jsxs("div",{className:"mt-3 space-y-1 rounded-md border border-border bg-muted/30 p-3 text-xs text-muted-foreground",children:[d.jsx("p",{className:"font-medium text-foreground",children:"Connectivity diagnostics"}),q.map((z,D)=>d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("p",{className:z.level==="warn"?"text-amber-600 dark:text-amber-400":void 0,children:["[",z.level,"] ",z.message]}),z.hint&&d.jsx("p",{className:"font-mono break-all",children:z.hint})]},`${z.code}:${D}`))]})]})})}return d.jsx("div",{className:"mx-auto max-w-xl py-10",children:d.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[d.jsx("h1",{className:"text-xl font-semibold",children:y.inviteType==="bootstrap_ceo"?"Bootstrap your Growthub instance":"Join this Growthub company"}),d.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["Invite expires ",Vle(y.expiresAt),"."]}),y.inviteType!=="bootstrap_ceo"&&d.jsx("div",{className:"mt-5 flex gap-2",children:k.map(S=>d.jsxs("button",{type:"button",onClick:()=>i(S),className:`rounded-md border px-3 py-1.5 text-sm ${r===S?"border-foreground bg-foreground text-background":"border-border bg-background text-foreground"}`,children:["Join as ",S]},S))}),r==="agent"&&y.inviteType!=="bootstrap_ceo"&&d.jsxs("div",{className:"mt-4 space-y-3",children:[d.jsxs("label",{className:"block text-sm",children:[d.jsx("span",{className:"mb-1 block text-muted-foreground",children:"Agent name"}),d.jsx("input",{className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm",value:s,onChange:S=>o(S.target.value)})]}),d.jsxs("label",{className:"block text-sm",children:[d.jsx("span",{className:"mb-1 block text-muted-foreground",children:"Adapter type"}),d.jsx("select",{className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm",value:a,onChange:S=>l(S.target.value),children:$le.map(S=>d.jsxs("option",{value:S,disabled:!MA.has(S),children:[Ble[S],MA.has(S)?"":" (Coming soon)"]},S))})]}),d.jsxs("label",{className:"block text-sm",children:[d.jsx("span",{className:"mb-1 block text-muted-foreground",children:"Capabilities (optional)"}),d.jsx("textarea",{className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm",rows:4,value:c,onChange:S=>u(S.target.value)})]})]}),C&&d.jsxs("div",{className:"mt-4 rounded-md border border-border bg-muted/30 p-3 text-sm",children:["Sign in or create an account before submitting a human join request.",d.jsx("div",{className:"mt-2",children:d.jsx(Oe,{asChild:!0,size:"sm",variant:"outline",children:d.jsx(Ut,{to:`/auth?next=${encodeURIComponent(`/invite/${n}`)}`,children:"Sign in / Create account"})})})]}),p&&d.jsx("p",{className:"mt-3 text-sm text-destructive",children:p}),d.jsx(Oe,{className:"mt-5",disabled:_.isPending||r==="agent"&&y.inviteType!=="bootstrap_ceo"&&s.trim().length===0||C,onClick:()=>_.mutate(),children:_.isPending?"Submitting…":y.inviteType==="bootstrap_ceo"?"Accept bootstrap invite":"Submit join request"})]})})}function VPe({scope:t="global",requestedPrefix:e}){const n=Ur(),{setBreadcrumbs:r}=Am(),{companies:i,selectedCompany:s}=Ys();x.useEffect(()=>{r([{label:"Not Found"}])},[r]);const o=s??i[0]??null,a=o?`/${o.issuePrefix}/dashboard`:"/",l=`${n.pathname}${n.search}${n.hash}`,c=e==null?void 0:e.toUpperCase(),u=t==="invalid_company_prefix"?"Company not found":"Page not found",f=t==="invalid_company_prefix"?`No company matches prefix "${c??"unknown"}".`:"This route does not exist.";return d.jsx("div",{className:"mx-auto max-w-2xl py-10",children:d.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 p-2",children:d.jsx(Bb,{className:"h-5 w-5 text-destructive"})}),d.jsxs("div",{children:[d.jsx("h1",{className:"text-xl font-semibold",children:u}),d.jsx("p",{className:"text-sm text-muted-foreground",children:f})]})]}),d.jsxs("div",{className:"mt-4 rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:["Requested path: ",d.jsx("code",{className:"font-mono",children:l})]}),d.jsxs("div",{className:"mt-5 flex flex-wrap gap-2",children:[d.jsx(Oe,{asChild:!0,children:d.jsxs(Ut,{to:a,children:[d.jsx(goe,{className:"mr-1.5 h-4 w-4"}),"Open dashboard"]})}),d.jsx(Oe,{variant:"outline",asChild:!0,children:d.jsx(Ut,{to:"/",children:"Go home"})})]})]})})}const RA={overview:t=>re.get(`/companies/${t}/budgets/overview`),upsertPolicy:(t,e)=>re.post(`/companies/${t}/budgets/policies`,e),resolveIncident:(t,e,n)=>re.post(`/companies/${t}/budget-incidents/${encodeURIComponent(e)}/resolve`,n)};function zb(){return Array.from({length:14},(t,e)=>{const n=new Date;return n.setDate(n.getDate()-(13-e)),n.toISOString().slice(0,10)})}function zle(t){const e=new Date(t+"T12:00:00");return`${e.getMonth()+1}/${e.getDate()}`}function Hb({days:t}){return d.jsx("div",{className:"flex gap-[3px] mt-1.5",children:t.map((e,n)=>d.jsx("div",{className:"flex-1 text-center",children:n===0||n===6||n===13?d.jsx("span",{className:"text-[9px] text-muted-foreground tabular-nums",children:zle(e)}):null},e))})}function j8({items:t}){return d.jsx("div",{className:"flex flex-wrap gap-x-2.5 gap-y-0.5 mt-2",children:t.map(e=>d.jsxs("span",{className:"flex items-center gap-1 text-[9px] text-muted-foreground",children:[d.jsx("span",{className:"h-1.5 w-1.5 rounded-full shrink-0",style:{backgroundColor:e.color}}),e.label]},e.label))})}function Tg({title:t,subtitle:e,children:n}){return d.jsxs("div",{className:"border border-border rounded-lg p-4 space-y-3",children:[d.jsxs("div",{children:[d.jsx("h3",{className:"text-xs font-medium text-muted-foreground",children:t}),e&&d.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:e})]}),n]})}function Hle({runs:t}){const e=zb(),n=new Map;for(const s of e)n.set(s,{succeeded:0,failed:0,other:0});for(const s of t){const o=new Date(s.createdAt).toISOString().slice(0,10),a=n.get(o);a&&(s.status==="succeeded"?a.succeeded++:s.status==="failed"||s.status==="timed_out"?a.failed++:a.other++)}const r=Math.max(...Array.from(n.values()).map(s=>s.succeeded+s.failed+s.other),1);return Array.from(n.values()).some(s=>s.succeeded+s.failed+s.other>0)?d.jsxs("div",{children:[d.jsx("div",{className:"flex items-end gap-[3px] h-20",children:e.map(s=>{const o=n.get(s),a=o.succeeded+o.failed+o.other,l=a/r*100;return d.jsx("div",{className:"flex-1 h-full flex flex-col justify-end",title:`${s}: ${a} runs`,children:a>0?d.jsxs("div",{className:"flex flex-col-reverse gap-px overflow-hidden",style:{height:`${l}%`,minHeight:2},children:[o.succeeded>0&&d.jsx("div",{className:"bg-emerald-500",style:{flex:o.succeeded}}),o.failed>0&&d.jsx("div",{className:"bg-red-500",style:{flex:o.failed}}),o.other>0&&d.jsx("div",{className:"bg-neutral-500",style:{flex:o.other}})]}):d.jsx("div",{className:"bg-muted/30 rounded-sm",style:{height:2}})},s)})}),d.jsx(Hb,{days:e})]}):d.jsx("p",{className:"text-xs text-muted-foreground",children:"No runs yet"})}const PA={critical:"#ef4444",high:"#f97316",medium:"#eab308",low:"#6b7280"},OA=["critical","high","medium","low"];function Ule({issues:t}){const e=zb(),n=new Map;for(const s of e)n.set(s,{critical:0,high:0,medium:0,low:0});for(const s of t){const o=new Date(s.createdAt).toISOString().slice(0,10),a=n.get(o);a&&s.priority in a&&a[s.priority]++}const r=Math.max(...Array.from(n.values()).map(s=>Object.values(s).reduce((o,a)=>o+a,0)),1);return Array.from(n.values()).some(s=>Object.values(s).reduce((o,a)=>o+a,0)>0)?d.jsxs("div",{children:[d.jsx("div",{className:"flex items-end gap-[3px] h-20",children:e.map(s=>{const o=n.get(s),a=Object.values(o).reduce((c,u)=>c+u,0),l=a/r*100;return d.jsx("div",{className:"flex-1 h-full flex flex-col justify-end",title:`${s}: ${a} issues`,children:a>0?d.jsx("div",{className:"flex flex-col-reverse gap-px overflow-hidden",style:{height:`${l}%`,minHeight:2},children:OA.map(c=>o[c]>0?d.jsx("div",{style:{flex:o[c],backgroundColor:PA[c]}},c):null)}):d.jsx("div",{className:"bg-muted/30 rounded-sm",style:{height:2}})},s)})}),d.jsx(Hb,{days:e}),d.jsx(j8,{items:OA.map(s=>({color:PA[s],label:s.charAt(0).toUpperCase()+s.slice(1)}))})]}):d.jsx("p",{className:"text-xs text-muted-foreground",children:"No issues"})}const LA={todo:"#3b82f6",in_progress:"#8b5cf6",in_review:"#a855f7",done:"#10b981",blocked:"#ef4444",cancelled:"#6b7280",backlog:"#64748b"},Wle={todo:"To Do",in_progress:"In Progress",in_review:"In Review",done:"Done",blocked:"Blocked",cancelled:"Cancelled",backlog:"Backlog"};function Kle({issues:t}){const e=zb(),n=new Set,r=new Map;for(const a of e)r.set(a,{});for(const a of t){const l=new Date(a.createdAt).toISOString().slice(0,10),c=r.get(l);c&&(c[a.status]=(c[a.status]??0)+1,n.add(a.status))}const i=["todo","in_progress","in_review","done","blocked","cancelled","backlog"].filter(a=>n.has(a)),s=Math.max(...Array.from(r.values()).map(a=>Object.values(a).reduce((l,c)=>l+c,0)),1);return n.size>0?d.jsxs("div",{children:[d.jsx("div",{className:"flex items-end gap-[3px] h-20",children:e.map(a=>{const l=r.get(a),c=Object.values(l).reduce((f,h)=>f+h,0),u=c/s*100;return d.jsx("div",{className:"flex-1 h-full flex flex-col justify-end",title:`${a}: ${c} issues`,children:c>0?d.jsx("div",{className:"flex flex-col-reverse gap-px overflow-hidden",style:{height:`${u}%`,minHeight:2},children:i.map(f=>(l[f]??0)>0?d.jsx("div",{style:{flex:l[f],backgroundColor:LA[f]??"#6b7280"}},f):null)}):d.jsx("div",{className:"bg-muted/30 rounded-sm",style:{height:2}})},a)})}),d.jsx(Hb,{days:e}),d.jsx(j8,{items:i.map(a=>({color:LA[a]??"#6b7280",label:Wle[a]??a}))})]}):d.jsx("p",{className:"text-xs text-muted-foreground",children:"No issues"})}function qle({runs:t}){const e=zb(),n=new Map;for(const i of e)n.set(i,{succeeded:0,total:0});for(const i of t){const s=new Date(i.createdAt).toISOString().slice(0,10),o=n.get(s);o&&(o.total++,i.status==="succeeded"&&o.succeeded++)}return Array.from(n.values()).some(i=>i.total>0)?d.jsxs("div",{children:[d.jsx("div",{className:"flex items-end gap-[3px] h-20",children:e.map(i=>{const s=n.get(i),o=s.total>0?s.succeeded/s.total:0,a=s.total===0?void 0:o>=.8?"#10b981":o>=.5?"#eab308":"#ef4444";return d.jsx("div",{className:"flex-1 h-full flex flex-col justify-end",title:`${i}: ${s.total>0?Math.round(o*100):0}% (${s.succeeded}/${s.total})`,children:s.total>0?d.jsx("div",{style:{height:`${o*100}%`,minHeight:2,backgroundColor:a}}):d.jsx("div",{className:"bg-muted/30 rounded-sm",style:{height:2}})},i)})}),d.jsx(Hb,{days:e})]}):d.jsx("p",{className:"text-xs text-muted-foreground",children:"No runs yet"})}const tC={list:t=>re.get(`/companies/${t}/activity`),forIssue:t=>re.get(`/issues/${t}/activity`),runsForIssue:t=>re.get(`/issues/${t}/runs`),issuesForRun:t=>re.get(`/heartbeat-runs/${t}/issues`)},Tn={list:(t,e)=>{const n=new URLSearchParams;e!=null&&e.status&&n.set("status",e.status),e!=null&&e.projectId&&n.set("projectId",e.projectId),e!=null&&e.assigneeAgentId&&n.set("assigneeAgentId",e.assigneeAgentId),e!=null&&e.assigneeUserId&&n.set("assigneeUserId",e.assigneeUserId),e!=null&&e.touchedByUserId&&n.set("touchedByUserId",e.touchedByUserId),e!=null&&e.unreadForUserId&&n.set("unreadForUserId",e.unreadForUserId),e!=null&&e.labelId&&n.set("labelId",e.labelId),e!=null&&e.q&&n.set("q",e.q);const r=n.toString();return re.get(`/companies/${t}/issues${r?`?${r}`:""}`)},listLabels:t=>re.get(`/companies/${t}/labels`),createLabel:(t,e)=>re.post(`/companies/${t}/labels`,e),deleteLabel:t=>re.delete(`/labels/${t}`),get:t=>re.get(`/issues/${t}`),markRead:t=>re.post(`/issues/${t}/read`,{}),create:(t,e)=>re.post(`/companies/${t}/issues`,e),update:(t,e)=>re.patch(`/issues/${t}`,e),remove:t=>re.delete(`/issues/${t}`),checkout:(t,e)=>re.post(`/issues/${t}/checkout`,{agentId:e,expectedStatuses:["todo","backlog","blocked"]}),release:t=>re.post(`/issues/${t}/release`,{}),openLocal:t=>re.post(`/issues/${t}/open-local`,{}),listComments:t=>re.get(`/issues/${t}/comments`),addComment:(t,e,n,r)=>re.post(`/issues/${t}/comments`,{body:e,...n===void 0?{}:{reopen:n},...r===void 0?{}:{interrupt:r}}),listDocuments:t=>re.get(`/issues/${t}/documents`),getDocument:(t,e)=>re.get(`/issues/${t}/documents/${encodeURIComponent(e)}`),upsertDocument:(t,e,n)=>re.put(`/issues/${t}/documents/${encodeURIComponent(e)}`,n),listDocumentRevisions:(t,e)=>re.get(`/issues/${t}/documents/${encodeURIComponent(e)}/revisions`),deleteDocument:(t,e)=>re.delete(`/issues/${t}/documents/${encodeURIComponent(e)}`),listAttachments:t=>re.get(`/issues/${t}/attachments`),uploadAttachment:(t,e,n,r)=>{const i=new FormData;return i.append("file",n),r&&i.append("issueCommentId",r),re.postForm(`/companies/${t}/issues/${e}/attachments`,i)},deleteAttachment:t=>re.delete(`/attachments/${t}`),listApprovals:t=>re.get(`/issues/${t}/approvals`),linkApproval:(t,e)=>re.post(`/issues/${t}/approvals`,{approvalId:e}),unlinkApproval:(t,e)=>re.delete(`/issues/${t}/approvals/${e}`),listArchived:t=>re.get(`/companies/${t}/issues/archived`),bulkArchive:(t,e)=>re.post(`/companies/${t}/issues/bulk-archive`,{ids:e}),bulkRestore:(t,e)=>re.post(`/companies/${t}/issues/bulk-restore`,{ids:e}),listWorkProducts:t=>re.get(`/issues/${t}/work-products`),createWorkProduct:(t,e)=>re.post(`/issues/${t}/work-products`,e),updateWorkProduct:(t,e)=>re.patch(`/work-products/${t}`,e),deleteWorkProduct:t=>re.delete(`/work-products/${t}`)},DA={list:t=>re.get(`/companies/${t}/secrets`),providers:t=>re.get(`/companies/${t}/secret-providers`),create:(t,e)=>re.post(`/companies/${t}/secrets`,e),rotate:(t,e)=>re.post(`/secrets/${t}/rotate`,e),update:(t,e)=>re.patch(`/secrets/${t}`,e),remove:t=>re.delete(`/secrets/${t}`)},bp="gpt-5.3-codex",Py=!0,vp="auto",wp="auto";function ni({...t}){return d.jsx(Cb,{"data-slot":"popover",...t})}function ri({...t}){return d.jsx(dX,{"data-slot":"popover-trigger",...t})}function ii({className:t,align:e="center",sideOffset:n=4,disablePortal:r=!1,...i}){const s=d.jsx(SL,{"data-slot":"popover-content",align:e,sideOffset:n,className:Z("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...i});return r?s:d.jsx(_b,{children:s})}function nC(t){const e=t.trim();return e.includes("/")&&e.slice(0,e.indexOf("/")).trim()||null}function Kh(t,e="other"){return nC(t)??e}function M8(t){const e=t.trim();return e.includes("/")?e.slice(e.indexOf("/")+1).trim():e}const Yt={name:"Display name for this agent.",title:"Job title shown in the org chart.",capabilities:"Describes what this agent can do. Shown in the org chart and used for task routing.",adapterType:"How this agent runs: local CLI (Claude/Codex/OpenCode), OpenClaw Gateway, spawned process, or generic HTTP webhook.",cwd:"Absolute working directory used by local adapters such as Claude, Codex, Cursor, Gemini, and OpenCode. Growthub CLI worker kits export working-directory-ready environments that can be pointed here directly. Use an absolute path on the machine running Growthub.",promptTemplate:"Sent on every heartbeat. Keep this small and dynamic. Use it for current-task framing, not large static instructions. Supports {{ agent.id }}, {{ agent.name }}, {{ agent.role }} and other template variables.",model:"Override the default model used by the adapter.",thinkingEffort:"Control model reasoning depth. Supported values vary by adapter/model.",chrome:"Enable Claude's Chrome integration by passing --chrome.",dangerouslySkipPermissions:"Run Claude without permission prompts. Required for unattended operation.",dangerouslyBypassSandbox:"Run Codex without sandbox restrictions. Required for filesystem/network access.",search:"Enable Codex web search capability during runs.",maxTurnsPerRun:"Maximum number of agentic turns (tool calls) per heartbeat run.",command:"The command to execute (e.g. node, python).",localCommand:"Override the path to the CLI command you want the adapter to call (e.g. /usr/local/bin/claude, codex, opencode).",args:"Command-line arguments, comma-separated.",extraArgs:"Extra CLI arguments for local adapters, comma-separated.",envVars:"Environment variables injected into the adapter process. Use plain values or secret references.",bootstrapPrompt:"Only sent when Growthub starts a fresh session. Use this for stable setup guidance that should not be repeated on every heartbeat.",payloadTemplateJson:"Optional JSON merged into remote adapter request payloads before Growthub adds its standard wake and workspace fields.",webhookUrl:"The URL that receives POST requests when the agent is invoked.",heartbeatInterval:"Run this agent automatically on a timer. Useful for periodic tasks like checking for new work.",intervalSec:"Seconds between automatic heartbeat invocations.",timeoutSec:"Maximum seconds a run can take before being terminated. 0 means no timeout.",graceSec:"Seconds to wait after sending interrupt before force-killing the process.",wakeOnDemand:"Allow this agent to be woken by assignments, API calls, UI actions, or automated systems.",cooldownSec:"Minimum seconds between consecutive heartbeat runs.",maxConcurrentRuns:"Maximum number of heartbeat runs that can execute simultaneously for this agent."},R8={claude_local:"Claude (local)",codex_local:"Codex (local)",gemini_local:"Gemini CLI (local)",opencode_local:"OpenCode (local)",openclaw_gateway:"OpenClaw Gateway",cursor:"Cursor (local)",process:"Process",http:"HTTP"},Gle=m6;function kp({text:t}){return d.jsxs(sie,{children:[d.jsx(oie,{asChild:!0,children:d.jsx("button",{type:"button",className:"inline-flex text-muted-foreground/50 hover:text-muted-foreground transition-colors",children:d.jsx(ooe,{className:"h-3 w-3"})})}),d.jsx(aie,{side:"top",className:"max-w-xs",children:t})]})}function Et({label:t,hint:e,children:n}){return d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[d.jsx("label",{className:"text-xs text-muted-foreground",children:t}),e&&d.jsx(kp,{text:e})]}),n]})}function Cp({label:t,hint:e,checked:n,onChange:r}){return d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e&&d.jsx(kp,{text:e})]}),d.jsx("button",{className:Z("relative inline-flex h-5 w-9 items-center rounded-full transition-colors",n?"bg-green-600":"bg-muted"),onClick:()=>r(!n),children:d.jsx("span",{className:Z("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",n?"translate-x-4.5":"translate-x-0.5")})})]})}function FA({label:t,hint:e,checked:n,onCheckedChange:r,number:i,onNumberChange:s,numberLabel:o,numberHint:a,numberPrefix:l,showNumber:c}){return d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between gap-3",children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e&&d.jsx(kp,{text:e})]}),d.jsx("button",{className:Z("relative inline-flex h-5 w-9 items-center rounded-full transition-colors shrink-0",n?"bg-green-600":"bg-muted"),onClick:()=>r(!n),children:d.jsx("span",{className:Z("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",n?"translate-x-4.5":"translate-x-0.5")})})]}),c&&d.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[l&&d.jsx("span",{children:l}),d.jsx("input",{type:"number",className:"w-16 rounded-md border border-border px-2 py-0.5 bg-transparent outline-none text-xs font-mono text-center",value:i,onChange:u=>s(Number(u.target.value))}),d.jsx("span",{children:o}),a&&d.jsx(kp,{text:a})]})]})}function Jle({title:t,icon:e,open:n,onToggle:r,bordered:i,children:s}){return d.jsxs("div",{className:Z(i&&"border-t border-border"),children:[d.jsxs("button",{className:"flex items-center gap-2 w-full px-4 py-2 text-xs font-medium text-muted-foreground hover:bg-accent/30 transition-colors",onClick:r,children:[n?d.jsx(_i,{className:"h-3 w-3"}):d.jsx(Vi,{className:"h-3 w-3"}),e,t]}),n&&d.jsx("div",{className:"px-4 pb-3",children:s})]})}function Mn({value:t,onCommit:e,immediate:n,className:r,...i}){const[s,o]=x.useState(t);return x.useEffect(()=>o(t),[t]),d.jsx("input",{className:r,value:s,onChange:a=>{o(a.target.value),n&&e(a.target.value)},onBlur:()=>{s!==t&&e(s)},...i})}function Fh({value:t,onCommit:e,immediate:n,className:r,...i}){const[s,o]=x.useState(String(t));return x.useEffect(()=>o(String(t)),[t]),d.jsx("input",{type:"number",className:r,value:s,onChange:a=>{o(a.target.value),n&&e(Number(a.target.value)||0)},onBlur:()=>{const a=Number(s)||0;a!==t&&e(a)},...i})}const rC={adapterType:"claude_local",cwd:"",instructionsFilePath:"",promptTemplate:"",model:"",thinkingEffort:"",chrome:!1,dangerouslySkipPermissions:!0,search:!1,dangerouslyBypassSandbox:!1,command:"",args:"",extraArgs:"",envVars:"",envBindings:{},url:"",bootstrapPrompt:"",payloadTemplateJson:"",workspaceStrategyType:"project_primary",workspaceBaseRef:"",workspaceBranchTemplate:"",worktreeParentDir:"",runtimeServicesJson:"",maxTurnsPerRun:300,heartbeatEnabled:!1,intervalSec:300};function ul(t){return typeof t!="object"||t===null||Array.isArray(t)?null:t}function Ng(t){return typeof t=="number"&&Number.isFinite(t)?t:0}function Zle(t){if(typeof t=="string")return t;const e=ul(t);if(!e)return"";const n=typeof e.message=="string"&&e.message||typeof e.error=="string"&&e.error||typeof e.code=="string"&&e.code||"";if(n)return n;try{return JSON.stringify(e)}catch{return""}}function Yle(t){try{return JSON.parse(t)}catch{return null}}function Qle(t,e){const n=ul(Yle(t));if(!n)return[{kind:"stdout",ts:e,text:t}];const r=typeof n.type=="string"?n.type:"";if(r==="system"&&n.subtype==="init")return[{kind:"init",ts:e,model:typeof n.model=="string"?n.model:"unknown",sessionId:typeof n.session_id=="string"?n.session_id:""}];if(r==="assistant"){const i=ul(n.message)??{},s=Array.isArray(i.content)?i.content:[],o=[];for(const a of s){const l=ul(a);if(!l)continue;const c=typeof l.type=="string"?l.type:"";if(c==="text"){const u=typeof l.text=="string"?l.text:"";u&&o.push({kind:"assistant",ts:e,text:u})}else if(c==="thinking"){const u=typeof l.thinking=="string"?l.thinking:"";u&&o.push({kind:"thinking",ts:e,text:u})}else c==="tool_use"&&o.push({kind:"tool_call",ts:e,name:typeof l.name=="string"?l.name:"unknown",toolUseId:typeof l.id=="string"?l.id:typeof l.tool_use_id=="string"?l.tool_use_id:void 0,input:l.input??{}})}return o.length>0?o:[{kind:"stdout",ts:e,text:t}]}if(r==="user"){const i=ul(n.message)??{},s=Array.isArray(i.content)?i.content:[],o=[];for(const a of s){const l=ul(a);if(!l)continue;const c=typeof l.type=="string"?l.type:"";if(c==="text"){const u=typeof l.text=="string"?l.text:"";u&&o.push({kind:"user",ts:e,text:u})}else if(c==="tool_result"){const u=typeof l.tool_use_id=="string"?l.tool_use_id:"",f=l.is_error===!0;let h="";if(typeof l.content=="string")h=l.content;else if(Array.isArray(l.content)){const p=[];for(const m of l.content){const g=ul(m);g&&typeof g.text=="string"&&p.push(g.text)}h=p.join(`
679
679
  `)}o.push({kind:"tool_result",ts:e,toolUseId:u,content:h,isError:f})}}if(o.length>0)return o}if(r==="result"){const i=ul(n.usage)??{},s=Ng(i.input_tokens),o=Ng(i.output_tokens),a=Ng(i.cache_read_input_tokens),l=Ng(n.total_cost_usd),c=typeof n.subtype=="string"?n.subtype:"",u=n.is_error===!0,f=Array.isArray(n.errors)?n.errors.map(Zle).filter(Boolean):[],h=typeof n.result=="string"?n.result:"";return[{kind:"result",ts:e,text:h,inputTokens:s,outputTokens:o,cachedTokens:a,costUsd:l,subtype:c,isError:u,errors:f}]}return[{kind:"stdout",ts:e,text:t}]}function Xle(t){return t.split(",").map(e=>e.trim()).filter(Boolean)}function ece(t){const e={};for(const n of t.split(/\r?\n/)){const r=n.trim();if(!r||r.startsWith("#"))continue;const i=r.indexOf("=");if(i<=0)continue;const s=r.slice(0,i).trim(),o=r.slice(i+1);/^[A-Za-z_][A-Za-z0-9_]*$/.test(s)&&(e[s]=o)}return e}function tce(t){if(typeof t!="object"||t===null||Array.isArray(t))return{};const e={};for(const[n,r]of Object.entries(t)){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(n))continue;if(typeof r=="string"){e[n]={type:"plain",value:r};continue}if(typeof r!="object"||r===null||Array.isArray(r))continue;const i=r;if(i.type==="plain"&&typeof i.value=="string"){e[n]={type:"plain",value:i.value};continue}i.type==="secret_ref"&&typeof i.secretId=="string"&&(e[n]={type:"secret_ref",secretId:i.secretId,...typeof i.version=="number"||i.version==="latest"?{version:i.version}:{}})}return e}function nce(t){const e=t.trim();if(!e)return null;try{const n=JSON.parse(e);return typeof n!="object"||n===null||Array.isArray(n)?null:n}catch{return null}}function rce(t){const e={};t.cwd&&(e.cwd=t.cwd),t.instructionsFilePath&&(e.instructionsFilePath=t.instructionsFilePath),t.promptTemplate&&(e.promptTemplate=t.promptTemplate),t.bootstrapPrompt&&(e.bootstrapPromptTemplate=t.bootstrapPrompt),t.model&&(e.model=t.model),t.thinkingEffort&&(e.effort=t.thinkingEffort),t.chrome&&(e.chrome=!0),e.timeoutSec=0,e.graceSec=15;const n=tce(t.envBindings),r=ece(t.envVars);for(const[s,o]of Object.entries(r))Object.prototype.hasOwnProperty.call(n,s)||(n[s]={type:"plain",value:o});Object.keys(n).length>0&&(e.env=n),e.maxTurnsPerRun=t.maxTurnsPerRun,e.dangerouslySkipPermissions=t.dangerouslySkipPermissions,t.workspaceStrategyType==="git_worktree"&&(e.workspaceStrategy={type:"git_worktree",...t.workspaceBaseRef?{baseRef:t.workspaceBaseRef}:{},...t.workspaceBranchTemplate?{branchTemplate:t.workspaceBranchTemplate}:{},...t.worktreeParentDir?{worktreeParentDir:t.worktreeParentDir}:{}});const i=nce(t.runtimeServicesJson??"");return i&&Array.isArray(i.services)&&(e.workspaceRuntime=i),t.command&&(e.command=t.command),t.extraArgs&&(e.extraArgs=Xle(t.extraArgs)),e}const ice=[{id:"mac",label:"macOS",icon:Ise},{id:"windows",label:"Windows",icon:bae},{id:"linux",label:"Linux",icon:Ry}],sce={mac:{steps:["Open Finder and navigate to the folder.","Right-click (or Control-click) the folder.",'Hold the Option (⌥) key — "Copy" changes to "Copy as Pathname".','Click "Copy as Pathname", then paste here.'],tip:"You can also open Terminal, type cd, drag the folder into the terminal window, and press Enter. Then type pwd to see the full path."},windows:{steps:["Open File Explorer and navigate to the folder.","Click in the address bar at the top — the full path will appear.","Copy the path, then paste here."],tip:'Alternatively, hold Shift and right-click the folder, then select "Copy as path".'},linux:{steps:["Open a terminal and navigate to the directory with cd.","Run pwd to print the full path.","Copy the output and paste here."],tip:"In most file managers, Ctrl+L reveals the full path in the address bar."}};function oce(){const t=navigator.userAgent.toLowerCase();return t.includes("mac")?"mac":t.includes("win")?"windows":"linux"}function ace({open:t,onOpenChange:e}){const[n,r]=x.useState(oce),i=sce[n];return d.jsx(Vb,{open:t,onOpenChange:e,children:d.jsxs(r5,{className:"sm:max-w-md",children:[d.jsxs(w8,{children:[d.jsx(k8,{className:"text-base",children:"How to get a full path"}),d.jsxs(jle,{children:["Paste the absolute path (e.g."," ",d.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:"/Users/you/project"}),") into the input field."]})]}),d.jsx("div",{className:"flex gap-1 rounded-md border border-border p-0.5",children:ice.map(s=>d.jsxs("button",{type:"button",className:Z("flex flex-1 items-center justify-center gap-1.5 rounded px-2 py-1 text-xs transition-colors",n===s.id?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground hover:bg-accent/50"),onClick:()=>r(s.id),children:[d.jsx(s.icon,{className:"h-3.5 w-3.5"}),s.label]},s.id))}),d.jsx("ol",{className:"space-y-2 text-sm",children:i.steps.map((s,o)=>d.jsxs("li",{className:"flex gap-2",children:[d.jsxs("span",{className:"text-muted-foreground font-mono text-xs mt-0.5 shrink-0",children:[o+1,"."]}),d.jsx("span",{children:s})]},o))}),i.tip&&d.jsx("p",{className:"text-xs text-muted-foreground border-l-2 border-border pl-3",children:i.tip})]})})}function Ws({className:t}){const[e,n]=x.useState(!1);return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:Z("inline-flex items-center rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground hover:bg-accent/50 transition-colors shrink-0",t),onClick:()=>n(!0),children:"Choose"}),d.jsx(ace,{open:e,onOpenChange:n})]})}function P8(t){return null}const Oy="w-full rounded-md border border-border px-2.5 py-1.5 bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40",lce="Absolute path to a markdown file (e.g. AGENTS.md) that defines this agent's behavior. Injected into the system prompt at runtime.",cce="Absolute path to the claude binary if it is not in PATH. Leave blank to use 'claude' from PATH.";function uce({mode:t,isCreate:e,adapterType:n,values:r,set:i,config:s,eff:o,mark:a,models:l}){return d.jsxs(d.Fragment,{children:[d.jsx(Et,{label:"Command (binary path)",hint:cce,children:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Mn,{value:e?r.command??"":o("adapterConfig","command",String(s.command??"")),onCommit:c=>e?i({command:c}):a("adapterConfig","command",c||void 0),immediate:!0,className:Oy,placeholder:"/opt/homebrew/bin/claude"}),d.jsx(Ws,{})]})}),d.jsx(Et,{label:"Agent instructions file",hint:lce,children:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Mn,{value:e?r.instructionsFilePath??"":o("adapterConfig","instructionsFilePath",String(s.instructionsFilePath??"")),onCommit:c=>e?i({instructionsFilePath:c}):a("adapterConfig","instructionsFilePath",c||void 0),immediate:!0,className:Oy,placeholder:"/absolute/path/to/AGENTS.md"}),d.jsx(Ws,{})]})}),d.jsx(P8,{isCreate:e,values:r,set:i,config:s,mark:a,eff:o,mode:t,adapterType:n,models:l})]})}function dce({isCreate:t,values:e,set:n,config:r,eff:i,mark:s}){return d.jsxs(d.Fragment,{children:[d.jsx(Cp,{label:"Enable Chrome",hint:Yt.chrome,checked:t?e.chrome:i("adapterConfig","chrome",r.chrome===!0),onChange:o=>t?n({chrome:o}):s("adapterConfig","chrome",o)}),d.jsx(Cp,{label:"Skip permissions",hint:Yt.dangerouslySkipPermissions,checked:t?e.dangerouslySkipPermissions:i("adapterConfig","dangerouslySkipPermissions",r.dangerouslySkipPermissions!==!1),onChange:o=>t?n({dangerouslySkipPermissions:o}):s("adapterConfig","dangerouslySkipPermissions",o)}),d.jsx(Et,{label:"Max turns per run",hint:Yt.maxTurnsPerRun,children:t?d.jsx("input",{type:"number",className:Oy,value:e.maxTurnsPerRun,onChange:o=>n({maxTurnsPerRun:Number(o.target.value)})}):d.jsx(Fh,{value:i("adapterConfig","maxTurnsPerRun",Number(r.maxTurnsPerRun??300)),onCommit:o=>s("adapterConfig","maxTurnsPerRun",o||300),immediate:!0,className:Oy})})]})}const fce={type:"claude_local",label:"Claude Code (local)",parseStdoutLine:Qle,ConfigFields:uce,buildAdapterConfig:rce},gv="[]",hce=[{regex:/\/Users\/[^/\\\s]+/g,replace:`/Users/${gv}`},{regex:/\/home\/[^/\\\s]+/g,replace:`/home/${gv}`},{regex:/([A-Za-z]:\\Users\\)[^\\/\s]+/g,replace:`$1${gv}`}];function pce(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}function vt(t){let e=t;for(const n of hce)e=e.replace(n.regex,n.replace);return e}function ts(t){if(typeof t=="string")return vt(t);if(Array.isArray(t))return t.map(n=>ts(n));if(!pce(t))return t;const e={};for(const[n,r]of Object.entries(t))e[n]=ts(r);return e}function $A(t){switch(t.kind){case"assistant":case"thinking":case"user":case"stderr":case"system":case"stdout":return{...t,text:vt(t.text)};case"tool_call":return{...t,name:vt(t.name),input:ts(t.input)};case"tool_result":return{...t,content:vt(t.content)};case"init":return{...t,model:vt(t.model),sessionId:vt(t.sessionId)};case"result":return{...t,text:vt(t.text),subtype:vt(t.subtype),errors:t.errors.map(e=>vt(e))};default:return t}}function mce(t){try{return JSON.parse(t)}catch{return null}}function vd(t){return typeof t!="object"||t===null||Array.isArray(t)?null:t}function Cn(t,e=""){return typeof t=="string"?t:e}function so(t,e=0){return typeof t=="number"&&Number.isFinite(t)?t:e}function Ix(t){if(typeof t=="string")return t;const e=vd(t);if(!e)return"";const n=typeof e.message=="string"&&e.message||typeof e.error=="string"&&e.error||typeof e.code=="string"&&e.code||"";if(n)return n;try{return JSON.stringify(e)}catch{return""}}function gce(t){if(typeof t=="string")return vt(t);if(t==null)return"";try{return JSON.stringify(ts(t),null,2)}catch{return vt(String(t))}}function xce(t,e,n){const r=Cn(t.id),i=Cn(t.command),s=Cn(t.status),o=typeof t.exit_code=="number"&&Number.isFinite(t.exit_code)?t.exit_code:null,a=vt(i),l=vt(Cn(t.aggregated_output)).replace(/\s+$/,"");if(n==="started")return[{kind:"tool_call",ts:e,name:"command_execution",toolUseId:r||i||"command_execution",input:{id:r,command:a}}];const c=[];a&&c.push(`command: ${a}`),s&&c.push(`status: ${s}`),o!==null&&c.push(`exit_code: ${o}`),l&&(c.length>0&&c.push(""),c.push(l));const u=o!==null&&o!==0||s==="failed"||s==="errored"||s==="error"||s==="cancelled";return[{kind:"tool_result",ts:e,toolUseId:r||i||"command_execution",content:c.join(`
680
680
  `).trim()||"command completed",isError:u}]}function yce(t,e){const r=(Array.isArray(t.changes)?t.changes:[]).map(o=>vd(o)).filter(o=>!!o).map(o=>{const a=Cn(o.kind,"update"),l=vt(Cn(o.path,"unknown"));return`${a} ${l}`});if(r.length===0)return[{kind:"system",ts:e,text:"file changes applied"}];const i=r.slice(0,6).join(", "),s=r.length>6?` (+${r.length-6} more)`:"";return[{kind:"system",ts:e,text:`file changes: ${i}${s}`}]}function bce(t,e,n){const r=Cn(t.type);if(r==="agent_message"){const a=Cn(t.text);return a?[{kind:"assistant",ts:e,text:vt(a)}]:[]}if(r==="reasoning"){const a=Cn(t.text);return a?[{kind:"thinking",ts:e,text:vt(a)}]:[{kind:"system",ts:e,text:n==="started"?"reasoning started":"reasoning completed"}]}if(r==="command_execution")return xce(t,e,n);if(r==="file_change"&&n==="completed")return yce(t,e);if(r==="tool_use")return[{kind:"tool_call",ts:e,name:vt(Cn(t.name,"unknown")),toolUseId:Cn(t.id),input:ts(t.input??{})}];if(r==="tool_result"&&n==="completed"){const a=Cn(t.tool_use_id,Cn(t.id)),l=Cn(t.content)||Cn(t.output)||Cn(t.result)||gce(t.content??t.output??t.result),c=t.is_error===!0||Cn(t.status)==="error";return[{kind:"tool_result",ts:e,toolUseId:a,content:vt(l),isError:c}]}if(r==="error"&&n==="completed"){const a=Ix(t.message??t.error??t);return[{kind:"stderr",ts:e,text:vt(a||"error")}]}const i=Cn(t.id),s=Cn(t.status),o=[i?`id=${i}`:"",s?`status=${s}`:""].filter(Boolean).join(" ");return[{kind:"system",ts:e,text:vt(`item ${n}: ${r||"unknown"}${o?` (${o})`:""}`)}]}function vce(t,e){const n=vd(mce(t));if(!n)return[{kind:"stdout",ts:e,text:vt(t)}];const r=Cn(n.type);if(r==="thread.started"){const i=Cn(n.thread_id);return[{kind:"init",ts:e,model:vt(Cn(n.model,"codex")),sessionId:vt(i)}]}if(r==="turn.started")return[{kind:"system",ts:e,text:"turn started"}];if(r==="item.started"||r==="item.completed"){const i=vd(n.item);return i?bce(i,e,r==="item.started"?"started":"completed"):[{kind:"system",ts:e,text:r.replace("."," ")}]}if(r==="turn.completed"){const i=vd(n.usage),s=so(i==null?void 0:i.input_tokens),o=so(i==null?void 0:i.output_tokens),a=so(i==null?void 0:i.cached_input_tokens,so(i==null?void 0:i.cache_read_input_tokens));return[{kind:"result",ts:e,text:vt(Cn(n.result)),inputTokens:s,outputTokens:o,cachedTokens:a,costUsd:so(n.total_cost_usd),subtype:vt(Cn(n.subtype)),isError:n.is_error===!0,errors:Array.isArray(n.errors)?n.errors.map(Ix).map(vt).filter(Boolean):[]}]}if(r==="turn.failed"){const i=vd(n.usage),s=so(i==null?void 0:i.input_tokens),o=so(i==null?void 0:i.output_tokens),a=so(i==null?void 0:i.cached_input_tokens,so(i==null?void 0:i.cache_read_input_tokens)),l=Ix(n.error??n.message);return[{kind:"result",ts:e,text:vt(Cn(n.result)),inputTokens:s,outputTokens:o,cachedTokens:a,costUsd:so(n.total_cost_usd),subtype:vt(Cn(n.subtype,"turn.failed")),isError:!0,errors:l?[vt(l)]:[]}]}if(r==="error"){const i=Ix(n.message??n.error??n);return[{kind:"stderr",ts:e,text:vt(i||t)}]}return[{kind:"stdout",ts:e,text:vt(t)}]}function wce(t){return t.split(",").map(e=>e.trim()).filter(Boolean)}function kce(t){const e={};for(const n of t.split(/\r?\n/)){const r=n.trim();if(!r||r.startsWith("#"))continue;const i=r.indexOf("=");if(i<=0)continue;const s=r.slice(0,i).trim(),o=r.slice(i+1);/^[A-Za-z_][A-Za-z0-9_]*$/.test(s)&&(e[s]=o)}return e}function Cce(t){if(typeof t!="object"||t===null||Array.isArray(t))return{};const e={};for(const[n,r]of Object.entries(t)){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(n))continue;if(typeof r=="string"){e[n]={type:"plain",value:r};continue}if(typeof r!="object"||r===null||Array.isArray(r))continue;const i=r;if(i.type==="plain"&&typeof i.value=="string"){e[n]={type:"plain",value:i.value};continue}i.type==="secret_ref"&&typeof i.secretId=="string"&&(e[n]={type:"secret_ref",secretId:i.secretId,...typeof i.version=="number"||i.version==="latest"?{version:i.version}:{}})}return e}function _ce(t){const e=t.trim();if(!e)return null;try{const n=JSON.parse(e);return typeof n!="object"||n===null||Array.isArray(n)?null:n}catch{return null}}function Sce(t){const e={};t.cwd&&(e.cwd=t.cwd),t.instructionsFilePath&&(e.instructionsFilePath=t.instructionsFilePath),t.promptTemplate&&(e.promptTemplate=t.promptTemplate),t.bootstrapPrompt&&(e.bootstrapPromptTemplate=t.bootstrapPrompt),e.model=t.model||bp,t.thinkingEffort&&(e.modelReasoningEffort=t.thinkingEffort),e.timeoutSec=0,e.graceSec=15;const n=Cce(t.envBindings),r=kce(t.envVars);for(const[s,o]of Object.entries(r))Object.prototype.hasOwnProperty.call(n,s)||(n[s]={type:"plain",value:o});Object.keys(n).length>0&&(e.env=n),e.search=t.search,e.dangerouslyBypassApprovalsAndSandbox=typeof t.dangerouslyBypassSandbox=="boolean"?t.dangerouslyBypassSandbox:Py,t.workspaceStrategyType==="git_worktree"&&(e.workspaceStrategy={type:"git_worktree",...t.workspaceBaseRef?{baseRef:t.workspaceBaseRef}:{},...t.workspaceBranchTemplate?{branchTemplate:t.workspaceBranchTemplate}:{},...t.worktreeParentDir?{worktreeParentDir:t.worktreeParentDir}:{}});const i=_ce(t.runtimeServicesJson??"");return i&&Array.isArray(i.services)&&(e.workspaceRuntime=i),t.command&&(e.command=t.command),t.extraArgs&&(e.extraArgs=wce(t.extraArgs)),e}const BA="w-full rounded-md border border-border px-2.5 py-1.5 bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40",Ece="Absolute path to a markdown file (e.g. AGENTS.md) that defines this agent's behavior. Injected into the system prompt at runtime.",Tce="Absolute path to the codex binary if it is not in PATH. Leave blank to use 'codex' from PATH.";function Nce({mode:t,isCreate:e,adapterType:n,values:r,set:i,config:s,eff:o,mark:a,models:l}){const c=s.dangerouslyBypassApprovalsAndSandbox===!0||s.dangerouslyBypassSandbox===!0;return d.jsxs(d.Fragment,{children:[d.jsx(Et,{label:"Command (binary path)",hint:Tce,children:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Mn,{value:e?r.command??"":o("adapterConfig","command",String(s.command??"")),onCommit:u=>e?i({command:u}):a("adapterConfig","command",u||void 0),immediate:!0,className:BA,placeholder:"/Applications/Codex.app/Contents/Resources/codex"}),d.jsx(Ws,{})]})}),d.jsx(Et,{label:"Agent instructions file",hint:Ece,children:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Mn,{value:e?r.instructionsFilePath??"":o("adapterConfig","instructionsFilePath",String(s.instructionsFilePath??"")),onCommit:u=>e?i({instructionsFilePath:u}):a("adapterConfig","instructionsFilePath",u||void 0),immediate:!0,className:BA,placeholder:"/absolute/path/to/AGENTS.md"}),d.jsx(Ws,{})]})}),d.jsx(Cp,{label:"Bypass sandbox",hint:Yt.dangerouslyBypassSandbox,checked:e?r.dangerouslyBypassSandbox:o("adapterConfig","dangerouslyBypassApprovalsAndSandbox",c),onChange:u=>e?i({dangerouslyBypassSandbox:u}):a("adapterConfig","dangerouslyBypassApprovalsAndSandbox",u)}),d.jsx(Cp,{label:"Enable search",hint:Yt.search,checked:e?r.search:o("adapterConfig","search",!!s.search),onChange:u=>e?i({search:u}):a("adapterConfig","search",u)}),d.jsx(P8,{isCreate:e,values:r,set:i,config:s,mark:a,eff:o,mode:t,adapterType:n,models:l})]})}const Ace={type:"codex_local",label:"Codex (local)",parseStdoutLine:vce,ConfigFields:Nce,buildAdapterConfig:Sce};function Ice(t){var s;const e=t.trim();if(!e)return{stream:null,line:""};const n=e.match(/^(stdout|stderr)\s*[:=]?\s*([\[{].*)$/i);if(!n)return{stream:null,line:e};const r=((s=n[1])==null?void 0:s.toLowerCase())==="stderr"?"stderr":"stdout",i=(n[2]??"").trim();return{stream:r,line:i}}function jce(t){try{return JSON.parse(t)}catch{return null}}function An(t){return typeof t!="object"||t===null||Array.isArray(t)?null:t}function mt(t,e=""){return typeof t=="string"?t:e}function Pr(t,e=0){return typeof t=="number"&&Number.isFinite(t)?t:e}function Yc(t){if(typeof t=="string")return t;if(t==null)return"";try{return JSON.stringify(t,null,2)}catch{return String(t)}}const Ag=2e3;function O8(t){const e=An(t);if(!e)return Yc(t);const n=An(e.success);if(!n)return Yc(t);const r=Pr(n.exitCode,NaN),i=mt(n.stdout).trim(),s=mt(n.stderr).trim();if(!(Number.isFinite(r)||i.length>0||s.length>0))return Yc(t);const a=[];if(Number.isFinite(r)&&a.push(`exit ${r}`),i){const l=i.length>Ag?i.slice(0,Ag)+`
681
681
  ... (truncated)`:i;a.push("<stdout>"),a.push(l)}if(s){const l=s.length>Ag?s.slice(0,Ag)+`
@@ -804,7 +804,7 @@ ${l}`.trim();return[o,{kind:"tool_result",ts:e,toolUseId:Sr(n.callID)||Sr(n.id,r
804
804
  `+e:"")+"\n```"},regExpEnd:{optional:!0,regExp:nNe},regExpStart:tNe,replace:(t,e,n,r,i,s)=>{let o,a;if(!e&&i){if(i.length===1)r?(o=wa(),a=n[1]+i[0]):(o=wa(n[1]),a=i[0].startsWith(" ")?i[0].slice(1):i[0]);else{if(o=wa(n[1]),i[0].trim().length===0)for(;i.length>0&&!i[0].length;)i.shift();else i[0]=i[0].startsWith(" ")?i[0].slice(1):i[0];for(;i.length>0&&!i[i.length-1].length;)i.pop();a=i.join(`
805
805
  `)}const l=mn(a);o.append(l),t.append(o)}else e&&yU((l=>wa(l?l[1]:void 0)))(t,e,n,s)},type:"multiline-element"},MT={dependencies:[Qa,Ya],export:(t,e)=>ut(t)?B1(t,e,0):null,regExp:YTe,replace:jT("bullet"),type:"element"},wU={dependencies:[Qa,Ya],export:(t,e)=>ut(t)?B1(t,e,0):null,regExp:QTe,replace:jT("check"),type:"element"},RT={dependencies:[Qa,Ya],export:(t,e)=>ut(t)?B1(t,e,0):null,regExp:ZTe,replace:jT("number"),type:"element"},kU={format:["code"],tag:"`",type:"text-format"},iNe={format:["highlight"],tag:"==",type:"text-format"},CU={format:["bold","italic"],tag:"***",type:"text-format"},_U={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},SU={format:["bold"],tag:"**",type:"text-format"},EU={format:["bold"],intraword:!1,tag:"__",type:"text-format"},sNe={format:["strikethrough"],tag:"~~",type:"text-format"},TU={format:["italic"],tag:"*",type:"text-format"},NU={format:["italic"],intraword:!1,tag:"_",type:"text-format"},AU={dependencies:[Za],export:(t,e,n)=>{if(!xi(t)||Is(t))return null;const r=t.getTitle(),i=e(t);return r?`[${i}](${t.getURL()} "${r}")`:`[${i}](${t.getURL()})`},importRegExp:/(?:\[(.*?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[(.*?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(t,e)=>{const[,n,r,i]=e,s=$a(r,{title:i}),o=n.split("[").length-1,a=n.split("]").length-1;let l=n,c="";if(o<a)return;if(o>a){const f=n.split("[");c="["+f[0],l=f.slice(1).join("[")}const u=mn(l);return u.setFormat(t.getFormat()),s.append(u),t.replace(s),c&&s.insertBefore(mn(c)),u},trigger:")",type:"text-match"},oNe=[rNe,bU,MT,RT],aNe=[vU],lNe=[kU,CU,_U,SU,EU,iNe,TU,NU,sNe],cNe=[AU],IU=[...oNe,...aNe,...lNe,...cNe],uNe=[{dependencies:[qm],export:t=>hE(t)?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(t,e,n,r)=>{const i=Jf();r||t.getNextSibling()!=null?t.replace(i):t.insertBefore(i),i.selectNext()},type:"element"},...IU];function Ow({transformers:t=uNe}){const[e]=Kr();return x.useEffect((()=>JTe(e,t)),[e,t]),null}const dNe=bs({init(t){const e=t.getValue(M$),n=e.includes("headings")?t.getValue(fE):[],r=mNe(e,n),i=r.filter(s=>!pNe.has(s));t.pubIn({[Hu]:()=>j.createElement(Ow,{transformers:r}),[cE]:()=>j.createElement(Ow,{transformers:r}),[j$]:()=>j.createElement(Ow,{transformers:i})})}}),fNe=t=>(e,n,r)=>{const i=t(r);i.append(...n),e.replace(i),i.select(0,0)},hNe={dependencies:[qm],export:t=>hE(t)?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(t,e,n,r)=>{const i=Jf();r||t.getNextSibling()!=null?t.replace(i):t.insertBefore(i),i.selectNext()},type:"element"},pNe=new Set([RT,MT,wU]);function mNe(t,e){const n=[CU,_U,SU,EU,kU,TU,NU];if(t.includes("headings")){const r=Math.min(...e),i=Math.max(...e),s=new RegExp(`^(#{${r},${i}})\\s`),o={dependencies:[zm],export:(a,l)=>{if(!xf(a))return null;const c=Number(a.getTag().slice(1));return"#".repeat(c)+" "+l(a)},regExp:s,replace:fNe(a=>{const l=`h${a[1].length}`;return ba(l)}),type:"element"};n.push(o)}if(t.includes("thematicBreak")&&n.push(hNe),t.includes("quote")&&n.push(bU),t.includes("link")&&n.push(AU),t.includes("lists")&&n.push(RT,MT,wU),t.includes("codeblock")){const r={...vU,dependencies:[Yf],replace:(i,s,o)=>{const a=Zm({code:"",language:o[1]??"",meta:""});i.selectPrevious(),i.replace(a),setTimeout(()=>{a.select()},80)}};n.push(r)}return n}function gNe(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const xNe={txt:"Text",md:"Markdown",js:"JavaScript",jsx:"JavaScript (JSX)",ts:"TypeScript",tsx:"TypeScript (TSX)",json:"JSON",bash:"Bash",sh:"Shell",python:"Python",go:"Go",rust:"Rust",sql:"SQL",html:"HTML",css:"CSS",yaml:"YAML",yml:"YAML"},yNe={priority:0,match:()=>!0,Editor:tU};function bNe(t){const e=window.getSelection();if(!e||e.rangeCount===0||!e.isCollapsed)return null;const n=e.getRangeAt(0),r=n.startContainer;if(r.nodeType!==Node.TEXT_NODE||!t.contains(r))return null;const i=r.textContent??"",s=n.startOffset;let o=-1;for(let f=s-1;f>=0;f--){const h=i[f];if(h==="@"){(f===0||/\s/.test(i[f-1]))&&(o=f);break}if(/\s/.test(h))break}if(o===-1)return null;const a=i.slice(o+1,s),l=document.createRange();l.setStart(r,o),l.setEnd(r,o+1);const c=l.getBoundingClientRect(),u=t.getBoundingClientRect();return{query:a,top:c.bottom-u.top,left:c.left-u.left,textNode:r,atPos:o,endPos:s}}function jU(t){return t.kind==="project"&&t.projectId?`[@${t.name}](${zre(t.projectId,t.projectColor??null)}) `:`@${t.name} `}function aP(t,e,n){const r=`@${e}`,i=jU(n),s=t.lastIndexOf(r);return s===-1?t:t.slice(0,s)+i+t.slice(s+r.length)}function vNe(t){const e=t.trim(),n=/^#([0-9a-f]{6})$/i.exec(e);if(!n)return null;const r=n[1];return{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16)}}function wNe(t){if(!t)return;const e=vNe(t);if(!e)return;const r=(.299*e.r+.587*e.g+.114*e.b)/255>.55?"#111827":"#f8fafc";return{borderColor:t,backgroundColor:`rgba(${e.r}, ${e.g}, ${e.b}, 0.22)`,color:r}}const ka=x.forwardRef(function({value:e,onChange:n,placeholder:r,className:i,contentClassName:s,onBlur:o,imageUploadHandler:a,bordered:l=!0,mentions:c,onSubmit:u},f){const h=x.useRef(null),p=x.useRef(null),m=x.useRef(e),[g,b]=x.useState(null),[v,y]=x.useState(!1),w=x.useRef(0),k=x.useRef(a);k.current=a;const[C,_]=x.useState(null),E=x.useRef(null),[S,T]=x.useState(0),A=C!==null&&c&&c.length>0,P=x.useMemo(()=>{const N=new Map;for(const $ of c??[])$.kind==="project"&&$.projectId&&N.set($.projectId,$.projectColor??null);return N},[c]),O=x.useMemo(()=>{if(!C||!c)return[];const N=C.query.toLowerCase();return c.filter($=>$.name.toLowerCase().includes(N)).slice(0,8)},[C==null?void 0:C.query,c]);x.useImperativeHandle(f,()=>({focus:()=>{var N;(N=p.current)==null||N.focus(void 0,{defaultSelection:"rootEnd"})}}),[]);const R=!!a,M=x.useMemo(()=>{const N=R?async X=>{const L=k.current;if(!L)throw new Error("No image upload handler");try{const te=await L(X);return b(null),setTimeout(()=>{var V;const ye=m.current,le=gNe(te),Y=ye.replace(new RegExp(`(!\\[[^\\]]*\\]\\(${le}\\))(?!\\n\\n)`,"g"),`$1
806
806
 
807
- `);Y!==ye&&(m.current=Y,(V=p.current)==null||V.setMarkdown(Y),n(Y),requestAnimationFrame(()=>{var ae;(ae=p.current)==null||ae.focus(void 0,{defaultSelection:"rootEnd"})}))},100),te}catch(te){const ye=te instanceof Error?te.message:"Image upload failed";throw b(ye),te}}:void 0,$=[Mbe(),Qbe(),Rwe(),M1e(),q1e(),OTe(),$be(),Hwe({defaultCodeBlockLanguage:"txt",codeBlockEditorDescriptors:[yNe]}),jTe({codeBlockLanguages:xNe}),dNe()];return N&&$.push(kwe({imageUploadHandler:N})),$},[R]);x.useEffect(()=>{var N;e!==m.current&&((N=p.current)==null||N.setMarkdown(e),m.current=e)},[e]);const F=x.useCallback(()=>{var X;const N=(X=h.current)==null?void 0:X.querySelector('[contenteditable="true"]');if(!N)return;const $=N.querySelectorAll("a");for(const L of $){const te=L,ye=B6(te.getAttribute("href")??"");if(!ye){te.dataset.projectMention==="true"&&(te.dataset.projectMention="false",te.classList.remove("paperclip-project-mention-chip"),te.removeAttribute("contenteditable"),te.style.removeProperty("border-color"),te.style.removeProperty("background-color"),te.style.removeProperty("color"));continue}const le=ye.color??P.get(ye.projectId)??null;te.dataset.projectMention="true",te.classList.add("paperclip-project-mention-chip"),te.setAttribute("contenteditable","false");const Y=wNe(le);Y&&(te.style.borderColor=Y.borderColor??"",te.style.backgroundColor=Y.backgroundColor??"",te.style.color=Y.color??"")}},[P]),q=x.useCallback(()=>{if(!c||c.length===0||!h.current){E.current=null,_(null);return}const N=bNe(h.current);E.current=N,N?(_(N),T(0)):_(null)},[c]);x.useEffect(()=>{if(!c||c.length===0)return;const N=h.current,$=()=>requestAnimationFrame(q);return document.addEventListener("selectionchange",q),N==null||N.addEventListener("input",$,!0),()=>{document.removeEventListener("selectionchange",q),N==null||N.removeEventListener("input",$,!0)}},[q,c]),x.useEffect(()=>{var X;const N=(X=h.current)==null?void 0:X.querySelector('[contenteditable="true"]');if(!N)return;F();const $=new MutationObserver(()=>{F()});return $.observe(N,{subtree:!0,childList:!0,characterData:!0}),()=>$.disconnect()},[F,e]);const z=x.useCallback(N=>{var te,ye;const $=E.current;if(!$)return;if(N.kind==="project"&&N.projectId){const le=m.current,Y=aP(le,$.query,N);Y!==le&&(m.current=Y,(te=p.current)==null||te.setMarkdown(Y),n(Y)),requestAnimationFrame(()=>{var V;(V=p.current)==null||V.focus(void 0,{defaultSelection:"rootEnd"}),F()}),E.current=null,_(null);return}const X=jU(N),L=window.getSelection();if(L&&$.textNode.isConnected){const le=document.createRange();le.setStart($.textNode,$.atPos),le.setEnd($.textNode,$.endPos),L.removeAllRanges(),L.addRange(le),document.execCommand("insertText",!1,X);const Y=$.atPos+X.length;requestAnimationFrame(()=>{var $e,tt;const V=window.getSelection();if(!V)return;if($.textNode.isConnected){const ft=(($e=$.textNode.textContent)==null?void 0:$e.length)??0;if(Y<=ft){const ht=document.createRange();ht.setStart($.textNode,Y),ht.collapse(!0),V.removeAllRanges(),V.addRange(ht);return}}const ae=(tt=h.current)==null?void 0:tt.querySelector('[contenteditable="true"]');if(!ae)return;const ce=document.createTreeWalker(ae,NodeFilter.SHOW_TEXT);let xe;for(;xe=ce.nextNode();){const ft=xe.textContent??"",ht=ft.indexOf(X);if(ht!==-1){const lt=ht+X.length;if(lt<=ft.length){const yt=document.createRange();yt.setStart(xe,lt),yt.collapse(!0),V.removeAllRanges(),V.addRange(yt);return}}}})}else{const le=m.current,Y=aP(le,$.query,N);Y!==le&&(m.current=Y,(ye=p.current)==null||ye.setMarkdown(Y),n(Y)),requestAnimationFrame(()=>{var V;(V=p.current)==null||V.focus(void 0,{defaultSelection:"rootEnd"})})}requestAnimationFrame(()=>{F()}),E.current=null,_(null)},[F,n]);function D(N){var $;return Array.from((($=N.dataTransfer)==null?void 0:$.types)??[]).includes("Files")}const W=!!a;return d.jsxs("div",{ref:h,className:Z("relative paperclip-mdxeditor-scope",l?"rounded-md border border-border bg-transparent":"bg-transparent",v&&"ring-1 ring-primary/60 bg-accent/20",i),onKeyDownCapture:N=>{if(u&&N.key==="Enter"&&(N.metaKey||N.ctrlKey)){N.preventDefault(),N.stopPropagation(),u();return}if(A){if(N.key===" "){E.current=null,_(null);return}if(N.key==="Escape"){N.preventDefault(),N.stopPropagation(),E.current=null,_(null);return}if(O.length>0){if(N.key==="ArrowDown"){N.preventDefault(),N.stopPropagation(),T($=>Math.min($+1,O.length-1));return}if(N.key==="ArrowUp"){N.preventDefault(),N.stopPropagation(),T($=>Math.max($-1,0));return}if(N.key==="Enter"||N.key==="Tab"){N.preventDefault(),N.stopPropagation(),z(O[S]);return}}}},onDragEnter:N=>{!W||!D(N)||(w.current+=1,y(!0))},onDragOver:N=>{!W||!D(N)||(N.preventDefault(),N.dataTransfer.dropEffect="copy")},onDragLeave:()=>{W&&(w.current=Math.max(0,w.current-1),w.current===0&&y(!1))},onDrop:()=>{w.current=0,y(!1)},children:[d.jsx(Ebe,{ref:p,markdown:e,placeholder:r,onChange:N=>{m.current=N,n(N)},onBlur:()=>o==null?void 0:o(),className:Z("paperclip-mdxeditor",!l&&"paperclip-mdxeditor--borderless"),contentEditableClassName:Z("paperclip-mdxeditor-content focus:outline-none [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5 [&_li]:list-item",s),plugins:M}),A&&O.length>0&&d.jsx("div",{className:"absolute z-50 min-w-[180px] max-h-[200px] overflow-y-auto rounded-md border border-border bg-popover shadow-md",style:{top:C.top+4,left:C.left},children:O.map((N,$)=>d.jsxs("button",{className:Z("flex items-center gap-2 w-full px-3 py-1.5 text-sm text-left hover:bg-accent/50 transition-colors",$===S&&"bg-accent"),onMouseDown:X=>{X.preventDefault(),z(N)},onMouseEnter:()=>T($),children:[N.kind==="project"&&N.projectId?d.jsx("span",{className:"inline-flex h-2 w-2 rounded-full border border-border/50",style:{backgroundColor:N.projectColor??"#64748b"}}):d.jsx("span",{className:"text-muted-foreground",children:"@"}),d.jsx("span",{children:N.name}),N.kind==="project"&&N.projectId&&d.jsx("span",{className:"ml-auto text-[10px] uppercase tracking-wide text-muted-foreground",children:"Project"})]},N.id))}),v&&W&&d.jsx("div",{className:Z("pointer-events-none absolute inset-1 z-40 flex items-center justify-center rounded-md border border-dashed border-primary/80 bg-primary/10 text-xs font-medium text-primary",!l&&"inset-0 rounded-sm"),children:"Drop image to upload"}),g&&d.jsx("p",{className:"px-3 pb-2 text-xs text-destructive",children:g})]})});function m_({className:t}){return d.jsxs(d.Fragment,{children:[d.jsx("img",{src:"/brands/opencode-logo-light-square.svg",alt:"OpenCode",className:Z("dark:hidden",t)}),d.jsx("img",{src:"/brands/opencode-logo-dark-square.svg",alt:"OpenCode",className:Z("hidden dark:block",t)})]})}const Lw={identity:{},adapterConfig:{},heartbeat:{},runtime:{}},lP={};function kNe(t){return Object.keys(t.identity).length>0||t.adapterType!==void 0||Object.keys(t.adapterConfig).length>0||Object.keys(t.heartbeat).length>0||Object.keys(t.runtime).length>0}const Zi="w-full rounded-md border border-border px-2.5 py-1.5 bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40";function CNe(t){return t.split(",").map(e=>e.trim()).filter(Boolean)}function _Ne(t){return Array.isArray(t)?t.filter(e=>typeof e=="string").join(", "):typeof t=="string"?t:""}const SNe=[{id:"",label:"Auto"},{id:"minimal",label:"Minimal"},{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"}],ENe=[{id:"",label:"Auto"},{id:"minimal",label:"Minimal"},{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"max",label:"Max"}],TNe=[{id:"",label:"Auto"},{id:"plan",label:"Plan"},{id:"ask",label:"Ask"}],NNe=[{id:"",label:"Auto"},{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"}];function ANe(t){const{mode:e,adapterModels:n}=t,r=e==="create",i=t.sectionLayout==="cards",{selectedCompanyId:s}=Ys(),o=ur(),{data:a=[]}=st({queryKey:s?ie.secrets.list(s):["secrets","none"],queryFn:()=>DA.list(s),enabled:!!s}),l=Bt({mutationFn:V=>{if(!s)throw new Error("Select a company to create secrets");return DA.create(s,V)},onSuccess:()=>{s&&o.invalidateQueries({queryKey:ie.secrets.list(s)})}}),c=Bt({mutationFn:async({file:V,namespace:ae})=>{if(!s)throw new Error("Select a company to upload images");return N8.uploadImage(s,V,ae)}}),[u,f]=x.useState(Lw),h=x.useRef(null);x.useEffect(()=>{r||(h.current!==null&&t.agent!==h.current&&f({...Lw}),h.current=t.agent)},[r,r?void 0:t.agent]);const p=!r&&kNe(u);function m(V,ae,ce){const xe=u[V];return ae in xe?xe[ae]:ce}function g(V,ae,ce){f(xe=>({...xe,[V]:{...xe[V],[ae]:ce}}))}const b=x.useCallback(()=>{f({...Lw})},[]),v=x.useCallback(()=>{if(r||!p)return;const V=t.agent,ae={};if(Object.keys(u.identity).length>0&&Object.assign(ae,u.identity),u.adapterType!==void 0)ae.adapterType=u.adapterType,ae.adapterConfig=u.adapterConfig;else if(Object.keys(u.adapterConfig).length>0){const ce=V.adapterConfig??{};ae.adapterConfig={...ce,...u.adapterConfig}}if(Object.keys(u.heartbeat).length>0){const ce=V.runtimeConfig??{},xe=ce.heartbeat??{};ae.runtimeConfig={...ce,heartbeat:{...xe,...u.heartbeat}}}Object.keys(u.runtime).length>0&&Object.assign(ae,u.runtime),t.onSave(ae)},[r,p,u,t]);x.useEffect(()=>{var V,ae,ce;r||((V=t.onDirtyChange)==null||V.call(t,p),(ae=t.onSaveActionChange)==null||ae.call(t,v),(ce=t.onCancelActionChange)==null||ce.call(t,b))},[r,p,t.onDirtyChange,t.onSaveActionChange,t.onCancelActionChange,v,b]),x.useEffect(()=>{if(!r)return()=>{var V,ae,ce;(V=t.onSaveActionChange)==null||V.call(t,null),(ae=t.onCancelActionChange)==null||ae.call(t,null),(ce=t.onDirtyChange)==null||ce.call(t,!1)}},[r,t.onDirtyChange,t.onSaveActionChange,t.onCancelActionChange]);const y=r?{}:t.agent.adapterConfig??{},w=r?{}:t.agent.runtimeConfig??{},k=r?{}:w.heartbeat??{},C=r?t.values.adapterType:u.adapterType??t.agent.adapterType,_=C==="claude_local"||C==="codex_local"||C==="gemini_local"||C==="opencode_local"||C==="cursor",E=x.useMemo(()=>_p(C),[C]),{data:S,error:T}=st({queryKey:s?ie.agents.adapterModels(s,C):["agents","none","adapter-models",C],queryFn:()=>Gt.adapterModels(s,C),enabled:!!s}),A=S??n??[],P={mode:e,isCreate:r,adapterType:C,values:r?t.values:null,set:r?V=>t.onChange(V):null,config:y,eff:m,mark:g,models:A},[O,R]=x.useState(!1),[M,F]=x.useState(!1),[q,z]=x.useState(!1),D=r?t.values:null,W=r?V=>t.onChange(V):null;function N(){return r?E.buildAdapterConfig(D):{...y,...u.adapterConfig}}const $=Bt({mutationFn:async()=>{if(!s)throw new Error("Select a company to test adapter environment");return Gt.testEnvironment(s,C,{adapterConfig:N()})}}),X=r?D.model:m("adapterConfig","model",String(y.model??"")),L=C==="codex_local"?"modelReasoningEffort":C==="cursor"?"mode":C==="opencode_local"?"variant":"effort",te=C==="codex_local"?SNe:C==="cursor"?TNe:C==="opencode_local"?ENe:NNe,ye=r?D.thinkingEffort:C==="codex_local"?m("adapterConfig","modelReasoningEffort",String(y.modelReasoningEffort??y.reasoningEffort??"")):C==="cursor"?m("adapterConfig","mode",String(y.mode??"")):C==="opencode_local"?m("adapterConfig","variant",String(y.variant??"")):m("adapterConfig","effort",String(y.effort??"")),le=C!=="gemini_local",Y=C==="codex_local"?r?!!D.search:m("adapterConfig","search",!!y.search):!1;return x.useMemo(()=>{if(r)return{heartbeat:{enabled:D.heartbeatEnabled,intervalSec:D.intervalSec}};const V={...w.heartbeat&&typeof w.heartbeat=="object"?w.heartbeat:{},...u.heartbeat};return{...w,heartbeat:V}},[r,u.heartbeat,w,D]),d.jsxs("div",{className:Z("relative",i&&"space-y-6"),children:[p&&!t.hideInlineSave&&d.jsx("div",{className:"sticky top-0 z-10 flex items-center justify-end px-4 py-2 bg-background/90 backdrop-blur-sm border-b border-primary/20",children:d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("span",{className:"text-xs text-muted-foreground",children:"Unsaved changes"}),d.jsx(Oe,{size:"sm",onClick:v,disabled:!r&&t.isSaving,children:!r&&t.isSaving?"Saving...":"Save"})]})}),!r&&d.jsxs("div",{className:Z(!i&&"border-b border-border"),children:[i?d.jsx("h3",{className:"text-sm font-medium mb-3",children:"Identity"}):d.jsx("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Identity"}),d.jsxs("div",{className:Z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[d.jsx(Et,{label:"Name",hint:Yt.name,children:d.jsx(Mn,{value:m("identity","name",t.agent.name),onCommit:V=>g("identity","name",V),immediate:!0,className:Zi,placeholder:"Agent name"})}),d.jsx(Et,{label:"Title",hint:Yt.title,children:d.jsx(Mn,{value:m("identity","title",t.agent.title??""),onCommit:V=>g("identity","title",V||null),immediate:!0,className:Zi,placeholder:"e.g. VP of Engineering"})}),d.jsx(Et,{label:"Capabilities",hint:Yt.capabilities,children:d.jsx(ka,{value:m("identity","capabilities",t.agent.capabilities??""),onChange:V=>g("identity","capabilities",V||null),placeholder:"Describe what this agent can do...",contentClassName:"min-h-[44px] text-sm font-mono",imageUploadHandler:async V=>(await c.mutateAsync({file:V,namespace:`agents/${t.agent.id}/capabilities`})).contentPath})}),_&&d.jsxs(d.Fragment,{children:[d.jsx(Et,{label:"Prompt Template",hint:Yt.promptTemplate,children:d.jsx(ka,{value:m("adapterConfig","promptTemplate",String(y.promptTemplate??"")),onChange:V=>g("adapterConfig","promptTemplate",V??""),placeholder:"You are agent {{ agent.name }}. Your role is {{ agent.role }}...",contentClassName:"min-h-[88px] text-sm font-mono",imageUploadHandler:async V=>{const ae=`agents/${t.agent.id}/prompt-template`;return(await c.mutateAsync({file:V,namespace:ae})).contentPath}})}),d.jsx("div",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100",children:"Prompt template is replayed on every heartbeat. Keep it compact and dynamic to avoid recurring token cost and cache churn."})]})]})]}),d.jsxs("div",{className:Z(!i&&(r?"border-t border-border":"border-b border-border")),children:[d.jsxs("div",{className:Z(i?"flex items-center justify-between mb-3":"px-4 py-2 flex items-center justify-between gap-2"),children:[i?d.jsx("h3",{className:"text-sm font-medium",children:"Adapter"}):d.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Adapter"}),d.jsx(Oe,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>$.mutate(),disabled:$.isPending||!s,children:$.isPending?"Testing...":"Test environment"})]}),d.jsxs("div",{className:Z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[d.jsx(Et,{label:"Adapter type",hint:Yt.adapterType,children:d.jsx(RNe,{value:C,onChange:V=>{if(r){const{adapterType:ae,...ce}=rC,xe={...ce,adapterType:V};V==="codex_local"?(xe.model=bp,xe.dangerouslyBypassSandbox=Py):V==="gemini_local"?xe.model=wp:V==="cursor"?xe.model=vp:V==="opencode_local"&&(xe.model=""),W(xe)}else f(ae=>({...ae,adapterType:V,adapterConfig:{model:V==="codex_local"?bp:V==="gemini_local"?wp:V==="cursor"?vp:"",effort:"",modelReasoningEffort:"",variant:"",mode:"",...V==="codex_local"?{dangerouslyBypassApprovalsAndSandbox:Py}:{}}}))}})}),$.error&&d.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:$.error instanceof Error?$.error.message:"Environment test failed"}),$.data&&d.jsx(INe,{result:$.data}),_&&d.jsx(Et,{label:"Working directory",hint:Yt.cwd,children:d.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border px-2.5 py-1.5",children:[d.jsx(m8,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),d.jsx(Mn,{value:r?D.cwd:m("adapterConfig","cwd",String(y.cwd??"")),onCommit:V=>r?W({cwd:V}):g("adapterConfig","cwd",V||void 0),immediate:!0,className:"w-full bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40",placeholder:"/path/to/project"}),d.jsx(Ws,{})]})}),_&&r&&d.jsxs(d.Fragment,{children:[d.jsx(Et,{label:"Prompt Template",hint:Yt.promptTemplate,children:d.jsx(ka,{value:D.promptTemplate,onChange:V=>W({promptTemplate:V}),placeholder:"You are agent {{ agent.name }}. Your role is {{ agent.role }}...",contentClassName:"min-h-[88px] text-sm font-mono",imageUploadHandler:async V=>(await c.mutateAsync({file:V,namespace:"agents/drafts/prompt-template"})).contentPath})}),d.jsxs("div",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100",children:["Prompt template is replayed on every heartbeat. Prefer small task framing and variables like ",d.jsx("code",{children:"{{ context.* }}"})," or ",d.jsx("code",{children:"{{ run.* }}"}),"; avoid repeating stable instructions here."]})]}),d.jsx(E.ConfigFields,{...P})]})]}),_&&d.jsxs("div",{className:Z(!i&&"border-b border-border"),children:[i?d.jsx("h3",{className:"text-sm font-medium mb-3",children:"Permissions & Configuration"}):d.jsx("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Permissions & Configuration"}),d.jsxs("div",{className:Z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[d.jsx(Et,{label:"Command",hint:Yt.localCommand,children:d.jsx(Mn,{value:r?D.command:m("adapterConfig","command",String(y.command??"")),onCommit:V=>r?W({command:V}):g("adapterConfig","command",V||void 0),immediate:!0,className:Zi,placeholder:C==="codex_local"?"codex":C==="gemini_local"?"gemini":C==="cursor"?"agent":C==="opencode_local"?"opencode":"claude"})}),d.jsx(ONe,{models:A,value:X,onChange:V=>r?W({model:V}):g("adapterConfig","model",V||void 0),open:M,onOpenChange:F,allowDefault:C!=="opencode_local",required:C==="opencode_local",groupByProvider:C==="opencode_local"}),T&&d.jsx("p",{className:"text-xs text-destructive",children:T instanceof Error?T.message:"Failed to load adapter models."}),le&&d.jsxs(d.Fragment,{children:[d.jsx(LNe,{value:ye,options:te,onChange:V=>r?W({thinkingEffort:V}):g("adapterConfig",L,V||void 0),open:q,onOpenChange:z}),C==="codex_local"&&Y&&ye==="minimal"&&d.jsx("p",{className:"text-xs text-amber-400",children:"Codex may reject `minimal` thinking when search is enabled."})]}),!r&&typeof y.bootstrapPromptTemplate=="string"&&y.bootstrapPromptTemplate&&d.jsxs(d.Fragment,{children:[d.jsx(Et,{label:"Bootstrap prompt (legacy)",hint:Yt.bootstrapPrompt,children:d.jsx(ka,{value:m("adapterConfig","bootstrapPromptTemplate",String(y.bootstrapPromptTemplate??"")),onChange:V=>g("adapterConfig","bootstrapPromptTemplate",V||void 0),placeholder:"Optional initial setup prompt for the first run",contentClassName:"min-h-[44px] text-sm font-mono",imageUploadHandler:async V=>{const ae=`agents/${t.agent.id}/bootstrap-prompt`;return(await c.mutateAsync({file:V,namespace:ae})).contentPath}})}),d.jsx("div",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-200",children:"Bootstrap prompt is legacy and will be removed in a future release. Consider moving this content into the agent's prompt template or instructions file instead."})]}),C==="claude_local"&&d.jsx(dce,{...P}),d.jsx(Et,{label:"Extra args (comma-separated)",hint:Yt.extraArgs,children:d.jsx(Mn,{value:r?D.extraArgs:m("adapterConfig","extraArgs",_Ne(y.extraArgs)),onCommit:V=>r?W({extraArgs:V}):g("adapterConfig","extraArgs",V?CNe(V):void 0),immediate:!0,className:Zi,placeholder:"e.g. --verbose, --foo=bar"})}),d.jsx(Et,{label:"Environment variables",hint:Yt.envVars,children:d.jsx(PNe,{value:r?D.envBindings??lP:m("adapterConfig","env",y.env??lP),secrets:a,onCreateSecret:async(V,ae)=>await l.mutateAsync({name:V,value:ae}),onChange:V=>r?W({envBindings:V??{},envVars:""}):g("adapterConfig","env",V)})}),!r&&d.jsxs(d.Fragment,{children:[d.jsx(Et,{label:"Timeout (sec)",hint:Yt.timeoutSec,children:d.jsx(Fh,{value:m("adapterConfig","timeoutSec",Number(y.timeoutSec??0)),onCommit:V=>g("adapterConfig","timeoutSec",V),immediate:!0,className:Zi})}),d.jsx(Et,{label:"Interrupt grace period (sec)",hint:Yt.graceSec,children:d.jsx(Fh,{value:m("adapterConfig","graceSec",Number(y.graceSec??15)),onCommit:V=>g("adapterConfig","graceSec",V),immediate:!0,className:Zi})})]})]})]}),r?d.jsxs("div",{className:Z(!i&&"border-b border-border"),children:[i?d.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[d.jsx(Dh,{className:"h-3 w-3"})," Run Policy"]}):d.jsxs("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground flex items-center gap-2",children:[d.jsx(Dh,{className:"h-3 w-3"})," Run Policy"]}),d.jsx("div",{className:Z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:d.jsx(FA,{label:"Heartbeat on interval",hint:Yt.heartbeatInterval,checked:D.heartbeatEnabled,onCheckedChange:V=>W({heartbeatEnabled:V}),number:D.intervalSec,onNumberChange:V=>W({intervalSec:V}),numberLabel:"sec",numberPrefix:"Run heartbeat every",numberHint:Yt.intervalSec,showNumber:D.heartbeatEnabled})})]}):d.jsxs("div",{className:Z(!i&&"border-b border-border"),children:[i?d.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[d.jsx(Dh,{className:"h-3 w-3"})," Run Policy"]}):d.jsxs("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground flex items-center gap-2",children:[d.jsx(Dh,{className:"h-3 w-3"})," Run Policy"]}),d.jsxs("div",{className:Z(i?"border border-border rounded-lg overflow-hidden":""),children:[d.jsx("div",{className:Z(i?"p-4 space-y-3":"px-4 pb-3 space-y-3"),children:d.jsx(FA,{label:"Heartbeat on interval",hint:Yt.heartbeatInterval,checked:m("heartbeat","enabled",k.enabled!==!1),onCheckedChange:V=>g("heartbeat","enabled",V),number:m("heartbeat","intervalSec",Number(k.intervalSec??300)),onNumberChange:V=>g("heartbeat","intervalSec",V),numberLabel:"sec",numberPrefix:"Run heartbeat every",numberHint:Yt.intervalSec,showNumber:m("heartbeat","enabled",k.enabled!==!1)})}),d.jsx(Jle,{title:"Advanced Run Policy",bordered:i,open:O,onToggle:()=>R(!O),children:d.jsxs("div",{className:"space-y-3",children:[d.jsx(Cp,{label:"Wake on demand",hint:Yt.wakeOnDemand,checked:m("heartbeat","wakeOnDemand",k.wakeOnDemand!==!1),onChange:V=>g("heartbeat","wakeOnDemand",V)}),d.jsx(Et,{label:"Cooldown (sec)",hint:Yt.cooldownSec,children:d.jsx(Fh,{value:m("heartbeat","cooldownSec",Number(k.cooldownSec??10)),onCommit:V=>g("heartbeat","cooldownSec",V),immediate:!0,className:Zi})}),d.jsx(Et,{label:"Max concurrent runs",hint:Yt.maxConcurrentRuns,children:d.jsx(Fh,{value:m("heartbeat","maxConcurrentRuns",Number(k.maxConcurrentRuns??1)),onCommit:V=>g("heartbeat","maxConcurrentRuns",V),immediate:!0,className:Zi})})]})})]})]})]})}function INe({result:t}){const e=t.status==="pass"?"Passed":t.status==="warn"?"Warnings":"Failed",n=t.status==="pass"?"text-green-700 dark:text-green-300 border-green-300 dark:border-green-500/40 bg-green-50 dark:bg-green-500/10":t.status==="warn"?"text-amber-700 dark:text-amber-300 border-amber-300 dark:border-amber-500/40 bg-amber-50 dark:bg-amber-500/10":"text-red-700 dark:text-red-300 border-red-300 dark:border-red-500/40 bg-red-50 dark:bg-red-500/10";return d.jsxs("div",{className:`rounded-md border px-3 py-2 text-xs ${n}`,children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("span",{className:"font-medium",children:e}),d.jsx("span",{className:"text-[11px] opacity-80",children:new Date(t.testedAt).toLocaleTimeString()})]}),d.jsx("div",{className:"mt-2 space-y-1.5",children:t.checks.map((r,i)=>d.jsxs("div",{className:"text-[11px] leading-relaxed break-words",children:[d.jsx("span",{className:"font-medium uppercase tracking-wide opacity-80",children:r.level}),d.jsx("span",{className:"mx-1 opacity-60",children:"·"}),d.jsx("span",{children:r.message}),r.detail&&d.jsxs("span",{className:"block opacity-75 break-all",children:["(",r.detail,")"]}),r.hint&&d.jsxs("span",{className:"block opacity-90 break-words",children:["Hint: ",r.hint]})]},`${r.code}-${i}`))})]})}const jNe=new Set(["claude_local","codex_local","gemini_local","opencode_local","pi_local","cursor"]),MNe=[...Nm.map(t=>({value:t,label:R8[t]??t,comingSoon:!jNe.has(t)}))];function RNe({value:t,onChange:e}){return d.jsxs(ni,{children:[d.jsx(ri,{asChild:!0,children:d.jsxs("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent/50 transition-colors w-full justify-between",children:[d.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t==="opencode_local"?d.jsx(m_,{className:"h-3.5 w-3.5"}):null,d.jsx("span",{children:R8[t]??t})]}),d.jsx(_i,{className:"h-3 w-3 text-muted-foreground"})]})}),d.jsx(ii,{className:"w-[var(--radix-popover-trigger-width)] p-1",align:"start",children:MNe.map(n=>d.jsxs("button",{disabled:n.comingSoon,className:Z("flex items-center justify-between w-full px-2 py-1.5 text-sm rounded",n.comingSoon?"opacity-40 cursor-not-allowed":"hover:bg-accent/50",n.value===t&&!n.comingSoon&&"bg-accent"),onClick:()=>{n.comingSoon||e(n.value)},children:[d.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.value==="opencode_local"?d.jsx(m_,{className:"h-3.5 w-3.5"}):null,d.jsx("span",{children:n.label})]}),n.comingSoon&&d.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Coming soon"})]},n.value))})]})}function PNe({value:t,secrets:e,onCreateSecret:n,onChange:r}){function i(g){return!g||typeof g!="object"?[{key:"",source:"plain",plainValue:"",secretId:""}]:[...Object.entries(g).map(([v,y])=>{if(typeof y=="string")return{key:v,source:"plain",plainValue:y,secretId:""};if(typeof y=="object"&&y!==null&&"type"in y&&y.type==="secret_ref"){const w=y;return{key:v,source:"secret",plainValue:"",secretId:typeof w.secretId=="string"?w.secretId:""}}if(typeof y=="object"&&y!==null&&"type"in y&&y.type==="plain"){const w=y;return{key:v,source:"plain",plainValue:typeof w.value=="string"?w.value:"",secretId:""}}return{key:v,source:"plain",plainValue:"",secretId:""}}),{key:"",source:"plain",plainValue:"",secretId:""}]}const[s,o]=x.useState(()=>i(t)),[a,l]=x.useState(null),c=x.useRef(t);x.useEffect(()=>{t!==c.current&&(c.current=t,o(i(t)))},[t]);function u(g){const b={};for(const v of g){const y=v.key.trim();if(y)if(v.source==="secret"){if(!v.secretId)continue;b[y]={type:"secret_ref",secretId:v.secretId,version:"latest"}}else b[y]={type:"plain",value:v.plainValue}}r(Object.keys(b).length>0?b:void 0)}function f(g,b){const v=s.map((y,w)=>w===g?{...y,...b}:y);(v[v.length-1].key||v[v.length-1].plainValue||v[v.length-1].secretId)&&v.push({key:"",source:"plain",plainValue:"",secretId:""}),o(v),u(v)}function h(g){const b=s.filter((v,y)=>y!==g);(b.length===0||b[b.length-1].key||b[b.length-1].plainValue||b[b.length-1].secretId)&&b.push({key:"",source:"plain",plainValue:"",secretId:""}),o(b),u(b)}function p(g){return g.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"").slice(0,64)}async function m(g){var C;const b=s[g];if(!b)return;const v=b.key.trim(),y=b.plainValue;if(!v||y.length===0)return;const w=p(v)||"secret",k=(C=window.prompt("Secret name",w))==null?void 0:C.trim();if(k)try{l(null);const _=await n(k,y);f(g,{source:"secret",secretId:_.id})}catch(_){l(_ instanceof Error?_.message:"Failed to create secret")}}return d.jsxs("div",{className:"space-y-1.5",children:[s.map((g,b)=>{const v=b===s.length-1&&!g.key&&!g.plainValue&&!g.secretId;return d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("input",{className:Z(Zi,"flex-[2]"),placeholder:"KEY",value:g.key,onChange:y=>f(b,{key:y.target.value})}),d.jsxs("select",{className:Z(Zi,"flex-[1] bg-background"),value:g.source,onChange:y=>f(b,{source:y.target.value==="secret"?"secret":"plain",...y.target.value==="plain"?{secretId:""}:{}}),children:[d.jsx("option",{value:"plain",children:"Plain"}),d.jsx("option",{value:"secret",children:"Secret"})]}),g.source==="secret"?d.jsxs(d.Fragment,{children:[d.jsxs("select",{className:Z(Zi,"flex-[3] bg-background"),value:g.secretId,onChange:y=>f(b,{secretId:y.target.value}),children:[d.jsx("option",{value:"",children:"Select secret..."}),e.map(y=>d.jsx("option",{value:y.id,children:y.name},y.id))]}),d.jsx("button",{type:"button",className:"inline-flex items-center rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground hover:bg-accent/50 transition-colors shrink-0",onClick:()=>m(b),disabled:!g.key.trim()||!g.plainValue,title:"Create secret from current plain value",children:"New"})]}):d.jsxs(d.Fragment,{children:[d.jsx("input",{className:Z(Zi,"flex-[3]"),placeholder:"value",value:g.plainValue,onChange:y=>f(b,{plainValue:y.target.value})}),d.jsx("button",{type:"button",className:"inline-flex items-center rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground hover:bg-accent/50 transition-colors shrink-0",onClick:()=>m(b),disabled:!g.key.trim()||!g.plainValue,title:"Store value as secret and replace with reference",children:"Seal"})]}),v?d.jsx("div",{className:"w-[26px] shrink-0"}):d.jsx("button",{type:"button",className:"shrink-0 p-1 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors",onClick:()=>h(b),children:d.jsx(Pa,{className:"h-3.5 w-3.5"})})]},b)}),a&&d.jsx("p",{className:"text-[11px] text-destructive",children:a}),d.jsx("p",{className:"text-[11px] text-muted-foreground/60",children:"PAPERCLIP_* variables are injected automatically at runtime."})]})}function ONe({models:t,value:e,onChange:n,open:r,onOpenChange:i,allowDefault:s,required:o,groupByProvider:a}){const[l,c]=x.useState(""),u=t.find(p=>p.id===e),f=x.useMemo(()=>t.filter(p=>{if(!l.trim())return!0;const m=l.toLowerCase(),g=nC(p.id)??"";return p.id.toLowerCase().includes(m)||p.label.toLowerCase().includes(m)||g.toLowerCase().includes(m)}),[t,l]),h=x.useMemo(()=>{if(!a)return[{provider:"models",entries:[...f].sort((m,g)=>m.id.localeCompare(g.id))}];const p=new Map;for(const m of f){const g=nC(m.id)??"other",b=p.get(g)??[];b.push(m),p.set(g,b)}return Array.from(p.entries()).sort(([m],[g])=>m.localeCompare(g)).map(([m,g])=>({provider:m,entries:[...g].sort((b,v)=>b.id.localeCompare(v.id))}))},[f,a]);return d.jsx(Et,{label:"Model",hint:Yt.model,children:d.jsxs(ni,{open:r,onOpenChange:p=>{i(p),p||c("")},children:[d.jsx(ri,{asChild:!0,children:d.jsxs("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent/50 transition-colors w-full justify-between",children:[d.jsx("span",{className:Z(!e&&"text-muted-foreground"),children:u?u.label:e||(s?"Default":o?"Select model (required)":"Select model")}),d.jsx(_i,{className:"h-3 w-3 text-muted-foreground"})]})}),d.jsxs(ii,{className:"w-[var(--radix-popover-trigger-width)] p-1",align:"start",children:[d.jsx("input",{className:"w-full px-2 py-1.5 text-xs bg-transparent outline-none border-b border-border mb-1 placeholder:text-muted-foreground/50",placeholder:"Search models...",value:l,onChange:p=>c(p.target.value),autoFocus:!0}),d.jsxs("div",{className:"max-h-[240px] overflow-y-auto",children:[s&&d.jsx("button",{className:Z("flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",!e&&"bg-accent"),onClick:()=>{n(""),i(!1)},children:"Default"}),h.map(p=>d.jsxs("div",{className:"mb-1 last:mb-0",children:[a&&d.jsxs("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:[p.provider," (",p.entries.length,")"]}),p.entries.map(m=>d.jsx("button",{className:Z("flex items-center w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",m.id===e&&"bg-accent"),onClick:()=>{n(m.id),i(!1)},children:d.jsx("span",{className:"block w-full text-left truncate",title:m.id,children:a?M8(m.id):m.label})},m.id))]},p.provider)),f.length===0&&d.jsx("p",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No models found."})]})]})]})})}function LNe({value:t,options:e,onChange:n,open:r,onOpenChange:i}){const s=e.find(o=>o.id===t)??e[0];return d.jsx(Et,{label:"Thinking effort",hint:Yt.thinkingEffort,children:d.jsxs(ni,{open:r,onOpenChange:i,children:[d.jsx(ri,{asChild:!0,children:d.jsxs("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent/50 transition-colors w-full justify-between",children:[d.jsx("span",{className:Z(!t&&"text-muted-foreground"),children:(s==null?void 0:s.label)??"Auto"}),d.jsx(_i,{className:"h-3 w-3 text-muted-foreground"})]})}),d.jsx(ii,{className:"w-[var(--radix-popover-trigger-width)] p-1",align:"start",children:e.map(o=>d.jsxs("button",{className:Z("flex items-center justify-between w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",o.id===t&&"bg-accent"),onClick:()=>{n(o.id),i(!1)},children:[d.jsx("span",{children:o.label}),o.id?d.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:o.id}):null]},o.id||"auto"))})]})})}function MU({className:t,orientation:e="horizontal",...n}){return d.jsx(cee,{"data-slot":"tabs","data-orientation":e,orientation:e,className:Z("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",t),...n})}const DNe=JS("p-[3px] group-data-[orientation=horizontal]/tabs:h-9 group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function RU({className:t,variant:e="default",...n}){return d.jsx(uee,{"data-slot":"tabs-list","data-variant":e,className:Z(DNe({variant:e}),t),...n})}function yd({className:t,...e}){return d.jsx(dee,{"data-slot":"tabs-trigger",className:Z("focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,background-color,border-color,box-shadow] group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:bg-background dark:data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 data-[state=active]:text-foreground","after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",t),...e})}function _h({className:t,...e}){return d.jsx(fee,{"data-slot":"tabs-content",className:Z("flex-1 outline-none",t),...e})}function FNe({items:t,value:e,onValueChange:n,align:r="center"}){const{isMobile:i}=Rb();return i&&e!==void 0&&n?d.jsx("select",{value:e,onChange:s=>n(s.target.value),className:"h-9 rounded-md border border-border bg-background px-2 py-1 text-base focus:outline-none focus:ring-1 focus:ring-ring",children:t.map(s=>d.jsx("option",{value:s.value,children:typeof s.label=="string"?s.label:s.value},s.value))}):d.jsx(RU,{variant:"line",className:r==="start"?"justify-start":void 0,children:t.map(s=>d.jsx(yd,{value:s.value,children:s.label},s.value))})}const $Ne={backlog:"text-muted-foreground border-muted-foreground",todo:"text-blue-600 border-blue-600 dark:text-blue-400 dark:border-blue-400",in_progress:"text-yellow-600 border-yellow-600 dark:text-yellow-400 dark:border-yellow-400",in_review:"text-violet-600 border-violet-600 dark:text-violet-400 dark:border-violet-400",done:"text-green-600 border-green-600 dark:text-green-400 dark:border-green-400",cancelled:"text-neutral-500 border-neutral-500",blocked:"text-red-600 border-red-600 dark:text-red-400 dark:border-red-400"},BNe="text-muted-foreground border-muted-foreground",Sh={backlog:"text-muted-foreground",todo:"text-blue-600 dark:text-blue-400",in_progress:"text-yellow-600 dark:text-yellow-400",in_review:"text-violet-600 dark:text-violet-400",done:"text-green-600 dark:text-green-400"},VNe={active:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",running:"bg-cyan-100 text-cyan-700 dark:bg-cyan-900/50 dark:text-cyan-300",paused:"bg-orange-100 text-orange-700 dark:bg-orange-900/50 dark:text-orange-300",idle:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-300",archived:"bg-muted text-muted-foreground",planned:"bg-muted text-muted-foreground",achieved:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",completed:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",failed:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",timed_out:"bg-orange-100 text-orange-700 dark:bg-orange-900/50 dark:text-orange-300",succeeded:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",error:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",terminated:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",pending:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-300",pending_approval:"bg-amber-100 text-amber-700 dark:bg-amber-900/50 dark:text-amber-300",revision_requested:"bg-amber-100 text-amber-700 dark:bg-amber-900/50 dark:text-amber-300",approved:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",rejected:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",backlog:"bg-muted text-muted-foreground",todo:"bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300",in_progress:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-300",in_review:"bg-violet-100 text-violet-700 dark:bg-violet-900/50 dark:text-violet-300",blocked:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",done:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",cancelled:"bg-muted text-muted-foreground"},zNe="bg-muted text-muted-foreground",r4e={running:"bg-cyan-400 animate-pulse",active:"bg-green-400",paused:"bg-yellow-400",idle:"bg-yellow-400",pending_approval:"bg-amber-400",error:"bg-red-400",archived:"bg-neutral-400"},i4e="bg-neutral-400",Il={critical:"text-red-600 dark:text-red-400",high:"text-orange-600 dark:text-orange-400",medium:"text-yellow-600 dark:text-yellow-400",low:"text-blue-600 dark:text-blue-400"};function Ha({status:t}){return d.jsx("span",{className:Z("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium whitespace-nowrap shrink-0",VNe[t]??zNe),children:t.replace("_"," ")})}function HNe(t,e){const n={};return(t[t.length-1]===""?[...t,""]:t).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const UNe=/[ \t\n\f\r]/g;function WNe(t){return typeof t=="object"?t.type==="text"?cP(t.value):!1:cP(t)}function cP(t){return t.replace(UNe,"")===""}class lg{constructor(e,n,r){this.normal=n,this.property=e,r&&(this.space=r)}}lg.prototype.normal={};lg.prototype.property={};lg.prototype.space=void 0;function PU(t,e){const n={},r={};for(const i of t)Object.assign(n,i.property),Object.assign(r,i.normal);return new lg(n,r,e)}function g_(t){return t.toLowerCase()}class Ti{constructor(e,n){this.attribute=n,this.property=e}}Ti.prototype.attribute="";Ti.prototype.booleanish=!1;Ti.prototype.boolean=!1;Ti.prototype.commaOrSpaceSeparated=!1;Ti.prototype.commaSeparated=!1;Ti.prototype.defined=!1;Ti.prototype.mustUseProperty=!1;Ti.prototype.number=!1;Ti.prototype.overloadedBoolean=!1;Ti.prototype.property="";Ti.prototype.spaceSeparated=!1;Ti.prototype.space=void 0;let KNe=0;const kt=Wu(),Zn=Wu(),x_=Wu(),Ie=Wu(),kn=Wu(),Hd=Wu(),Ai=Wu();function Wu(){return 2**++KNe}const y_=Object.freeze(Object.defineProperty({__proto__:null,boolean:kt,booleanish:Zn,commaOrSpaceSeparated:Ai,commaSeparated:Hd,number:Ie,overloadedBoolean:x_,spaceSeparated:kn},Symbol.toStringTag,{value:"Module"})),Dw=Object.keys(y_);class PT extends Ti{constructor(e,n,r,i){let s=-1;if(super(e,n),uP(this,"space",i),typeof r=="number")for(;++s<Dw.length;){const o=Dw[s];uP(this,Dw[s],(r&y_[o])===y_[o])}}}PT.prototype.defined=!0;function uP(t,e,n){n&&(t[e]=n)}function nh(t){const e={},n={};for(const[r,i]of Object.entries(t.properties)){const s=new PT(r,t.transform(t.attributes||{},r),i,t.space);t.mustUseProperty&&t.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),e[r]=s,n[g_(r)]=r,n[g_(s.attribute)]=r}return new lg(e,n,t.space)}const OU=nh({properties:{ariaActiveDescendant:null,ariaAtomic:Zn,ariaAutoComplete:null,ariaBusy:Zn,ariaChecked:Zn,ariaColCount:Ie,ariaColIndex:Ie,ariaColSpan:Ie,ariaControls:kn,ariaCurrent:null,ariaDescribedBy:kn,ariaDetails:null,ariaDisabled:Zn,ariaDropEffect:kn,ariaErrorMessage:null,ariaExpanded:Zn,ariaFlowTo:kn,ariaGrabbed:Zn,ariaHasPopup:null,ariaHidden:Zn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:kn,ariaLevel:Ie,ariaLive:null,ariaModal:Zn,ariaMultiLine:Zn,ariaMultiSelectable:Zn,ariaOrientation:null,ariaOwns:kn,ariaPlaceholder:null,ariaPosInSet:Ie,ariaPressed:Zn,ariaReadOnly:Zn,ariaRelevant:null,ariaRequired:Zn,ariaRoleDescription:kn,ariaRowCount:Ie,ariaRowIndex:Ie,ariaRowSpan:Ie,ariaSelected:Zn,ariaSetSize:Ie,ariaSort:null,ariaValueMax:Ie,ariaValueMin:Ie,ariaValueNow:Ie,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function LU(t,e){return e in t?t[e]:e}function DU(t,e){return LU(t,e.toLowerCase())}const qNe=nh({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Hd,acceptCharset:kn,accessKey:kn,action:null,allow:null,allowFullScreen:kt,allowPaymentRequest:kt,allowUserMedia:kt,alt:null,as:null,async:kt,autoCapitalize:null,autoComplete:kn,autoFocus:kt,autoPlay:kt,blocking:kn,capture:null,charSet:null,checked:kt,cite:null,className:kn,cols:Ie,colSpan:null,content:null,contentEditable:Zn,controls:kt,controlsList:kn,coords:Ie|Hd,crossOrigin:null,data:null,dateTime:null,decoding:null,default:kt,defer:kt,dir:null,dirName:null,disabled:kt,download:x_,draggable:Zn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:kt,formTarget:null,headers:kn,height:Ie,hidden:x_,high:Ie,href:null,hrefLang:null,htmlFor:kn,httpEquiv:kn,id:null,imageSizes:null,imageSrcSet:null,inert:kt,inputMode:null,integrity:null,is:null,isMap:kt,itemId:null,itemProp:kn,itemRef:kn,itemScope:kt,itemType:kn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:kt,low:Ie,manifest:null,max:null,maxLength:Ie,media:null,method:null,min:null,minLength:Ie,multiple:kt,muted:kt,name:null,nonce:null,noModule:kt,noValidate:kt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:kt,optimum:Ie,pattern:null,ping:kn,placeholder:null,playsInline:kt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:kt,referrerPolicy:null,rel:kn,required:kt,reversed:kt,rows:Ie,rowSpan:Ie,sandbox:kn,scope:null,scoped:kt,seamless:kt,selected:kt,shadowRootClonable:kt,shadowRootDelegatesFocus:kt,shadowRootMode:null,shape:null,size:Ie,sizes:null,slot:null,span:Ie,spellCheck:Zn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ie,step:null,style:null,tabIndex:Ie,target:null,title:null,translate:null,type:null,typeMustMatch:kt,useMap:null,value:Zn,width:Ie,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:kn,axis:null,background:null,bgColor:null,border:Ie,borderColor:null,bottomMargin:Ie,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:kt,declare:kt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ie,leftMargin:Ie,link:null,longDesc:null,lowSrc:null,marginHeight:Ie,marginWidth:Ie,noResize:kt,noHref:kt,noShade:kt,noWrap:kt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ie,rules:null,scheme:null,scrolling:Zn,standby:null,summary:null,text:null,topMargin:Ie,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ie,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:kt,disableRemotePlayback:kt,prefix:null,property:null,results:Ie,security:null,unselectable:null},space:"html",transform:DU}),GNe=nh({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Ai,accentHeight:Ie,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ie,amplitude:Ie,arabicForm:null,ascent:Ie,attributeName:null,attributeType:null,azimuth:Ie,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ie,by:null,calcMode:null,capHeight:Ie,className:kn,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ie,diffuseConstant:Ie,direction:null,display:null,dur:null,divisor:Ie,dominantBaseline:null,download:kt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ie,enableBackground:null,end:null,event:null,exponent:Ie,externalResourcesRequired:null,fill:null,fillOpacity:Ie,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Hd,g2:Hd,glyphName:Hd,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ie,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ie,horizOriginX:Ie,horizOriginY:Ie,id:null,ideographic:Ie,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ie,k:Ie,k1:Ie,k2:Ie,k3:Ie,k4:Ie,kernelMatrix:Ai,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ie,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ie,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ie,overlineThickness:Ie,paintOrder:null,panose1:null,path:null,pathLength:Ie,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:kn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ie,pointsAtY:Ie,pointsAtZ:Ie,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ai,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ai,rev:Ai,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ai,requiredFeatures:Ai,requiredFonts:Ai,requiredFormats:Ai,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ie,specularExponent:Ie,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ie,strikethroughThickness:Ie,string:null,stroke:null,strokeDashArray:Ai,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ie,strokeOpacity:Ie,strokeWidth:null,style:null,surfaceScale:Ie,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ai,tabIndex:Ie,tableValues:null,target:null,targetX:Ie,targetY:Ie,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ai,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ie,underlineThickness:Ie,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ie,values:null,vAlphabetic:Ie,vMathematical:Ie,vectorEffect:null,vHanging:Ie,vIdeographic:Ie,version:null,vertAdvY:Ie,vertOriginX:Ie,vertOriginY:Ie,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ie,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:LU}),FU=nh({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,e){return"xlink:"+e.slice(5).toLowerCase()}}),$U=nh({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:DU}),BU=nh({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),JNe={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},ZNe=/[A-Z]/g,dP=/-[a-z]/g,YNe=/^data[-\w.:]+$/i;function QNe(t,e){const n=g_(e);let r=e,i=Ti;if(n in t.normal)return t.property[t.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&YNe.test(e)){if(e.charAt(4)==="-"){const s=e.slice(5).replace(dP,eAe);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=e.slice(4);if(!dP.test(s)){let o=s.replace(ZNe,XNe);o.charAt(0)!=="-"&&(o="-"+o),e="data"+o}}i=PT}return new i(r,e)}function XNe(t){return"-"+t.toLowerCase()}function eAe(t){return t.charAt(1).toUpperCase()}const tAe=PU([OU,qNe,FU,$U,BU],"html"),OT=PU([OU,GNe,FU,$U,BU],"svg");function nAe(t){return t.join(" ").trim()}var sd={},Fw,fP;function rAe(){if(fP)return Fw;fP=1;var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,e=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,a=/^\s+|\s+$/g,l=`
807
+ `);Y!==ye&&(m.current=Y,(V=p.current)==null||V.setMarkdown(Y),n(Y),requestAnimationFrame(()=>{var ae;(ae=p.current)==null||ae.focus(void 0,{defaultSelection:"rootEnd"})}))},100),te}catch(te){const ye=te instanceof Error?te.message:"Image upload failed";throw b(ye),te}}:void 0,$=[Mbe(),Qbe(),Rwe(),M1e(),q1e(),OTe(),$be(),Hwe({defaultCodeBlockLanguage:"txt",codeBlockEditorDescriptors:[yNe]}),jTe({codeBlockLanguages:xNe}),dNe()];return N&&$.push(kwe({imageUploadHandler:N})),$},[R]);x.useEffect(()=>{var N;e!==m.current&&((N=p.current)==null||N.setMarkdown(e),m.current=e)},[e]);const F=x.useCallback(()=>{var X;const N=(X=h.current)==null?void 0:X.querySelector('[contenteditable="true"]');if(!N)return;const $=N.querySelectorAll("a");for(const L of $){const te=L,ye=B6(te.getAttribute("href")??"");if(!ye){te.dataset.projectMention==="true"&&(te.dataset.projectMention="false",te.classList.remove("paperclip-project-mention-chip"),te.removeAttribute("contenteditable"),te.style.removeProperty("border-color"),te.style.removeProperty("background-color"),te.style.removeProperty("color"));continue}const le=ye.color??P.get(ye.projectId)??null;te.dataset.projectMention="true",te.classList.add("paperclip-project-mention-chip"),te.setAttribute("contenteditable","false");const Y=wNe(le);Y&&(te.style.borderColor=Y.borderColor??"",te.style.backgroundColor=Y.backgroundColor??"",te.style.color=Y.color??"")}},[P]),q=x.useCallback(()=>{if(!c||c.length===0||!h.current){E.current=null,_(null);return}const N=bNe(h.current);E.current=N,N?(_(N),T(0)):_(null)},[c]);x.useEffect(()=>{if(!c||c.length===0)return;const N=h.current,$=()=>requestAnimationFrame(q);return document.addEventListener("selectionchange",q),N==null||N.addEventListener("input",$,!0),()=>{document.removeEventListener("selectionchange",q),N==null||N.removeEventListener("input",$,!0)}},[q,c]),x.useEffect(()=>{var X;const N=(X=h.current)==null?void 0:X.querySelector('[contenteditable="true"]');if(!N)return;F();const $=new MutationObserver(()=>{F()});return $.observe(N,{subtree:!0,childList:!0,characterData:!0}),()=>$.disconnect()},[F,e]);const z=x.useCallback(N=>{var te,ye;const $=E.current;if(!$)return;if(N.kind==="project"&&N.projectId){const le=m.current,Y=aP(le,$.query,N);Y!==le&&(m.current=Y,(te=p.current)==null||te.setMarkdown(Y),n(Y)),requestAnimationFrame(()=>{var V;(V=p.current)==null||V.focus(void 0,{defaultSelection:"rootEnd"}),F()}),E.current=null,_(null);return}const X=jU(N),L=window.getSelection();if(L&&$.textNode.isConnected){const le=document.createRange();le.setStart($.textNode,$.atPos),le.setEnd($.textNode,$.endPos),L.removeAllRanges(),L.addRange(le),document.execCommand("insertText",!1,X);const Y=$.atPos+X.length;requestAnimationFrame(()=>{var $e,tt;const V=window.getSelection();if(!V)return;if($.textNode.isConnected){const ft=(($e=$.textNode.textContent)==null?void 0:$e.length)??0;if(Y<=ft){const ht=document.createRange();ht.setStart($.textNode,Y),ht.collapse(!0),V.removeAllRanges(),V.addRange(ht);return}}const ae=(tt=h.current)==null?void 0:tt.querySelector('[contenteditable="true"]');if(!ae)return;const ce=document.createTreeWalker(ae,NodeFilter.SHOW_TEXT);let xe;for(;xe=ce.nextNode();){const ft=xe.textContent??"",ht=ft.indexOf(X);if(ht!==-1){const lt=ht+X.length;if(lt<=ft.length){const yt=document.createRange();yt.setStart(xe,lt),yt.collapse(!0),V.removeAllRanges(),V.addRange(yt);return}}}})}else{const le=m.current,Y=aP(le,$.query,N);Y!==le&&(m.current=Y,(ye=p.current)==null||ye.setMarkdown(Y),n(Y)),requestAnimationFrame(()=>{var V;(V=p.current)==null||V.focus(void 0,{defaultSelection:"rootEnd"})})}requestAnimationFrame(()=>{F()}),E.current=null,_(null)},[F,n]);function D(N){var $;return Array.from((($=N.dataTransfer)==null?void 0:$.types)??[]).includes("Files")}const W=!!a;return d.jsxs("div",{ref:h,className:Z("relative paperclip-mdxeditor-scope",l?"rounded-md border border-border bg-transparent":"bg-transparent",v&&"ring-1 ring-primary/60 bg-accent/20",i),onKeyDownCapture:N=>{if(u&&N.key==="Enter"&&(N.metaKey||N.ctrlKey)){N.preventDefault(),N.stopPropagation(),u();return}if(A){if(N.key===" "){E.current=null,_(null);return}if(N.key==="Escape"){N.preventDefault(),N.stopPropagation(),E.current=null,_(null);return}if(O.length>0){if(N.key==="ArrowDown"){N.preventDefault(),N.stopPropagation(),T($=>Math.min($+1,O.length-1));return}if(N.key==="ArrowUp"){N.preventDefault(),N.stopPropagation(),T($=>Math.max($-1,0));return}if(N.key==="Enter"||N.key==="Tab"){N.preventDefault(),N.stopPropagation(),z(O[S]);return}}}},onDragEnter:N=>{!W||!D(N)||(w.current+=1,y(!0))},onDragOver:N=>{!W||!D(N)||(N.preventDefault(),N.dataTransfer.dropEffect="copy")},onDragLeave:()=>{W&&(w.current=Math.max(0,w.current-1),w.current===0&&y(!1))},onDrop:()=>{w.current=0,y(!1)},children:[d.jsx(Ebe,{ref:p,markdown:e,placeholder:r,onChange:N=>{m.current=N,n(N)},onBlur:()=>o==null?void 0:o(),className:Z("paperclip-mdxeditor",!l&&"paperclip-mdxeditor--borderless"),contentEditableClassName:Z("paperclip-mdxeditor-content focus:outline-none [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5 [&_li]:list-item",s),plugins:M}),A&&O.length>0&&d.jsx("div",{className:"absolute z-50 min-w-[180px] max-h-[200px] overflow-y-auto rounded-md border border-border bg-popover shadow-md",style:{top:C.top+4,left:C.left},children:O.map((N,$)=>d.jsxs("button",{className:Z("flex items-center gap-2 w-full px-3 py-1.5 text-sm text-left hover:bg-accent/50 transition-colors",$===S&&"bg-accent"),onMouseDown:X=>{X.preventDefault(),z(N)},onMouseEnter:()=>T($),children:[N.kind==="project"&&N.projectId?d.jsx("span",{className:"inline-flex h-2 w-2 rounded-full border border-border/50",style:{backgroundColor:N.projectColor??"#64748b"}}):d.jsx("span",{className:"text-muted-foreground",children:"@"}),d.jsx("span",{children:N.name}),N.kind==="project"&&N.projectId&&d.jsx("span",{className:"ml-auto text-[10px] uppercase tracking-wide text-muted-foreground",children:"Project"})]},N.id))}),v&&W&&d.jsx("div",{className:Z("pointer-events-none absolute inset-1 z-40 flex items-center justify-center rounded-md border border-dashed border-primary/80 bg-primary/10 text-xs font-medium text-primary",!l&&"inset-0 rounded-sm"),children:"Drop image to upload"}),g&&d.jsx("p",{className:"px-3 pb-2 text-xs text-destructive",children:g})]})});function m_({className:t}){return d.jsxs(d.Fragment,{children:[d.jsx("img",{src:"/brands/opencode-logo-light-square.svg",alt:"OpenCode",className:Z("dark:hidden",t)}),d.jsx("img",{src:"/brands/opencode-logo-dark-square.svg",alt:"OpenCode",className:Z("hidden dark:block",t)})]})}const Lw={identity:{},adapterConfig:{},heartbeat:{},runtime:{}},lP={};function kNe(t){return Object.keys(t.identity).length>0||t.adapterType!==void 0||Object.keys(t.adapterConfig).length>0||Object.keys(t.heartbeat).length>0||Object.keys(t.runtime).length>0}const Zi="w-full rounded-md border border-border px-2.5 py-1.5 bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40";function CNe(t){return t.split(",").map(e=>e.trim()).filter(Boolean)}function _Ne(t){return Array.isArray(t)?t.filter(e=>typeof e=="string").join(", "):typeof t=="string"?t:""}const SNe=[{id:"",label:"Auto"},{id:"minimal",label:"Minimal"},{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"}],ENe=[{id:"",label:"Auto"},{id:"minimal",label:"Minimal"},{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"max",label:"Max"}],TNe=[{id:"",label:"Auto"},{id:"plan",label:"Plan"},{id:"ask",label:"Ask"}],NNe=[{id:"",label:"Auto"},{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"}];function ANe(t){const{mode:e,adapterModels:n}=t,r=e==="create",i=t.sectionLayout==="cards",{selectedCompanyId:s}=Ys(),o=ur(),{data:a=[]}=st({queryKey:s?ie.secrets.list(s):["secrets","none"],queryFn:()=>DA.list(s),enabled:!!s}),l=Bt({mutationFn:V=>{if(!s)throw new Error("Select a company to create secrets");return DA.create(s,V)},onSuccess:()=>{s&&o.invalidateQueries({queryKey:ie.secrets.list(s)})}}),c=Bt({mutationFn:async({file:V,namespace:ae})=>{if(!s)throw new Error("Select a company to upload images");return N8.uploadImage(s,V,ae)}}),[u,f]=x.useState(Lw),h=x.useRef(null);x.useEffect(()=>{r||(h.current!==null&&t.agent!==h.current&&f({...Lw}),h.current=t.agent)},[r,r?void 0:t.agent]);const p=!r&&kNe(u);function m(V,ae,ce){const xe=u[V];return ae in xe?xe[ae]:ce}function g(V,ae,ce){f(xe=>({...xe,[V]:{...xe[V],[ae]:ce}}))}const b=x.useCallback(()=>{f({...Lw})},[]),v=x.useCallback(()=>{if(r||!p)return;const V=t.agent,ae={};if(Object.keys(u.identity).length>0&&Object.assign(ae,u.identity),u.adapterType!==void 0)ae.adapterType=u.adapterType,ae.adapterConfig=u.adapterConfig;else if(Object.keys(u.adapterConfig).length>0){const ce=V.adapterConfig??{};ae.adapterConfig={...ce,...u.adapterConfig}}if(Object.keys(u.heartbeat).length>0){const ce=V.runtimeConfig??{},xe=ce.heartbeat??{};ae.runtimeConfig={...ce,heartbeat:{...xe,...u.heartbeat}}}Object.keys(u.runtime).length>0&&Object.assign(ae,u.runtime),t.onSave(ae)},[r,p,u,t]);x.useEffect(()=>{var V,ae,ce;r||((V=t.onDirtyChange)==null||V.call(t,p),(ae=t.onSaveActionChange)==null||ae.call(t,v),(ce=t.onCancelActionChange)==null||ce.call(t,b))},[r,p,t.onDirtyChange,t.onSaveActionChange,t.onCancelActionChange,v,b]),x.useEffect(()=>{if(!r)return()=>{var V,ae,ce;(V=t.onSaveActionChange)==null||V.call(t,null),(ae=t.onCancelActionChange)==null||ae.call(t,null),(ce=t.onDirtyChange)==null||ce.call(t,!1)}},[r,t.onDirtyChange,t.onSaveActionChange,t.onCancelActionChange]);const y=r?{}:t.agent.adapterConfig??{},w=r?{}:t.agent.runtimeConfig??{},k=r?{}:w.heartbeat??{},C=r?t.values.adapterType:u.adapterType??t.agent.adapterType,_=C==="claude_local"||C==="codex_local"||C==="gemini_local"||C==="opencode_local"||C==="cursor",E=x.useMemo(()=>_p(C),[C]),{data:S,error:T}=st({queryKey:s?ie.agents.adapterModels(s,C):["agents","none","adapter-models",C],queryFn:()=>Gt.adapterModels(s,C),enabled:!!s}),A=S??n??[],P={mode:e,isCreate:r,adapterType:C,values:r?t.values:null,set:r?V=>t.onChange(V):null,config:y,eff:m,mark:g,models:A},[O,R]=x.useState(!1),[M,F]=x.useState(!1),[q,z]=x.useState(!1),D=r?t.values:null,W=r?V=>t.onChange(V):null;function N(){return r?E.buildAdapterConfig(D):{...y,...u.adapterConfig}}const $=Bt({mutationFn:async()=>{if(!s)throw new Error("Select a company to test adapter environment");return Gt.testEnvironment(s,C,{adapterConfig:N()})}}),X=r?D.model:m("adapterConfig","model",String(y.model??"")),L=C==="codex_local"?"modelReasoningEffort":C==="cursor"?"mode":C==="opencode_local"?"variant":"effort",te=C==="codex_local"?SNe:C==="cursor"?TNe:C==="opencode_local"?ENe:NNe,ye=r?D.thinkingEffort:C==="codex_local"?m("adapterConfig","modelReasoningEffort",String(y.modelReasoningEffort??y.reasoningEffort??"")):C==="cursor"?m("adapterConfig","mode",String(y.mode??"")):C==="opencode_local"?m("adapterConfig","variant",String(y.variant??"")):m("adapterConfig","effort",String(y.effort??"")),le=C!=="gemini_local",Y=C==="codex_local"?r?!!D.search:m("adapterConfig","search",!!y.search):!1;return x.useMemo(()=>{if(r)return{heartbeat:{enabled:D.heartbeatEnabled,intervalSec:D.intervalSec}};const V={...w.heartbeat&&typeof w.heartbeat=="object"?w.heartbeat:{},...u.heartbeat};return{...w,heartbeat:V}},[r,u.heartbeat,w,D]),d.jsxs("div",{className:Z("relative",i&&"space-y-6"),children:[p&&!t.hideInlineSave&&d.jsx("div",{className:"sticky top-0 z-10 flex items-center justify-end px-4 py-2 bg-background/90 backdrop-blur-sm border-b border-primary/20",children:d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("span",{className:"text-xs text-muted-foreground",children:"Unsaved changes"}),d.jsx(Oe,{size:"sm",onClick:v,disabled:!r&&t.isSaving,children:!r&&t.isSaving?"Saving...":"Save"})]})}),!r&&d.jsxs("div",{className:Z(!i&&"border-b border-border"),children:[i?d.jsx("h3",{className:"text-sm font-medium mb-3",children:"Identity"}):d.jsx("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Identity"}),d.jsxs("div",{className:Z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[d.jsx(Et,{label:"Name",hint:Yt.name,children:d.jsx(Mn,{value:m("identity","name",t.agent.name),onCommit:V=>g("identity","name",V),immediate:!0,className:Zi,placeholder:"Agent name"})}),d.jsx(Et,{label:"Title",hint:Yt.title,children:d.jsx(Mn,{value:m("identity","title",t.agent.title??""),onCommit:V=>g("identity","title",V||null),immediate:!0,className:Zi,placeholder:"e.g. VP of Engineering"})}),d.jsx(Et,{label:"Capabilities",hint:Yt.capabilities,children:d.jsx(ka,{value:m("identity","capabilities",t.agent.capabilities??""),onChange:V=>g("identity","capabilities",V||null),placeholder:"Describe what this agent can do...",contentClassName:"min-h-[44px] text-sm font-mono",imageUploadHandler:async V=>(await c.mutateAsync({file:V,namespace:`agents/${t.agent.id}/capabilities`})).contentPath})}),_&&d.jsxs(d.Fragment,{children:[d.jsx(Et,{label:"Prompt Template",hint:Yt.promptTemplate,children:d.jsx(ka,{value:m("adapterConfig","promptTemplate",String(y.promptTemplate??"")),onChange:V=>g("adapterConfig","promptTemplate",V??""),placeholder:"You are agent {{ agent.name }}. Your role is {{ agent.role }}...",contentClassName:"min-h-[88px] text-sm font-mono",imageUploadHandler:async V=>{const ae=`agents/${t.agent.id}/prompt-template`;return(await c.mutateAsync({file:V,namespace:ae})).contentPath}})}),d.jsx("div",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100",children:"Prompt template is replayed on every heartbeat. Keep it compact and dynamic to avoid recurring token cost and cache churn."})]})]})]}),d.jsxs("div",{className:Z(!i&&(r?"border-t border-border":"border-b border-border")),children:[d.jsxs("div",{className:Z(i?"flex items-center justify-between mb-3":"px-4 py-2 flex items-center justify-between gap-2"),children:[i?d.jsx("h3",{className:"text-sm font-medium",children:"Adapter"}):d.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Adapter"}),d.jsx(Oe,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>$.mutate(),disabled:$.isPending||!s,children:$.isPending?"Testing...":"Test environment"})]}),d.jsxs("div",{className:Z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[d.jsx(Et,{label:"Adapter type",hint:Yt.adapterType,children:d.jsx(RNe,{value:C,onChange:V=>{if(r){const{adapterType:ae,...ce}=rC,xe={...ce,adapterType:V};V==="codex_local"?(xe.model=bp,xe.dangerouslyBypassSandbox=Py):V==="gemini_local"?xe.model=wp:V==="cursor"?xe.model=vp:V==="opencode_local"&&(xe.model=""),W(xe)}else f(ae=>({...ae,adapterType:V,adapterConfig:{model:V==="codex_local"?bp:V==="gemini_local"?wp:V==="cursor"?vp:"",effort:"",modelReasoningEffort:"",variant:"",mode:"",...V==="codex_local"?{dangerouslyBypassApprovalsAndSandbox:Py}:{}}}))}})}),$.error&&d.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:$.error instanceof Error?$.error.message:"Environment test failed"}),$.data&&d.jsx(INe,{result:$.data}),_&&d.jsx(Et,{label:"Working directory",hint:Yt.cwd,children:d.jsxs("div",{className:"space-y-1.5",children:[d.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border px-2.5 py-1.5",children:[d.jsx(m8,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),d.jsx(Mn,{value:r?D.cwd:m("adapterConfig","cwd",String(y.cwd??"")),onCommit:V=>r?W({cwd:V}):g("adapterConfig","cwd",V||void 0),immediate:!0,className:"w-full bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40",placeholder:"/path/to/project"}),d.jsx(Ws,{})]}),d.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Local adapters run inside this directory. Growthub CLI worker kits export specialized working-directory-ready environments that can be downloaded locally and pointed here directly."})]})}),_&&r&&d.jsxs(d.Fragment,{children:[d.jsx(Et,{label:"Prompt Template",hint:Yt.promptTemplate,children:d.jsx(ka,{value:D.promptTemplate,onChange:V=>W({promptTemplate:V}),placeholder:"You are agent {{ agent.name }}. Your role is {{ agent.role }}...",contentClassName:"min-h-[88px] text-sm font-mono",imageUploadHandler:async V=>(await c.mutateAsync({file:V,namespace:"agents/drafts/prompt-template"})).contentPath})}),d.jsxs("div",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100",children:["Prompt template is replayed on every heartbeat. Prefer small task framing and variables like ",d.jsx("code",{children:"{{ context.* }}"})," or ",d.jsx("code",{children:"{{ run.* }}"}),"; avoid repeating stable instructions here."]})]}),d.jsx(E.ConfigFields,{...P})]})]}),_&&d.jsxs("div",{className:Z(!i&&"border-b border-border"),children:[i?d.jsx("h3",{className:"text-sm font-medium mb-3",children:"Permissions & Configuration"}):d.jsx("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Permissions & Configuration"}),d.jsxs("div",{className:Z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[d.jsx(Et,{label:"Command",hint:Yt.localCommand,children:d.jsx(Mn,{value:r?D.command:m("adapterConfig","command",String(y.command??"")),onCommit:V=>r?W({command:V}):g("adapterConfig","command",V||void 0),immediate:!0,className:Zi,placeholder:C==="codex_local"?"codex":C==="gemini_local"?"gemini":C==="cursor"?"agent":C==="opencode_local"?"opencode":"claude"})}),d.jsx(ONe,{models:A,value:X,onChange:V=>r?W({model:V}):g("adapterConfig","model",V||void 0),open:M,onOpenChange:F,allowDefault:C!=="opencode_local",required:C==="opencode_local",groupByProvider:C==="opencode_local"}),T&&d.jsx("p",{className:"text-xs text-destructive",children:T instanceof Error?T.message:"Failed to load adapter models."}),le&&d.jsxs(d.Fragment,{children:[d.jsx(LNe,{value:ye,options:te,onChange:V=>r?W({thinkingEffort:V}):g("adapterConfig",L,V||void 0),open:q,onOpenChange:z}),C==="codex_local"&&Y&&ye==="minimal"&&d.jsx("p",{className:"text-xs text-amber-400",children:"Codex may reject `minimal` thinking when search is enabled."})]}),!r&&typeof y.bootstrapPromptTemplate=="string"&&y.bootstrapPromptTemplate&&d.jsxs(d.Fragment,{children:[d.jsx(Et,{label:"Bootstrap prompt (legacy)",hint:Yt.bootstrapPrompt,children:d.jsx(ka,{value:m("adapterConfig","bootstrapPromptTemplate",String(y.bootstrapPromptTemplate??"")),onChange:V=>g("adapterConfig","bootstrapPromptTemplate",V||void 0),placeholder:"Optional initial setup prompt for the first run",contentClassName:"min-h-[44px] text-sm font-mono",imageUploadHandler:async V=>{const ae=`agents/${t.agent.id}/bootstrap-prompt`;return(await c.mutateAsync({file:V,namespace:ae})).contentPath}})}),d.jsx("div",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-200",children:"Bootstrap prompt is legacy and will be removed in a future release. Consider moving this content into the agent's prompt template or instructions file instead."})]}),C==="claude_local"&&d.jsx(dce,{...P}),d.jsx(Et,{label:"Extra args (comma-separated)",hint:Yt.extraArgs,children:d.jsx(Mn,{value:r?D.extraArgs:m("adapterConfig","extraArgs",_Ne(y.extraArgs)),onCommit:V=>r?W({extraArgs:V}):g("adapterConfig","extraArgs",V?CNe(V):void 0),immediate:!0,className:Zi,placeholder:"e.g. --verbose, --foo=bar"})}),d.jsx(Et,{label:"Environment variables",hint:Yt.envVars,children:d.jsx(PNe,{value:r?D.envBindings??lP:m("adapterConfig","env",y.env??lP),secrets:a,onCreateSecret:async(V,ae)=>await l.mutateAsync({name:V,value:ae}),onChange:V=>r?W({envBindings:V??{},envVars:""}):g("adapterConfig","env",V)})}),!r&&d.jsxs(d.Fragment,{children:[d.jsx(Et,{label:"Timeout (sec)",hint:Yt.timeoutSec,children:d.jsx(Fh,{value:m("adapterConfig","timeoutSec",Number(y.timeoutSec??0)),onCommit:V=>g("adapterConfig","timeoutSec",V),immediate:!0,className:Zi})}),d.jsx(Et,{label:"Interrupt grace period (sec)",hint:Yt.graceSec,children:d.jsx(Fh,{value:m("adapterConfig","graceSec",Number(y.graceSec??15)),onCommit:V=>g("adapterConfig","graceSec",V),immediate:!0,className:Zi})})]})]})]}),r?d.jsxs("div",{className:Z(!i&&"border-b border-border"),children:[i?d.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[d.jsx(Dh,{className:"h-3 w-3"})," Run Policy"]}):d.jsxs("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground flex items-center gap-2",children:[d.jsx(Dh,{className:"h-3 w-3"})," Run Policy"]}),d.jsx("div",{className:Z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:d.jsx(FA,{label:"Heartbeat on interval",hint:Yt.heartbeatInterval,checked:D.heartbeatEnabled,onCheckedChange:V=>W({heartbeatEnabled:V}),number:D.intervalSec,onNumberChange:V=>W({intervalSec:V}),numberLabel:"sec",numberPrefix:"Run heartbeat every",numberHint:Yt.intervalSec,showNumber:D.heartbeatEnabled})})]}):d.jsxs("div",{className:Z(!i&&"border-b border-border"),children:[i?d.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[d.jsx(Dh,{className:"h-3 w-3"})," Run Policy"]}):d.jsxs("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground flex items-center gap-2",children:[d.jsx(Dh,{className:"h-3 w-3"})," Run Policy"]}),d.jsxs("div",{className:Z(i?"border border-border rounded-lg overflow-hidden":""),children:[d.jsx("div",{className:Z(i?"p-4 space-y-3":"px-4 pb-3 space-y-3"),children:d.jsx(FA,{label:"Heartbeat on interval",hint:Yt.heartbeatInterval,checked:m("heartbeat","enabled",k.enabled!==!1),onCheckedChange:V=>g("heartbeat","enabled",V),number:m("heartbeat","intervalSec",Number(k.intervalSec??300)),onNumberChange:V=>g("heartbeat","intervalSec",V),numberLabel:"sec",numberPrefix:"Run heartbeat every",numberHint:Yt.intervalSec,showNumber:m("heartbeat","enabled",k.enabled!==!1)})}),d.jsx(Jle,{title:"Advanced Run Policy",bordered:i,open:O,onToggle:()=>R(!O),children:d.jsxs("div",{className:"space-y-3",children:[d.jsx(Cp,{label:"Wake on demand",hint:Yt.wakeOnDemand,checked:m("heartbeat","wakeOnDemand",k.wakeOnDemand!==!1),onChange:V=>g("heartbeat","wakeOnDemand",V)}),d.jsx(Et,{label:"Cooldown (sec)",hint:Yt.cooldownSec,children:d.jsx(Fh,{value:m("heartbeat","cooldownSec",Number(k.cooldownSec??10)),onCommit:V=>g("heartbeat","cooldownSec",V),immediate:!0,className:Zi})}),d.jsx(Et,{label:"Max concurrent runs",hint:Yt.maxConcurrentRuns,children:d.jsx(Fh,{value:m("heartbeat","maxConcurrentRuns",Number(k.maxConcurrentRuns??1)),onCommit:V=>g("heartbeat","maxConcurrentRuns",V),immediate:!0,className:Zi})})]})})]})]})]})}function INe({result:t}){const e=t.status==="pass"?"Passed":t.status==="warn"?"Warnings":"Failed",n=t.status==="pass"?"text-green-700 dark:text-green-300 border-green-300 dark:border-green-500/40 bg-green-50 dark:bg-green-500/10":t.status==="warn"?"text-amber-700 dark:text-amber-300 border-amber-300 dark:border-amber-500/40 bg-amber-50 dark:bg-amber-500/10":"text-red-700 dark:text-red-300 border-red-300 dark:border-red-500/40 bg-red-50 dark:bg-red-500/10";return d.jsxs("div",{className:`rounded-md border px-3 py-2 text-xs ${n}`,children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("span",{className:"font-medium",children:e}),d.jsx("span",{className:"text-[11px] opacity-80",children:new Date(t.testedAt).toLocaleTimeString()})]}),d.jsx("div",{className:"mt-2 space-y-1.5",children:t.checks.map((r,i)=>d.jsxs("div",{className:"text-[11px] leading-relaxed break-words",children:[d.jsx("span",{className:"font-medium uppercase tracking-wide opacity-80",children:r.level}),d.jsx("span",{className:"mx-1 opacity-60",children:"·"}),d.jsx("span",{children:r.message}),r.detail&&d.jsxs("span",{className:"block opacity-75 break-all",children:["(",r.detail,")"]}),r.hint&&d.jsxs("span",{className:"block opacity-90 break-words",children:["Hint: ",r.hint]})]},`${r.code}-${i}`))})]})}const jNe=new Set(["claude_local","codex_local","gemini_local","opencode_local","pi_local","cursor"]),MNe=[...Nm.map(t=>({value:t,label:R8[t]??t,comingSoon:!jNe.has(t)}))];function RNe({value:t,onChange:e}){return d.jsxs(ni,{children:[d.jsx(ri,{asChild:!0,children:d.jsxs("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent/50 transition-colors w-full justify-between",children:[d.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t==="opencode_local"?d.jsx(m_,{className:"h-3.5 w-3.5"}):null,d.jsx("span",{children:R8[t]??t})]}),d.jsx(_i,{className:"h-3 w-3 text-muted-foreground"})]})}),d.jsx(ii,{className:"w-[var(--radix-popover-trigger-width)] p-1",align:"start",children:MNe.map(n=>d.jsxs("button",{disabled:n.comingSoon,className:Z("flex items-center justify-between w-full px-2 py-1.5 text-sm rounded",n.comingSoon?"opacity-40 cursor-not-allowed":"hover:bg-accent/50",n.value===t&&!n.comingSoon&&"bg-accent"),onClick:()=>{n.comingSoon||e(n.value)},children:[d.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.value==="opencode_local"?d.jsx(m_,{className:"h-3.5 w-3.5"}):null,d.jsx("span",{children:n.label})]}),n.comingSoon&&d.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Coming soon"})]},n.value))})]})}function PNe({value:t,secrets:e,onCreateSecret:n,onChange:r}){function i(g){return!g||typeof g!="object"?[{key:"",source:"plain",plainValue:"",secretId:""}]:[...Object.entries(g).map(([v,y])=>{if(typeof y=="string")return{key:v,source:"plain",plainValue:y,secretId:""};if(typeof y=="object"&&y!==null&&"type"in y&&y.type==="secret_ref"){const w=y;return{key:v,source:"secret",plainValue:"",secretId:typeof w.secretId=="string"?w.secretId:""}}if(typeof y=="object"&&y!==null&&"type"in y&&y.type==="plain"){const w=y;return{key:v,source:"plain",plainValue:typeof w.value=="string"?w.value:"",secretId:""}}return{key:v,source:"plain",plainValue:"",secretId:""}}),{key:"",source:"plain",plainValue:"",secretId:""}]}const[s,o]=x.useState(()=>i(t)),[a,l]=x.useState(null),c=x.useRef(t);x.useEffect(()=>{t!==c.current&&(c.current=t,o(i(t)))},[t]);function u(g){const b={};for(const v of g){const y=v.key.trim();if(y)if(v.source==="secret"){if(!v.secretId)continue;b[y]={type:"secret_ref",secretId:v.secretId,version:"latest"}}else b[y]={type:"plain",value:v.plainValue}}r(Object.keys(b).length>0?b:void 0)}function f(g,b){const v=s.map((y,w)=>w===g?{...y,...b}:y);(v[v.length-1].key||v[v.length-1].plainValue||v[v.length-1].secretId)&&v.push({key:"",source:"plain",plainValue:"",secretId:""}),o(v),u(v)}function h(g){const b=s.filter((v,y)=>y!==g);(b.length===0||b[b.length-1].key||b[b.length-1].plainValue||b[b.length-1].secretId)&&b.push({key:"",source:"plain",plainValue:"",secretId:""}),o(b),u(b)}function p(g){return g.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"").slice(0,64)}async function m(g){var C;const b=s[g];if(!b)return;const v=b.key.trim(),y=b.plainValue;if(!v||y.length===0)return;const w=p(v)||"secret",k=(C=window.prompt("Secret name",w))==null?void 0:C.trim();if(k)try{l(null);const _=await n(k,y);f(g,{source:"secret",secretId:_.id})}catch(_){l(_ instanceof Error?_.message:"Failed to create secret")}}return d.jsxs("div",{className:"space-y-1.5",children:[s.map((g,b)=>{const v=b===s.length-1&&!g.key&&!g.plainValue&&!g.secretId;return d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("input",{className:Z(Zi,"flex-[2]"),placeholder:"KEY",value:g.key,onChange:y=>f(b,{key:y.target.value})}),d.jsxs("select",{className:Z(Zi,"flex-[1] bg-background"),value:g.source,onChange:y=>f(b,{source:y.target.value==="secret"?"secret":"plain",...y.target.value==="plain"?{secretId:""}:{}}),children:[d.jsx("option",{value:"plain",children:"Plain"}),d.jsx("option",{value:"secret",children:"Secret"})]}),g.source==="secret"?d.jsxs(d.Fragment,{children:[d.jsxs("select",{className:Z(Zi,"flex-[3] bg-background"),value:g.secretId,onChange:y=>f(b,{secretId:y.target.value}),children:[d.jsx("option",{value:"",children:"Select secret..."}),e.map(y=>d.jsx("option",{value:y.id,children:y.name},y.id))]}),d.jsx("button",{type:"button",className:"inline-flex items-center rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground hover:bg-accent/50 transition-colors shrink-0",onClick:()=>m(b),disabled:!g.key.trim()||!g.plainValue,title:"Create secret from current plain value",children:"New"})]}):d.jsxs(d.Fragment,{children:[d.jsx("input",{className:Z(Zi,"flex-[3]"),placeholder:"value",value:g.plainValue,onChange:y=>f(b,{plainValue:y.target.value})}),d.jsx("button",{type:"button",className:"inline-flex items-center rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground hover:bg-accent/50 transition-colors shrink-0",onClick:()=>m(b),disabled:!g.key.trim()||!g.plainValue,title:"Store value as secret and replace with reference",children:"Seal"})]}),v?d.jsx("div",{className:"w-[26px] shrink-0"}):d.jsx("button",{type:"button",className:"shrink-0 p-1 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors",onClick:()=>h(b),children:d.jsx(Pa,{className:"h-3.5 w-3.5"})})]},b)}),a&&d.jsx("p",{className:"text-[11px] text-destructive",children:a}),d.jsx("p",{className:"text-[11px] text-muted-foreground/60",children:"PAPERCLIP_* variables are injected automatically at runtime."})]})}function ONe({models:t,value:e,onChange:n,open:r,onOpenChange:i,allowDefault:s,required:o,groupByProvider:a}){const[l,c]=x.useState(""),u=t.find(p=>p.id===e),f=x.useMemo(()=>t.filter(p=>{if(!l.trim())return!0;const m=l.toLowerCase(),g=nC(p.id)??"";return p.id.toLowerCase().includes(m)||p.label.toLowerCase().includes(m)||g.toLowerCase().includes(m)}),[t,l]),h=x.useMemo(()=>{if(!a)return[{provider:"models",entries:[...f].sort((m,g)=>m.id.localeCompare(g.id))}];const p=new Map;for(const m of f){const g=nC(m.id)??"other",b=p.get(g)??[];b.push(m),p.set(g,b)}return Array.from(p.entries()).sort(([m],[g])=>m.localeCompare(g)).map(([m,g])=>({provider:m,entries:[...g].sort((b,v)=>b.id.localeCompare(v.id))}))},[f,a]);return d.jsx(Et,{label:"Model",hint:Yt.model,children:d.jsxs(ni,{open:r,onOpenChange:p=>{i(p),p||c("")},children:[d.jsx(ri,{asChild:!0,children:d.jsxs("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent/50 transition-colors w-full justify-between",children:[d.jsx("span",{className:Z(!e&&"text-muted-foreground"),children:u?u.label:e||(s?"Default":o?"Select model (required)":"Select model")}),d.jsx(_i,{className:"h-3 w-3 text-muted-foreground"})]})}),d.jsxs(ii,{className:"w-[var(--radix-popover-trigger-width)] p-1",align:"start",children:[d.jsx("input",{className:"w-full px-2 py-1.5 text-xs bg-transparent outline-none border-b border-border mb-1 placeholder:text-muted-foreground/50",placeholder:"Search models...",value:l,onChange:p=>c(p.target.value),autoFocus:!0}),d.jsxs("div",{className:"max-h-[240px] overflow-y-auto",children:[s&&d.jsx("button",{className:Z("flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",!e&&"bg-accent"),onClick:()=>{n(""),i(!1)},children:"Default"}),h.map(p=>d.jsxs("div",{className:"mb-1 last:mb-0",children:[a&&d.jsxs("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:[p.provider," (",p.entries.length,")"]}),p.entries.map(m=>d.jsx("button",{className:Z("flex items-center w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",m.id===e&&"bg-accent"),onClick:()=>{n(m.id),i(!1)},children:d.jsx("span",{className:"block w-full text-left truncate",title:m.id,children:a?M8(m.id):m.label})},m.id))]},p.provider)),f.length===0&&d.jsx("p",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No models found."})]})]})]})})}function LNe({value:t,options:e,onChange:n,open:r,onOpenChange:i}){const s=e.find(o=>o.id===t)??e[0];return d.jsx(Et,{label:"Thinking effort",hint:Yt.thinkingEffort,children:d.jsxs(ni,{open:r,onOpenChange:i,children:[d.jsx(ri,{asChild:!0,children:d.jsxs("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent/50 transition-colors w-full justify-between",children:[d.jsx("span",{className:Z(!t&&"text-muted-foreground"),children:(s==null?void 0:s.label)??"Auto"}),d.jsx(_i,{className:"h-3 w-3 text-muted-foreground"})]})}),d.jsx(ii,{className:"w-[var(--radix-popover-trigger-width)] p-1",align:"start",children:e.map(o=>d.jsxs("button",{className:Z("flex items-center justify-between w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",o.id===t&&"bg-accent"),onClick:()=>{n(o.id),i(!1)},children:[d.jsx("span",{children:o.label}),o.id?d.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:o.id}):null]},o.id||"auto"))})]})})}function MU({className:t,orientation:e="horizontal",...n}){return d.jsx(cee,{"data-slot":"tabs","data-orientation":e,orientation:e,className:Z("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",t),...n})}const DNe=JS("p-[3px] group-data-[orientation=horizontal]/tabs:h-9 group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function RU({className:t,variant:e="default",...n}){return d.jsx(uee,{"data-slot":"tabs-list","data-variant":e,className:Z(DNe({variant:e}),t),...n})}function yd({className:t,...e}){return d.jsx(dee,{"data-slot":"tabs-trigger",className:Z("focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,background-color,border-color,box-shadow] group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:bg-background dark:data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 data-[state=active]:text-foreground","after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",t),...e})}function _h({className:t,...e}){return d.jsx(fee,{"data-slot":"tabs-content",className:Z("flex-1 outline-none",t),...e})}function FNe({items:t,value:e,onValueChange:n,align:r="center"}){const{isMobile:i}=Rb();return i&&e!==void 0&&n?d.jsx("select",{value:e,onChange:s=>n(s.target.value),className:"h-9 rounded-md border border-border bg-background px-2 py-1 text-base focus:outline-none focus:ring-1 focus:ring-ring",children:t.map(s=>d.jsx("option",{value:s.value,children:typeof s.label=="string"?s.label:s.value},s.value))}):d.jsx(RU,{variant:"line",className:r==="start"?"justify-start":void 0,children:t.map(s=>d.jsx(yd,{value:s.value,children:s.label},s.value))})}const $Ne={backlog:"text-muted-foreground border-muted-foreground",todo:"text-blue-600 border-blue-600 dark:text-blue-400 dark:border-blue-400",in_progress:"text-yellow-600 border-yellow-600 dark:text-yellow-400 dark:border-yellow-400",in_review:"text-violet-600 border-violet-600 dark:text-violet-400 dark:border-violet-400",done:"text-green-600 border-green-600 dark:text-green-400 dark:border-green-400",cancelled:"text-neutral-500 border-neutral-500",blocked:"text-red-600 border-red-600 dark:text-red-400 dark:border-red-400"},BNe="text-muted-foreground border-muted-foreground",Sh={backlog:"text-muted-foreground",todo:"text-blue-600 dark:text-blue-400",in_progress:"text-yellow-600 dark:text-yellow-400",in_review:"text-violet-600 dark:text-violet-400",done:"text-green-600 dark:text-green-400"},VNe={active:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",running:"bg-cyan-100 text-cyan-700 dark:bg-cyan-900/50 dark:text-cyan-300",paused:"bg-orange-100 text-orange-700 dark:bg-orange-900/50 dark:text-orange-300",idle:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-300",archived:"bg-muted text-muted-foreground",planned:"bg-muted text-muted-foreground",achieved:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",completed:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",failed:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",timed_out:"bg-orange-100 text-orange-700 dark:bg-orange-900/50 dark:text-orange-300",succeeded:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",error:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",terminated:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",pending:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-300",pending_approval:"bg-amber-100 text-amber-700 dark:bg-amber-900/50 dark:text-amber-300",revision_requested:"bg-amber-100 text-amber-700 dark:bg-amber-900/50 dark:text-amber-300",approved:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",rejected:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",backlog:"bg-muted text-muted-foreground",todo:"bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300",in_progress:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-300",in_review:"bg-violet-100 text-violet-700 dark:bg-violet-900/50 dark:text-violet-300",blocked:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",done:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",cancelled:"bg-muted text-muted-foreground"},zNe="bg-muted text-muted-foreground",r4e={running:"bg-cyan-400 animate-pulse",active:"bg-green-400",paused:"bg-yellow-400",idle:"bg-yellow-400",pending_approval:"bg-amber-400",error:"bg-red-400",archived:"bg-neutral-400"},i4e="bg-neutral-400",Il={critical:"text-red-600 dark:text-red-400",high:"text-orange-600 dark:text-orange-400",medium:"text-yellow-600 dark:text-yellow-400",low:"text-blue-600 dark:text-blue-400"};function Ha({status:t}){return d.jsx("span",{className:Z("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium whitespace-nowrap shrink-0",VNe[t]??zNe),children:t.replace("_"," ")})}function HNe(t,e){const n={};return(t[t.length-1]===""?[...t,""]:t).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const UNe=/[ \t\n\f\r]/g;function WNe(t){return typeof t=="object"?t.type==="text"?cP(t.value):!1:cP(t)}function cP(t){return t.replace(UNe,"")===""}class lg{constructor(e,n,r){this.normal=n,this.property=e,r&&(this.space=r)}}lg.prototype.normal={};lg.prototype.property={};lg.prototype.space=void 0;function PU(t,e){const n={},r={};for(const i of t)Object.assign(n,i.property),Object.assign(r,i.normal);return new lg(n,r,e)}function g_(t){return t.toLowerCase()}class Ti{constructor(e,n){this.attribute=n,this.property=e}}Ti.prototype.attribute="";Ti.prototype.booleanish=!1;Ti.prototype.boolean=!1;Ti.prototype.commaOrSpaceSeparated=!1;Ti.prototype.commaSeparated=!1;Ti.prototype.defined=!1;Ti.prototype.mustUseProperty=!1;Ti.prototype.number=!1;Ti.prototype.overloadedBoolean=!1;Ti.prototype.property="";Ti.prototype.spaceSeparated=!1;Ti.prototype.space=void 0;let KNe=0;const kt=Wu(),Zn=Wu(),x_=Wu(),Ie=Wu(),kn=Wu(),Hd=Wu(),Ai=Wu();function Wu(){return 2**++KNe}const y_=Object.freeze(Object.defineProperty({__proto__:null,boolean:kt,booleanish:Zn,commaOrSpaceSeparated:Ai,commaSeparated:Hd,number:Ie,overloadedBoolean:x_,spaceSeparated:kn},Symbol.toStringTag,{value:"Module"})),Dw=Object.keys(y_);class PT extends Ti{constructor(e,n,r,i){let s=-1;if(super(e,n),uP(this,"space",i),typeof r=="number")for(;++s<Dw.length;){const o=Dw[s];uP(this,Dw[s],(r&y_[o])===y_[o])}}}PT.prototype.defined=!0;function uP(t,e,n){n&&(t[e]=n)}function nh(t){const e={},n={};for(const[r,i]of Object.entries(t.properties)){const s=new PT(r,t.transform(t.attributes||{},r),i,t.space);t.mustUseProperty&&t.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),e[r]=s,n[g_(r)]=r,n[g_(s.attribute)]=r}return new lg(e,n,t.space)}const OU=nh({properties:{ariaActiveDescendant:null,ariaAtomic:Zn,ariaAutoComplete:null,ariaBusy:Zn,ariaChecked:Zn,ariaColCount:Ie,ariaColIndex:Ie,ariaColSpan:Ie,ariaControls:kn,ariaCurrent:null,ariaDescribedBy:kn,ariaDetails:null,ariaDisabled:Zn,ariaDropEffect:kn,ariaErrorMessage:null,ariaExpanded:Zn,ariaFlowTo:kn,ariaGrabbed:Zn,ariaHasPopup:null,ariaHidden:Zn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:kn,ariaLevel:Ie,ariaLive:null,ariaModal:Zn,ariaMultiLine:Zn,ariaMultiSelectable:Zn,ariaOrientation:null,ariaOwns:kn,ariaPlaceholder:null,ariaPosInSet:Ie,ariaPressed:Zn,ariaReadOnly:Zn,ariaRelevant:null,ariaRequired:Zn,ariaRoleDescription:kn,ariaRowCount:Ie,ariaRowIndex:Ie,ariaRowSpan:Ie,ariaSelected:Zn,ariaSetSize:Ie,ariaSort:null,ariaValueMax:Ie,ariaValueMin:Ie,ariaValueNow:Ie,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function LU(t,e){return e in t?t[e]:e}function DU(t,e){return LU(t,e.toLowerCase())}const qNe=nh({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Hd,acceptCharset:kn,accessKey:kn,action:null,allow:null,allowFullScreen:kt,allowPaymentRequest:kt,allowUserMedia:kt,alt:null,as:null,async:kt,autoCapitalize:null,autoComplete:kn,autoFocus:kt,autoPlay:kt,blocking:kn,capture:null,charSet:null,checked:kt,cite:null,className:kn,cols:Ie,colSpan:null,content:null,contentEditable:Zn,controls:kt,controlsList:kn,coords:Ie|Hd,crossOrigin:null,data:null,dateTime:null,decoding:null,default:kt,defer:kt,dir:null,dirName:null,disabled:kt,download:x_,draggable:Zn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:kt,formTarget:null,headers:kn,height:Ie,hidden:x_,high:Ie,href:null,hrefLang:null,htmlFor:kn,httpEquiv:kn,id:null,imageSizes:null,imageSrcSet:null,inert:kt,inputMode:null,integrity:null,is:null,isMap:kt,itemId:null,itemProp:kn,itemRef:kn,itemScope:kt,itemType:kn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:kt,low:Ie,manifest:null,max:null,maxLength:Ie,media:null,method:null,min:null,minLength:Ie,multiple:kt,muted:kt,name:null,nonce:null,noModule:kt,noValidate:kt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:kt,optimum:Ie,pattern:null,ping:kn,placeholder:null,playsInline:kt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:kt,referrerPolicy:null,rel:kn,required:kt,reversed:kt,rows:Ie,rowSpan:Ie,sandbox:kn,scope:null,scoped:kt,seamless:kt,selected:kt,shadowRootClonable:kt,shadowRootDelegatesFocus:kt,shadowRootMode:null,shape:null,size:Ie,sizes:null,slot:null,span:Ie,spellCheck:Zn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ie,step:null,style:null,tabIndex:Ie,target:null,title:null,translate:null,type:null,typeMustMatch:kt,useMap:null,value:Zn,width:Ie,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:kn,axis:null,background:null,bgColor:null,border:Ie,borderColor:null,bottomMargin:Ie,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:kt,declare:kt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ie,leftMargin:Ie,link:null,longDesc:null,lowSrc:null,marginHeight:Ie,marginWidth:Ie,noResize:kt,noHref:kt,noShade:kt,noWrap:kt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ie,rules:null,scheme:null,scrolling:Zn,standby:null,summary:null,text:null,topMargin:Ie,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ie,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:kt,disableRemotePlayback:kt,prefix:null,property:null,results:Ie,security:null,unselectable:null},space:"html",transform:DU}),GNe=nh({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Ai,accentHeight:Ie,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ie,amplitude:Ie,arabicForm:null,ascent:Ie,attributeName:null,attributeType:null,azimuth:Ie,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ie,by:null,calcMode:null,capHeight:Ie,className:kn,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ie,diffuseConstant:Ie,direction:null,display:null,dur:null,divisor:Ie,dominantBaseline:null,download:kt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ie,enableBackground:null,end:null,event:null,exponent:Ie,externalResourcesRequired:null,fill:null,fillOpacity:Ie,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Hd,g2:Hd,glyphName:Hd,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ie,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ie,horizOriginX:Ie,horizOriginY:Ie,id:null,ideographic:Ie,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ie,k:Ie,k1:Ie,k2:Ie,k3:Ie,k4:Ie,kernelMatrix:Ai,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ie,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ie,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ie,overlineThickness:Ie,paintOrder:null,panose1:null,path:null,pathLength:Ie,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:kn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ie,pointsAtY:Ie,pointsAtZ:Ie,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ai,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ai,rev:Ai,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ai,requiredFeatures:Ai,requiredFonts:Ai,requiredFormats:Ai,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ie,specularExponent:Ie,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ie,strikethroughThickness:Ie,string:null,stroke:null,strokeDashArray:Ai,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ie,strokeOpacity:Ie,strokeWidth:null,style:null,surfaceScale:Ie,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ai,tabIndex:Ie,tableValues:null,target:null,targetX:Ie,targetY:Ie,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ai,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ie,underlineThickness:Ie,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ie,values:null,vAlphabetic:Ie,vMathematical:Ie,vectorEffect:null,vHanging:Ie,vIdeographic:Ie,version:null,vertAdvY:Ie,vertOriginX:Ie,vertOriginY:Ie,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ie,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:LU}),FU=nh({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,e){return"xlink:"+e.slice(5).toLowerCase()}}),$U=nh({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:DU}),BU=nh({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),JNe={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},ZNe=/[A-Z]/g,dP=/-[a-z]/g,YNe=/^data[-\w.:]+$/i;function QNe(t,e){const n=g_(e);let r=e,i=Ti;if(n in t.normal)return t.property[t.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&YNe.test(e)){if(e.charAt(4)==="-"){const s=e.slice(5).replace(dP,eAe);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=e.slice(4);if(!dP.test(s)){let o=s.replace(ZNe,XNe);o.charAt(0)!=="-"&&(o="-"+o),e="data"+o}}i=PT}return new i(r,e)}function XNe(t){return"-"+t.toLowerCase()}function eAe(t){return t.charAt(1).toUpperCase()}const tAe=PU([OU,qNe,FU,$U,BU],"html"),OT=PU([OU,GNe,FU,$U,BU],"svg");function nAe(t){return t.join(" ").trim()}var sd={},Fw,fP;function rAe(){if(fP)return Fw;fP=1;var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,e=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,a=/^\s+|\s+$/g,l=`
808
808
  `,c="/",u="*",f="",h="comment",p="declaration";function m(b,v){if(typeof b!="string")throw new TypeError("First argument must be a string");if(!b)return[];v=v||{};var y=1,w=1;function k(M){var F=M.match(e);F&&(y+=F.length);var q=M.lastIndexOf(l);w=~q?M.length-q:w+M.length}function C(){var M={line:y,column:w};return function(F){return F.position=new _(M),T(),F}}function _(M){this.start=M,this.end={line:y,column:w},this.source=v.source}_.prototype.content=b;function E(M){var F=new Error(v.source+":"+y+":"+w+": "+M);if(F.reason=M,F.filename=v.source,F.line=y,F.column=w,F.source=b,!v.silent)throw F}function S(M){var F=M.exec(b);if(F){var q=F[0];return k(q),b=b.slice(q.length),F}}function T(){S(n)}function A(M){var F;for(M=M||[];F=P();)F!==!1&&M.push(F);return M}function P(){var M=C();if(!(c!=b.charAt(0)||u!=b.charAt(1))){for(var F=2;f!=b.charAt(F)&&(u!=b.charAt(F)||c!=b.charAt(F+1));)++F;if(F+=2,f===b.charAt(F-1))return E("End of comment missing");var q=b.slice(2,F-2);return w+=2,k(q),b=b.slice(F),w+=2,M({type:h,comment:q})}}function O(){var M=C(),F=S(r);if(F){if(P(),!S(i))return E("property missing ':'");var q=S(s),z=M({type:p,property:g(F[0].replace(t,f)),value:q?g(q[0].replace(t,f)):f});return S(o),z}}function R(){var M=[];A(M);for(var F;F=O();)F!==!1&&(M.push(F),A(M));return M}return T(),R()}function g(b){return b?b.replace(a,f):f}return Fw=m,Fw}var hP;function iAe(){if(hP)return sd;hP=1;var t=sd&&sd.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(sd,"__esModule",{value:!0}),sd.default=n;const e=t(rAe());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const o=(0,e.default)(r),a=typeof i=="function";return o.forEach(l=>{if(l.type!=="declaration")return;const{property:c,value:u}=l;a?i(c,u,l):u&&(s=s||{},s[c]=u)}),s}return sd}var Eh={},pP;function sAe(){if(pP)return Eh;pP=1,Object.defineProperty(Eh,"__esModule",{value:!0}),Eh.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,e=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(c){return!c||n.test(c)||t.test(c)},o=function(c,u){return u.toUpperCase()},a=function(c,u){return"".concat(u,"-")},l=function(c,u){return u===void 0&&(u={}),s(c)?c:(c=c.toLowerCase(),u.reactCompat?c=c.replace(i,a):c=c.replace(r,a),c.replace(e,o))};return Eh.camelCase=l,Eh}var Th,mP;function oAe(){if(mP)return Th;mP=1;var t=Th&&Th.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},e=t(iAe()),n=sAe();function r(i,s){var o={};return!i||typeof i!="string"||(0,e.default)(i,function(a,l){a&&l&&(o[(0,n.camelCase)(a,s)]=l)}),o}return r.default=r,Th=r,Th}var aAe=oAe();const lAe=mm(aAe),VU=zU("end"),LT=zU("start");function zU(t){return e;function e(n){const r=n&&n.position&&n.position[t]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function cAe(t){const e=LT(t),n=VU(t);if(e&&n)return{start:e,end:n}}const DT={}.hasOwnProperty,uAe=new Map,dAe=/[A-Z]/g,fAe=new Set(["table","tbody","thead","tfoot","tr"]),hAe=new Set(["td","th"]),HU="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function pAe(t,e){if(!e||e.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=e.filePath||void 0;let r;if(e.development){if(typeof e.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=kAe(n,e.jsxDEV)}else{if(typeof e.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof e.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=wAe(n,e.jsx,e.jsxs)}const i={Fragment:e.Fragment,ancestors:[],components:e.components||{},create:r,elementAttributeNameCase:e.elementAttributeNameCase||"react",evaluater:e.createEvaluater?e.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:e.ignoreInvalidStyle||!1,passKeys:e.passKeys!==!1,passNode:e.passNode||!1,schema:e.space==="svg"?OT:tAe,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},s=UU(i,t,void 0);return s&&typeof s!="string"?s:i.create(t,i.Fragment,{children:s||void 0},void 0)}function UU(t,e,n){if(e.type==="element")return mAe(t,e,n);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return gAe(t,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return yAe(t,e,n);if(e.type==="mdxjsEsm")return xAe(t,e);if(e.type==="root")return bAe(t,e,n);if(e.type==="text")return vAe(t,e)}function mAe(t,e,n){const r=t.schema;let i=r;e.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=OT,t.schema=i),t.ancestors.push(e);const s=KU(t,e.tagName,!1),o=CAe(t,e);let a=$T(t,e);return fAe.has(e.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!WNe(l):!0})),WU(t,o,s,e),FT(o,a),t.ancestors.pop(),t.schema=r,t.create(e,s,o,n)}function gAe(t,e){if(e.data&&e.data.estree&&t.evaluater){const r=e.data.estree.body[0];return r.type,t.evaluater.evaluateExpression(r.expression)}om(t,e.position)}function xAe(t,e){if(e.data&&e.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(e.data.estree);om(t,e.position)}function yAe(t,e,n){const r=t.schema;let i=r;e.name==="svg"&&r.space==="html"&&(i=OT,t.schema=i),t.ancestors.push(e);const s=e.name===null?t.Fragment:KU(t,e.name,!0),o=_Ae(t,e),a=$T(t,e);return WU(t,o,s,e),FT(o,a),t.ancestors.pop(),t.schema=r,t.create(e,s,o,n)}function bAe(t,e,n){const r={};return FT(r,$T(t,e)),t.create(e,t.Fragment,r,n)}function vAe(t,e){return e.value}function WU(t,e,n,r){typeof n!="string"&&n!==t.Fragment&&t.passNode&&(e.node=r)}function FT(t,e){if(e.length>0){const n=e.length>1?e:e[0];n&&(t.children=n)}}function wAe(t,e,n){return r;function r(i,s,o,a){const c=Array.isArray(o.children)?n:e;return a?c(s,o,a):c(s,o)}}function kAe(t,e){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=LT(r);return e(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:t,lineNumber:l?l.line:void 0},void 0)}}function CAe(t,e){const n={};let r,i;for(i in e.properties)if(i!=="children"&&DT.call(e.properties,i)){const s=SAe(t,i,e.properties[i]);if(s){const[o,a]=s;t.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&hAe.has(e.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[t.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function _Ae(t,e){const n={};for(const r of e.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&t.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,t.evaluater.evaluateExpression(a.argument))}else om(t,e.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&t.evaluater){const a=r.value.data.estree.body[0];a.type,s=t.evaluater.evaluateExpression(a.expression)}else om(t,e.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function $T(t,e){const n=[];let r=-1;const i=t.passKeys?new Map:uAe;for(;++r<e.children.length;){const s=e.children[r];let o;if(t.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const c=i.get(l)||0;o=l+"-"+c,i.set(l,c+1)}}const a=UU(t,s,o);a!==void 0&&n.push(a)}return n}function SAe(t,e,n){const r=QNe(t.schema,e);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?HNe(n):nAe(n)),r.property==="style"){let i=typeof n=="object"?n:EAe(t,String(n));return t.stylePropertyNameCase==="css"&&(i=TAe(i)),["style",i]}return[t.elementAttributeNameCase==="react"&&r.space?JNe[r.property]||r.property:r.attribute,n]}}function EAe(t,e){try{return lAe(e,{reactCompat:!0})}catch(n){if(t.ignoreInvalidStyle)return{};const r=n,i=new nn("Cannot parse `style` attribute",{ancestors:t.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=t.filePath||void 0,i.url=HU+"#cannot-parse-style-attribute",i}}function KU(t,e,n){let r;if(!n)r={type:"Literal",value:e};else if(e.includes(".")){const i=e.split(".");let s=-1,o;for(;++s<i.length;){const a=gI(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=gI(e)&&!/^[a-z]/.test(e)?{type:"Identifier",name:e}:{type:"Literal",value:e};if(r.type==="Literal"){const i=r.value;return DT.call(t.components,i)?t.components[i]:i}if(t.evaluater)return t.evaluater.evaluateExpression(r);om(t)}function om(t,e){const n=new nn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:t.ancestors,place:e,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=t.filePath||void 0,n.url=HU+"#cannot-handle-mdx-estrees-without-createevaluater",n}function TAe(t){const e={};let n;for(n in t)DT.call(t,n)&&(e[NAe(n)]=t[n]);return e}function NAe(t){let e=t.replace(dAe,AAe);return e.slice(0,3)==="ms-"&&(e="-"+e),e}function AAe(t){return"-"+t.toLowerCase()}const $w={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]};function IAe(t){const e=this;e.parser=n;function n(r){return u$(r,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}function jAe(t,e){const n={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(e),!0)};return t.patch(e,n),t.applyData(e,n)}function MAe(t,e){const n={type:"element",tagName:"br",properties:{},children:[]};return t.patch(e,n),[t.applyData(e,n),{type:"text",value:`
809
809
  `}]}function RAe(t,e){const n=e.value?e.value+`
810
810
  `:"",r={},i=e.lang?e.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return e.meta&&(s.data={meta:e.meta}),t.patch(e,s),s=t.applyData(e,s),s={type:"element",tagName:"pre",properties:{},children:[s]},t.patch(e,s),s}function PAe(t,e){const n={type:"element",tagName:"del",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function OAe(t,e){const n={type:"element",tagName:"em",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function LAe(t,e){const n=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",r=String(e.identifier).toUpperCase(),i=qf(r.toLowerCase()),s=t.footnoteOrder.indexOf(r);let o,a=t.footnoteCounts.get(r);a===void 0?(a=0,t.footnoteOrder.push(r),o=t.footnoteOrder.length):o=s+1,a+=1,t.footnoteCounts.set(r,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};t.patch(e,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return t.patch(e,c),t.applyData(e,c)}function DAe(t,e){const n={type:"element",tagName:"h"+e.depth,properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function FAe(t,e){if(t.options.allowDangerousHtml){const n={type:"raw",value:e.value};return t.patch(e,n),t.applyData(e,n)}}function qU(t,e){const n=e.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(e.label||e.identifier)+"]"),e.type==="imageReference")return[{type:"text",value:"!["+e.alt+r}];const i=t.all(e),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function $Ae(t,e){const n=String(e.identifier).toUpperCase(),r=t.definitionById.get(n);if(!r)return qU(t,e);const i={src:qf(r.url||""),alt:e.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return t.patch(e,s),t.applyData(e,s)}function BAe(t,e){const n={src:qf(e.url)};e.alt!==null&&e.alt!==void 0&&(n.alt=e.alt),e.title!==null&&e.title!==void 0&&(n.title=e.title);const r={type:"element",tagName:"img",properties:n,children:[]};return t.patch(e,r),t.applyData(e,r)}function VAe(t,e){const n={type:"text",value:e.value.replace(/\r?\n|\r/g," ")};t.patch(e,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return t.patch(e,r),t.applyData(e,r)}function zAe(t,e){const n=String(e.identifier).toUpperCase(),r=t.definitionById.get(n);if(!r)return qU(t,e);const i={href:qf(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:t.all(e)};return t.patch(e,s),t.applyData(e,s)}function HAe(t,e){const n={href:qf(e.url)};e.title!==null&&e.title!==void 0&&(n.title=e.title);const r={type:"element",tagName:"a",properties:n,children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function UAe(t,e,n){const r=t.all(e),i=n?WAe(n):GU(e),s={},o=[];if(typeof e.checked=="boolean"){const u=r[0];let f;u&&u.type==="element"&&u.tagName==="p"?f=u:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:e.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const u=r[a];(i||a!==0||u.type!=="element"||u.tagName!=="p")&&o.push({type:"text",value:`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@growthub/cli",
3
- "version": "0.3.35",
3
+ "version": "0.3.37",
4
4
  "description": "Growthub CLI — orchestrate AI agent teams to run a business",
5
5
  "type": "module",
6
6
  "bin": {