@plannotator/opencode 0.17.0 → 0.17.1
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/dist/index.js +9 -4
- package/package.json +2 -2
- package/plannotator.html +2 -2
- package/review-editor.html +122 -116
package/dist/index.js
CHANGED
|
@@ -24940,10 +24940,15 @@ var {$: $3 } = globalThis.Bun;
|
|
|
24940
24940
|
function parseRemoteUrl(url) {
|
|
24941
24941
|
if (!url)
|
|
24942
24942
|
return null;
|
|
24943
|
-
const
|
|
24944
|
-
if (
|
|
24945
|
-
return
|
|
24946
|
-
|
|
24943
|
+
const sshPortMatch = url.match(/^ssh:\/\/[^/]+(?::\d+)?\/(.+?)(?:\.git)?$/);
|
|
24944
|
+
if (sshPortMatch)
|
|
24945
|
+
return sshPortMatch[1];
|
|
24946
|
+
if (!url.includes("://")) {
|
|
24947
|
+
const sshMatch = url.match(/:([^/][^:]*?)(?:\.git)?$/);
|
|
24948
|
+
if (sshMatch)
|
|
24949
|
+
return sshMatch[1];
|
|
24950
|
+
}
|
|
24951
|
+
const httpsMatch = url.match(/^https?:\/\/[^/]+\/(.+?)(?:\.git)?$/);
|
|
24947
24952
|
if (httpsMatch)
|
|
24948
24953
|
return httpsMatch[1];
|
|
24949
24954
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plannotator/opencode",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"description": "Plannotator plugin for OpenCode - interactive plan review with visual annotation",
|
|
5
5
|
"author": "backnotprop",
|
|
6
6
|
"license": "MIT OR Apache-2.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@opencode-ai/plugin": "^1.1.10"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@plannotator/server": "0.17.
|
|
41
|
+
"@plannotator/server": "0.17.1",
|
|
42
42
|
"@plannotator/shared": "0.0.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
package/plannotator.html
CHANGED
|
@@ -498,7 +498,7 @@ created: ${new Date().toISOString().slice(0,19)}Z
|
|
|
498
498
|
source: plannotator
|
|
499
499
|
tags: [plan, ...]
|
|
500
500
|
---`})]}),w.jsx("div",{className:"border-t border-border/30"}),w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Obsidian when a plan loads, before you approve or deny"})]}),w.jsx("button",{role:"switch","aria-checked":Q.autoSave,onClick:()=>ae({autoSave:!Q.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${Q.autoSave?"bg-primary":"bg-muted"}`,children:w.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${Q.autoSave?"translate-x-6":"translate-x-1"}`})})]}),w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-xs font-medium",children:"Vault Browser"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Browse and annotate vault files from the sidebar"})]}),w.jsx("button",{role:"switch","aria-checked":Q.vaultBrowserEnabled,onClick:()=>ae({vaultBrowserEnabled:!Q.vaultBrowserEnabled}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${Q.vaultBrowserEnabled?"bg-primary":"bg-muted"}`,children:w.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${Q.vaultBrowserEnabled?"translate-x-6":"translate-x-1"}`})})]})]})]})]}),C==="bear"&&w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-sm font-medium",children:"Bear Notes"}),w.jsx("div",{className:"text-xs text-muted-foreground",children:"Auto-save approved plans to Bear"})]}),w.jsx("button",{role:"switch","aria-checked":x.enabled,onClick:()=>NA({enabled:!x.enabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${x.enabled?"bg-primary":"bg-muted"}`,children:w.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${x.enabled?"translate-x-6":"translate-x-1"}`})})]}),x.enabled&&w.jsxs("div",{className:"mt-3 space-y-3",children:[w.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[w.jsx("label",{className:"text-xs text-muted-foreground",children:"Custom Tags"}),w.jsx("input",{type:"text",value:x.customTags,onChange:dA=>NA({customTags:dA.target.value}),onBlur:dA=>NA({customTags:sUA(dA.target.value)}),placeholder:"plan, work",className:"w-full px-3 py-2 bg-muted rounded-lg text-xs font-mono placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary/50"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Comma-separated, kebab-case. Leave empty for auto-generated tags."})]}),w.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[w.jsx("label",{className:"text-xs text-muted-foreground",children:"Tag Position"}),w.jsxs("select",{value:x.tagPosition,onChange:dA=>NA({tagPosition:dA.target.value}),className:"w-full px-3 py-2 bg-muted rounded-lg text-xs focus:outline-none focus:ring-1 focus:ring-primary/50",children:[w.jsx("option",{value:"append",children:"Append (end of note)"}),w.jsx("option",{value:"prepend",children:"Prepend (after title)"})]})]}),w.jsx("div",{className:"border-t border-border/30"}),w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Bear when a plan loads, before you approve or deny"})]}),w.jsx("button",{role:"switch","aria-checked":x.autoSave,onClick:()=>NA({autoSave:!x.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${x.autoSave?"bg-primary":"bg-muted"}`,children:w.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${x.autoSave?"translate-x-6":"translate-x-1"}`})})]})]})]}),C==="octarine"&&w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-sm font-medium",children:"Octarine"}),w.jsx("div",{className:"text-xs text-muted-foreground",children:"Auto-save approved plans to Octarine"})]}),w.jsx("button",{role:"switch","aria-checked":b.enabled,onClick:()=>$A({enabled:!b.enabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${b.enabled?"bg-primary":"bg-muted"}`,children:w.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${b.enabled?"translate-x-6":"translate-x-1"}`})})]}),b.enabled&&w.jsxs("div",{className:"mt-3 space-y-3",children:[w.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[w.jsx("label",{className:"text-xs text-muted-foreground",children:"Workspace Name"}),w.jsx("input",{type:"text",value:b.workspace,onChange:dA=>$A({workspace:dA.target.value}),placeholder:"My Workspace",className:"w-full px-3 py-2 bg-muted rounded-lg text-xs font-mono placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary/50"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"The Octarine workspace name to save plans into."})]}),w.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[w.jsx("label",{className:"text-xs text-muted-foreground",children:"Folder"}),w.jsx("input",{type:"text",value:b.folder,onChange:dA=>$A({folder:dA.target.value}),placeholder:"plannotator",className:"w-full px-3 py-2 bg-muted rounded-lg text-xs font-mono placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary/50"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Subfolder within the workspace for saved plans."})]}),w.jsxs("div",{className:"text-[10px] text-muted-foreground/70",children:["Plans saved to: ",b.workspace||"..."," / ",b.folder||"plannotator","/"]}),w.jsx("div",{className:"border-t border-border/30"}),w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Octarine when a plan loads, before you approve or deny"})]}),w.jsx("button",{role:"switch","aria-checked":b.autoSave,onClick:()=>$A({autoSave:!b.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${b.autoSave?"bg-primary":"bg-muted"}`,children:w.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${b.autoSave?"translate-x-6":"translate-x-1"}`})})]})]})]})]})]})]})}),document.body)]})},cW=({onClick:e,disabled:A=!1,isLoading:t=!1,label:i="Send Feedback",shortLabel:r,loadingLabel:n="Sending...",shortLoadingLabel:a,title:s="Send Feedback",muted:o=!1})=>w.jsxs("button",{onClick:e,disabled:A,className:`p-1.5 md:px-2.5 md:py-1 rounded-md text-xs font-medium transition-all ${o?"opacity-50 cursor-not-allowed bg-accent/10 text-accent/50":A?"opacity-50 cursor-not-allowed bg-muted text-muted-foreground":"bg-accent/15 text-accent hover:bg-accent/25 border border-accent/30"}`,title:s,children:[w.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),r?w.jsxs(w.Fragment,{children:[w.jsx("span",{className:"hidden md:inline lg:hidden",children:t?a??n:r}),w.jsx("span",{className:"hidden lg:inline",children:t?n:i})]}):w.jsx("span",{className:"hidden md:inline",children:t?n:i})]}),IW=({onClick:e,disabled:A=!1,isLoading:t=!1,label:i="Approve",loadingLabel:r="Approving...",mobileLabel:n="OK",mobileLoadingLabel:a="...",title:s,dimmed:o=!1,muted:g=!1})=>w.jsxs("button",{onClick:e,disabled:A,className:`px-2 py-1 md:px-2.5 rounded-md text-xs font-medium transition-all ${g?"opacity-40 cursor-not-allowed bg-muted text-muted-foreground":A?"opacity-50 cursor-not-allowed bg-muted text-muted-foreground":o?"bg-success/50 text-success-foreground/70 hover:bg-success hover:text-success-foreground":"bg-success text-success-foreground hover:opacity-90"}`,title:s,children:[w.jsx("span",{className:"md:hidden",children:t?a:n}),w.jsx("span",{className:"hidden md:inline",children:t?r:i})]});async function $oA(e){const A=JSON.stringify(e),t=new TextEncoder().encode(A),i=new CompressionStream("deflate-raw"),r=i.writable.getWriter();r.write(t),r.close();const n=await new Response(i.readable).arrayBuffer(),a=new Uint8Array(n);let s="";for(let g=0;g<a.length;g++)s+=String.fromCharCode(a[g]);return btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async function hv(e){const A=e.replace(/-/g,"+").replace(/_/g,"/"),t=atob(A),i=Uint8Array.from(t,o=>o.charCodeAt(0)),r=new DecompressionStream("deflate-raw"),n=r.writable.getWriter();n.write(i),n.close();const a=await new Response(r.readable).arrayBuffer(),s=new TextDecoder().decode(a);return JSON.parse(s)}async function o4A(e){const A=await crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt"]),t=crypto.getRandomValues(new Uint8Array(12)),i=new TextEncoder().encode(e),r=await crypto.subtle.encrypt({name:"AES-GCM",iv:t},A,i),n=new Uint8Array(t.length+r.byteLength);n.set(t,0),n.set(new Uint8Array(r),t.length);const a=await crypto.subtle.exportKey("raw",A);return{ciphertext:CW(n),key:CW(new Uint8Array(a))}}async function g4A(e,A){const t=EW(e),i=EW(A),r=t.slice(0,12),n=t.slice(12),a=await crypto.subtle.importKey("raw",i.buffer,{name:"AES-GCM",length:256},!1,["decrypt"]),s=await crypto.subtle.decrypt({name:"AES-GCM",iv:r},a,n);return new TextDecoder().decode(s)}function CW(e){let A="";for(let t=0;t<e.length;t++)A+=String.fromCharCode(e[t]);return btoa(A).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function EW(e){const A=e.replace(/-/g,"+").replace(/_/g,"/"),t=atob(A);return Uint8Array.from(t,i=>i.charCodeAt(0))}function kB(e){if(e?.length)return e.map(A=>{if(typeof A=="string"){const t=A.split("/").pop()?.replace(/\.[^.]+$/,"")||"image";return{path:A,name:t}}return{path:A[0],name:A[1]}})}function w4(e){if(e?.length)return e.map(A=>[A.path,A.name])}function AgA(e){return e.map(A=>{const t=A.author||null,i=w4(A.images);return A.type===gi.GLOBAL_COMMENT?["G",A.text||"",t,i]:A.type===gi.DELETION?["D",A.originalText,t,i]:A.isQuickLabel?["C",A.originalText,A.text||"",t,i??void 0,1]:["C",A.originalText,A.text||"",t,i]})}function SD(e,A,t){const i={D:gi.DELETION,C:gi.COMMENT,G:gi.GLOBAL_COMMENT};return e.map((r,n)=>{const a=r[0];if(a==="G"){const C=r[1],E=r[2],B=r[3];return{id:`shared-${n}-${Date.now()}`,blockId:"",startOffset:0,endOffset:0,type:gi.GLOBAL_COMMENT,text:C||void 0,originalText:"",createdA:Date.now()+n,author:E||void 0,images:kB(B),...t?.[n]?{source:t[n]}:{}}}const s=r[1],o=a==="D"?void 0:r[2],g=a==="D"?r[2]:r[3],l=a==="D"?r[3]:r[4],I=a==="C"&&r.length>5&&r[5]===1?!0:void 0;return{id:`shared-${n}-${Date.now()}`,blockId:"",startOffset:0,endOffset:0,type:i[a],text:o||void 0,originalText:s,createdA:Date.now()+n,author:g||void 0,images:kB(l),...I?{isQuickLabel:I}:{},...A?.[n]?{diffContext:A[n]}:{},...t?.[n]?{source:t[n]}:{}}})}function egA(e){const A=e.map(t=>t.diffContext||null);return A.some(t=>t!==null)?A:null}function tgA(e){const A=e.map(t=>t.source||void 0);return A.some(t=>t!==void 0)?A:null}async function l4A(e,A,t,i=rgA){const r=egA(A),n=tgA(A),a={p:e,a:AgA(A),g:t?.length?w4(t):void 0,...r?{d:r}:{},...n?{s:n}:{}},s=await $oA(a);return`${i}/#${s}`}async function c4A(){const A=window.location.hash.slice(1).split("?")[0];if(!A)return null;try{return await hv(A)}catch(t){return console.warn("Failed to parse share hash:",t),null}}function I4A(e){const A=new Blob([e]).size;return A<1024?`${A} B`:`${(A/1024).toFixed(1)} KB`}const igA="https://plannotator-paste.plannotator.workers.dev",rgA="https://share.plannotator.ai";async function C4A(e,A,t,i){const r=i?.pasteApiUrl??igA,n=i?.shareBaseUrl??rgA;try{const a=egA(A),s=tgA(A),o={p:e,a:AgA(A),g:t?.length?w4(t):void 0,...a?{d:a}:{},...s?{s}:{}},g=await $oA(o),{ciphertext:l,key:I}=await o4A(g),C=await fetch(`${r}/api/paste`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:l}),signal:AbortSignal.timeout(5e3)});if(!C.ok)return console.warn(`[sharing] Paste service returned ${C.status}`),null;const E=await C.json();return{shortUrl:`${n}/p/${E.id}#key=${I}`,id:E.id}}catch(a){return console.debug("[sharing] Short URL service unavailable, using hash-based sharing:",a),null}}async function uW(e,A=igA,t){try{const i=await fetch(`${A}/api/paste/${e}`,{signal:AbortSignal.timeout(1e4)});if(!i.ok)return console.warn(`[sharing] Paste fetch returned ${i.status} for id ${e}`),null;const r=await i.json();if(t){const n=await g4A(r.data,t);return await hv(n)}return await hv(r.data)}catch(i){return console.warn("[sharing] Failed to load from paste ID:",i),null}}function E4A(e,A,t,i,r,n,a,s,o){const[g,l]=aA.useState(!1),[I,C]=aA.useState(!0),[E,B]=aA.useState(""),[h,Q]=aA.useState(""),[f,m]=aA.useState(""),[y,v]=aA.useState(!1),[S,x]=aA.useState(""),[R,b]=aA.useState(null),[N,T]=aA.useState(null),[L,K]=aA.useState(""),H=aA.useCallback(()=>{b(null),T(null)},[]),k=aA.useCallback(()=>K(""),[]),U=aA.useCallback(async()=>{try{const P=window.location.pathname.match(/^\/p\/([A-Za-z0-9]{6,16})$/);if(P){const V=P[1],j=window.location.hash.slice(1),AA=j.startsWith("key=")?j.slice(4):void 0,X=await uW(V,o,AA);if(X){i(X.p);const gA=SD(X.a,X.d,X.s);if(r(gA),X.g?.length){const hA=kB(X.g)??[];n(hA),T(hA)}b(gA),l(!0),a?.();const nA=window.location.pathname.replace(/\/p\/[A-Za-z0-9]+$/,"")||"/";return window.history.replaceState({},"",nA),!0}return K("Failed to load shared plan — the link may be expired or incomplete."),!1}const z=window.location.hash.slice(1),Y=await c4A();if(Y){i(Y.p);const V=SD(Y.a,Y.d,Y.s);if(r(V),Y.g?.length){const j=kB(Y.g)??[];n(j),T(j)}return b(V),l(!0),a?.(),window.history.replaceState({},"",window.location.pathname),!0}return z&&K("Failed to load shared plan — the URL may have been truncated by your browser."),!1}catch(P){return console.error("Failed to load from share hash:",P),K("Failed to load shared plan — an unexpected error occurred."),!1}},[i,r,n,a,o]);aA.useEffect(()=>{U().finally(()=>C(!1))},[]),aA.useEffect(()=>{const P=()=>{window.location.hash.length>1&&U()};return window.addEventListener("hashchange",P),()=>window.removeEventListener("hashchange",P)},[U]);const O=aA.useCallback(async()=>{try{const P=await l4A(e,A,t,s);B(P),Q(I4A(P))}catch(P){console.error("Failed to generate share URL:",P),B(""),Q("")}},[e,A,t,s]);aA.useEffect(()=>{O()},[O]),aA.useEffect(()=>{m(""),x("")},[e,A]);const F=aA.useCallback(async()=>{if(e){v(!0),x("");try{const P=await C4A(e,A,t,{pasteApiUrl:o,shareBaseUrl:s});P?m(P.shortUrl):(m(""),x("Short URL service unavailable"))}catch{m(""),x("Failed to generate short URL")}finally{v(!1)}}},[e,A,t,s,o]),G=aA.useCallback(async P=>{try{let z;const Y=P.match(/\/p\/([A-Za-z0-9]{6,16})(?:#key=([A-Za-z0-9_-]+))?(?:\?|#|$)/);if(Y){const nA=Y[1],hA=Y[2],rA=await uW(nA,o,hA);if(!rA)return{success:!1,count:0,planTitle:"",error:"Failed to load from short URL — paste may have expired"};z=rA}else{const nA=P.indexOf("#");if(nA===-1)return{success:!1,count:0,planTitle:"",error:"Invalid share URL: no hash fragment or short link found"};const hA=P.slice(nA+1);if(!hA)return{success:!1,count:0,planTitle:"",error:"Invalid share URL: empty hash"};z=await hv(hA)}const j=(z.p||"").trim().split(`
|
|
501
|
-
`).find(nA=>nA.startsWith("#")),AA=j?j.replace(/^#+\s*/,"").trim():"Unknown Plan",X=SD(z.a,z.d,z.s);if(X.length===0)return{success:!0,count:0,planTitle:AA,error:"No annotations found in share link"};const gA=X.filter(nA=>!A.some(hA=>hA.originalText===nA.originalText&&hA.type===nA.type&&hA.text===nA.text));if(gA.length>0&&(r(nA=>{const hA=X.filter(oA=>!nA.some(lA=>lA.originalText===oA.originalText&&lA.type===oA.type&&lA.text===oA.text));if(hA.length===0)return nA;const rA=[...nA,...hA];return b(rA),rA}),z.g?.length)){const nA=kB(z.g)??[];n(hA=>{const rA=new Set(hA.map(lA=>lA.path)),oA=nA.filter(lA=>!rA.has(lA.path));return oA.length>0?[...hA,...oA]:hA}),T(nA)}return{success:!0,count:gA.length,planTitle:AA}}catch(z){return{success:!1,count:0,planTitle:"",error:z instanceof Error?z.message:"Failed to decompress share URL"}}},[A,t,r,n,o]);return{isSharedSession:g,isLoadingShared:I,shareUrl:E,shareUrlSize:h,shortShareUrl:f,isGeneratingShortUrl:y,shortUrlError:S,pendingSharedAnnotations:R,sharedGlobalAttachments:N,clearPendingSharedAnnotations:H,refreshShareUrl:O,generateShortUrl:F,importFromShareUrl:G,shareLoadError:L,clearShareLoadError:k}}var bD=(e=>(e.Approve="approve",e.Feedback="feedback",e))(bD||{});function u4A(e=window.location){const A=new URLSearchParams(e.search);let t=A.get("cb"),i=A.get("ct");if(!t||!i){const r=e.hash.indexOf("?");if(r!==-1){const n=new URLSearchParams(e.hash.slice(r+1));t=t??n.get("cb"),i=i??n.get("ct")}}if(!t||!i)return null;try{const{protocol:r}=new URL(t);if(r!=="https:"&&r!=="http:")return null}catch{return null}return{callbackUrl:t,token:i}}async function B4A(e,A,t){const i=e==="approve"?"Plan approved! The bot will proceed to implementation.":"Feedback sent! The bot will re-plan with your annotations.";try{const r=await fetch(A.callbackUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,token:A.token,annotated_url:t})});return r.ok?{type:"success",message:i}:{type:"error",message:r.status===401?"Plan link expired — request a new one from the bot.":"Callback failed."}}catch{return{type:"error",message:"Callback failed."}}}function d4A(e,A){const[t,i]=aA.useState(null),r=aA.useRef(null);return aA.useEffect(()=>{const n=e.current;if(!n)return;const a=n.querySelectorAll('[data-block-type="heading"]');if(a.length===0)return;const s=new Map;return r.current=new IntersectionObserver(o=>{o.forEach(I=>{s.set(I.target,I.isIntersecting)});let g=null,l=1/0;for(const[I,C]of s)if(C){const E=I.getBoundingClientRect();E.top<l&&(l=E.top,g=I)}if(g){const I=g.getAttribute("data-block-id");I&&i(I)}},{root:n,rootMargin:"-80px 0px -80% 0px",threshold:[0,.1,.5,1]}),a.forEach(o=>{r.current?.observe(o)}),()=>{r.current?.disconnect()}},[e,A]),t}function BW(e){window.close(),setTimeout(()=>{window.closed||e()},300)}function h4A(e){const[A,t]=aA.useState({phase:"idle"});aA.useEffect(()=>{if(!e)return;const r=XAA();r==="0"?(BW(()=>t({phase:"closeFailed"})),t({phase:"closed"})):t(r!=="off"?{phase:"counting",remaining:Number(r)}:{phase:"prompt"})},[e]),aA.useEffect(()=>{if(A.phase!=="counting")return;if(A.remaining<=0){BW(()=>t({phase:"closeFailed"}));return}const r=setTimeout(()=>t(n=>n.phase==="counting"?{phase:"counting",remaining:n.remaining-1}:n),1e3);return()=>clearTimeout(r)},[A]);const i=aA.useCallback(()=>{$AA("3"),t({phase:"counting",remaining:3})},[]);return{state:A,enableAndStart:i}}const Q4A=()=>w.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),f4A=()=>w.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})});function p4A({submitted:e,title:A,subtitle:t,agentLabel:i}){const{state:r,enableAndStart:n}=h4A(!!e);if(!e)return null;const a=e==="approved";return w.jsx("div",{className:"fixed inset-0 z-[100] bg-background flex items-center justify-center",children:w.jsxs("div",{className:"text-center space-y-6 max-w-md px-8",children:[w.jsx("div",{className:`mx-auto w-16 h-16 rounded-full flex items-center justify-center ${a?"bg-success/20 text-success":"bg-accent/20 text-accent"}`,children:a?w.jsx(Q4A,{}):w.jsx(f4A,{})}),w.jsxs("div",{className:"space-y-2",children:[w.jsx("h2",{className:"text-xl font-semibold text-foreground",children:A}),w.jsx("p",{className:"text-muted-foreground",children:t})]}),w.jsx("div",{className:"pt-4 border-t border-border space-y-2",children:r.phase==="counting"?w.jsxs(w.Fragment,{children:[w.jsxs("p",{className:"text-sm text-muted-foreground",children:["This tab will close in ",w.jsx("span",{className:"text-foreground font-medium",children:r.remaining})," second",r.remaining!==1?"s":"","..."]}),w.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change this in Settings."})]}):r.phase==="closeFailed"?w.jsxs(w.Fragment,{children:[w.jsx("p",{className:"text-sm text-muted-foreground",children:"Could not close this tab automatically. Please close it manually."}),w.jsxs("p",{className:"text-xs text-muted-foreground/60",children:["Auto-close works when the tab is opened by ",i,"."]})]}):w.jsxs(w.Fragment,{children:[w.jsxs("p",{className:"text-sm text-muted-foreground",children:["You can close this tab and return to ",w.jsx("span",{className:"text-foreground font-medium",children:i}),"."]}),r.phase==="prompt"?w.jsxs(w.Fragment,{children:[w.jsxs("label",{className:"flex items-center justify-center gap-2 cursor-pointer group",children:[w.jsx("input",{type:"checkbox",checked:!1,onChange:n,className:"accent-primary"}),w.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-foreground transition-colors",children:"Auto-close this tab after 3 seconds"})]}),w.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change the delay in Settings."})]}):w.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Your response has been sent."})]})})]})})}const m4A="https://api.github.com/repos/backnotprop/plannotator/releases/latest",dW={"0.5.0":{title:"Code Review is here!",description:"Review git diffs with inline annotations. Run /plannotator-review to try it."}};function y4A(e,A){const t=n=>n.replace(/^v/,""),i=t(e).split(".").map(Number),r=t(A).split(".").map(Number);for(let n=0;n<Math.max(i.length,r.length);n++){const a=i[n]||0,s=r[n]||0;if(s>a)return!0;if(s<a)return!1}return!1}function D4A(){const[e,A]=aA.useState(null);return aA.useEffect(()=>{(async()=>{try{const i="0.17.0",n=new URLSearchParams(window.location.search).get("preview-update");if(n){const C=n.replace(/^v/,"");A({currentVersion:i,latestVersion:n,updateAvailable:!0,releaseUrl:`https://github.com/backnotprop/plannotator/releases/tag/v${C}`,featureHighlight:dW[C]});return}const a=await fetch(m4A);if(!a.ok)return;const s=await a.json(),o=s.tag_name,g=y4A(i,o),l=o.replace(/^v/,""),I=dW[l];A({currentVersion:i,latestVersion:o,updateAvailable:g,releaseUrl:s.html_url,featureHighlight:I})}catch(i){console.debug("Update check failed:",i)}})()},[]),e}const w4A="pi install npm:@plannotator/pi-extension";function v4A(e){return JyA&&!e?'powershell -c "irm https://plannotator.ai/install.ps1 | iex"':"curl -fsSL https://plannotator.ai/install.sh | bash"}const S4A=({origin:e,isWSL:A=!1})=>{const t=D4A(),[i,r]=aA.useState(!1),[n,a]=aA.useState(!1),g=new URLSearchParams(window.location.search).get("preview-origin")||e,l=g==="pi",I=g==="opencode",C=l?w4A:v4A(A);if(!t?.updateAvailable||n)return null;const E=async()=>{try{await navigator.clipboard.writeText(C),r(!0),setTimeout(()=>r(!1),2e3)}catch(h){console.error("Failed to copy:",h)}};return t.featureHighlight?w.jsx("div",{className:"fixed bottom-4 right-4 z-50 max-w-md animate-in slide-in-from-bottom-2 fade-in duration-300",children:w.jsxs("div",{className:"bg-card border border-primary/30 rounded-xl shadow-2xl overflow-hidden",children:[w.jsx("div",{className:"bg-gradient-to-r from-primary/20 to-primary/5 px-5 py-4 border-b border-border/50",children:w.jsxs("div",{className:"flex items-start justify-between gap-3",children:[w.jsxs("div",{className:"flex items-center gap-3",children:[w.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-primary/20 flex items-center justify-center",children:w.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}),w.jsxs("div",{children:[w.jsx("h4",{className:"text-base font-semibold text-foreground",children:t.featureHighlight.title}),w.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["New in ",t.latestVersion]})]})]}),w.jsx("button",{onClick:()=>a(!0),className:"text-muted-foreground hover:text-foreground transition-colors p-1",children:w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),w.jsxs("div",{className:"px-5 py-4",children:[w.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed",children:t.featureHighlight.description}),w.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:["You have ",t.currentVersion]}),I&&w.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install script, then restart OpenCode."}),l&&w.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install command, then restart Pi."}),w.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[w.jsx("button",{onClick:E,className:"flex-1 px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-lg hover:opacity-90 transition-opacity",children:i?"Copied!":"Copy install command"}),w.jsx("a",{href:t.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground border border-border rounded-lg hover:bg-muted transition-colors",children:"Release notes"})]})]})]})}):w.jsx("div",{className:"fixed bottom-4 right-4 z-50 max-w-sm animate-in slide-in-from-bottom-2 fade-in duration-300",children:w.jsx("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4",children:w.jsxs("div",{className:"flex items-start gap-3",children:[w.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center",children:w.jsx("svg",{className:"w-4 h-4 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})})}),w.jsxs("div",{className:"flex-1 min-w-0",children:[w.jsxs("div",{className:"flex items-center justify-between gap-2",children:[w.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Update available"}),w.jsx("button",{onClick:()=>a(!0),className:"text-muted-foreground hover:text-foreground transition-colors",children:w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),w.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[t.latestVersion," is available (you have ",t.currentVersion,")"]}),w.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[w.jsx("button",{onClick:E,className:"flex-1 px-3 py-1.5 text-xs font-medium bg-primary text-primary-foreground rounded-md hover:opacity-90 transition-opacity",children:i?"Copied!":"Copy install command"}),w.jsx("a",{href:t.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:"px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground border border-border rounded-md hover:bg-muted transition-colors",children:"Notes"})]})]})]})})})},ngA="plannotator-editor-mode",b4A="selection";function R4A(){const e=ze.getItem(ngA);return e==="selection"||e==="comment"||e==="redline"||e==="quickLabel"?e:b4A}function N4A(e){ze.setItem(ngA,e)}const agA="plannotator-input-method",M4A="drag";function k4A(){const e=ze.getItem(agA);return e==="drag"||e==="pinpoint"?e:M4A}function x4A(e){ze.setItem(agA,e)}const L4A=300,T4A=300;function F4A(e,A){const t=aA.useRef("idle"),i=aA.useRef(0),r=aA.useRef(void 0),n=aA.useRef(e);aA.useEffect(()=>{t.current==="idle"&&(n.current=e)},[e]);const a=aA.useCallback(s=>s==="drag"?"pinpoint":"drag",[]);aA.useEffect(()=>{const s=g=>{if(g.key!=="Alt"||g.repeat)return;const l=g.target?.tagName;l==="INPUT"||l==="TEXTAREA"||g.target?.isContentEditable||document.querySelector("[data-quick-label-picker]")||(t.current==="idle"?(n.current=e,i.current=Date.now(),t.current="held",A(a(e))):t.current==="tapped"&&(clearTimeout(r.current),t.current="idle",n.current=a(n.current)))},o=g=>{g.key==="Alt"&&t.current==="held"&&(Date.now()-i.current>=T4A?(A(n.current),t.current="idle"):(t.current="tapped",r.current=setTimeout(()=>{t.current==="tapped"&&(A(n.current),t.current="idle")},L4A)))};return window.addEventListener("keydown",s),window.addEventListener("keyup",o),()=>{clearTimeout(r.current),window.removeEventListener("keydown",s),window.removeEventListener("keyup",o)}},[e,A,a])}function G4A(){aA.useEffect(()=>{const e=()=>document.documentElement.classList.add("plannotator-print"),A=()=>document.documentElement.classList.remove("plannotator-print"),t=()=>{!document.hidden&&document.documentElement.classList.contains("plannotator-print")&&document.documentElement.classList.remove("plannotator-print")};return window.addEventListener("beforeprint",e),window.addEventListener("afterprint",A),document.addEventListener("visibilitychange",t),()=>{window.removeEventListener("beforeprint",e),window.removeEventListener("afterprint",A),document.removeEventListener("visibilitychange",t),document.documentElement.classList.remove("plannotator-print")}},[])}function hW({storageKey:e,defaultWidth:A=288,minWidth:t=200,maxWidth:i=600,side:r="right"}){const[n,a]=aA.useState(()=>{const Q=ze.getItem(e);if(Q){const f=Number(Q);if(!Number.isNaN(f)&&f>=t&&f<=i)return f}return A}),[s,o]=aA.useState(!1),g=aA.useRef(0),l=aA.useRef(0),I=aA.useRef(n),C=aA.useCallback(Q=>{I.current=Q,a(Q)},[]),E=aA.useCallback(Q=>{Q.preventDefault(),g.current=Q.clientX,l.current=I.current,o(!0)},[]),B=aA.useCallback(Q=>{Q.preventDefault(),g.current=Q.touches[0].clientX,l.current=I.current,o(!0)},[]);aA.useEffect(()=>{if(!s)return;const Q=y=>"touches"in y?y.touches[0]?.clientX??y.changedTouches[0]?.clientX??0:y.clientX,f=y=>{const v=Q(y),S=r==="right"?g.current-v:v-g.current;C(Math.min(i,Math.max(t,l.current+S)))},m=()=>{o(!1),ze.setItem(e,String(I.current))};return document.addEventListener("mousemove",f),document.addEventListener("mouseup",m),document.addEventListener("touchmove",f,{passive:!1}),document.addEventListener("touchend",m),document.addEventListener("touchcancel",m),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",m),document.removeEventListener("touchmove",f),document.removeEventListener("touchend",m),document.removeEventListener("touchcancel",m)}},[s,t,i,e,r,C]);const h=aA.useCallback(()=>{C(A),ze.setItem(e,String(A))},[A,e,C]);return{width:n,isDragging:s,handleProps:{isDragging:s,onMouseDown:E,onTouchStart:B,onDoubleClick:h}}}const QW=({isDragging:e,onMouseDown:A,onTouchStart:t,onDoubleClick:i,className:r,side:n})=>w.jsxs("div",{className:`relative w-0 cursor-col-resize flex-shrink-0 group z-10${r?` ${r}`:""}`,children:[w.jsx("div",{className:`absolute inset-y-0 -left-0.5 -right-0.5 transition-colors ${e?"bg-primary/50":"group-hover:bg-border"}`}),w.jsx("div",{className:`absolute inset-y-0 ${n==="left"?"-right-2 -left-1":n==="right"?"-right-3 left-0":"-inset-x-2"}`,onMouseDown:A,onTouchStart:t,onDoubleClick:i})]}),O4A=({className:e,panelClassName:A,renderTrigger:t,children:i})=>{const[r,n]=aA.useState(!1),a=aA.useRef(null);return aA.useEffect(()=>{if(!r)return;const s=g=>{a.current&&!a.current.contains(g.target)&&n(!1)},o=g=>{g.key==="Escape"&&n(!1)};return document.addEventListener("pointerdown",s),document.addEventListener("keydown",o),()=>{document.removeEventListener("pointerdown",s),document.removeEventListener("keydown",o)}},[r]),w.jsxs("div",{ref:a,className:e?`relative ${e}`:"relative",children:[t({isOpen:r,toggleMenu:()=>n(s=>!s)}),r&&w.jsx("div",{className:A??"absolute top-full right-0 mt-1 w-56 rounded-lg border border-border bg-popover py-1 shadow-xl z-[70]",children:i({closeMenu:()=>n(!1)})})]})},FC=({onClick:e,icon:A,label:t,badge:i})=>w.jsxs("button",{onClick:e,className:"flex w-full items-center gap-2 px-3 py-2 text-left text-xs transition-colors hover:bg-muted",children:[w.jsx("span",{className:"text-muted-foreground",children:A}),w.jsx("span",{className:"flex-1",children:t}),i]}),tL=()=>w.jsx("div",{className:"my-1 border-t border-border"}),U4A=({children:e})=>w.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:e}),K4A=({isPanelOpen:e,onTogglePanel:A,annotationCount:t,onOpenExport:i,onOpenSettings:r,onDownloadAnnotations:n,onCopyShareLink:a,onOpenImport:s,onPrint:o,sharingEnabled:g,className:l})=>{const{theme:I,setTheme:C}=f4();return w.jsx(O4A,{className:l,renderTrigger:({isOpen:E,toggleMenu:B})=>w.jsx("button",{onClick:B,className:"p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"Menu",children:E?w.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}):w.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})})}),panelClassName:"absolute top-full right-0 mt-1 w-56 bg-popover border border-border rounded-lg shadow-xl z-[70] py-1",children:({closeMenu:E})=>w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"px-3 py-2",children:[w.jsx("div",{className:"mb-1.5",children:w.jsx(U4A,{children:"Theme"})}),w.jsx("div",{className:"flex items-center gap-1 bg-muted/50 rounded-lg p-0.5",children:["light","dark","system"].map(B=>w.jsx("button",{onClick:()=>C(B),className:`flex-1 px-2 py-1 text-[10px] capitalize rounded-md transition-colors ${I===B?"bg-background text-foreground shadow-sm font-medium":"text-muted-foreground hover:text-foreground"}`,children:B},B))})]}),w.jsx(tL,{}),w.jsx(FC,{onClick:()=>{E(),r()},icon:w.jsx(Y4A,{}),label:"Settings"}),w.jsx(FC,{onClick:()=>{E(),A()},icon:w.jsx(H4A,{}),label:e?"Hide Annotations":"Show Annotations",badge:t>0?w.jsx("span",{className:"text-[10px] font-mono bg-muted px-1.5 py-0.5 rounded text-muted-foreground",children:t}):void 0}),w.jsx(tL,{}),w.jsx(FC,{onClick:()=>{E(),i()},icon:w.jsx(P4A,{}),label:"Export"}),w.jsx(FC,{onClick:()=>{E(),n()},icon:w.jsx(J4A,{}),label:"Download Annotations"}),w.jsx(FC,{onClick:()=>{E(),o()},icon:w.jsx(W4A,{}),label:"Print Plan"}),g&&w.jsx(FC,{onClick:()=>{E(),a()},icon:w.jsx(z4A,{}),label:"Copy Share Link"}),g&&w.jsxs(w.Fragment,{children:[w.jsx(tL,{}),w.jsx(FC,{onClick:()=>{E(),s()},icon:w.jsx(q4A,{}),label:"Import Review"})]})]})})},Y4A=()=>w.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),H4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),P4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})}),J4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),z4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),q4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4M10 17l5-5-5-5M15 12H3"})}),W4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"})}),V4A=({isOpen:e,onComplete:A})=>{const[t,i]=aA.useState("acceptEdits");if(!e)return null;const r=()=>{PoA(t),A(t)};return sg.createPortal(w.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-background/90 backdrop-blur-sm p-4",children:w.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-lg shadow-2xl",children:[w.jsxs("div",{className:"p-5 border-b border-border",children:[w.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[w.jsx("div",{className:"p-1.5 rounded-lg bg-primary/15",children:w.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0"})})}),w.jsx("h3",{className:"font-semibold text-base",children:"New: Permission Mode Preservation"})]}),w.jsx("p",{className:"text-sm text-muted-foreground",children:"Claude Code 2.1.7+ supports preserving your permission mode after plan approval. Choose your preferred automation level."}),w.jsxs("p",{className:"text-xs text-muted-foreground/70 mt-1",children:["Requires Claude Code 2.1.7 or later. Run ",w.jsx("code",{className:"bg-muted px-1 rounded",children:"claude update"})," to update."]})]}),w.jsx("div",{className:"p-4 space-y-2",children:i3.map(n=>w.jsxs("label",{className:`flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all border ${t===n.value?"border-primary bg-primary/10":"border-transparent bg-muted/50 hover:bg-muted"}`,children:[w.jsx("input",{type:"radio",name:"permissionMode",value:n.value,checked:t===n.value,onChange:()=>i(n.value),className:"mt-0.5 accent-primary"}),w.jsxs("div",{className:"flex-1",children:[w.jsx("div",{className:"text-sm font-medium",children:n.label}),w.jsx("div",{className:"text-xs text-muted-foreground",children:n.description})]})]},n.value))}),w.jsxs("div",{className:"p-4 border-t border-border flex justify-between items-center",children:[w.jsx("p",{className:"text-xs text-muted-foreground",children:"You can change this later in Settings."}),w.jsx("button",{onClick:r,className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:opacity-90 transition-opacity",children:"Continue"})]})]})}),document.body)};function Z4A(e){const[A,t]=aA.useState(e),[i,r]=aA.useState("toc"),n=aA.useCallback(o=>{t(!0),o&&r(o)},[]),a=aA.useCallback(()=>{t(!1)},[]),s=aA.useCallback(o=>{A?i===o?t(!1):r(o):(t(!0),r(o))},[A,i]);return{isOpen:A,activeTab:i,open:n,close:a,toggleTab:s}}class j4A{diff(A,t,i={}){let r;typeof i=="function"?(r=i,i={}):"callback"in i&&(r=i.callback);const n=this.castInput(A,i),a=this.castInput(t,i),s=this.removeEmpty(this.tokenize(n,i)),o=this.removeEmpty(this.tokenize(a,i));return this.diffWithOptionsObj(s,o,i,r)}diffWithOptionsObj(A,t,i,r){var n;const a=m=>{if(m=this.postProcess(m,i),r){setTimeout(function(){r(m)},0);return}else return m},s=t.length,o=A.length;let g=1,l=s+o;i.maxEditLength!=null&&(l=Math.min(l,i.maxEditLength));const I=(n=i.timeout)!==null&&n!==void 0?n:1/0,C=Date.now()+I,E=[{oldPos:-1,lastComponent:void 0}];let B=this.extractCommon(E[0],t,A,0,i);if(E[0].oldPos+1>=o&&B+1>=s)return a(this.buildValues(E[0].lastComponent,t,A));let h=-1/0,Q=1/0;const f=()=>{for(let m=Math.max(h,-g);m<=Math.min(Q,g);m+=2){let y;const v=E[m-1],S=E[m+1];v&&(E[m-1]=void 0);let x=!1;if(S){const b=S.oldPos-m;x=S&&0<=b&&b<s}const R=v&&v.oldPos+1<o;if(!x&&!R){E[m]=void 0;continue}if(!R||x&&v.oldPos<S.oldPos?y=this.addToPath(S,!0,!1,0,i):y=this.addToPath(v,!1,!0,1,i),B=this.extractCommon(y,t,A,m,i),y.oldPos+1>=o&&B+1>=s)return a(this.buildValues(y.lastComponent,t,A))||!0;E[m]=y,y.oldPos+1>=o&&(Q=Math.min(Q,m-1)),B+1>=s&&(h=Math.max(h,m+1))}g++};if(r)(function m(){setTimeout(function(){if(g>l||Date.now()>C)return r(void 0);f()||m()},0)})();else for(;g<=l&&Date.now()<=C;){const m=f();if(m)return m}}addToPath(A,t,i,r,n){const a=A.lastComponent;return a&&!n.oneChangePerToken&&a.added===t&&a.removed===i?{oldPos:A.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:i,previousComponent:a.previousComponent}}:{oldPos:A.oldPos+r,lastComponent:{count:1,added:t,removed:i,previousComponent:a}}}extractCommon(A,t,i,r,n){const a=t.length,s=i.length;let o=A.oldPos,g=o-r,l=0;for(;g+1<a&&o+1<s&&this.equals(i[o+1],t[g+1],n);)g++,o++,l++,n.oneChangePerToken&&(A.lastComponent={count:1,previousComponent:A.lastComponent,added:!1,removed:!1});return l&&!n.oneChangePerToken&&(A.lastComponent={count:l,previousComponent:A.lastComponent,added:!1,removed:!1}),A.oldPos=o,g}equals(A,t,i){return i.comparator?i.comparator(A,t):A===t||!!i.ignoreCase&&A.toLowerCase()===t.toLowerCase()}removeEmpty(A){const t=[];for(let i=0;i<A.length;i++)A[i]&&t.push(A[i]);return t}castInput(A,t){return A}tokenize(A,t){return Array.from(A)}join(A){return A.join("")}postProcess(A,t){return A}get useLongestToken(){return!1}buildValues(A,t,i){const r=[];let n;for(;A;)r.push(A),n=A.previousComponent,delete A.previousComponent,A=n;r.reverse();const a=r.length;let s=0,o=0,g=0;for(;s<a;s++){const l=r[s];if(l.removed)l.value=this.join(i.slice(g,g+l.count)),g+=l.count;else{if(!l.added&&this.useLongestToken){let I=t.slice(o,o+l.count);I=I.map(function(C,E){const B=i[g+E];return B.length>C.length?B:C}),l.value=this.join(I)}else l.value=this.join(t.slice(o,o+l.count));o+=l.count,l.added||(g+=l.count)}}return r}}class _4A extends j4A{constructor(){super(...arguments),this.tokenize=AKA}equals(A,t,i){return i.ignoreWhitespace?((!i.newlineIsToken||!A.includes(`
|
|
501
|
+
`).find(nA=>nA.startsWith("#")),AA=j?j.replace(/^#+\s*/,"").trim():"Unknown Plan",X=SD(z.a,z.d,z.s);if(X.length===0)return{success:!0,count:0,planTitle:AA,error:"No annotations found in share link"};const gA=X.filter(nA=>!A.some(hA=>hA.originalText===nA.originalText&&hA.type===nA.type&&hA.text===nA.text));if(gA.length>0&&(r(nA=>{const hA=X.filter(oA=>!nA.some(lA=>lA.originalText===oA.originalText&&lA.type===oA.type&&lA.text===oA.text));if(hA.length===0)return nA;const rA=[...nA,...hA];return b(rA),rA}),z.g?.length)){const nA=kB(z.g)??[];n(hA=>{const rA=new Set(hA.map(lA=>lA.path)),oA=nA.filter(lA=>!rA.has(lA.path));return oA.length>0?[...hA,...oA]:hA}),T(nA)}return{success:!0,count:gA.length,planTitle:AA}}catch(z){return{success:!1,count:0,planTitle:"",error:z instanceof Error?z.message:"Failed to decompress share URL"}}},[A,t,r,n,o]);return{isSharedSession:g,isLoadingShared:I,shareUrl:E,shareUrlSize:h,shortShareUrl:f,isGeneratingShortUrl:y,shortUrlError:S,pendingSharedAnnotations:R,sharedGlobalAttachments:N,clearPendingSharedAnnotations:H,refreshShareUrl:O,generateShortUrl:F,importFromShareUrl:G,shareLoadError:L,clearShareLoadError:k}}var bD=(e=>(e.Approve="approve",e.Feedback="feedback",e))(bD||{});function u4A(e=window.location){const A=new URLSearchParams(e.search);let t=A.get("cb"),i=A.get("ct");if(!t||!i){const r=e.hash.indexOf("?");if(r!==-1){const n=new URLSearchParams(e.hash.slice(r+1));t=t??n.get("cb"),i=i??n.get("ct")}}if(!t||!i)return null;try{const{protocol:r}=new URL(t);if(r!=="https:"&&r!=="http:")return null}catch{return null}return{callbackUrl:t,token:i}}async function B4A(e,A,t){const i=e==="approve"?"Plan approved! The bot will proceed to implementation.":"Feedback sent! The bot will re-plan with your annotations.";try{const r=await fetch(A.callbackUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,token:A.token,annotated_url:t})});return r.ok?{type:"success",message:i}:{type:"error",message:r.status===401?"Plan link expired — request a new one from the bot.":"Callback failed."}}catch{return{type:"error",message:"Callback failed."}}}function d4A(e,A){const[t,i]=aA.useState(null),r=aA.useRef(null);return aA.useEffect(()=>{const n=e.current;if(!n)return;const a=n.querySelectorAll('[data-block-type="heading"]');if(a.length===0)return;const s=new Map;return r.current=new IntersectionObserver(o=>{o.forEach(I=>{s.set(I.target,I.isIntersecting)});let g=null,l=1/0;for(const[I,C]of s)if(C){const E=I.getBoundingClientRect();E.top<l&&(l=E.top,g=I)}if(g){const I=g.getAttribute("data-block-id");I&&i(I)}},{root:n,rootMargin:"-80px 0px -80% 0px",threshold:[0,.1,.5,1]}),a.forEach(o=>{r.current?.observe(o)}),()=>{r.current?.disconnect()}},[e,A]),t}function BW(e){window.close(),setTimeout(()=>{window.closed||e()},300)}function h4A(e){const[A,t]=aA.useState({phase:"idle"});aA.useEffect(()=>{if(!e)return;const r=XAA();r==="0"?(BW(()=>t({phase:"closeFailed"})),t({phase:"closed"})):t(r!=="off"?{phase:"counting",remaining:Number(r)}:{phase:"prompt"})},[e]),aA.useEffect(()=>{if(A.phase!=="counting")return;if(A.remaining<=0){BW(()=>t({phase:"closeFailed"}));return}const r=setTimeout(()=>t(n=>n.phase==="counting"?{phase:"counting",remaining:n.remaining-1}:n),1e3);return()=>clearTimeout(r)},[A]);const i=aA.useCallback(()=>{$AA("3"),t({phase:"counting",remaining:3})},[]);return{state:A,enableAndStart:i}}const Q4A=()=>w.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),f4A=()=>w.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})});function p4A({submitted:e,title:A,subtitle:t,agentLabel:i}){const{state:r,enableAndStart:n}=h4A(!!e);if(!e)return null;const a=e==="approved";return w.jsx("div",{className:"fixed inset-0 z-[100] bg-background flex items-center justify-center",children:w.jsxs("div",{className:"text-center space-y-6 max-w-md px-8",children:[w.jsx("div",{className:`mx-auto w-16 h-16 rounded-full flex items-center justify-center ${a?"bg-success/20 text-success":"bg-accent/20 text-accent"}`,children:a?w.jsx(Q4A,{}):w.jsx(f4A,{})}),w.jsxs("div",{className:"space-y-2",children:[w.jsx("h2",{className:"text-xl font-semibold text-foreground",children:A}),w.jsx("p",{className:"text-muted-foreground",children:t})]}),w.jsx("div",{className:"pt-4 border-t border-border space-y-2",children:r.phase==="counting"?w.jsxs(w.Fragment,{children:[w.jsxs("p",{className:"text-sm text-muted-foreground",children:["This tab will close in ",w.jsx("span",{className:"text-foreground font-medium",children:r.remaining})," second",r.remaining!==1?"s":"","..."]}),w.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change this in Settings."})]}):r.phase==="closeFailed"?w.jsxs(w.Fragment,{children:[w.jsx("p",{className:"text-sm text-muted-foreground",children:"Could not close this tab automatically. Please close it manually."}),w.jsxs("p",{className:"text-xs text-muted-foreground/60",children:["Auto-close works when the tab is opened by ",i,"."]})]}):w.jsxs(w.Fragment,{children:[w.jsxs("p",{className:"text-sm text-muted-foreground",children:["You can close this tab and return to ",w.jsx("span",{className:"text-foreground font-medium",children:i}),"."]}),r.phase==="prompt"?w.jsxs(w.Fragment,{children:[w.jsxs("label",{className:"flex items-center justify-center gap-2 cursor-pointer group",children:[w.jsx("input",{type:"checkbox",checked:!1,onChange:n,className:"accent-primary"}),w.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-foreground transition-colors",children:"Auto-close this tab after 3 seconds"})]}),w.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change the delay in Settings."})]}):w.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Your response has been sent."})]})})]})})}const m4A="https://api.github.com/repos/backnotprop/plannotator/releases/latest",dW={"0.5.0":{title:"Code Review is here!",description:"Review git diffs with inline annotations. Run /plannotator-review to try it."}};function y4A(e,A){const t=n=>n.replace(/^v/,""),i=t(e).split(".").map(Number),r=t(A).split(".").map(Number);for(let n=0;n<Math.max(i.length,r.length);n++){const a=i[n]||0,s=r[n]||0;if(s>a)return!0;if(s<a)return!1}return!1}function D4A(){const[e,A]=aA.useState(null);return aA.useEffect(()=>{(async()=>{try{const i="0.17.1",n=new URLSearchParams(window.location.search).get("preview-update");if(n){const C=n.replace(/^v/,"");A({currentVersion:i,latestVersion:n,updateAvailable:!0,releaseUrl:`https://github.com/backnotprop/plannotator/releases/tag/v${C}`,featureHighlight:dW[C]});return}const a=await fetch(m4A);if(!a.ok)return;const s=await a.json(),o=s.tag_name,g=y4A(i,o),l=o.replace(/^v/,""),I=dW[l];A({currentVersion:i,latestVersion:o,updateAvailable:g,releaseUrl:s.html_url,featureHighlight:I})}catch(i){console.debug("Update check failed:",i)}})()},[]),e}const w4A="pi install npm:@plannotator/pi-extension";function v4A(e){return JyA&&!e?'powershell -c "irm https://plannotator.ai/install.ps1 | iex"':"curl -fsSL https://plannotator.ai/install.sh | bash"}const S4A=({origin:e,isWSL:A=!1})=>{const t=D4A(),[i,r]=aA.useState(!1),[n,a]=aA.useState(!1),g=new URLSearchParams(window.location.search).get("preview-origin")||e,l=g==="pi",I=g==="opencode",C=l?w4A:v4A(A);if(!t?.updateAvailable||n)return null;const E=async()=>{try{await navigator.clipboard.writeText(C),r(!0),setTimeout(()=>r(!1),2e3)}catch(h){console.error("Failed to copy:",h)}};return t.featureHighlight?w.jsx("div",{className:"fixed bottom-4 right-4 z-50 max-w-md animate-in slide-in-from-bottom-2 fade-in duration-300",children:w.jsxs("div",{className:"bg-card border border-primary/30 rounded-xl shadow-2xl overflow-hidden",children:[w.jsx("div",{className:"bg-gradient-to-r from-primary/20 to-primary/5 px-5 py-4 border-b border-border/50",children:w.jsxs("div",{className:"flex items-start justify-between gap-3",children:[w.jsxs("div",{className:"flex items-center gap-3",children:[w.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-primary/20 flex items-center justify-center",children:w.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}),w.jsxs("div",{children:[w.jsx("h4",{className:"text-base font-semibold text-foreground",children:t.featureHighlight.title}),w.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["New in ",t.latestVersion]})]})]}),w.jsx("button",{onClick:()=>a(!0),className:"text-muted-foreground hover:text-foreground transition-colors p-1",children:w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),w.jsxs("div",{className:"px-5 py-4",children:[w.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed",children:t.featureHighlight.description}),w.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:["You have ",t.currentVersion]}),I&&w.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install script, then restart OpenCode."}),l&&w.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install command, then restart Pi."}),w.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[w.jsx("button",{onClick:E,className:"flex-1 px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-lg hover:opacity-90 transition-opacity",children:i?"Copied!":"Copy install command"}),w.jsx("a",{href:t.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground border border-border rounded-lg hover:bg-muted transition-colors",children:"Release notes"})]})]})]})}):w.jsx("div",{className:"fixed bottom-4 right-4 z-50 max-w-sm animate-in slide-in-from-bottom-2 fade-in duration-300",children:w.jsx("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4",children:w.jsxs("div",{className:"flex items-start gap-3",children:[w.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center",children:w.jsx("svg",{className:"w-4 h-4 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})})}),w.jsxs("div",{className:"flex-1 min-w-0",children:[w.jsxs("div",{className:"flex items-center justify-between gap-2",children:[w.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Update available"}),w.jsx("button",{onClick:()=>a(!0),className:"text-muted-foreground hover:text-foreground transition-colors",children:w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),w.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[t.latestVersion," is available (you have ",t.currentVersion,")"]}),w.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[w.jsx("button",{onClick:E,className:"flex-1 px-3 py-1.5 text-xs font-medium bg-primary text-primary-foreground rounded-md hover:opacity-90 transition-opacity",children:i?"Copied!":"Copy install command"}),w.jsx("a",{href:t.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:"px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground border border-border rounded-md hover:bg-muted transition-colors",children:"Notes"})]})]})]})})})},ngA="plannotator-editor-mode",b4A="selection";function R4A(){const e=ze.getItem(ngA);return e==="selection"||e==="comment"||e==="redline"||e==="quickLabel"?e:b4A}function N4A(e){ze.setItem(ngA,e)}const agA="plannotator-input-method",M4A="drag";function k4A(){const e=ze.getItem(agA);return e==="drag"||e==="pinpoint"?e:M4A}function x4A(e){ze.setItem(agA,e)}const L4A=300,T4A=300;function F4A(e,A){const t=aA.useRef("idle"),i=aA.useRef(0),r=aA.useRef(void 0),n=aA.useRef(e);aA.useEffect(()=>{t.current==="idle"&&(n.current=e)},[e]);const a=aA.useCallback(s=>s==="drag"?"pinpoint":"drag",[]);aA.useEffect(()=>{const s=g=>{if(g.key!=="Alt"||g.repeat)return;const l=g.target?.tagName;l==="INPUT"||l==="TEXTAREA"||g.target?.isContentEditable||document.querySelector("[data-quick-label-picker]")||(t.current==="idle"?(n.current=e,i.current=Date.now(),t.current="held",A(a(e))):t.current==="tapped"&&(clearTimeout(r.current),t.current="idle",n.current=a(n.current)))},o=g=>{g.key==="Alt"&&t.current==="held"&&(Date.now()-i.current>=T4A?(A(n.current),t.current="idle"):(t.current="tapped",r.current=setTimeout(()=>{t.current==="tapped"&&(A(n.current),t.current="idle")},L4A)))};return window.addEventListener("keydown",s),window.addEventListener("keyup",o),()=>{clearTimeout(r.current),window.removeEventListener("keydown",s),window.removeEventListener("keyup",o)}},[e,A,a])}function G4A(){aA.useEffect(()=>{const e=()=>document.documentElement.classList.add("plannotator-print"),A=()=>document.documentElement.classList.remove("plannotator-print"),t=()=>{!document.hidden&&document.documentElement.classList.contains("plannotator-print")&&document.documentElement.classList.remove("plannotator-print")};return window.addEventListener("beforeprint",e),window.addEventListener("afterprint",A),document.addEventListener("visibilitychange",t),()=>{window.removeEventListener("beforeprint",e),window.removeEventListener("afterprint",A),document.removeEventListener("visibilitychange",t),document.documentElement.classList.remove("plannotator-print")}},[])}function hW({storageKey:e,defaultWidth:A=288,minWidth:t=200,maxWidth:i=600,side:r="right"}){const[n,a]=aA.useState(()=>{const Q=ze.getItem(e);if(Q){const f=Number(Q);if(!Number.isNaN(f)&&f>=t&&f<=i)return f}return A}),[s,o]=aA.useState(!1),g=aA.useRef(0),l=aA.useRef(0),I=aA.useRef(n),C=aA.useCallback(Q=>{I.current=Q,a(Q)},[]),E=aA.useCallback(Q=>{Q.preventDefault(),g.current=Q.clientX,l.current=I.current,o(!0)},[]),B=aA.useCallback(Q=>{Q.preventDefault(),g.current=Q.touches[0].clientX,l.current=I.current,o(!0)},[]);aA.useEffect(()=>{if(!s)return;const Q=y=>"touches"in y?y.touches[0]?.clientX??y.changedTouches[0]?.clientX??0:y.clientX,f=y=>{const v=Q(y),S=r==="right"?g.current-v:v-g.current;C(Math.min(i,Math.max(t,l.current+S)))},m=()=>{o(!1),ze.setItem(e,String(I.current))};return document.addEventListener("mousemove",f),document.addEventListener("mouseup",m),document.addEventListener("touchmove",f,{passive:!1}),document.addEventListener("touchend",m),document.addEventListener("touchcancel",m),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",m),document.removeEventListener("touchmove",f),document.removeEventListener("touchend",m),document.removeEventListener("touchcancel",m)}},[s,t,i,e,r,C]);const h=aA.useCallback(()=>{C(A),ze.setItem(e,String(A))},[A,e,C]);return{width:n,isDragging:s,handleProps:{isDragging:s,onMouseDown:E,onTouchStart:B,onDoubleClick:h}}}const QW=({isDragging:e,onMouseDown:A,onTouchStart:t,onDoubleClick:i,className:r,side:n})=>w.jsxs("div",{className:`relative w-0 cursor-col-resize flex-shrink-0 group z-10${r?` ${r}`:""}`,children:[w.jsx("div",{className:`absolute inset-y-0 -left-0.5 -right-0.5 transition-colors ${e?"bg-primary/50":"group-hover:bg-border"}`}),w.jsx("div",{className:`absolute inset-y-0 ${n==="left"?"-right-2 -left-1":n==="right"?"-right-3 left-0":"-inset-x-2"}`,onMouseDown:A,onTouchStart:t,onDoubleClick:i})]}),O4A=({className:e,panelClassName:A,renderTrigger:t,children:i})=>{const[r,n]=aA.useState(!1),a=aA.useRef(null);return aA.useEffect(()=>{if(!r)return;const s=g=>{a.current&&!a.current.contains(g.target)&&n(!1)},o=g=>{g.key==="Escape"&&n(!1)};return document.addEventListener("pointerdown",s),document.addEventListener("keydown",o),()=>{document.removeEventListener("pointerdown",s),document.removeEventListener("keydown",o)}},[r]),w.jsxs("div",{ref:a,className:e?`relative ${e}`:"relative",children:[t({isOpen:r,toggleMenu:()=>n(s=>!s)}),r&&w.jsx("div",{className:A??"absolute top-full right-0 mt-1 w-56 rounded-lg border border-border bg-popover py-1 shadow-xl z-[70]",children:i({closeMenu:()=>n(!1)})})]})},FC=({onClick:e,icon:A,label:t,badge:i})=>w.jsxs("button",{onClick:e,className:"flex w-full items-center gap-2 px-3 py-2 text-left text-xs transition-colors hover:bg-muted",children:[w.jsx("span",{className:"text-muted-foreground",children:A}),w.jsx("span",{className:"flex-1",children:t}),i]}),tL=()=>w.jsx("div",{className:"my-1 border-t border-border"}),U4A=({children:e})=>w.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:e}),K4A=({isPanelOpen:e,onTogglePanel:A,annotationCount:t,onOpenExport:i,onOpenSettings:r,onDownloadAnnotations:n,onCopyShareLink:a,onOpenImport:s,onPrint:o,sharingEnabled:g,className:l})=>{const{theme:I,setTheme:C}=f4();return w.jsx(O4A,{className:l,renderTrigger:({isOpen:E,toggleMenu:B})=>w.jsx("button",{onClick:B,className:"p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"Menu",children:E?w.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}):w.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})})}),panelClassName:"absolute top-full right-0 mt-1 w-56 bg-popover border border-border rounded-lg shadow-xl z-[70] py-1",children:({closeMenu:E})=>w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"px-3 py-2",children:[w.jsx("div",{className:"mb-1.5",children:w.jsx(U4A,{children:"Theme"})}),w.jsx("div",{className:"flex items-center gap-1 bg-muted/50 rounded-lg p-0.5",children:["light","dark","system"].map(B=>w.jsx("button",{onClick:()=>C(B),className:`flex-1 px-2 py-1 text-[10px] capitalize rounded-md transition-colors ${I===B?"bg-background text-foreground shadow-sm font-medium":"text-muted-foreground hover:text-foreground"}`,children:B},B))})]}),w.jsx(tL,{}),w.jsx(FC,{onClick:()=>{E(),r()},icon:w.jsx(Y4A,{}),label:"Settings"}),w.jsx(FC,{onClick:()=>{E(),A()},icon:w.jsx(H4A,{}),label:e?"Hide Annotations":"Show Annotations",badge:t>0?w.jsx("span",{className:"text-[10px] font-mono bg-muted px-1.5 py-0.5 rounded text-muted-foreground",children:t}):void 0}),w.jsx(tL,{}),w.jsx(FC,{onClick:()=>{E(),i()},icon:w.jsx(P4A,{}),label:"Export"}),w.jsx(FC,{onClick:()=>{E(),n()},icon:w.jsx(J4A,{}),label:"Download Annotations"}),w.jsx(FC,{onClick:()=>{E(),o()},icon:w.jsx(W4A,{}),label:"Print Plan"}),g&&w.jsx(FC,{onClick:()=>{E(),a()},icon:w.jsx(z4A,{}),label:"Copy Share Link"}),g&&w.jsxs(w.Fragment,{children:[w.jsx(tL,{}),w.jsx(FC,{onClick:()=>{E(),s()},icon:w.jsx(q4A,{}),label:"Import Review"})]})]})})},Y4A=()=>w.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),H4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),P4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})}),J4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),z4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),q4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4M10 17l5-5-5-5M15 12H3"})}),W4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"})}),V4A=({isOpen:e,onComplete:A})=>{const[t,i]=aA.useState("acceptEdits");if(!e)return null;const r=()=>{PoA(t),A(t)};return sg.createPortal(w.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-background/90 backdrop-blur-sm p-4",children:w.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-lg shadow-2xl",children:[w.jsxs("div",{className:"p-5 border-b border-border",children:[w.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[w.jsx("div",{className:"p-1.5 rounded-lg bg-primary/15",children:w.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0"})})}),w.jsx("h3",{className:"font-semibold text-base",children:"New: Permission Mode Preservation"})]}),w.jsx("p",{className:"text-sm text-muted-foreground",children:"Claude Code 2.1.7+ supports preserving your permission mode after plan approval. Choose your preferred automation level."}),w.jsxs("p",{className:"text-xs text-muted-foreground/70 mt-1",children:["Requires Claude Code 2.1.7 or later. Run ",w.jsx("code",{className:"bg-muted px-1 rounded",children:"claude update"})," to update."]})]}),w.jsx("div",{className:"p-4 space-y-2",children:i3.map(n=>w.jsxs("label",{className:`flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all border ${t===n.value?"border-primary bg-primary/10":"border-transparent bg-muted/50 hover:bg-muted"}`,children:[w.jsx("input",{type:"radio",name:"permissionMode",value:n.value,checked:t===n.value,onChange:()=>i(n.value),className:"mt-0.5 accent-primary"}),w.jsxs("div",{className:"flex-1",children:[w.jsx("div",{className:"text-sm font-medium",children:n.label}),w.jsx("div",{className:"text-xs text-muted-foreground",children:n.description})]})]},n.value))}),w.jsxs("div",{className:"p-4 border-t border-border flex justify-between items-center",children:[w.jsx("p",{className:"text-xs text-muted-foreground",children:"You can change this later in Settings."}),w.jsx("button",{onClick:r,className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:opacity-90 transition-opacity",children:"Continue"})]})]})}),document.body)};function Z4A(e){const[A,t]=aA.useState(e),[i,r]=aA.useState("toc"),n=aA.useCallback(o=>{t(!0),o&&r(o)},[]),a=aA.useCallback(()=>{t(!1)},[]),s=aA.useCallback(o=>{A?i===o?t(!1):r(o):(t(!0),r(o))},[A,i]);return{isOpen:A,activeTab:i,open:n,close:a,toggleTab:s}}class j4A{diff(A,t,i={}){let r;typeof i=="function"?(r=i,i={}):"callback"in i&&(r=i.callback);const n=this.castInput(A,i),a=this.castInput(t,i),s=this.removeEmpty(this.tokenize(n,i)),o=this.removeEmpty(this.tokenize(a,i));return this.diffWithOptionsObj(s,o,i,r)}diffWithOptionsObj(A,t,i,r){var n;const a=m=>{if(m=this.postProcess(m,i),r){setTimeout(function(){r(m)},0);return}else return m},s=t.length,o=A.length;let g=1,l=s+o;i.maxEditLength!=null&&(l=Math.min(l,i.maxEditLength));const I=(n=i.timeout)!==null&&n!==void 0?n:1/0,C=Date.now()+I,E=[{oldPos:-1,lastComponent:void 0}];let B=this.extractCommon(E[0],t,A,0,i);if(E[0].oldPos+1>=o&&B+1>=s)return a(this.buildValues(E[0].lastComponent,t,A));let h=-1/0,Q=1/0;const f=()=>{for(let m=Math.max(h,-g);m<=Math.min(Q,g);m+=2){let y;const v=E[m-1],S=E[m+1];v&&(E[m-1]=void 0);let x=!1;if(S){const b=S.oldPos-m;x=S&&0<=b&&b<s}const R=v&&v.oldPos+1<o;if(!x&&!R){E[m]=void 0;continue}if(!R||x&&v.oldPos<S.oldPos?y=this.addToPath(S,!0,!1,0,i):y=this.addToPath(v,!1,!0,1,i),B=this.extractCommon(y,t,A,m,i),y.oldPos+1>=o&&B+1>=s)return a(this.buildValues(y.lastComponent,t,A))||!0;E[m]=y,y.oldPos+1>=o&&(Q=Math.min(Q,m-1)),B+1>=s&&(h=Math.max(h,m+1))}g++};if(r)(function m(){setTimeout(function(){if(g>l||Date.now()>C)return r(void 0);f()||m()},0)})();else for(;g<=l&&Date.now()<=C;){const m=f();if(m)return m}}addToPath(A,t,i,r,n){const a=A.lastComponent;return a&&!n.oneChangePerToken&&a.added===t&&a.removed===i?{oldPos:A.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:i,previousComponent:a.previousComponent}}:{oldPos:A.oldPos+r,lastComponent:{count:1,added:t,removed:i,previousComponent:a}}}extractCommon(A,t,i,r,n){const a=t.length,s=i.length;let o=A.oldPos,g=o-r,l=0;for(;g+1<a&&o+1<s&&this.equals(i[o+1],t[g+1],n);)g++,o++,l++,n.oneChangePerToken&&(A.lastComponent={count:1,previousComponent:A.lastComponent,added:!1,removed:!1});return l&&!n.oneChangePerToken&&(A.lastComponent={count:l,previousComponent:A.lastComponent,added:!1,removed:!1}),A.oldPos=o,g}equals(A,t,i){return i.comparator?i.comparator(A,t):A===t||!!i.ignoreCase&&A.toLowerCase()===t.toLowerCase()}removeEmpty(A){const t=[];for(let i=0;i<A.length;i++)A[i]&&t.push(A[i]);return t}castInput(A,t){return A}tokenize(A,t){return Array.from(A)}join(A){return A.join("")}postProcess(A,t){return A}get useLongestToken(){return!1}buildValues(A,t,i){const r=[];let n;for(;A;)r.push(A),n=A.previousComponent,delete A.previousComponent,A=n;r.reverse();const a=r.length;let s=0,o=0,g=0;for(;s<a;s++){const l=r[s];if(l.removed)l.value=this.join(i.slice(g,g+l.count)),g+=l.count;else{if(!l.added&&this.useLongestToken){let I=t.slice(o,o+l.count);I=I.map(function(C,E){const B=i[g+E];return B.length>C.length?B:C}),l.value=this.join(I)}else l.value=this.join(t.slice(o,o+l.count));o+=l.count,l.added||(g+=l.count)}}return r}}class _4A extends j4A{constructor(){super(...arguments),this.tokenize=AKA}equals(A,t,i){return i.ignoreWhitespace?((!i.newlineIsToken||!A.includes(`
|
|
502
502
|
`))&&(A=A.trim()),(!i.newlineIsToken||!t.includes(`
|
|
503
503
|
`))&&(t=t.trim())):i.ignoreNewlineAtEof&&!i.newlineIsToken&&(A.endsWith(`
|
|
504
504
|
`)&&(A=A.slice(0,-1)),t.endsWith(`
|
|
@@ -845,7 +845,7 @@ export const CursorOverlay: React.FC<CursorOverlayProps> = ({
|
|
|
845
845
|
---
|
|
846
846
|
|
|
847
847
|
**Target:** Ship MVP in next sprint
|
|
848
|
-
`;function OKA({blocks:e,annotations:A,addAnnotation:t,removeAnnotation:i}){const[r,n]=aA.useState(new Map),a=aA.useRef(e);a.current=e;const s=aA.useRef(A);s.current=A,aA.useEffect(()=>{if(r.size===0)return;const l=new Set(e.map(C=>C.id)),I=[...r.keys()].filter(C=>!l.has(C));I.length>0&&n(C=>{const E=new Map(C);return I.forEach(B=>E.delete(B)),E})},[e]);const o=aA.useCallback((l,I)=>{const C=a.current,E=s.current,B=C.find(Q=>Q.id===l);if(B&&I===B.checked)n(f=>{const m=new Map(f);return m.delete(l),m}),E.filter(f=>f.blockId===l&&f.id.startsWith("ann-checkbox-")).forEach(f=>i(f.id));else if(E.filter(f=>f.blockId===l&&f.id.startsWith("ann-checkbox-")).forEach(f=>i(f.id)),n(f=>{const m=new Map(f);return m.set(l,I),m}),B){const f=C.indexOf(B);let m="";for(let x=f-1;x>=0;x--)if(C[x].type==="heading"){m=C[x].content;break}const y=I?"Mark as completed":"Mark as not completed",v=m?` (under "${m}")`:` (line ${B.startLine})`,S={id:`ann-checkbox-${l}-${Date.now()}`,blockId:l,startOffset:0,endOffset:B.content.length,type:gi.COMMENT,text:`${y}${v}: ${B.content}`,originalText:B.content,createdA:Date.now()};t(S)}},[t,i]),g=aA.useCallback(l=>{n(I=>{const C=new Map(I);return C.delete(l),C})},[]);return{overrides:r,toggle:o,revertOverride:g}}const UKA=()=>{const[e,A]=aA.useState(GKA),[t,i]=aA.useState([]),[r,n]=aA.useState(null),[a,s]=aA.useState([]),[o,g]=aA.useState(null),[l,I]=aA.useState(!1),[C,E]=aA.useState(!1),[B,h]=aA.useState(!1),[Q,f]=aA.useState(!1),[m,y]=aA.useState(!1),[v,S]=aA.useState(""),[x,R]=aA.useState(()=>window.innerWidth>=768),[b,N]=aA.useState(!1),[T,L]=aA.useState(R4A),[K,H]=aA.useState(k4A),[k,U]=aA.useState(()=>ze.getItem("plannotator-tater-mode")==="true"),[O,F]=aA.useState(()=>t3()),[G,P]=aA.useState(!1),[z,Y]=aA.useState(null),[V,j]=aA.useState(),[AA,X]=aA.useState(!1),[gA,nA]=aA.useState([]),[hA,rA]=aA.useState(!1),[oA,lA]=aA.useState(null),[sA,uA]=aA.useState(void 0),[CA,xA]=aA.useState(!0),[BA,VA]=aA.useState(!1),[tA,ne]=aA.useState(null),[RA,ce]=aA.useState(null),[Ie,Qe]=aA.useState(!1),[OA,ie]=aA.useState("bypassPermissions"),[YA,ZA]=aA.useState(!0),[ae,NA]=aA.useState(void 0),[$A,EA]=aA.useState(void 0),[vA,Z]=aA.useState(null),[mA,pA]=aA.useState(null);aA.useEffect(()=>{document.title=vA?`${vA.display} · Plannotator`:"Plannotator"},[vA]);const[kA,MA]=aA.useState(!1),[TA,dA]=aA.useState(),[wA,PA]=aA.useState(null),[_A,Ee]=aA.useState(!1),[yA,UA]=aA.useState("clean"),[KA,te]=aA.useState(null),[Ge,Se]=aA.useState(null),eA=aA.useRef(null),le=aA.useRef(null);G4A();const se=hW({storageKey:"plannotator-panel-width"}),ve=hW({storageKey:"plannotator-toc-width",defaultWidth:240,minWidth:160,maxWidth:400,side:"left"}),Me=se.isDragging||ve.isDragging,ke=Z4A(t3().tocEnabled);aA.useEffect(()=>{O.tocEnabled?ke.open("toc"):ke.close()},[O.tocEnabled]),aA.useEffect(()=>{ke.activeTab==="toc"&&_A&&Ee(!1)},[ke.activeTab]),aA.useEffect(()=>{if(!_A)return;const XA=Ke=>{Ke.key==="Escape"&&Ee(!1)};return document.addEventListener("keydown",XA),()=>document.removeEventListener("keydown",XA)},[_A]);const Re=tKA(e,KA,Ge),we=iKA({markdown:e,annotations:t,selectedAnnotationId:r,globalAttachments:gA,setMarkdown:A,setAnnotations:i,setSelectedAnnotationId:n,setGlobalAttachments:nA,viewerRef:eA,sidebar:ke}),rt=gKA({markdown:e,viewerRef:eA,linkedDocHook:we,setMarkdown:A,setAnnotations:i,setSelectedAnnotationId:n,setSubmitted:ne}),We=rKA(),It=aA.useMemo(()=>nUA(),[O]),Et=aA.useMemo(()=>{if(!It)return"";const XA=cI();return II(XA)},[It,O]);aA.useEffect(()=>{It||We.setActiveFile(null)},[It]),aA.useEffect(()=>{ke.activeTab==="vault"&&It&&Et&&We.tree.length===0&&!We.isLoading&&We.fetchTree(Et)},[ke.activeTab,It,Et]);const Gt=cn.useCallback(XA=>Ke=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(XA)}&path=${encodeURIComponent(Ke)}`,[]),Dt=cn.useCallback(XA=>{we.open(XA,Gt(Et)),We.setActiveFile(XA)},[Et,we,We,Gt]),pt=uKA(),ci=aA.useMemo(()=>!!mA||gW(),[mA,O]),Ye=aA.useMemo(()=>{const XA=mA?[mA]:[],Ke=gW()?D4().directories:[];return[...new Set([...XA,...Ke])]},[mA,O]);aA.useEffect(()=>{ci||pt.setActiveFile(null)},[ci]),aA.useEffect(()=>{if(ke.activeTab==="files"&&ci&&Ye.length>0){const XA=pt.dirs.map(At=>At.path);(Ye.length!==XA.length||Ye.some(At=>!XA.includes(At)))&&pt.fetchAll(Ye)}},[ke.activeTab,ci,Ye]);const zA=cn.useCallback((XA,Ke)=>{const At=mt=>`/api/doc?path=${encodeURIComponent(mt)}&base=${encodeURIComponent(Ke)}`;we.open(XA,At,"files"),pt.setActiveFile(XA),We.setActiveFile(null)},[we,pt]),be=cn.useCallback(XA=>{if(We.activeFile&&Et)we.open(XA,Gt(Et));else if(pt.activeFile&&pt.activeDirPath){const Ke=we.filepath?.replace(/\/[^/]+$/,"")||pt.activeDirPath;we.open(XA,At=>`/api/doc?path=${encodeURIComponent(At)}&base=${encodeURIComponent(Ke)}`)}else{const Ke=we.filepath?we.filepath.replace(/\/[^/]+$/,""):sA;Ke?we.open(XA,At=>`/api/doc?path=${encodeURIComponent(At)}&base=${encodeURIComponent(Ke)}`):we.open(XA)}},[We.activeFile,Et,pt.activeFile,pt.activeDirPath,we,Gt,sA]),_e=cn.useCallback(()=>{we.back(),We.setActiveFile(null),pt.setActiveFile(null),rt.clearSelection()},[we,We,pt,rt]),Rt=aA.useMemo(()=>{const XA=new Map;for(const[Ke,At]of we.getDocAnnotations()){const mt=At.annotations.length+At.globalAttachments.length;mt>0&&XA.set(Ke,mt)}return XA},[we.getDocAnnotations,t,gA]),ai=aA.useMemo(()=>{if(Ye.length===0)return Rt;const XA=new Map;for(const[Ke,At]of Rt)Ye.some(mt=>Ke.startsWith(mt+"/"))&&XA.set(Ke,At);return XA},[Rt,Ye]),Ct=aA.useMemo(()=>{if(!Et)return new Map;const XA=Et.endsWith("/")?Et:Et+"/",Ke=new Map;for(const[At,mt]of Rt)At.startsWith(XA)&&Ke.set(At.slice(XA.length),mt);return Ke},[Rt,Et]),Ii=ai.size>0,Li=Ct.size>0,fi=aA.useMemo(()=>{const XA=we.filepath;let Ke=0,At=0;for(const[mt,Si]of Rt)mt!==XA&&(Ke+=Si,At++);return Ke>0?{count:Ke,files:At}:void 0},[Rt,we.filepath]),[Le,ye]=aA.useState(),Te=cn.useRef(),Ne=cn.useCallback(()=>{const XA=new Set(Rt.keys());XA.size!==0&&((!ke.isOpen||ke.activeTab!=="files"&&ke.activeTab!=="vault")&&ke.open(Li&&!Ii?"vault":"files"),Te.current&&clearTimeout(Te.current),ye(void 0),requestAnimationFrame(()=>{ye(XA),Te.current=setTimeout(()=>ye(void 0),1200)}))},[Rt,ke,Li,Ii]),me=aA.useMemo(()=>{if(!Le||!Et)return;const XA=Et.endsWith("/")?Et:Et+"/",Ke=new Set;for(const At of Le)At.startsWith(XA)&&Ke.add(At.slice(XA.length));return Ke.size>0?Ke:void 0},[Le,Et]),ot=oA==="folder"?"file list":oA==="file"?"file":oA==="message"?"message":"plan",LA=cn.useCallback(()=>{We.fetchTree(Et)},[We,Et]),er=aA.useMemo(()=>a.filter(XA=>XA.type==="heading").length,[a]),FA=d4A(le,er),{editorAnnotations:wt,deleteEditorAnnotation:es}=cKA(),{externalAnnotations:nn,updateExternalAnnotation:Ma,deleteExternalAnnotation:vs}=EKA({enabled:G}),Ht=aA.useMemo(()=>nn.length===0?t:[...t.filter(Ke=>Ke.source?!nn.some(At=>At.source===Ke.source&&At.type===Ke.type&&At.originalText===Ke.originalText):!0),...nn],[t,nn]),ar=aA.useMemo(()=>Ht.filter(XA=>!!XA.diffContext),[Ht]),ts=aA.useMemo(()=>Ht.filter(XA=>!XA.diffContext),[Ht]),{isSharedSession:Or,isLoadingShared:Ea,shareUrl:wi,shareUrlSize:Ss,shortShareUrl:sr,isGeneratingShortUrl:dt,shortUrlError:kt,pendingSharedAnnotations:vi,clearPendingSharedAnnotations:Ai,generateShortUrl:Wr,importFromShareUrl:or,shareLoadError:Un,clearShareLoadError:an}=E4A(e,Ht,gA,A,i,nA,()=>{xA(!1)},ae,$A),{draftBanner:qe,restoreDraft:q,dismissDraft:_}=oKA({annotations:Ht,globalAttachments:gA,isApiMode:G,isSharedSession:Or,submitted:!!tA}),IA=cn.useCallback(()=>{const{annotations:XA,globalAttachments:Ke}=q();XA.length>0&&(i(XA),Ke.length>0&&nA(Ke),setTimeout(()=>{eA.current?.applySharedAnnotations(XA.filter(At=>!At.diffContext))},100))},[q]),{getAgentWarning:DA}=qoA(z);aA.useEffect(()=>{if(vi&&vi.length>0){const XA=setTimeout(()=>{eA.current?.clearAllHighlights(),eA.current?.applySharedAnnotations(vi.filter(Ke=>!Ke.diffContext)),Ai()},100);return()=>clearTimeout(XA)}},[vi,Ai]);const GA=XA=>{U(XA),ze.setItem("plannotator-tater-mode",String(XA))},jA=XA=>{L(XA),N4A(XA)},ge=XA=>{H(XA),x4A(XA)};F4A(K,ge),aA.useEffect(()=>{Ea||Or||fetch("/api/plan").then(XA=>{if(!XA.ok)throw new Error("Not in API mode");return XA.json()}).then(XA=>{pa.init(XA.serverConfig),j(XA.serverConfig?.gitUser),XA.mode==="archive"?(A(XA.plan||""),XA.archivePlans&&rt.init(XA.archivePlans),rt.fetchPlans(),ZA(!1),ke.open("archive")):XA.mode==="annotate-folder"?A(""):XA.plan&&A(XA.plan),P(!0),(XA.mode==="annotate"||XA.mode==="annotate-last"||XA.mode==="annotate-folder")&&rA(!0),XA.mode==="annotate-folder"&&ke.open("files"),XA.mode&&XA.mode!=="archive"&&lA(XA.mode==="annotate-last"?"message":XA.mode==="annotate-folder"?"folder":"file"),XA.filePath&&uA(XA.mode==="annotate-folder"?XA.filePath:XA.filePath.replace(/\/[^/]+$/,"")),XA.sharingEnabled!==void 0&&ZA(XA.sharingEnabled),XA.shareBaseUrl&&NA(XA.shareBaseUrl),XA.pasteApiUrl&&EA(XA.pasteApiUrl),XA.repoInfo&&Z(XA.repoInfo),XA.projectRoot&&pA(XA.projectRoot),XA.previousPlan!==void 0&&te(XA.previousPlan),XA.versionInfo&&Se(XA.versionInfo),XA.origin&&(Y(XA.origin),XA.origin==="claude-code"&&xUA()&&Qe(!0),ie(HoA().mode)),XA.isWSL&&X(!0)}).catch(()=>{P(!1)}).finally(()=>xA(!1))},[Ea,Or]),aA.useEffect(()=>{const{frontmatter:XA}=qAA(e);g(XA),s(WAA(e))},[e]);const fe=aA.useRef(!1),Xe=aA.useRef({}),Ot=aA.useRef(null);aA.useEffect(()=>{fe.current=!1,Xe.current={},Ot.current=null},[e]),aA.useEffect(()=>{if(!G||!e||Or||hA||rt.archiveMode||fe.current)return;const XA={},Ke=[],At=cI();if(At.autoSave&&At.enabled){const Ir=II(At);Ir&&(XA.obsidian={vaultPath:Ir,folder:At.folder||"plannotator",plan:e,...At.filenameFormat&&{filenameFormat:At.filenameFormat},...At.filenameSeparator&&At.filenameSeparator!=="space"&&{filenameSeparator:At.filenameSeparator}},Ke.push("Obsidian"))}const mt=rI();mt.autoSave&&mt.enabled&&(XA.bear={plan:e,customTags:mt.customTags,tagPosition:mt.tagPosition},Ke.push("Bear"));const Si=MB();if(Si.autoSave&&rQ()&&(XA.octarine={plan:e,workspace:Si.workspace,folder:Si.folder||"plannotator"},Ke.push("Octarine")),Ke.length===0)return;fe.current=!0;const wr=fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(XA)}).then(Ir=>Ir.json()).then(Ir=>{const Fo={...XA.obsidian?{obsidian:!!Ir.results?.obsidian?.success}:{},...XA.bear?{bear:!!Ir.results?.bear?.success}:{},...XA.octarine?{octarine:!!Ir.results?.octarine?.success}:{}};Xe.current=Fo;const Cl=Ke.filter(jd=>!Ir.results?.[jd.toLowerCase()]?.success);return Cl.length===0?PA({type:"success",message:`Auto-saved to ${Ke.join(" & ")}`}):PA({type:"error",message:`Auto-save failed for ${Cl.join(" & ")}`}),Fo}).catch(()=>(Xe.current={},PA({type:"error",message:"Auto-save failed"}),{})).finally(()=>setTimeout(()=>PA(null),3e3));Ot.current=wr},[G,e,Or,hA]),aA.useEffect(()=>{const XA=Ke=>{const At=Ke.clipboardData?.items;if(At){for(const mt of At)if(mt.type.startsWith("image/")){Ke.preventDefault();const Si=mt.getAsFile();if(Si){const wr=JF(Si.name,gA.map(Fo=>Fo.name)),Ir=URL.createObjectURL(Si);ce({file:Si,blobUrl:Ir,initialName:wr})}break}}};return document.addEventListener("paste",XA),()=>document.removeEventListener("paste",XA)},[gA]);const Pt=async(XA,Ke,At)=>{if(RA)try{const mt=new FormData,Si=Ke?new File([XA],"annotated.png",{type:"image/png"}):RA.file;mt.append("file",Si);const wr=await fetch("/api/upload",{method:"POST",body:mt});if(wr.ok){const Ir=await wr.json();nA(Fo=>[...Fo,{path:Ir.path,name:At}])}}catch{}finally{URL.revokeObjectURL(RA.blobUrl),ce(null)}},ti=()=>{RA&&(URL.revokeObjectURL(RA.blobUrl),ce(null))},Xt=async()=>{VA(!0);try{const XA=cI(),Ke=rI(),At=MB(),mt=m4(),Si=Bv(),wr=Ke.autoSave&&Ot.current?await Ot.current:Xe.current,Ir={};z==="claude-code"&&(Ir.permissionMode=OA);const Fo=RUA(mt);Fo&&(Ir.agentSwitch=Fo),Ir.planSave={enabled:Si.enabled,...Si.customPath&&{customPath:Si.customPath}};const Cl=II(XA);XA.enabled&&Cl&&(Ir.obsidian={vaultPath:Cl,folder:XA.folder||"plannotator",plan:e,...XA.filenameFormat&&{filenameFormat:XA.filenameFormat},...XA.filenameSeparator&&XA.filenameSeparator!=="space"&&{filenameSeparator:XA.filenameSeparator}}),Ke.enabled&&!(Ke.autoSave&&wr.bear)&&(Ir.bear={plan:e,customTags:Ke.customTags,tagPosition:Ke.tagPosition}),rQ()&&(Ir.octarine={plan:e,workspace:At.workspace,folder:At.folder||"plannotator"});const jd=Array.from(we.getDocAnnotations().values()).some(xp=>xp.annotations.length>0||xp.globalAttachments.length>0);(Ht.length>0||gA.length>0||jd||wt.length>0)&&(Ir.feedback=bs),await fetch("/api/approve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ir)}),ne("approved")}catch{VA(!1)}},vt=async()=>{VA(!0);try{const XA=Bv();await fetch("/api/deny",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:bs,planSave:{enabled:XA.enabled,...XA.customPath&&{customPath:XA.customPath}}})}),ne("denied")}catch{VA(!1)}},Tt=async()=>{VA(!0);try{await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:bs,annotations:Ht})}),ne("denied")}catch{VA(!1)}};aA.useEffect(()=>{const XA=Ke=>{if(Ke.key!=="Enter"||!(Ke.metaKey||Ke.ctrlKey))return;const At=Ke.target?.tagName;if(At==="INPUT"||At==="TEXTAREA"||l||C||B||Q||m||Ie||RA||tA||BA||!G||we.isActive)return;if(Ke.preventDefault(),hA){Tt();return}const mt=we.getDocAnnotations(),Si=Array.from(mt.values()).some(wr=>wr.annotations.length>0||wr.globalAttachments.length>0);if(Ht.length===0&&wt.length===0&&!Si){if(z==="opencode"){const wr=DA();if(wr){S(wr),y(!0);return}}Xt()}else vt()};return window.addEventListener("keydown",XA),()=>window.removeEventListener("keydown",XA)},[l,C,B,Q,m,Ie,RA,tA,BA,G,we.isActive,t.length,nn.length,hA,z,DA]);const Hi=XA=>{i(Ke=>[...Ke,XA]),n(XA.id),R(!0)},pn=cn.useCallback(XA=>{n(XA),XA&&window.innerWidth<768&&R(!0)},[]),mn=XA=>{eA.current?.removeHighlight(XA),i(Ke=>Ke.filter(At=>At.id!==XA)),r===XA&&n(null)},Pi=OKA({blocks:a,annotations:t,addAnnotation:Hi,removeAnnotation:mn}),Vr=XA=>{const Ke=Ht.find(At=>At.id===XA);if(Ke?.source&&nn.some(At=>At.id===XA)){vs(XA),r===XA&&n(null);return}XA.startsWith("ann-checkbox-")&&Ke&&Pi.revertOverride(Ke.blockId),mn(XA)},Ao=(XA,Ke)=>{if(Ht.find(mt=>mt.id===XA)?.source&&nn.some(mt=>mt.id===XA)){Ma(XA,Ke);return}i(mt=>mt.map(Si=>Si.id===XA?{...Si,...Ke}:Si))},Kn=(XA,Ke)=>{i(At=>At.map(mt=>mt.author===XA?{...mt,author:Ke}:mt))},hg=XA=>{nA(Ke=>[...Ke,XA])},kr=XA=>{nA(Ke=>Ke.filter(At=>At.path!==XA))},Wd=XA=>{},bs=aA.useMemo(()=>{const XA=we.getDocAnnotations(),Ke=Array.from(XA.values()).some(wr=>wr.annotations.length>0||wr.globalAttachments.length>0),At=Ht.length>0||gA.length>0,mt=wt.length>0;if(!At&&!Ke&&!mt)return"User reviewed the document and has no feedback.";let Si=At?pfA(a,Ht,gA,oA==="message"?"Message Feedback":oA==="folder"?"Folder Feedback":oA==="file"?"File Feedback":"Plan Feedback",oA??"plan"):"";return Ke&&(Si+=mfA(XA)),mt&&(Si+=yfA(wt)),Si},[a,Ht,gA,we.getDocAnnotations,wt]),Il=cn.useMemo(()=>u4A(),[]),CC=cn.useCallback(async XA=>{if(!(!Il||BA||!wi)){VA(!0);try{const Ke=await B4A(XA,Il,wi);Ke&&(PA(Ke),setTimeout(()=>PA(null),4e3),Ke.type==="success"&&ne(XA===bD.Approve?"approved":"denied"))}finally{VA(!1)}}},[Il,BA,wi]),Nb=cn.useCallback(()=>CC(bD.Approve),[CC]),Mb=cn.useCallback(()=>CC(bD.Feedback),[CC]),Vd=()=>{MA(!1);const XA=new Blob([bs],{type:"text/plain"}),Ke=URL.createObjectURL(XA),At=document.createElement("a");At.href=Ke,At.download="annotations.md",At.click(),URL.revokeObjectURL(Ke),PA({type:"success",message:"Downloaded annotations"}),setTimeout(()=>PA(null),3e3)},Qg=async XA=>{MA(!1);const Ke={};if(XA==="obsidian"){const mt=cI(),Si=II(mt);Si&&(Ke.obsidian={vaultPath:Si,folder:mt.folder||"plannotator",plan:e,...mt.filenameFormat&&{filenameFormat:mt.filenameFormat},...mt.filenameSeparator&&mt.filenameSeparator!=="space"&&{filenameSeparator:mt.filenameSeparator}})}if(XA==="bear"){const mt=rI();Ke.bear={plan:e,customTags:mt.customTags,tagPosition:mt.tagPosition}}if(XA==="octarine"){const mt=MB();Ke.octarine={plan:e,workspace:mt.workspace,folder:mt.folder||"plannotator"}}const At=XA==="obsidian"?"Obsidian":XA==="bear"?"Bear":"Octarine";try{const wr=(await(await fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ke)})).json()).results?.[XA];wr?.success?PA({type:"success",message:`Saved to ${At}`}):PA({type:"error",message:wr?.error||"Save failed"})}catch{PA({type:"error",message:"Save failed"})}setTimeout(()=>PA(null),3e3)};aA.useEffect(()=>{const XA=Ke=>{if(Ke.key!=="s"||!(Ke.metaKey||Ke.ctrlKey))return;const At=Ke.target?.tagName;if(At==="INPUT"||At==="TEXTAREA"||l||B||Q||m||Ie||RA||tA||!G)return;Ke.preventDefault();const mt=zoA(),Si=X2(),wr=rI().enabled,Ir=rQ();mt==="download"?Vd():mt==="obsidian"&&Si?Qg("obsidian"):mt==="bear"&&wr?Qg("bear"):mt==="octarine"&&Ir?Qg("octarine"):(dA("notes"),I(!0))};return window.addEventListener("keydown",XA),()=>window.removeEventListener("keydown",XA)},[l,B,Q,m,Ie,RA,tA,G,e,bs]),aA.useEffect(()=>{const XA=Ke=>{if(Ke.key!=="p"||!(Ke.metaKey||Ke.ctrlKey))return;const At=Ke.target?.tagName;At==="INPUT"||At==="TEXTAREA"||l||B||Q||m||Ie||RA||tA||(Ke.preventDefault(),window.print())};return window.addEventListener("keydown",XA),()=>window.removeEventListener("keydown",XA)},[l,B,Q,m,Ie,RA,tA]),aA.useEffect(()=>{if(!kA)return;const XA=Ke=>{Ke.target.closest("[data-export-dropdown]")||MA(!1)};return document.addEventListener("pointerdown",XA),()=>document.removeEventListener("pointerdown",XA)},[kA]);const fg=aA.useMemo(()=>hfA(z),[z]),Zd=aA.useMemo(()=>({compact:832,default:1040,wide:1280})[O.planWidth]??832,[O.planWidth]);return w.jsx(cUA,{defaultTheme:"dark",children:w.jsxs("div",{"data-print-region":"root",className:"h-screen flex flex-col bg-background overflow-hidden",children:[w.jsxs("header",{className:"h-12 flex items-center justify-between px-2 md:px-4 border-b border-border/50 bg-card/50 backdrop-blur-xl sticky top-0 z-[50]",children:[w.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[w.jsx("a",{href:"https://plannotator.ai",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 md:gap-2 hover:opacity-80 transition-opacity",children:w.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Plannotator"})}),w.jsxs("a",{href:"https://github.com/backnotprop/plannotator/releases",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground font-mono opacity-60 hidden md:inline hover:opacity-100 transition-opacity",children:["v","0.17.0"]}),z&&w.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium hidden md:inline ${QfA(z)}`,children:fg})]}),w.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[Il&&!G&&Or&&w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"}),w.jsx(cW,{onClick:Mb,disabled:BA||!wi,isLoading:BA,title:"Send feedback to bot"}),w.jsx(IW,{onClick:Nb,disabled:BA||!wi,isLoading:BA,title:"Approve design and notify bot"})]}),G&&!we.isActive&&rt.archiveMode&&w.jsxs(w.Fragment,{children:[w.jsxs("button",{onClick:rt.copy,className:"px-2.5 py-1 rounded-md text-xs font-medium transition-all bg-muted text-foreground hover:bg-muted/80 border border-border",title:"Copy plan content",children:[w.jsx("span",{className:"hidden md:inline",children:"Copy"}),w.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})]}),w.jsx("button",{onClick:rt.done,className:"px-2.5 py-1 rounded-md text-xs font-medium transition-all bg-success text-success-foreground hover:opacity-90",title:"Close archive",children:"Done"})]}),G&&!we.isActive&&!rt.archiveMode&&w.jsxs(w.Fragment,{children:[w.jsx(cW,{onClick:()=>{if(hA){Tt();return}const XA=we.getDocAnnotations(),Ke=Array.from(XA.values()).some(At=>At.annotations.length>0||At.globalAttachments.length>0);Ht.length===0&&wt.length===0&&!Ke?h(!0):vt()},disabled:BA,isLoading:BA,label:hA?Ht.length>0||wt.length>0||we.docAnnotationCount>0?"Send Annotations":"Done":"Send Feedback",title:hA?Ht.length>0||wt.length>0||we.docAnnotationCount>0?"Send Annotations":"Done":"Send Feedback"}),!hA&&w.jsxs("div",{className:"relative group/approve",children:[w.jsx(IW,{onClick:()=>{if(z==="claude-code"&&Ht.length>0){f(!0);return}if(z==="opencode"){const XA=DA();if(XA){S(XA),y(!0);return}}Xt()},disabled:BA,isLoading:BA,dimmed:(z==="claude-code"||z==="gemini-cli")&&Ht.length>0}),(z==="claude-code"||z==="gemini-cli")&&Ht.length>0&&w.jsxs("div",{className:"absolute top-full right-0 mt-2 px-3 py-2 bg-popover border border-border rounded-lg shadow-xl text-xs text-foreground w-56 text-center opacity-0 invisible group-hover/approve:opacity-100 group-hover/approve:visible transition-all pointer-events-none z-50",children:[w.jsx("div",{className:"absolute bottom-full right-4 border-4 border-transparent border-b-border"}),w.jsx("div",{className:"absolute bottom-full right-4 mt-px border-4 border-transparent border-b-popover"}),fg," doesn't support feedback on approval. Your annotations won't be seen."]})]}),w.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"})]}),w.jsxs("div",{className:"hidden md:flex items-center gap-2",children:[w.jsx(IUA,{}),!we.isActive&&w.jsx(s4A,{taterMode:k,onTaterModeChange:GA,onIdentityChange:Kn,origin:z,onUIPreferencesChange:F,externalOpen:b,onExternalClose:()=>N(!1),gitUser:V}),w.jsx("button",{onClick:()=>R(!x),className:`p-1.5 rounded-md text-xs font-medium transition-all ${x?"bg-primary/15 text-primary":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})}),w.jsxs("div",{className:"relative flex","data-export-dropdown":!0,children:[w.jsx("button",{onClick:()=>{dA(void 0),I(!0)},className:"px-2.5 py-1 rounded-l-md text-xs font-medium bg-muted hover:bg-muted/80 transition-colors",title:"Export",children:"Export"}),w.jsx("button",{onClick:()=>MA(XA=>!XA),className:"px-1.5 rounded-r-md text-xs bg-muted hover:bg-muted/80 border-l border-border/50 transition-colors flex items-center",title:"Quick save options",children:w.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}),kA&&w.jsxs("div",{className:"absolute top-full right-0 mt-1 w-48 bg-popover border border-border rounded-lg shadow-xl z-50 py-1",children:[YA&&w.jsxs("button",{onClick:async()=>{MA(!1);try{await navigator.clipboard.writeText(wi),PA({type:"success",message:"Share link copied"})}catch{PA({type:"error",message:"Failed to copy"})}setTimeout(()=>PA(null),3e3)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),"Copy Share Link"]}),w.jsxs("button",{onClick:Vd,className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),"Download Annotations"]}),w.jsxs("button",{onClick:()=>{MA(!1),window.print()},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"})}),"Print Plan",w.jsxs("span",{className:"ml-auto text-[10px] text-muted-foreground/60",children:[cs,"+P"]})]}),w.jsx("div",{className:"my-1 border-t border-border"}),G&&X2()&&w.jsxs("button",{onClick:()=>Qg("obsidian"),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),"Save to Obsidian"]}),G&&rI().enabled&&w.jsxs("button",{onClick:()=>Qg("bear"),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),"Save to Bear"]}),G&&rQ()&&w.jsxs("button",{onClick:()=>Qg("octarine"),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),"Save to Octarine"]}),G&&!X2()&&!rI().enabled&&!rQ()&&w.jsx("div",{className:"px-3 py-2 text-[10px] text-muted-foreground",children:"No notes apps configured."}),YA&&w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"my-1 border-t border-border"}),w.jsxs("button",{onClick:()=>{MA(!1),E(!0)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4M10 17l5-5-5-5M15 12H3"})}),"Import Review"]})]})]})]})]}),w.jsx(K4A,{className:"md:hidden",isPanelOpen:x,onTogglePanel:()=>R(!x),annotationCount:Ht.length+wt.length,onOpenExport:()=>{dA(void 0),I(!0)},onOpenSettings:()=>N(!0),onDownloadAnnotations:Vd,onCopyShareLink:async()=>{try{await navigator.clipboard.writeText(wi),PA({type:"success",message:"Share link copied"})}catch{PA({type:"error",message:"Failed to copy"})}setTimeout(()=>PA(null),3e3)},onOpenImport:()=>E(!0),onPrint:()=>window.print(),sharingEnabled:YA})]})]}),we.error&&w.jsxs("div",{className:"bg-destructive/10 border-b border-destructive/20 px-4 py-2 flex items-center gap-2 flex-shrink-0",children:[w.jsx("span",{className:"text-xs text-destructive",children:we.error}),w.jsx("button",{onClick:we.dismissError,className:"ml-auto text-xs text-destructive/60 hover:text-destructive",children:"dismiss"})]}),w.jsxs("div",{"data-print-region":"content",className:`flex-1 flex overflow-hidden relative z-0 ${Me?"select-none":""}`,children:[k&&w.jsx(mUA,{}),!ke.isOpen&&w.jsx(BKA,{activeTab:ke.activeTab,onToggleTab:ke.toggleTab,hasDiff:Re.hasPreviousVersion,showFilesTab:ci&&!rt.archiveMode,showVaultTab:It,hasFileAnnotations:Ii,hasVaultAnnotations:Li,className:"hidden lg:flex"}),ke.isOpen&&w.jsxs(w.Fragment,{children:[w.jsx(bKA,{activeTab:ke.activeTab,onTabChange:XA=>{ke.toggleTab(XA),XA==="archive"&&!rt.archiveMode&&rt.fetchPlans()},onClose:ke.close,width:ve.width,blocks:a,annotations:t,activeSection:FA,onTocNavigate:Wd,linkedDocFilepath:we.filepath,onLinkedDocBack:we.isActive?_e:void 0,backLabel:ot,showFilesTab:ci&&!rt.archiveMode,fileAnnotationCounts:ai,highlightedFiles:Le,fileBrowser:pt,onFilesSelectFile:zA,onFilesFetchAll:()=>pt.fetchAll(Ye),showVaultTab:It&&!rt.archiveMode,vaultPath:Et,vaultBrowser:We,vaultAnnotationCounts:Ct,vaultHighlightedFiles:me,onVaultSelectFile:Dt,onVaultFetchTree:LA,hasFileAnnotations:Ii,hasVaultAnnotations:Li,versionInfo:Ge,versions:Re.versions,selectedBaseVersion:Re.diffBaseVersion,onSelectBaseVersion:Re.selectBaseVersion,isPlanDiffActive:_A,hasPreviousVersion:Re.hasPreviousVersion,onActivatePlanDiff:()=>Ee(!0),isLoadingVersions:Re.isLoadingVersions,isSelectingVersion:Re.isSelectingVersion,fetchingVersion:Re.fetchingVersion,onFetchVersions:Re.fetchVersions,showArchiveTab:G&&!hA,archivePlans:rt.plans,selectedArchiveFile:rt.selectedFile,onArchiveSelect:rt.select,isLoadingArchive:rt.isLoading}),w.jsx(QW,{...ve.handleProps,className:"hidden lg:block",side:"left"})]}),w.jsxs("main",{"data-print-region":"document",ref:le,className:"flex-1 min-w-0 overflow-y-auto bg-grid",children:[w.jsx(nQ,{isOpen:!!qe,onClose:_,onConfirm:IA,title:"Draft Recovered",message:qe?`Found ${qe.count} annotation${qe.count!==1?"s":""} from ${qe.timeAgo}. Would you like to restore them?`:"",confirmText:"Restore",cancelText:"Dismiss",showCancel:!0}),w.jsxs("div",{className:"min-h-full flex flex-col items-center px-2 py-3 md:px-10 md:py-8 xl:px-16 relative z-10",children:[!_A&&!rt.archiveMode&&w.jsx("div",{"data-print-hide":!0,className:"w-full mb-3 md:mb-4 flex items-center justify-start",style:{maxWidth:Zd},children:w.jsx(BUA,{inputMethod:K,onInputMethodChange:ge,mode:T,onModeChange:jA,taterMode:k})}),Re.diffBlocks&&Re.diffStats&&w.jsx("div",{className:"w-full flex justify-center",style:{display:_A?void 0:"none"},children:w.jsx(FKA,{diffBlocks:Re.diffBlocks,diffStats:Re.diffStats,diffMode:yA,onDiffModeChange:UA,onPlanDiffToggle:()=>Ee(!1),repoInfo:vA,baseVersionLabel:Re.diffBaseVersion!=null?`v${Re.diffBaseVersion}`:void 0,baseVersion:Re.diffBaseVersion??void 0,maxWidth:Zd,annotations:ar,onAddAnnotation:Hi,onSelectAnnotation:pn,selectedAnnotationId:r,mode:T})}),oA==="folder"&&!e&&!we.isActive&&w.jsx("div",{className:"w-full flex justify-center",children:w.jsxs("div",{className:"w-full max-w-3xl p-12 text-center text-muted-foreground",children:[w.jsx("p",{className:"text-lg font-medium mb-2",children:"Select a file to annotate"}),w.jsx("p",{className:"text-sm",children:"Pick a markdown file from the sidebar to begin."})]})}),w.jsx("div",{className:"w-full flex justify-center",style:{display:_A&&Re.diffBlocks||oA==="folder"&&!e&&!we.isActive?"none":void 0},children:w.jsx(VOA,{ref:eA,blocks:a,markdown:e,frontmatter:o,annotations:ts,onAddAnnotation:Hi,onSelectAnnotation:pn,selectedAnnotationId:r,mode:T,inputMethod:K,taterMode:k,globalAttachments:gA,onAddGlobalAttachment:hg,onRemoveGlobalAttachment:kr,repoInfo:vA,stickyActions:O.stickyActionsEnabled,planDiffStats:we.isActive?null:Re.diffStats,isPlanDiffActive:_A,onPlanDiffToggle:()=>Ee(!_A),hasPreviousVersion:!we.isActive&&Re.hasPreviousVersion,showDemoBadge:!G&&!Ea&&!Or,maxWidth:Zd,onOpenLinkedDoc:be,linkedDocInfo:we.isActive?{filepath:we.filepath,onBack:_e,label:We.activeFile?"Vault File":pt.activeFile?"File":void 0,backLabel:ot}:null,imageBaseDir:sA,copyLabel:oA==="message"?"Copy message":oA==="file"||oA==="folder"?"Copy file":void 0,archiveInfo:rt.currentInfo,onToggleCheckbox:Pi.toggle,checkboxOverrides:Pi.overrides},we.isActive?`doc:${we.filepath}`:"plan")})]})]}),x&&w.jsx(QW,{...se.handleProps,className:"hidden md:block",side:"right"}),w.jsx(AUA,{isOpen:x,blocks:a,annotations:Ht,selectedId:r,onSelect:n,onDelete:Vr,onEdit:Ao,shareUrl:wi,sharingEnabled:YA,width:se.width,editorAnnotations:wt,onDeleteEditorAnnotation:es,onClose:()=>R(!1),onQuickCopy:async()=>{await navigator.clipboard.writeText(VAA(bs))},otherFileAnnotations:fi,onOtherFileAnnotationsClick:Ne})]}),w.jsx(gUA,{isOpen:l,onClose:()=>{I(!1),dA(void 0)},shareUrl:wi,shareUrlSize:Ss,shortShareUrl:sr,isGeneratingShortUrl:dt,shortUrlError:kt,onGenerateShortUrl:Wr,annotationsOutput:bs,annotationCount:Ht.length,taterSprite:k?w.jsx(p4,{}):void 0,sharingEnabled:YA,markdown:e,isApiMode:G,initialTab:TA}),w.jsx(lUA,{isOpen:C,onClose:()=>E(!1),onImport:or,shareBaseUrl:ae}),w.jsx(nQ,{isOpen:B,onClose:()=>h(!1),title:"Add Annotations First",message:`To provide feedback, select text in the plan and add annotations. ${fg} will use your annotations to revise the plan.`,variant:"info"}),w.jsx(nQ,{isOpen:Q,onClose:()=>f(!1),onConfirm:()=>{f(!1),Xt()},title:"Annotations Won't Be Sent",message:w.jsxs(w.Fragment,{children:[fg," doesn't yet support feedback on approval. Your ",Ht.length," annotation",Ht.length!==1?"s":""," will be lost."]}),subMessage:w.jsxs(w.Fragment,{children:["To send feedback, use ",w.jsx("strong",{children:"Send Feedback"})," instead.",w.jsx("br",{}),w.jsx("br",{}),"Want this feature? Upvote these issues:",w.jsx("br",{}),w.jsx("a",{href:"https://github.com/anthropics/claude-code/issues/16001",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"#16001"})," · ",w.jsx("a",{href:"https://github.com/anthropics/claude-code/issues/15755",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"#15755"})]}),confirmText:"Approve Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),w.jsx(nQ,{isOpen:m,onClose:()=>y(!1),onConfirm:()=>{y(!1),Xt()},title:"Agent Not Found",message:v,subMessage:w.jsxs(w.Fragment,{children:["You can change the agent in ",w.jsx("strong",{children:"Settings"}),", or approve anyway and OpenCode will use the default agent."]}),confirmText:"Approve Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),w.jsx(nQ,{isOpen:!!Un&&!G,onClose:an,title:"Shared Plan Could Not Be Loaded",message:Un,subMessage:"You are viewing a demo plan. This is sample content — it is not your data or anyone else's.",variant:"warning"}),wA&&w.jsx("div",{className:`fixed top-16 right-4 z-50 px-3 py-2 rounded-lg text-xs font-medium shadow-lg transition-opacity ${wA.type==="success"?"bg-success/15 text-success border border-success/30":"bg-destructive/15 text-destructive border border-destructive/30"}`,children:wA.message}),w.jsx(p4A,{submitted:tA,title:rt.archiveMode?"Archive Closed":tA==="approved"?"Plan Approved":hA?"Annotations Sent":"Feedback Sent",subtitle:rt.archiveMode?"You can reopen with plannotator archive.":tA==="approved"?`${fg} will proceed with the implementation.`:hA?`${fg} will address your annotations on the ${oA==="message"?"message":oA==="folder"?"files":"file"}.`:`${fg} will revise the plan based on your annotations.`,agentLabel:fg}),w.jsx(S4A,{origin:z,isWSL:AA}),w.jsx(neA,{isOpen:!!RA,imageSrc:RA?.blobUrl??"",initialName:RA?.initialName,onAccept:Pt,onClose:ti}),w.jsx(V4A,{isOpen:Ie,onComplete:XA=>{ie(XA),Qe(!1)}})]})})},IgA=document.getElementById("root");if(!IgA)throw new Error("Could not find root element to mount to");const KKA=dfA.createRoot(IgA);KKA.render(w.jsx(cn.StrictMode,{children:w.jsx(UKA,{})}));class ls{constructor(A,t,i){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=A,this.start=t,this.end=i}static range(A,t){return t?!A||!A.loc||!t.loc||A.loc.lexer!==t.loc.lexer?null:new ls(A.loc.lexer,A.loc.start,t.loc.end):A&&A.loc}}class Hs{constructor(A,t){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=A,this.loc=t}range(A,t){return new Hs(t,ls.range(this,A))}}class je{constructor(A,t){this.name=void 0,this.position=void 0,this.length=void 0,this.rawMessage=void 0;var i="KaTeX parse error: "+A,r,n,a=t&&t.loc;if(a&&a.start<=a.end){var s=a.lexer.input;r=a.start,n=a.end,r===s.length?i+=" at end of input: ":i+=" at position "+(r+1)+": ";var o=s.slice(r,n).replace(/[^]/g,"$&̲"),g;r>15?g="…"+s.slice(r-15,r):g=s.slice(0,r);var l;n+15<s.length?l=s.slice(n,n+15)+"…":l=s.slice(n),i+=g+o+l}var I=new Error(i);return I.name="ParseError",I.__proto__=je.prototype,I.position=r,r!=null&&n!=null&&(I.length=n-r),I.rawMessage=A,I}}je.prototype.__proto__=Error.prototype;var YKA=function(A,t){return A===void 0?t:A},HKA=/([A-Z])/g,PKA=function(A){return A.replace(HKA,"-$1").toLowerCase()},JKA={"&":"&",">":">","<":"<",'"':""","'":"'"},zKA=/[&><"']/g;function qKA(e){return String(e).replace(zKA,A=>JKA[A])}var CgA=function e(A){return A.type==="ordgroup"||A.type==="color"?A.body.length===1?e(A.body[0]):A:A.type==="font"?e(A.body):A},WKA=function(A){var t=CgA(A);return t.type==="mathord"||t.type==="textord"||t.type==="atom"},VKA=function(A){if(!A)throw new Error("Expected non-null, but got "+String(A));return A},ZKA=function(A){var t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(A);return t?t[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():"_relative"},Oi={deflt:YKA,escape:qKA,hyphenate:PKA,getBaseElem:CgA,isCharacterBox:WKA,protocolFromUrl:ZKA},kf={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format <type>"},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color <color>",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:e=>"#"+e},macros:{type:"object",cli:"-m, --macro <def>",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(e,A)=>(A.push(e),A)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:"--min-rule-thickness <size>",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:e=>Math.max(0,e),cli:"-s, --max-size <n>",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:e=>Math.max(0,e),cli:"-e, --max-expand <n>",cliProcessor:e=>e==="Infinity"?1/0:parseInt(e)},globalGroup:{type:"boolean",cli:!1}};function jKA(e){if(e.default)return e.default;var A=e.type,t=Array.isArray(A)?A[0]:A;if(typeof t!="string")return t.enum[0];switch(t){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{}}}class v4{constructor(A){this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,A=A||{};for(var t in kf)if(kf.hasOwnProperty(t)){var i=kf[t];this[t]=A[t]!==void 0?i.processor?i.processor(A[t]):A[t]:jKA(i)}}reportNonstrict(A,t,i){var r=this.strict;if(typeof r=="function"&&(r=r(A,t,i)),!(!r||r==="ignore")){if(r===!0||r==="error")throw new je("LaTeX-incompatible input and strict mode is set to 'error': "+(t+" ["+A+"]"),i);r==="warn"?typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(t+" ["+A+"]")):typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+r+"': "+t+" ["+A+"]"))}}useStrictBehavior(A,t,i){var r=this.strict;if(typeof r=="function")try{r=r(A,t,i)}catch{r="error"}return!r||r==="ignore"?!1:r===!0||r==="error"?!0:r==="warn"?(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(t+" ["+A+"]")),!1):(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+r+"': "+t+" ["+A+"]")),!1)}isTrusted(A){if(A.url&&!A.protocol){var t=Oi.protocolFromUrl(A.url);if(t==null)return!1;A.protocol=t}var i=typeof this.trust=="function"?this.trust(A):this.trust;return!!i}}class Xc{constructor(A,t,i){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=A,this.size=t,this.cramped=i}sup(){return Fg[_KA[this.id]]}sub(){return Fg[XKA[this.id]]}fracNum(){return Fg[$KA[this.id]]}fracDen(){return Fg[A5A[this.id]]}cramp(){return Fg[e5A[this.id]]}text(){return Fg[t5A[this.id]]}isTight(){return this.size>=2}}var S4=0,Qv=1,xB=2,ec=3,l0=4,mo=5,sd=6,Ha=7,Fg=[new Xc(S4,0,!1),new Xc(Qv,0,!0),new Xc(xB,1,!1),new Xc(ec,1,!0),new Xc(l0,2,!1),new Xc(mo,2,!0),new Xc(sd,3,!1),new Xc(Ha,3,!0)],_KA=[l0,mo,l0,mo,sd,Ha,sd,Ha],XKA=[mo,mo,mo,mo,Ha,Ha,Ha,Ha],$KA=[xB,ec,l0,mo,sd,Ha,sd,Ha],A5A=[ec,ec,mo,mo,Ha,Ha,Ha,Ha],e5A=[Qv,Qv,ec,ec,mo,mo,Ha,Ha],t5A=[S4,Qv,xB,ec,xB,ec,xB,ec],Kt={DISPLAY:Fg[S4],TEXT:Fg[xB],SCRIPT:Fg[l0],SCRIPTSCRIPT:Fg[sd]},n3=[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}];function i5A(e){for(var A=0;A<n3.length;A++)for(var t=n3[A],i=0;i<t.blocks.length;i++){var r=t.blocks[i];if(e>=r[0]&&e<=r[1])return t.name}return null}var RD=[];n3.forEach(e=>e.blocks.forEach(A=>RD.push(...A)));function EgA(e){for(var A=0;A<RD.length;A+=2)if(e>=RD[A]&&e<=RD[A+1])return!0;return!1}var Zu=80,r5A=function(A,t){return"M95,"+(622+A+t)+`
|
|
848
|
+
`;function OKA({blocks:e,annotations:A,addAnnotation:t,removeAnnotation:i}){const[r,n]=aA.useState(new Map),a=aA.useRef(e);a.current=e;const s=aA.useRef(A);s.current=A,aA.useEffect(()=>{if(r.size===0)return;const l=new Set(e.map(C=>C.id)),I=[...r.keys()].filter(C=>!l.has(C));I.length>0&&n(C=>{const E=new Map(C);return I.forEach(B=>E.delete(B)),E})},[e]);const o=aA.useCallback((l,I)=>{const C=a.current,E=s.current,B=C.find(Q=>Q.id===l);if(B&&I===B.checked)n(f=>{const m=new Map(f);return m.delete(l),m}),E.filter(f=>f.blockId===l&&f.id.startsWith("ann-checkbox-")).forEach(f=>i(f.id));else if(E.filter(f=>f.blockId===l&&f.id.startsWith("ann-checkbox-")).forEach(f=>i(f.id)),n(f=>{const m=new Map(f);return m.set(l,I),m}),B){const f=C.indexOf(B);let m="";for(let x=f-1;x>=0;x--)if(C[x].type==="heading"){m=C[x].content;break}const y=I?"Mark as completed":"Mark as not completed",v=m?` (under "${m}")`:` (line ${B.startLine})`,S={id:`ann-checkbox-${l}-${Date.now()}`,blockId:l,startOffset:0,endOffset:B.content.length,type:gi.COMMENT,text:`${y}${v}: ${B.content}`,originalText:B.content,createdA:Date.now()};t(S)}},[t,i]),g=aA.useCallback(l=>{n(I=>{const C=new Map(I);return C.delete(l),C})},[]);return{overrides:r,toggle:o,revertOverride:g}}const UKA=()=>{const[e,A]=aA.useState(GKA),[t,i]=aA.useState([]),[r,n]=aA.useState(null),[a,s]=aA.useState([]),[o,g]=aA.useState(null),[l,I]=aA.useState(!1),[C,E]=aA.useState(!1),[B,h]=aA.useState(!1),[Q,f]=aA.useState(!1),[m,y]=aA.useState(!1),[v,S]=aA.useState(""),[x,R]=aA.useState(()=>window.innerWidth>=768),[b,N]=aA.useState(!1),[T,L]=aA.useState(R4A),[K,H]=aA.useState(k4A),[k,U]=aA.useState(()=>ze.getItem("plannotator-tater-mode")==="true"),[O,F]=aA.useState(()=>t3()),[G,P]=aA.useState(!1),[z,Y]=aA.useState(null),[V,j]=aA.useState(),[AA,X]=aA.useState(!1),[gA,nA]=aA.useState([]),[hA,rA]=aA.useState(!1),[oA,lA]=aA.useState(null),[sA,uA]=aA.useState(void 0),[CA,xA]=aA.useState(!0),[BA,VA]=aA.useState(!1),[tA,ne]=aA.useState(null),[RA,ce]=aA.useState(null),[Ie,Qe]=aA.useState(!1),[OA,ie]=aA.useState("bypassPermissions"),[YA,ZA]=aA.useState(!0),[ae,NA]=aA.useState(void 0),[$A,EA]=aA.useState(void 0),[vA,Z]=aA.useState(null),[mA,pA]=aA.useState(null);aA.useEffect(()=>{document.title=vA?`${vA.display} · Plannotator`:"Plannotator"},[vA]);const[kA,MA]=aA.useState(!1),[TA,dA]=aA.useState(),[wA,PA]=aA.useState(null),[_A,Ee]=aA.useState(!1),[yA,UA]=aA.useState("clean"),[KA,te]=aA.useState(null),[Ge,Se]=aA.useState(null),eA=aA.useRef(null),le=aA.useRef(null);G4A();const se=hW({storageKey:"plannotator-panel-width"}),ve=hW({storageKey:"plannotator-toc-width",defaultWidth:240,minWidth:160,maxWidth:400,side:"left"}),Me=se.isDragging||ve.isDragging,ke=Z4A(t3().tocEnabled);aA.useEffect(()=>{O.tocEnabled?ke.open("toc"):ke.close()},[O.tocEnabled]),aA.useEffect(()=>{ke.activeTab==="toc"&&_A&&Ee(!1)},[ke.activeTab]),aA.useEffect(()=>{if(!_A)return;const XA=Ke=>{Ke.key==="Escape"&&Ee(!1)};return document.addEventListener("keydown",XA),()=>document.removeEventListener("keydown",XA)},[_A]);const Re=tKA(e,KA,Ge),we=iKA({markdown:e,annotations:t,selectedAnnotationId:r,globalAttachments:gA,setMarkdown:A,setAnnotations:i,setSelectedAnnotationId:n,setGlobalAttachments:nA,viewerRef:eA,sidebar:ke}),rt=gKA({markdown:e,viewerRef:eA,linkedDocHook:we,setMarkdown:A,setAnnotations:i,setSelectedAnnotationId:n,setSubmitted:ne}),We=rKA(),It=aA.useMemo(()=>nUA(),[O]),Et=aA.useMemo(()=>{if(!It)return"";const XA=cI();return II(XA)},[It,O]);aA.useEffect(()=>{It||We.setActiveFile(null)},[It]),aA.useEffect(()=>{ke.activeTab==="vault"&&It&&Et&&We.tree.length===0&&!We.isLoading&&We.fetchTree(Et)},[ke.activeTab,It,Et]);const Gt=cn.useCallback(XA=>Ke=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(XA)}&path=${encodeURIComponent(Ke)}`,[]),Dt=cn.useCallback(XA=>{we.open(XA,Gt(Et)),We.setActiveFile(XA)},[Et,we,We,Gt]),pt=uKA(),ci=aA.useMemo(()=>!!mA||gW(),[mA,O]),Ye=aA.useMemo(()=>{const XA=mA?[mA]:[],Ke=gW()?D4().directories:[];return[...new Set([...XA,...Ke])]},[mA,O]);aA.useEffect(()=>{ci||pt.setActiveFile(null)},[ci]),aA.useEffect(()=>{if(ke.activeTab==="files"&&ci&&Ye.length>0){const XA=pt.dirs.map(At=>At.path);(Ye.length!==XA.length||Ye.some(At=>!XA.includes(At)))&&pt.fetchAll(Ye)}},[ke.activeTab,ci,Ye]);const zA=cn.useCallback((XA,Ke)=>{const At=mt=>`/api/doc?path=${encodeURIComponent(mt)}&base=${encodeURIComponent(Ke)}`;we.open(XA,At,"files"),pt.setActiveFile(XA),We.setActiveFile(null)},[we,pt]),be=cn.useCallback(XA=>{if(We.activeFile&&Et)we.open(XA,Gt(Et));else if(pt.activeFile&&pt.activeDirPath){const Ke=we.filepath?.replace(/\/[^/]+$/,"")||pt.activeDirPath;we.open(XA,At=>`/api/doc?path=${encodeURIComponent(At)}&base=${encodeURIComponent(Ke)}`)}else{const Ke=we.filepath?we.filepath.replace(/\/[^/]+$/,""):sA;Ke?we.open(XA,At=>`/api/doc?path=${encodeURIComponent(At)}&base=${encodeURIComponent(Ke)}`):we.open(XA)}},[We.activeFile,Et,pt.activeFile,pt.activeDirPath,we,Gt,sA]),_e=cn.useCallback(()=>{we.back(),We.setActiveFile(null),pt.setActiveFile(null),rt.clearSelection()},[we,We,pt,rt]),Rt=aA.useMemo(()=>{const XA=new Map;for(const[Ke,At]of we.getDocAnnotations()){const mt=At.annotations.length+At.globalAttachments.length;mt>0&&XA.set(Ke,mt)}return XA},[we.getDocAnnotations,t,gA]),ai=aA.useMemo(()=>{if(Ye.length===0)return Rt;const XA=new Map;for(const[Ke,At]of Rt)Ye.some(mt=>Ke.startsWith(mt+"/"))&&XA.set(Ke,At);return XA},[Rt,Ye]),Ct=aA.useMemo(()=>{if(!Et)return new Map;const XA=Et.endsWith("/")?Et:Et+"/",Ke=new Map;for(const[At,mt]of Rt)At.startsWith(XA)&&Ke.set(At.slice(XA.length),mt);return Ke},[Rt,Et]),Ii=ai.size>0,Li=Ct.size>0,fi=aA.useMemo(()=>{const XA=we.filepath;let Ke=0,At=0;for(const[mt,Si]of Rt)mt!==XA&&(Ke+=Si,At++);return Ke>0?{count:Ke,files:At}:void 0},[Rt,we.filepath]),[Le,ye]=aA.useState(),Te=cn.useRef(),Ne=cn.useCallback(()=>{const XA=new Set(Rt.keys());XA.size!==0&&((!ke.isOpen||ke.activeTab!=="files"&&ke.activeTab!=="vault")&&ke.open(Li&&!Ii?"vault":"files"),Te.current&&clearTimeout(Te.current),ye(void 0),requestAnimationFrame(()=>{ye(XA),Te.current=setTimeout(()=>ye(void 0),1200)}))},[Rt,ke,Li,Ii]),me=aA.useMemo(()=>{if(!Le||!Et)return;const XA=Et.endsWith("/")?Et:Et+"/",Ke=new Set;for(const At of Le)At.startsWith(XA)&&Ke.add(At.slice(XA.length));return Ke.size>0?Ke:void 0},[Le,Et]),ot=oA==="folder"?"file list":oA==="file"?"file":oA==="message"?"message":"plan",LA=cn.useCallback(()=>{We.fetchTree(Et)},[We,Et]),er=aA.useMemo(()=>a.filter(XA=>XA.type==="heading").length,[a]),FA=d4A(le,er),{editorAnnotations:wt,deleteEditorAnnotation:es}=cKA(),{externalAnnotations:nn,updateExternalAnnotation:Ma,deleteExternalAnnotation:vs}=EKA({enabled:G}),Ht=aA.useMemo(()=>nn.length===0?t:[...t.filter(Ke=>Ke.source?!nn.some(At=>At.source===Ke.source&&At.type===Ke.type&&At.originalText===Ke.originalText):!0),...nn],[t,nn]),ar=aA.useMemo(()=>Ht.filter(XA=>!!XA.diffContext),[Ht]),ts=aA.useMemo(()=>Ht.filter(XA=>!XA.diffContext),[Ht]),{isSharedSession:Or,isLoadingShared:Ea,shareUrl:wi,shareUrlSize:Ss,shortShareUrl:sr,isGeneratingShortUrl:dt,shortUrlError:kt,pendingSharedAnnotations:vi,clearPendingSharedAnnotations:Ai,generateShortUrl:Wr,importFromShareUrl:or,shareLoadError:Un,clearShareLoadError:an}=E4A(e,Ht,gA,A,i,nA,()=>{xA(!1)},ae,$A),{draftBanner:qe,restoreDraft:q,dismissDraft:_}=oKA({annotations:Ht,globalAttachments:gA,isApiMode:G,isSharedSession:Or,submitted:!!tA}),IA=cn.useCallback(()=>{const{annotations:XA,globalAttachments:Ke}=q();XA.length>0&&(i(XA),Ke.length>0&&nA(Ke),setTimeout(()=>{eA.current?.applySharedAnnotations(XA.filter(At=>!At.diffContext))},100))},[q]),{getAgentWarning:DA}=qoA(z);aA.useEffect(()=>{if(vi&&vi.length>0){const XA=setTimeout(()=>{eA.current?.clearAllHighlights(),eA.current?.applySharedAnnotations(vi.filter(Ke=>!Ke.diffContext)),Ai()},100);return()=>clearTimeout(XA)}},[vi,Ai]);const GA=XA=>{U(XA),ze.setItem("plannotator-tater-mode",String(XA))},jA=XA=>{L(XA),N4A(XA)},ge=XA=>{H(XA),x4A(XA)};F4A(K,ge),aA.useEffect(()=>{Ea||Or||fetch("/api/plan").then(XA=>{if(!XA.ok)throw new Error("Not in API mode");return XA.json()}).then(XA=>{pa.init(XA.serverConfig),j(XA.serverConfig?.gitUser),XA.mode==="archive"?(A(XA.plan||""),XA.archivePlans&&rt.init(XA.archivePlans),rt.fetchPlans(),ZA(!1),ke.open("archive")):XA.mode==="annotate-folder"?A(""):XA.plan&&A(XA.plan),P(!0),(XA.mode==="annotate"||XA.mode==="annotate-last"||XA.mode==="annotate-folder")&&rA(!0),XA.mode==="annotate-folder"&&ke.open("files"),XA.mode&&XA.mode!=="archive"&&lA(XA.mode==="annotate-last"?"message":XA.mode==="annotate-folder"?"folder":"file"),XA.filePath&&uA(XA.mode==="annotate-folder"?XA.filePath:XA.filePath.replace(/\/[^/]+$/,"")),XA.sharingEnabled!==void 0&&ZA(XA.sharingEnabled),XA.shareBaseUrl&&NA(XA.shareBaseUrl),XA.pasteApiUrl&&EA(XA.pasteApiUrl),XA.repoInfo&&Z(XA.repoInfo),XA.projectRoot&&pA(XA.projectRoot),XA.previousPlan!==void 0&&te(XA.previousPlan),XA.versionInfo&&Se(XA.versionInfo),XA.origin&&(Y(XA.origin),XA.origin==="claude-code"&&xUA()&&Qe(!0),ie(HoA().mode)),XA.isWSL&&X(!0)}).catch(()=>{P(!1)}).finally(()=>xA(!1))},[Ea,Or]),aA.useEffect(()=>{const{frontmatter:XA}=qAA(e);g(XA),s(WAA(e))},[e]);const fe=aA.useRef(!1),Xe=aA.useRef({}),Ot=aA.useRef(null);aA.useEffect(()=>{fe.current=!1,Xe.current={},Ot.current=null},[e]),aA.useEffect(()=>{if(!G||!e||Or||hA||rt.archiveMode||fe.current)return;const XA={},Ke=[],At=cI();if(At.autoSave&&At.enabled){const Ir=II(At);Ir&&(XA.obsidian={vaultPath:Ir,folder:At.folder||"plannotator",plan:e,...At.filenameFormat&&{filenameFormat:At.filenameFormat},...At.filenameSeparator&&At.filenameSeparator!=="space"&&{filenameSeparator:At.filenameSeparator}},Ke.push("Obsidian"))}const mt=rI();mt.autoSave&&mt.enabled&&(XA.bear={plan:e,customTags:mt.customTags,tagPosition:mt.tagPosition},Ke.push("Bear"));const Si=MB();if(Si.autoSave&&rQ()&&(XA.octarine={plan:e,workspace:Si.workspace,folder:Si.folder||"plannotator"},Ke.push("Octarine")),Ke.length===0)return;fe.current=!0;const wr=fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(XA)}).then(Ir=>Ir.json()).then(Ir=>{const Fo={...XA.obsidian?{obsidian:!!Ir.results?.obsidian?.success}:{},...XA.bear?{bear:!!Ir.results?.bear?.success}:{},...XA.octarine?{octarine:!!Ir.results?.octarine?.success}:{}};Xe.current=Fo;const Cl=Ke.filter(jd=>!Ir.results?.[jd.toLowerCase()]?.success);return Cl.length===0?PA({type:"success",message:`Auto-saved to ${Ke.join(" & ")}`}):PA({type:"error",message:`Auto-save failed for ${Cl.join(" & ")}`}),Fo}).catch(()=>(Xe.current={},PA({type:"error",message:"Auto-save failed"}),{})).finally(()=>setTimeout(()=>PA(null),3e3));Ot.current=wr},[G,e,Or,hA]),aA.useEffect(()=>{const XA=Ke=>{const At=Ke.clipboardData?.items;if(At){for(const mt of At)if(mt.type.startsWith("image/")){Ke.preventDefault();const Si=mt.getAsFile();if(Si){const wr=JF(Si.name,gA.map(Fo=>Fo.name)),Ir=URL.createObjectURL(Si);ce({file:Si,blobUrl:Ir,initialName:wr})}break}}};return document.addEventListener("paste",XA),()=>document.removeEventListener("paste",XA)},[gA]);const Pt=async(XA,Ke,At)=>{if(RA)try{const mt=new FormData,Si=Ke?new File([XA],"annotated.png",{type:"image/png"}):RA.file;mt.append("file",Si);const wr=await fetch("/api/upload",{method:"POST",body:mt});if(wr.ok){const Ir=await wr.json();nA(Fo=>[...Fo,{path:Ir.path,name:At}])}}catch{}finally{URL.revokeObjectURL(RA.blobUrl),ce(null)}},ti=()=>{RA&&(URL.revokeObjectURL(RA.blobUrl),ce(null))},Xt=async()=>{VA(!0);try{const XA=cI(),Ke=rI(),At=MB(),mt=m4(),Si=Bv(),wr=Ke.autoSave&&Ot.current?await Ot.current:Xe.current,Ir={};z==="claude-code"&&(Ir.permissionMode=OA);const Fo=RUA(mt);Fo&&(Ir.agentSwitch=Fo),Ir.planSave={enabled:Si.enabled,...Si.customPath&&{customPath:Si.customPath}};const Cl=II(XA);XA.enabled&&Cl&&(Ir.obsidian={vaultPath:Cl,folder:XA.folder||"plannotator",plan:e,...XA.filenameFormat&&{filenameFormat:XA.filenameFormat},...XA.filenameSeparator&&XA.filenameSeparator!=="space"&&{filenameSeparator:XA.filenameSeparator}}),Ke.enabled&&!(Ke.autoSave&&wr.bear)&&(Ir.bear={plan:e,customTags:Ke.customTags,tagPosition:Ke.tagPosition}),rQ()&&(Ir.octarine={plan:e,workspace:At.workspace,folder:At.folder||"plannotator"});const jd=Array.from(we.getDocAnnotations().values()).some(xp=>xp.annotations.length>0||xp.globalAttachments.length>0);(Ht.length>0||gA.length>0||jd||wt.length>0)&&(Ir.feedback=bs),await fetch("/api/approve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ir)}),ne("approved")}catch{VA(!1)}},vt=async()=>{VA(!0);try{const XA=Bv();await fetch("/api/deny",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:bs,planSave:{enabled:XA.enabled,...XA.customPath&&{customPath:XA.customPath}}})}),ne("denied")}catch{VA(!1)}},Tt=async()=>{VA(!0);try{await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:bs,annotations:Ht})}),ne("denied")}catch{VA(!1)}};aA.useEffect(()=>{const XA=Ke=>{if(Ke.key!=="Enter"||!(Ke.metaKey||Ke.ctrlKey))return;const At=Ke.target?.tagName;if(At==="INPUT"||At==="TEXTAREA"||l||C||B||Q||m||Ie||RA||tA||BA||!G||we.isActive)return;if(Ke.preventDefault(),hA){Tt();return}const mt=we.getDocAnnotations(),Si=Array.from(mt.values()).some(wr=>wr.annotations.length>0||wr.globalAttachments.length>0);if(Ht.length===0&&wt.length===0&&!Si){if(z==="opencode"){const wr=DA();if(wr){S(wr),y(!0);return}}Xt()}else vt()};return window.addEventListener("keydown",XA),()=>window.removeEventListener("keydown",XA)},[l,C,B,Q,m,Ie,RA,tA,BA,G,we.isActive,t.length,nn.length,hA,z,DA]);const Hi=XA=>{i(Ke=>[...Ke,XA]),n(XA.id),R(!0)},pn=cn.useCallback(XA=>{n(XA),XA&&window.innerWidth<768&&R(!0)},[]),mn=XA=>{eA.current?.removeHighlight(XA),i(Ke=>Ke.filter(At=>At.id!==XA)),r===XA&&n(null)},Pi=OKA({blocks:a,annotations:t,addAnnotation:Hi,removeAnnotation:mn}),Vr=XA=>{const Ke=Ht.find(At=>At.id===XA);if(Ke?.source&&nn.some(At=>At.id===XA)){vs(XA),r===XA&&n(null);return}XA.startsWith("ann-checkbox-")&&Ke&&Pi.revertOverride(Ke.blockId),mn(XA)},Ao=(XA,Ke)=>{if(Ht.find(mt=>mt.id===XA)?.source&&nn.some(mt=>mt.id===XA)){Ma(XA,Ke);return}i(mt=>mt.map(Si=>Si.id===XA?{...Si,...Ke}:Si))},Kn=(XA,Ke)=>{i(At=>At.map(mt=>mt.author===XA?{...mt,author:Ke}:mt))},hg=XA=>{nA(Ke=>[...Ke,XA])},kr=XA=>{nA(Ke=>Ke.filter(At=>At.path!==XA))},Wd=XA=>{},bs=aA.useMemo(()=>{const XA=we.getDocAnnotations(),Ke=Array.from(XA.values()).some(wr=>wr.annotations.length>0||wr.globalAttachments.length>0),At=Ht.length>0||gA.length>0,mt=wt.length>0;if(!At&&!Ke&&!mt)return"User reviewed the document and has no feedback.";let Si=At?pfA(a,Ht,gA,oA==="message"?"Message Feedback":oA==="folder"?"Folder Feedback":oA==="file"?"File Feedback":"Plan Feedback",oA??"plan"):"";return Ke&&(Si+=mfA(XA)),mt&&(Si+=yfA(wt)),Si},[a,Ht,gA,we.getDocAnnotations,wt]),Il=cn.useMemo(()=>u4A(),[]),CC=cn.useCallback(async XA=>{if(!(!Il||BA||!wi)){VA(!0);try{const Ke=await B4A(XA,Il,wi);Ke&&(PA(Ke),setTimeout(()=>PA(null),4e3),Ke.type==="success"&&ne(XA===bD.Approve?"approved":"denied"))}finally{VA(!1)}}},[Il,BA,wi]),Nb=cn.useCallback(()=>CC(bD.Approve),[CC]),Mb=cn.useCallback(()=>CC(bD.Feedback),[CC]),Vd=()=>{MA(!1);const XA=new Blob([bs],{type:"text/plain"}),Ke=URL.createObjectURL(XA),At=document.createElement("a");At.href=Ke,At.download="annotations.md",At.click(),URL.revokeObjectURL(Ke),PA({type:"success",message:"Downloaded annotations"}),setTimeout(()=>PA(null),3e3)},Qg=async XA=>{MA(!1);const Ke={};if(XA==="obsidian"){const mt=cI(),Si=II(mt);Si&&(Ke.obsidian={vaultPath:Si,folder:mt.folder||"plannotator",plan:e,...mt.filenameFormat&&{filenameFormat:mt.filenameFormat},...mt.filenameSeparator&&mt.filenameSeparator!=="space"&&{filenameSeparator:mt.filenameSeparator}})}if(XA==="bear"){const mt=rI();Ke.bear={plan:e,customTags:mt.customTags,tagPosition:mt.tagPosition}}if(XA==="octarine"){const mt=MB();Ke.octarine={plan:e,workspace:mt.workspace,folder:mt.folder||"plannotator"}}const At=XA==="obsidian"?"Obsidian":XA==="bear"?"Bear":"Octarine";try{const wr=(await(await fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ke)})).json()).results?.[XA];wr?.success?PA({type:"success",message:`Saved to ${At}`}):PA({type:"error",message:wr?.error||"Save failed"})}catch{PA({type:"error",message:"Save failed"})}setTimeout(()=>PA(null),3e3)};aA.useEffect(()=>{const XA=Ke=>{if(Ke.key!=="s"||!(Ke.metaKey||Ke.ctrlKey))return;const At=Ke.target?.tagName;if(At==="INPUT"||At==="TEXTAREA"||l||B||Q||m||Ie||RA||tA||!G)return;Ke.preventDefault();const mt=zoA(),Si=X2(),wr=rI().enabled,Ir=rQ();mt==="download"?Vd():mt==="obsidian"&&Si?Qg("obsidian"):mt==="bear"&&wr?Qg("bear"):mt==="octarine"&&Ir?Qg("octarine"):(dA("notes"),I(!0))};return window.addEventListener("keydown",XA),()=>window.removeEventListener("keydown",XA)},[l,B,Q,m,Ie,RA,tA,G,e,bs]),aA.useEffect(()=>{const XA=Ke=>{if(Ke.key!=="p"||!(Ke.metaKey||Ke.ctrlKey))return;const At=Ke.target?.tagName;At==="INPUT"||At==="TEXTAREA"||l||B||Q||m||Ie||RA||tA||(Ke.preventDefault(),window.print())};return window.addEventListener("keydown",XA),()=>window.removeEventListener("keydown",XA)},[l,B,Q,m,Ie,RA,tA]),aA.useEffect(()=>{if(!kA)return;const XA=Ke=>{Ke.target.closest("[data-export-dropdown]")||MA(!1)};return document.addEventListener("pointerdown",XA),()=>document.removeEventListener("pointerdown",XA)},[kA]);const fg=aA.useMemo(()=>hfA(z),[z]),Zd=aA.useMemo(()=>({compact:832,default:1040,wide:1280})[O.planWidth]??832,[O.planWidth]);return w.jsx(cUA,{defaultTheme:"dark",children:w.jsxs("div",{"data-print-region":"root",className:"h-screen flex flex-col bg-background overflow-hidden",children:[w.jsxs("header",{className:"h-12 flex items-center justify-between px-2 md:px-4 border-b border-border/50 bg-card/50 backdrop-blur-xl sticky top-0 z-[50]",children:[w.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[w.jsx("a",{href:"https://plannotator.ai",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 md:gap-2 hover:opacity-80 transition-opacity",children:w.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Plannotator"})}),w.jsxs("a",{href:"https://github.com/backnotprop/plannotator/releases",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground font-mono opacity-60 hidden md:inline hover:opacity-100 transition-opacity",children:["v","0.17.1"]}),z&&w.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium hidden md:inline ${QfA(z)}`,children:fg})]}),w.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[Il&&!G&&Or&&w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"}),w.jsx(cW,{onClick:Mb,disabled:BA||!wi,isLoading:BA,title:"Send feedback to bot"}),w.jsx(IW,{onClick:Nb,disabled:BA||!wi,isLoading:BA,title:"Approve design and notify bot"})]}),G&&!we.isActive&&rt.archiveMode&&w.jsxs(w.Fragment,{children:[w.jsxs("button",{onClick:rt.copy,className:"px-2.5 py-1 rounded-md text-xs font-medium transition-all bg-muted text-foreground hover:bg-muted/80 border border-border",title:"Copy plan content",children:[w.jsx("span",{className:"hidden md:inline",children:"Copy"}),w.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})]}),w.jsx("button",{onClick:rt.done,className:"px-2.5 py-1 rounded-md text-xs font-medium transition-all bg-success text-success-foreground hover:opacity-90",title:"Close archive",children:"Done"})]}),G&&!we.isActive&&!rt.archiveMode&&w.jsxs(w.Fragment,{children:[w.jsx(cW,{onClick:()=>{if(hA){Tt();return}const XA=we.getDocAnnotations(),Ke=Array.from(XA.values()).some(At=>At.annotations.length>0||At.globalAttachments.length>0);Ht.length===0&&wt.length===0&&!Ke?h(!0):vt()},disabled:BA,isLoading:BA,label:hA?Ht.length>0||wt.length>0||we.docAnnotationCount>0?"Send Annotations":"Done":"Send Feedback",title:hA?Ht.length>0||wt.length>0||we.docAnnotationCount>0?"Send Annotations":"Done":"Send Feedback"}),!hA&&w.jsxs("div",{className:"relative group/approve",children:[w.jsx(IW,{onClick:()=>{if(z==="claude-code"&&Ht.length>0){f(!0);return}if(z==="opencode"){const XA=DA();if(XA){S(XA),y(!0);return}}Xt()},disabled:BA,isLoading:BA,dimmed:(z==="claude-code"||z==="gemini-cli")&&Ht.length>0}),(z==="claude-code"||z==="gemini-cli")&&Ht.length>0&&w.jsxs("div",{className:"absolute top-full right-0 mt-2 px-3 py-2 bg-popover border border-border rounded-lg shadow-xl text-xs text-foreground w-56 text-center opacity-0 invisible group-hover/approve:opacity-100 group-hover/approve:visible transition-all pointer-events-none z-50",children:[w.jsx("div",{className:"absolute bottom-full right-4 border-4 border-transparent border-b-border"}),w.jsx("div",{className:"absolute bottom-full right-4 mt-px border-4 border-transparent border-b-popover"}),fg," doesn't support feedback on approval. Your annotations won't be seen."]})]}),w.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"})]}),w.jsxs("div",{className:"hidden md:flex items-center gap-2",children:[w.jsx(IUA,{}),!we.isActive&&w.jsx(s4A,{taterMode:k,onTaterModeChange:GA,onIdentityChange:Kn,origin:z,onUIPreferencesChange:F,externalOpen:b,onExternalClose:()=>N(!1),gitUser:V}),w.jsx("button",{onClick:()=>R(!x),className:`p-1.5 rounded-md text-xs font-medium transition-all ${x?"bg-primary/15 text-primary":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})}),w.jsxs("div",{className:"relative flex","data-export-dropdown":!0,children:[w.jsx("button",{onClick:()=>{dA(void 0),I(!0)},className:"px-2.5 py-1 rounded-l-md text-xs font-medium bg-muted hover:bg-muted/80 transition-colors",title:"Export",children:"Export"}),w.jsx("button",{onClick:()=>MA(XA=>!XA),className:"px-1.5 rounded-r-md text-xs bg-muted hover:bg-muted/80 border-l border-border/50 transition-colors flex items-center",title:"Quick save options",children:w.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}),kA&&w.jsxs("div",{className:"absolute top-full right-0 mt-1 w-48 bg-popover border border-border rounded-lg shadow-xl z-50 py-1",children:[YA&&w.jsxs("button",{onClick:async()=>{MA(!1);try{await navigator.clipboard.writeText(wi),PA({type:"success",message:"Share link copied"})}catch{PA({type:"error",message:"Failed to copy"})}setTimeout(()=>PA(null),3e3)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),"Copy Share Link"]}),w.jsxs("button",{onClick:Vd,className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),"Download Annotations"]}),w.jsxs("button",{onClick:()=>{MA(!1),window.print()},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"})}),"Print Plan",w.jsxs("span",{className:"ml-auto text-[10px] text-muted-foreground/60",children:[cs,"+P"]})]}),w.jsx("div",{className:"my-1 border-t border-border"}),G&&X2()&&w.jsxs("button",{onClick:()=>Qg("obsidian"),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),"Save to Obsidian"]}),G&&rI().enabled&&w.jsxs("button",{onClick:()=>Qg("bear"),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),"Save to Bear"]}),G&&rQ()&&w.jsxs("button",{onClick:()=>Qg("octarine"),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),"Save to Octarine"]}),G&&!X2()&&!rI().enabled&&!rQ()&&w.jsx("div",{className:"px-3 py-2 text-[10px] text-muted-foreground",children:"No notes apps configured."}),YA&&w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"my-1 border-t border-border"}),w.jsxs("button",{onClick:()=>{MA(!1),E(!0)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4M10 17l5-5-5-5M15 12H3"})}),"Import Review"]})]})]})]})]}),w.jsx(K4A,{className:"md:hidden",isPanelOpen:x,onTogglePanel:()=>R(!x),annotationCount:Ht.length+wt.length,onOpenExport:()=>{dA(void 0),I(!0)},onOpenSettings:()=>N(!0),onDownloadAnnotations:Vd,onCopyShareLink:async()=>{try{await navigator.clipboard.writeText(wi),PA({type:"success",message:"Share link copied"})}catch{PA({type:"error",message:"Failed to copy"})}setTimeout(()=>PA(null),3e3)},onOpenImport:()=>E(!0),onPrint:()=>window.print(),sharingEnabled:YA})]})]}),we.error&&w.jsxs("div",{className:"bg-destructive/10 border-b border-destructive/20 px-4 py-2 flex items-center gap-2 flex-shrink-0",children:[w.jsx("span",{className:"text-xs text-destructive",children:we.error}),w.jsx("button",{onClick:we.dismissError,className:"ml-auto text-xs text-destructive/60 hover:text-destructive",children:"dismiss"})]}),w.jsxs("div",{"data-print-region":"content",className:`flex-1 flex overflow-hidden relative z-0 ${Me?"select-none":""}`,children:[k&&w.jsx(mUA,{}),!ke.isOpen&&w.jsx(BKA,{activeTab:ke.activeTab,onToggleTab:ke.toggleTab,hasDiff:Re.hasPreviousVersion,showFilesTab:ci&&!rt.archiveMode,showVaultTab:It,hasFileAnnotations:Ii,hasVaultAnnotations:Li,className:"hidden lg:flex"}),ke.isOpen&&w.jsxs(w.Fragment,{children:[w.jsx(bKA,{activeTab:ke.activeTab,onTabChange:XA=>{ke.toggleTab(XA),XA==="archive"&&!rt.archiveMode&&rt.fetchPlans()},onClose:ke.close,width:ve.width,blocks:a,annotations:t,activeSection:FA,onTocNavigate:Wd,linkedDocFilepath:we.filepath,onLinkedDocBack:we.isActive?_e:void 0,backLabel:ot,showFilesTab:ci&&!rt.archiveMode,fileAnnotationCounts:ai,highlightedFiles:Le,fileBrowser:pt,onFilesSelectFile:zA,onFilesFetchAll:()=>pt.fetchAll(Ye),showVaultTab:It&&!rt.archiveMode,vaultPath:Et,vaultBrowser:We,vaultAnnotationCounts:Ct,vaultHighlightedFiles:me,onVaultSelectFile:Dt,onVaultFetchTree:LA,hasFileAnnotations:Ii,hasVaultAnnotations:Li,versionInfo:Ge,versions:Re.versions,selectedBaseVersion:Re.diffBaseVersion,onSelectBaseVersion:Re.selectBaseVersion,isPlanDiffActive:_A,hasPreviousVersion:Re.hasPreviousVersion,onActivatePlanDiff:()=>Ee(!0),isLoadingVersions:Re.isLoadingVersions,isSelectingVersion:Re.isSelectingVersion,fetchingVersion:Re.fetchingVersion,onFetchVersions:Re.fetchVersions,showArchiveTab:G&&!hA,archivePlans:rt.plans,selectedArchiveFile:rt.selectedFile,onArchiveSelect:rt.select,isLoadingArchive:rt.isLoading}),w.jsx(QW,{...ve.handleProps,className:"hidden lg:block",side:"left"})]}),w.jsxs("main",{"data-print-region":"document",ref:le,className:"flex-1 min-w-0 overflow-y-auto bg-grid",children:[w.jsx(nQ,{isOpen:!!qe,onClose:_,onConfirm:IA,title:"Draft Recovered",message:qe?`Found ${qe.count} annotation${qe.count!==1?"s":""} from ${qe.timeAgo}. Would you like to restore them?`:"",confirmText:"Restore",cancelText:"Dismiss",showCancel:!0}),w.jsxs("div",{className:"min-h-full flex flex-col items-center px-2 py-3 md:px-10 md:py-8 xl:px-16 relative z-10",children:[!_A&&!rt.archiveMode&&w.jsx("div",{"data-print-hide":!0,className:"w-full mb-3 md:mb-4 flex items-center justify-start",style:{maxWidth:Zd},children:w.jsx(BUA,{inputMethod:K,onInputMethodChange:ge,mode:T,onModeChange:jA,taterMode:k})}),Re.diffBlocks&&Re.diffStats&&w.jsx("div",{className:"w-full flex justify-center",style:{display:_A?void 0:"none"},children:w.jsx(FKA,{diffBlocks:Re.diffBlocks,diffStats:Re.diffStats,diffMode:yA,onDiffModeChange:UA,onPlanDiffToggle:()=>Ee(!1),repoInfo:vA,baseVersionLabel:Re.diffBaseVersion!=null?`v${Re.diffBaseVersion}`:void 0,baseVersion:Re.diffBaseVersion??void 0,maxWidth:Zd,annotations:ar,onAddAnnotation:Hi,onSelectAnnotation:pn,selectedAnnotationId:r,mode:T})}),oA==="folder"&&!e&&!we.isActive&&w.jsx("div",{className:"w-full flex justify-center",children:w.jsxs("div",{className:"w-full max-w-3xl p-12 text-center text-muted-foreground",children:[w.jsx("p",{className:"text-lg font-medium mb-2",children:"Select a file to annotate"}),w.jsx("p",{className:"text-sm",children:"Pick a markdown file from the sidebar to begin."})]})}),w.jsx("div",{className:"w-full flex justify-center",style:{display:_A&&Re.diffBlocks||oA==="folder"&&!e&&!we.isActive?"none":void 0},children:w.jsx(VOA,{ref:eA,blocks:a,markdown:e,frontmatter:o,annotations:ts,onAddAnnotation:Hi,onSelectAnnotation:pn,selectedAnnotationId:r,mode:T,inputMethod:K,taterMode:k,globalAttachments:gA,onAddGlobalAttachment:hg,onRemoveGlobalAttachment:kr,repoInfo:vA,stickyActions:O.stickyActionsEnabled,planDiffStats:we.isActive?null:Re.diffStats,isPlanDiffActive:_A,onPlanDiffToggle:()=>Ee(!_A),hasPreviousVersion:!we.isActive&&Re.hasPreviousVersion,showDemoBadge:!G&&!Ea&&!Or,maxWidth:Zd,onOpenLinkedDoc:be,linkedDocInfo:we.isActive?{filepath:we.filepath,onBack:_e,label:We.activeFile?"Vault File":pt.activeFile?"File":void 0,backLabel:ot}:null,imageBaseDir:sA,copyLabel:oA==="message"?"Copy message":oA==="file"||oA==="folder"?"Copy file":void 0,archiveInfo:rt.currentInfo,onToggleCheckbox:Pi.toggle,checkboxOverrides:Pi.overrides},we.isActive?`doc:${we.filepath}`:"plan")})]})]}),x&&w.jsx(QW,{...se.handleProps,className:"hidden md:block",side:"right"}),w.jsx(AUA,{isOpen:x,blocks:a,annotations:Ht,selectedId:r,onSelect:n,onDelete:Vr,onEdit:Ao,shareUrl:wi,sharingEnabled:YA,width:se.width,editorAnnotations:wt,onDeleteEditorAnnotation:es,onClose:()=>R(!1),onQuickCopy:async()=>{await navigator.clipboard.writeText(VAA(bs))},otherFileAnnotations:fi,onOtherFileAnnotationsClick:Ne})]}),w.jsx(gUA,{isOpen:l,onClose:()=>{I(!1),dA(void 0)},shareUrl:wi,shareUrlSize:Ss,shortShareUrl:sr,isGeneratingShortUrl:dt,shortUrlError:kt,onGenerateShortUrl:Wr,annotationsOutput:bs,annotationCount:Ht.length,taterSprite:k?w.jsx(p4,{}):void 0,sharingEnabled:YA,markdown:e,isApiMode:G,initialTab:TA}),w.jsx(lUA,{isOpen:C,onClose:()=>E(!1),onImport:or,shareBaseUrl:ae}),w.jsx(nQ,{isOpen:B,onClose:()=>h(!1),title:"Add Annotations First",message:`To provide feedback, select text in the plan and add annotations. ${fg} will use your annotations to revise the plan.`,variant:"info"}),w.jsx(nQ,{isOpen:Q,onClose:()=>f(!1),onConfirm:()=>{f(!1),Xt()},title:"Annotations Won't Be Sent",message:w.jsxs(w.Fragment,{children:[fg," doesn't yet support feedback on approval. Your ",Ht.length," annotation",Ht.length!==1?"s":""," will be lost."]}),subMessage:w.jsxs(w.Fragment,{children:["To send feedback, use ",w.jsx("strong",{children:"Send Feedback"})," instead.",w.jsx("br",{}),w.jsx("br",{}),"Want this feature? Upvote these issues:",w.jsx("br",{}),w.jsx("a",{href:"https://github.com/anthropics/claude-code/issues/16001",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"#16001"})," · ",w.jsx("a",{href:"https://github.com/anthropics/claude-code/issues/15755",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"#15755"})]}),confirmText:"Approve Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),w.jsx(nQ,{isOpen:m,onClose:()=>y(!1),onConfirm:()=>{y(!1),Xt()},title:"Agent Not Found",message:v,subMessage:w.jsxs(w.Fragment,{children:["You can change the agent in ",w.jsx("strong",{children:"Settings"}),", or approve anyway and OpenCode will use the default agent."]}),confirmText:"Approve Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),w.jsx(nQ,{isOpen:!!Un&&!G,onClose:an,title:"Shared Plan Could Not Be Loaded",message:Un,subMessage:"You are viewing a demo plan. This is sample content — it is not your data or anyone else's.",variant:"warning"}),wA&&w.jsx("div",{className:`fixed top-16 right-4 z-50 px-3 py-2 rounded-lg text-xs font-medium shadow-lg transition-opacity ${wA.type==="success"?"bg-success/15 text-success border border-success/30":"bg-destructive/15 text-destructive border border-destructive/30"}`,children:wA.message}),w.jsx(p4A,{submitted:tA,title:rt.archiveMode?"Archive Closed":tA==="approved"?"Plan Approved":hA?"Annotations Sent":"Feedback Sent",subtitle:rt.archiveMode?"You can reopen with plannotator archive.":tA==="approved"?`${fg} will proceed with the implementation.`:hA?`${fg} will address your annotations on the ${oA==="message"?"message":oA==="folder"?"files":"file"}.`:`${fg} will revise the plan based on your annotations.`,agentLabel:fg}),w.jsx(S4A,{origin:z,isWSL:AA}),w.jsx(neA,{isOpen:!!RA,imageSrc:RA?.blobUrl??"",initialName:RA?.initialName,onAccept:Pt,onClose:ti}),w.jsx(V4A,{isOpen:Ie,onComplete:XA=>{ie(XA),Qe(!1)}})]})})},IgA=document.getElementById("root");if(!IgA)throw new Error("Could not find root element to mount to");const KKA=dfA.createRoot(IgA);KKA.render(w.jsx(cn.StrictMode,{children:w.jsx(UKA,{})}));class ls{constructor(A,t,i){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=A,this.start=t,this.end=i}static range(A,t){return t?!A||!A.loc||!t.loc||A.loc.lexer!==t.loc.lexer?null:new ls(A.loc.lexer,A.loc.start,t.loc.end):A&&A.loc}}class Hs{constructor(A,t){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=A,this.loc=t}range(A,t){return new Hs(t,ls.range(this,A))}}class je{constructor(A,t){this.name=void 0,this.position=void 0,this.length=void 0,this.rawMessage=void 0;var i="KaTeX parse error: "+A,r,n,a=t&&t.loc;if(a&&a.start<=a.end){var s=a.lexer.input;r=a.start,n=a.end,r===s.length?i+=" at end of input: ":i+=" at position "+(r+1)+": ";var o=s.slice(r,n).replace(/[^]/g,"$&̲"),g;r>15?g="…"+s.slice(r-15,r):g=s.slice(0,r);var l;n+15<s.length?l=s.slice(n,n+15)+"…":l=s.slice(n),i+=g+o+l}var I=new Error(i);return I.name="ParseError",I.__proto__=je.prototype,I.position=r,r!=null&&n!=null&&(I.length=n-r),I.rawMessage=A,I}}je.prototype.__proto__=Error.prototype;var YKA=function(A,t){return A===void 0?t:A},HKA=/([A-Z])/g,PKA=function(A){return A.replace(HKA,"-$1").toLowerCase()},JKA={"&":"&",">":">","<":"<",'"':""","'":"'"},zKA=/[&><"']/g;function qKA(e){return String(e).replace(zKA,A=>JKA[A])}var CgA=function e(A){return A.type==="ordgroup"||A.type==="color"?A.body.length===1?e(A.body[0]):A:A.type==="font"?e(A.body):A},WKA=function(A){var t=CgA(A);return t.type==="mathord"||t.type==="textord"||t.type==="atom"},VKA=function(A){if(!A)throw new Error("Expected non-null, but got "+String(A));return A},ZKA=function(A){var t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(A);return t?t[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():"_relative"},Oi={deflt:YKA,escape:qKA,hyphenate:PKA,getBaseElem:CgA,isCharacterBox:WKA,protocolFromUrl:ZKA},kf={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format <type>"},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color <color>",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:e=>"#"+e},macros:{type:"object",cli:"-m, --macro <def>",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(e,A)=>(A.push(e),A)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:"--min-rule-thickness <size>",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:e=>Math.max(0,e),cli:"-s, --max-size <n>",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:e=>Math.max(0,e),cli:"-e, --max-expand <n>",cliProcessor:e=>e==="Infinity"?1/0:parseInt(e)},globalGroup:{type:"boolean",cli:!1}};function jKA(e){if(e.default)return e.default;var A=e.type,t=Array.isArray(A)?A[0]:A;if(typeof t!="string")return t.enum[0];switch(t){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{}}}class v4{constructor(A){this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,A=A||{};for(var t in kf)if(kf.hasOwnProperty(t)){var i=kf[t];this[t]=A[t]!==void 0?i.processor?i.processor(A[t]):A[t]:jKA(i)}}reportNonstrict(A,t,i){var r=this.strict;if(typeof r=="function"&&(r=r(A,t,i)),!(!r||r==="ignore")){if(r===!0||r==="error")throw new je("LaTeX-incompatible input and strict mode is set to 'error': "+(t+" ["+A+"]"),i);r==="warn"?typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(t+" ["+A+"]")):typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+r+"': "+t+" ["+A+"]"))}}useStrictBehavior(A,t,i){var r=this.strict;if(typeof r=="function")try{r=r(A,t,i)}catch{r="error"}return!r||r==="ignore"?!1:r===!0||r==="error"?!0:r==="warn"?(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(t+" ["+A+"]")),!1):(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+r+"': "+t+" ["+A+"]")),!1)}isTrusted(A){if(A.url&&!A.protocol){var t=Oi.protocolFromUrl(A.url);if(t==null)return!1;A.protocol=t}var i=typeof this.trust=="function"?this.trust(A):this.trust;return!!i}}class Xc{constructor(A,t,i){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=A,this.size=t,this.cramped=i}sup(){return Fg[_KA[this.id]]}sub(){return Fg[XKA[this.id]]}fracNum(){return Fg[$KA[this.id]]}fracDen(){return Fg[A5A[this.id]]}cramp(){return Fg[e5A[this.id]]}text(){return Fg[t5A[this.id]]}isTight(){return this.size>=2}}var S4=0,Qv=1,xB=2,ec=3,l0=4,mo=5,sd=6,Ha=7,Fg=[new Xc(S4,0,!1),new Xc(Qv,0,!0),new Xc(xB,1,!1),new Xc(ec,1,!0),new Xc(l0,2,!1),new Xc(mo,2,!0),new Xc(sd,3,!1),new Xc(Ha,3,!0)],_KA=[l0,mo,l0,mo,sd,Ha,sd,Ha],XKA=[mo,mo,mo,mo,Ha,Ha,Ha,Ha],$KA=[xB,ec,l0,mo,sd,Ha,sd,Ha],A5A=[ec,ec,mo,mo,Ha,Ha,Ha,Ha],e5A=[Qv,Qv,ec,ec,mo,mo,Ha,Ha],t5A=[S4,Qv,xB,ec,xB,ec,xB,ec],Kt={DISPLAY:Fg[S4],TEXT:Fg[xB],SCRIPT:Fg[l0],SCRIPTSCRIPT:Fg[sd]},n3=[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}];function i5A(e){for(var A=0;A<n3.length;A++)for(var t=n3[A],i=0;i<t.blocks.length;i++){var r=t.blocks[i];if(e>=r[0]&&e<=r[1])return t.name}return null}var RD=[];n3.forEach(e=>e.blocks.forEach(A=>RD.push(...A)));function EgA(e){for(var A=0;A<RD.length;A+=2)if(e>=RD[A]&&e<=RD[A+1])return!0;return!1}var Zu=80,r5A=function(A,t){return"M95,"+(622+A+t)+`
|
|
849
849
|
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
|
|
850
850
|
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
|
|
851
851
|
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
|