@plannotator/opencode 0.19.2 → 0.19.3

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/plannotator.html CHANGED
@@ -651,7 +651,7 @@ created: ${new Date().toISOString().slice(0,19)}Z
651
651
  source: plannotator
652
652
  tags: [plan, ...]
653
653
  ---`})]}),D.jsx("div",{className:"border-t border-border/30"}),D.jsxs("div",{className:"flex items-center justify-between",children:[D.jsxs("div",{children:[D.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),D.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Obsidian when a plan loads, before you approve or deny"})]}),D.jsx("button",{role:"switch","aria-checked":h.autoSave,onClick:()=>OA({autoSave:!h.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${h.autoSave?"bg-primary":"bg-muted"}`,children:D.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${h.autoSave?"translate-x-6":"translate-x-1"}`})})]}),D.jsxs("div",{className:"flex items-center justify-between",children:[D.jsxs("div",{children:[D.jsx("div",{className:"text-xs font-medium",children:"Vault Browser"}),D.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Browse and annotate vault files from the sidebar"})]}),D.jsx("button",{role:"switch","aria-checked":h.vaultBrowserEnabled,onClick:()=>OA({vaultBrowserEnabled:!h.vaultBrowserEnabled}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${h.vaultBrowserEnabled?"bg-primary":"bg-muted"}`,children:D.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${h.vaultBrowserEnabled?"translate-x-6":"translate-x-1"}`})})]})]})]})]}),C==="bear"&&D.jsxs(D.Fragment,{children:[D.jsxs("div",{className:"flex items-center justify-between",children:[D.jsxs("div",{children:[D.jsx("div",{className:"text-sm font-medium",children:"Bear Notes"}),D.jsx("div",{className:"text-xs text-muted-foreground",children:"Auto-save approved plans to Bear"})]}),D.jsx("button",{role:"switch","aria-checked":M.enabled,onClick:()=>JA({enabled:!M.enabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${M.enabled?"bg-primary":"bg-muted"}`,children:D.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${M.enabled?"translate-x-6":"translate-x-1"}`})})]}),M.enabled&&D.jsxs("div",{className:"mt-3 space-y-3",children:[D.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[D.jsx("label",{className:"text-xs text-muted-foreground",children:"Custom Tags"}),D.jsx("input",{type:"text",value:M.customTags,onChange:EA=>JA({customTags:EA.target.value}),onBlur:EA=>JA({customTags:sVA(EA.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"}),D.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Comma-separated, kebab-case. Leave empty for auto-generated tags."})]}),D.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[D.jsx("label",{className:"text-xs text-muted-foreground",children:"Tag Position"}),D.jsxs("select",{value:M.tagPosition,onChange:EA=>JA({tagPosition:EA.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:[D.jsx("option",{value:"append",children:"Append (end of note)"}),D.jsx("option",{value:"prepend",children:"Prepend (after title)"})]})]}),D.jsx("div",{className:"border-t border-border/30"}),D.jsxs("div",{className:"flex items-center justify-between",children:[D.jsxs("div",{children:[D.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),D.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Bear when a plan loads, before you approve or deny"})]}),D.jsx("button",{role:"switch","aria-checked":M.autoSave,onClick:()=>JA({autoSave:!M.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${M.autoSave?"bg-primary":"bg-muted"}`,children:D.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${M.autoSave?"translate-x-6":"translate-x-1"}`})})]})]})]}),C==="octarine"&&D.jsxs(D.Fragment,{children:[D.jsxs("div",{className:"flex items-center justify-between",children:[D.jsxs("div",{children:[D.jsx("div",{className:"text-sm font-medium",children:"Octarine"}),D.jsx("div",{className:"text-xs text-muted-foreground",children:"Auto-save approved plans to Octarine"})]}),D.jsx("button",{role:"switch","aria-checked":R.enabled,onClick:()=>Ce({enabled:!R.enabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${R.enabled?"bg-primary":"bg-muted"}`,children:D.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${R.enabled?"translate-x-6":"translate-x-1"}`})})]}),R.enabled&&D.jsxs("div",{className:"mt-3 space-y-3",children:[D.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[D.jsx("label",{className:"text-xs text-muted-foreground",children:"Workspace Name"}),D.jsx("input",{type:"text",value:R.workspace,onChange:EA=>Ce({workspace:EA.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"}),D.jsx("div",{className:"text-[10px] text-muted-foreground",children:"The Octarine workspace name to save plans into."})]}),D.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[D.jsx("label",{className:"text-xs text-muted-foreground",children:"Folder"}),D.jsx("input",{type:"text",value:R.folder,onChange:EA=>Ce({folder:EA.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"}),D.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Subfolder within the workspace for saved plans."})]}),D.jsxs("div",{className:"text-[10px] text-muted-foreground/70",children:["Plans saved to: ",R.workspace||"..."," / ",R.folder||"plannotator","/"]}),D.jsx("div",{className:"border-t border-border/30"}),D.jsxs("div",{className:"flex items-center justify-between",children:[D.jsxs("div",{children:[D.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),D.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Octarine when a plan loads, before you approve or deny"})]}),D.jsx("button",{role:"switch","aria-checked":R.autoSave,onClick:()=>Ce({autoSave:!R.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${R.autoSave?"bg-primary":"bg-muted"}`,children:D.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${R.autoSave?"translate-x-6":"translate-x-1"}`})})]})]})]})]})})]})]})}),document.body)]})},Q3=({onClick:e,disabled:A=!1,isLoading:t=!1,label:r="Send Feedback",shortLabel:i,loadingLabel:n="Sending...",shortLoadingLabel:a,title:o="Send Feedback",muted:s=!1})=>D.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 ${s?"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:o,children:[D.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.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"})}),i?D.jsxs(D.Fragment,{children:[D.jsx("span",{className:"hidden md:inline lg:hidden",children:t?a??n:i}),D.jsx("span",{className:"hidden lg:inline",children:t?n:r})]}):D.jsx("span",{className:"hidden md:inline",children:t?n:r})]}),aAA=({onClick:e,disabled:A=!1,isLoading:t=!1,label:r="Approve",loadingLabel:i="Approving...",mobileLabel:n="OK",mobileLoadingLabel:a="...",title:o,dimmed:s=!1,muted:g=!1})=>D.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":s?"bg-success/50 text-success-foreground/70 hover:bg-success hover:text-success-foreground":"bg-success text-success-foreground hover:opacity-90"}`,title:o,children:[D.jsx("span",{className:"md:hidden",children:t?a:n}),D.jsx("span",{className:"hidden md:inline",children:t?i:r})]}),r_A=({onClick:e,disabled:A=!1,isLoading:t=!1,title:r="Close session without sending feedback"})=>D.jsxs("button",{onClick:e,disabled:A||t,className:`px-2.5 py-1 rounded-md text-xs font-medium transition-all ${A||t?"opacity-50 cursor-not-allowed bg-muted text-muted-foreground":"bg-muted text-muted-foreground hover:bg-muted/80"}`,title:r,children:[D.jsx("span",{className:"md:hidden",children:t?"...":"✕"}),D.jsx("span",{className:"hidden md:inline",children:t?"Closing...":"Close"})]});async function OhA(e){const A=JSON.stringify(e),t=new TextEncoder().encode(A),r=new CompressionStream("deflate-raw"),i=r.writable.getWriter();i.write(t),i.close();const n=await new Response(r.readable).arrayBuffer(),a=new Uint8Array(n);let o="";for(let g=0;g<a.length;g++)o+=String.fromCharCode(a[g]);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async function Mb(e){const A=e.replace(/-/g,"+").replace(/_/g,"/"),t=atob(A),r=Uint8Array.from(t,s=>s.charCodeAt(0)),i=new DecompressionStream("deflate-raw"),n=i.writable.getWriter();n.write(r),n.close();const a=await new Response(i.readable).arrayBuffer(),o=new TextDecoder().decode(a);return JSON.parse(o)}async function i_A(e){const A=await crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt"]),t=crypto.getRandomValues(new Uint8Array(12)),r=new TextEncoder().encode(e),i=await crypto.subtle.encrypt({name:"AES-GCM",iv:t},A,r),n=new Uint8Array(t.length+i.byteLength);n.set(t,0),n.set(new Uint8Array(i),t.length);const a=await crypto.subtle.exportKey("raw",A);return{ciphertext:oAA(n),key:oAA(new Uint8Array(a))}}async function n_A(e,A){const t=sAA(e),r=sAA(A),i=t.slice(0,12),n=t.slice(12),a=await crypto.subtle.importKey("raw",r.buffer,{name:"AES-GCM",length:256},!1,["decrypt"]),o=await crypto.subtle.decrypt({name:"AES-GCM",iv:i},a,n);return new TextDecoder().decode(o)}function oAA(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 sAA(e){const A=e.replace(/-/g,"+").replace(/_/g,"/"),t=atob(A);return Uint8Array.from(t,r=>r.charCodeAt(0))}function yh(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 d9(e){if(e?.length)return e.map(A=>[A.path,A.name])}function UhA(e){return e.map(A=>{const t=A.author||null,r=d9(A.images);return A.type===Er.GLOBAL_COMMENT?["G",A.text||"",t,r]:A.type===Er.DELETION?["D",A.originalText,t,r]:A.isQuickLabel?["C",A.originalText,A.text||"",t,r??void 0,1]:["C",A.originalText,A.text||"",t,r]})}function SS(e,A,t){const r={D:Er.DELETION,C:Er.COMMENT,G:Er.GLOBAL_COMMENT};return e.map((i,n)=>{const a=i[0];if(a==="G"){const C=i[1],E=i[2],u=i[3];return{id:`shared-${n}-${Date.now()}`,blockId:"",startOffset:0,endOffset:0,type:Er.GLOBAL_COMMENT,text:C||void 0,originalText:"",createdA:Date.now()+n,author:E||void 0,images:yh(u),...t?.[n]?{source:t[n]}:{}}}const o=i[1],s=a==="D"?void 0:i[2],g=a==="D"?i[2]:i[3],l=a==="D"?i[3]:i[4],I=a==="C"&&i.length>5&&i[5]===1?!0:void 0;return{id:`shared-${n}-${Date.now()}`,blockId:"",startOffset:0,endOffset:0,type:r[a],text:s||void 0,originalText:o,createdA:Date.now()+n,author:g||void 0,images:yh(l),...I?{isQuickLabel:I}:{},...A?.[n]?{diffContext:A[n]}:{},...t?.[n]?{source:t[n]}:{}}})}function KhA(e){const A=e.map(t=>t.diffContext||null);return A.some(t=>t!==null)?A:null}function YhA(e){const A=e.map(t=>t.source||void 0);return A.some(t=>t!==void 0)?A:null}async function a_A(e,A,t,r=PhA){const i=KhA(A),n=YhA(A),a={p:e,a:UhA(A),g:t?.length?d9(t):void 0,...i?{d:i}:{},...n?{s:n}:{}},o=await OhA(a);return`${r}/#${o}`}async function o_A(){const A=window.location.hash.slice(1).split("?")[0];if(!A)return null;try{return await Mb(A)}catch(t){return console.warn("Failed to parse share hash:",t),null}}function s_A(e){const A=new Blob([e]).size;return A<1024?`${A} B`:`${(A/1024).toFixed(1)} KB`}const e5="https://plannotator-paste.plannotator.workers.dev",PhA="https://share.plannotator.ai";async function g_A(e,A,t,r){const i=r?.pasteApiUrl??e5,n=r?.shareBaseUrl??PhA;try{const a=KhA(A),o=YhA(A),s={p:e,a:UhA(A),g:t?.length?d9(t):void 0,...a?{d:a}:{},...o?{s:o}:{}},g=await OhA(s),{ciphertext:l,key:I}=await i_A(g),C=await fetch(`${i}/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(),u=i!==e5?`&paste=${btoa(i).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}`:"";return{shortUrl:`${n}/p/${E.id}#key=${I}${u}`,id:E.id}}catch(a){return console.debug("[sharing] Short URL service unavailable, using hash-based sharing:",a),null}}async function gAA(e,A=e5,t){try{const r=await fetch(`${A}/api/paste/${e}`,{signal:AbortSignal.timeout(1e4)});if(!r.ok)return console.warn(`[sharing] Paste fetch returned ${r.status} for id ${e}`),null;const i=await r.json();if(t){const n=await n_A(i.data,t);return await Mb(n)}return await Mb(i.data)}catch(r){return console.warn("[sharing] Failed to load from paste ID:",r),null}}function lAA(e){const A=e.replace(/^#/,"").split("?")[0];return A.length>=30&&/^[A-Za-z0-9_-]+$/.test(A)&&/[A-Z]/.test(A)}function l_A(e,A,t,r,i,n,a,o,s){const[g,l]=Z.useState(!1),[I,C]=Z.useState(!0),[E,u]=Z.useState(""),[B,h]=Z.useState(""),[f,p]=Z.useState(""),[m,w]=Z.useState(!1),[v,M]=Z.useState(""),[b,R]=Z.useState(null),[N,L]=Z.useState(null),[T,O]=Z.useState(""),P=Z.useCallback(()=>{R(null),L(null)},[]),x=Z.useCallback(()=>O(""),[]),U=Z.useCallback(async()=>{try{const H=window.location.pathname.match(/^\/p\/([A-Za-z0-9]{6,16})$/);if(H){const q=H[1],j=window.location.hash.slice(1),$=new URLSearchParams(j),X=$.get("key")??void 0,gA=$.get("paste")?atob($.get("paste").replace(/-/g,"+").replace(/_/g,"/")):void 0,tA=await gAA(q,gA??s,X);if(tA){r(tA.p);const hA=SS(tA.a,tA.d,tA.s);if(i(hA),tA.g?.length){const oA=yh(tA.g)??[];n(oA),L(oA)}R(hA),l(!0),a?.();const rA=window.location.pathname.replace(/\/p\/[A-Za-z0-9]+$/,"")||"/";return window.history.replaceState({},"",rA),!0}return O("Failed to load shared plan — the link may be expired or incomplete."),!1}const z=window.location.hash.slice(1);if(!lAA(z))return!1;const Y=await o_A();if(Y){r(Y.p);const q=SS(Y.a,Y.d,Y.s);if(i(q),Y.g?.length){const j=yh(Y.g)??[];n(j),L(j)}return R(q),l(!0),a?.(),window.history.replaceState({},"",window.location.pathname),!0}return z&&O("Failed to load shared plan — the URL may have been truncated by your browser."),!1}catch(H){return console.error("Failed to load from share hash:",H),O("Failed to load shared plan — an unexpected error occurred."),!1}},[r,i,n,a,s]);Z.useEffect(()=>{U().finally(()=>C(!1))},[]),Z.useEffect(()=>{const H=()=>{lAA(window.location.hash)&&U()};return window.addEventListener("hashchange",H),()=>window.removeEventListener("hashchange",H)},[U]);const G=Z.useCallback(async()=>{try{const H=await a_A(e,A,t,o);u(H),h(s_A(H))}catch(H){console.error("Failed to generate share URL:",H),u(""),h("")}},[e,A,t,o]);Z.useEffect(()=>{G()},[G]),Z.useEffect(()=>{p(""),M("")},[e,A]);const F=Z.useCallback(async()=>{if(e){w(!0),M("");try{const H=await g_A(e,A,t,{pasteApiUrl:s,shareBaseUrl:o});H?p(H.shortUrl):(p(""),M("Short URL service unavailable"))}catch{p(""),M("Failed to generate short URL")}finally{w(!1)}}},[e,A,t,o,s]),K=Z.useCallback(async H=>{try{let z;const Y=H.match(/\/p\/([A-Za-z0-9]{6,16})(?:#(.*))?(?:\?|$)/);if(Y){const tA=Y[1],hA=new URLSearchParams(Y[2]??""),rA=hA.get("key")??void 0,oA=hA.get("paste")?atob(hA.get("paste").replace(/-/g,"+").replace(/_/g,"/")):void 0,sA=await gAA(tA,oA??s,rA);if(!sA)return{success:!1,count:0,planTitle:"",error:"Failed to load from short URL — paste may have expired"};z=sA}else{const tA=H.indexOf("#");if(tA===-1)return{success:!1,count:0,planTitle:"",error:"Invalid share URL: no hash fragment or short link found"};const hA=H.slice(tA+1);if(!hA)return{success:!1,count:0,planTitle:"",error:"Invalid share URL: empty hash"};z=await Mb(hA)}const j=(z.p||"").trim().split(`
654
- `).find(tA=>tA.startsWith("#")),$=j?j.replace(/^#+\s*/,"").trim():"Unknown Plan",X=SS(z.a,z.d,z.s);if(X.length===0)return{success:!0,count:0,planTitle:$,error:"No annotations found in share link"};const gA=X.filter(tA=>!A.some(hA=>hA.originalText===tA.originalText&&hA.type===tA.type&&hA.text===tA.text));if(gA.length>0&&(i(tA=>{const hA=X.filter(oA=>!tA.some(sA=>sA.originalText===oA.originalText&&sA.type===oA.type&&sA.text===oA.text));if(hA.length===0)return tA;const rA=[...tA,...hA];return R(rA),rA}),z.g?.length)){const tA=yh(z.g)??[];n(hA=>{const rA=new Set(hA.map(sA=>sA.path)),oA=tA.filter(sA=>!rA.has(sA.path));return oA.length>0?[...hA,...oA]:hA}),L(tA)}return{success:!0,count:gA.length,planTitle:$}}catch(z){return{success:!1,count:0,planTitle:"",error:z instanceof Error?z.message:"Failed to decompress share URL"}}},[A,t,i,n,s]);return{isSharedSession:g,isLoadingShared:I,shareUrl:E,shareUrlSize:B,shortShareUrl:f,isGeneratingShortUrl:m,shortUrlError:v,pendingSharedAnnotations:b,sharedGlobalAttachments:N,clearPendingSharedAnnotations:P,refreshShareUrl:G,generateShortUrl:F,importFromShareUrl:K,shareLoadError:T,clearShareLoadError:x}}var bS=(e=>(e.Approve="approve",e.Feedback="feedback",e))(bS||{});function c_A(e=window.location){const A=new URLSearchParams(e.search);let t=A.get("cb"),r=A.get("ct");if(!t||!r){const i=e.hash.indexOf("?");if(i!==-1){const n=new URLSearchParams(e.hash.slice(i+1));t=t??n.get("cb"),r=r??n.get("ct")}}if(!t||!r)return null;try{const{protocol:i}=new URL(t);if(i!=="https:"&&i!=="http:")return null}catch{return null}return{callbackUrl:t,token:r}}async function I_A(e,A,t){const r=e==="approve"?"Plan approved! The bot will proceed to implementation.":"Feedback sent! The bot will re-plan with your annotations.";try{const i=await fetch(A.callbackUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,token:A.token,annotated_url:t})});return i.ok?{type:"success",message:r}:{type:"error",message:i.status===401?"Plan link expired — request a new one from the bot.":"Callback failed."}}catch{return{type:"error",message:"Callback failed."}}}function C_A(e,A,t){const[r,i]=Z.useState(null),n=Z.useRef(null);return Z.useEffect(()=>{const a=t??e.current;if(!a)return;const o=a.querySelectorAll('[data-block-type="heading"]');if(o.length===0)return;const s=new Map;return n.current=new IntersectionObserver(g=>{g.forEach(C=>{s.set(C.target,C.isIntersecting)});let l=null,I=1/0;for(const[C,E]of s)if(E){const u=C.getBoundingClientRect();u.top<I&&(I=u.top,l=C)}if(l){const C=l.getAttribute("data-block-id");C&&i(C)}},{root:a,rootMargin:"-80px 0px -80% 0px",threshold:[0,.1,.5,1]}),o.forEach(g=>{n.current?.observe(g)}),()=>{n.current?.disconnect()}},[e,A,t]),r}function cAA(e){window.close(),setTimeout(()=>{window.closed||e()},300)}function E_A(e){const[A,t]=Z.useState({phase:"idle"});Z.useEffect(()=>{if(!e)return;const i=CgA();i==="0"?(cAA(()=>t({phase:"closeFailed"})),t({phase:"closed"})):t(i!=="off"?{phase:"counting",remaining:Number(i)}:{phase:"prompt"})},[e]),Z.useEffect(()=>{if(A.phase!=="counting")return;if(A.remaining<=0){cAA(()=>t({phase:"closeFailed"}));return}const i=setTimeout(()=>t(n=>n.phase==="counting"?{phase:"counting",remaining:n.remaining-1}:n),1e3);return()=>clearTimeout(i)},[A]);const r=Z.useCallback(()=>{EgA("3"),t({phase:"counting",remaining:3})},[]);return{state:A,enableAndStart:r}}const u_A=()=>D.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:D.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),d_A=()=>D.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:D.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 B_A({submitted:e,title:A,subtitle:t,agentLabel:r}){const{state:i,enableAndStart:n}=E_A(!!e);if(!e)return null;const a=e==="approved";return D.jsx("div",{className:"fixed inset-0 z-[100] bg-background flex items-center justify-center",children:D.jsxs("div",{className:"text-center space-y-6 max-w-md px-8",children:[D.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?D.jsx(u_A,{}):D.jsx(d_A,{})}),D.jsxs("div",{className:"space-y-2",children:[D.jsx("h2",{className:"text-xl font-semibold text-foreground",children:A}),D.jsx("p",{className:"text-muted-foreground",children:t})]}),D.jsx("div",{className:"pt-4 border-t border-border space-y-2",children:i.phase==="counting"?D.jsxs(D.Fragment,{children:[D.jsxs("p",{className:"text-sm text-muted-foreground",children:["This tab will close in ",D.jsx("span",{className:"text-foreground font-medium",children:i.remaining})," second",i.remaining!==1?"s":"","..."]}),D.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change this in Settings."})]}):i.phase==="closeFailed"?D.jsxs(D.Fragment,{children:[D.jsx("p",{className:"text-sm text-muted-foreground",children:"Could not close this tab automatically. Please close it manually."}),D.jsxs("p",{className:"text-xs text-muted-foreground/60",children:["Auto-close works when the tab is opened by ",r,"."]})]}):D.jsxs(D.Fragment,{children:[D.jsxs("p",{className:"text-sm text-muted-foreground",children:["You can close this tab and return to ",D.jsx("span",{className:"text-foreground font-medium",children:r}),"."]}),i.phase==="prompt"?D.jsxs(D.Fragment,{children:[D.jsxs("label",{className:"flex items-center justify-center gap-2 cursor-pointer group",children:[D.jsx("input",{type:"checkbox",checked:!1,onChange:n,className:"accent-primary"}),D.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-foreground transition-colors",children:"Auto-close this tab after 3 seconds"})]}),D.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change the delay in Settings."})]}):D.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Your response has been sent."})]})})]})})}const h_A="https://api.github.com/repos/backnotprop/plannotator/releases/latest",IAA={"0.5.0":{title:"Code Review is here!",description:"Review git diffs with inline annotations. Run /plannotator-review to try it."}};function Q_A(e,A){const t=n=>n.replace(/^v/,""),r=t(e).split(".").map(Number),i=t(A).split(".").map(Number);for(let n=0;n<Math.max(r.length,i.length);n++){const a=r[n]||0,o=i[n]||0;if(o>a)return!0;if(o<a)return!1}return!1}function f_A(){const[e,A]=Z.useState(null);return Z.useEffect(()=>{(async()=>{try{const r="0.19.2",n=new URLSearchParams(window.location.search).get("preview-update");if(n){const C=n.replace(/^v/,"");A({currentVersion:r,latestVersion:n,updateAvailable:!0,releaseUrl:`https://github.com/backnotprop/plannotator/releases/tag/v${C}`,featureHighlight:IAA[C]});return}const a=await fetch(h_A);if(!a.ok)return;const o=await a.json(),s=o.tag_name,g=Q_A(r,s),l=s.replace(/^v/,""),I=IAA[l];A({currentVersion:r,latestVersion:s,updateAvailable:g,releaseUrl:o.html_url,featureHighlight:I})}catch(r){console.debug("Update check failed:",r)}})()},[]),e}const p_A="pi install npm:@plannotator/pi-extension";function m_A(e){return GLA&&!e?'powershell -c "irm https://plannotator.ai/install.ps1 | iex"':"curl -fsSL https://plannotator.ai/install.sh | bash"}const y_A=({origin:e,isWSL:A=!1})=>{const t=f_A(),[r,i]=Z.useState(!1),[n,a]=Z.useState(!1),g=new URLSearchParams(window.location.search).get("preview-origin")||e,l=g==="pi",I=g==="opencode",C=l?p_A:m_A(A);if(!t?.updateAvailable||n)return null;const E=async()=>{try{await navigator.clipboard.writeText(C),i(!0),setTimeout(()=>i(!1),2e3)}catch(B){console.error("Failed to copy:",B)}};return t.featureHighlight?D.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:D.jsxs("div",{className:"bg-card border border-primary/30 rounded-xl shadow-2xl overflow-hidden",children:[D.jsx("div",{className:"bg-gradient-to-r from-primary/20 to-primary/5 px-5 py-4 border-b border-border/50",children:D.jsxs("div",{className:"flex items-start justify-between gap-3",children:[D.jsxs("div",{className:"flex items-center gap-3",children:[D.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-primary/20 flex items-center justify-center",children:D.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.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"})})}),D.jsxs("div",{children:[D.jsx("h4",{className:"text-base font-semibold text-foreground",children:t.featureHighlight.title}),D.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["New in ",t.latestVersion]})]})]}),D.jsx("button",{onClick:()=>a(!0),className:"text-muted-foreground hover:text-foreground transition-colors p-1",children:D.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),D.jsxs("div",{className:"px-5 py-4",children:[D.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed",children:t.featureHighlight.description}),D.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:["You have ",t.currentVersion]}),I&&D.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install script, then restart OpenCode."}),l&&D.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install command, then restart Pi."}),D.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[D.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:r?"Copied!":"Copy install command"}),D.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"})]})]})]})}):D.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:D.jsx("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4",children:D.jsxs("div",{className:"flex items-start gap-3",children:[D.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center",children:D.jsx("svg",{className:"w-4 h-4 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.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"})})}),D.jsxs("div",{className:"flex-1 min-w-0",children:[D.jsxs("div",{className:"flex items-center justify-between gap-2",children:[D.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Update available"}),D.jsx("button",{onClick:()=>a(!0),className:"text-muted-foreground hover:text-foreground transition-colors",children:D.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),D.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[t.latestVersion," is available (you have ",t.currentVersion,")"]}),D.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[D.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:r?"Copied!":"Copy install command"}),D.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"})]})]})]})})})},HhA="plannotator-editor-mode",D_A="selection";function w_A(){const e=Je.getItem(HhA);return e==="selection"||e==="comment"||e==="redline"||e==="quickLabel"?e:D_A}function v_A(e){Je.setItem(HhA,e)}const JhA="plannotator-input-method",S_A="drag";function b_A(){const e=Je.getItem(JhA);return e==="drag"||e==="pinpoint"?e:S_A}function R_A(e){Je.setItem(JhA,e)}const N_A=300,M_A=300;function k_A(e,A){const t=Z.useRef("idle"),r=Z.useRef(0),i=Z.useRef(void 0),n=Z.useRef(e);Z.useEffect(()=>{t.current==="idle"&&(n.current=e)},[e]);const a=Z.useCallback(o=>o==="drag"?"pinpoint":"drag",[]);Z.useEffect(()=>{const o=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,r.current=Date.now(),t.current="held",A(a(e))):t.current==="tapped"&&(clearTimeout(i.current),t.current="idle",n.current=a(n.current)))},s=g=>{g.key==="Alt"&&t.current==="held"&&(Date.now()-r.current>=M_A?(A(n.current),t.current="idle"):(t.current="tapped",i.current=setTimeout(()=>{t.current==="tapped"&&(A(n.current),t.current="idle")},N_A)))};return window.addEventListener("keydown",o),window.addEventListener("keyup",s),()=>{clearTimeout(i.current),window.removeEventListener("keydown",o),window.removeEventListener("keyup",s)}},[e,A,a])}function x_A(){Z.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 CAA({storageKey:e,defaultWidth:A=288,minWidth:t=200,maxWidth:r=600,side:i="right"}){const[n,a]=Z.useState(()=>{const h=Je.getItem(e);if(h){const f=Number(h);if(!Number.isNaN(f)&&f>=t&&f<=r)return f}return A}),[o,s]=Z.useState(!1),g=Z.useRef(0),l=Z.useRef(0),I=Z.useRef(n),C=Z.useCallback(h=>{I.current=h,a(h)},[]),E=Z.useCallback(h=>{h.preventDefault(),g.current=h.clientX,l.current=I.current,s(!0)},[]),u=Z.useCallback(h=>{h.preventDefault(),g.current=h.touches[0].clientX,l.current=I.current,s(!0)},[]);Z.useEffect(()=>{if(!o)return;const h=m=>"touches"in m?m.touches[0]?.clientX??m.changedTouches[0]?.clientX??0:m.clientX,f=m=>{const w=h(m),v=i==="right"?g.current-w:w-g.current;C(Math.min(r,Math.max(t,l.current+v)))},p=()=>{s(!1),Je.setItem(e,String(I.current))};return document.addEventListener("mousemove",f),document.addEventListener("mouseup",p),document.addEventListener("touchmove",f,{passive:!1}),document.addEventListener("touchend",p),document.addEventListener("touchcancel",p),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p),document.removeEventListener("touchmove",f),document.removeEventListener("touchend",p),document.removeEventListener("touchcancel",p)}},[o,t,r,e,i,C]);const B=Z.useCallback(()=>{C(A),Je.setItem(e,String(A))},[A,e,C]);return{width:n,isDragging:o,handleProps:{isDragging:o,onMouseDown:E,onTouchStart:u,onDoubleClick:B}}}const EAA=({isDragging:e,onMouseDown:A,onTouchStart:t,onDoubleClick:r,className:i,side:n})=>D.jsxs("div",{className:`relative w-0 cursor-col-resize flex-shrink-0 group z-10${i?` ${i}`:""}`,children:[D.jsx("div",{className:`absolute inset-y-0 -left-0.5 -right-0.5 transition-colors ${e?"bg-primary/50":"group-hover:bg-border"}`}),D.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:r})]});function T_A(){const e=Z.useRef(null),[A,t]=Z.useState(null),r=Z.useCallback(i=>{const n=i;e.current=n,t(n)},[]);return{ref:e,viewport:A,onViewportReady:r}}const L_A=({className:e,panelClassName:A,renderTrigger:t,children:r})=>{const[i,n]=Z.useState(!1),a=Z.useRef(null);return Z.useEffect(()=>{if(!i)return;const o=g=>{a.current&&!a.current.contains(g.target)&&n(!1)},s=g=>{g.key==="Escape"&&n(!1)};return document.addEventListener("pointerdown",o),document.addEventListener("keydown",s),()=>{document.removeEventListener("pointerdown",o),document.removeEventListener("keydown",s)}},[i]),D.jsxs("div",{ref:a,className:e?`relative ${e}`:"relative",children:[t({isOpen:i,toggleMenu:()=>n(o=>!o)}),i&&D.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:r({closeMenu:()=>n(!1)})})]})},dl=({onClick:e,icon:A,label:t,subtitle:r,badge:i})=>D.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:[D.jsx("span",{className:"text-muted-foreground",children:A}),r?D.jsxs("span",{className:"flex flex-1 flex-col gap-0.5",children:[D.jsx("span",{children:t}),D.jsx("span",{className:"text-[10px] text-muted-foreground",children:r})]}):D.jsx("span",{className:"flex-1",children:t}),i]}),Ww=()=>D.jsx("div",{className:"my-1 border-t border-border"}),uAA=({children:e})=>D.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:e}),F_A=({className:e="w-3.5 h-3.5"})=>D.jsxs("svg",{className:`${e} flex-shrink-0`,viewBox:"0 0 64 64",fill:"none",stroke:"currentColor",children:[D.jsx("path",{d:"M40.5 40.5L55 55",strokeWidth:7,strokeLinecap:"round"}),D.jsx("circle",{cx:"27",cy:"27",r:"20",strokeWidth:4}),D.jsx("path",{d:"M27 14L29.2 14.3L30.2 17.2L32.6 18.6L35.5 17.5L37.2 19.2L36.1 22.1L37.5 24.5L40.4 25.5L40.7 27.7L40.4 29.9L37.5 30.9L36.1 33.3L37.2 36.2L35.5 37.9L32.6 36.8L30.2 38.2L29.2 41.1L27 41.4L24.8 41.1L23.8 38.2L21.4 36.8L18.5 37.9L16.8 36.2L17.9 33.3L16.5 30.9L13.6 29.9L13.3 27.7L13.6 25.5L16.5 24.5L17.9 22.1L16.8 19.2L18.5 17.5L21.4 18.6L23.8 17.2L24.8 14.3Z",strokeWidth:1.5,strokeLinejoin:"round"}),D.jsx("circle",{cx:"27",cy:"27.7",r:"7",strokeWidth:1.5})]}),G_A=({appVersion:e,onOpenSettings:A,onOpenExport:t,onCopyAgentInstructions:r,onDownloadAnnotations:i,onPrint:n,onCopyShareLink:a,onOpenImport:o,onSaveToObsidian:s,onSaveToBear:g,onSaveToOctarine:l,sharingEnabled:I,isApiMode:C,agentInstructionsEnabled:E,obsidianConfigured:u,bearConfigured:B,octarineConfigured:h})=>{const{theme:f,setTheme:p}=FBA(),m=C&&(u||B||h);return D.jsx(L_A,{renderTrigger:({isOpen:w,toggleMenu:v})=>D.jsxs("button",{onClick:v,className:`relative flex items-center gap-1.5 p-1.5 md:px-2.5 md:py-1 rounded-md text-xs font-medium transition-colors ${w?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:"Options","aria-label":"Options","aria-expanded":w,children:[w?D.jsx(U_A,{}):D.jsx(O_A,{}),D.jsx("span",{className:"hidden md:inline",children:"Options"})]}),children:({closeMenu:w})=>D.jsxs(D.Fragment,{children:[D.jsxs("div",{className:"px-3 py-2 space-y-1.5",children:[D.jsx(uAA,{children:"Theme"}),D.jsx("div",{className:"flex items-center gap-1 rounded-lg bg-muted/50 p-0.5",children:["light","dark","system"].map(v=>D.jsxs("button",{onClick:()=>{w(),p(v)},className:`flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1 text-[11px] font-medium transition-colors ${f===v?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[v==="light"?D.jsx(MhA,{}):v==="dark"?D.jsx(khA,{}):D.jsx(xhA,{}),D.jsx("span",{className:"capitalize",children:v})]},v))})]}),D.jsx(Ww,{}),D.jsx(dl,{onClick:()=>{w(),A()},icon:D.jsx(K_A,{}),label:"Settings"}),D.jsx(dl,{onClick:()=>{w(),t()},icon:D.jsx(Y_A,{}),label:"Export"}),E&&D.jsx(dl,{onClick:()=>{w(),r()},icon:D.jsx(F_A,{}),label:"Agent Instructions",subtitle:"Copy agent instructions for external annotations"}),D.jsx(Ww,{}),D.jsx(dl,{onClick:()=>{w(),i()},icon:D.jsx(P_A,{}),label:"Download Annotations"}),D.jsx(dl,{onClick:()=>{w(),n()},icon:D.jsx(H_A,{}),label:"Print / Save as PDF",subtitle:"Choose 'Save as PDF' in the print dialog"}),I&&D.jsx(dl,{onClick:()=>{w(),a()},icon:D.jsx(J_A,{}),label:"Copy Share Link"}),I&&D.jsx(dl,{onClick:()=>{w(),o()},icon:D.jsx(z_A,{}),label:"Import Review"}),m&&D.jsxs(D.Fragment,{children:[D.jsx(Ww,{}),u&&D.jsx(dl,{onClick:()=>{w(),s()},icon:D.jsx(f3,{}),label:"Save to Obsidian"}),B&&D.jsx(dl,{onClick:()=>{w(),g()},icon:D.jsx(f3,{}),label:"Save to Bear"}),h&&D.jsx(dl,{onClick:()=>{w(),l()},icon:D.jsx(f3,{}),label:"Save to Octarine"})]}),D.jsx(Ww,{}),D.jsxs("div",{className:"px-3 py-2 space-y-2",children:[D.jsxs("div",{className:"flex items-center justify-between gap-3",children:[D.jsx(uAA,{children:"Plannotator"}),D.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground/70",children:["v",e]})]}),D.jsxs("div",{className:"flex flex-col items-start gap-1 text-[11px]",children:[D.jsx("a",{href:"https://github.com/backnotprop/plannotator/releases",target:"_blank",rel:"noopener noreferrer",onClick:w,className:"text-muted-foreground hover:text-foreground transition-colors",children:"Release notes"}),D.jsx("a",{href:"https://github.com/backnotprop/plannotator",target:"_blank",rel:"noopener noreferrer",onClick:w,className:"text-muted-foreground hover:text-foreground transition-colors",children:"Project repo"})]})]})]})})},O_A=()=>D.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})}),U_A=()=>D.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:D.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}),K_A=()=>D.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[D.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"}),D.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),Y_A=()=>D.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.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"})}),P_A=()=>D.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.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"})}),H_A=()=>D.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.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"})}),J_A=()=>D.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.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"})}),z_A=()=>D.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4M10 17l5-5-5-5M15 12H3"})}),f3=()=>D.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),q_A=({isOpen:e,onComplete:A})=>{const[t,r]=Z.useState("acceptEdits");if(!e)return null;const i=()=>{ShA(t),A(t)};return lo.createPortal(D.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-background/90 backdrop-blur-sm p-4",children:D.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-lg shadow-2xl",children:[D.jsxs("div",{className:"p-5 border-b border-border",children:[D.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[D.jsx("div",{className:"p-1.5 rounded-lg bg-primary/15",children:D.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:D.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"})})}),D.jsx("h3",{className:"font-semibold text-base",children:"New: Permission Mode Preservation"})]}),D.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."}),D.jsxs("p",{className:"text-xs text-muted-foreground/70 mt-1",children:["Requires Claude Code 2.1.7 or later. Run ",D.jsx("code",{className:"bg-muted px-1 rounded",children:"claude update"})," to update."]})]}),D.jsx("div",{className:"p-4 space-y-2",children:XK.map(n=>D.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:[D.jsx("input",{type:"radio",name:"permissionMode",value:n.value,checked:t===n.value,onChange:()=>r(n.value),className:"mt-0.5 accent-primary"}),D.jsxs("div",{className:"flex-1",children:[D.jsx("div",{className:"text-sm font-medium",children:n.label}),D.jsx("div",{className:"text-xs text-muted-foreground",children:n.description})]})]},n.value))}),D.jsxs("div",{className:"p-4 border-t border-border flex justify-between items-center",children:[D.jsx("p",{className:"text-xs text-muted-foreground",children:"You can change this later in Settings."}),D.jsx("button",{onClick:i,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 W_A(e){const[A,t]=Z.useState(e),[r,i]=Z.useState("toc"),n=Z.useCallback(s=>{t(!0),s&&i(s)},[]),a=Z.useCallback(()=>{t(!1)},[]),o=Z.useCallback(s=>{A?r===s?t(!1):i(s):(t(!0),i(s))},[A,r]);return{isOpen:A,activeTab:r,open:n,close:a,toggleTab:o}}class zhA{diff(A,t,r={}){let i;typeof r=="function"?(i=r,r={}):"callback"in r&&(i=r.callback);const n=this.castInput(A,r),a=this.castInput(t,r),o=this.removeEmpty(this.tokenize(n,r)),s=this.removeEmpty(this.tokenize(a,r));return this.diffWithOptionsObj(o,s,r,i)}diffWithOptionsObj(A,t,r,i){var n;const a=p=>{if(p=this.postProcess(p,r),i){setTimeout(function(){i(p)},0);return}else return p},o=t.length,s=A.length;let g=1,l=o+s;r.maxEditLength!=null&&(l=Math.min(l,r.maxEditLength));const I=(n=r.timeout)!==null&&n!==void 0?n:1/0,C=Date.now()+I,E=[{oldPos:-1,lastComponent:void 0}];let u=this.extractCommon(E[0],t,A,0,r);if(E[0].oldPos+1>=s&&u+1>=o)return a(this.buildValues(E[0].lastComponent,t,A));let B=-1/0,h=1/0;const f=()=>{for(let p=Math.max(B,-g);p<=Math.min(h,g);p+=2){let m;const w=E[p-1],v=E[p+1];w&&(E[p-1]=void 0);let M=!1;if(v){const R=v.oldPos-p;M=v&&0<=R&&R<o}const b=w&&w.oldPos+1<s;if(!M&&!b){E[p]=void 0;continue}if(!b||M&&w.oldPos<v.oldPos?m=this.addToPath(v,!0,!1,0,r):m=this.addToPath(w,!1,!0,1,r),u=this.extractCommon(m,t,A,p,r),m.oldPos+1>=s&&u+1>=o)return a(this.buildValues(m.lastComponent,t,A))||!0;E[p]=m,m.oldPos+1>=s&&(h=Math.min(h,p-1)),u+1>=o&&(B=Math.max(B,p+1))}g++};if(i)(function p(){setTimeout(function(){if(g>l||Date.now()>C)return i(void 0);f()||p()},0)})();else for(;g<=l&&Date.now()<=C;){const p=f();if(p)return p}}addToPath(A,t,r,i,n){const a=A.lastComponent;return a&&!n.oneChangePerToken&&a.added===t&&a.removed===r?{oldPos:A.oldPos+i,lastComponent:{count:a.count+1,added:t,removed:r,previousComponent:a.previousComponent}}:{oldPos:A.oldPos+i,lastComponent:{count:1,added:t,removed:r,previousComponent:a}}}extractCommon(A,t,r,i,n){const a=t.length,o=r.length;let s=A.oldPos,g=s-i,l=0;for(;g+1<a&&s+1<o&&this.equals(r[s+1],t[g+1],n);)g++,s++,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=s,g}equals(A,t,r){return r.comparator?r.comparator(A,t):A===t||!!r.ignoreCase&&A.toLowerCase()===t.toLowerCase()}removeEmpty(A){const t=[];for(let r=0;r<A.length;r++)A[r]&&t.push(A[r]);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,r){const i=[];let n;for(;A;)i.push(A),n=A.previousComponent,delete A.previousComponent,A=n;i.reverse();const a=i.length;let o=0,s=0,g=0;for(;o<a;o++){const l=i[o];if(l.removed)l.value=this.join(r.slice(g,g+l.count)),g+=l.count;else{if(!l.added&&this.useLongestToken){let I=t.slice(s,s+l.count);I=I.map(function(C,E){const u=r[g+E];return u.length>C.length?u:C}),l.value=this.join(I)}else l.value=this.join(t.slice(s,s+l.count));s+=l.count,l.added||(g+=l.count)}}return i}}const dAA="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";class V_A extends zhA{tokenize(A){const t=new RegExp(`(\\r?\\n)|[${dAA}]+|[^\\S\\n\\r]+|[^${dAA}]`,"ug");return A.match(t)||[]}}const Z_A=new V_A;function j_A(e,A,t){return Z_A.diff(e,A,t)}class __A extends zhA{constructor(){super(...arguments),this.tokenize=AXA}equals(A,t,r){return r.ignoreWhitespace?((!r.newlineIsToken||!A.includes(`
654
+ `).find(tA=>tA.startsWith("#")),$=j?j.replace(/^#+\s*/,"").trim():"Unknown Plan",X=SS(z.a,z.d,z.s);if(X.length===0)return{success:!0,count:0,planTitle:$,error:"No annotations found in share link"};const gA=X.filter(tA=>!A.some(hA=>hA.originalText===tA.originalText&&hA.type===tA.type&&hA.text===tA.text));if(gA.length>0&&(i(tA=>{const hA=X.filter(oA=>!tA.some(sA=>sA.originalText===oA.originalText&&sA.type===oA.type&&sA.text===oA.text));if(hA.length===0)return tA;const rA=[...tA,...hA];return R(rA),rA}),z.g?.length)){const tA=yh(z.g)??[];n(hA=>{const rA=new Set(hA.map(sA=>sA.path)),oA=tA.filter(sA=>!rA.has(sA.path));return oA.length>0?[...hA,...oA]:hA}),L(tA)}return{success:!0,count:gA.length,planTitle:$}}catch(z){return{success:!1,count:0,planTitle:"",error:z instanceof Error?z.message:"Failed to decompress share URL"}}},[A,t,i,n,s]);return{isSharedSession:g,isLoadingShared:I,shareUrl:E,shareUrlSize:B,shortShareUrl:f,isGeneratingShortUrl:m,shortUrlError:v,pendingSharedAnnotations:b,sharedGlobalAttachments:N,clearPendingSharedAnnotations:P,refreshShareUrl:G,generateShortUrl:F,importFromShareUrl:K,shareLoadError:T,clearShareLoadError:x}}var bS=(e=>(e.Approve="approve",e.Feedback="feedback",e))(bS||{});function c_A(e=window.location){const A=new URLSearchParams(e.search);let t=A.get("cb"),r=A.get("ct");if(!t||!r){const i=e.hash.indexOf("?");if(i!==-1){const n=new URLSearchParams(e.hash.slice(i+1));t=t??n.get("cb"),r=r??n.get("ct")}}if(!t||!r)return null;try{const{protocol:i}=new URL(t);if(i!=="https:"&&i!=="http:")return null}catch{return null}return{callbackUrl:t,token:r}}async function I_A(e,A,t){const r=e==="approve"?"Plan approved! The bot will proceed to implementation.":"Feedback sent! The bot will re-plan with your annotations.";try{const i=await fetch(A.callbackUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,token:A.token,annotated_url:t})});return i.ok?{type:"success",message:r}:{type:"error",message:i.status===401?"Plan link expired — request a new one from the bot.":"Callback failed."}}catch{return{type:"error",message:"Callback failed."}}}function C_A(e,A,t){const[r,i]=Z.useState(null),n=Z.useRef(null);return Z.useEffect(()=>{const a=t??e.current;if(!a)return;const o=a.querySelectorAll('[data-block-type="heading"]');if(o.length===0)return;const s=new Map;return n.current=new IntersectionObserver(g=>{g.forEach(C=>{s.set(C.target,C.isIntersecting)});let l=null,I=1/0;for(const[C,E]of s)if(E){const u=C.getBoundingClientRect();u.top<I&&(I=u.top,l=C)}if(l){const C=l.getAttribute("data-block-id");C&&i(C)}},{root:a,rootMargin:"-80px 0px -80% 0px",threshold:[0,.1,.5,1]}),o.forEach(g=>{n.current?.observe(g)}),()=>{n.current?.disconnect()}},[e,A,t]),r}function cAA(e){window.close(),setTimeout(()=>{window.closed||e()},300)}function E_A(e){const[A,t]=Z.useState({phase:"idle"});Z.useEffect(()=>{if(!e)return;const i=CgA();i==="0"?(cAA(()=>t({phase:"closeFailed"})),t({phase:"closed"})):t(i!=="off"?{phase:"counting",remaining:Number(i)}:{phase:"prompt"})},[e]),Z.useEffect(()=>{if(A.phase!=="counting")return;if(A.remaining<=0){cAA(()=>t({phase:"closeFailed"}));return}const i=setTimeout(()=>t(n=>n.phase==="counting"?{phase:"counting",remaining:n.remaining-1}:n),1e3);return()=>clearTimeout(i)},[A]);const r=Z.useCallback(()=>{EgA("3"),t({phase:"counting",remaining:3})},[]);return{state:A,enableAndStart:r}}const u_A=()=>D.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:D.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),d_A=()=>D.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:D.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 B_A({submitted:e,title:A,subtitle:t,agentLabel:r}){const{state:i,enableAndStart:n}=E_A(!!e);if(!e)return null;const a=e==="approved";return D.jsx("div",{className:"fixed inset-0 z-[100] bg-background flex items-center justify-center",children:D.jsxs("div",{className:"text-center space-y-6 max-w-md px-8",children:[D.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?D.jsx(u_A,{}):D.jsx(d_A,{})}),D.jsxs("div",{className:"space-y-2",children:[D.jsx("h2",{className:"text-xl font-semibold text-foreground",children:A}),D.jsx("p",{className:"text-muted-foreground",children:t})]}),D.jsx("div",{className:"pt-4 border-t border-border space-y-2",children:i.phase==="counting"?D.jsxs(D.Fragment,{children:[D.jsxs("p",{className:"text-sm text-muted-foreground",children:["This tab will close in ",D.jsx("span",{className:"text-foreground font-medium",children:i.remaining})," second",i.remaining!==1?"s":"","..."]}),D.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change this in Settings."})]}):i.phase==="closeFailed"?D.jsxs(D.Fragment,{children:[D.jsx("p",{className:"text-sm text-muted-foreground",children:"Could not close this tab automatically. Please close it manually."}),D.jsxs("p",{className:"text-xs text-muted-foreground/60",children:["Auto-close works when the tab is opened by ",r,"."]})]}):D.jsxs(D.Fragment,{children:[D.jsxs("p",{className:"text-sm text-muted-foreground",children:["You can close this tab and return to ",D.jsx("span",{className:"text-foreground font-medium",children:r}),"."]}),i.phase==="prompt"?D.jsxs(D.Fragment,{children:[D.jsxs("label",{className:"flex items-center justify-center gap-2 cursor-pointer group",children:[D.jsx("input",{type:"checkbox",checked:!1,onChange:n,className:"accent-primary"}),D.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-foreground transition-colors",children:"Auto-close this tab after 3 seconds"})]}),D.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change the delay in Settings."})]}):D.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Your response has been sent."})]})})]})})}const h_A="https://api.github.com/repos/backnotprop/plannotator/releases/latest",IAA={"0.5.0":{title:"Code Review is here!",description:"Review git diffs with inline annotations. Run /plannotator-review to try it."}};function Q_A(e,A){const t=n=>n.replace(/^v/,""),r=t(e).split(".").map(Number),i=t(A).split(".").map(Number);for(let n=0;n<Math.max(r.length,i.length);n++){const a=r[n]||0,o=i[n]||0;if(o>a)return!0;if(o<a)return!1}return!1}function f_A(){const[e,A]=Z.useState(null);return Z.useEffect(()=>{(async()=>{try{const r="0.19.3",n=new URLSearchParams(window.location.search).get("preview-update");if(n){const C=n.replace(/^v/,"");A({currentVersion:r,latestVersion:n,updateAvailable:!0,releaseUrl:`https://github.com/backnotprop/plannotator/releases/tag/v${C}`,featureHighlight:IAA[C]});return}const a=await fetch(h_A);if(!a.ok)return;const o=await a.json(),s=o.tag_name,g=Q_A(r,s),l=s.replace(/^v/,""),I=IAA[l];A({currentVersion:r,latestVersion:s,updateAvailable:g,releaseUrl:o.html_url,featureHighlight:I})}catch(r){console.debug("Update check failed:",r)}})()},[]),e}const p_A="pi install npm:@plannotator/pi-extension";function m_A(e){return GLA&&!e?'powershell -c "irm https://plannotator.ai/install.ps1 | iex"':"curl -fsSL https://plannotator.ai/install.sh | bash"}const y_A=({origin:e,isWSL:A=!1})=>{const t=f_A(),[r,i]=Z.useState(!1),[n,a]=Z.useState(!1),g=new URLSearchParams(window.location.search).get("preview-origin")||e,l=g==="pi",I=g==="opencode",C=l?p_A:m_A(A);if(!t?.updateAvailable||n)return null;const E=async()=>{try{await navigator.clipboard.writeText(C),i(!0),setTimeout(()=>i(!1),2e3)}catch(B){console.error("Failed to copy:",B)}};return t.featureHighlight?D.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:D.jsxs("div",{className:"bg-card border border-primary/30 rounded-xl shadow-2xl overflow-hidden",children:[D.jsx("div",{className:"bg-gradient-to-r from-primary/20 to-primary/5 px-5 py-4 border-b border-border/50",children:D.jsxs("div",{className:"flex items-start justify-between gap-3",children:[D.jsxs("div",{className:"flex items-center gap-3",children:[D.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-primary/20 flex items-center justify-center",children:D.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.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"})})}),D.jsxs("div",{children:[D.jsx("h4",{className:"text-base font-semibold text-foreground",children:t.featureHighlight.title}),D.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["New in ",t.latestVersion]})]})]}),D.jsx("button",{onClick:()=>a(!0),className:"text-muted-foreground hover:text-foreground transition-colors p-1",children:D.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),D.jsxs("div",{className:"px-5 py-4",children:[D.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed",children:t.featureHighlight.description}),D.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:["You have ",t.currentVersion]}),I&&D.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install script, then restart OpenCode."}),l&&D.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install command, then restart Pi."}),D.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[D.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:r?"Copied!":"Copy install command"}),D.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"})]})]})]})}):D.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:D.jsx("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4",children:D.jsxs("div",{className:"flex items-start gap-3",children:[D.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center",children:D.jsx("svg",{className:"w-4 h-4 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.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"})})}),D.jsxs("div",{className:"flex-1 min-w-0",children:[D.jsxs("div",{className:"flex items-center justify-between gap-2",children:[D.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Update available"}),D.jsx("button",{onClick:()=>a(!0),className:"text-muted-foreground hover:text-foreground transition-colors",children:D.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),D.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[t.latestVersion," is available (you have ",t.currentVersion,")"]}),D.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[D.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:r?"Copied!":"Copy install command"}),D.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"})]})]})]})})})},HhA="plannotator-editor-mode",D_A="selection";function w_A(){const e=Je.getItem(HhA);return e==="selection"||e==="comment"||e==="redline"||e==="quickLabel"?e:D_A}function v_A(e){Je.setItem(HhA,e)}const JhA="plannotator-input-method",S_A="drag";function b_A(){const e=Je.getItem(JhA);return e==="drag"||e==="pinpoint"?e:S_A}function R_A(e){Je.setItem(JhA,e)}const N_A=300,M_A=300;function k_A(e,A){const t=Z.useRef("idle"),r=Z.useRef(0),i=Z.useRef(void 0),n=Z.useRef(e);Z.useEffect(()=>{t.current==="idle"&&(n.current=e)},[e]);const a=Z.useCallback(o=>o==="drag"?"pinpoint":"drag",[]);Z.useEffect(()=>{const o=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,r.current=Date.now(),t.current="held",A(a(e))):t.current==="tapped"&&(clearTimeout(i.current),t.current="idle",n.current=a(n.current)))},s=g=>{g.key==="Alt"&&t.current==="held"&&(Date.now()-r.current>=M_A?(A(n.current),t.current="idle"):(t.current="tapped",i.current=setTimeout(()=>{t.current==="tapped"&&(A(n.current),t.current="idle")},N_A)))};return window.addEventListener("keydown",o),window.addEventListener("keyup",s),()=>{clearTimeout(i.current),window.removeEventListener("keydown",o),window.removeEventListener("keyup",s)}},[e,A,a])}function x_A(){Z.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 CAA({storageKey:e,defaultWidth:A=288,minWidth:t=200,maxWidth:r=600,side:i="right"}){const[n,a]=Z.useState(()=>{const h=Je.getItem(e);if(h){const f=Number(h);if(!Number.isNaN(f)&&f>=t&&f<=r)return f}return A}),[o,s]=Z.useState(!1),g=Z.useRef(0),l=Z.useRef(0),I=Z.useRef(n),C=Z.useCallback(h=>{I.current=h,a(h)},[]),E=Z.useCallback(h=>{h.preventDefault(),g.current=h.clientX,l.current=I.current,s(!0)},[]),u=Z.useCallback(h=>{h.preventDefault(),g.current=h.touches[0].clientX,l.current=I.current,s(!0)},[]);Z.useEffect(()=>{if(!o)return;const h=m=>"touches"in m?m.touches[0]?.clientX??m.changedTouches[0]?.clientX??0:m.clientX,f=m=>{const w=h(m),v=i==="right"?g.current-w:w-g.current;C(Math.min(r,Math.max(t,l.current+v)))},p=()=>{s(!1),Je.setItem(e,String(I.current))};return document.addEventListener("mousemove",f),document.addEventListener("mouseup",p),document.addEventListener("touchmove",f,{passive:!1}),document.addEventListener("touchend",p),document.addEventListener("touchcancel",p),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p),document.removeEventListener("touchmove",f),document.removeEventListener("touchend",p),document.removeEventListener("touchcancel",p)}},[o,t,r,e,i,C]);const B=Z.useCallback(()=>{C(A),Je.setItem(e,String(A))},[A,e,C]);return{width:n,isDragging:o,handleProps:{isDragging:o,onMouseDown:E,onTouchStart:u,onDoubleClick:B}}}const EAA=({isDragging:e,onMouseDown:A,onTouchStart:t,onDoubleClick:r,className:i,side:n})=>D.jsxs("div",{className:`relative w-0 cursor-col-resize flex-shrink-0 group z-10${i?` ${i}`:""}`,children:[D.jsx("div",{className:`absolute inset-y-0 -left-0.5 -right-0.5 transition-colors ${e?"bg-primary/50":"group-hover:bg-border"}`}),D.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:r})]});function T_A(){const e=Z.useRef(null),[A,t]=Z.useState(null),r=Z.useCallback(i=>{const n=i;e.current=n,t(n)},[]);return{ref:e,viewport:A,onViewportReady:r}}const L_A=({className:e,panelClassName:A,renderTrigger:t,children:r})=>{const[i,n]=Z.useState(!1),a=Z.useRef(null);return Z.useEffect(()=>{if(!i)return;const o=g=>{a.current&&!a.current.contains(g.target)&&n(!1)},s=g=>{g.key==="Escape"&&n(!1)};return document.addEventListener("pointerdown",o),document.addEventListener("keydown",s),()=>{document.removeEventListener("pointerdown",o),document.removeEventListener("keydown",s)}},[i]),D.jsxs("div",{ref:a,className:e?`relative ${e}`:"relative",children:[t({isOpen:i,toggleMenu:()=>n(o=>!o)}),i&&D.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:r({closeMenu:()=>n(!1)})})]})},dl=({onClick:e,icon:A,label:t,subtitle:r,badge:i})=>D.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:[D.jsx("span",{className:"text-muted-foreground",children:A}),r?D.jsxs("span",{className:"flex flex-1 flex-col gap-0.5",children:[D.jsx("span",{children:t}),D.jsx("span",{className:"text-[10px] text-muted-foreground",children:r})]}):D.jsx("span",{className:"flex-1",children:t}),i]}),Ww=()=>D.jsx("div",{className:"my-1 border-t border-border"}),uAA=({children:e})=>D.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:e}),F_A=({className:e="w-3.5 h-3.5"})=>D.jsxs("svg",{className:`${e} flex-shrink-0`,viewBox:"0 0 64 64",fill:"none",stroke:"currentColor",children:[D.jsx("path",{d:"M40.5 40.5L55 55",strokeWidth:7,strokeLinecap:"round"}),D.jsx("circle",{cx:"27",cy:"27",r:"20",strokeWidth:4}),D.jsx("path",{d:"M27 14L29.2 14.3L30.2 17.2L32.6 18.6L35.5 17.5L37.2 19.2L36.1 22.1L37.5 24.5L40.4 25.5L40.7 27.7L40.4 29.9L37.5 30.9L36.1 33.3L37.2 36.2L35.5 37.9L32.6 36.8L30.2 38.2L29.2 41.1L27 41.4L24.8 41.1L23.8 38.2L21.4 36.8L18.5 37.9L16.8 36.2L17.9 33.3L16.5 30.9L13.6 29.9L13.3 27.7L13.6 25.5L16.5 24.5L17.9 22.1L16.8 19.2L18.5 17.5L21.4 18.6L23.8 17.2L24.8 14.3Z",strokeWidth:1.5,strokeLinejoin:"round"}),D.jsx("circle",{cx:"27",cy:"27.7",r:"7",strokeWidth:1.5})]}),G_A=({appVersion:e,onOpenSettings:A,onOpenExport:t,onCopyAgentInstructions:r,onDownloadAnnotations:i,onPrint:n,onCopyShareLink:a,onOpenImport:o,onSaveToObsidian:s,onSaveToBear:g,onSaveToOctarine:l,sharingEnabled:I,isApiMode:C,agentInstructionsEnabled:E,obsidianConfigured:u,bearConfigured:B,octarineConfigured:h})=>{const{theme:f,setTheme:p}=FBA(),m=C&&(u||B||h);return D.jsx(L_A,{renderTrigger:({isOpen:w,toggleMenu:v})=>D.jsxs("button",{onClick:v,className:`relative flex items-center gap-1.5 p-1.5 md:px-2.5 md:py-1 rounded-md text-xs font-medium transition-colors ${w?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:"Options","aria-label":"Options","aria-expanded":w,children:[w?D.jsx(U_A,{}):D.jsx(O_A,{}),D.jsx("span",{className:"hidden md:inline",children:"Options"})]}),children:({closeMenu:w})=>D.jsxs(D.Fragment,{children:[D.jsxs("div",{className:"px-3 py-2 space-y-1.5",children:[D.jsx(uAA,{children:"Theme"}),D.jsx("div",{className:"flex items-center gap-1 rounded-lg bg-muted/50 p-0.5",children:["light","dark","system"].map(v=>D.jsxs("button",{onClick:()=>{w(),p(v)},className:`flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1 text-[11px] font-medium transition-colors ${f===v?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[v==="light"?D.jsx(MhA,{}):v==="dark"?D.jsx(khA,{}):D.jsx(xhA,{}),D.jsx("span",{className:"capitalize",children:v})]},v))})]}),D.jsx(Ww,{}),D.jsx(dl,{onClick:()=>{w(),A()},icon:D.jsx(K_A,{}),label:"Settings"}),D.jsx(dl,{onClick:()=>{w(),t()},icon:D.jsx(Y_A,{}),label:"Export"}),E&&D.jsx(dl,{onClick:()=>{w(),r()},icon:D.jsx(F_A,{}),label:"Agent Instructions",subtitle:"Copy agent instructions for external annotations"}),D.jsx(Ww,{}),D.jsx(dl,{onClick:()=>{w(),i()},icon:D.jsx(P_A,{}),label:"Download Annotations"}),D.jsx(dl,{onClick:()=>{w(),n()},icon:D.jsx(H_A,{}),label:"Print / Save as PDF",subtitle:"Choose 'Save as PDF' in the print dialog"}),I&&D.jsx(dl,{onClick:()=>{w(),a()},icon:D.jsx(J_A,{}),label:"Copy Share Link"}),I&&D.jsx(dl,{onClick:()=>{w(),o()},icon:D.jsx(z_A,{}),label:"Import Review"}),m&&D.jsxs(D.Fragment,{children:[D.jsx(Ww,{}),u&&D.jsx(dl,{onClick:()=>{w(),s()},icon:D.jsx(f3,{}),label:"Save to Obsidian"}),B&&D.jsx(dl,{onClick:()=>{w(),g()},icon:D.jsx(f3,{}),label:"Save to Bear"}),h&&D.jsx(dl,{onClick:()=>{w(),l()},icon:D.jsx(f3,{}),label:"Save to Octarine"})]}),D.jsx(Ww,{}),D.jsxs("div",{className:"px-3 py-2 space-y-2",children:[D.jsxs("div",{className:"flex items-center justify-between gap-3",children:[D.jsx(uAA,{children:"Plannotator"}),D.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground/70",children:["v",e]})]}),D.jsxs("div",{className:"flex flex-col items-start gap-1 text-[11px]",children:[D.jsx("a",{href:"https://github.com/backnotprop/plannotator/releases",target:"_blank",rel:"noopener noreferrer",onClick:w,className:"text-muted-foreground hover:text-foreground transition-colors",children:"Release notes"}),D.jsx("a",{href:"https://github.com/backnotprop/plannotator",target:"_blank",rel:"noopener noreferrer",onClick:w,className:"text-muted-foreground hover:text-foreground transition-colors",children:"Project repo"})]})]})]})})},O_A=()=>D.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})}),U_A=()=>D.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:D.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}),K_A=()=>D.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[D.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"}),D.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),Y_A=()=>D.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.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"})}),P_A=()=>D.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.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"})}),H_A=()=>D.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.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"})}),J_A=()=>D.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.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"})}),z_A=()=>D.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4M10 17l5-5-5-5M15 12H3"})}),f3=()=>D.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),q_A=({isOpen:e,onComplete:A})=>{const[t,r]=Z.useState("acceptEdits");if(!e)return null;const i=()=>{ShA(t),A(t)};return lo.createPortal(D.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-background/90 backdrop-blur-sm p-4",children:D.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-lg shadow-2xl",children:[D.jsxs("div",{className:"p-5 border-b border-border",children:[D.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[D.jsx("div",{className:"p-1.5 rounded-lg bg-primary/15",children:D.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:D.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"})})}),D.jsx("h3",{className:"font-semibold text-base",children:"New: Permission Mode Preservation"})]}),D.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."}),D.jsxs("p",{className:"text-xs text-muted-foreground/70 mt-1",children:["Requires Claude Code 2.1.7 or later. Run ",D.jsx("code",{className:"bg-muted px-1 rounded",children:"claude update"})," to update."]})]}),D.jsx("div",{className:"p-4 space-y-2",children:XK.map(n=>D.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:[D.jsx("input",{type:"radio",name:"permissionMode",value:n.value,checked:t===n.value,onChange:()=>r(n.value),className:"mt-0.5 accent-primary"}),D.jsxs("div",{className:"flex-1",children:[D.jsx("div",{className:"text-sm font-medium",children:n.label}),D.jsx("div",{className:"text-xs text-muted-foreground",children:n.description})]})]},n.value))}),D.jsxs("div",{className:"p-4 border-t border-border flex justify-between items-center",children:[D.jsx("p",{className:"text-xs text-muted-foreground",children:"You can change this later in Settings."}),D.jsx("button",{onClick:i,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 W_A(e){const[A,t]=Z.useState(e),[r,i]=Z.useState("toc"),n=Z.useCallback(s=>{t(!0),s&&i(s)},[]),a=Z.useCallback(()=>{t(!1)},[]),o=Z.useCallback(s=>{A?r===s?t(!1):i(s):(t(!0),i(s))},[A,r]);return{isOpen:A,activeTab:r,open:n,close:a,toggleTab:o}}class zhA{diff(A,t,r={}){let i;typeof r=="function"?(i=r,r={}):"callback"in r&&(i=r.callback);const n=this.castInput(A,r),a=this.castInput(t,r),o=this.removeEmpty(this.tokenize(n,r)),s=this.removeEmpty(this.tokenize(a,r));return this.diffWithOptionsObj(o,s,r,i)}diffWithOptionsObj(A,t,r,i){var n;const a=p=>{if(p=this.postProcess(p,r),i){setTimeout(function(){i(p)},0);return}else return p},o=t.length,s=A.length;let g=1,l=o+s;r.maxEditLength!=null&&(l=Math.min(l,r.maxEditLength));const I=(n=r.timeout)!==null&&n!==void 0?n:1/0,C=Date.now()+I,E=[{oldPos:-1,lastComponent:void 0}];let u=this.extractCommon(E[0],t,A,0,r);if(E[0].oldPos+1>=s&&u+1>=o)return a(this.buildValues(E[0].lastComponent,t,A));let B=-1/0,h=1/0;const f=()=>{for(let p=Math.max(B,-g);p<=Math.min(h,g);p+=2){let m;const w=E[p-1],v=E[p+1];w&&(E[p-1]=void 0);let M=!1;if(v){const R=v.oldPos-p;M=v&&0<=R&&R<o}const b=w&&w.oldPos+1<s;if(!M&&!b){E[p]=void 0;continue}if(!b||M&&w.oldPos<v.oldPos?m=this.addToPath(v,!0,!1,0,r):m=this.addToPath(w,!1,!0,1,r),u=this.extractCommon(m,t,A,p,r),m.oldPos+1>=s&&u+1>=o)return a(this.buildValues(m.lastComponent,t,A))||!0;E[p]=m,m.oldPos+1>=s&&(h=Math.min(h,p-1)),u+1>=o&&(B=Math.max(B,p+1))}g++};if(i)(function p(){setTimeout(function(){if(g>l||Date.now()>C)return i(void 0);f()||p()},0)})();else for(;g<=l&&Date.now()<=C;){const p=f();if(p)return p}}addToPath(A,t,r,i,n){const a=A.lastComponent;return a&&!n.oneChangePerToken&&a.added===t&&a.removed===r?{oldPos:A.oldPos+i,lastComponent:{count:a.count+1,added:t,removed:r,previousComponent:a.previousComponent}}:{oldPos:A.oldPos+i,lastComponent:{count:1,added:t,removed:r,previousComponent:a}}}extractCommon(A,t,r,i,n){const a=t.length,o=r.length;let s=A.oldPos,g=s-i,l=0;for(;g+1<a&&s+1<o&&this.equals(r[s+1],t[g+1],n);)g++,s++,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=s,g}equals(A,t,r){return r.comparator?r.comparator(A,t):A===t||!!r.ignoreCase&&A.toLowerCase()===t.toLowerCase()}removeEmpty(A){const t=[];for(let r=0;r<A.length;r++)A[r]&&t.push(A[r]);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,r){const i=[];let n;for(;A;)i.push(A),n=A.previousComponent,delete A.previousComponent,A=n;i.reverse();const a=i.length;let o=0,s=0,g=0;for(;o<a;o++){const l=i[o];if(l.removed)l.value=this.join(r.slice(g,g+l.count)),g+=l.count;else{if(!l.added&&this.useLongestToken){let I=t.slice(s,s+l.count);I=I.map(function(C,E){const u=r[g+E];return u.length>C.length?u:C}),l.value=this.join(I)}else l.value=this.join(t.slice(s,s+l.count));s+=l.count,l.added||(g+=l.count)}}return i}}const dAA="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";class V_A extends zhA{tokenize(A){const t=new RegExp(`(\\r?\\n)|[${dAA}]+|[^\\S\\n\\r]+|[^${dAA}]`,"ug");return A.match(t)||[]}}const Z_A=new V_A;function j_A(e,A,t){return Z_A.diff(e,A,t)}class __A extends zhA{constructor(){super(...arguments),this.tokenize=AXA}equals(A,t,r){return r.ignoreWhitespace?((!r.newlineIsToken||!A.includes(`
655
655
  `))&&(A=A.trim()),(!r.newlineIsToken||!t.includes(`
656
656
  `))&&(t=t.trim())):r.ignoreNewlineAtEof&&!r.newlineIsToken&&(A.endsWith(`
657
657
  `)&&(A=A.slice(0,-1)),t.endsWith(`
@@ -1140,7 +1140,7 @@ digraph CollaborationStack {
1140
1140
  ---
1141
1141
 
1142
1142
  **Target:** Ship MVP in next sprint
1143
- `;function f$A(e){return!e.archiveMode&&!e.isPlanDiffActive}function p$A(e,A){const t=A?.restore!==!1;return A?.sidebarTab?{sidebarOpen:!0,sidebarTab:A.sidebarTab,panelOpen:A.panelOpen}:{sidebarOpen:t?e?.sidebarIsOpen??!1:!1,sidebarTab:t&&e?.sidebarIsOpen?e.sidebarTab:null,panelOpen:A?.panelOpen??(t?e?.panelOpen??!1:void 0)}}function m$A({blocks:e,annotations:A,addAnnotation:t,removeAnnotation:r}){const[i,n]=Z.useState(new Map),a=Z.useRef(e);a.current=e;const o=Z.useRef(A);o.current=A,Z.useEffect(()=>{if(i.size===0)return;const l=new Set(e.map(C=>C.id)),I=[...i.keys()].filter(C=>!l.has(C));I.length>0&&n(C=>{const E=new Map(C);return I.forEach(u=>E.delete(u)),E})},[e]);const s=Z.useCallback((l,I)=>{const C=a.current,E=o.current,u=C.find(h=>h.id===l);if(u&&I===u.checked)n(f=>{const p=new Map(f);return p.delete(l),p}),E.filter(f=>f.blockId===l&&f.id.startsWith("ann-checkbox-")).forEach(f=>r(f.id));else if(E.filter(f=>f.blockId===l&&f.id.startsWith("ann-checkbox-")).forEach(f=>r(f.id)),n(f=>{const p=new Map(f);return p.set(l,I),p}),u){const f=C.indexOf(u);let p="";for(let M=f-1;M>=0;M--)if(C[M].type==="heading"){p=C[M].content;break}const m=I?"Mark as completed":"Mark as not completed",w=p?` (under "${p}")`:` (line ${u.startLine})`,v={id:`ann-checkbox-${l}-${Date.now()}`,blockId:l,startOffset:0,endOffset:u.content.length,type:Er.COMMENT,text:`${m}${w}: ${u.content}`,originalText:u.content,createdA:Date.now()};t(v)}},[t,r]),g=Z.useCallback(l=>{n(I=>{const C=new Map(I);return C.delete(l),C})},[]);return{overrides:i,toggle:s,revertOverride:g}}const y$A=Q$A,D$A=()=>{const[e,A]=Z.useState(y$A),[t,r]=Z.useState([]),[i,n]=Z.useState(null),[a,o]=Z.useState([]),[s,g]=Z.useState(null),[l,I]=Z.useState(!1),[C,E]=Z.useState(!1),[u,B]=Z.useState(!1),[h,f]=Z.useState(!1),[p,m]=Z.useState(!1),[w,v]=Z.useState("close"),[M,b]=Z.useState(!1),[R,N]=Z.useState(""),[L,T]=Z.useState(()=>window.innerWidth>=768),[O,P]=Z.useState(!1),[x,U]=Z.useState(w_A),[G,F]=Z.useState(b_A),[K,H]=Z.useState(()=>Je.getItem("plannotator-tater-mode")==="true"),[z,Y]=Z.useState(()=>_K()),q=Z.useRef(null),[j,$]=Z.useState("full");Z.useLayoutEffect(()=>{const WA=q.current;if(!WA)return;const Ye=ht=>ht>=800?"full":ht>=680?"short":"icon";$(Ye(WA.getBoundingClientRect().width));const je=new ResizeObserver(([ht])=>{const sr=Ye(ht.contentRect.width);$(ri=>ri===sr?ri:sr)});return je.observe(WA),()=>je.disconnect()},[]);const[X,gA]=Z.useState(!1),[tA,hA]=Z.useState(null),[rA,oA]=Z.useState(),[sA,nA]=Z.useState(!1),[IA,cA]=Z.useState([]),[wA,dA]=Z.useState(!1),[YA,aA]=Z.useState(!1),[_A,bA]=Z.useState(null),[re,ae]=Z.useState(),[de,GA]=Z.useState(!1),[se,OA]=Z.useState(),[JA,Ce]=Z.useState(void 0),[LA,ee]=Z.useState(!0),[BA,SA]=Z.useState(!1),[_,yA]=Z.useState(!1),[fA,TA]=Z.useState(null),[EA,MA]=Z.useState(null),[PA,FA]=Z.useState(!1),[XA,Ae]=Z.useState("bypassPermissions"),[Be,vA]=Z.useState(!0),[HA,UA]=Z.useState(void 0),[ce,Le]=Z.useState(void 0),[Ne,iA]=Z.useState(null),[ue,Ie]=Z.useState(null),[VA,le]=Z.useState(null),De=Z.useRef(null),ke=Z.useRef(z.tocEnabled);Z.useEffect(()=>{document.title=Ne?`${Ne.display} · Plannotator`:"Plannotator"},[Ne]);const[Pe,lt]=Z.useState(),[We,Xe]=Z.useState(null),[It,mt]=Z.useState(!1),[Bt,Wt]=Z.useState("clean"),[Nr,ve]=Z.useState(null),[QA,$A]=Z.useState(null),we=RdA(),rt=Z.useRef(null),{ref:xt,viewport:At,onViewportReady:Vt}=T_A();x_A();const lr=CAA({storageKey:"plannotator-panel-width"}),ar=CAA({storageKey:"plannotator-toc-width",defaultWidth:240,minWidth:160,maxWidth:400,side:"left"}),Ge=lr.isDragging||ar.isDragging,ne=W_A(_K().tocEnabled),Te=Z.useCallback(WA=>{if(VA===null){WA?.sidebarTab&&ne.open(WA.sidebarTab),WA?.panelOpen===!0?T(!0):WA?.panelOpen===!1&&T(!1);return}const Ye=De.current,je=p$A(Ye,WA);le(null),De.current=null,je.sidebarOpen&&je.sidebarTab?ne.open(je.sidebarTab):ne.close(),je.panelOpen!==void 0&&T(je.panelOpen)},[VA,ne.close,ne.open]),xe=Z.useCallback(WA=>{if(VA!==null){Te({restore:!1,sidebarTab:WA,panelOpen:!1});return}ne.open(WA)},[Te,VA,ne.open]),be=Z.useCallback(WA=>{if(VA!==null){Te({restore:!1,sidebarTab:WA,panelOpen:!1});return}ne.toggleTab(WA)},[Te,VA,ne.toggleTab]),ut=Z.useCallback(()=>{if(VA!==null){Te({restore:!1,panelOpen:!0});return}T(WA=>!WA)},[Te,VA]);Z.useEffect(()=>{VA===null&&ke.current!==z.tocEnabled&&(ke.current=z.tocEnabled,z.tocEnabled?ne.open("toc"):ne.close())},[VA,ne.close,ne.open,z.tocEnabled]),Z.useEffect(()=>{ne.activeTab==="toc"&&It&&mt(!1)},[ne.activeTab]),Z.useEffect(()=>{if(!It)return;const WA=Ye=>{Ye.key==="Escape"&&mt(!1)};return document.addEventListener("keydown",WA),()=>document.removeEventListener("keydown",WA)},[It]);const kA=kXA(e,Nr,QA),li=Z.useMemo(()=>({...ne,open:xe,toggleTab:be}),[xe,ne.activeTab,ne.close,ne.isOpen,be]),xA=xXA({markdown:e,annotations:t,selectedAnnotationId:i,globalAttachments:IA,setMarkdown:A,setAnnotations:r,setSelectedAnnotationId:n,setGlobalAttachments:cA,viewerRef:rt,sidebar:li,sourceFilePath:se,sourceConverted:de}),st=OXA({markdown:e,viewerRef:rt,linkedDocHook:xA,setMarkdown:A,setAnnotations:r,setSelectedAnnotationId:n,setSubmitted:TA}),kn=Z.useMemo(()=>f$A({archiveMode:st.archiveMode,isPlanDiffActive:It}),[st.archiveMode,It]),qa=Z.useCallback(WA=>{kn&&(VA===null&&(De.current={sidebarIsOpen:ne.isOpen,sidebarTab:ne.activeTab,panelOpen:L}),le(WA),ne.close(),T(!1))},[kn,L,VA,ne.activeTab,ne.close,ne.isOpen]),Wa=Z.useCallback(WA=>{VA===WA?Te():qa(WA)},[qa,Te,VA]);Z.useEffect(()=>{!kn&&VA!==null&&Te()},[kn,Te,VA]);const cr=qXA(),Ur=Z.useMemo(()=>G$()?hC(BC()):"",[z]),Kr=Z.useMemo(()=>!!ue||nAA()||G$(),[ue,z]),xn=Z.useMemo(()=>{const WA=ue?[ue]:[],Ye=nAA()?u9().directories:[];return[...new Set([...WA,...Ye])]},[ue,z]);Z.useEffect(()=>{Kr||cr.setActiveFile(null)},[Kr]),Z.useEffect(()=>{Ur||cr.clearVaultDirs()},[Ur]),Z.useEffect(()=>{if(ne.activeTab==="files"&&Kr){if(xn.length>0){const WA=cr.dirs.filter(je=>!je.isVault).map(je=>je.path);(xn.some(je=>!WA.includes(je))||WA.some(je=>!xn.includes(je)))&&cr.fetchAll(xn)}Ur&&!cr.dirs.find(WA=>WA.isVault&&WA.path===Ur&&!WA.error)&&cr.addVaultDir(Ur)}},[ne.activeTab,Kr,xn,Ur]);const Ra=Li.useCallback((WA,Ye)=>{const ht=cr.dirs.find(sr=>sr.path===Ye)?.isVault?sr=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(Ye)}&path=${encodeURIComponent(sr)}`:sr=>`/api/doc?path=${encodeURIComponent(sr)}&base=${encodeURIComponent(Ye)}`;xA.open(WA,ht,"files"),cr.setActiveFile(WA)},[xA,cr]),Do=Li.useCallback(WA=>{if(cr.dirs.find(je=>je.path===cr.activeDirPath)?.isVault&&cr.activeDirPath)xA.open(WA,je=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(cr.activeDirPath)}&path=${encodeURIComponent(je)}`);else if(cr.activeFile&&cr.activeDirPath){const je=xA.filepath?.replace(/\/[^/]+$/,"")||cr.activeDirPath;xA.open(WA,ht=>`/api/doc?path=${encodeURIComponent(ht)}&base=${encodeURIComponent(je)}`)}else{const je=xA.filepath?xA.filepath.replace(/\/[^/]+$/,""):JA;je?xA.open(WA,ht=>`/api/doc?path=${encodeURIComponent(ht)}&base=${encodeURIComponent(je)}`):xA.open(WA)}},[cr.dirs,cr.activeDirPath,cr.activeFile,xA,JA]),hi=Li.useCallback(()=>{xA.back(),cr.setActiveFile(null),st.clearSelection()},[xA,cr,st]),Tn=Z.useMemo(()=>{const WA=new Map;for(const[Ye,je]of xA.getDocAnnotations()){const ht=je.annotations.length+je.globalAttachments.length;ht>0&&WA.set(Ye,ht)}return WA},[xA.getDocAnnotations,t,IA]),ci=Z.useMemo(()=>{const WA=cr.dirs.map(je=>je.path);if(WA.length===0)return Tn;const Ye=new Map;for(const[je,ht]of Tn)WA.some(sr=>je.startsWith(sr+"/"))&&Ye.set(je,ht);return Ye},[Tn,cr.dirs]),Qt=ci.size>0,Tt=Z.useMemo(()=>{const WA=xA.filepath;let Ye=0,je=0;for(const[ht,sr]of Tn)ht!==WA&&(Ye+=sr,je++);return Ye>0?{count:Ye,files:je}:void 0},[Tn,xA.filepath]),[Vr,rr]=Z.useState(),Ji=Li.useRef(),Qi=Li.useCallback(()=>{const WA=new Set(Tn.keys());WA.size!==0&&((!ne.isOpen||ne.activeTab!=="files")&&xe("files"),Ji.current&&clearTimeout(Ji.current),rr(void 0),requestAnimationFrame(()=>{rr(WA),Ji.current=setTimeout(()=>rr(void 0),1200)}))},[Tn,xe,ne,Qt]),Xn=_A==="folder"?"file list":_A==="file"?"file":_A==="message"?"message":"plan",Bn=Z.useMemo(()=>a.filter(WA=>WA.type==="heading").length,[a]),Ze=C_A(xt,Bn,At),{editorAnnotations:W,deleteEditorAnnotation:AA}=KXA(),{externalAnnotations:uA,updateExternalAnnotation:DA,deleteExternalAnnotation:KA}=HXA({enabled:X}),{reset:te}=JXA({viewerRef:rt,externalAnnotations:uA,enabled:X&&!xA.isActive&&!It,planKey:e}),oe=Z.useMemo(()=>uA.length===0?t:[...t.filter(Ye=>Ye.source?!uA.some(je=>je.source===Ye.source&&je.type===Ye.type&&je.originalText===Ye.originalText):!0),...uA],[t,uA]),Se=Z.useMemo(()=>oe.filter(WA=>!!WA.diffContext),[oe]),et=Z.useMemo(()=>oe.filter(WA=>!WA.diffContext),[oe]),Gt=Z.useMemo(()=>oe.length>0||W.length>0||xA.docAnnotationCount>0||IA.length>0,[oe.length,W.length,xA.docAnnotationCount,IA.length]),{isSharedSession:Nt,isLoadingShared:nr,shareUrl:Ht,shareUrlSize:bt,shortShareUrl:Ot,isGeneratingShortUrl:Ii,shortUrlError:$n,pendingSharedAnnotations:an,clearPendingSharedAnnotations:ti,generateShortUrl:on,importFromShareUrl:xs,shareLoadError:Ln,clearShareLoadError:gl}=l_A(e,oe,IA,A,r,cA,()=>{ee(!1)},HA,ce),{draftBanner:fi,restoreDraft:Ud,dismissDraft:vE}=GXA({annotations:oe,globalAttachments:IA,isApiMode:X,isSharedSession:Nt,submitted:!!fA}),Kd=Li.useCallback(()=>{const{annotations:WA,globalAttachments:Ye}=Ud();WA.length>0&&(r(WA),Ye.length>0&&cA(Ye),setTimeout(()=>{rt.current?.applySharedAnnotations(WA.filter(je=>!je.diffContext))},100))},[Ud]),{getAgentWarning:Yd}=NhA(tA);Z.useEffect(()=>{if(an&&an.length>0){const WA=setTimeout(()=>{rt.current?.clearAllHighlights(),rt.current?.applySharedAnnotations(an.filter(Ye=>!Ye.diffContext)),ti(),te()},100);return()=>clearTimeout(WA)}},[an,ti,te]);const ck=WA=>{H(WA),Je.setItem("plannotator-tater-mode",String(WA))},eD=WA=>{U(WA),v_A(WA)},XQ=WA=>{F(WA),R_A(WA)};k_A(G,XQ),Z.useEffect(()=>{nr||Nt||fetch("/api/plan").then(WA=>{if(!WA.ok)throw new Error("Not in API mode");return WA.json()}).then(WA=>{yn.init(WA.serverConfig),oA(WA.serverConfig?.gitUser),WA.mode==="archive"?(A(WA.plan||""),WA.archivePlans&&st.init(WA.archivePlans),st.fetchPlans(),vA(!1),ne.open("archive")):WA.mode==="annotate-folder"?A(""):WA.plan&&A(WA.plan),gA(!0),(WA.mode==="annotate"||WA.mode==="annotate-last"||WA.mode==="annotate-folder")&&(dA(!0),aA(WA.gate??!1)),WA.mode==="annotate-folder"&&ne.open("files"),WA.mode&&WA.mode!=="archive"&&bA(WA.mode==="annotate-last"?"message":WA.mode==="annotate-folder"?"folder":"file"),ae(WA.sourceInfo??void 0),GA(!!WA.sourceConverted),WA.filePath&&(Ce(WA.mode==="annotate-folder"?WA.filePath:WA.filePath.replace(/\/[^/]+$/,"")),WA.mode==="annotate"&&OA(WA.filePath)),WA.sharingEnabled!==void 0&&vA(WA.sharingEnabled),WA.shareBaseUrl&&UA(WA.shareBaseUrl),WA.pasteApiUrl&&Le(WA.pasteApiUrl),WA.repoInfo&&iA(WA.repoInfo),WA.projectRoot&&Ie(WA.projectRoot),WA.previousPlan!==void 0&&ve(WA.previousPlan),WA.versionInfo&&$A(WA.versionInfo),WA.origin&&(hA(WA.origin),WA.origin==="claude-code"&&vjA()&&FA(!0),Ae(vhA().mode)),WA.isWSL&&nA(!0)}).catch(()=>{gA(!1)}).finally(()=>ee(!1))},[nr,Nt]),Z.useEffect(()=>{const{frontmatter:WA}=AsA(e);g(WA),o(Am(e))},[e]);const SE=Z.useRef(!1),Pd=Z.useRef({}),Hd=Z.useRef(null);Z.useEffect(()=>{SE.current=!1,Pd.current={},Hd.current=null},[e]),Z.useEffect(()=>{if(!X||!e||Nt||wA||st.archiveMode||SE.current)return;const WA={},Ye=[],je=BC();if(je.autoSave&&je.enabled){const Mr=hC(je);Mr&&(WA.obsidian={vaultPath:Mr,folder:je.folder||"plannotator",plan:e,...je.filenameFormat&&{filenameFormat:je.filenameFormat},...je.filenameSeparator&&je.filenameSeparator!=="space"&&{filenameSeparator:je.filenameSeparator}},Ye.push("Obsidian"))}const ht=Eu();ht.autoSave&&ht.enabled&&(WA.bear={plan:e,customTags:ht.customTags,tagPosition:ht.tagPosition},Ye.push("Bear"));const sr=ph();if(sr.autoSave&&Jw()&&(WA.octarine={plan:e,workspace:sr.workspace,folder:sr.folder||"plannotator"},Ye.push("Octarine")),Ye.length===0)return;SE.current=!0;const ri=fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(WA)}).then(Mr=>Mr.json()).then(Mr=>{const ga={...WA.obsidian?{obsidian:!!Mr.results?.obsidian?.success}:{},...WA.bear?{bear:!!Mr.results?.bear?.success}:{},...WA.octarine?{octarine:!!Mr.results?.octarine?.success}:{}};Pd.current=ga;const Va=Ye.filter(nf=>!Mr.results?.[nf.toLowerCase()]?.success);return Va.length===0?Xe({type:"success",message:`Auto-saved to ${Ye.join(" & ")}`}):Xe({type:"error",message:`Auto-save failed for ${Va.join(" & ")}`}),ga}).catch(()=>(Pd.current={},Xe({type:"error",message:"Auto-save failed"}),{})).finally(()=>setTimeout(()=>Xe(null),3e3));Hd.current=ri},[X,e,Nt,wA]),Z.useEffect(()=>{const WA=Ye=>{const je=Ye.clipboardData?.items;if(je){for(const ht of je)if(ht.type.startsWith("image/")){Ye.preventDefault();const sr=ht.getAsFile();if(sr){const ri=m4(sr.name,IA.map(ga=>ga.name)),Mr=URL.createObjectURL(sr);MA({file:sr,blobUrl:Mr,initialName:ri})}break}}};return document.addEventListener("paste",WA),()=>document.removeEventListener("paste",WA)},[IA]);const Ik=async(WA,Ye,je)=>{if(EA)try{const ht=new FormData,sr=Ye?new File([WA],"annotated.png",{type:"image/png"}):EA.file;ht.append("file",sr);const ri=await fetch("/api/upload",{method:"POST",body:ht});if(ri.ok){const Mr=await ri.json();cA(ga=>[...ga,{path:Mr.path,name:je}])}}catch{}finally{URL.revokeObjectURL(EA.blobUrl),MA(null)}},Ck=()=>{EA&&(URL.revokeObjectURL(EA.blobUrl),MA(null))},Jd=async()=>{SA(!0);try{const WA=BC(),Ye=Eu(),je=ph(),ht=C9(),sr=Rb(),ri=Ye.autoSave&&Hd.current?await Hd.current:Pd.current,Mr={};tA==="claude-code"&&(Mr.permissionMode=XA);const ga=mjA(ht);ga&&(Mr.agentSwitch=ga),Mr.planSave={enabled:sr.enabled,...sr.customPath&&{customPath:sr.customPath}};const Va=hC(WA);WA.enabled&&Va&&(Mr.obsidian={vaultPath:Va,folder:WA.folder||"plannotator",plan:e,...WA.filenameFormat&&{filenameFormat:WA.filenameFormat},...WA.filenameSeparator&&WA.filenameSeparator!=="space"&&{filenameSeparator:WA.filenameSeparator}}),Ye.enabled&&!(Ye.autoSave&&ri.bear)&&(Mr.bear={plan:e,customTags:Ye.customTags,tagPosition:Ye.tagPosition}),Jw()&&(Mr.octarine={plan:e,workspace:je.workspace,folder:je.folder||"plannotator"});const nf=Array.from(xA.getDocAnnotations().values()).some(bE=>bE.annotations.length>0||bE.globalAttachments.length>0);(oe.length>0||IA.length>0||nf||W.length>0)&&(Mr.feedback=Ic),await fetch("/api/approve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Mr)}),TA("approved")}catch{SA(!1)}},$Q=async()=>{SA(!0);try{const WA=Rb();await fetch("/api/deny",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:Ic,planSave:{enabled:WA.enabled,...WA.customPath&&{customPath:WA.customPath}}})}),TA("denied")}catch{SA(!1)}},tD=async()=>{SA(!0);try{await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:Ic,annotations:oe})}),TA("denied")}catch{SA(!1)}},Af=async()=>{SA(!0);try{await fetch("/api/approve",{method:"POST"}),TA("approved")}catch{SA(!1)}},rD=Z.useCallback(async()=>{yA(!0);try{if((await fetch("/api/exit",{method:"POST"})).ok)TA("exited");else throw new Error("Failed to exit")}catch{yA(!1)}},[]);Z.useEffect(()=>{const WA=Ye=>{if(Ye.key!=="Enter"||!(Ye.metaKey||Ye.ctrlKey))return;const je=Ye.target?.tagName;if(je==="INPUT"||je==="TEXTAREA"||l||C||u||h||p||M||PA||EA||fA||BA||_||!X||xA.isActive)return;if(Ye.preventDefault(),wA){if(YA&&!Gt){Af();return}tD();return}const ht=xA.getDocAnnotations(),sr=Array.from(ht.values()).some(ri=>ri.annotations.length>0||ri.globalAttachments.length>0);if(oe.length===0&&W.length===0&&!sr){if(tA==="opencode"){const ri=Yd();if(ri){N(ri),b(!0);return}}Jd()}else $Q()};return window.addEventListener("keydown",WA),()=>window.removeEventListener("keydown",WA)},[l,C,u,h,p,M,PA,EA,fA,BA,_,X,xA.isActive,t.length,uA.length,wA,YA,Gt,tA,Yd]);const ef=WA=>{r(Ye=>[...Ye,WA]),n(WA.id),VA===null&&T(!0)},zd=Li.useCallback(WA=>{n(WA),WA&&we&&VA===null&&T(!0)},[we,VA]),iD=WA=>{rt.current?.removeHighlight(WA),r(Ye=>Ye.filter(je=>je.id!==WA)),i===WA&&n(null)},tf=m$A({blocks:a,annotations:t,addAnnotation:ef,removeAnnotation:iD}),Ek=WA=>{const Ye=oe.find(je=>je.id===WA);if(Ye?.source&&uA.some(je=>je.id===WA)){KA(WA),i===WA&&n(null);return}WA.startsWith("ann-checkbox-")&&Ye&&tf.revertOverride(Ye.blockId),iD(WA)},nD=(WA,Ye)=>{if(oe.find(ht=>ht.id===WA)?.source&&uA.some(ht=>ht.id===WA)){DA(WA,Ye);return}r(ht=>ht.map(sr=>sr.id===WA?{...sr,...Ye}:sr))},uk=(WA,Ye)=>{r(je=>je.map(ht=>ht.author===WA?{...ht,author:Ye}:ht))},dk=WA=>{cA(Ye=>[...Ye,WA])},Bk=WA=>{cA(Ye=>Ye.filter(je=>je.path!==WA))},hk=WA=>{},Ic=Z.useMemo(()=>{const WA=xA.getDocAnnotations(),Ye=Array.from(WA.values()).some(Mr=>Mr.annotations.length>0||Mr.globalAttachments.length>0),je=oe.length>0||IA.length>0,ht=W.length>0;if(!je&&!Ye&&!ht)return"User reviewed the document and has no feedback.";const sr=xA.isActive?WA.get(xA.filepath??"")?.isConverted??!1:de;let ri=je?_1A(a,oe,IA,_A==="message"?"Message Feedback":_A==="folder"?"Folder Feedback":_A==="file"?"File Feedback":"Plan Feedback",_A??"plan",{sourceConverted:sr}):"";if(Ye){const Mr=new Map(WA);for(const[ga,Va]of Mr)Va.markdown&&Mr.set(ga,{...Va,blocks:Am(Va.markdown)});ri+=X1A(Mr)}return ht&&(ri+=$1A(W)),ri},[a,oe,IA,xA.getDocAnnotations,W,de,_A,xA.isActive,xA.filepath]),qd=Li.useMemo(()=>c_A(),[]),Wd=Li.useCallback(async WA=>{if(!(!qd||BA||!Ht)){SA(!0);try{const Ye=await I_A(WA,qd,Ht);Ye&&(Xe(Ye),setTimeout(()=>Xe(null),4e3),Ye.type==="success"&&TA(WA===bS.Approve?"approved":"denied"))}finally{SA(!1)}}},[qd,BA,Ht]),Qk=Li.useCallback(()=>Wd(bS.Approve),[Wd]),fk=Li.useCallback(()=>Wd(bS.Feedback),[Wd]),Vd=()=>{const WA=new Blob([Ic],{type:"text/plain"}),Ye=URL.createObjectURL(WA),je=document.createElement("a");je.href=Ye,je.download="annotations.md",je.click(),URL.revokeObjectURL(Ye),Xe({type:"success",message:"Downloaded annotations"}),setTimeout(()=>Xe(null),3e3)},Ts=async WA=>{const Ye={};if(WA==="obsidian"){const ht=BC(),sr=hC(ht);sr&&(Ye.obsidian={vaultPath:sr,folder:ht.folder||"plannotator",plan:e,...ht.filenameFormat&&{filenameFormat:ht.filenameFormat},...ht.filenameSeparator&&ht.filenameSeparator!=="space"&&{filenameSeparator:ht.filenameSeparator}})}if(WA==="bear"){const ht=Eu();Ye.bear={plan:e,customTags:ht.customTags,tagPosition:ht.tagPosition}}if(WA==="octarine"){const ht=ph();Ye.octarine={plan:e,workspace:ht.workspace,folder:ht.folder||"plannotator"}}const je=WA==="obsidian"?"Obsidian":WA==="bear"?"Bear":"Octarine";try{const ri=(await(await fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ye)})).json()).results?.[WA];ri?.success?Xe({type:"success",message:`Saved to ${je}`}):Xe({type:"error",message:ri?.error||"Save failed"})}catch{Xe({type:"error",message:"Save failed"})}setTimeout(()=>Xe(null),3e3)},pk=async()=>{const WA=zXA(window.location.origin);try{await navigator.clipboard.writeText(WA),Xe({type:"success",message:"Agent instructions copied"})}catch{Xe({type:"error",message:"Failed to copy"})}setTimeout(()=>Xe(null),3e3)},aD=async()=>{try{await navigator.clipboard.writeText(Ht),Xe({type:"success",message:"Share link copied"})}catch{Xe({type:"error",message:"Failed to copy"})}setTimeout(()=>Xe(null),3e3)};Z.useEffect(()=>{const WA=Ye=>{if(Ye.key!=="s"||!(Ye.metaKey||Ye.ctrlKey))return;const je=Ye.target?.tagName;if(je==="INPUT"||je==="TEXTAREA"||l||u||h||p||M||PA||EA||fA||!X)return;Ye.preventDefault();const ht=RhA(),sr=F$(),ri=Eu().enabled,Mr=Jw();ht==="download"?Vd():ht==="obsidian"&&sr?Ts("obsidian"):ht==="bear"&&ri?Ts("bear"):ht==="octarine"&&Mr?Ts("octarine"):(lt("notes"),I(!0))};return window.addEventListener("keydown",WA),()=>window.removeEventListener("keydown",WA)},[l,u,h,p,M,PA,EA,fA,X,e,Ic]),Z.useEffect(()=>{const WA=Ye=>{if(Ye.key!=="p"||!(Ye.metaKey||Ye.ctrlKey))return;const je=Ye.target?.tagName;je==="INPUT"||je==="TEXTAREA"||l||u||h||p||M||PA||EA||fA||(Ye.preventDefault(),window.print())};return window.addEventListener("keydown",WA),()=>window.removeEventListener("keydown",WA)},[l,u,h,p,M,PA,EA,fA]);const fg=Z.useMemo(()=>q1A(tA),[tA]),rf=Z.useMemo(()=>({compact:832,default:1040,wide:1280})[z.planWidth]??832,[z.planWidth]),Cc=kn&&VA==="wide"?null:rf;return D.jsx(IVA,{defaultTheme:"dark",children:D.jsx(AjA,{delayDuration:900,skipDelayDuration:200,disableHoverableContent:!0,children:D.jsxs("div",{"data-print-region":"root",className:"h-screen flex flex-col bg-background overflow-hidden",children:[D.jsxs("header",{"data-app-header":"true",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:[D.jsx("div",{className:"flex items-center gap-2 md:gap-3",children:D.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:D.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Plannotator"})})}),D.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[qd&&!X&&Nt&&D.jsxs(D.Fragment,{children:[D.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"}),D.jsx(Q3,{onClick:fk,disabled:BA||!Ht,isLoading:BA,title:"Send feedback to bot"}),D.jsx(aAA,{onClick:Qk,disabled:BA||!Ht,isLoading:BA,title:"Approve design and notify bot"})]}),X&&!xA.isActive&&st.archiveMode&&D.jsxs(D.Fragment,{children:[D.jsxs("button",{onClick:st.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:[D.jsx("span",{className:"hidden md:inline",children:"Copy"}),D.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.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"})})]}),D.jsx("button",{onClick:st.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"})]}),X&&(!xA.isActive||wA)&&!st.archiveMode&&D.jsxs(D.Fragment,{children:[wA?D.jsxs(D.Fragment,{children:[D.jsx(r_A,{onClick:()=>{Gt?(v("close"),m(!0)):rD()},disabled:BA||_,isLoading:_}),Gt&&D.jsx(Q3,{onClick:tD,disabled:BA||_,isLoading:BA,label:"Send Annotations",title:"Send Annotations"})]}):D.jsx(Q3,{onClick:()=>{const WA=xA.getDocAnnotations(),Ye=Array.from(WA.values()).some(je=>je.annotations.length>0||je.globalAttachments.length>0);oe.length===0&&W.length===0&&!Ye?B(!0):$Q()},disabled:BA,isLoading:BA,label:"Send Feedback",title:"Send Feedback"}),(!wA||YA)&&D.jsxs("div",{className:"relative group/approve",children:[D.jsx(aAA,{onClick:()=>{if(wA){if(Gt){v("approve"),m(!0);return}Af();return}if(tA==="claude-code"&&oe.length>0){f(!0);return}if(tA==="opencode"){const WA=Yd();if(WA){N(WA),b(!0);return}}Jd()},disabled:BA||wA&&_,isLoading:BA,dimmed:!wA&&(tA==="claude-code"||tA==="gemini-cli")&&oe.length>0,title:wA?"Approve — no changes requested":void 0}),!wA&&(tA==="claude-code"||tA==="gemini-cli")&&oe.length>0&&D.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:[D.jsx("div",{className:"absolute bottom-full right-4 border-4 border-transparent border-b-border"}),D.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."]})]}),D.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"})]}),D.jsx("button",{onClick:ut,className:`p-1.5 rounded-md text-xs font-medium transition-all ${L?"bg-primary/15 text-primary":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:L?"Hide annotations":"Show annotations",children:D.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.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"})})}),D.jsx("div",{className:"hidden",children:D.jsx(t_A,{taterMode:K,onTaterModeChange:ck,onIdentityChange:uk,origin:tA,onUIPreferencesChange:Y,externalOpen:O,onExternalClose:()=>P(!1),gitUser:rA})}),D.jsx(G_A,{appVersion:"0.19.2",onOpenSettings:()=>{P(!0)},onOpenExport:()=>{lt(void 0),I(!0)},onCopyAgentInstructions:pk,onDownloadAnnotations:Vd,onPrint:()=>window.print(),onCopyShareLink:aD,onOpenImport:()=>E(!0),onSaveToObsidian:()=>Ts("obsidian"),onSaveToBear:()=>Ts("bear"),onSaveToOctarine:()=>Ts("octarine"),sharingEnabled:Be,isApiMode:X,agentInstructionsEnabled:X&&!st.archiveMode&&!wA,obsidianConfigured:F$(),bearConfigured:Eu().enabled,octarineConfigured:Jw()})]})]}),xA.error&&D.jsxs("div",{className:"bg-destructive/10 border-b border-destructive/20 px-4 py-2 flex items-center gap-2 flex-shrink-0",children:[D.jsx("span",{className:"text-xs text-destructive",children:xA.error}),D.jsx("button",{onClick:xA.dismissError,className:"ml-auto text-xs text-destructive/60 hover:text-destructive",children:"dismiss"})]}),D.jsx(bdA.Provider,{value:At,children:D.jsxs("div",{"data-print-region":"content",className:`flex-1 flex overflow-hidden relative z-0 ${Ge?"select-none":""}`,children:[K&&D.jsx(ujA,{}),VA===null&&!ne.isOpen&&D.jsx(WXA,{activeTab:ne.activeTab,onToggleTab:be,hasDiff:kA.hasPreviousVersion,showVersionsTab:QA!==null&&QA.totalVersions>1,showFilesTab:Kr&&!st.archiveMode,hasFileAnnotations:Qt,className:"hidden lg:flex absolute left-0 top-0 z-10"}),ne.isOpen&&D.jsxs(D.Fragment,{children:[D.jsx(n$A,{activeTab:ne.activeTab,onTabChange:WA=>{be(WA),WA==="archive"&&!st.archiveMode&&st.fetchPlans()},onClose:ne.close,width:ar.width,blocks:a,annotations:t,activeSection:Ze,onTocNavigate:hk,linkedDocFilepath:xA.filepath,onLinkedDocBack:xA.isActive?hi:void 0,backLabel:Xn,showFilesTab:Kr&&!st.archiveMode,fileAnnotationCounts:ci,highlightedFiles:Vr,fileBrowser:cr,onFilesSelectFile:Ra,onFilesFetchAll:()=>cr.fetchAll(xn),onFilesRetryVaultDir:WA=>cr.addVaultDir(WA),hasFileAnnotations:Qt,showVersionsTab:QA!==null&&QA.totalVersions>1,versionInfo:QA,versions:kA.versions,selectedBaseVersion:kA.diffBaseVersion,onSelectBaseVersion:kA.selectBaseVersion,isPlanDiffActive:It,hasPreviousVersion:kA.hasPreviousVersion,onActivatePlanDiff:()=>mt(!0),isLoadingVersions:kA.isLoadingVersions,isSelectingVersion:kA.isSelectingVersion,fetchingVersion:kA.fetchingVersion,onFetchVersions:kA.fetchVersions,showArchiveTab:X&&!wA,archivePlans:st.plans,selectedArchiveFile:st.selectedFile,onArchiveSelect:st.select,isLoadingArchive:st.isLoading}),D.jsx(EAA,{...ar.handleProps,className:"hidden lg:block",side:"left"})]}),D.jsxs(hy,{element:"main",className:`flex-1 min-w-0 bg-grid ${!ne.isOpen&&VA===null?"lg:pl-[30px]":""}`,"data-print-region":"document",onViewportReady:Vt,children:[D.jsx(MB,{isOpen:!!fi,onClose:vE,onConfirm:Kd,title:"Draft Recovered",message:fi?`Found ${fi.count} annotation${fi.count!==1?"s":""} from ${fi.timeAgo}. Would you like to restore them?`:"",confirmText:"Restore",cancelText:"Dismiss",showCancel:!0}),D.jsxs("div",{ref:q,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:[!It&&!st.archiveMode&&z.stickyActionsEnabled&&D.jsx(ljA,{inputMethod:G,onInputMethodChange:XQ,mode:x,onModeChange:eD,taterMode:K,repoInfo:Ne,planDiffStats:kA.diffStats,isPlanDiffActive:It,hasPreviousVersion:kA.hasPreviousVersion,onPlanDiffToggle:()=>mt(!It),archiveInfo:st.currentInfo,maxWidth:Cc,remountToken:xA.isActive?`doc:${xA.filepath}`:"plan"}),!It&&!st.archiveMode&&D.jsx("div",{"data-print-hide":!0,className:"w-full mb-3 md:mb-4 flex items-center justify-start",style:Cc==null?void 0:{maxWidth:Cc},children:D.jsx(uhA,{inputMethod:G,onInputMethodChange:XQ,mode:x,onModeChange:eD,taterMode:K})}),kA.diffBlocks&&kA.diffStats&&D.jsx("div",{className:"w-full flex justify-center",style:{display:It?void 0:"none"},children:D.jsx(h$A,{diffBlocks:kA.diffBlocks,diffStats:kA.diffStats,diffMode:Bt,onDiffModeChange:Wt,onPlanDiffToggle:()=>mt(!1),repoInfo:Ne,baseVersionLabel:kA.diffBaseVersion!=null?`v${kA.diffBaseVersion}`:void 0,baseVersion:kA.diffBaseVersion??void 0,maxWidth:rf,annotations:Se,onAddAnnotation:ef,onSelectAnnotation:zd,selectedAnnotationId:i,mode:x})}),_A==="folder"&&!e&&!xA.isActive&&D.jsx("div",{className:"w-full flex justify-center",children:D.jsxs("div",{className:"w-full max-w-3xl p-12 text-center text-muted-foreground",children:[D.jsx("p",{className:"text-lg font-medium mb-2",children:"Select a file to annotate"}),D.jsx("p",{className:"text-sm",children:"Pick a markdown file from the sidebar to begin."})]})}),D.jsxs("div",{className:"w-full flex justify-center relative",style:{display:It&&kA.diffBlocks||_A==="folder"&&!e&&!xA.isActive?"none":void 0},children:[kn&&!It&&!st.archiveMode&&D.jsx("div",{"data-print-hide":!0,className:"absolute -top-5 left-0 right-0 mx-auto w-full flex justify-end pointer-events-none",style:Cc===null?void 0:{maxWidth:Cc??832},children:D.jsx("div",{className:`pointer-events-auto flex items-center gap-1.5 text-[11px] tracking-wide ${K?"mr-[60px]":"mr-[4px]"}`,children:["wide","focus"].map((WA,Ye)=>D.jsxs(Li.Fragment,{children:[Ye>0&&D.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/30 select-none",children:"|"}),D.jsx(ejA,{side:"top",align:"end",content:WA==="wide"?"Hide panels and expand document width":"Hide panels, keep document width",children:D.jsx("button",{type:"button",onClick:()=>Wa(WA),"aria-pressed":VA===WA,className:`cursor-pointer rounded-sm transition-colors duration-150 outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background active:opacity-80 ${VA===WA?"text-foreground":"text-muted-foreground/50 hover:text-muted-foreground"}`,children:WA.charAt(0).toUpperCase()+WA.slice(1)})})]},WA))})}),D.jsx(HqA,{ref:rt,blocks:a,markdown:e,frontmatter:s,annotations:et,onAddAnnotation:ef,onSelectAnnotation:zd,selectedAnnotationId:i,mode:x,inputMethod:G,taterMode:K,globalAttachments:IA,onAddGlobalAttachment:dk,onRemoveGlobalAttachment:Bk,repoInfo:Ne,stickyActions:z.stickyActionsEnabled,planDiffStats:xA.isActive?null:kA.diffStats,isPlanDiffActive:It,onPlanDiffToggle:()=>mt(!It),hasPreviousVersion:!xA.isActive&&kA.hasPreviousVersion,showDemoBadge:!X&&!nr&&!Nt,maxWidth:Cc,onOpenLinkedDoc:Do,linkedDocInfo:xA.isActive?{filepath:xA.filepath,onBack:hi,label:cr.dirs.find(WA=>WA.path===cr.activeDirPath)?.isVault?"Vault File":cr.activeFile?"File":void 0,backLabel:Xn}:null,imageBaseDir:JA,copyLabel:_A==="message"?"Copy message":_A==="file"||_A==="folder"?"Copy file":void 0,archiveInfo:st.currentInfo,sourceInfo:re,onToggleCheckbox:tf.toggle,checkboxOverrides:tf.overrides,actionsLabelMode:j},xA.isActive?`doc:${xA.filepath}`:"plan")]})]})]}),L&&VA===null&&D.jsx(EAA,{...lr.handleProps,className:"hidden md:block",side:"right"}),D.jsx(tVA,{isOpen:L&&VA===null,blocks:a,annotations:oe,selectedId:i,onSelect:n,onDelete:Ek,onEdit:nD,sharingEnabled:Be,width:lr.width,editorAnnotations:W,onDeleteEditorAnnotation:AA,onClose:()=>T(!1),onQuickCopy:async()=>{await navigator.clipboard.writeText(tsA(Ic))},onShare:Ht?()=>{T(!1),lt("share"),I(!0)}:void 0,otherFileAnnotations:Tt,onOtherFileAnnotationsClick:Qi})]})}),D.jsx(lVA,{isOpen:l,onClose:()=>{I(!1),lt(void 0)},shareUrl:Ht,shareUrlSize:bt,shortShareUrl:Ot,isGeneratingShortUrl:Ii,shortUrlError:$n,onGenerateShortUrl:on,annotationsOutput:Ic,annotationCount:oe.length,taterSprite:K?D.jsx(I9,{}):void 0,sharingEnabled:Be,markdown:e,isApiMode:X,initialTab:Pe}),D.jsx(cVA,{isOpen:C,onClose:()=>E(!1),onImport:xs,shareBaseUrl:HA}),D.jsx(MB,{isOpen:u,onClose:()=>B(!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"}),D.jsx(MB,{isOpen:h,onClose:()=>f(!1),onConfirm:()=>{f(!1),Jd()},title:"Annotations Won't Be Sent",message:D.jsxs(D.Fragment,{children:[fg," doesn't yet support feedback on approval. Your ",oe.length," annotation",oe.length!==1?"s":""," will be lost."]}),subMessage:D.jsxs(D.Fragment,{children:["To send feedback, use ",D.jsx("strong",{children:"Send Feedback"})," instead.",D.jsx("br",{}),D.jsx("br",{}),"Want this feature? Upvote these issues:",D.jsx("br",{}),D.jsx("a",{href:"https://github.com/anthropics/claude-code/issues/16001",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"#16001"})," · ",D.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}),D.jsx(MB,{isOpen:p,onClose:()=>m(!1),onConfirm:()=>{m(!1),w==="approve"?Af():rD()},title:"Annotations Won't Be Sent",message:D.jsxs(D.Fragment,{children:["You have ",oe.length+W.length+xA.docAnnotationCount+IA.length," annotation",oe.length+W.length+xA.docAnnotationCount+IA.length!==1?"s":""," that will be lost if you ",w==="approve"?"approve":"close","."]}),subMessage:"To send your annotations, use Send Annotations instead.",confirmText:w==="approve"?"Approve Anyway":"Close Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),D.jsx(MB,{isOpen:M,onClose:()=>b(!1),onConfirm:()=>{b(!1),Jd()},title:"Agent Not Found",message:R,subMessage:D.jsxs(D.Fragment,{children:["You can change the agent in ",D.jsx("strong",{children:"Settings"}),", or approve anyway and OpenCode will use the default agent."]}),confirmText:"Approve Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),D.jsx(MB,{isOpen:!!Ln&&!X,onClose:gl,title:"Shared Plan Could Not Be Loaded",message:Ln,subMessage:"You are viewing a demo plan. This is sample content — it is not your data or anyone else's.",variant:"warning"}),We&&D.jsx("div",{className:`fixed top-16 right-4 z-50 px-3 py-2 rounded-lg text-xs font-medium shadow-lg transition-opacity ${We.type==="success"?"bg-success/15 text-success border border-success/30":"bg-destructive/15 text-destructive border border-destructive/30"}`,children:We.message}),D.jsx(B_A,{submitted:fA,title:st.archiveMode?"Archive Closed":fA==="exited"?"Session Closed":fA==="approved"?wA?"Approved":"Plan Approved":wA?"Annotations Sent":"Feedback Sent",subtitle:fA==="exited"?"Annotation session closed without feedback.":st.archiveMode?"You can reopen with plannotator archive.":fA==="approved"?wA?`${fg} will proceed.`:`${fg} will proceed with the implementation.`:wA?`${fg} will address your annotations on the ${_A==="message"?"message":_A==="folder"?"files":"file"}.`:`${fg} will revise the plan based on your annotations.`,agentLabel:fg}),D.jsx(y_A,{origin:tA,isWSL:sA}),D.jsx(QgA,{isOpen:!!EA,imageSrc:EA?.blobUrl??"",initialName:EA?.initialName,onAccept:Ik,onClose:Ck}),D.jsx(q_A,{isOpen:PA,onComplete:WA=>{Ae(WA),FA(!1)}})]})})})},AQA=document.getElementById("root");if(!AQA)throw new Error("Could not find root element to mount to");const w$A=z1A.createRoot(AQA);w$A.render(D.jsx(Li.StrictMode,{children:D.jsx(D$A,{})}));class ko{constructor(A,t,r){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=A,this.start=t,this.end=r}static range(A,t){return t?!A||!A.loc||!t.loc||A.loc.lexer!==t.loc.lexer?null:new ko(A.loc.lexer,A.loc.start,t.loc.end):A&&A.loc}}class Qs{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 Qs(t,ko.range(this,A))}}class $e{constructor(A,t){this.name=void 0,this.position=void 0,this.length=void 0,this.rawMessage=void 0;var r="KaTeX parse error: "+A,i,n,a=t&&t.loc;if(a&&a.start<=a.end){var o=a.lexer.input;i=a.start,n=a.end,i===o.length?r+=" at end of input: ":r+=" at position "+(i+1)+": ";var s=o.slice(i,n).replace(/[^]/g,"$&̲"),g;i>15?g="…"+o.slice(i-15,i):g=o.slice(0,i);var l;n+15<o.length?l=o.slice(n,n+15)+"…":l=o.slice(n),r+=g+s+l}var I=new Error(r);return I.name="ParseError",I.__proto__=$e.prototype,I.position=i,i!=null&&n!=null&&(I.length=n-i),I.rawMessage=A,I}}$e.prototype.__proto__=Error.prototype;var v$A=function(A,t){return A===void 0?t:A},S$A=/([A-Z])/g,b$A=function(A){return A.replace(S$A,"-$1").toLowerCase()},R$A={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},N$A=/[&><"']/g;function M$A(e){return String(e).replace(N$A,A=>R$A[A])}var eQA=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},k$A=function(A){var t=eQA(A);return t.type==="mathord"||t.type==="textord"||t.type==="atom"},x$A=function(A){if(!A)throw new Error("Expected non-null, but got "+String(A));return A},T$A=function(A){var t=/^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(A);return t?t[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():"_relative"},zr={deflt:v$A,escape:M$A,hyphenate:b$A,getBaseElem:eQA,isCharacterBox:k$A,protocolFromUrl:T$A},J0={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 L$A(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 B9{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 J0)if(J0.hasOwnProperty(t)){var r=J0[t];this[t]=A[t]!==void 0?r.processor?r.processor(A[t]):A[t]:L$A(r)}}reportNonstrict(A,t,r){var i=this.strict;if(typeof i=="function"&&(i=i(A,t,r)),!(!i||i==="ignore")){if(i===!0||i==="error")throw new $e("LaTeX-incompatible input and strict mode is set to 'error': "+(t+" ["+A+"]"),r);i==="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 '"+i+"': "+t+" ["+A+"]"))}}useStrictBehavior(A,t,r){var i=this.strict;if(typeof i=="function")try{i=i(A,t,r)}catch{i="error"}return!i||i==="ignore"?!1:i===!0||i==="error"?!0:i==="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 '"+i+"': "+t+" ["+A+"]")),!1)}isTrusted(A){if(A.url&&!A.protocol){var t=zr.protocolFromUrl(A.url);if(t==null)return!1;A.protocol=t}var r=typeof this.trust=="function"?this.trust(A):this.trust;return!!r}}class tC{constructor(A,t,r){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=A,this.size=t,this.cramped=r}sup(){return Rl[F$A[this.id]]}sub(){return Rl[G$A[this.id]]}fracNum(){return Rl[O$A[this.id]]}fracDen(){return Rl[U$A[this.id]]}cramp(){return Rl[K$A[this.id]]}text(){return Rl[Y$A[this.id]]}isTight(){return this.size>=2}}var h9=0,kb=1,Dh=2,rI=3,bm=4,tg=5,nQ=6,oo=7,Rl=[new tC(h9,0,!1),new tC(kb,0,!0),new tC(Dh,1,!1),new tC(rI,1,!0),new tC(bm,2,!1),new tC(tg,2,!0),new tC(nQ,3,!1),new tC(oo,3,!0)],F$A=[bm,tg,bm,tg,nQ,oo,nQ,oo],G$A=[tg,tg,tg,tg,oo,oo,oo,oo],O$A=[Dh,rI,bm,tg,nQ,oo,nQ,oo],U$A=[rI,rI,tg,tg,oo,oo,oo,oo],K$A=[kb,kb,rI,rI,tg,tg,oo,oo],Y$A=[h9,kb,Dh,rI,Dh,rI,Dh,rI],Yt={DISPLAY:Rl[h9],TEXT:Rl[Dh],SCRIPT:Rl[bm],SCRIPTSCRIPT:Rl[nQ]},r5=[{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 P$A(e){for(var A=0;A<r5.length;A++)for(var t=r5[A],r=0;r<t.blocks.length;r++){var i=t.blocks[r];if(e>=i[0]&&e<=i[1])return t.name}return null}var RS=[];r5.forEach(e=>e.blocks.forEach(A=>RS.push(...A)));function tQA(e){for(var A=0;A<RS.length;A+=2)if(e>=RS[A]&&e<=RS[A+1])return!0;return!1}var xB=80,H$A=function(A,t){return"M95,"+(622+A+t)+`
1143
+ `;function f$A(e){return!e.archiveMode&&!e.isPlanDiffActive}function p$A(e,A){const t=A?.restore!==!1;return A?.sidebarTab?{sidebarOpen:!0,sidebarTab:A.sidebarTab,panelOpen:A.panelOpen}:{sidebarOpen:t?e?.sidebarIsOpen??!1:!1,sidebarTab:t&&e?.sidebarIsOpen?e.sidebarTab:null,panelOpen:A?.panelOpen??(t?e?.panelOpen??!1:void 0)}}function m$A({blocks:e,annotations:A,addAnnotation:t,removeAnnotation:r}){const[i,n]=Z.useState(new Map),a=Z.useRef(e);a.current=e;const o=Z.useRef(A);o.current=A,Z.useEffect(()=>{if(i.size===0)return;const l=new Set(e.map(C=>C.id)),I=[...i.keys()].filter(C=>!l.has(C));I.length>0&&n(C=>{const E=new Map(C);return I.forEach(u=>E.delete(u)),E})},[e]);const s=Z.useCallback((l,I)=>{const C=a.current,E=o.current,u=C.find(h=>h.id===l);if(u&&I===u.checked)n(f=>{const p=new Map(f);return p.delete(l),p}),E.filter(f=>f.blockId===l&&f.id.startsWith("ann-checkbox-")).forEach(f=>r(f.id));else if(E.filter(f=>f.blockId===l&&f.id.startsWith("ann-checkbox-")).forEach(f=>r(f.id)),n(f=>{const p=new Map(f);return p.set(l,I),p}),u){const f=C.indexOf(u);let p="";for(let M=f-1;M>=0;M--)if(C[M].type==="heading"){p=C[M].content;break}const m=I?"Mark as completed":"Mark as not completed",w=p?` (under "${p}")`:` (line ${u.startLine})`,v={id:`ann-checkbox-${l}-${Date.now()}`,blockId:l,startOffset:0,endOffset:u.content.length,type:Er.COMMENT,text:`${m}${w}: ${u.content}`,originalText:u.content,createdA:Date.now()};t(v)}},[t,r]),g=Z.useCallback(l=>{n(I=>{const C=new Map(I);return C.delete(l),C})},[]);return{overrides:i,toggle:s,revertOverride:g}}const y$A=Q$A,D$A=()=>{const[e,A]=Z.useState(y$A),[t,r]=Z.useState([]),[i,n]=Z.useState(null),[a,o]=Z.useState([]),[s,g]=Z.useState(null),[l,I]=Z.useState(!1),[C,E]=Z.useState(!1),[u,B]=Z.useState(!1),[h,f]=Z.useState(!1),[p,m]=Z.useState(!1),[w,v]=Z.useState("close"),[M,b]=Z.useState(!1),[R,N]=Z.useState(""),[L,T]=Z.useState(()=>window.innerWidth>=768),[O,P]=Z.useState(!1),[x,U]=Z.useState(w_A),[G,F]=Z.useState(b_A),[K,H]=Z.useState(()=>Je.getItem("plannotator-tater-mode")==="true"),[z,Y]=Z.useState(()=>_K()),q=Z.useRef(null),[j,$]=Z.useState("full");Z.useLayoutEffect(()=>{const WA=q.current;if(!WA)return;const Ye=ht=>ht>=800?"full":ht>=680?"short":"icon";$(Ye(WA.getBoundingClientRect().width));const je=new ResizeObserver(([ht])=>{const sr=Ye(ht.contentRect.width);$(ri=>ri===sr?ri:sr)});return je.observe(WA),()=>je.disconnect()},[]);const[X,gA]=Z.useState(!1),[tA,hA]=Z.useState(null),[rA,oA]=Z.useState(),[sA,nA]=Z.useState(!1),[IA,cA]=Z.useState([]),[wA,dA]=Z.useState(!1),[YA,aA]=Z.useState(!1),[_A,bA]=Z.useState(null),[re,ae]=Z.useState(),[de,GA]=Z.useState(!1),[se,OA]=Z.useState(),[JA,Ce]=Z.useState(void 0),[LA,ee]=Z.useState(!0),[BA,SA]=Z.useState(!1),[_,yA]=Z.useState(!1),[fA,TA]=Z.useState(null),[EA,MA]=Z.useState(null),[PA,FA]=Z.useState(!1),[XA,Ae]=Z.useState("bypassPermissions"),[Be,vA]=Z.useState(!0),[HA,UA]=Z.useState(void 0),[ce,Le]=Z.useState(void 0),[Ne,iA]=Z.useState(null),[ue,Ie]=Z.useState(null),[VA,le]=Z.useState(null),De=Z.useRef(null),ke=Z.useRef(z.tocEnabled);Z.useEffect(()=>{document.title=Ne?`${Ne.display} · Plannotator`:"Plannotator"},[Ne]);const[Pe,lt]=Z.useState(),[We,Xe]=Z.useState(null),[It,mt]=Z.useState(!1),[Bt,Wt]=Z.useState("clean"),[Nr,ve]=Z.useState(null),[QA,$A]=Z.useState(null),we=RdA(),rt=Z.useRef(null),{ref:xt,viewport:At,onViewportReady:Vt}=T_A();x_A();const lr=CAA({storageKey:"plannotator-panel-width"}),ar=CAA({storageKey:"plannotator-toc-width",defaultWidth:240,minWidth:160,maxWidth:400,side:"left"}),Ge=lr.isDragging||ar.isDragging,ne=W_A(_K().tocEnabled),Te=Z.useCallback(WA=>{if(VA===null){WA?.sidebarTab&&ne.open(WA.sidebarTab),WA?.panelOpen===!0?T(!0):WA?.panelOpen===!1&&T(!1);return}const Ye=De.current,je=p$A(Ye,WA);le(null),De.current=null,je.sidebarOpen&&je.sidebarTab?ne.open(je.sidebarTab):ne.close(),je.panelOpen!==void 0&&T(je.panelOpen)},[VA,ne.close,ne.open]),xe=Z.useCallback(WA=>{if(VA!==null){Te({restore:!1,sidebarTab:WA,panelOpen:!1});return}ne.open(WA)},[Te,VA,ne.open]),be=Z.useCallback(WA=>{if(VA!==null){Te({restore:!1,sidebarTab:WA,panelOpen:!1});return}ne.toggleTab(WA)},[Te,VA,ne.toggleTab]),ut=Z.useCallback(()=>{if(VA!==null){Te({restore:!1,panelOpen:!0});return}T(WA=>!WA)},[Te,VA]);Z.useEffect(()=>{VA===null&&ke.current!==z.tocEnabled&&(ke.current=z.tocEnabled,z.tocEnabled?ne.open("toc"):ne.close())},[VA,ne.close,ne.open,z.tocEnabled]),Z.useEffect(()=>{ne.activeTab==="toc"&&It&&mt(!1)},[ne.activeTab]),Z.useEffect(()=>{if(!It)return;const WA=Ye=>{Ye.key==="Escape"&&mt(!1)};return document.addEventListener("keydown",WA),()=>document.removeEventListener("keydown",WA)},[It]);const kA=kXA(e,Nr,QA),li=Z.useMemo(()=>({...ne,open:xe,toggleTab:be}),[xe,ne.activeTab,ne.close,ne.isOpen,be]),xA=xXA({markdown:e,annotations:t,selectedAnnotationId:i,globalAttachments:IA,setMarkdown:A,setAnnotations:r,setSelectedAnnotationId:n,setGlobalAttachments:cA,viewerRef:rt,sidebar:li,sourceFilePath:se,sourceConverted:de}),st=OXA({markdown:e,viewerRef:rt,linkedDocHook:xA,setMarkdown:A,setAnnotations:r,setSelectedAnnotationId:n,setSubmitted:TA}),kn=Z.useMemo(()=>f$A({archiveMode:st.archiveMode,isPlanDiffActive:It}),[st.archiveMode,It]),qa=Z.useCallback(WA=>{kn&&(VA===null&&(De.current={sidebarIsOpen:ne.isOpen,sidebarTab:ne.activeTab,panelOpen:L}),le(WA),ne.close(),T(!1))},[kn,L,VA,ne.activeTab,ne.close,ne.isOpen]),Wa=Z.useCallback(WA=>{VA===WA?Te():qa(WA)},[qa,Te,VA]);Z.useEffect(()=>{!kn&&VA!==null&&Te()},[kn,Te,VA]);const cr=qXA(),Ur=Z.useMemo(()=>G$()?hC(BC()):"",[z]),Kr=Z.useMemo(()=>!!ue||nAA()||G$(),[ue,z]),xn=Z.useMemo(()=>{const WA=ue?[ue]:[],Ye=nAA()?u9().directories:[];return[...new Set([...WA,...Ye])]},[ue,z]);Z.useEffect(()=>{Kr||cr.setActiveFile(null)},[Kr]),Z.useEffect(()=>{Ur||cr.clearVaultDirs()},[Ur]),Z.useEffect(()=>{if(ne.activeTab==="files"&&Kr){if(xn.length>0){const WA=cr.dirs.filter(je=>!je.isVault).map(je=>je.path);(xn.some(je=>!WA.includes(je))||WA.some(je=>!xn.includes(je)))&&cr.fetchAll(xn)}Ur&&!cr.dirs.find(WA=>WA.isVault&&WA.path===Ur&&!WA.error)&&cr.addVaultDir(Ur)}},[ne.activeTab,Kr,xn,Ur]);const Ra=Li.useCallback((WA,Ye)=>{const ht=cr.dirs.find(sr=>sr.path===Ye)?.isVault?sr=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(Ye)}&path=${encodeURIComponent(sr)}`:sr=>`/api/doc?path=${encodeURIComponent(sr)}&base=${encodeURIComponent(Ye)}`;xA.open(WA,ht,"files"),cr.setActiveFile(WA)},[xA,cr]),Do=Li.useCallback(WA=>{if(cr.dirs.find(je=>je.path===cr.activeDirPath)?.isVault&&cr.activeDirPath)xA.open(WA,je=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(cr.activeDirPath)}&path=${encodeURIComponent(je)}`);else if(cr.activeFile&&cr.activeDirPath){const je=xA.filepath?.replace(/\/[^/]+$/,"")||cr.activeDirPath;xA.open(WA,ht=>`/api/doc?path=${encodeURIComponent(ht)}&base=${encodeURIComponent(je)}`)}else{const je=xA.filepath?xA.filepath.replace(/\/[^/]+$/,""):JA;je?xA.open(WA,ht=>`/api/doc?path=${encodeURIComponent(ht)}&base=${encodeURIComponent(je)}`):xA.open(WA)}},[cr.dirs,cr.activeDirPath,cr.activeFile,xA,JA]),hi=Li.useCallback(()=>{xA.back(),cr.setActiveFile(null),st.clearSelection()},[xA,cr,st]),Tn=Z.useMemo(()=>{const WA=new Map;for(const[Ye,je]of xA.getDocAnnotations()){const ht=je.annotations.length+je.globalAttachments.length;ht>0&&WA.set(Ye,ht)}return WA},[xA.getDocAnnotations,t,IA]),ci=Z.useMemo(()=>{const WA=cr.dirs.map(je=>je.path);if(WA.length===0)return Tn;const Ye=new Map;for(const[je,ht]of Tn)WA.some(sr=>je.startsWith(sr+"/"))&&Ye.set(je,ht);return Ye},[Tn,cr.dirs]),Qt=ci.size>0,Tt=Z.useMemo(()=>{const WA=xA.filepath;let Ye=0,je=0;for(const[ht,sr]of Tn)ht!==WA&&(Ye+=sr,je++);return Ye>0?{count:Ye,files:je}:void 0},[Tn,xA.filepath]),[Vr,rr]=Z.useState(),Ji=Li.useRef(),Qi=Li.useCallback(()=>{const WA=new Set(Tn.keys());WA.size!==0&&((!ne.isOpen||ne.activeTab!=="files")&&xe("files"),Ji.current&&clearTimeout(Ji.current),rr(void 0),requestAnimationFrame(()=>{rr(WA),Ji.current=setTimeout(()=>rr(void 0),1200)}))},[Tn,xe,ne,Qt]),Xn=_A==="folder"?"file list":_A==="file"?"file":_A==="message"?"message":"plan",Bn=Z.useMemo(()=>a.filter(WA=>WA.type==="heading").length,[a]),Ze=C_A(xt,Bn,At),{editorAnnotations:W,deleteEditorAnnotation:AA}=KXA(),{externalAnnotations:uA,updateExternalAnnotation:DA,deleteExternalAnnotation:KA}=HXA({enabled:X}),{reset:te}=JXA({viewerRef:rt,externalAnnotations:uA,enabled:X&&!xA.isActive&&!It,planKey:e}),oe=Z.useMemo(()=>uA.length===0?t:[...t.filter(Ye=>Ye.source?!uA.some(je=>je.source===Ye.source&&je.type===Ye.type&&je.originalText===Ye.originalText):!0),...uA],[t,uA]),Se=Z.useMemo(()=>oe.filter(WA=>!!WA.diffContext),[oe]),et=Z.useMemo(()=>oe.filter(WA=>!WA.diffContext),[oe]),Gt=Z.useMemo(()=>oe.length>0||W.length>0||xA.docAnnotationCount>0||IA.length>0,[oe.length,W.length,xA.docAnnotationCount,IA.length]),{isSharedSession:Nt,isLoadingShared:nr,shareUrl:Ht,shareUrlSize:bt,shortShareUrl:Ot,isGeneratingShortUrl:Ii,shortUrlError:$n,pendingSharedAnnotations:an,clearPendingSharedAnnotations:ti,generateShortUrl:on,importFromShareUrl:xs,shareLoadError:Ln,clearShareLoadError:gl}=l_A(e,oe,IA,A,r,cA,()=>{ee(!1)},HA,ce),{draftBanner:fi,restoreDraft:Ud,dismissDraft:vE}=GXA({annotations:oe,globalAttachments:IA,isApiMode:X,isSharedSession:Nt,submitted:!!fA}),Kd=Li.useCallback(()=>{const{annotations:WA,globalAttachments:Ye}=Ud();WA.length>0&&(r(WA),Ye.length>0&&cA(Ye),setTimeout(()=>{rt.current?.applySharedAnnotations(WA.filter(je=>!je.diffContext))},100))},[Ud]),{getAgentWarning:Yd}=NhA(tA);Z.useEffect(()=>{if(an&&an.length>0){const WA=setTimeout(()=>{rt.current?.clearAllHighlights(),rt.current?.applySharedAnnotations(an.filter(Ye=>!Ye.diffContext)),ti(),te()},100);return()=>clearTimeout(WA)}},[an,ti,te]);const ck=WA=>{H(WA),Je.setItem("plannotator-tater-mode",String(WA))},eD=WA=>{U(WA),v_A(WA)},XQ=WA=>{F(WA),R_A(WA)};k_A(G,XQ),Z.useEffect(()=>{nr||Nt||fetch("/api/plan").then(WA=>{if(!WA.ok)throw new Error("Not in API mode");return WA.json()}).then(WA=>{yn.init(WA.serverConfig),oA(WA.serverConfig?.gitUser),WA.mode==="archive"?(A(WA.plan||""),WA.archivePlans&&st.init(WA.archivePlans),st.fetchPlans(),vA(!1),ne.open("archive")):WA.mode==="annotate-folder"?A(""):WA.plan&&A(WA.plan),gA(!0),(WA.mode==="annotate"||WA.mode==="annotate-last"||WA.mode==="annotate-folder")&&(dA(!0),aA(WA.gate??!1)),WA.mode==="annotate-folder"&&ne.open("files"),WA.mode&&WA.mode!=="archive"&&bA(WA.mode==="annotate-last"?"message":WA.mode==="annotate-folder"?"folder":"file"),ae(WA.sourceInfo??void 0),GA(!!WA.sourceConverted),WA.filePath&&(Ce(WA.mode==="annotate-folder"?WA.filePath:WA.filePath.replace(/\/[^/]+$/,"")),WA.mode==="annotate"&&OA(WA.filePath)),WA.sharingEnabled!==void 0&&vA(WA.sharingEnabled),WA.shareBaseUrl&&UA(WA.shareBaseUrl),WA.pasteApiUrl&&Le(WA.pasteApiUrl),WA.repoInfo&&iA(WA.repoInfo),WA.projectRoot&&Ie(WA.projectRoot),WA.previousPlan!==void 0&&ve(WA.previousPlan),WA.versionInfo&&$A(WA.versionInfo),WA.origin&&(hA(WA.origin),WA.origin==="claude-code"&&vjA()&&FA(!0),Ae(vhA().mode)),WA.isWSL&&nA(!0)}).catch(()=>{gA(!1)}).finally(()=>ee(!1))},[nr,Nt]),Z.useEffect(()=>{const{frontmatter:WA}=AsA(e);g(WA),o(Am(e))},[e]);const SE=Z.useRef(!1),Pd=Z.useRef({}),Hd=Z.useRef(null);Z.useEffect(()=>{SE.current=!1,Pd.current={},Hd.current=null},[e]),Z.useEffect(()=>{if(!X||!e||Nt||wA||st.archiveMode||SE.current)return;const WA={},Ye=[],je=BC();if(je.autoSave&&je.enabled){const Mr=hC(je);Mr&&(WA.obsidian={vaultPath:Mr,folder:je.folder||"plannotator",plan:e,...je.filenameFormat&&{filenameFormat:je.filenameFormat},...je.filenameSeparator&&je.filenameSeparator!=="space"&&{filenameSeparator:je.filenameSeparator}},Ye.push("Obsidian"))}const ht=Eu();ht.autoSave&&ht.enabled&&(WA.bear={plan:e,customTags:ht.customTags,tagPosition:ht.tagPosition},Ye.push("Bear"));const sr=ph();if(sr.autoSave&&Jw()&&(WA.octarine={plan:e,workspace:sr.workspace,folder:sr.folder||"plannotator"},Ye.push("Octarine")),Ye.length===0)return;SE.current=!0;const ri=fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(WA)}).then(Mr=>Mr.json()).then(Mr=>{const ga={...WA.obsidian?{obsidian:!!Mr.results?.obsidian?.success}:{},...WA.bear?{bear:!!Mr.results?.bear?.success}:{},...WA.octarine?{octarine:!!Mr.results?.octarine?.success}:{}};Pd.current=ga;const Va=Ye.filter(nf=>!Mr.results?.[nf.toLowerCase()]?.success);return Va.length===0?Xe({type:"success",message:`Auto-saved to ${Ye.join(" & ")}`}):Xe({type:"error",message:`Auto-save failed for ${Va.join(" & ")}`}),ga}).catch(()=>(Pd.current={},Xe({type:"error",message:"Auto-save failed"}),{})).finally(()=>setTimeout(()=>Xe(null),3e3));Hd.current=ri},[X,e,Nt,wA]),Z.useEffect(()=>{const WA=Ye=>{const je=Ye.clipboardData?.items;if(je){for(const ht of je)if(ht.type.startsWith("image/")){Ye.preventDefault();const sr=ht.getAsFile();if(sr){const ri=m4(sr.name,IA.map(ga=>ga.name)),Mr=URL.createObjectURL(sr);MA({file:sr,blobUrl:Mr,initialName:ri})}break}}};return document.addEventListener("paste",WA),()=>document.removeEventListener("paste",WA)},[IA]);const Ik=async(WA,Ye,je)=>{if(EA)try{const ht=new FormData,sr=Ye?new File([WA],"annotated.png",{type:"image/png"}):EA.file;ht.append("file",sr);const ri=await fetch("/api/upload",{method:"POST",body:ht});if(ri.ok){const Mr=await ri.json();cA(ga=>[...ga,{path:Mr.path,name:je}])}}catch{}finally{URL.revokeObjectURL(EA.blobUrl),MA(null)}},Ck=()=>{EA&&(URL.revokeObjectURL(EA.blobUrl),MA(null))},Jd=async()=>{SA(!0);try{const WA=BC(),Ye=Eu(),je=ph(),ht=C9(),sr=Rb(),ri=Ye.autoSave&&Hd.current?await Hd.current:Pd.current,Mr={};tA==="claude-code"&&(Mr.permissionMode=XA);const ga=mjA(ht);ga&&(Mr.agentSwitch=ga),Mr.planSave={enabled:sr.enabled,...sr.customPath&&{customPath:sr.customPath}};const Va=hC(WA);WA.enabled&&Va&&(Mr.obsidian={vaultPath:Va,folder:WA.folder||"plannotator",plan:e,...WA.filenameFormat&&{filenameFormat:WA.filenameFormat},...WA.filenameSeparator&&WA.filenameSeparator!=="space"&&{filenameSeparator:WA.filenameSeparator}}),Ye.enabled&&!(Ye.autoSave&&ri.bear)&&(Mr.bear={plan:e,customTags:Ye.customTags,tagPosition:Ye.tagPosition}),Jw()&&(Mr.octarine={plan:e,workspace:je.workspace,folder:je.folder||"plannotator"});const nf=Array.from(xA.getDocAnnotations().values()).some(bE=>bE.annotations.length>0||bE.globalAttachments.length>0);(oe.length>0||IA.length>0||nf||W.length>0)&&(Mr.feedback=Ic),await fetch("/api/approve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Mr)}),TA("approved")}catch{SA(!1)}},$Q=async()=>{SA(!0);try{const WA=Rb();await fetch("/api/deny",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:Ic,planSave:{enabled:WA.enabled,...WA.customPath&&{customPath:WA.customPath}}})}),TA("denied")}catch{SA(!1)}},tD=async()=>{SA(!0);try{await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:Ic,annotations:oe})}),TA("denied")}catch{SA(!1)}},Af=async()=>{SA(!0);try{await fetch("/api/approve",{method:"POST"}),TA("approved")}catch{SA(!1)}},rD=Z.useCallback(async()=>{yA(!0);try{if((await fetch("/api/exit",{method:"POST"})).ok)TA("exited");else throw new Error("Failed to exit")}catch{yA(!1)}},[]);Z.useEffect(()=>{const WA=Ye=>{if(Ye.key!=="Enter"||!(Ye.metaKey||Ye.ctrlKey))return;const je=Ye.target?.tagName;if(je==="INPUT"||je==="TEXTAREA"||l||C||u||h||p||M||PA||EA||fA||BA||_||!X||xA.isActive)return;if(Ye.preventDefault(),wA){if(YA&&!Gt){Af();return}tD();return}const ht=xA.getDocAnnotations(),sr=Array.from(ht.values()).some(ri=>ri.annotations.length>0||ri.globalAttachments.length>0);if(oe.length===0&&W.length===0&&!sr){if(tA==="opencode"){const ri=Yd();if(ri){N(ri),b(!0);return}}Jd()}else $Q()};return window.addEventListener("keydown",WA),()=>window.removeEventListener("keydown",WA)},[l,C,u,h,p,M,PA,EA,fA,BA,_,X,xA.isActive,t.length,uA.length,wA,YA,Gt,tA,Yd]);const ef=WA=>{r(Ye=>[...Ye,WA]),n(WA.id),VA===null&&T(!0)},zd=Li.useCallback(WA=>{n(WA),WA&&we&&VA===null&&T(!0)},[we,VA]),iD=WA=>{rt.current?.removeHighlight(WA),r(Ye=>Ye.filter(je=>je.id!==WA)),i===WA&&n(null)},tf=m$A({blocks:a,annotations:t,addAnnotation:ef,removeAnnotation:iD}),Ek=WA=>{const Ye=oe.find(je=>je.id===WA);if(Ye?.source&&uA.some(je=>je.id===WA)){KA(WA),i===WA&&n(null);return}WA.startsWith("ann-checkbox-")&&Ye&&tf.revertOverride(Ye.blockId),iD(WA)},nD=(WA,Ye)=>{if(oe.find(ht=>ht.id===WA)?.source&&uA.some(ht=>ht.id===WA)){DA(WA,Ye);return}r(ht=>ht.map(sr=>sr.id===WA?{...sr,...Ye}:sr))},uk=(WA,Ye)=>{r(je=>je.map(ht=>ht.author===WA?{...ht,author:Ye}:ht))},dk=WA=>{cA(Ye=>[...Ye,WA])},Bk=WA=>{cA(Ye=>Ye.filter(je=>je.path!==WA))},hk=WA=>{},Ic=Z.useMemo(()=>{const WA=xA.getDocAnnotations(),Ye=Array.from(WA.values()).some(Mr=>Mr.annotations.length>0||Mr.globalAttachments.length>0),je=oe.length>0||IA.length>0,ht=W.length>0;if(!je&&!Ye&&!ht)return"User reviewed the document and has no feedback.";const sr=xA.isActive?WA.get(xA.filepath??"")?.isConverted??!1:de;let ri=je?_1A(a,oe,IA,_A==="message"?"Message Feedback":_A==="folder"?"Folder Feedback":_A==="file"?"File Feedback":"Plan Feedback",_A??"plan",{sourceConverted:sr}):"";if(Ye){const Mr=new Map(WA);for(const[ga,Va]of Mr)Va.markdown&&Mr.set(ga,{...Va,blocks:Am(Va.markdown)});ri+=X1A(Mr)}return ht&&(ri+=$1A(W)),ri},[a,oe,IA,xA.getDocAnnotations,W,de,_A,xA.isActive,xA.filepath]),qd=Li.useMemo(()=>c_A(),[]),Wd=Li.useCallback(async WA=>{if(!(!qd||BA||!Ht)){SA(!0);try{const Ye=await I_A(WA,qd,Ht);Ye&&(Xe(Ye),setTimeout(()=>Xe(null),4e3),Ye.type==="success"&&TA(WA===bS.Approve?"approved":"denied"))}finally{SA(!1)}}},[qd,BA,Ht]),Qk=Li.useCallback(()=>Wd(bS.Approve),[Wd]),fk=Li.useCallback(()=>Wd(bS.Feedback),[Wd]),Vd=()=>{const WA=new Blob([Ic],{type:"text/plain"}),Ye=URL.createObjectURL(WA),je=document.createElement("a");je.href=Ye,je.download="annotations.md",je.click(),URL.revokeObjectURL(Ye),Xe({type:"success",message:"Downloaded annotations"}),setTimeout(()=>Xe(null),3e3)},Ts=async WA=>{const Ye={};if(WA==="obsidian"){const ht=BC(),sr=hC(ht);sr&&(Ye.obsidian={vaultPath:sr,folder:ht.folder||"plannotator",plan:e,...ht.filenameFormat&&{filenameFormat:ht.filenameFormat},...ht.filenameSeparator&&ht.filenameSeparator!=="space"&&{filenameSeparator:ht.filenameSeparator}})}if(WA==="bear"){const ht=Eu();Ye.bear={plan:e,customTags:ht.customTags,tagPosition:ht.tagPosition}}if(WA==="octarine"){const ht=ph();Ye.octarine={plan:e,workspace:ht.workspace,folder:ht.folder||"plannotator"}}const je=WA==="obsidian"?"Obsidian":WA==="bear"?"Bear":"Octarine";try{const ri=(await(await fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ye)})).json()).results?.[WA];ri?.success?Xe({type:"success",message:`Saved to ${je}`}):Xe({type:"error",message:ri?.error||"Save failed"})}catch{Xe({type:"error",message:"Save failed"})}setTimeout(()=>Xe(null),3e3)},pk=async()=>{const WA=zXA(window.location.origin);try{await navigator.clipboard.writeText(WA),Xe({type:"success",message:"Agent instructions copied"})}catch{Xe({type:"error",message:"Failed to copy"})}setTimeout(()=>Xe(null),3e3)},aD=async()=>{try{await navigator.clipboard.writeText(Ht),Xe({type:"success",message:"Share link copied"})}catch{Xe({type:"error",message:"Failed to copy"})}setTimeout(()=>Xe(null),3e3)};Z.useEffect(()=>{const WA=Ye=>{if(Ye.key!=="s"||!(Ye.metaKey||Ye.ctrlKey))return;const je=Ye.target?.tagName;if(je==="INPUT"||je==="TEXTAREA"||l||u||h||p||M||PA||EA||fA||!X)return;Ye.preventDefault();const ht=RhA(),sr=F$(),ri=Eu().enabled,Mr=Jw();ht==="download"?Vd():ht==="obsidian"&&sr?Ts("obsidian"):ht==="bear"&&ri?Ts("bear"):ht==="octarine"&&Mr?Ts("octarine"):(lt("notes"),I(!0))};return window.addEventListener("keydown",WA),()=>window.removeEventListener("keydown",WA)},[l,u,h,p,M,PA,EA,fA,X,e,Ic]),Z.useEffect(()=>{const WA=Ye=>{if(Ye.key!=="p"||!(Ye.metaKey||Ye.ctrlKey))return;const je=Ye.target?.tagName;je==="INPUT"||je==="TEXTAREA"||l||u||h||p||M||PA||EA||fA||(Ye.preventDefault(),window.print())};return window.addEventListener("keydown",WA),()=>window.removeEventListener("keydown",WA)},[l,u,h,p,M,PA,EA,fA]);const fg=Z.useMemo(()=>q1A(tA),[tA]),rf=Z.useMemo(()=>({compact:832,default:1040,wide:1280})[z.planWidth]??832,[z.planWidth]),Cc=kn&&VA==="wide"?null:rf;return D.jsx(IVA,{defaultTheme:"dark",children:D.jsx(AjA,{delayDuration:900,skipDelayDuration:200,disableHoverableContent:!0,children:D.jsxs("div",{"data-print-region":"root",className:"h-screen flex flex-col bg-background overflow-hidden",children:[D.jsxs("header",{"data-app-header":"true",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:[D.jsx("div",{className:"flex items-center gap-2 md:gap-3",children:D.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:D.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Plannotator"})})}),D.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[qd&&!X&&Nt&&D.jsxs(D.Fragment,{children:[D.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"}),D.jsx(Q3,{onClick:fk,disabled:BA||!Ht,isLoading:BA,title:"Send feedback to bot"}),D.jsx(aAA,{onClick:Qk,disabled:BA||!Ht,isLoading:BA,title:"Approve design and notify bot"})]}),X&&!xA.isActive&&st.archiveMode&&D.jsxs(D.Fragment,{children:[D.jsxs("button",{onClick:st.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:[D.jsx("span",{className:"hidden md:inline",children:"Copy"}),D.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.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"})})]}),D.jsx("button",{onClick:st.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"})]}),X&&(!xA.isActive||wA)&&!st.archiveMode&&D.jsxs(D.Fragment,{children:[wA?D.jsxs(D.Fragment,{children:[D.jsx(r_A,{onClick:()=>{Gt?(v("close"),m(!0)):rD()},disabled:BA||_,isLoading:_}),Gt&&D.jsx(Q3,{onClick:tD,disabled:BA||_,isLoading:BA,label:"Send Annotations",title:"Send Annotations"})]}):D.jsx(Q3,{onClick:()=>{const WA=xA.getDocAnnotations(),Ye=Array.from(WA.values()).some(je=>je.annotations.length>0||je.globalAttachments.length>0);oe.length===0&&W.length===0&&!Ye?B(!0):$Q()},disabled:BA,isLoading:BA,label:"Send Feedback",title:"Send Feedback"}),(!wA||YA)&&D.jsxs("div",{className:"relative group/approve",children:[D.jsx(aAA,{onClick:()=>{if(wA){if(Gt){v("approve"),m(!0);return}Af();return}if(tA==="claude-code"&&oe.length>0){f(!0);return}if(tA==="opencode"){const WA=Yd();if(WA){N(WA),b(!0);return}}Jd()},disabled:BA||wA&&_,isLoading:BA,dimmed:!wA&&(tA==="claude-code"||tA==="gemini-cli")&&oe.length>0,title:wA?"Approve — no changes requested":void 0}),!wA&&(tA==="claude-code"||tA==="gemini-cli")&&oe.length>0&&D.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:[D.jsx("div",{className:"absolute bottom-full right-4 border-4 border-transparent border-b-border"}),D.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."]})]}),D.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"})]}),D.jsx("button",{onClick:ut,className:`p-1.5 rounded-md text-xs font-medium transition-all ${L?"bg-primary/15 text-primary":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:L?"Hide annotations":"Show annotations",children:D.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:D.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"})})}),D.jsx("div",{className:"hidden",children:D.jsx(t_A,{taterMode:K,onTaterModeChange:ck,onIdentityChange:uk,origin:tA,onUIPreferencesChange:Y,externalOpen:O,onExternalClose:()=>P(!1),gitUser:rA})}),D.jsx(G_A,{appVersion:"0.19.3",onOpenSettings:()=>{P(!0)},onOpenExport:()=>{lt(void 0),I(!0)},onCopyAgentInstructions:pk,onDownloadAnnotations:Vd,onPrint:()=>window.print(),onCopyShareLink:aD,onOpenImport:()=>E(!0),onSaveToObsidian:()=>Ts("obsidian"),onSaveToBear:()=>Ts("bear"),onSaveToOctarine:()=>Ts("octarine"),sharingEnabled:Be,isApiMode:X,agentInstructionsEnabled:X&&!st.archiveMode&&!wA,obsidianConfigured:F$(),bearConfigured:Eu().enabled,octarineConfigured:Jw()})]})]}),xA.error&&D.jsxs("div",{className:"bg-destructive/10 border-b border-destructive/20 px-4 py-2 flex items-center gap-2 flex-shrink-0",children:[D.jsx("span",{className:"text-xs text-destructive",children:xA.error}),D.jsx("button",{onClick:xA.dismissError,className:"ml-auto text-xs text-destructive/60 hover:text-destructive",children:"dismiss"})]}),D.jsx(bdA.Provider,{value:At,children:D.jsxs("div",{"data-print-region":"content",className:`flex-1 flex overflow-hidden relative z-0 ${Ge?"select-none":""}`,children:[K&&D.jsx(ujA,{}),VA===null&&!ne.isOpen&&D.jsx(WXA,{activeTab:ne.activeTab,onToggleTab:be,hasDiff:kA.hasPreviousVersion,showVersionsTab:QA!==null&&QA.totalVersions>1,showFilesTab:Kr&&!st.archiveMode,hasFileAnnotations:Qt,className:"hidden lg:flex absolute left-0 top-0 z-10"}),ne.isOpen&&D.jsxs(D.Fragment,{children:[D.jsx(n$A,{activeTab:ne.activeTab,onTabChange:WA=>{be(WA),WA==="archive"&&!st.archiveMode&&st.fetchPlans()},onClose:ne.close,width:ar.width,blocks:a,annotations:t,activeSection:Ze,onTocNavigate:hk,linkedDocFilepath:xA.filepath,onLinkedDocBack:xA.isActive?hi:void 0,backLabel:Xn,showFilesTab:Kr&&!st.archiveMode,fileAnnotationCounts:ci,highlightedFiles:Vr,fileBrowser:cr,onFilesSelectFile:Ra,onFilesFetchAll:()=>cr.fetchAll(xn),onFilesRetryVaultDir:WA=>cr.addVaultDir(WA),hasFileAnnotations:Qt,showVersionsTab:QA!==null&&QA.totalVersions>1,versionInfo:QA,versions:kA.versions,selectedBaseVersion:kA.diffBaseVersion,onSelectBaseVersion:kA.selectBaseVersion,isPlanDiffActive:It,hasPreviousVersion:kA.hasPreviousVersion,onActivatePlanDiff:()=>mt(!0),isLoadingVersions:kA.isLoadingVersions,isSelectingVersion:kA.isSelectingVersion,fetchingVersion:kA.fetchingVersion,onFetchVersions:kA.fetchVersions,showArchiveTab:X&&!wA,archivePlans:st.plans,selectedArchiveFile:st.selectedFile,onArchiveSelect:st.select,isLoadingArchive:st.isLoading}),D.jsx(EAA,{...ar.handleProps,className:"hidden lg:block",side:"left"})]}),D.jsxs(hy,{element:"main",className:`flex-1 min-w-0 bg-grid ${!ne.isOpen&&VA===null?"lg:pl-[30px]":""}`,"data-print-region":"document",onViewportReady:Vt,children:[D.jsx(MB,{isOpen:!!fi,onClose:vE,onConfirm:Kd,title:"Draft Recovered",message:fi?`Found ${fi.count} annotation${fi.count!==1?"s":""} from ${fi.timeAgo}. Would you like to restore them?`:"",confirmText:"Restore",cancelText:"Dismiss",showCancel:!0}),D.jsxs("div",{ref:q,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:[!It&&!st.archiveMode&&z.stickyActionsEnabled&&D.jsx(ljA,{inputMethod:G,onInputMethodChange:XQ,mode:x,onModeChange:eD,taterMode:K,repoInfo:Ne,planDiffStats:kA.diffStats,isPlanDiffActive:It,hasPreviousVersion:kA.hasPreviousVersion,onPlanDiffToggle:()=>mt(!It),archiveInfo:st.currentInfo,maxWidth:Cc,remountToken:xA.isActive?`doc:${xA.filepath}`:"plan"}),!It&&!st.archiveMode&&D.jsx("div",{"data-print-hide":!0,className:"w-full mb-3 md:mb-4 flex items-center justify-start",style:Cc==null?void 0:{maxWidth:Cc},children:D.jsx(uhA,{inputMethod:G,onInputMethodChange:XQ,mode:x,onModeChange:eD,taterMode:K})}),kA.diffBlocks&&kA.diffStats&&D.jsx("div",{className:"w-full flex justify-center",style:{display:It?void 0:"none"},children:D.jsx(h$A,{diffBlocks:kA.diffBlocks,diffStats:kA.diffStats,diffMode:Bt,onDiffModeChange:Wt,onPlanDiffToggle:()=>mt(!1),repoInfo:Ne,baseVersionLabel:kA.diffBaseVersion!=null?`v${kA.diffBaseVersion}`:void 0,baseVersion:kA.diffBaseVersion??void 0,maxWidth:rf,annotations:Se,onAddAnnotation:ef,onSelectAnnotation:zd,selectedAnnotationId:i,mode:x})}),_A==="folder"&&!e&&!xA.isActive&&D.jsx("div",{className:"w-full flex justify-center",children:D.jsxs("div",{className:"w-full max-w-3xl p-12 text-center text-muted-foreground",children:[D.jsx("p",{className:"text-lg font-medium mb-2",children:"Select a file to annotate"}),D.jsx("p",{className:"text-sm",children:"Pick a markdown file from the sidebar to begin."})]})}),D.jsxs("div",{className:"w-full flex justify-center relative",style:{display:It&&kA.diffBlocks||_A==="folder"&&!e&&!xA.isActive?"none":void 0},children:[kn&&!It&&!st.archiveMode&&D.jsx("div",{"data-print-hide":!0,className:"absolute -top-5 left-0 right-0 mx-auto w-full flex justify-end pointer-events-none",style:Cc===null?void 0:{maxWidth:Cc??832},children:D.jsx("div",{className:`pointer-events-auto flex items-center gap-1.5 text-[11px] tracking-wide ${K?"mr-[60px]":"mr-[4px]"}`,children:["wide","focus"].map((WA,Ye)=>D.jsxs(Li.Fragment,{children:[Ye>0&&D.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/30 select-none",children:"|"}),D.jsx(ejA,{side:"top",align:"end",content:WA==="wide"?"Hide panels and expand document width":"Hide panels, keep document width",children:D.jsx("button",{type:"button",onClick:()=>Wa(WA),"aria-pressed":VA===WA,className:`cursor-pointer rounded-sm transition-colors duration-150 outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background active:opacity-80 ${VA===WA?"text-foreground":"text-muted-foreground/50 hover:text-muted-foreground"}`,children:WA.charAt(0).toUpperCase()+WA.slice(1)})})]},WA))})}),D.jsx(HqA,{ref:rt,blocks:a,markdown:e,frontmatter:s,annotations:et,onAddAnnotation:ef,onSelectAnnotation:zd,selectedAnnotationId:i,mode:x,inputMethod:G,taterMode:K,globalAttachments:IA,onAddGlobalAttachment:dk,onRemoveGlobalAttachment:Bk,repoInfo:Ne,stickyActions:z.stickyActionsEnabled,planDiffStats:xA.isActive?null:kA.diffStats,isPlanDiffActive:It,onPlanDiffToggle:()=>mt(!It),hasPreviousVersion:!xA.isActive&&kA.hasPreviousVersion,showDemoBadge:!X&&!nr&&!Nt,maxWidth:Cc,onOpenLinkedDoc:Do,linkedDocInfo:xA.isActive?{filepath:xA.filepath,onBack:hi,label:cr.dirs.find(WA=>WA.path===cr.activeDirPath)?.isVault?"Vault File":cr.activeFile?"File":void 0,backLabel:Xn}:null,imageBaseDir:JA,copyLabel:_A==="message"?"Copy message":_A==="file"||_A==="folder"?"Copy file":void 0,archiveInfo:st.currentInfo,sourceInfo:re,onToggleCheckbox:tf.toggle,checkboxOverrides:tf.overrides,actionsLabelMode:j},xA.isActive?`doc:${xA.filepath}`:"plan")]})]})]}),L&&VA===null&&D.jsx(EAA,{...lr.handleProps,className:"hidden md:block",side:"right"}),D.jsx(tVA,{isOpen:L&&VA===null,blocks:a,annotations:oe,selectedId:i,onSelect:n,onDelete:Ek,onEdit:nD,sharingEnabled:Be,width:lr.width,editorAnnotations:W,onDeleteEditorAnnotation:AA,onClose:()=>T(!1),onQuickCopy:async()=>{await navigator.clipboard.writeText(tsA(Ic))},onShare:Ht?()=>{T(!1),lt("share"),I(!0)}:void 0,otherFileAnnotations:Tt,onOtherFileAnnotationsClick:Qi})]})}),D.jsx(lVA,{isOpen:l,onClose:()=>{I(!1),lt(void 0)},shareUrl:Ht,shareUrlSize:bt,shortShareUrl:Ot,isGeneratingShortUrl:Ii,shortUrlError:$n,onGenerateShortUrl:on,annotationsOutput:Ic,annotationCount:oe.length,taterSprite:K?D.jsx(I9,{}):void 0,sharingEnabled:Be,markdown:e,isApiMode:X,initialTab:Pe}),D.jsx(cVA,{isOpen:C,onClose:()=>E(!1),onImport:xs,shareBaseUrl:HA}),D.jsx(MB,{isOpen:u,onClose:()=>B(!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"}),D.jsx(MB,{isOpen:h,onClose:()=>f(!1),onConfirm:()=>{f(!1),Jd()},title:"Annotations Won't Be Sent",message:D.jsxs(D.Fragment,{children:[fg," doesn't yet support feedback on approval. Your ",oe.length," annotation",oe.length!==1?"s":""," will be lost."]}),subMessage:D.jsxs(D.Fragment,{children:["To send feedback, use ",D.jsx("strong",{children:"Send Feedback"})," instead.",D.jsx("br",{}),D.jsx("br",{}),"Want this feature? Upvote these issues:",D.jsx("br",{}),D.jsx("a",{href:"https://github.com/anthropics/claude-code/issues/16001",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"#16001"})," · ",D.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}),D.jsx(MB,{isOpen:p,onClose:()=>m(!1),onConfirm:()=>{m(!1),w==="approve"?Af():rD()},title:"Annotations Won't Be Sent",message:D.jsxs(D.Fragment,{children:["You have ",oe.length+W.length+xA.docAnnotationCount+IA.length," annotation",oe.length+W.length+xA.docAnnotationCount+IA.length!==1?"s":""," that will be lost if you ",w==="approve"?"approve":"close","."]}),subMessage:"To send your annotations, use Send Annotations instead.",confirmText:w==="approve"?"Approve Anyway":"Close Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),D.jsx(MB,{isOpen:M,onClose:()=>b(!1),onConfirm:()=>{b(!1),Jd()},title:"Agent Not Found",message:R,subMessage:D.jsxs(D.Fragment,{children:["You can change the agent in ",D.jsx("strong",{children:"Settings"}),", or approve anyway and OpenCode will use the default agent."]}),confirmText:"Approve Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),D.jsx(MB,{isOpen:!!Ln&&!X,onClose:gl,title:"Shared Plan Could Not Be Loaded",message:Ln,subMessage:"You are viewing a demo plan. This is sample content — it is not your data or anyone else's.",variant:"warning"}),We&&D.jsx("div",{className:`fixed top-16 right-4 z-50 px-3 py-2 rounded-lg text-xs font-medium shadow-lg transition-opacity ${We.type==="success"?"bg-success/15 text-success border border-success/30":"bg-destructive/15 text-destructive border border-destructive/30"}`,children:We.message}),D.jsx(B_A,{submitted:fA,title:st.archiveMode?"Archive Closed":fA==="exited"?"Session Closed":fA==="approved"?wA?"Approved":"Plan Approved":wA?"Annotations Sent":"Feedback Sent",subtitle:fA==="exited"?"Annotation session closed without feedback.":st.archiveMode?"You can reopen with plannotator archive.":fA==="approved"?wA?`${fg} will proceed.`:`${fg} will proceed with the implementation.`:wA?`${fg} will address your annotations on the ${_A==="message"?"message":_A==="folder"?"files":"file"}.`:`${fg} will revise the plan based on your annotations.`,agentLabel:fg}),D.jsx(y_A,{origin:tA,isWSL:sA}),D.jsx(QgA,{isOpen:!!EA,imageSrc:EA?.blobUrl??"",initialName:EA?.initialName,onAccept:Ik,onClose:Ck}),D.jsx(q_A,{isOpen:PA,onComplete:WA=>{Ae(WA),FA(!1)}})]})})})},AQA=document.getElementById("root");if(!AQA)throw new Error("Could not find root element to mount to");const w$A=z1A.createRoot(AQA);w$A.render(D.jsx(Li.StrictMode,{children:D.jsx(D$A,{})}));class ko{constructor(A,t,r){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=A,this.start=t,this.end=r}static range(A,t){return t?!A||!A.loc||!t.loc||A.loc.lexer!==t.loc.lexer?null:new ko(A.loc.lexer,A.loc.start,t.loc.end):A&&A.loc}}class Qs{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 Qs(t,ko.range(this,A))}}class $e{constructor(A,t){this.name=void 0,this.position=void 0,this.length=void 0,this.rawMessage=void 0;var r="KaTeX parse error: "+A,i,n,a=t&&t.loc;if(a&&a.start<=a.end){var o=a.lexer.input;i=a.start,n=a.end,i===o.length?r+=" at end of input: ":r+=" at position "+(i+1)+": ";var s=o.slice(i,n).replace(/[^]/g,"$&̲"),g;i>15?g="…"+o.slice(i-15,i):g=o.slice(0,i);var l;n+15<o.length?l=o.slice(n,n+15)+"…":l=o.slice(n),r+=g+s+l}var I=new Error(r);return I.name="ParseError",I.__proto__=$e.prototype,I.position=i,i!=null&&n!=null&&(I.length=n-i),I.rawMessage=A,I}}$e.prototype.__proto__=Error.prototype;var v$A=function(A,t){return A===void 0?t:A},S$A=/([A-Z])/g,b$A=function(A){return A.replace(S$A,"-$1").toLowerCase()},R$A={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},N$A=/[&><"']/g;function M$A(e){return String(e).replace(N$A,A=>R$A[A])}var eQA=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},k$A=function(A){var t=eQA(A);return t.type==="mathord"||t.type==="textord"||t.type==="atom"},x$A=function(A){if(!A)throw new Error("Expected non-null, but got "+String(A));return A},T$A=function(A){var t=/^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(A);return t?t[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():"_relative"},zr={deflt:v$A,escape:M$A,hyphenate:b$A,getBaseElem:eQA,isCharacterBox:k$A,protocolFromUrl:T$A},J0={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 L$A(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 B9{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 J0)if(J0.hasOwnProperty(t)){var r=J0[t];this[t]=A[t]!==void 0?r.processor?r.processor(A[t]):A[t]:L$A(r)}}reportNonstrict(A,t,r){var i=this.strict;if(typeof i=="function"&&(i=i(A,t,r)),!(!i||i==="ignore")){if(i===!0||i==="error")throw new $e("LaTeX-incompatible input and strict mode is set to 'error': "+(t+" ["+A+"]"),r);i==="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 '"+i+"': "+t+" ["+A+"]"))}}useStrictBehavior(A,t,r){var i=this.strict;if(typeof i=="function")try{i=i(A,t,r)}catch{i="error"}return!i||i==="ignore"?!1:i===!0||i==="error"?!0:i==="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 '"+i+"': "+t+" ["+A+"]")),!1)}isTrusted(A){if(A.url&&!A.protocol){var t=zr.protocolFromUrl(A.url);if(t==null)return!1;A.protocol=t}var r=typeof this.trust=="function"?this.trust(A):this.trust;return!!r}}class tC{constructor(A,t,r){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=A,this.size=t,this.cramped=r}sup(){return Rl[F$A[this.id]]}sub(){return Rl[G$A[this.id]]}fracNum(){return Rl[O$A[this.id]]}fracDen(){return Rl[U$A[this.id]]}cramp(){return Rl[K$A[this.id]]}text(){return Rl[Y$A[this.id]]}isTight(){return this.size>=2}}var h9=0,kb=1,Dh=2,rI=3,bm=4,tg=5,nQ=6,oo=7,Rl=[new tC(h9,0,!1),new tC(kb,0,!0),new tC(Dh,1,!1),new tC(rI,1,!0),new tC(bm,2,!1),new tC(tg,2,!0),new tC(nQ,3,!1),new tC(oo,3,!0)],F$A=[bm,tg,bm,tg,nQ,oo,nQ,oo],G$A=[tg,tg,tg,tg,oo,oo,oo,oo],O$A=[Dh,rI,bm,tg,nQ,oo,nQ,oo],U$A=[rI,rI,tg,tg,oo,oo,oo,oo],K$A=[kb,kb,rI,rI,tg,tg,oo,oo],Y$A=[h9,kb,Dh,rI,Dh,rI,Dh,rI],Yt={DISPLAY:Rl[h9],TEXT:Rl[Dh],SCRIPT:Rl[bm],SCRIPTSCRIPT:Rl[nQ]},r5=[{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 P$A(e){for(var A=0;A<r5.length;A++)for(var t=r5[A],r=0;r<t.blocks.length;r++){var i=t.blocks[r];if(e>=i[0]&&e<=i[1])return t.name}return null}var RS=[];r5.forEach(e=>e.blocks.forEach(A=>RS.push(...A)));function tQA(e){for(var A=0;A<RS.length;A+=2)if(e>=RS[A]&&e<=RS[A+1])return!0;return!1}var xB=80,H$A=function(A,t){return"M95,"+(622+A+t)+`
1144
1144
  c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
1145
1145
  c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
1146
1146
  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