@plannotator/pi-extension 0.19.10 → 0.19.11
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/generated/agent-review-message.ts +148 -0
- package/generated/claude-review.ts +5 -1
- package/generated/codex-review.ts +0 -82
- package/generated/jj-core.ts +329 -0
- package/generated/review-args.ts +86 -0
- package/generated/review-core.ts +73 -1
- package/generated/tour-review.ts +17 -33
- package/generated/vcs-core.ts +452 -0
- package/index.ts +9 -4
- package/package.json +1 -1
- package/plannotator-browser.ts +143 -133
- package/plannotator-events.ts +5 -1
- package/plannotator.html +3 -3
- package/review-editor.html +98 -51
- package/server/serverReview.ts +30 -102
- package/server/vcs.ts +120 -0
- package/server.ts +17 -3
package/plannotator.html
CHANGED
|
@@ -667,7 +667,7 @@ created: ${new Date().toISOString().slice(0,19)}Z
|
|
|
667
667
|
source: plannotator
|
|
668
668
|
tags: [plan, ...]
|
|
669
669
|
---`})]}),y.jsx("div",{className:"border-t border-border/30"}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Obsidian when a plan loads, before you approve or deny"})]}),y.jsx("button",{role:"switch","aria-checked":I.autoSave,onClick:()=>At({autoSave:!I.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${I.autoSave?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${I.autoSave?"translate-x-6":"translate-x-1"}`})})]}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-xs font-medium",children:"Vault Browser"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Browse and annotate vault files from the sidebar"})]}),y.jsx("button",{role:"switch","aria-checked":I.vaultBrowserEnabled,onClick:()=>At({vaultBrowserEnabled:!I.vaultBrowserEnabled}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${I.vaultBrowserEnabled?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${I.vaultBrowserEnabled?"translate-x-6":"translate-x-1"}`})})]})]})]})]}),m==="bear"&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-sm font-medium",children:"Bear Notes"}),y.jsx("div",{className:"text-xs text-muted-foreground",children:"Auto-save approved plans to Bear"})]}),y.jsx("button",{role:"switch","aria-checked":x.enabled,onClick:()=>_e({enabled:!x.enabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${x.enabled?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${x.enabled?"translate-x-6":"translate-x-1"}`})})]}),x.enabled&&y.jsxs("div",{className:"mt-3 space-y-3",children:[y.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[y.jsx("label",{className:"text-xs text-muted-foreground",children:"Custom Tags"}),y.jsx("input",{type:"text",value:x.customTags,onChange:Ee=>_e({customTags:Ee.target.value}),onBlur:Ee=>_e({customTags:ftt(Ee.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"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Comma-separated, kebab-case. Leave empty for auto-generated tags."})]}),y.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[y.jsx("label",{className:"text-xs text-muted-foreground",children:"Tag Position"}),y.jsxs("select",{value:x.tagPosition,onChange:Ee=>_e({tagPosition:Ee.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:[y.jsx("option",{value:"append",children:"Append (end of note)"}),y.jsx("option",{value:"prepend",children:"Prepend (after title)"})]})]}),y.jsx("div",{className:"border-t border-border/30"}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Bear when a plan loads, before you approve or deny"})]}),y.jsx("button",{role:"switch","aria-checked":x.autoSave,onClick:()=>_e({autoSave:!x.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${x.autoSave?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${x.autoSave?"translate-x-6":"translate-x-1"}`})})]})]})]}),m==="octarine"&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-sm font-medium",children:"Octarine"}),y.jsx("div",{className:"text-xs text-muted-foreground",children:"Auto-save approved plans to Octarine"})]}),y.jsx("button",{role:"switch","aria-checked":F.enabled,onClick:()=>et({enabled:!F.enabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${F.enabled?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${F.enabled?"translate-x-6":"translate-x-1"}`})})]}),F.enabled&&y.jsxs("div",{className:"mt-3 space-y-3",children:[y.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[y.jsx("label",{className:"text-xs text-muted-foreground",children:"Workspace Name"}),y.jsx("input",{type:"text",value:F.workspace,onChange:Ee=>et({workspace:Ee.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"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"The Octarine workspace name to save plans into."})]}),y.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[y.jsx("label",{className:"text-xs text-muted-foreground",children:"Folder"}),y.jsx("input",{type:"text",value:F.folder,onChange:Ee=>et({folder:Ee.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"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Subfolder within the workspace for saved plans."})]}),y.jsxs("div",{className:"text-[10px] text-muted-foreground/70",children:["Plans saved to: ",F.workspace||"..."," / ",F.folder||"plannotator","/"]}),y.jsx("div",{className:"border-t border-border/30"}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{children:[y.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),y.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Octarine when a plan loads, before you approve or deny"})]}),y.jsx("button",{role:"switch","aria-checked":F.autoSave,onClick:()=>et({autoSave:!F.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${F.autoSave?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${F.autoSave?"translate-x-6":"translate-x-1"}`})})]})]})]})]})})]})]})}),document.body),g&&YA.createPortal(y.jsxs("div",{className:"fixed inset-0 z-[100] flex flex-col pointer-events-none",children:[y.jsx("div",{className:"flex-1"}),y.jsxs("div",{className:"pointer-events-auto w-full bg-card border-t-2 border-primary/30 shadow-[0_-4px_20px_rgba(0,0,0,0.4)] flex flex-col max-h-[35vh] overflow-hidden",onClick:Ee=>Ee.stopPropagation(),children:[y.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border flex-shrink-0",children:[y.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Theme Preview"}),y.jsx("button",{onClick:()=>{p(!1),u(!0)},className:"px-2.5 py-1 rounded-md text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 transition-colors",children:"Done"})]}),y.jsx("div",{className:"p-3 overflow-y-auto flex-1 min-h-0",children:y.jsx(ere,{compact:!0})})]})]}),document.body)]})},n8=({onClick:t,disabled:e=!1,isLoading:n=!1,label:a="Send Feedback",shortLabel:r,loadingLabel:i="Sending...",shortLoadingLabel:A,title:o="Send Feedback",muted:s=!1})=>y.jsxs("button",{onClick:t,disabled:e,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":e?"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:[y.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),r?y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"hidden md:inline lg:hidden",children:n?A??i:r}),y.jsx("span",{className:"hidden lg:inline",children:n?i:a})]}):y.jsx("span",{className:"hidden md:inline",children:n?i:a})]}),nre=({onClick:t,disabled:e=!1,isLoading:n=!1,label:a="Approve",loadingLabel:r="Approving...",mobileLabel:i="OK",mobileLoadingLabel:A="...",title:o,dimmed:s=!1,muted:l=!1})=>y.jsxs("button",{onClick:t,disabled:e,className:`px-2 py-1 md:px-2.5 rounded-md text-xs font-medium transition-all ${l?"opacity-40 cursor-not-allowed bg-muted text-muted-foreground":e?"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:[y.jsx("span",{className:"md:hidden",children:n?A:i}),y.jsx("span",{className:"hidden md:inline",children:n?r:a})]}),lrt=({onClick:t,disabled:e=!1,isLoading:n=!1,title:a="Close session without sending feedback"})=>y.jsxs("button",{onClick:t,disabled:e||n,className:`px-2.5 py-1 rounded-md text-xs font-medium transition-all ${e||n?"opacity-50 cursor-not-allowed bg-muted text-muted-foreground":"bg-muted text-muted-foreground hover:bg-muted/80"}`,title:a,children:[y.jsx("span",{className:"md:hidden",children:n?"...":"✕"}),y.jsx("span",{className:"hidden md:inline",children:n?"Closing...":"Close"})]});function drt(t,e){return t.switchTo==="disabled"?null:t.switchTo==="custom"&&t.customName?t.customName:e.find(a=>a.id.toLowerCase()===t.switchTo.toLowerCase())?.name??t.switchTo}function urt(t,e){return e.switchTo==="custom"||e.switchTo==="disabled"?!1:t.toLowerCase()===e.switchTo.toLowerCase()}const a8=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),grt=({onApprove:t,agents:e,disabled:n=!1,isLoading:a=!1})=>{const[r,i]=J.useState(()=>IR()),[A,o]=J.useState(!1),s=J.useRef(null);J.useEffect(()=>{const b=I=>{s.current&&!s.current.contains(I.target)&&o(!1)},C=I=>{I.key==="Escape"&&o(!1)};return document.addEventListener("pointerdown",b),document.addEventListener("keydown",C),()=>{document.removeEventListener("pointerdown",b),document.removeEventListener("keydown",C)}},[]);const l=b=>{i(b),Rye(b),o(!1)},d=drt(r,e),u=r.switchTo==="disabled",g=r.switchTo==="custom",p=d&&!u&&!g&&!e.some(b=>b.id.toLowerCase()===r.switchTo.toLowerCase()),m=n?"opacity-50 cursor-not-allowed bg-muted text-muted-foreground":"bg-success text-success-foreground hover:opacity-90",f=()=>{o(!1),t()};return y.jsxs("div",{className:"relative",ref:s,children:[y.jsx("button",{onClick:f,disabled:n,className:`md:hidden px-2 py-1 rounded-md text-xs font-medium transition-all ${m}`,children:a?"...":"OK"}),y.jsxs("div",{className:"hidden md:flex items-stretch",children:[y.jsx("button",{onClick:f,disabled:n,className:`px-2.5 py-1 rounded-l-md text-xs font-medium transition-all ${m}`,children:a?"Approving...":d?y.jsxs("span",{className:"flex items-center gap-1",children:["Approve",y.jsx("span",{className:"opacity-60",children:"→"}),y.jsx("span",{className:"max-w-[120px] truncate",children:d}),p&&y.jsx("span",{className:"opacity-60 text-[10px]",children:"(?)"})]}):"Approve"}),y.jsx("button",{onClick:()=>o(!A),disabled:n,className:`px-1.5 py-1 rounded-r-md border-l border-success-foreground/20 text-xs transition-all ${m}`,children:y.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})})]}),A&&y.jsxs("div",{className:"absolute right-0 top-full mt-1 w-52 rounded-lg border border-border bg-popover shadow-xl z-[70] overflow-hidden py-1",children:[y.jsx("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wider text-muted-foreground/70 font-medium",children:"Switch to agent"}),e.map(b=>{const C=urt(b.id,r);return y.jsxs("button",{onClick:()=>l({switchTo:b.id}),className:`w-full px-3 py-1.5 text-left text-xs transition-colors flex items-center gap-2 ${C?"text-primary bg-primary/10 font-medium":"text-popover-foreground hover:bg-muted"}`,children:[y.jsx("span",{className:"w-4 flex-shrink-0",children:C&&y.jsx(a8,{})}),y.jsx("span",{className:"truncate",children:b.name})]},b.id)}),g&&r.customName&&y.jsxs("button",{onClick:()=>o(!1),className:"w-full px-3 py-1.5 text-left text-xs transition-colors flex items-center gap-2 text-primary bg-primary/10 font-medium",children:[y.jsx("span",{className:"w-4 flex-shrink-0",children:y.jsx(a8,{})}),y.jsx("span",{className:"truncate",children:r.customName}),y.jsx("span",{className:"text-[10px] text-muted-foreground ml-auto",children:"(custom)"})]}),y.jsx("div",{className:"border-t border-border my-1"}),y.jsxs("button",{onClick:()=>l({switchTo:"disabled"}),className:`w-full px-3 py-1.5 text-left text-xs transition-colors flex items-center gap-2 ${u?"text-primary bg-primary/10 font-medium":"text-popover-foreground hover:bg-muted"}`,children:[y.jsx("span",{className:"w-4 flex-shrink-0",children:u&&y.jsx(a8,{})}),"No switch"]})]})]})};async function Zye(t){const e=JSON.stringify(t),n=new TextEncoder().encode(e),a=new CompressionStream("deflate-raw"),r=a.writable.getWriter();r.write(n),r.close();const i=await new Response(a.readable).arrayBuffer(),A=new Uint8Array(i);let o="";for(let l=0;l<A.length;l++)o+=String.fromCharCode(A[l]);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async function KS(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),n=atob(e),a=Uint8Array.from(n,s=>s.charCodeAt(0)),r=new DecompressionStream("deflate-raw"),i=r.writable.getWriter();i.write(a),i.close();const A=await new Response(r.readable).arrayBuffer(),o=new TextDecoder().decode(A);return JSON.parse(o)}async function prt(t){const e=await crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt"]),n=crypto.getRandomValues(new Uint8Array(12)),a=new TextEncoder().encode(t),r=await crypto.subtle.encrypt({name:"AES-GCM",iv:n},e,a),i=new Uint8Array(n.length+r.byteLength);i.set(n,0),i.set(new Uint8Array(r),n.length);const A=await crypto.subtle.exportKey("raw",e);return{ciphertext:are(i),key:are(new Uint8Array(A))}}async function mrt(t,e){const n=rre(t),a=rre(e),r=n.slice(0,12),i=n.slice(12),A=await crypto.subtle.importKey("raw",a.buffer,{name:"AES-GCM",length:256},!1,["decrypt"]),o=await crypto.subtle.decrypt({name:"AES-GCM",iv:r},A,i);return new TextDecoder().decode(o)}function are(t){let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function rre(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),n=atob(e);return Uint8Array.from(n,a=>a.charCodeAt(0))}function vC(t){if(t?.length)return t.map(e=>{if(typeof e=="string"){const n=e.split("/").pop()?.replace(/\.[^.]+$/,"")||"image";return{path:e,name:n}}return{path:e[0],name:e[1]}})}function qH(t){if(t?.length)return t.map(e=>[e.path,e.name])}function Vye(t){return t.map(e=>{const n=e.author||null,a=qH(e.images);return e.type===Ba.GLOBAL_COMMENT?["G",e.text||"",n,a]:e.type===Ba.DELETION?["D",e.originalText,n,a]:e.isQuickLabel?["C",e.originalText,e.text||"",n,a??void 0,1]:["C",e.originalText,e.text||"",n,a]})}function _x(t,e,n){const a={D:Ba.DELETION,C:Ba.COMMENT,G:Ba.GLOBAL_COMMENT};return t.map((r,i)=>{const A=r[0];if(A==="G"){const g=r[1],p=r[2],m=r[3];return{id:`shared-${i}-${Date.now()}`,blockId:"",startOffset:0,endOffset:0,type:Ba.GLOBAL_COMMENT,text:g||void 0,originalText:"",createdA:Date.now()+i,author:p||void 0,images:vC(m),...n?.[i]?{source:n[i]}:{}}}const o=r[1],s=A==="D"?void 0:r[2],l=A==="D"?r[2]:r[3],d=A==="D"?r[3]:r[4],u=A==="C"&&r.length>5&&r[5]===1?!0:void 0;return{id:`shared-${i}-${Date.now()}`,blockId:"",startOffset:0,endOffset:0,type:a[A],text:s||void 0,originalText:o,createdA:Date.now()+i,author:l||void 0,images:vC(d),...u?{isQuickLabel:u}:{},...e?.[i]?{diffContext:e[i]}:{},...n?.[i]?{source:n[i]}:{}}})}function Xye(t){const e=t.map(n=>n.diffContext||null);return e.some(n=>n!==null)?e:null}function $ye(t){const e=t.map(n=>n.source||void 0);return e.some(n=>n!==void 0)?e:null}async function hrt(t,e,n,a=eQe){const r=Xye(e),i=$ye(e),A={p:t,a:Vye(e),g:n?.length?qH(n):void 0,...r?{d:r}:{},...i?{s:i}:{}},o=await Zye(A);return`${a}/#${o}`}async function frt(){const e=window.location.hash.slice(1).split("?")[0];if(!e)return null;try{return await KS(e)}catch(n){return console.warn("Failed to parse share hash:",n),null}}function brt(t){const e=new Blob([t]).size;return e<1024?`${e} B`:`${(e/1024).toFixed(1)} KB`}const iP="https://plannotator-paste.plannotator.workers.dev",eQe="https://share.plannotator.ai";async function Crt(t,e,n,a){const r=a?.pasteApiUrl??iP,i=a?.shareBaseUrl??eQe;try{const A=Xye(e),o=$ye(e),s={p:t,a:Vye(e),g:n?.length?qH(n):void 0,...A?{d:A}:{},...o?{s:o}:{}},l=await Zye(s),{ciphertext:d,key:u}=await prt(l),g=await fetch(`${r}/api/paste`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:d}),signal:AbortSignal.timeout(5e3)});if(!g.ok)return console.warn(`[sharing] Paste service returned ${g.status}`),null;const p=await g.json(),m=r!==iP?`&paste=${btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}`:"";return{shortUrl:`${i}/p/${p.id}#key=${u}${m}`,id:p.id}}catch(A){return console.debug("[sharing] Short URL service unavailable, using hash-based sharing:",A),null}}async function ire(t,e=iP,n){try{const a=await fetch(`${e}/api/paste/${t}`,{signal:AbortSignal.timeout(1e4)});if(!a.ok)return console.warn(`[sharing] Paste fetch returned ${a.status} for id ${t}`),null;const r=await a.json();if(n){const i=await mrt(r.data,n);return await KS(i)}return await KS(r.data)}catch(a){return console.warn("[sharing] Failed to load from paste ID:",a),null}}function Are(t){const e=t.replace(/^#/,"").split("?")[0];return e.length>=30&&/^[A-Za-z0-9_-]+$/.test(e)&&/[A-Z]/.test(e)}function Ert(t,e,n,a,r,i,A,o,s){const[l,d]=J.useState(!1),[u,g]=J.useState(!0),[p,m]=J.useState(""),[f,b]=J.useState(""),[C,I]=J.useState(""),[B,w]=J.useState(!1),[k,_]=J.useState(""),[D,x]=J.useState(null),[S,F]=J.useState(null),[M,O]=J.useState(""),K=J.useCallback(()=>{x(null),F(null)},[]),R=J.useCallback(()=>O(""),[]),G=J.useCallback(async()=>{try{const H=window.location.pathname.match(/^\/p\/([A-Za-z0-9]{6,16})$/);if(H){const j=H[1],Z=window.location.hash.slice(1),$=new URLSearchParams(Z),X=$.get("key")??void 0,ce=$.get("paste")?atob($.get("paste").replace(/-/g,"+").replace(/_/g,"/")):void 0,te=await ire(j,ce??s,X);if(te){a(te.p);const he=_x(te.a,te.d,te.s);if(r(he),te.g?.length){const se=vC(te.g)??[];i(se),F(se)}x(he),d(!0),A?.();const ae=window.location.pathname.replace(/\/p\/[A-Za-z0-9]+$/,"")||"/";return window.history.replaceState({},"",ae),!0}return O("Failed to load shared plan — the link may be expired or incomplete."),!1}const q=window.location.hash.slice(1);if(!Are(q))return!1;const P=await frt();if(P){a(P.p);const j=_x(P.a,P.d,P.s);if(r(j),P.g?.length){const Z=vC(P.g)??[];i(Z),F(Z)}return x(j),d(!0),A?.(),window.history.replaceState({},"",window.location.pathname),!0}return q&&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}},[a,r,i,A,s]);J.useEffect(()=>{G().finally(()=>g(!1))},[]),J.useEffect(()=>{const H=()=>{Are(window.location.hash)&&G()};return window.addEventListener("hashchange",H),()=>window.removeEventListener("hashchange",H)},[G]);const T=J.useCallback(async()=>{try{const H=await hrt(t,e,n,o);m(H),b(brt(H))}catch(H){console.error("Failed to generate share URL:",H),m(""),b("")}},[t,e,n,o]);J.useEffect(()=>{T()},[T]),J.useEffect(()=>{I(""),_("")},[t,e]);const L=J.useCallback(async()=>{if(t){w(!0),_("");try{const H=await Crt(t,e,n,{pasteApiUrl:s,shareBaseUrl:o});H?I(H.shortUrl):(I(""),_("Short URL service unavailable"))}catch{I(""),_("Failed to generate short URL")}finally{w(!1)}}},[t,e,n,o,s]),U=J.useCallback(async H=>{try{let q;const P=H.match(/\/p\/([A-Za-z0-9]{6,16})(?:#(.*))?(?:\?|$)/);if(P){const te=P[1],he=new URLSearchParams(P[2]??""),ae=he.get("key")??void 0,se=he.get("paste")?atob(he.get("paste").replace(/-/g,"+").replace(/_/g,"/")):void 0,oe=await ire(te,se??s,ae);if(!oe)return{success:!1,count:0,planTitle:"",error:"Failed to load from short URL — paste may have expired"};q=oe}else{const te=H.indexOf("#");if(te===-1)return{success:!1,count:0,planTitle:"",error:"Invalid share URL: no hash fragment or short link found"};const he=H.slice(te+1);if(!he)return{success:!1,count:0,planTitle:"",error:"Invalid share URL: empty hash"};q=await KS(he)}const Z=(q.p||"").trim().split(`
|
|
670
|
-
`).find(te=>te.startsWith("#")),$=Z?Z.replace(/^#+\s*/,"").trim():"Unknown Plan",X=_x(q.a,q.d,q.s);if(X.length===0)return{success:!0,count:0,planTitle:$,error:"No annotations found in share link"};const ce=X.filter(te=>!e.some(he=>he.originalText===te.originalText&&he.type===te.type&&he.text===te.text));if(ce.length>0&&(r(te=>{const he=X.filter(se=>!te.some(oe=>oe.originalText===se.originalText&&oe.type===se.type&&oe.text===se.text));if(he.length===0)return te;const ae=[...te,...he];return x(ae),ae}),q.g?.length)){const te=vC(q.g)??[];i(he=>{const ae=new Set(he.map(oe=>oe.path)),se=te.filter(oe=>!ae.has(oe.path));return se.length>0?[...he,...se]:he}),F(te)}return{success:!0,count:ce.length,planTitle:$}}catch(q){return{success:!1,count:0,planTitle:"",error:q instanceof Error?q.message:"Failed to decompress share URL"}}},[e,n,r,i,s]);return{isSharedSession:l,isLoadingShared:u,shareUrl:p,shareUrlSize:f,shortShareUrl:C,isGeneratingShortUrl:B,shortUrlError:k,pendingSharedAnnotations:D,sharedGlobalAttachments:S,clearPendingSharedAnnotations:K,refreshShareUrl:T,generateShortUrl:L,importFromShareUrl:U,shareLoadError:M,clearShareLoadError:R}}var Rx=(t=>(t.Approve="approve",t.Feedback="feedback",t))(Rx||{});function Irt(t=window.location){const e=new URLSearchParams(t.search);let n=e.get("cb"),a=e.get("ct");if(!n||!a){const r=t.hash.indexOf("?");if(r!==-1){const i=new URLSearchParams(t.hash.slice(r+1));n=n??i.get("cb"),a=a??i.get("ct")}}if(!n||!a)return null;try{const{protocol:r}=new URL(n);if(r!=="https:"&&r!=="http:")return null}catch{return null}return{callbackUrl:n,token:a}}async function Brt(t,e,n){const a=t==="approve"?"Plan approved! The bot will proceed to implementation.":"Feedback sent! The bot will re-plan with your annotations.";try{const r=await fetch(e.callbackUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t,token:e.token,annotated_url:n})});return r.ok?{type:"success",message:a}:{type:"error",message:r.status===401?"Plan link expired — request a new one from the bot.":"Callback failed."}}catch{return{type:"error",message:"Callback failed."}}}function yrt(t,e,n){const[a,r]=J.useState(null),i=J.useRef(null);return J.useEffect(()=>{const A=n??t.current;if(!A)return;const o=A.querySelectorAll('[data-block-type="heading"]');if(o.length===0)return;const s=new Map;return i.current=new IntersectionObserver(l=>{l.forEach(g=>{s.set(g.target,g.isIntersecting)});let d=null,u=1/0;for(const[g,p]of s)if(p){const m=g.getBoundingClientRect();m.top<u&&(u=m.top,d=g)}if(d){const g=d.getAttribute("data-block-id");g&&r(g)}},{root:A,rootMargin:"-80px 0px -80% 0px",threshold:[0,.1,.5,1]}),o.forEach(l=>{i.current?.observe(l)}),()=>{i.current?.disconnect()}},[t,e,n]),a}function ore(t){window.close(),setTimeout(()=>{window.closed||t()},300)}function Qrt(t){const[e,n]=J.useState({phase:"idle"});J.useEffect(()=>{if(!t)return;const r=Qpe();r==="0"?(ore(()=>n({phase:"closeFailed"})),n({phase:"closed"})):n(r!=="off"?{phase:"counting",remaining:Number(r)}:{phase:"prompt"})},[t]),J.useEffect(()=>{if(e.phase!=="counting")return;if(e.remaining<=0){ore(()=>n({phase:"closeFailed"}));return}const r=setTimeout(()=>n(i=>i.phase==="counting"?{phase:"counting",remaining:i.remaining-1}:i),1e3);return()=>clearTimeout(r)},[e]);const a=J.useCallback(()=>{wpe("3"),n({phase:"counting",remaining:3})},[]);return{state:e,enableAndStart:a}}const wrt=()=>y.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),krt=()=>y.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:y.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 vrt({submitted:t,title:e,subtitle:n,agentLabel:a}){const{state:r,enableAndStart:i}=Qrt(!!t);if(!t)return null;const A=t==="approved";return y.jsx("div",{className:"fixed inset-0 z-[100] bg-background flex items-center justify-center",children:y.jsxs("div",{className:"text-center space-y-6 max-w-md px-8",children:[y.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?y.jsx(wrt,{}):y.jsx(krt,{})}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("h2",{className:"text-xl font-semibold text-foreground",children:e}),y.jsx("p",{className:"text-muted-foreground",children:n})]}),y.jsx("div",{className:"pt-4 border-t border-border space-y-2",children:r.phase==="counting"?y.jsxs(y.Fragment,{children:[y.jsxs("p",{className:"text-sm text-muted-foreground",children:["This tab will close in ",y.jsx("span",{className:"text-foreground font-medium",children:r.remaining})," second",r.remaining!==1?"s":"","..."]}),y.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change this in Settings."})]}):r.phase==="closeFailed"?y.jsxs(y.Fragment,{children:[y.jsx("p",{className:"text-sm text-muted-foreground",children:"Could not close this tab automatically. Please close it manually."}),y.jsxs("p",{className:"text-xs text-muted-foreground/60",children:["Auto-close works when the tab is opened by ",a,"."]})]}):y.jsxs(y.Fragment,{children:[y.jsxs("p",{className:"text-sm text-muted-foreground",children:["You can close this tab and return to ",y.jsx("span",{className:"text-foreground font-medium",children:a}),"."]}),r.phase==="prompt"?y.jsxs(y.Fragment,{children:[y.jsxs("label",{className:"flex items-center justify-center gap-2 cursor-pointer group",children:[y.jsx("input",{type:"checkbox",checked:!1,onChange:i,className:"accent-primary"}),y.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-foreground transition-colors",children:"Auto-close this tab after 3 seconds"})]}),y.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change the delay in Settings."})]}):y.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Your response has been sent."})]})})]})})}const Drt="https://api.github.com/repos/backnotprop/plannotator/releases/latest",sre={"0.5.0":{title:"Code Review is here!",description:"Review git diffs with inline annotations. Run /plannotator-review to try it."}};function xrt(t,e){const n=i=>i.replace(/^v/,""),a=n(t).split(".").map(Number),r=n(e).split(".").map(Number);for(let i=0;i<Math.max(a.length,r.length);i++){const A=a[i]||0,o=r[i]||0;if(o>A)return!0;if(o<A)return!1}return!1}function Srt(){const[t,e]=J.useState(null);return J.useEffect(()=>{(async()=>{try{const a="0.19.10",i=new URLSearchParams(window.location.search).get("preview-update");if(i){const g=i.replace(/^v/,"");e({currentVersion:a,latestVersion:i,updateAvailable:!0,releaseUrl:`https://github.com/backnotprop/plannotator/releases/tag/v${g}`,featureHighlight:sre[g]});return}const A=await fetch(Drt);if(!A.ok)return;const o=await A.json(),s=o.tag_name,l=xrt(a,s),d=s.replace(/^v/,""),u=sre[d];e({currentVersion:a,latestVersion:s,updateAvailable:l,releaseUrl:o.html_url,featureHighlight:u})}catch(a){console.debug("Update check failed:",a)}})()},[]),t}const _rt="pi install npm:@plannotator/pi-extension";function Rrt(t){return YOe&&!t?'powershell -c "irm https://plannotator.ai/install.ps1 | iex"':"curl -fsSL https://plannotator.ai/install.sh | bash"}const Nrt=({origin:t,isWSL:e=!1})=>{const n=Srt(),[a,r]=J.useState(!1),[i,A]=J.useState(!1),l=new URLSearchParams(window.location.search).get("preview-origin")||t,d=l==="pi",u=l==="opencode",g=d?_rt:Rrt(e);if(!n?.updateAvailable||i)return null;const p=async()=>{try{await navigator.clipboard.writeText(g),r(!0),setTimeout(()=>r(!1),2e3)}catch(f){console.error("Failed to copy:",f)}};return n.featureHighlight?y.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:y.jsxs("div",{className:"bg-card border border-primary/30 rounded-xl shadow-2xl overflow-hidden",children:[y.jsx("div",{className:"bg-gradient-to-r from-primary/20 to-primary/5 px-5 py-4 border-b border-border/50",children:y.jsxs("div",{className:"flex items-start justify-between gap-3",children:[y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-primary/20 flex items-center justify-center",children:y.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})})}),y.jsxs("div",{children:[y.jsx("h4",{className:"text-base font-semibold text-foreground",children:n.featureHighlight.title}),y.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["New in ",n.latestVersion]})]})]}),y.jsx("button",{onClick:()=>A(!0),className:"text-muted-foreground hover:text-foreground transition-colors p-1",children:y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),y.jsxs("div",{className:"px-5 py-4",children:[y.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed",children:n.featureHighlight.description}),y.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:["You have ",n.currentVersion]}),u&&y.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install script, then restart OpenCode."}),d&&y.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install command, then restart Pi."}),y.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[y.jsx("button",{onClick:p,className:"flex-1 px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-lg hover:opacity-90 transition-opacity",children:a?"Copied!":"Copy install command"}),y.jsx("a",{href:n.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"})]})]})]})}):y.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:y.jsx("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4",children:y.jsxs("div",{className:"flex items-start gap-3",children:[y.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center",children:y.jsx("svg",{className:"w-4 h-4 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})})}),y.jsxs("div",{className:"flex-1 min-w-0",children:[y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Update available"}),y.jsx("button",{onClick:()=>A(!0),className:"text-muted-foreground hover:text-foreground transition-colors",children:y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),y.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[n.latestVersion," is available (you have ",n.currentVersion,")"]}),y.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[y.jsx("button",{onClick:p,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:a?"Copied!":"Copy install command"}),y.jsx("a",{href:n.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"})]})]})]})})})},tQe="plannotator-editor-mode",Mrt="selection";function Frt(){const t=zt.getItem(tQe);return t==="selection"||t==="comment"||t==="redline"||t==="quickLabel"?t:Mrt}function Lrt(t){zt.setItem(tQe,t)}const nQe="plannotator-input-method",Trt="drag";function Grt(){const t=zt.getItem(nQe);return t==="drag"||t==="pinpoint"?t:Trt}function Ort(t){zt.setItem(nQe,t)}const Urt=300,Prt=300;function Krt(t,e){const n=J.useRef("idle"),a=J.useRef(0),r=J.useRef(void 0),i=J.useRef(t);J.useEffect(()=>{n.current==="idle"&&(i.current=t)},[t]);const A=J.useCallback(o=>o==="drag"?"pinpoint":"drag",[]);J.useEffect(()=>{const o=l=>{if(l.key!=="Alt"||l.repeat)return;const d=l.target?.tagName;d==="INPUT"||d==="TEXTAREA"||l.target?.isContentEditable||document.querySelector("[data-quick-label-picker]")||(n.current==="idle"?(i.current=t,a.current=Date.now(),n.current="held",e(A(t))):n.current==="tapped"&&(clearTimeout(r.current),n.current="idle",i.current=A(i.current)))},s=l=>{l.key==="Alt"&&n.current==="held"&&(Date.now()-a.current>=Prt?(e(i.current),n.current="idle"):(n.current="tapped",r.current=setTimeout(()=>{n.current==="tapped"&&(e(i.current),n.current="idle")},Urt)))};return window.addEventListener("keydown",o),window.addEventListener("keyup",s),()=>{clearTimeout(r.current),window.removeEventListener("keydown",o),window.removeEventListener("keyup",s)}},[t,e,A])}function Hrt(){J.useEffect(()=>{const t=()=>document.documentElement.classList.add("plannotator-print"),e=()=>document.documentElement.classList.remove("plannotator-print"),n=()=>{!document.hidden&&document.documentElement.classList.contains("plannotator-print")&&document.documentElement.classList.remove("plannotator-print")};return window.addEventListener("beforeprint",t),window.addEventListener("afterprint",e),document.addEventListener("visibilitychange",n),()=>{window.removeEventListener("beforeprint",t),window.removeEventListener("afterprint",e),document.removeEventListener("visibilitychange",n),document.documentElement.classList.remove("plannotator-print")}},[])}function cre({storageKey:t,defaultWidth:e=288,minWidth:n=200,maxWidth:a=600,side:r="right"}){const[i,A]=J.useState(()=>{const b=zt.getItem(t);if(b){const C=Number(b);if(!Number.isNaN(C)&&C>=n&&C<=a)return C}return e}),[o,s]=J.useState(!1),l=J.useRef(0),d=J.useRef(0),u=J.useRef(i),g=J.useCallback(b=>{u.current=b,A(b)},[]),p=J.useCallback(b=>{b.preventDefault(),l.current=b.clientX,d.current=u.current,s(!0)},[]),m=J.useCallback(b=>{b.preventDefault(),l.current=b.touches[0].clientX,d.current=u.current,s(!0)},[]);J.useEffect(()=>{if(!o)return;const b=B=>"touches"in B?B.touches[0]?.clientX??B.changedTouches[0]?.clientX??0:B.clientX,C=B=>{const w=b(B),k=r==="right"?l.current-w:w-l.current;g(Math.min(a,Math.max(n,d.current+k)))},I=()=>{s(!1),zt.setItem(t,String(u.current))};return document.addEventListener("mousemove",C),document.addEventListener("mouseup",I),document.addEventListener("touchmove",C,{passive:!1}),document.addEventListener("touchend",I),document.addEventListener("touchcancel",I),()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",I),document.removeEventListener("touchmove",C),document.removeEventListener("touchend",I),document.removeEventListener("touchcancel",I)}},[o,n,a,t,r,g]);const f=J.useCallback(()=>{g(e),zt.setItem(t,String(e))},[e,t,g]);return{width:i,isDragging:o,handleProps:{isDragging:o,onMouseDown:p,onTouchStart:m,onDoubleClick:f}}}const lre=({isDragging:t,onMouseDown:e,onTouchStart:n,onDoubleClick:a,className:r,side:i})=>y.jsxs("div",{className:`relative w-0 cursor-col-resize flex-shrink-0 group z-10${r?` ${r}`:""}`,children:[y.jsx("div",{className:`absolute inset-y-0 -left-0.5 -right-0.5 transition-colors ${t?"bg-primary/50":"group-hover:bg-border"}`}),y.jsx("div",{className:`absolute inset-y-0 ${i==="left"?"-right-2 -left-1":i==="right"?"-right-3 left-0":"-inset-x-2"}`,onMouseDown:e,onTouchStart:n,onDoubleClick:a})]});function Yrt(){const t=J.useRef(null),[e,n]=J.useState(null),a=J.useCallback(r=>{const i=r;t.current=i,n(i)},[]);return{ref:t,viewport:e,onViewportReady:a}}const qrt=({className:t,panelClassName:e,renderTrigger:n,children:a})=>{const[r,i]=J.useState(!1),A=J.useRef(null);return J.useEffect(()=>{if(!r)return;const o=l=>{A.current&&!A.current.contains(l.target)&&i(!1)},s=l=>{l.key==="Escape"&&i(!1)};return document.addEventListener("pointerdown",o),document.addEventListener("keydown",s),()=>{document.removeEventListener("pointerdown",o),document.removeEventListener("keydown",s)}},[r]),y.jsxs("div",{ref:A,className:t?`relative ${t}`:"relative",children:[n({isOpen:r,toggleMenu:()=>i(o=>!o)}),r&&y.jsx("div",{className:e??"absolute top-full right-0 mt-1 w-56 rounded-lg border border-border bg-popover py-1 shadow-xl z-[70]",children:a({closeMenu:()=>i(!1)})})]})},Yl=({onClick:t,icon:e,label:n,subtitle:a,badge:r})=>y.jsxs("button",{onClick:t,className:"flex w-full items-center gap-2 px-3 py-2 text-left text-xs transition-colors hover:bg-muted",children:[y.jsx("span",{className:"text-muted-foreground",children:e}),a?y.jsxs("span",{className:"flex flex-1 flex-col gap-0.5",children:[y.jsx("span",{children:n}),y.jsx("span",{className:"text-[10px] text-muted-foreground",children:a})]}):y.jsx("span",{className:"flex-1",children:n}),r]}),Kv=()=>y.jsx("div",{className:"my-1 border-t border-border"}),dre=({children:t})=>y.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:t}),jrt=({className:t="w-3.5 h-3.5"})=>y.jsxs("svg",{className:`${t} flex-shrink-0`,viewBox:"0 0 64 64",fill:"none",stroke:"currentColor",children:[y.jsx("path",{d:"M40.5 40.5L55 55",strokeWidth:7,strokeLinecap:"round"}),y.jsx("circle",{cx:"27",cy:"27",r:"20",strokeWidth:4}),y.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"}),y.jsx("circle",{cx:"27",cy:"27.7",r:"7",strokeWidth:1.5})]}),zrt=({appVersion:t,onOpenSettings:e,onOpenExport:n,onCopyAgentInstructions:a,onDownloadAnnotations:r,onPrint:i,onCopyShareLink:A,onOpenImport:o,onSaveToObsidian:s,onSaveToBear:l,onSaveToOctarine:d,sharingEnabled:u,isApiMode:g,agentInstructionsEnabled:p,obsidianConfigured:m,bearConfigured:f,octarineConfigured:b})=>{const{theme:C,setTheme:I}=_H(),B=g&&(m||f||b);return y.jsx(qrt,{renderTrigger:({isOpen:w,toggleMenu:k})=>y.jsxs("button",{onClick:k,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?y.jsx(Wrt,{}):y.jsx(Jrt,{}),y.jsx("span",{className:"hidden md:inline",children:"Options"})]}),children:({closeMenu:w})=>y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"px-3 py-2 space-y-1.5",children:[y.jsx(dre,{children:"Theme"}),y.jsx("div",{className:"flex items-center gap-1 rounded-lg bg-muted/50 p-0.5",children:["light","dark","system"].map(k=>y.jsxs("button",{onClick:()=>{w(),I(k)},className:`flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1 text-[11px] font-medium transition-colors ${C===k?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[k==="light"?y.jsx(Hye,{}):k==="dark"?y.jsx(Yye,{}):y.jsx(qye,{}),y.jsx("span",{className:"capitalize",children:k})]},k))})]}),y.jsx(Kv,{}),y.jsx(Yl,{onClick:()=>{w(),e()},icon:y.jsx(Zrt,{}),label:"Settings"}),y.jsx(Yl,{onClick:()=>{w(),n()},icon:y.jsx(Vrt,{}),label:"Export"}),p&&y.jsx(Yl,{onClick:()=>{w(),a()},icon:y.jsx(jrt,{}),label:"Agent Instructions",subtitle:"Copy agent instructions for external annotations"}),y.jsx(Kv,{}),y.jsx(Yl,{onClick:()=>{w(),r()},icon:y.jsx(Xrt,{}),label:"Download Annotations"}),y.jsx(Yl,{onClick:()=>{w(),i()},icon:y.jsx($rt,{}),label:"Print / Save as PDF",subtitle:"Choose 'Save as PDF' in the print dialog"}),u&&y.jsx(Yl,{onClick:()=>{w(),A()},icon:y.jsx(eit,{}),label:"Copy Share Link"}),u&&y.jsx(Yl,{onClick:()=>{w(),o()},icon:y.jsx(tit,{}),label:"Import Review"}),B&&y.jsxs(y.Fragment,{children:[y.jsx(Kv,{}),m&&y.jsx(Yl,{onClick:()=>{w(),s()},icon:y.jsx(r8,{}),label:"Save to Obsidian"}),f&&y.jsx(Yl,{onClick:()=>{w(),l()},icon:y.jsx(r8,{}),label:"Save to Bear"}),b&&y.jsx(Yl,{onClick:()=>{w(),d()},icon:y.jsx(r8,{}),label:"Save to Octarine"})]}),y.jsx(Kv,{}),y.jsxs("div",{className:"px-3 py-2 space-y-2",children:[y.jsxs("div",{className:"flex items-center justify-between gap-3",children:[y.jsx(dre,{children:"Plannotator"}),y.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground/70",children:["v",t]})]}),y.jsxs("div",{className:"flex flex-col items-start gap-1 text-[11px]",children:[y.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"}),y.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"})]})]})]})})},Jrt=()=>y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})}),Wrt=()=>y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}),Zrt=()=>y.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[y.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"}),y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),Vrt=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})}),Xrt=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})}),$rt=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})}),eit=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})}),tit=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4M10 17l5-5-5-5M15 12H3"})}),r8=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),nit=({isOpen:t,onComplete:e})=>{const[n,a]=J.useState("acceptEdits");if(!t)return null;const r=()=>{Oye(n),e(n)};return YA.createPortal(y.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-background/90 backdrop-blur-sm p-4",children:y.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-lg shadow-2xl",children:[y.jsxs("div",{className:"p-5 border-b border-border",children:[y.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[y.jsx("div",{className:"p-1.5 rounded-lg bg-primary/15",children:y.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:y.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"})})}),y.jsx("h3",{className:"font-semibold text-base",children:"New: Permission Mode Preservation"})]}),y.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."}),y.jsxs("p",{className:"text-xs text-muted-foreground/70 mt-1",children:["Requires Claude Code 2.1.7 or later. Run ",y.jsx("code",{className:"bg-muted px-1 rounded",children:"claude update"})," to update."]})]}),y.jsx("div",{className:"p-4 space-y-2",children:aP.map(i=>y.jsxs("label",{className:`flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all border ${n===i.value?"border-primary bg-primary/10":"border-transparent bg-muted/50 hover:bg-muted"}`,children:[y.jsx("input",{type:"radio",name:"permissionMode",value:i.value,checked:n===i.value,onChange:()=>a(i.value),className:"mt-0.5 accent-primary"}),y.jsxs("div",{className:"flex-1",children:[y.jsx("div",{className:"text-sm font-medium",children:i.label}),y.jsx("div",{className:"text-xs text-muted-foreground",children:i.description})]})]},i.value))}),y.jsxs("div",{className:"p-4 border-t border-border flex justify-between items-center",children:[y.jsx("p",{className:"text-xs text-muted-foreground",children:"You can change this later in Settings."}),y.jsx("button",{onClick:r,className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:opacity-90 transition-opacity",children:"Continue"})]})]})}),document.body)};function ait(t,e){const[n,a]=J.useState(t),[r,i]=J.useState("toc"),A=J.useCallback(l=>{a(!0),l&&i(l)},[]),o=J.useCallback(()=>{a(!1)},[]),s=J.useCallback(l=>{n?r===l?a(!1):i(l):(a(!0),i(l))},[n,r]);return{isOpen:n,activeTab:r,open:A,close:o,toggleTab:s}}class aQe{diff(e,n,a={}){let r;typeof a=="function"?(r=a,a={}):"callback"in a&&(r=a.callback);const i=this.castInput(e,a),A=this.castInput(n,a),o=this.removeEmpty(this.tokenize(i,a)),s=this.removeEmpty(this.tokenize(A,a));return this.diffWithOptionsObj(o,s,a,r)}diffWithOptionsObj(e,n,a,r){var i;const A=I=>{if(I=this.postProcess(I,a),r){setTimeout(function(){r(I)},0);return}else return I},o=n.length,s=e.length;let l=1,d=o+s;a.maxEditLength!=null&&(d=Math.min(d,a.maxEditLength));const u=(i=a.timeout)!==null&&i!==void 0?i:1/0,g=Date.now()+u,p=[{oldPos:-1,lastComponent:void 0}];let m=this.extractCommon(p[0],n,e,0,a);if(p[0].oldPos+1>=s&&m+1>=o)return A(this.buildValues(p[0].lastComponent,n,e));let f=-1/0,b=1/0;const C=()=>{for(let I=Math.max(f,-l);I<=Math.min(b,l);I+=2){let B;const w=p[I-1],k=p[I+1];w&&(p[I-1]=void 0);let _=!1;if(k){const x=k.oldPos-I;_=k&&0<=x&&x<o}const D=w&&w.oldPos+1<s;if(!_&&!D){p[I]=void 0;continue}if(!D||_&&w.oldPos<k.oldPos?B=this.addToPath(k,!0,!1,0,a):B=this.addToPath(w,!1,!0,1,a),m=this.extractCommon(B,n,e,I,a),B.oldPos+1>=s&&m+1>=o)return A(this.buildValues(B.lastComponent,n,e))||!0;p[I]=B,B.oldPos+1>=s&&(b=Math.min(b,I-1)),m+1>=o&&(f=Math.max(f,I+1))}l++};if(r)(function I(){setTimeout(function(){if(l>d||Date.now()>g)return r(void 0);C()||I()},0)})();else for(;l<=d&&Date.now()<=g;){const I=C();if(I)return I}}addToPath(e,n,a,r,i){const A=e.lastComponent;return A&&!i.oneChangePerToken&&A.added===n&&A.removed===a?{oldPos:e.oldPos+r,lastComponent:{count:A.count+1,added:n,removed:a,previousComponent:A.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:n,removed:a,previousComponent:A}}}extractCommon(e,n,a,r,i){const A=n.length,o=a.length;let s=e.oldPos,l=s-r,d=0;for(;l+1<A&&s+1<o&&this.equals(a[s+1],n[l+1],i);)l++,s++,d++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return d&&!i.oneChangePerToken&&(e.lastComponent={count:d,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,l}equals(e,n,a){return a.comparator?a.comparator(e,n):e===n||!!a.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){const n=[];for(let a=0;a<e.length;a++)e[a]&&n.push(e[a]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,a){const r=[];let i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();const A=r.length;let o=0,s=0,l=0;for(;o<A;o++){const d=r[o];if(d.removed)d.value=this.join(a.slice(l,l+d.count)),l+=d.count;else{if(!d.added&&this.useLongestToken){let u=n.slice(s,s+d.count);u=u.map(function(g,p){const m=a[l+p];return m.length>g.length?m:g}),d.value=this.join(u)}else d.value=this.join(n.slice(s,s+d.count));s+=d.count,d.added||(l+=d.count)}}return r}}const ure="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 rit extends aQe{tokenize(e){const n=new RegExp(`(\\r?\\n)|[${ure}]+|[^\\S\\n\\r]+|[^${ure}]`,"ug");return e.match(n)||[]}}const iit=new rit;function Ait(t,e,n){return iit.diff(t,e,n)}class oit extends aQe{constructor(){super(...arguments),this.tokenize=lit}equals(e,n,a){return a.ignoreWhitespace?((!a.newlineIsToken||!e.includes(`
|
|
670
|
+
`).find(te=>te.startsWith("#")),$=Z?Z.replace(/^#+\s*/,"").trim():"Unknown Plan",X=_x(q.a,q.d,q.s);if(X.length===0)return{success:!0,count:0,planTitle:$,error:"No annotations found in share link"};const ce=X.filter(te=>!e.some(he=>he.originalText===te.originalText&&he.type===te.type&&he.text===te.text));if(ce.length>0&&(r(te=>{const he=X.filter(se=>!te.some(oe=>oe.originalText===se.originalText&&oe.type===se.type&&oe.text===se.text));if(he.length===0)return te;const ae=[...te,...he];return x(ae),ae}),q.g?.length)){const te=vC(q.g)??[];i(he=>{const ae=new Set(he.map(oe=>oe.path)),se=te.filter(oe=>!ae.has(oe.path));return se.length>0?[...he,...se]:he}),F(te)}return{success:!0,count:ce.length,planTitle:$}}catch(q){return{success:!1,count:0,planTitle:"",error:q instanceof Error?q.message:"Failed to decompress share URL"}}},[e,n,r,i,s]);return{isSharedSession:l,isLoadingShared:u,shareUrl:p,shareUrlSize:f,shortShareUrl:C,isGeneratingShortUrl:B,shortUrlError:k,pendingSharedAnnotations:D,sharedGlobalAttachments:S,clearPendingSharedAnnotations:K,refreshShareUrl:T,generateShortUrl:L,importFromShareUrl:U,shareLoadError:M,clearShareLoadError:R}}var Rx=(t=>(t.Approve="approve",t.Feedback="feedback",t))(Rx||{});function Irt(t=window.location){const e=new URLSearchParams(t.search);let n=e.get("cb"),a=e.get("ct");if(!n||!a){const r=t.hash.indexOf("?");if(r!==-1){const i=new URLSearchParams(t.hash.slice(r+1));n=n??i.get("cb"),a=a??i.get("ct")}}if(!n||!a)return null;try{const{protocol:r}=new URL(n);if(r!=="https:"&&r!=="http:")return null}catch{return null}return{callbackUrl:n,token:a}}async function Brt(t,e,n){const a=t==="approve"?"Plan approved! The bot will proceed to implementation.":"Feedback sent! The bot will re-plan with your annotations.";try{const r=await fetch(e.callbackUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t,token:e.token,annotated_url:n})});return r.ok?{type:"success",message:a}:{type:"error",message:r.status===401?"Plan link expired — request a new one from the bot.":"Callback failed."}}catch{return{type:"error",message:"Callback failed."}}}function yrt(t,e,n){const[a,r]=J.useState(null),i=J.useRef(null);return J.useEffect(()=>{const A=n??t.current;if(!A)return;const o=A.querySelectorAll('[data-block-type="heading"]');if(o.length===0)return;const s=new Map;return i.current=new IntersectionObserver(l=>{l.forEach(g=>{s.set(g.target,g.isIntersecting)});let d=null,u=1/0;for(const[g,p]of s)if(p){const m=g.getBoundingClientRect();m.top<u&&(u=m.top,d=g)}if(d){const g=d.getAttribute("data-block-id");g&&r(g)}},{root:A,rootMargin:"-80px 0px -80% 0px",threshold:[0,.1,.5,1]}),o.forEach(l=>{i.current?.observe(l)}),()=>{i.current?.disconnect()}},[t,e,n]),a}function ore(t){window.close(),setTimeout(()=>{window.closed||t()},300)}function Qrt(t){const[e,n]=J.useState({phase:"idle"});J.useEffect(()=>{if(!t)return;const r=Qpe();r==="0"?(ore(()=>n({phase:"closeFailed"})),n({phase:"closed"})):n(r!=="off"?{phase:"counting",remaining:Number(r)}:{phase:"prompt"})},[t]),J.useEffect(()=>{if(e.phase!=="counting")return;if(e.remaining<=0){ore(()=>n({phase:"closeFailed"}));return}const r=setTimeout(()=>n(i=>i.phase==="counting"?{phase:"counting",remaining:i.remaining-1}:i),1e3);return()=>clearTimeout(r)},[e]);const a=J.useCallback(()=>{wpe("3"),n({phase:"counting",remaining:3})},[]);return{state:e,enableAndStart:a}}const wrt=()=>y.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),krt=()=>y.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:y.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 vrt({submitted:t,title:e,subtitle:n,agentLabel:a}){const{state:r,enableAndStart:i}=Qrt(!!t);if(!t)return null;const A=t==="approved";return y.jsx("div",{className:"fixed inset-0 z-[100] bg-background flex items-center justify-center",children:y.jsxs("div",{className:"text-center space-y-6 max-w-md px-8",children:[y.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?y.jsx(wrt,{}):y.jsx(krt,{})}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("h2",{className:"text-xl font-semibold text-foreground",children:e}),y.jsx("p",{className:"text-muted-foreground",children:n})]}),y.jsx("div",{className:"pt-4 border-t border-border space-y-2",children:r.phase==="counting"?y.jsxs(y.Fragment,{children:[y.jsxs("p",{className:"text-sm text-muted-foreground",children:["This tab will close in ",y.jsx("span",{className:"text-foreground font-medium",children:r.remaining})," second",r.remaining!==1?"s":"","..."]}),y.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change this in Settings."})]}):r.phase==="closeFailed"?y.jsxs(y.Fragment,{children:[y.jsx("p",{className:"text-sm text-muted-foreground",children:"Could not close this tab automatically. Please close it manually."}),y.jsxs("p",{className:"text-xs text-muted-foreground/60",children:["Auto-close works when the tab is opened by ",a,"."]})]}):y.jsxs(y.Fragment,{children:[y.jsxs("p",{className:"text-sm text-muted-foreground",children:["You can close this tab and return to ",y.jsx("span",{className:"text-foreground font-medium",children:a}),"."]}),r.phase==="prompt"?y.jsxs(y.Fragment,{children:[y.jsxs("label",{className:"flex items-center justify-center gap-2 cursor-pointer group",children:[y.jsx("input",{type:"checkbox",checked:!1,onChange:i,className:"accent-primary"}),y.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-foreground transition-colors",children:"Auto-close this tab after 3 seconds"})]}),y.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change the delay in Settings."})]}):y.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Your response has been sent."})]})})]})})}const Drt="https://api.github.com/repos/backnotprop/plannotator/releases/latest",sre={"0.5.0":{title:"Code Review is here!",description:"Review git diffs with inline annotations. Run /plannotator-review to try it."}};function xrt(t,e){const n=i=>i.replace(/^v/,""),a=n(t).split(".").map(Number),r=n(e).split(".").map(Number);for(let i=0;i<Math.max(a.length,r.length);i++){const A=a[i]||0,o=r[i]||0;if(o>A)return!0;if(o<A)return!1}return!1}function Srt(){const[t,e]=J.useState(null);return J.useEffect(()=>{(async()=>{try{const a="0.19.11",i=new URLSearchParams(window.location.search).get("preview-update");if(i){const g=i.replace(/^v/,"");e({currentVersion:a,latestVersion:i,updateAvailable:!0,releaseUrl:`https://github.com/backnotprop/plannotator/releases/tag/v${g}`,featureHighlight:sre[g]});return}const A=await fetch(Drt);if(!A.ok)return;const o=await A.json(),s=o.tag_name,l=xrt(a,s),d=s.replace(/^v/,""),u=sre[d];e({currentVersion:a,latestVersion:s,updateAvailable:l,releaseUrl:o.html_url,featureHighlight:u})}catch(a){console.debug("Update check failed:",a)}})()},[]),t}const _rt="pi install npm:@plannotator/pi-extension";function Rrt(t){return YOe&&!t?'powershell -c "irm https://plannotator.ai/install.ps1 | iex"':"curl -fsSL https://plannotator.ai/install.sh | bash"}const Nrt=({origin:t,isWSL:e=!1})=>{const n=Srt(),[a,r]=J.useState(!1),[i,A]=J.useState(!1),l=new URLSearchParams(window.location.search).get("preview-origin")||t,d=l==="pi",u=l==="opencode",g=d?_rt:Rrt(e);if(!n?.updateAvailable||i)return null;const p=async()=>{try{await navigator.clipboard.writeText(g),r(!0),setTimeout(()=>r(!1),2e3)}catch(f){console.error("Failed to copy:",f)}};return n.featureHighlight?y.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:y.jsxs("div",{className:"bg-card border border-primary/30 rounded-xl shadow-2xl overflow-hidden",children:[y.jsx("div",{className:"bg-gradient-to-r from-primary/20 to-primary/5 px-5 py-4 border-b border-border/50",children:y.jsxs("div",{className:"flex items-start justify-between gap-3",children:[y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-primary/20 flex items-center justify-center",children:y.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})})}),y.jsxs("div",{children:[y.jsx("h4",{className:"text-base font-semibold text-foreground",children:n.featureHighlight.title}),y.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["New in ",n.latestVersion]})]})]}),y.jsx("button",{onClick:()=>A(!0),className:"text-muted-foreground hover:text-foreground transition-colors p-1",children:y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),y.jsxs("div",{className:"px-5 py-4",children:[y.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed",children:n.featureHighlight.description}),y.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:["You have ",n.currentVersion]}),u&&y.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install script, then restart OpenCode."}),d&&y.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install command, then restart Pi."}),y.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[y.jsx("button",{onClick:p,className:"flex-1 px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-lg hover:opacity-90 transition-opacity",children:a?"Copied!":"Copy install command"}),y.jsx("a",{href:n.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"})]})]})]})}):y.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:y.jsx("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4",children:y.jsxs("div",{className:"flex items-start gap-3",children:[y.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center",children:y.jsx("svg",{className:"w-4 h-4 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})})}),y.jsxs("div",{className:"flex-1 min-w-0",children:[y.jsxs("div",{className:"flex items-center justify-between gap-2",children:[y.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Update available"}),y.jsx("button",{onClick:()=>A(!0),className:"text-muted-foreground hover:text-foreground transition-colors",children:y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),y.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[n.latestVersion," is available (you have ",n.currentVersion,")"]}),y.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[y.jsx("button",{onClick:p,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:a?"Copied!":"Copy install command"}),y.jsx("a",{href:n.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"})]})]})]})})})},tQe="plannotator-editor-mode",Mrt="selection";function Frt(){const t=zt.getItem(tQe);return t==="selection"||t==="comment"||t==="redline"||t==="quickLabel"?t:Mrt}function Lrt(t){zt.setItem(tQe,t)}const nQe="plannotator-input-method",Trt="drag";function Grt(){const t=zt.getItem(nQe);return t==="drag"||t==="pinpoint"?t:Trt}function Ort(t){zt.setItem(nQe,t)}const Urt=300,Prt=300;function Krt(t,e){const n=J.useRef("idle"),a=J.useRef(0),r=J.useRef(void 0),i=J.useRef(t);J.useEffect(()=>{n.current==="idle"&&(i.current=t)},[t]);const A=J.useCallback(o=>o==="drag"?"pinpoint":"drag",[]);J.useEffect(()=>{const o=l=>{if(l.key!=="Alt"||l.repeat)return;const d=l.target?.tagName;d==="INPUT"||d==="TEXTAREA"||l.target?.isContentEditable||document.querySelector("[data-quick-label-picker]")||(n.current==="idle"?(i.current=t,a.current=Date.now(),n.current="held",e(A(t))):n.current==="tapped"&&(clearTimeout(r.current),n.current="idle",i.current=A(i.current)))},s=l=>{l.key==="Alt"&&n.current==="held"&&(Date.now()-a.current>=Prt?(e(i.current),n.current="idle"):(n.current="tapped",r.current=setTimeout(()=>{n.current==="tapped"&&(e(i.current),n.current="idle")},Urt)))};return window.addEventListener("keydown",o),window.addEventListener("keyup",s),()=>{clearTimeout(r.current),window.removeEventListener("keydown",o),window.removeEventListener("keyup",s)}},[t,e,A])}function Hrt(){J.useEffect(()=>{const t=()=>document.documentElement.classList.add("plannotator-print"),e=()=>document.documentElement.classList.remove("plannotator-print"),n=()=>{!document.hidden&&document.documentElement.classList.contains("plannotator-print")&&document.documentElement.classList.remove("plannotator-print")};return window.addEventListener("beforeprint",t),window.addEventListener("afterprint",e),document.addEventListener("visibilitychange",n),()=>{window.removeEventListener("beforeprint",t),window.removeEventListener("afterprint",e),document.removeEventListener("visibilitychange",n),document.documentElement.classList.remove("plannotator-print")}},[])}function cre({storageKey:t,defaultWidth:e=288,minWidth:n=200,maxWidth:a=600,side:r="right"}){const[i,A]=J.useState(()=>{const b=zt.getItem(t);if(b){const C=Number(b);if(!Number.isNaN(C)&&C>=n&&C<=a)return C}return e}),[o,s]=J.useState(!1),l=J.useRef(0),d=J.useRef(0),u=J.useRef(i),g=J.useCallback(b=>{u.current=b,A(b)},[]),p=J.useCallback(b=>{b.preventDefault(),l.current=b.clientX,d.current=u.current,s(!0)},[]),m=J.useCallback(b=>{b.preventDefault(),l.current=b.touches[0].clientX,d.current=u.current,s(!0)},[]);J.useEffect(()=>{if(!o)return;const b=B=>"touches"in B?B.touches[0]?.clientX??B.changedTouches[0]?.clientX??0:B.clientX,C=B=>{const w=b(B),k=r==="right"?l.current-w:w-l.current;g(Math.min(a,Math.max(n,d.current+k)))},I=()=>{s(!1),zt.setItem(t,String(u.current))};return document.addEventListener("mousemove",C),document.addEventListener("mouseup",I),document.addEventListener("touchmove",C,{passive:!1}),document.addEventListener("touchend",I),document.addEventListener("touchcancel",I),()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",I),document.removeEventListener("touchmove",C),document.removeEventListener("touchend",I),document.removeEventListener("touchcancel",I)}},[o,n,a,t,r,g]);const f=J.useCallback(()=>{g(e),zt.setItem(t,String(e))},[e,t,g]);return{width:i,isDragging:o,handleProps:{isDragging:o,onMouseDown:p,onTouchStart:m,onDoubleClick:f}}}const lre=({isDragging:t,onMouseDown:e,onTouchStart:n,onDoubleClick:a,className:r,side:i})=>y.jsxs("div",{className:`relative w-0 cursor-col-resize flex-shrink-0 group z-10${r?` ${r}`:""}`,children:[y.jsx("div",{className:`absolute inset-y-0 -left-0.5 -right-0.5 transition-colors ${t?"bg-primary/50":"group-hover:bg-border"}`}),y.jsx("div",{className:`absolute inset-y-0 ${i==="left"?"-right-2 -left-1":i==="right"?"-right-3 left-0":"-inset-x-2"}`,onMouseDown:e,onTouchStart:n,onDoubleClick:a})]});function Yrt(){const t=J.useRef(null),[e,n]=J.useState(null),a=J.useCallback(r=>{const i=r;t.current=i,n(i)},[]);return{ref:t,viewport:e,onViewportReady:a}}const qrt=({className:t,panelClassName:e,renderTrigger:n,children:a})=>{const[r,i]=J.useState(!1),A=J.useRef(null);return J.useEffect(()=>{if(!r)return;const o=l=>{A.current&&!A.current.contains(l.target)&&i(!1)},s=l=>{l.key==="Escape"&&i(!1)};return document.addEventListener("pointerdown",o),document.addEventListener("keydown",s),()=>{document.removeEventListener("pointerdown",o),document.removeEventListener("keydown",s)}},[r]),y.jsxs("div",{ref:A,className:t?`relative ${t}`:"relative",children:[n({isOpen:r,toggleMenu:()=>i(o=>!o)}),r&&y.jsx("div",{className:e??"absolute top-full right-0 mt-1 w-56 rounded-lg border border-border bg-popover py-1 shadow-xl z-[70]",children:a({closeMenu:()=>i(!1)})})]})},Yl=({onClick:t,icon:e,label:n,subtitle:a,badge:r})=>y.jsxs("button",{onClick:t,className:"flex w-full items-center gap-2 px-3 py-2 text-left text-xs transition-colors hover:bg-muted",children:[y.jsx("span",{className:"text-muted-foreground",children:e}),a?y.jsxs("span",{className:"flex flex-1 flex-col gap-0.5",children:[y.jsx("span",{children:n}),y.jsx("span",{className:"text-[10px] text-muted-foreground",children:a})]}):y.jsx("span",{className:"flex-1",children:n}),r]}),Kv=()=>y.jsx("div",{className:"my-1 border-t border-border"}),dre=({children:t})=>y.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:t}),jrt=({className:t="w-3.5 h-3.5"})=>y.jsxs("svg",{className:`${t} flex-shrink-0`,viewBox:"0 0 64 64",fill:"none",stroke:"currentColor",children:[y.jsx("path",{d:"M40.5 40.5L55 55",strokeWidth:7,strokeLinecap:"round"}),y.jsx("circle",{cx:"27",cy:"27",r:"20",strokeWidth:4}),y.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"}),y.jsx("circle",{cx:"27",cy:"27.7",r:"7",strokeWidth:1.5})]}),zrt=({appVersion:t,onOpenSettings:e,onOpenExport:n,onCopyAgentInstructions:a,onDownloadAnnotations:r,onPrint:i,onCopyShareLink:A,onOpenImport:o,onSaveToObsidian:s,onSaveToBear:l,onSaveToOctarine:d,sharingEnabled:u,isApiMode:g,agentInstructionsEnabled:p,obsidianConfigured:m,bearConfigured:f,octarineConfigured:b})=>{const{theme:C,setTheme:I}=_H(),B=g&&(m||f||b);return y.jsx(qrt,{renderTrigger:({isOpen:w,toggleMenu:k})=>y.jsxs("button",{onClick:k,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?y.jsx(Wrt,{}):y.jsx(Jrt,{}),y.jsx("span",{className:"hidden md:inline",children:"Options"})]}),children:({closeMenu:w})=>y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"px-3 py-2 space-y-1.5",children:[y.jsx(dre,{children:"Theme"}),y.jsx("div",{className:"flex items-center gap-1 rounded-lg bg-muted/50 p-0.5",children:["light","dark","system"].map(k=>y.jsxs("button",{onClick:()=>{w(),I(k)},className:`flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1 text-[11px] font-medium transition-colors ${C===k?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[k==="light"?y.jsx(Hye,{}):k==="dark"?y.jsx(Yye,{}):y.jsx(qye,{}),y.jsx("span",{className:"capitalize",children:k})]},k))})]}),y.jsx(Kv,{}),y.jsx(Yl,{onClick:()=>{w(),e()},icon:y.jsx(Zrt,{}),label:"Settings"}),y.jsx(Yl,{onClick:()=>{w(),n()},icon:y.jsx(Vrt,{}),label:"Export"}),p&&y.jsx(Yl,{onClick:()=>{w(),a()},icon:y.jsx(jrt,{}),label:"Agent Instructions",subtitle:"Copy agent instructions for external annotations"}),y.jsx(Kv,{}),y.jsx(Yl,{onClick:()=>{w(),r()},icon:y.jsx(Xrt,{}),label:"Download Annotations"}),y.jsx(Yl,{onClick:()=>{w(),i()},icon:y.jsx($rt,{}),label:"Print / Save as PDF",subtitle:"Choose 'Save as PDF' in the print dialog"}),u&&y.jsx(Yl,{onClick:()=>{w(),A()},icon:y.jsx(eit,{}),label:"Copy Share Link"}),u&&y.jsx(Yl,{onClick:()=>{w(),o()},icon:y.jsx(tit,{}),label:"Import Review"}),B&&y.jsxs(y.Fragment,{children:[y.jsx(Kv,{}),m&&y.jsx(Yl,{onClick:()=>{w(),s()},icon:y.jsx(r8,{}),label:"Save to Obsidian"}),f&&y.jsx(Yl,{onClick:()=>{w(),l()},icon:y.jsx(r8,{}),label:"Save to Bear"}),b&&y.jsx(Yl,{onClick:()=>{w(),d()},icon:y.jsx(r8,{}),label:"Save to Octarine"})]}),y.jsx(Kv,{}),y.jsxs("div",{className:"px-3 py-2 space-y-2",children:[y.jsxs("div",{className:"flex items-center justify-between gap-3",children:[y.jsx(dre,{children:"Plannotator"}),y.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground/70",children:["v",t]})]}),y.jsxs("div",{className:"flex flex-col items-start gap-1 text-[11px]",children:[y.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"}),y.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"})]})]})]})})},Jrt=()=>y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})}),Wrt=()=>y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}),Zrt=()=>y.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[y.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"}),y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),Vrt=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})}),Xrt=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})}),$rt=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})}),eit=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})}),tit=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4M10 17l5-5-5-5M15 12H3"})}),r8=()=>y.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),nit=({isOpen:t,onComplete:e})=>{const[n,a]=J.useState("acceptEdits");if(!t)return null;const r=()=>{Oye(n),e(n)};return YA.createPortal(y.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-background/90 backdrop-blur-sm p-4",children:y.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-lg shadow-2xl",children:[y.jsxs("div",{className:"p-5 border-b border-border",children:[y.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[y.jsx("div",{className:"p-1.5 rounded-lg bg-primary/15",children:y.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:y.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"})})}),y.jsx("h3",{className:"font-semibold text-base",children:"New: Permission Mode Preservation"})]}),y.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."}),y.jsxs("p",{className:"text-xs text-muted-foreground/70 mt-1",children:["Requires Claude Code 2.1.7 or later. Run ",y.jsx("code",{className:"bg-muted px-1 rounded",children:"claude update"})," to update."]})]}),y.jsx("div",{className:"p-4 space-y-2",children:aP.map(i=>y.jsxs("label",{className:`flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all border ${n===i.value?"border-primary bg-primary/10":"border-transparent bg-muted/50 hover:bg-muted"}`,children:[y.jsx("input",{type:"radio",name:"permissionMode",value:i.value,checked:n===i.value,onChange:()=>a(i.value),className:"mt-0.5 accent-primary"}),y.jsxs("div",{className:"flex-1",children:[y.jsx("div",{className:"text-sm font-medium",children:i.label}),y.jsx("div",{className:"text-xs text-muted-foreground",children:i.description})]})]},i.value))}),y.jsxs("div",{className:"p-4 border-t border-border flex justify-between items-center",children:[y.jsx("p",{className:"text-xs text-muted-foreground",children:"You can change this later in Settings."}),y.jsx("button",{onClick:r,className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:opacity-90 transition-opacity",children:"Continue"})]})]})}),document.body)};function ait(t,e){const[n,a]=J.useState(t),[r,i]=J.useState("toc"),A=J.useCallback(l=>{a(!0),l&&i(l)},[]),o=J.useCallback(()=>{a(!1)},[]),s=J.useCallback(l=>{n?r===l?a(!1):i(l):(a(!0),i(l))},[n,r]);return{isOpen:n,activeTab:r,open:A,close:o,toggleTab:s}}class aQe{diff(e,n,a={}){let r;typeof a=="function"?(r=a,a={}):"callback"in a&&(r=a.callback);const i=this.castInput(e,a),A=this.castInput(n,a),o=this.removeEmpty(this.tokenize(i,a)),s=this.removeEmpty(this.tokenize(A,a));return this.diffWithOptionsObj(o,s,a,r)}diffWithOptionsObj(e,n,a,r){var i;const A=I=>{if(I=this.postProcess(I,a),r){setTimeout(function(){r(I)},0);return}else return I},o=n.length,s=e.length;let l=1,d=o+s;a.maxEditLength!=null&&(d=Math.min(d,a.maxEditLength));const u=(i=a.timeout)!==null&&i!==void 0?i:1/0,g=Date.now()+u,p=[{oldPos:-1,lastComponent:void 0}];let m=this.extractCommon(p[0],n,e,0,a);if(p[0].oldPos+1>=s&&m+1>=o)return A(this.buildValues(p[0].lastComponent,n,e));let f=-1/0,b=1/0;const C=()=>{for(let I=Math.max(f,-l);I<=Math.min(b,l);I+=2){let B;const w=p[I-1],k=p[I+1];w&&(p[I-1]=void 0);let _=!1;if(k){const x=k.oldPos-I;_=k&&0<=x&&x<o}const D=w&&w.oldPos+1<s;if(!_&&!D){p[I]=void 0;continue}if(!D||_&&w.oldPos<k.oldPos?B=this.addToPath(k,!0,!1,0,a):B=this.addToPath(w,!1,!0,1,a),m=this.extractCommon(B,n,e,I,a),B.oldPos+1>=s&&m+1>=o)return A(this.buildValues(B.lastComponent,n,e))||!0;p[I]=B,B.oldPos+1>=s&&(b=Math.min(b,I-1)),m+1>=o&&(f=Math.max(f,I+1))}l++};if(r)(function I(){setTimeout(function(){if(l>d||Date.now()>g)return r(void 0);C()||I()},0)})();else for(;l<=d&&Date.now()<=g;){const I=C();if(I)return I}}addToPath(e,n,a,r,i){const A=e.lastComponent;return A&&!i.oneChangePerToken&&A.added===n&&A.removed===a?{oldPos:e.oldPos+r,lastComponent:{count:A.count+1,added:n,removed:a,previousComponent:A.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:n,removed:a,previousComponent:A}}}extractCommon(e,n,a,r,i){const A=n.length,o=a.length;let s=e.oldPos,l=s-r,d=0;for(;l+1<A&&s+1<o&&this.equals(a[s+1],n[l+1],i);)l++,s++,d++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return d&&!i.oneChangePerToken&&(e.lastComponent={count:d,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,l}equals(e,n,a){return a.comparator?a.comparator(e,n):e===n||!!a.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){const n=[];for(let a=0;a<e.length;a++)e[a]&&n.push(e[a]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,a){const r=[];let i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();const A=r.length;let o=0,s=0,l=0;for(;o<A;o++){const d=r[o];if(d.removed)d.value=this.join(a.slice(l,l+d.count)),l+=d.count;else{if(!d.added&&this.useLongestToken){let u=n.slice(s,s+d.count);u=u.map(function(g,p){const m=a[l+p];return m.length>g.length?m:g}),d.value=this.join(u)}else d.value=this.join(n.slice(s,s+d.count));s+=d.count,d.added||(l+=d.count)}}return r}}const ure="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 rit extends aQe{tokenize(e){const n=new RegExp(`(\\r?\\n)|[${ure}]+|[^\\S\\n\\r]+|[^${ure}]`,"ug");return e.match(n)||[]}}const iit=new rit;function Ait(t,e,n){return iit.diff(t,e,n)}class oit extends aQe{constructor(){super(...arguments),this.tokenize=lit}equals(e,n,a){return a.ignoreWhitespace?((!a.newlineIsToken||!e.includes(`
|
|
671
671
|
`))&&(e=e.trim()),(!a.newlineIsToken||!n.includes(`
|
|
672
672
|
`))&&(n=n.trim())):a.ignoreNewlineAtEof&&!a.newlineIsToken&&(e.endsWith(`
|
|
673
673
|
`)&&(e=e.slice(0,-1)),n.endsWith(`
|
|
@@ -1041,7 +1041,7 @@ XID_Start XIDS`.split(/\s/).map(t=>[DR(t),t])),Xlt=new Map([["s",nA(383)],[nA(38
|
|
|
1041
1041
|
`).slice(Math.max(0,e-1),Math.max(0,n)).join(`
|
|
1042
1042
|
`)}function Nwe(t,e){return t===e?`line ${t}`:`lines ${t}-${e}`}function Rie(t){let e=t;for(e?.nodeType===Node.TEXT_NODE&&(e=e.parentNode);e;){if(e instanceof HTMLElement){const n=e.closest("[data-line]")?.getAttribute("data-line");if(n){const a=Number(n);return Number.isFinite(a)?a:null}}e=e.parentNode}return null}function agt(t){const n=t?.querySelector("diffs-container")?.shadowRoot?.getSelection?.();return n&&!n.isCollapsed?n:window.getSelection()}const rgt=({annotation:t,isSelected:e,onSelect:n,onEdit:a,onDelete:r})=>{const[i,A]=J.useState(!1),[o,s]=J.useState(t.text??""),l=J.useRef(null);J.useEffect(()=>{i||s(t.text??"")},[t.text,i]),J.useEffect(()=>{i&&(l.current?.focus(),l.current?.select())},[i]);const d=()=>{a?.(t.id,{text:o}),A(!1)};return y.jsxs("div",{"data-code-annotation-id":t.id,onClick:()=>n?.(t.id),className:`group my-2 mx-3 rounded-lg border px-3 py-2 text-xs shadow-sm cursor-pointer transition-colors ${e?"border-primary/50":"border-border hover:border-border/80"}`,style:{backgroundColor:e?"color-mix(in oklab, var(--primary) 12%, var(--popover))":"var(--popover)",color:"var(--foreground)",opacity:1},children:[y.jsxs("div",{className:"flex items-center gap-2 text-[10px] uppercase tracking-wide text-muted-foreground",children:[y.jsx("span",{className:"font-semibold text-primary",children:"Comment"}),y.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono normal-case text-foreground",children:Nwe(t.lineStart,t.lineEnd)}),t.author&&y.jsxs("span",{className:"truncate normal-case",children:["by ",t.author]}),y.jsxs("div",{className:"ml-auto flex items-center gap-1 opacity-0 group-hover:opacity-100 [@media(hover:none)]:opacity-100",children:[a&&!i&&y.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),A(!0)},className:"rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground",title:"Edit comment",children:y.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),r&&y.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),r(t.id)},className:"rounded p-1 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",title:"Delete comment",children:y.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]}),i?y.jsxs("div",{className:"mt-2 space-y-2",children:[y.jsx("textarea",{ref:l,value:o,onChange:u=>s(u.target.value),onClick:u=>u.stopPropagation(),onKeyDown:u=>{u.key==="Escape"?(u.preventDefault(),A(!1),s(t.text??"")):u.key==="Enter"&&(u.metaKey||u.ctrlKey)&&!u.nativeEvent.isComposing&&(u.preventDefault(),d())},rows:Math.min(o.split(`
|
|
1043
1043
|
`).length+1,8),className:"w-full resize-none rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40"}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),d()},className:"rounded bg-primary px-2 py-1 text-[10px] font-medium text-primary-foreground hover:opacity-90",children:"Save"}),y.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),A(!1),s(t.text??"")},className:"rounded bg-muted px-2 py-1 text-[10px] font-medium text-muted-foreground hover:bg-muted/80",children:"Cancel"})]})]}):t.text&&y.jsx("div",{className:"mt-1.5 whitespace-pre-wrap border-l-2 border-primary/50 pl-2 text-foreground/90",children:t.text}),t.images&&t.images.length>0&&y.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.images.map(u=>y.jsxs("div",{className:"text-center",children:[y.jsx(g2,{path:u.path,size:"sm",showRemove:!1}),y.jsx("div",{className:"max-w-[3rem] truncate text-[9px] text-muted-foreground",title:u.name,children:u.name})]},u.path))})]})},igt=({open:t,onClose:e,filepath:n,contents:a,prerenderedHTML:r,error:i,requestedPath:A,annotations:o=[],selectedAnnotationId:s,onAddAnnotation:l,onEditAnnotation:d,onDeleteAnnotation:u,onSelectAnnotation:g,container:p})=>{const{resolvedMode:m}=_H(),f=m??"dark",b=Sie(),[C,I]=J.useState(()=>({type:f,css:_ie(f,b.bg,b.fg)})),[B,w]=J.useState(!1),[k,_]=J.useState(null),D=J.useRef(null),x=J.useRef(null),S=J.useRef(0);J.useEffect(()=>{requestAnimationFrame(()=>{const $=Sie();I({type:f,css:_ie(f,$.bg,$.fg)})})},[f]),J.useEffect(()=>{_(null)},[n]);const F=n.split("/").pop()||n,M=n.replace(/.*\/(?=.*\/)/,""),O=J.useMemo(()=>a.split(`
|
|
1044
|
-
`).length,[a]),K=J.useMemo(()=>o.find($=>$.id===s),[o,s]),R=J.useMemo(()=>o.filter($=>($.scope??"line")==="line").map($=>({lineNumber:$.lineEnd,metadata:$})),[o]),G=J.useMemo(()=>k?{start:k.range.start,end:k.range.end}:K?{start:K.lineStart,end:K.lineEnd}:null,[k,K]),T=R.length===0?r:void 0;J.useEffect(()=>{if(!s||!D.current)return;const $=setTimeout(()=>{D.current?.querySelector(`[data-code-annotation-id="${s}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})},100);return()=>clearTimeout($)},[s,n]);const L=J.useCallback(($,X,ce)=>{const te=Math.min($.start,$.end),he=Math.max($.start,$.end);_({range:{start:te,end:he},anchorEl:X,anchorRect:ce??X?.getBoundingClientRect()??x.current??void 0,contextText:`${M} ${Nwe(te,he)}`,originalCode:ngt(a,te,he)})},[a,M]),U=J.useCallback(()=>{if(!l)return;const $=agt(D.current),X=$?.toString();if(!$||$.isCollapsed||!X?.trim())return;const ce=Rie($.anchorNode),te=Rie($.focusNode);ce==null||te==null||(L({start:ce,end:te},void 0,x.current??($.rangeCount>0?$.getRangeAt(0).getBoundingClientRect():void 0)),$.removeAllRanges())},[l,L]),H=J.useCallback($=>$.metadata?y.jsx(rgt,{annotation:$.metadata,isSelected:s===$.metadata.id,onSelect:g,onEdit:d,onDelete:u}):null,[u,d,g,s]),q=J.useCallback($=>y.jsx("button",{type:"button",
|
|
1044
|
+
`).length,[a]),K=J.useMemo(()=>o.find($=>$.id===s),[o,s]),R=J.useMemo(()=>o.filter($=>($.scope??"line")==="line").map($=>({lineNumber:$.lineEnd,metadata:$})),[o]),G=J.useMemo(()=>k?{start:k.range.start,end:k.range.end}:K?{start:K.lineStart,end:K.lineEnd}:null,[k,K]),T=R.length===0?r:void 0;J.useEffect(()=>{if(!s||!D.current)return;const $=setTimeout(()=>{D.current?.querySelector(`[data-code-annotation-id="${s}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})},100);return()=>clearTimeout($)},[s,n]);const L=J.useCallback(($,X,ce)=>{const te=Math.min($.start,$.end),he=Math.max($.start,$.end);_({range:{start:te,end:he},anchorEl:X,anchorRect:ce??X?.getBoundingClientRect()??x.current??void 0,contextText:`${M} ${Nwe(te,he)}`,originalCode:ngt(a,te,he)})},[a,M]),U=J.useCallback(()=>{if(!l)return;const $=agt(D.current),X=$?.toString();if(!$||$.isCollapsed||!X?.trim())return;const ce=Rie($.anchorNode),te=Rie($.focusNode);ce==null||te==null||(L({start:ce,end:te},void 0,x.current??($.rangeCount>0?$.getRangeAt(0).getBoundingClientRect():void 0)),$.removeAllRanges())},[l,L]),H=J.useCallback($=>$.metadata?y.jsx(rgt,{annotation:$.metadata,isSelected:s===$.metadata.id,onSelect:g,onEdit:d,onDelete:u}):null,[u,d,g,s]),q=J.useCallback($=>y.jsx("button",{type:"button",style:tgt,title:"Add code comment",onMouseEnter:X=>{X.currentTarget.style.filter="brightness(1.2)"},onMouseLeave:X=>{X.currentTarget.style.filter=""},onClick:X=>{X.stopPropagation();const ce=$();ce&&L({start:ce.lineNumber,end:ce.lineNumber},X.currentTarget)},children:"+"}),[L]),P=J.useCallback($=>{l&&$&&($.start!==$.end&&(S.current=Date.now()+300),L({start:$.start,end:$.end},void 0,x.current??void 0))},[l,L]),j=J.useCallback($=>{l&&(Date.now()<S.current||L({start:$.lineNumber,end:$.lineNumber},void 0,$.lineElement.getBoundingClientRect()))},[l,L]),Z=async()=>{try{await navigator.clipboard.writeText(a),w(!0),setTimeout(()=>w(!1),1500)}catch($){console.error("Failed to copy:",$)}};if(i){const $=/^file not found/i.test(i);return y.jsx(yU,{open:t,onClose:e,title:A??F,container:p,className:"w-[min(520px,calc(100vw-4rem))]",children:y.jsxs("div",{className:"flex flex-col gap-2 px-5 py-6 text-sm",children:[y.jsx("div",{className:"font-medium text-foreground",children:i}),y.jsx("code",{className:"text-xs font-mono text-muted-foreground break-all",children:A??n}),$&&y.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"The path was referenced in the document but no matching file was found in this project. It may describe a planned/future file."})]})})}return y.jsxs(yU,{open:t,onClose:e,title:F,container:p,className:"w-[calc(100vw-4rem)] max-w-[min(calc(100vw-4rem),1500px)] h-[calc(100vh-4rem)]",children:[y.jsxs("div",{className:"flex items-center gap-3 px-5 pt-4 pb-3 pr-12",children:[y.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[y.jsx("svg",{className:"w-4 h-4 flex-shrink-0 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),y.jsx("span",{className:"text-sm font-medium text-foreground truncate",title:n,children:M})]}),y.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[y.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[O," lines"]}),y.jsx("button",{onClick:Z,title:B?"Copied!":"Copy file contents",className:`p-1.5 rounded-md transition-colors ${B?"text-success":"text-muted-foreground hover:bg-muted hover:text-foreground"}`,children:B?y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})})})]})]}),y.jsx("div",{className:"border-t border-border/30"}),y.jsx("div",{ref:D,className:"flex-1 min-h-0",onPointerMove:$=>{x.current=new DOMRect($.clientX,$.clientY,0,0)},onMouseUp:()=>{requestAnimationFrame(U)},children:y.jsx(egt,{file:{name:F,contents:a},prerenderedHTML:T,className:"h-full",lineAnnotations:R,selectedLines:G,renderAnnotation:H,renderGutterUtility:q,style:{"--diffs-dark-bg":b.bg,"--diffs-light-bg":b.bg,"--diffs-dark":b.fg,"--diffs-light":b.fg},options:{themeType:C.type,unsafeCSS:C.css,overflow:"scroll",disableFileHeader:!0,enableLineSelection:!0,enableGutterUtility:!!l,lineHoverHighlight:l?"line":"disabled",onLineClick:j,onLineSelectionEnd:P}},n)}),k&&l&&y.jsx(F1,{anchorEl:k.anchorEl,anchorRect:k.anchorRect,contextText:k.contextText,isGlobal:!1,onSubmit:($,X)=>{l({filePath:n,lineStart:k.range.start,lineEnd:k.range.end,text:$,images:X,originalCode:k.originalCode}),_(null)},onClose:()=>_(null)})]})},Agt=`# Implementation Plan: Real-time Collaboration
|
|
1045
1045
|
|
|
1046
1046
|
## Context
|
|
1047
1047
|
|
|
@@ -1426,7 +1426,7 @@ On the server side, update packages/server/index.ts to register the new WebSocke
|
|
|
1426
1426
|
- Commands like \`npm install\` and \`bun run build\` remain unchanged
|
|
1427
1427
|
|
|
1428
1428
|
**Target:** Ship MVP in next sprint
|
|
1429
|
-
`;function ogt(t){return!t.archiveMode&&!t.isPlanDiffActive}function sgt(t,e){const n=e?.restore!==!1;return e?.sidebarTab?{sidebarOpen:!0,sidebarTab:e.sidebarTab,panelOpen:e.panelOpen}:{sidebarOpen:n?t?.sidebarIsOpen??!1:!1,sidebarTab:n&&t?.sidebarIsOpen?t.sidebarTab:null,panelOpen:e?.panelOpen??(n?t?.panelOpen??!1:void 0)}}function cgt({blocks:t,annotations:e,addAnnotation:n,removeAnnotation:a}){const[r,i]=J.useState(new Map),A=J.useRef(t);A.current=t;const o=J.useRef(e);o.current=e,J.useEffect(()=>{if(r.size===0)return;const d=new Set(t.map(g=>g.id)),u=[...r.keys()].filter(g=>!d.has(g));u.length>0&&i(g=>{const p=new Map(g);return u.forEach(m=>p.delete(m)),p})},[t]);const s=J.useCallback((d,u)=>{const g=A.current,p=o.current,m=g.find(b=>b.id===d);if(m&&u===m.checked)i(C=>{const I=new Map(C);return I.delete(d),I}),p.filter(C=>C.blockId===d&&C.id.startsWith("ann-checkbox-")).forEach(C=>a(C.id));else if(p.filter(C=>C.blockId===d&&C.id.startsWith("ann-checkbox-")).forEach(C=>a(C.id)),i(C=>{const I=new Map(C);return I.set(d,u),I}),m){const C=g.indexOf(m);let I="";for(let _=C-1;_>=0;_--)if(g[_].type==="heading"){I=g[_].content;break}const B=u?"Mark as completed":"Mark as not completed",w=I?` (under "${I}")`:` (line ${m.startLine})`,k={id:`ann-checkbox-${d}-${Date.now()}`,blockId:d,startOffset:0,endOffset:m.content.length,type:Ba.COMMENT,text:`${B}${w}: ${m.content}`,originalText:m.content,createdA:Date.now()};n(k)}},[n,a]),l=J.useCallback(d=>{i(u=>{const g=new Map(u);return g.delete(d),g})},[]);return{overrides:r,toggle:s,revertOverride:l}}const lgt=Agt,dgt=()=>{const[t,e]=J.useState(lgt),[n,a]=J.useState([]),[r,i]=J.useState([]),[A,o]=J.useState(null),[s,l]=J.useState(null),[d,u]=J.useState([]),[g,p]=J.useState(null),[m,f]=J.useState(!1),[b,C]=J.useState(!1),[I,B]=J.useState(!1),[w,k]=J.useState(!1),[_,D]=J.useState(!1),[x,S]=J.useState("close"),[F,M]=J.useState(!1),[O,K]=J.useState(""),[R,G]=J.useState(()=>window.innerWidth>=768),[T,L]=J.useState(!1),[U,H]=J.useState(Frt),[q,P]=J.useState(Grt),[j,Z]=J.useState(()=>zt.getItem("plannotator-tater-mode")==="true"),[$,X]=J.useState(()=>nP()),ce=J.useRef(null),[te,he]=J.useState("full");J.useLayoutEffect(()=>{const Ke=ce.current;if(!Ke)return;const Pt=ln=>ln>=800?"full":ln>=680?"short":"icon";he(Pt(Ke.getBoundingClientRect().width));const jt=new ResizeObserver(([ln])=>{const ma=Pt(ln.contentRect.width);he(Ha=>Ha===ma?Ha:ma)});return jt.observe(Ke),()=>jt.disconnect()},[]);const[ae,se]=J.useState(!1),[oe,Ae]=J.useState(null),[pe,le]=J.useState(),[ke,me]=J.useState(!1),[He,ie]=J.useState([]),[Ze,ve]=J.useState(!1),[at,rt]=J.useState(!1),[ct,Oe]=J.useState(null),[st,qe]=J.useState(),[ze,At]=J.useState(!1),[_e,et]=J.useState(),[fe,De]=J.useState(void 0),[V,ye]=J.useState(!0),[Ce,Ne]=J.useState(!1),[Me,Ue]=J.useState(!1),[Ee,xe]=J.useState(null),[We,nt]=J.useState(null),[ht,Qe]=J.useState(!1),[Ye,Ge]=J.useState("bypassPermissions"),[ot,Ft]=J.useState(!0),[Nt,re]=J.useState(void 0),[pt,dt]=J.useState(void 0),[_t,St]=J.useState(null),[Ot,gt]=J.useState(null),[ft,Vt]=J.useState(null),Yt=J.useRef(null),rn=J.useRef($.tocEnabled);J.useEffect(()=>{document.title=_t?`${_t.display} · Plannotator`:"Plannotator"},[_t]);const[Fn,vn]=J.useState(),[hn,fn]=J.useState(null),[Gn,Et]=J.useState(!1),[be,$e]=J.useState("clean"),[vt,pn]=J.useState(null),[Sn,an]=J.useState(null),qn=UIe(),oa=J.useRef(null),{ref:pa,viewport:Gt,onViewportReady:It}=Yrt();Hrt();const Lt=cre({storageKey:"plannotator-panel-width"}),Mt=cre({storageKey:"plannotator-toc-width",defaultWidth:240,minWidth:160,maxWidth:400,side:"left"}),xt=Lt.isDragging||Mt.isDragging,qt=ait(nP().tocEnabled),Le=J.useMemo(()=>d.some(Ke=>Ke.type==="heading"&&(Ke.level??0)<=3),[d]),va=J.useCallback(Ke=>{if(ft===null){Ke?.sidebarTab&&qt.open(Ke.sidebarTab),Ke?.panelOpen===!0?G(!0):Ke?.panelOpen===!1&&G(!1);return}const Pt=Yt.current,jt=sgt(Pt,Ke);Vt(null),Yt.current=null,jt.sidebarOpen&&jt.sidebarTab?qt.open(jt.sidebarTab):qt.close(),jt.panelOpen!==void 0&&G(jt.panelOpen)},[ft,qt.close,qt.open]),Te=J.useCallback(Ke=>{if(ft!==null){va({restore:!1,sidebarTab:Ke,panelOpen:!1});return}qt.open(Ke)},[va,ft,qt.open]),Kn=J.useCallback(Ke=>{if(ft!==null){va({restore:!1,sidebarTab:Ke,panelOpen:!1});return}qt.toggleTab(Ke)},[va,ft,qt.toggleTab]),Ko=J.useCallback(()=>{if(ft!==null){va({restore:!1,panelOpen:!0});return}G(Ke=>!Ke)},[va,ft]);J.useEffect(()=>{ft===null&&rn.current!==$.tocEnabled&&(rn.current=$.tocEnabled,$.tocEnabled&&Le?qt.open("toc"):$.tocEnabled||qt.close())},[ft,qt.close,qt.open,$.tocEnabled,Le]),J.useEffect(()=>{d.length!==0&&(Le||qt.activeTab==="toc"&&qt.isOpen&&qt.close())},[d,Le]),J.useEffect(()=>{qt.activeTab==="toc"&&Gn&&Et(!1)},[qt.activeTab]),J.useEffect(()=>{if(!Gn)return;const Ke=Pt=>{Pt.key==="Escape"&&Et(!1)};return document.addEventListener("keydown",Ke),()=>document.removeEventListener("keydown",Ke)},[Gn]);const Ga=Kit(t,vt,Sn),go=J.useMemo(()=>({...qt,open:Te,toggleTab:Kn}),[Te,qt.activeTab,qt.close,qt.isOpen,Kn]),wn=Hit({markdown:t,annotations:n,selectedAnnotationId:A,globalAttachments:He,setMarkdown:e,setAnnotations:a,setSelectedAnnotationId:o,setGlobalAttachments:ie,viewerRef:oa,sidebar:go,sourceFilePath:_e,sourceConverted:ze}),sr=J.useMemo(()=>wn.filepath?wn.filepath.replace(/\/[^/]+$/,""):fe?.includes("/")?fe:void 0,[wn.filepath,fe]),Ja=Yit({buildUrl:J.useCallback(Ke=>sr?`/api/doc?path=${encodeURIComponent(Ke)}&base=${encodeURIComponent(sr)}`:`/api/doc?path=${encodeURIComponent(Ke)}`,[sr])}),Ia=Wit({markdown:t,viewerRef:oa,linkedDocHook:wn,setMarkdown:e,setAnnotations:a,setSelectedAnnotationId:o,setSubmitted:xe}),yi=J.useMemo(()=>ogt({archiveMode:Ia.archiveMode,isPlanDiffActive:Gn}),[Ia.archiveMode,Gn]),po=J.useCallback(Ke=>{yi&&(ft===null&&(Yt.current={sidebarIsOpen:qt.isOpen,sidebarTab:qt.activeTab,panelOpen:R}),Vt(Ke),qt.close(),G(!1))},[yi,R,ft,qt.activeTab,qt.close,qt.isOpen]),Rr=J.useCallback(Ke=>{ft===Ke?va():po(Ke)},[po,va,ft]);J.useEffect(()=>{!yi&&ft!==null&&va()},[yi,va,ft]);const fa=aAt(),Wa=J.useMemo(()=>Rae()?cp(sp()):"",[$]),Cn=J.useMemo(()=>!!Ot||tre()||Rae(),[Ot,$]),_n=J.useMemo(()=>{const Ke=Ot?[Ot]:[],Pt=tre()?YH().directories:[];return[...new Set([...Ke,...Pt])]},[Ot,$]);J.useEffect(()=>{Cn||fa.setActiveFile(null)},[Cn]),J.useEffect(()=>{Wa||fa.clearVaultDirs()},[Wa]),J.useEffect(()=>{if(qt.activeTab==="files"&&Cn){if(_n.length>0){const Ke=fa.dirs.filter(jt=>!jt.isVault).map(jt=>jt.path);(_n.some(jt=>!Ke.includes(jt))||Ke.some(jt=>!_n.includes(jt)))&&fa.fetchAll(_n)}Wa&&!fa.dirs.find(Ke=>Ke.isVault&&Ke.path===Wa&&!Ke.error)&&fa.addVaultDir(Wa)}},[qt.activeTab,Cn,_n,Wa]);const rr=or.useCallback((Ke,Pt)=>{const ln=fa.dirs.find(ma=>ma.path===Pt)?.isVault?ma=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(Pt)}&path=${encodeURIComponent(ma)}`:ma=>`/api/doc?path=${encodeURIComponent(ma)}&base=${encodeURIComponent(Pt)}`;wn.open(Ke,ln,"files"),fa.setActiveFile(Ke)},[wn,fa]),la=or.useCallback(Ke=>{if(fa.dirs.find(jt=>jt.path===fa.activeDirPath)?.isVault&&fa.activeDirPath)wn.open(Ke,jt=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(fa.activeDirPath)}&path=${encodeURIComponent(jt)}`);else if(fa.activeFile&&fa.activeDirPath){const jt=wn.filepath?.replace(/\/[^/]+$/,"")||fa.activeDirPath;wn.open(Ke,ln=>`/api/doc?path=${encodeURIComponent(ln)}&base=${encodeURIComponent(jt)}`)}else{const jt=wn.filepath?wn.filepath.replace(/\/[^/]+$/,""):fe?.includes("/")?fe:void 0;jt?wn.open(Ke,ln=>`/api/doc?path=${encodeURIComponent(ln)}&base=${encodeURIComponent(jt)}`):wn.open(Ke)}},[fa.dirs,fa.activeDirPath,fa.activeFile,wn,fe]),li=or.useCallback(()=>{wn.back(),fa.setActiveFile(null),Ia.clearSelection()},[wn,fa,Ia]),Ka=J.useMemo(()=>{const Ke=new Map;for(const[Pt,jt]of wn.getDocAnnotations()){const ln=jt.annotations.length+jt.globalAttachments.length;ln>0&&Ke.set(Pt,ln)}return Ke},[wn.getDocAnnotations,n,He]),mA=J.useMemo(()=>{const Ke=fa.dirs.map(jt=>jt.path);if(Ke.length===0)return Ka;const Pt=new Map;for(const[jt,ln]of Ka)Ke.some(ma=>jt.startsWith(ma+"/"))&&Pt.set(jt,ln);return Pt},[Ka,fa.dirs]),di=mA.size>0,$t=J.useMemo(()=>{const Ke=wn.filepath;let Pt=0,jt=0;for(const[ln,ma]of Ka)ln!==Ke&&(Pt+=ma,jt++);return Pt>0?{count:Pt,files:jt}:void 0},[Ka,wn.filepath]),[z,ee]=J.useState(),ge=or.useRef(),we=or.useCallback(()=>{const Ke=new Set(Ka.keys());Ke.size!==0&&((!qt.isOpen||qt.activeTab!=="files")&&Te("files"),ge.current&&clearTimeout(ge.current),ee(void 0),requestAnimationFrame(()=>{ee(Ke),ge.current=setTimeout(()=>ee(void 0),1200)}))},[Ka,Te,qt,di]),Pe=ct==="folder"?"file list":ct==="file"?"file":ct==="message"?"message":"plan",tt=J.useMemo(()=>d.filter(Ke=>Ke.type==="heading").length,[d]),bt=yrt(pa,tt,Gt),{editorAnnotations:Bt,deleteEditorAnnotation:An}=Vit(),{externalAnnotations:On,updateExternalAnnotation:Wn,deleteExternalAnnotation:ua}=eAt({enabled:ae}),{reset:ca}=tAt({viewerRef:oa,externalAnnotations:On,enabled:ae&&!wn.isActive&&!Gn,planKey:t}),on=J.useMemo(()=>On.length===0?n:[...n.filter(Pt=>Pt.source?!On.some(jt=>jt.source===Pt.source&&jt.type===Pt.type&&jt.originalText===Pt.originalText):!0),...On],[n,On]),Hn=J.useMemo(()=>on.filter(Ke=>!!Ke.diffContext),[on]),Ir=J.useMemo(()=>on.filter(Ke=>!Ke.diffContext),[on]),ui=J.useMemo(()=>on.length>0||r.length>0||Bt.length>0||wn.docAnnotationCount>0||He.length>0,[on.length,r.length,Bt.length,wn.docAnnotationCount,He.length]),Wi=on.length+r.length+Bt.length+wn.docAnnotationCount+He.length,ir=ot&&r.length===0,{isSharedSession:vr,isLoadingShared:Ho,shareUrl:Ur,shareUrlSize:Ll,shortShareUrl:ai,isGeneratingShortUrl:pI,shortUrlError:Em,pendingSharedAnnotations:Hd,clearPendingSharedAnnotations:mI,generateShortUrl:VN,importFromShareUrl:XN,shareLoadError:P0,clearShareLoadError:hI}=Ert(t,on,He,e,a,ie,()=>{ye(!1)},Nt,pt),{draftBanner:Im,restoreDraft:K0,dismissDraft:$N}=Jit({annotations:on,codeAnnotations:r,globalAttachments:He,isApiMode:ae,isSharedSession:vr,submitted:!!Ee}),eM=or.useCallback(()=>{const{annotations:Ke,codeAnnotations:Pt,globalAttachments:jt}=K0();(Ke.length>0||Pt.length>0||jt.length>0)&&(a(Ke),i(Pt),jt.length>0&&ie(jt),setTimeout(()=>{oa.current?.applySharedAnnotations(Ke.filter(ln=>!ln.diffContext))},100))},[K0]),{agents:H0,getAgentWarning:Bm}=Kye(oe);J.useEffect(()=>{if(Hd&&Hd.length>0){const Ke=setTimeout(()=>{oa.current?.clearAllHighlights(),oa.current?.applySharedAnnotations(Hd.filter(Pt=>!Pt.diffContext)),mI(),ca()},100);return()=>clearTimeout(Ke)}},[Hd,mI,ca]);const tM=Ke=>{Z(Ke),zt.setItem("plannotator-tater-mode",String(Ke))},Y0=Ke=>{H(Ke),Lrt(Ke)},fI=Ke=>{P(Ke),Ort(Ke)};Krt(q,fI),J.useEffect(()=>{Ho||vr||fetch("/api/plan").then(Ke=>{if(!Ke.ok)throw new Error("Not in API mode");return Ke.json()}).then(Ke=>{fi.init(Ke.serverConfig),le(Ke.serverConfig?.gitUser),Ke.mode==="archive"?(e(Ke.plan||""),Ke.archivePlans&&Ia.init(Ke.archivePlans),Ia.fetchPlans(),Ft(!1),qt.open("archive")):Ke.mode==="annotate-folder"?e(""):Ke.plan&&e(Ke.plan),se(!0),(Ke.mode==="annotate"||Ke.mode==="annotate-last"||Ke.mode==="annotate-folder")&&(ve(!0),rt(Ke.gate??!1)),Ke.mode==="annotate-folder"&&qt.open("files"),Ke.mode&&Ke.mode!=="archive"&&Oe(Ke.mode==="annotate-last"?"message":Ke.mode==="annotate-folder"?"folder":"file"),qe(Ke.sourceInfo??void 0),At(!!Ke.sourceConverted),Ke.filePath&&(De(Ke.mode==="annotate-folder"?Ke.filePath:Ke.filePath.replace(/\/[^/]+$/,"")),Ke.mode==="annotate"&&et(Ke.filePath)),Ke.sharingEnabled!==void 0&&Ft(Ke.sharingEnabled),Ke.shareBaseUrl&&re(Ke.shareBaseUrl),Ke.pasteApiUrl&&dt(Ke.pasteApiUrl),Ke.repoInfo&&St(Ke.repoInfo),Ke.projectRoot&>(Ke.projectRoot),Ke.previousPlan!==void 0&&pn(Ke.previousPlan),Ke.versionInfo&&an(Ke.versionInfo),Ke.origin&&(Ae(Ke.origin),Ke.origin==="claude-code"&&Mat()&&Qe(!0),Ge(Gye().mode)),Ke.isWSL&&me(!0)}).catch(()=>{se(!1)}).finally(()=>ye(!1))},[Ho,vr]),J.useEffect(()=>{const{frontmatter:Ke}=ige(t);p(Ke),u(wQ(t))},[t]);const bI=J.useRef(!1),hg=J.useRef({}),Kf=J.useRef(null);J.useEffect(()=>{bI.current=!1,hg.current={},Kf.current=null},[t]),J.useEffect(()=>{if(!ae||!t||vr||Ze||Ia.archiveMode||bI.current)return;const Ke={},Pt=[],jt=sp();if(jt.autoSave&&jt.enabled){const Pr=cp(jt);Pr&&(Ke.obsidian={vaultPath:Pr,folder:jt.folder||"plannotator",plan:t,...jt.filenameFormat&&{filenameFormat:jt.filenameFormat},...jt.filenameSeparator&&jt.filenameSeparator!=="space"&&{filenameSeparator:jt.filenameSeparator}},Pt.push("Obsidian"))}const ln=lh();ln.autoSave&&ln.enabled&&(Ke.bear={plan:t,customTags:ln.customTags,tagPosition:ln.tagPosition},Pt.push("Bear"));const ma=wC();if(ma.autoSave&&Ov()&&(Ke.octarine={plan:t,workspace:ma.workspace,folder:ma.folder||"plannotator"},Pt.push("Octarine")),Pt.length===0)return;bI.current=!0;const Ha=fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ke)}).then(Pr=>Pr.json()).then(Pr=>{const hA={...Ke.obsidian?{obsidian:!!Pr.results?.obsidian?.success}:{},...Ke.bear?{bear:!!Pr.results?.bear?.success}:{},...Ke.octarine?{octarine:!!Pr.results?.octarine?.success}:{}};hg.current=hA;const Ig=Pt.filter(gi=>!Pr.results?.[gi.toLowerCase()]?.success);return Ig.length===0?fn({type:"success",message:`Auto-saved to ${Pt.join(" & ")}`}):fn({type:"error",message:`Auto-save failed for ${Ig.join(" & ")}`}),hA}).catch(()=>(hg.current={},fn({type:"error",message:"Auto-save failed"}),{})).finally(()=>setTimeout(()=>fn(null),3e3));Kf.current=Ha},[ae,t,vr,Ze]),J.useEffect(()=>{const Ke=Pt=>{const jt=Pt.clipboardData?.items;if(jt){for(const ln of jt)if(ln.type.startsWith("image/")){Pt.preventDefault();const ma=ln.getAsFile();if(ma){const Ha=DU(ma.name,He.map(hA=>hA.name)),Pr=URL.createObjectURL(ma);nt({file:ma,blobUrl:Pr,initialName:Ha})}break}}};return document.addEventListener("paste",Ke),()=>document.removeEventListener("paste",Ke)},[He]);const nM=async(Ke,Pt,jt)=>{if(We)try{const ln=new FormData,ma=Pt?new File([Ke],"annotated.png",{type:"image/png"}):We.file;ln.append("file",ma);const Ha=await fetch("/api/upload",{method:"POST",body:ln});if(Ha.ok){const Pr=await Ha.json();ie(hA=>[...hA,{path:Pr.path,name:jt}])}}catch{}finally{URL.revokeObjectURL(We.blobUrl),nt(null)}},aM=()=>{We&&(URL.revokeObjectURL(We.blobUrl),nt(null))},fg=async()=>{Ne(!0);try{const Ke=sp(),Pt=lh(),jt=wC(),ln=US(),ma=Pt.autoSave&&Kf.current?await Kf.current:hg.current,Ha={};oe==="claude-code"&&(Ha.permissionMode=Ye);const Pr=Sat(IR());Pr&&(Ha.agentSwitch=Pr),Ha.planSave={enabled:ln.enabled,...ln.customPath&&{customPath:ln.customPath}};const hA=cp(Ke);Ke.enabled&&hA&&(Ha.obsidian={vaultPath:hA,folder:Ke.folder||"plannotator",plan:t,...Ke.filenameFormat&&{filenameFormat:Ke.filenameFormat},...Ke.filenameSeparator&&Ke.filenameSeparator!=="space"&&{filenameSeparator:Ke.filenameSeparator}}),Pt.enabled&&!(Pt.autoSave&&ma.bear)&&(Ha.bear={plan:t,customTags:Pt.customTags,tagPosition:Pt.tagPosition}),Ov()&&(Ha.octarine={plan:t,workspace:jt.workspace,folder:jt.folder||"plannotator"});const Ig=Array.from(wn.getDocAnnotations().values()).some(gi=>gi.annotations.length>0||gi.globalAttachments.length>0);(on.length>0||r.length>0||He.length>0||Ig||Bt.length>0)&&(Ha.feedback=Yd),await fetch("/api/approve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ha)}),xe("approved")}catch{Ne(!1)}},q0=async()=>{Ne(!0);try{const Ke=US();await fetch("/api/deny",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:Yd,planSave:{enabled:Ke.enabled,...Ke.customPath&&{customPath:Ke.customPath}}})}),xe("denied")}catch{Ne(!1)}},j0=async()=>{Ne(!0);try{await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:Yd,annotations:on,codeAnnotations:r})}),xe("denied")}catch{Ne(!1)}},CI=async()=>{Ne(!0);try{await fetch("/api/approve",{method:"POST"}),xe("approved")}catch{Ne(!1)}},z0=J.useCallback(async()=>{Ue(!0);try{if((await fetch("/api/exit",{method:"POST"})).ok)xe("exited");else throw new Error("Failed to exit")}catch{Ue(!1)}},[]);J.useEffect(()=>{const Ke=Pt=>{if(Pt.key!=="Enter"||!(Pt.metaKey||Pt.ctrlKey))return;const jt=Pt.target?.tagName;if(jt==="INPUT"||jt==="TEXTAREA"||m||b||I||w||_||F||ht||We||Ee||Ce||Me||!ae||wn.isActive)return;if(Pt.preventDefault(),Ze){if(at&&!ui){CI();return}j0();return}const ln=wn.getDocAnnotations(),ma=Array.from(ln.values()).some(Ha=>Ha.annotations.length>0||Ha.globalAttachments.length>0);if(on.length===0&&r.length===0&&Bt.length===0&&!ma){if(oe==="opencode"){const Ha=Bm();if(Ha){K(Ha),M(!0);return}}fg()}else q0()};return window.addEventListener("keydown",Ke),()=>window.removeEventListener("keydown",Ke)},[m,b,I,w,_,F,ht,We,Ee,Ce,Me,ae,wn.isActive,n.length,r.length,On.length,Ze,at,ui,oe,Bm]);const EI=Ke=>{a(Pt=>[...Pt,Ke]),o(Ke.id),l(null),ft===null&&G(!0)},II=or.useCallback(Ke=>{o(Ke),Ke&&l(null),Ke&&qn&&ft===null&&G(!0)},[qn,ft]),rM=or.useCallback(Ke=>{const Pt={id:rAt("code-ann"),type:"comment",scope:"line",filePath:Ke.filePath,lineStart:Ke.lineStart,lineEnd:Ke.lineEnd,side:"new",text:Ke.text,images:Ke.images,originalCode:Ke.originalCode,createdAt:Date.now(),author:fi.get("displayName")||void 0};i(jt=>[...jt,Pt]),o(null),l(Pt.id),ft===null&&G(!0)},[ft]),iM=or.useCallback(Ke=>{const Pt=r.find(jt=>jt.id===Ke);Pt&&(o(null),l(Ke),Ja.open(Pt.filePath),qn&&ft===null&&G(!0))},[r,Ja.open,qn,ft]),J0=or.useCallback(Ke=>{i(Pt=>Pt.filter(jt=>jt.id!==Ke)),s===Ke&&l(null)},[s]),Hf=or.useCallback((Ke,Pt)=>{i(jt=>jt.map(ln=>ln.id===Ke?{...ln,...Pt}:ln))},[]),bg=Ke=>{oa.current?.removeHighlight(Ke),a(Pt=>Pt.filter(jt=>jt.id!==Ke)),A===Ke&&o(null)},BI=cgt({blocks:d,annotations:n,addAnnotation:EI,removeAnnotation:bg}),W0=Ke=>{const Pt=on.find(jt=>jt.id===Ke);if(Pt?.source&&On.some(jt=>jt.id===Ke)){ua(Ke),A===Ke&&o(null);return}Ke.startsWith("ann-checkbox-")&&Pt&&BI.revertOverride(Pt.blockId),bg(Ke)},Z0=(Ke,Pt)=>{if(on.find(ln=>ln.id===Ke)?.source&&On.some(ln=>ln.id===Ke)){Wn(Ke,Pt);return}a(ln=>ln.map(ma=>ma.id===Ke?{...ma,...Pt}:ma))},V0=(Ke,Pt)=>{a(jt=>jt.map(ln=>ln.author===Ke?{...ln,author:Pt}:ln)),i(jt=>jt.map(ln=>ln.author===Ke?{...ln,author:Pt}:ln))},X0=Ke=>{ie(Pt=>[...Pt,Ke])},$0=Ke=>{ie(Pt=>Pt.filter(jt=>jt.path!==Ke))},Cg=Ke=>{},Yd=J.useMemo(()=>{const Ke=wn.getDocAnnotations(),Pt=Array.from(Ke.values()).some(hA=>hA.annotations.length>0||hA.globalAttachments.length>0),jt=on.length>0||He.length>0,ln=Bt.length>0,ma=r.length>0;if(!jt&&!Pt&&!ln&&!ma)return"User reviewed the document and has no feedback.";const Ha=wn.isActive?Ke.get(wn.filepath??"")?.isConverted??!1:ze;let Pr=jt?JNe(d,on,He,ct==="message"?"Message Feedback":ct==="folder"?"Folder Feedback":ct==="file"?"File Feedback":"Plan Feedback",ct??"plan",{sourceConverted:Ha}):"";if(Pt){const hA=new Map(Ke);for(const[Ig,gi]of hA)gi.markdown&&hA.set(Ig,{...gi,blocks:wQ(gi.markdown)});Pr+=WNe(hA)}return ln&&(Pr+=ZNe(Bt)),ma&&(Pr+=VNe(r)),Pr},[d,on,He,wn.getDocAnnotations,Bt,r,ze,ct,wn.isActive,wn.filepath]),Yf=or.useMemo(()=>Irt(),[]),qf=or.useCallback(async Ke=>{if(!(!Yf||Ce||!Ur)){Ne(!0);try{const Pt=await Brt(Ke,Yf,Ur);Pt&&(fn(Pt),setTimeout(()=>fn(null),4e3),Pt.type==="success"&&xe(Ke===Rx.Approve?"approved":"denied"))}finally{Ne(!1)}}},[Yf,Ce,Ur]),ek=or.useCallback(()=>qf(Rx.Approve),[qf]),tk=or.useCallback(()=>qf(Rx.Feedback),[qf]),Eg=()=>{const Ke=new Blob([Yd],{type:"text/plain"}),Pt=URL.createObjectURL(Ke),jt=document.createElement("a");jt.href=Pt,jt.download="annotations.md",jt.click(),URL.revokeObjectURL(Pt),fn({type:"success",message:"Downloaded annotations"}),setTimeout(()=>fn(null),3e3)},tc=async Ke=>{const Pt={};if(Ke==="obsidian"){const ln=sp(),ma=cp(ln);ma&&(Pt.obsidian={vaultPath:ma,folder:ln.folder||"plannotator",plan:t,...ln.filenameFormat&&{filenameFormat:ln.filenameFormat},...ln.filenameSeparator&&ln.filenameSeparator!=="space"&&{filenameSeparator:ln.filenameSeparator}})}if(Ke==="bear"){const ln=lh();Pt.bear={plan:t,customTags:ln.customTags,tagPosition:ln.tagPosition}}if(Ke==="octarine"){const ln=wC();Pt.octarine={plan:t,workspace:ln.workspace,folder:ln.folder||"plannotator"}}const jt=Ke==="obsidian"?"Obsidian":Ke==="bear"?"Bear":"Octarine";try{const Ha=(await(await fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Pt)})).json()).results?.[Ke];Ha?.success?fn({type:"success",message:`Saved to ${jt}`}):fn({type:"error",message:Ha?.error||"Save failed"})}catch{fn({type:"error",message:"Save failed"})}setTimeout(()=>fn(null),3e3)},AM=async()=>{const Ke=nAt(window.location.origin);try{await navigator.clipboard.writeText(Ke),fn({type:"success",message:"Agent instructions copied"})}catch{fn({type:"error",message:"Failed to copy"})}setTimeout(()=>fn(null),3e3)},jf=async()=>{try{await navigator.clipboard.writeText(Ur),fn({type:"success",message:"Share link copied"})}catch{fn({type:"error",message:"Failed to copy"})}setTimeout(()=>fn(null),3e3)};J.useEffect(()=>{const Ke=Pt=>{if(Pt.key!=="s"||!(Pt.metaKey||Pt.ctrlKey))return;const jt=Pt.target?.tagName;if(jt==="INPUT"||jt==="TEXTAREA"||m||I||w||_||F||ht||We||Ee||!ae)return;Pt.preventDefault();const ln=Pye(),ma=_ae(),Ha=lh().enabled,Pr=Ov();ln==="download"?Eg():ln==="obsidian"&&ma?tc("obsidian"):ln==="bear"&&Ha?tc("bear"):ln==="octarine"&&Pr?tc("octarine"):(vn("notes"),f(!0))};return window.addEventListener("keydown",Ke),()=>window.removeEventListener("keydown",Ke)},[m,I,w,_,F,ht,We,Ee,ae,t,Yd]),J.useEffect(()=>{const Ke=Pt=>{if(Pt.key!=="p"||!(Pt.metaKey||Pt.ctrlKey))return;const jt=Pt.target?.tagName;jt==="INPUT"||jt==="TEXTAREA"||m||I||w||_||F||ht||We||Ee||(Pt.preventDefault(),window.print())};return window.addEventListener("keydown",Ke),()=>window.removeEventListener("keydown",Ke)},[m,I,w,_,F,ht,We,Ee]);const qc=J.useMemo(()=>HNe(oe),[oe]),yI=J.useMemo(()=>({compact:832,default:1040,wide:1280})[$.planWidth]??832,[$.planWidth]),Tl=yi&&ft==="wide"?null:yI;return y.jsx(Itt,{defaultTheme:"dark",children:y.jsx(cat,{delayDuration:900,skipDelayDuration:200,disableHoverableContent:!0,children:y.jsxs("div",{"data-print-region":"root",className:"h-screen flex flex-col bg-background overflow-hidden",children:[y.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:[y.jsx("div",{className:"flex items-center gap-2 md:gap-3",children:y.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:y.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Plannotator"})})}),y.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[Yf&&!ae&&vr&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"}),y.jsx(n8,{onClick:tk,disabled:Ce||!Ur,isLoading:Ce,title:"Send feedback to bot"}),y.jsx(nre,{onClick:ek,disabled:Ce||!Ur,isLoading:Ce,title:"Approve design and notify bot"})]}),ae&&!wn.isActive&&Ia.archiveMode&&y.jsxs(y.Fragment,{children:[y.jsxs("button",{onClick:Ia.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:[y.jsx("span",{className:"hidden md:inline",children:"Copy"}),y.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})})]}),y.jsx("button",{onClick:Ia.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"})]}),ae&&(!wn.isActive||Ze)&&!Ia.archiveMode&&y.jsxs(y.Fragment,{children:[Ze?y.jsxs(y.Fragment,{children:[y.jsx(lrt,{onClick:()=>{ui?(S("close"),D(!0)):z0()},disabled:Ce||Me,isLoading:Me}),ui&&y.jsx(n8,{onClick:j0,disabled:Ce||Me,isLoading:Ce,label:"Send Annotations",title:"Send Annotations"})]}):y.jsx(n8,{onClick:()=>{const Ke=wn.getDocAnnotations(),Pt=Array.from(Ke.values()).some(jt=>jt.annotations.length>0||jt.globalAttachments.length>0);on.length===0&&r.length===0&&Bt.length===0&&!Pt?B(!0):q0()},disabled:Ce,isLoading:Ce,label:"Send Feedback",title:"Send Feedback"}),(!Ze||at)&&(oe==="opencode"&&!Ze&&H0.length>0?y.jsx(grt,{onApprove:()=>{const Ke=Bm();if(Ke){K(Ke),M(!0);return}fg()},agents:H0,disabled:Ce,isLoading:Ce}):y.jsxs("div",{className:"relative group/approve",children:[y.jsx(nre,{onClick:()=>{if(Ze){if(ui){S("approve"),D(!0);return}CI();return}if(oe==="claude-code"&&(on.length>0||r.length>0)){k(!0);return}if(oe==="opencode"){const Ke=Bm();if(Ke){K(Ke),M(!0);return}}fg()},disabled:Ce||Ze&&Me,isLoading:Ce,dimmed:!Ze&&(oe==="claude-code"||oe==="gemini-cli")&&(on.length>0||r.length>0),title:Ze?"Approve — no changes requested":void 0}),!Ze&&(oe==="claude-code"||oe==="gemini-cli")&&(on.length>0||r.length>0)&&y.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:[y.jsx("div",{className:"absolute bottom-full right-4 border-4 border-transparent border-b-border"}),y.jsx("div",{className:"absolute bottom-full right-4 mt-px border-4 border-transparent border-b-popover"}),qc," doesn't support feedback on approval. Your annotations won't be seen."]})]})),y.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"})]}),y.jsx("button",{onClick:Ko,className:`p-1.5 rounded-md text-xs font-medium transition-all ${R?"bg-primary/15 text-primary":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:R?"Hide annotations":"Show annotations",children:y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})})}),y.jsx("div",{className:"hidden",children:y.jsx(crt,{taterMode:j,onTaterModeChange:tM,onIdentityChange:V0,origin:oe,onUIPreferencesChange:X,externalOpen:T,onExternalClose:()=>L(!1),gitUser:pe})}),y.jsx(zrt,{appVersion:"0.19.10",onOpenSettings:()=>{L(!0)},onOpenExport:()=>{vn(void 0),f(!0)},onCopyAgentInstructions:AM,onDownloadAnnotations:Eg,onPrint:()=>window.print(),onCopyShareLink:jf,onOpenImport:()=>C(!0),onSaveToObsidian:()=>tc("obsidian"),onSaveToBear:()=>tc("bear"),onSaveToOctarine:()=>tc("octarine"),sharingEnabled:ir,isApiMode:ae,agentInstructionsEnabled:ae&&!Ia.archiveMode&&!Ze,obsidianConfigured:_ae(),bearConfigured:lh().enabled,octarineConfigured:Ov()})]})]}),wn.error&&y.jsxs("div",{className:"bg-destructive/10 border-b border-destructive/20 px-4 py-2 flex items-center gap-2 flex-shrink-0",children:[y.jsx("span",{className:"text-xs text-destructive",children:wn.error}),y.jsx("button",{onClick:wn.dismissError,className:"ml-auto text-xs text-destructive/60 hover:text-destructive",children:"dismiss"})]}),y.jsx(OIe.Provider,{value:Gt,children:y.jsxs("div",{"data-print-region":"content",className:`flex-1 flex overflow-hidden relative z-0 ${xt?"select-none":""}`,children:[j&&y.jsx(Qat,{}),ft===null&&!qt.isOpen&&y.jsx(iAt,{activeTab:qt.activeTab,onToggleTab:Kn,hasDiff:Ga.hasPreviousVersion,showVersionsTab:Sn!==null&&Sn.totalVersions>1,showFilesTab:Cn&&!Ia.archiveMode,hasFileAnnotations:di,className:"hidden lg:flex absolute left-0 top-0 z-10"}),qt.isOpen&&y.jsxs(y.Fragment,{children:[y.jsx(fAt,{activeTab:qt.activeTab,onTabChange:Ke=>{Kn(Ke),Ke==="archive"&&!Ia.archiveMode&&Ia.fetchPlans()},onClose:qt.close,width:Mt.width,blocks:d,annotations:n,activeSection:bt,onTocNavigate:Cg,linkedDocFilepath:wn.filepath,onLinkedDocBack:wn.isActive?li:void 0,backLabel:Pe,showFilesTab:Cn&&!Ia.archiveMode,fileAnnotationCounts:mA,highlightedFiles:z,fileBrowser:fa,onFilesSelectFile:rr,onFilesFetchAll:()=>fa.fetchAll(_n),onFilesRetryVaultDir:Ke=>fa.addVaultDir(Ke),hasFileAnnotations:di,showVersionsTab:Sn!==null&&Sn.totalVersions>1,versionInfo:Sn,versions:Ga.versions,selectedBaseVersion:Ga.diffBaseVersion,onSelectBaseVersion:Ga.selectBaseVersion,isPlanDiffActive:Gn,hasPreviousVersion:Ga.hasPreviousVersion,onActivatePlanDiff:()=>Et(!0),isLoadingVersions:Ga.isLoadingVersions,isSelectingVersion:Ga.isSelectingVersion,fetchingVersion:Ga.fetchingVersion,onFetchVersions:Ga.fetchVersions,showArchiveTab:ae&&!Ze,archivePlans:Ia.plans,selectedArchiveFile:Ia.selectedFile,onArchiveSelect:Ia.select,isLoadingArchive:Ia.isLoading}),y.jsx(lre,{...Mt.handleProps,className:"hidden lg:block",side:"left"})]}),y.jsxs(Zw,{element:"main",className:`flex-1 min-w-0 bg-grid ${!qt.isOpen&&ft===null?"lg:pl-[30px]":""}`,"data-print-region":"document",onViewportReady:It,children:[y.jsx(xb,{isOpen:!!Im,onClose:$N,onConfirm:eM,title:"Draft Recovered",message:Im?`Found ${Im.count} annotation${Im.count!==1?"s":""} from ${Im.timeAgo}. Would you like to restore them?`:"",confirmText:"Restore",cancelText:"Dismiss",showCancel:!0}),y.jsxs("div",{ref:ce,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:[!Gn&&!Ia.archiveMode&&$.stickyActionsEnabled&&y.jsx(Cat,{inputMethod:q,onInputMethodChange:fI,mode:U,onModeChange:Y0,taterMode:j,repoInfo:_t,planDiffStats:Ga.diffStats,isPlanDiffActive:Gn,hasPreviousVersion:Ga.hasPreviousVersion,onPlanDiffToggle:()=>Et(!Gn),archiveInfo:Ia.currentInfo,maxWidth:Tl,remountToken:wn.isActive?`doc:${wn.filepath}`:"plan"}),!Gn&&!Ia.archiveMode&&y.jsx("div",{"data-print-hide":!0,className:"w-full mb-3 md:mb-4 flex items-center justify-start",style:Tl==null?void 0:{maxWidth:Tl},children:y.jsx(kye,{inputMethod:q,onInputMethodChange:fI,mode:U,onModeChange:Y0,taterMode:j})}),Ga.diffBlocks&&Ga.diffStats&&y.jsx("div",{className:"w-full flex justify-center",style:{display:Gn?void 0:"none"},children:y.jsx(SAt,{diffBlocks:Ga.diffBlocks,diffStats:Ga.diffStats,diffMode:be,onDiffModeChange:$e,onPlanDiffToggle:()=>Et(!1),repoInfo:_t,baseVersionLabel:Ga.diffBaseVersion!=null?`v${Ga.diffBaseVersion}`:void 0,baseVersion:Ga.diffBaseVersion??void 0,maxWidth:yI,annotations:Hn,onAddAnnotation:EI,onSelectAnnotation:II,selectedAnnotationId:A,mode:U})}),ct==="folder"&&!t&&!wn.isActive&&y.jsx("div",{className:"w-full flex justify-center",children:y.jsxs("div",{className:"w-full max-w-3xl p-12 text-center text-muted-foreground",children:[y.jsx("p",{className:"text-lg font-medium mb-2",children:"Select a file to annotate"}),y.jsx("p",{className:"text-sm",children:"Pick a markdown file from the sidebar to begin."})]})}),y.jsxs("div",{className:"w-full flex justify-center relative",style:{display:Gn&&Ga.diffBlocks||ct==="folder"&&!t&&!wn.isActive?"none":void 0},children:[yi&&!Gn&&!Ia.archiveMode&&y.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:Tl===null?void 0:{maxWidth:Tl??832},children:y.jsx("div",{className:`pointer-events-auto flex items-center gap-1.5 text-[11px] tracking-wide ${j?"mr-[60px]":"mr-[4px]"}`,children:["wide","focus"].map((Ke,Pt)=>y.jsxs(or.Fragment,{children:[Pt>0&&y.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/30 select-none",children:"|"}),y.jsx(lat,{side:"top",align:"end",content:Ke==="wide"?"Hide panels and expand document width":"Hide panels, keep document width",children:y.jsx("button",{type:"button",onClick:()=>Rr(Ke),"aria-pressed":ft===Ke,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 ${ft===Ke?"text-foreground":"text-muted-foreground/50 hover:text-muted-foreground"}`,children:Ke.charAt(0).toUpperCase()+Ke.slice(1)})})]},Ke))})}),y.jsx(Z$e,{ref:oa,blocks:d,markdown:t,frontmatter:g,annotations:Ir,onAddAnnotation:EI,onSelectAnnotation:II,selectedAnnotationId:A,mode:U,inputMethod:q,taterMode:j,globalAttachments:He,onAddGlobalAttachment:X0,onRemoveGlobalAttachment:$0,repoInfo:_t,stickyActions:$.stickyActionsEnabled,planDiffStats:wn.isActive?null:Ga.diffStats,isPlanDiffActive:Gn,onPlanDiffToggle:()=>Et(!Gn),hasPreviousVersion:!wn.isActive&&Ga.hasPreviousVersion,showDemoBadge:!ae&&!Ho&&!vr,maxWidth:Tl,onOpenLinkedDoc:la,onOpenCodeFile:Ja.open,linkedDocInfo:wn.isActive?{filepath:wn.filepath,onBack:li,label:fa.dirs.find(Ke=>Ke.path===fa.activeDirPath)?.isVault?"Vault File":fa.activeFile?"File":void 0,backLabel:Pe}:null,imageBaseDir:fe,codePathBaseDir:sr,copyLabel:ct==="message"?"Copy message":ct==="file"||ct==="folder"?"Copy file":void 0,archiveInfo:Ia.currentInfo,sourceInfo:st,onToggleCheckbox:BI.toggle,checkboxOverrides:BI.overrides,actionsLabelMode:te},wn.isActive?`doc:${wn.filepath}`:"plan")]})]})]}),R&&ft===null&&y.jsx(lre,{...Lt.handleProps,className:"hidden md:block",side:"right"}),y.jsx(dtt,{isOpen:R&&ft===null,blocks:d,annotations:on,selectedId:A??s,onSelect:II,onDelete:W0,onEdit:Z0,codeAnnotations:r,onSelectCodeAnnotation:iM,onDeleteCodeAnnotation:J0,onEditCodeAnnotation:Hf,sharingEnabled:ir,width:Lt.width,editorAnnotations:Bt,onDeleteEditorAnnotation:An,onClose:()=>G(!1),onQuickCopy:async()=>{await navigator.clipboard.writeText(oge(Yd))},onShare:ir&&Ur?()=>{G(!1),vn("share"),f(!0)}:void 0,otherFileAnnotations:$t,onOtherFileAnnotationsClick:we})]})}),Ja.popoutProps&&y.jsx(igt,{...Ja.popoutProps,annotations:r.filter(Ke=>Ke.filePath===Ja.popoutProps?.filepath),selectedAnnotationId:s,onAddAnnotation:rM,onEditAnnotation:Hf,onDeleteAnnotation:J0,onSelectAnnotation:Ke=>{o(null),l(Ke)}}),y.jsx(Ctt,{isOpen:m,onClose:()=>{f(!1),vn(void 0)},shareUrl:Ur,shareUrlSize:Ll,shortShareUrl:ai,isGeneratingShortUrl:pI,shortUrlError:Em,onGenerateShortUrl:VN,annotationsOutput:Yd,annotationCount:on.length+r.length,taterSprite:j?y.jsx(KH,{}):void 0,sharingEnabled:ir,markdown:t,isApiMode:ae,initialTab:Fn}),y.jsx(Ett,{isOpen:b,onClose:()=>C(!1),onImport:XN,shareBaseUrl:Nt}),y.jsx(xb,{isOpen:I,onClose:()=>B(!1),title:"Add Annotations First",message:`To provide feedback, select text in the plan and add annotations. ${qc} will use your annotations to revise the plan.`,variant:"info"}),y.jsx(xb,{isOpen:w,onClose:()=>k(!1),onConfirm:()=>{k(!1),fg()},title:"Annotations Won't Be Sent",message:y.jsxs(y.Fragment,{children:[qc," doesn't yet support feedback on approval. Your ",on.length+r.length," annotation",on.length+r.length!==1?"s":""," will be lost."]}),subMessage:y.jsxs(y.Fragment,{children:["To send feedback, use ",y.jsx("strong",{children:"Send Feedback"})," instead.",y.jsx("br",{}),y.jsx("br",{}),"Want this feature? Upvote these issues:",y.jsx("br",{}),y.jsx("a",{href:"https://github.com/anthropics/claude-code/issues/16001",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"#16001"})," · ",y.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}),y.jsx(xb,{isOpen:_,onClose:()=>D(!1),onConfirm:()=>{D(!1),x==="approve"?CI():z0()},title:"Annotations Won't Be Sent",message:y.jsxs(y.Fragment,{children:["You have ",Wi," annotation",Wi!==1?"s":""," that will be lost if you ",x==="approve"?"approve":"close","."]}),subMessage:"To send your annotations, use Send Annotations instead.",confirmText:x==="approve"?"Approve Anyway":"Close Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),y.jsx(xb,{isOpen:F,onClose:()=>M(!1),onConfirm:()=>{M(!1),fg()},title:"Agent Not Found",message:O,subMessage:y.jsxs(y.Fragment,{children:["You can change the agent in ",y.jsx("strong",{children:"Settings"}),", or approve anyway and OpenCode will use the default agent."]}),confirmText:"Approve Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),y.jsx(xb,{isOpen:!!P0&&!ae,onClose:hI,title:"Shared Plan Could Not Be Loaded",message:P0,subMessage:"You are viewing a demo plan. This is sample content — it is not your data or anyone else's.",variant:"warning"}),hn&&y.jsx("div",{className:`fixed top-16 right-4 z-50 px-3 py-2 rounded-lg text-xs font-medium shadow-lg transition-opacity ${hn.type==="success"?"bg-success/15 text-success border border-success/30":"bg-destructive/15 text-destructive border border-destructive/30"}`,children:hn.message}),y.jsx(vrt,{submitted:Ee,title:Ia.archiveMode?"Archive Closed":Ee==="exited"?"Session Closed":Ee==="approved"?Ze?"Approved":"Plan Approved":Ze?"Annotations Sent":"Feedback Sent",subtitle:Ee==="exited"?"Annotation session closed without feedback.":Ia.archiveMode?"You can reopen with plannotator archive.":Ee==="approved"?Ze?`${qc} will proceed.`:`${qc} will proceed with the implementation.`:Ze?`${qc} will address your annotations on the ${ct==="message"?"message":ct==="folder"?"files":"file"}.`:`${qc} will revise the plan based on your annotations.`,agentLabel:qc}),y.jsx(Nrt,{origin:oe,isWSL:ke}),y.jsx(Spe,{isOpen:!!We,imageSrc:We?.blobUrl??"",initialName:We?.initialName,onAccept:nM,onClose:aM}),y.jsx(nit,{isOpen:ht,onComplete:Ke=>{Ge(Ke),Qe(!1)}})]})})})},Mwe=document.getElementById("root");if(!Mwe)throw new Error("Could not find root element to mount to");const ugt=KNe.createRoot(Mwe);ugt.render(y.jsx(or.StrictMode,{children:y.jsx(dgt,{})}));class Vo{constructor(e,n,a){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=e,this.start=n,this.end=a}static range(e,n){return n?!e||!e.loc||!n.loc||e.loc.lexer!==n.loc.lexer?null:new Vo(e.loc.lexer,e.loc.start,n.loc.end):e&&e.loc}}class Us{constructor(e,n){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=e,this.loc=n}range(e,n){return new Us(n,Vo.range(this,e))}}class tn{constructor(e,n){this.name=void 0,this.position=void 0,this.length=void 0,this.rawMessage=void 0;var a="KaTeX parse error: "+e,r,i,A=n&&n.loc;if(A&&A.start<=A.end){var o=A.lexer.input;r=A.start,i=A.end,r===o.length?a+=" at end of input: ":a+=" at position "+(r+1)+": ";var s=o.slice(r,i).replace(/[^]/g,"$&̲"),l;r>15?l="…"+o.slice(r-15,r):l=o.slice(0,r);var d;i+15<o.length?d=o.slice(i,i+15)+"…":d=o.slice(i),a+=l+s+d}var u=new Error(a);return u.name="ParseError",u.__proto__=tn.prototype,u.position=r,r!=null&&i!=null&&(u.length=i-r),u.rawMessage=e,u}}tn.prototype.__proto__=Error.prototype;var ggt=function(e,n){return e===void 0?n:e},pgt=/([A-Z])/g,mgt=function(e){return e.replace(pgt,"-$1").toLowerCase()},hgt={"&":"&",">":">","<":"<",'"':""","'":"'"},fgt=/[&><"']/g;function bgt(t){return String(t).replace(fgt,e=>hgt[e])}var Fwe=function t(e){return e.type==="ordgroup"||e.type==="color"?e.body.length===1?t(e.body[0]):e:e.type==="font"?t(e.body):e},Cgt=function(e){var n=Fwe(e);return n.type==="mathord"||n.type==="textord"||n.type==="atom"},Egt=function(e){if(!e)throw new Error("Expected non-null, but got "+String(e));return e},Igt=function(e){var n=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(e);return n?n[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(n[1])?null:n[1].toLowerCase():"_relative"},er={deflt:ggt,escape:bgt,hyphenate:mgt,getBaseElem:Fwe,isCharacterBox:Cgt,protocolFromUrl:Igt},mQ={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:t=>"#"+t},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:(t,e)=>(e.push(t),e)},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:t=>Math.max(0,t),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:t=>Math.max(0,t),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:t=>Math.max(0,t),cli:"-e, --max-expand <n>",cliProcessor:t=>t==="Infinity"?1/0:parseInt(t)},globalGroup:{type:"boolean",cli:!1}};function Bgt(t){if(t.default)return t.default;var e=t.type,n=Array.isArray(e)?e[0]:e;if(typeof n!="string")return n.enum[0];switch(n){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{}}}class dY{constructor(e){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,e=e||{};for(var n in mQ)if(mQ.hasOwnProperty(n)){var a=mQ[n];this[n]=e[n]!==void 0?a.processor?a.processor(e[n]):e[n]:Bgt(a)}}reportNonstrict(e,n,a){var r=this.strict;if(typeof r=="function"&&(r=r(e,n,a)),!(!r||r==="ignore")){if(r===!0||r==="error")throw new tn("LaTeX-incompatible input and strict mode is set to 'error': "+(n+" ["+e+"]"),a);r==="warn"?typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(n+" ["+e+"]")):typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+r+"': "+n+" ["+e+"]"))}}useStrictBehavior(e,n,a){var r=this.strict;if(typeof r=="function")try{r=r(e,n,a)}catch{r="error"}return!r||r==="ignore"?!1:r===!0||r==="error"?!0:r==="warn"?(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(n+" ["+e+"]")),!1):(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+r+"': "+n+" ["+e+"]")),!1)}isTrusted(e){if(e.url&&!e.protocol){var n=er.protocolFromUrl(e.url);if(n==null)return!1;e.protocol=n}var a=typeof this.trust=="function"?this.trust(e):this.trust;return!!a}}class qg{constructor(e,n,a){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=n,this.cramped=a}sup(){return Ad[ygt[this.id]]}sub(){return Ad[Qgt[this.id]]}fracNum(){return Ad[wgt[this.id]]}fracDen(){return Ad[kgt[this.id]]}cramp(){return Ad[vgt[this.id]]}text(){return Ad[Dgt[this.id]]}isTight(){return this.size>=2}}var uY=0,a_=1,_C=2,Uu=3,Aw=4,vc=5,pE=6,vo=7,Ad=[new qg(uY,0,!1),new qg(a_,0,!0),new qg(_C,1,!1),new qg(Uu,1,!0),new qg(Aw,2,!1),new qg(vc,2,!0),new qg(pE,3,!1),new qg(vo,3,!0)],ygt=[Aw,vc,Aw,vc,pE,vo,pE,vo],Qgt=[vc,vc,vc,vc,vo,vo,vo,vo],wgt=[_C,Uu,Aw,vc,pE,vo,pE,vo],kgt=[Uu,Uu,vc,vc,vo,vo,vo,vo],vgt=[a_,a_,Uu,Uu,vc,vc,vo,vo],Dgt=[uY,a_,_C,Uu,_C,Uu,_C,Uu],zn={DISPLAY:Ad[uY],TEXT:Ad[_C],SCRIPT:Ad[Aw],SCRIPTSCRIPT:Ad[pE]},RP=[{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 xgt(t){for(var e=0;e<RP.length;e++)for(var n=RP[e],a=0;a<n.blocks.length;a++){var r=n.blocks[a];if(t>=r[0]&&t<=r[1])return n.name}return null}var Gx=[];RP.forEach(t=>t.blocks.forEach(e=>Gx.push(...e)));function Lwe(t){for(var e=0;e<Gx.length;e+=2)if(t>=Gx[e]&&t<=Gx[e+1])return!0;return!1}var Mb=80,Sgt=function(e,n){return"M95,"+(622+e+n)+`
|
|
1429
|
+
`;function ogt(t){return!t.archiveMode&&!t.isPlanDiffActive}function sgt(t,e){const n=e?.restore!==!1;return e?.sidebarTab?{sidebarOpen:!0,sidebarTab:e.sidebarTab,panelOpen:e.panelOpen}:{sidebarOpen:n?t?.sidebarIsOpen??!1:!1,sidebarTab:n&&t?.sidebarIsOpen?t.sidebarTab:null,panelOpen:e?.panelOpen??(n?t?.panelOpen??!1:void 0)}}function cgt({blocks:t,annotations:e,addAnnotation:n,removeAnnotation:a}){const[r,i]=J.useState(new Map),A=J.useRef(t);A.current=t;const o=J.useRef(e);o.current=e,J.useEffect(()=>{if(r.size===0)return;const d=new Set(t.map(g=>g.id)),u=[...r.keys()].filter(g=>!d.has(g));u.length>0&&i(g=>{const p=new Map(g);return u.forEach(m=>p.delete(m)),p})},[t]);const s=J.useCallback((d,u)=>{const g=A.current,p=o.current,m=g.find(b=>b.id===d);if(m&&u===m.checked)i(C=>{const I=new Map(C);return I.delete(d),I}),p.filter(C=>C.blockId===d&&C.id.startsWith("ann-checkbox-")).forEach(C=>a(C.id));else if(p.filter(C=>C.blockId===d&&C.id.startsWith("ann-checkbox-")).forEach(C=>a(C.id)),i(C=>{const I=new Map(C);return I.set(d,u),I}),m){const C=g.indexOf(m);let I="";for(let _=C-1;_>=0;_--)if(g[_].type==="heading"){I=g[_].content;break}const B=u?"Mark as completed":"Mark as not completed",w=I?` (under "${I}")`:` (line ${m.startLine})`,k={id:`ann-checkbox-${d}-${Date.now()}`,blockId:d,startOffset:0,endOffset:m.content.length,type:Ba.COMMENT,text:`${B}${w}: ${m.content}`,originalText:m.content,createdA:Date.now()};n(k)}},[n,a]),l=J.useCallback(d=>{i(u=>{const g=new Map(u);return g.delete(d),g})},[]);return{overrides:r,toggle:s,revertOverride:l}}const lgt=Agt,dgt=()=>{const[t,e]=J.useState(lgt),[n,a]=J.useState([]),[r,i]=J.useState([]),[A,o]=J.useState(null),[s,l]=J.useState(null),[d,u]=J.useState([]),[g,p]=J.useState(null),[m,f]=J.useState(!1),[b,C]=J.useState(!1),[I,B]=J.useState(!1),[w,k]=J.useState(!1),[_,D]=J.useState(!1),[x,S]=J.useState("close"),[F,M]=J.useState(!1),[O,K]=J.useState(""),[R,G]=J.useState(()=>window.innerWidth>=768),[T,L]=J.useState(!1),[U,H]=J.useState(Frt),[q,P]=J.useState(Grt),[j,Z]=J.useState(()=>zt.getItem("plannotator-tater-mode")==="true"),[$,X]=J.useState(()=>nP()),ce=J.useRef(null),[te,he]=J.useState("full");J.useLayoutEffect(()=>{const Ke=ce.current;if(!Ke)return;const Pt=ln=>ln>=800?"full":ln>=680?"short":"icon";he(Pt(Ke.getBoundingClientRect().width));const jt=new ResizeObserver(([ln])=>{const ma=Pt(ln.contentRect.width);he(Ha=>Ha===ma?Ha:ma)});return jt.observe(Ke),()=>jt.disconnect()},[]);const[ae,se]=J.useState(!1),[oe,Ae]=J.useState(null),[pe,le]=J.useState(),[ke,me]=J.useState(!1),[He,ie]=J.useState([]),[Ze,ve]=J.useState(!1),[at,rt]=J.useState(!1),[ct,Oe]=J.useState(null),[st,qe]=J.useState(),[ze,At]=J.useState(!1),[_e,et]=J.useState(),[fe,De]=J.useState(void 0),[V,ye]=J.useState(!0),[Ce,Ne]=J.useState(!1),[Me,Ue]=J.useState(!1),[Ee,xe]=J.useState(null),[We,nt]=J.useState(null),[ht,Qe]=J.useState(!1),[Ye,Ge]=J.useState("bypassPermissions"),[ot,Ft]=J.useState(!0),[Nt,re]=J.useState(void 0),[pt,dt]=J.useState(void 0),[_t,St]=J.useState(null),[Ot,gt]=J.useState(null),[ft,Vt]=J.useState(null),Yt=J.useRef(null),rn=J.useRef($.tocEnabled);J.useEffect(()=>{document.title=_t?`${_t.display} · Plannotator`:"Plannotator"},[_t]);const[Fn,vn]=J.useState(),[hn,fn]=J.useState(null),[Gn,Et]=J.useState(!1),[be,$e]=J.useState("clean"),[vt,pn]=J.useState(null),[Sn,an]=J.useState(null),qn=UIe(),oa=J.useRef(null),{ref:pa,viewport:Gt,onViewportReady:It}=Yrt();Hrt();const Lt=cre({storageKey:"plannotator-panel-width"}),Mt=cre({storageKey:"plannotator-toc-width",defaultWidth:240,minWidth:160,maxWidth:400,side:"left"}),xt=Lt.isDragging||Mt.isDragging,qt=ait(nP().tocEnabled),Le=J.useMemo(()=>d.some(Ke=>Ke.type==="heading"&&(Ke.level??0)<=3),[d]),va=J.useCallback(Ke=>{if(ft===null){Ke?.sidebarTab&&qt.open(Ke.sidebarTab),Ke?.panelOpen===!0?G(!0):Ke?.panelOpen===!1&&G(!1);return}const Pt=Yt.current,jt=sgt(Pt,Ke);Vt(null),Yt.current=null,jt.sidebarOpen&&jt.sidebarTab?qt.open(jt.sidebarTab):qt.close(),jt.panelOpen!==void 0&&G(jt.panelOpen)},[ft,qt.close,qt.open]),Te=J.useCallback(Ke=>{if(ft!==null){va({restore:!1,sidebarTab:Ke,panelOpen:!1});return}qt.open(Ke)},[va,ft,qt.open]),Kn=J.useCallback(Ke=>{if(ft!==null){va({restore:!1,sidebarTab:Ke,panelOpen:!1});return}qt.toggleTab(Ke)},[va,ft,qt.toggleTab]),Ko=J.useCallback(()=>{if(ft!==null){va({restore:!1,panelOpen:!0});return}G(Ke=>!Ke)},[va,ft]);J.useEffect(()=>{ft===null&&rn.current!==$.tocEnabled&&(rn.current=$.tocEnabled,$.tocEnabled&&Le?qt.open("toc"):$.tocEnabled||qt.close())},[ft,qt.close,qt.open,$.tocEnabled,Le]),J.useEffect(()=>{d.length!==0&&(Le||qt.activeTab==="toc"&&qt.isOpen&&qt.close())},[d,Le]),J.useEffect(()=>{qt.activeTab==="toc"&&Gn&&Et(!1)},[qt.activeTab]),J.useEffect(()=>{if(!Gn)return;const Ke=Pt=>{Pt.key==="Escape"&&Et(!1)};return document.addEventListener("keydown",Ke),()=>document.removeEventListener("keydown",Ke)},[Gn]);const Ga=Kit(t,vt,Sn),go=J.useMemo(()=>({...qt,open:Te,toggleTab:Kn}),[Te,qt.activeTab,qt.close,qt.isOpen,Kn]),wn=Hit({markdown:t,annotations:n,selectedAnnotationId:A,globalAttachments:He,setMarkdown:e,setAnnotations:a,setSelectedAnnotationId:o,setGlobalAttachments:ie,viewerRef:oa,sidebar:go,sourceFilePath:_e,sourceConverted:ze}),sr=J.useMemo(()=>wn.filepath?wn.filepath.replace(/\/[^/]+$/,""):fe?.includes("/")?fe:void 0,[wn.filepath,fe]),Ja=Yit({buildUrl:J.useCallback(Ke=>sr?`/api/doc?path=${encodeURIComponent(Ke)}&base=${encodeURIComponent(sr)}`:`/api/doc?path=${encodeURIComponent(Ke)}`,[sr])}),Ia=Wit({markdown:t,viewerRef:oa,linkedDocHook:wn,setMarkdown:e,setAnnotations:a,setSelectedAnnotationId:o,setSubmitted:xe}),yi=J.useMemo(()=>ogt({archiveMode:Ia.archiveMode,isPlanDiffActive:Gn}),[Ia.archiveMode,Gn]),po=J.useCallback(Ke=>{yi&&(ft===null&&(Yt.current={sidebarIsOpen:qt.isOpen,sidebarTab:qt.activeTab,panelOpen:R}),Vt(Ke),qt.close(),G(!1))},[yi,R,ft,qt.activeTab,qt.close,qt.isOpen]),Rr=J.useCallback(Ke=>{ft===Ke?va():po(Ke)},[po,va,ft]);J.useEffect(()=>{!yi&&ft!==null&&va()},[yi,va,ft]);const fa=aAt(),Wa=J.useMemo(()=>Rae()?cp(sp()):"",[$]),Cn=J.useMemo(()=>!!Ot||tre()||Rae(),[Ot,$]),_n=J.useMemo(()=>{const Ke=Ot?[Ot]:[],Pt=tre()?YH().directories:[];return[...new Set([...Ke,...Pt])]},[Ot,$]);J.useEffect(()=>{Cn||fa.setActiveFile(null)},[Cn]),J.useEffect(()=>{Wa||fa.clearVaultDirs()},[Wa]),J.useEffect(()=>{if(qt.activeTab==="files"&&Cn){if(_n.length>0){const Ke=fa.dirs.filter(jt=>!jt.isVault).map(jt=>jt.path);(_n.some(jt=>!Ke.includes(jt))||Ke.some(jt=>!_n.includes(jt)))&&fa.fetchAll(_n)}Wa&&!fa.dirs.find(Ke=>Ke.isVault&&Ke.path===Wa&&!Ke.error)&&fa.addVaultDir(Wa)}},[qt.activeTab,Cn,_n,Wa]);const rr=or.useCallback((Ke,Pt)=>{const ln=fa.dirs.find(ma=>ma.path===Pt)?.isVault?ma=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(Pt)}&path=${encodeURIComponent(ma)}`:ma=>`/api/doc?path=${encodeURIComponent(ma)}&base=${encodeURIComponent(Pt)}`;wn.open(Ke,ln,"files"),fa.setActiveFile(Ke)},[wn,fa]),la=or.useCallback(Ke=>{if(fa.dirs.find(jt=>jt.path===fa.activeDirPath)?.isVault&&fa.activeDirPath)wn.open(Ke,jt=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(fa.activeDirPath)}&path=${encodeURIComponent(jt)}`);else if(fa.activeFile&&fa.activeDirPath){const jt=wn.filepath?.replace(/\/[^/]+$/,"")||fa.activeDirPath;wn.open(Ke,ln=>`/api/doc?path=${encodeURIComponent(ln)}&base=${encodeURIComponent(jt)}`)}else{const jt=wn.filepath?wn.filepath.replace(/\/[^/]+$/,""):fe?.includes("/")?fe:void 0;jt?wn.open(Ke,ln=>`/api/doc?path=${encodeURIComponent(ln)}&base=${encodeURIComponent(jt)}`):wn.open(Ke)}},[fa.dirs,fa.activeDirPath,fa.activeFile,wn,fe]),li=or.useCallback(()=>{wn.back(),fa.setActiveFile(null),Ia.clearSelection()},[wn,fa,Ia]),Ka=J.useMemo(()=>{const Ke=new Map;for(const[Pt,jt]of wn.getDocAnnotations()){const ln=jt.annotations.length+jt.globalAttachments.length;ln>0&&Ke.set(Pt,ln)}return Ke},[wn.getDocAnnotations,n,He]),mA=J.useMemo(()=>{const Ke=fa.dirs.map(jt=>jt.path);if(Ke.length===0)return Ka;const Pt=new Map;for(const[jt,ln]of Ka)Ke.some(ma=>jt.startsWith(ma+"/"))&&Pt.set(jt,ln);return Pt},[Ka,fa.dirs]),di=mA.size>0,$t=J.useMemo(()=>{const Ke=wn.filepath;let Pt=0,jt=0;for(const[ln,ma]of Ka)ln!==Ke&&(Pt+=ma,jt++);return Pt>0?{count:Pt,files:jt}:void 0},[Ka,wn.filepath]),[z,ee]=J.useState(),ge=or.useRef(),we=or.useCallback(()=>{const Ke=new Set(Ka.keys());Ke.size!==0&&((!qt.isOpen||qt.activeTab!=="files")&&Te("files"),ge.current&&clearTimeout(ge.current),ee(void 0),requestAnimationFrame(()=>{ee(Ke),ge.current=setTimeout(()=>ee(void 0),1200)}))},[Ka,Te,qt,di]),Pe=ct==="folder"?"file list":ct==="file"?"file":ct==="message"?"message":"plan",tt=J.useMemo(()=>d.filter(Ke=>Ke.type==="heading").length,[d]),bt=yrt(pa,tt,Gt),{editorAnnotations:Bt,deleteEditorAnnotation:An}=Vit(),{externalAnnotations:On,updateExternalAnnotation:Wn,deleteExternalAnnotation:ua}=eAt({enabled:ae}),{reset:ca}=tAt({viewerRef:oa,externalAnnotations:On,enabled:ae&&!wn.isActive&&!Gn,planKey:t}),on=J.useMemo(()=>On.length===0?n:[...n.filter(Pt=>Pt.source?!On.some(jt=>jt.source===Pt.source&&jt.type===Pt.type&&jt.originalText===Pt.originalText):!0),...On],[n,On]),Hn=J.useMemo(()=>on.filter(Ke=>!!Ke.diffContext),[on]),Ir=J.useMemo(()=>on.filter(Ke=>!Ke.diffContext),[on]),ui=J.useMemo(()=>on.length>0||r.length>0||Bt.length>0||wn.docAnnotationCount>0||He.length>0,[on.length,r.length,Bt.length,wn.docAnnotationCount,He.length]),Wi=on.length+r.length+Bt.length+wn.docAnnotationCount+He.length,ir=ot&&r.length===0,{isSharedSession:vr,isLoadingShared:Ho,shareUrl:Ur,shareUrlSize:Ll,shortShareUrl:ai,isGeneratingShortUrl:pI,shortUrlError:Em,pendingSharedAnnotations:Hd,clearPendingSharedAnnotations:mI,generateShortUrl:VN,importFromShareUrl:XN,shareLoadError:P0,clearShareLoadError:hI}=Ert(t,on,He,e,a,ie,()=>{ye(!1)},Nt,pt),{draftBanner:Im,restoreDraft:K0,dismissDraft:$N}=Jit({annotations:on,codeAnnotations:r,globalAttachments:He,isApiMode:ae,isSharedSession:vr,submitted:!!Ee}),eM=or.useCallback(()=>{const{annotations:Ke,codeAnnotations:Pt,globalAttachments:jt}=K0();(Ke.length>0||Pt.length>0||jt.length>0)&&(a(Ke),i(Pt),jt.length>0&&ie(jt),setTimeout(()=>{oa.current?.applySharedAnnotations(Ke.filter(ln=>!ln.diffContext))},100))},[K0]),{agents:H0,getAgentWarning:Bm}=Kye(oe);J.useEffect(()=>{if(Hd&&Hd.length>0){const Ke=setTimeout(()=>{oa.current?.clearAllHighlights(),oa.current?.applySharedAnnotations(Hd.filter(Pt=>!Pt.diffContext)),mI(),ca()},100);return()=>clearTimeout(Ke)}},[Hd,mI,ca]);const tM=Ke=>{Z(Ke),zt.setItem("plannotator-tater-mode",String(Ke))},Y0=Ke=>{H(Ke),Lrt(Ke)},fI=Ke=>{P(Ke),Ort(Ke)};Krt(q,fI),J.useEffect(()=>{Ho||vr||fetch("/api/plan").then(Ke=>{if(!Ke.ok)throw new Error("Not in API mode");return Ke.json()}).then(Ke=>{fi.init(Ke.serverConfig),le(Ke.serverConfig?.gitUser),Ke.mode==="archive"?(e(Ke.plan||""),Ke.archivePlans&&Ia.init(Ke.archivePlans),Ia.fetchPlans(),Ft(!1),qt.open("archive")):Ke.mode==="annotate-folder"?e(""):Ke.plan&&e(Ke.plan),se(!0),(Ke.mode==="annotate"||Ke.mode==="annotate-last"||Ke.mode==="annotate-folder")&&(ve(!0),rt(Ke.gate??!1)),Ke.mode==="annotate-folder"&&qt.open("files"),Ke.mode&&Ke.mode!=="archive"&&Oe(Ke.mode==="annotate-last"?"message":Ke.mode==="annotate-folder"?"folder":"file"),qe(Ke.sourceInfo??void 0),At(!!Ke.sourceConverted),Ke.filePath&&(De(Ke.mode==="annotate-folder"?Ke.filePath:Ke.filePath.replace(/\/[^/]+$/,"")),Ke.mode==="annotate"&&et(Ke.filePath)),Ke.sharingEnabled!==void 0&&Ft(Ke.sharingEnabled),Ke.shareBaseUrl&&re(Ke.shareBaseUrl),Ke.pasteApiUrl&&dt(Ke.pasteApiUrl),Ke.repoInfo&&St(Ke.repoInfo),Ke.projectRoot&>(Ke.projectRoot),Ke.previousPlan!==void 0&&pn(Ke.previousPlan),Ke.versionInfo&&an(Ke.versionInfo),Ke.origin&&(Ae(Ke.origin),Ke.origin==="claude-code"&&Mat()&&Qe(!0),Ge(Gye().mode)),Ke.isWSL&&me(!0)}).catch(()=>{se(!1)}).finally(()=>ye(!1))},[Ho,vr]),J.useEffect(()=>{const{frontmatter:Ke}=ige(t);p(Ke),u(wQ(t))},[t]);const bI=J.useRef(!1),hg=J.useRef({}),Kf=J.useRef(null);J.useEffect(()=>{bI.current=!1,hg.current={},Kf.current=null},[t]),J.useEffect(()=>{if(!ae||!t||vr||Ze||Ia.archiveMode||bI.current)return;const Ke={},Pt=[],jt=sp();if(jt.autoSave&&jt.enabled){const Pr=cp(jt);Pr&&(Ke.obsidian={vaultPath:Pr,folder:jt.folder||"plannotator",plan:t,...jt.filenameFormat&&{filenameFormat:jt.filenameFormat},...jt.filenameSeparator&&jt.filenameSeparator!=="space"&&{filenameSeparator:jt.filenameSeparator}},Pt.push("Obsidian"))}const ln=lh();ln.autoSave&&ln.enabled&&(Ke.bear={plan:t,customTags:ln.customTags,tagPosition:ln.tagPosition},Pt.push("Bear"));const ma=wC();if(ma.autoSave&&Ov()&&(Ke.octarine={plan:t,workspace:ma.workspace,folder:ma.folder||"plannotator"},Pt.push("Octarine")),Pt.length===0)return;bI.current=!0;const Ha=fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ke)}).then(Pr=>Pr.json()).then(Pr=>{const hA={...Ke.obsidian?{obsidian:!!Pr.results?.obsidian?.success}:{},...Ke.bear?{bear:!!Pr.results?.bear?.success}:{},...Ke.octarine?{octarine:!!Pr.results?.octarine?.success}:{}};hg.current=hA;const Ig=Pt.filter(gi=>!Pr.results?.[gi.toLowerCase()]?.success);return Ig.length===0?fn({type:"success",message:`Auto-saved to ${Pt.join(" & ")}`}):fn({type:"error",message:`Auto-save failed for ${Ig.join(" & ")}`}),hA}).catch(()=>(hg.current={},fn({type:"error",message:"Auto-save failed"}),{})).finally(()=>setTimeout(()=>fn(null),3e3));Kf.current=Ha},[ae,t,vr,Ze]),J.useEffect(()=>{const Ke=Pt=>{const jt=Pt.clipboardData?.items;if(jt){for(const ln of jt)if(ln.type.startsWith("image/")){Pt.preventDefault();const ma=ln.getAsFile();if(ma){const Ha=DU(ma.name,He.map(hA=>hA.name)),Pr=URL.createObjectURL(ma);nt({file:ma,blobUrl:Pr,initialName:Ha})}break}}};return document.addEventListener("paste",Ke),()=>document.removeEventListener("paste",Ke)},[He]);const nM=async(Ke,Pt,jt)=>{if(We)try{const ln=new FormData,ma=Pt?new File([Ke],"annotated.png",{type:"image/png"}):We.file;ln.append("file",ma);const Ha=await fetch("/api/upload",{method:"POST",body:ln});if(Ha.ok){const Pr=await Ha.json();ie(hA=>[...hA,{path:Pr.path,name:jt}])}}catch{}finally{URL.revokeObjectURL(We.blobUrl),nt(null)}},aM=()=>{We&&(URL.revokeObjectURL(We.blobUrl),nt(null))},fg=async()=>{Ne(!0);try{const Ke=sp(),Pt=lh(),jt=wC(),ln=US(),ma=Pt.autoSave&&Kf.current?await Kf.current:hg.current,Ha={};oe==="claude-code"&&(Ha.permissionMode=Ye);const Pr=Sat(IR());Pr&&(Ha.agentSwitch=Pr),Ha.planSave={enabled:ln.enabled,...ln.customPath&&{customPath:ln.customPath}};const hA=cp(Ke);Ke.enabled&&hA&&(Ha.obsidian={vaultPath:hA,folder:Ke.folder||"plannotator",plan:t,...Ke.filenameFormat&&{filenameFormat:Ke.filenameFormat},...Ke.filenameSeparator&&Ke.filenameSeparator!=="space"&&{filenameSeparator:Ke.filenameSeparator}}),Pt.enabled&&!(Pt.autoSave&&ma.bear)&&(Ha.bear={plan:t,customTags:Pt.customTags,tagPosition:Pt.tagPosition}),Ov()&&(Ha.octarine={plan:t,workspace:jt.workspace,folder:jt.folder||"plannotator"});const Ig=Array.from(wn.getDocAnnotations().values()).some(gi=>gi.annotations.length>0||gi.globalAttachments.length>0);(on.length>0||r.length>0||He.length>0||Ig||Bt.length>0)&&(Ha.feedback=Yd),await fetch("/api/approve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ha)}),xe("approved")}catch{Ne(!1)}},q0=async()=>{Ne(!0);try{const Ke=US();await fetch("/api/deny",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:Yd,planSave:{enabled:Ke.enabled,...Ke.customPath&&{customPath:Ke.customPath}}})}),xe("denied")}catch{Ne(!1)}},j0=async()=>{Ne(!0);try{await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:Yd,annotations:on,codeAnnotations:r})}),xe("denied")}catch{Ne(!1)}},CI=async()=>{Ne(!0);try{await fetch("/api/approve",{method:"POST"}),xe("approved")}catch{Ne(!1)}},z0=J.useCallback(async()=>{Ue(!0);try{if((await fetch("/api/exit",{method:"POST"})).ok)xe("exited");else throw new Error("Failed to exit")}catch{Ue(!1)}},[]);J.useEffect(()=>{const Ke=Pt=>{if(Pt.key!=="Enter"||!(Pt.metaKey||Pt.ctrlKey))return;const jt=Pt.target?.tagName;if(jt==="INPUT"||jt==="TEXTAREA"||m||b||I||w||_||F||ht||We||Ee||Ce||Me||!ae||wn.isActive)return;if(Pt.preventDefault(),Ze){if(at&&!ui){CI();return}j0();return}const ln=wn.getDocAnnotations(),ma=Array.from(ln.values()).some(Ha=>Ha.annotations.length>0||Ha.globalAttachments.length>0);if(on.length===0&&r.length===0&&Bt.length===0&&!ma){if(oe==="opencode"){const Ha=Bm();if(Ha){K(Ha),M(!0);return}}fg()}else q0()};return window.addEventListener("keydown",Ke),()=>window.removeEventListener("keydown",Ke)},[m,b,I,w,_,F,ht,We,Ee,Ce,Me,ae,wn.isActive,n.length,r.length,On.length,Ze,at,ui,oe,Bm]);const EI=Ke=>{a(Pt=>[...Pt,Ke]),o(Ke.id),l(null),ft===null&&G(!0)},II=or.useCallback(Ke=>{o(Ke),Ke&&l(null),Ke&&qn&&ft===null&&G(!0)},[qn,ft]),rM=or.useCallback(Ke=>{const Pt={id:rAt("code-ann"),type:"comment",scope:"line",filePath:Ke.filePath,lineStart:Ke.lineStart,lineEnd:Ke.lineEnd,side:"new",text:Ke.text,images:Ke.images,originalCode:Ke.originalCode,createdAt:Date.now(),author:fi.get("displayName")||void 0};i(jt=>[...jt,Pt]),o(null),l(Pt.id),ft===null&&G(!0)},[ft]),iM=or.useCallback(Ke=>{const Pt=r.find(jt=>jt.id===Ke);Pt&&(o(null),l(Ke),Ja.open(Pt.filePath),qn&&ft===null&&G(!0))},[r,Ja.open,qn,ft]),J0=or.useCallback(Ke=>{i(Pt=>Pt.filter(jt=>jt.id!==Ke)),s===Ke&&l(null)},[s]),Hf=or.useCallback((Ke,Pt)=>{i(jt=>jt.map(ln=>ln.id===Ke?{...ln,...Pt}:ln))},[]),bg=Ke=>{oa.current?.removeHighlight(Ke),a(Pt=>Pt.filter(jt=>jt.id!==Ke)),A===Ke&&o(null)},BI=cgt({blocks:d,annotations:n,addAnnotation:EI,removeAnnotation:bg}),W0=Ke=>{const Pt=on.find(jt=>jt.id===Ke);if(Pt?.source&&On.some(jt=>jt.id===Ke)){ua(Ke),A===Ke&&o(null);return}Ke.startsWith("ann-checkbox-")&&Pt&&BI.revertOverride(Pt.blockId),bg(Ke)},Z0=(Ke,Pt)=>{if(on.find(ln=>ln.id===Ke)?.source&&On.some(ln=>ln.id===Ke)){Wn(Ke,Pt);return}a(ln=>ln.map(ma=>ma.id===Ke?{...ma,...Pt}:ma))},V0=(Ke,Pt)=>{a(jt=>jt.map(ln=>ln.author===Ke?{...ln,author:Pt}:ln)),i(jt=>jt.map(ln=>ln.author===Ke?{...ln,author:Pt}:ln))},X0=Ke=>{ie(Pt=>[...Pt,Ke])},$0=Ke=>{ie(Pt=>Pt.filter(jt=>jt.path!==Ke))},Cg=Ke=>{},Yd=J.useMemo(()=>{const Ke=wn.getDocAnnotations(),Pt=Array.from(Ke.values()).some(hA=>hA.annotations.length>0||hA.globalAttachments.length>0),jt=on.length>0||He.length>0,ln=Bt.length>0,ma=r.length>0;if(!jt&&!Pt&&!ln&&!ma)return"User reviewed the document and has no feedback.";const Ha=wn.isActive?Ke.get(wn.filepath??"")?.isConverted??!1:ze;let Pr=jt?JNe(d,on,He,ct==="message"?"Message Feedback":ct==="folder"?"Folder Feedback":ct==="file"?"File Feedback":"Plan Feedback",ct??"plan",{sourceConverted:Ha}):"";if(Pt){const hA=new Map(Ke);for(const[Ig,gi]of hA)gi.markdown&&hA.set(Ig,{...gi,blocks:wQ(gi.markdown)});Pr+=WNe(hA)}return ln&&(Pr+=ZNe(Bt)),ma&&(Pr+=VNe(r)),Pr},[d,on,He,wn.getDocAnnotations,Bt,r,ze,ct,wn.isActive,wn.filepath]),Yf=or.useMemo(()=>Irt(),[]),qf=or.useCallback(async Ke=>{if(!(!Yf||Ce||!Ur)){Ne(!0);try{const Pt=await Brt(Ke,Yf,Ur);Pt&&(fn(Pt),setTimeout(()=>fn(null),4e3),Pt.type==="success"&&xe(Ke===Rx.Approve?"approved":"denied"))}finally{Ne(!1)}}},[Yf,Ce,Ur]),ek=or.useCallback(()=>qf(Rx.Approve),[qf]),tk=or.useCallback(()=>qf(Rx.Feedback),[qf]),Eg=()=>{const Ke=new Blob([Yd],{type:"text/plain"}),Pt=URL.createObjectURL(Ke),jt=document.createElement("a");jt.href=Pt,jt.download="annotations.md",jt.click(),URL.revokeObjectURL(Pt),fn({type:"success",message:"Downloaded annotations"}),setTimeout(()=>fn(null),3e3)},tc=async Ke=>{const Pt={};if(Ke==="obsidian"){const ln=sp(),ma=cp(ln);ma&&(Pt.obsidian={vaultPath:ma,folder:ln.folder||"plannotator",plan:t,...ln.filenameFormat&&{filenameFormat:ln.filenameFormat},...ln.filenameSeparator&&ln.filenameSeparator!=="space"&&{filenameSeparator:ln.filenameSeparator}})}if(Ke==="bear"){const ln=lh();Pt.bear={plan:t,customTags:ln.customTags,tagPosition:ln.tagPosition}}if(Ke==="octarine"){const ln=wC();Pt.octarine={plan:t,workspace:ln.workspace,folder:ln.folder||"plannotator"}}const jt=Ke==="obsidian"?"Obsidian":Ke==="bear"?"Bear":"Octarine";try{const Ha=(await(await fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Pt)})).json()).results?.[Ke];Ha?.success?fn({type:"success",message:`Saved to ${jt}`}):fn({type:"error",message:Ha?.error||"Save failed"})}catch{fn({type:"error",message:"Save failed"})}setTimeout(()=>fn(null),3e3)},AM=async()=>{const Ke=nAt(window.location.origin);try{await navigator.clipboard.writeText(Ke),fn({type:"success",message:"Agent instructions copied"})}catch{fn({type:"error",message:"Failed to copy"})}setTimeout(()=>fn(null),3e3)},jf=async()=>{try{await navigator.clipboard.writeText(Ur),fn({type:"success",message:"Share link copied"})}catch{fn({type:"error",message:"Failed to copy"})}setTimeout(()=>fn(null),3e3)};J.useEffect(()=>{const Ke=Pt=>{if(Pt.key!=="s"||!(Pt.metaKey||Pt.ctrlKey))return;const jt=Pt.target?.tagName;if(jt==="INPUT"||jt==="TEXTAREA"||m||I||w||_||F||ht||We||Ee||!ae)return;Pt.preventDefault();const ln=Pye(),ma=_ae(),Ha=lh().enabled,Pr=Ov();ln==="download"?Eg():ln==="obsidian"&&ma?tc("obsidian"):ln==="bear"&&Ha?tc("bear"):ln==="octarine"&&Pr?tc("octarine"):(vn("notes"),f(!0))};return window.addEventListener("keydown",Ke),()=>window.removeEventListener("keydown",Ke)},[m,I,w,_,F,ht,We,Ee,ae,t,Yd]),J.useEffect(()=>{const Ke=Pt=>{if(Pt.key!=="p"||!(Pt.metaKey||Pt.ctrlKey))return;const jt=Pt.target?.tagName;jt==="INPUT"||jt==="TEXTAREA"||m||I||w||_||F||ht||We||Ee||(Pt.preventDefault(),window.print())};return window.addEventListener("keydown",Ke),()=>window.removeEventListener("keydown",Ke)},[m,I,w,_,F,ht,We,Ee]);const qc=J.useMemo(()=>HNe(oe),[oe]),yI=J.useMemo(()=>({compact:832,default:1040,wide:1280})[$.planWidth]??832,[$.planWidth]),Tl=yi&&ft==="wide"?null:yI;return y.jsx(Itt,{defaultTheme:"dark",children:y.jsx(cat,{delayDuration:900,skipDelayDuration:200,disableHoverableContent:!0,children:y.jsxs("div",{"data-print-region":"root",className:"h-screen flex flex-col bg-background overflow-hidden",children:[y.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:[y.jsx("div",{className:"flex items-center gap-2 md:gap-3",children:y.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:y.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Plannotator"})})}),y.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[Yf&&!ae&&vr&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"}),y.jsx(n8,{onClick:tk,disabled:Ce||!Ur,isLoading:Ce,title:"Send feedback to bot"}),y.jsx(nre,{onClick:ek,disabled:Ce||!Ur,isLoading:Ce,title:"Approve design and notify bot"})]}),ae&&!wn.isActive&&Ia.archiveMode&&y.jsxs(y.Fragment,{children:[y.jsxs("button",{onClick:Ia.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:[y.jsx("span",{className:"hidden md:inline",children:"Copy"}),y.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})})]}),y.jsx("button",{onClick:Ia.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"})]}),ae&&(!wn.isActive||Ze)&&!Ia.archiveMode&&y.jsxs(y.Fragment,{children:[Ze?y.jsxs(y.Fragment,{children:[y.jsx(lrt,{onClick:()=>{ui?(S("close"),D(!0)):z0()},disabled:Ce||Me,isLoading:Me}),ui&&y.jsx(n8,{onClick:j0,disabled:Ce||Me,isLoading:Ce,label:"Send Annotations",title:"Send Annotations"})]}):y.jsx(n8,{onClick:()=>{const Ke=wn.getDocAnnotations(),Pt=Array.from(Ke.values()).some(jt=>jt.annotations.length>0||jt.globalAttachments.length>0);on.length===0&&r.length===0&&Bt.length===0&&!Pt?B(!0):q0()},disabled:Ce,isLoading:Ce,label:"Send Feedback",title:"Send Feedback"}),(!Ze||at)&&(oe==="opencode"&&!Ze&&H0.length>0?y.jsx(grt,{onApprove:()=>{const Ke=Bm();if(Ke){K(Ke),M(!0);return}fg()},agents:H0,disabled:Ce,isLoading:Ce}):y.jsxs("div",{className:"relative group/approve",children:[y.jsx(nre,{onClick:()=>{if(Ze){if(ui){S("approve"),D(!0);return}CI();return}if(oe==="claude-code"&&(on.length>0||r.length>0)){k(!0);return}if(oe==="opencode"){const Ke=Bm();if(Ke){K(Ke),M(!0);return}}fg()},disabled:Ce||Ze&&Me,isLoading:Ce,dimmed:!Ze&&(oe==="claude-code"||oe==="gemini-cli")&&(on.length>0||r.length>0),title:Ze?"Approve — no changes requested":void 0}),!Ze&&(oe==="claude-code"||oe==="gemini-cli")&&(on.length>0||r.length>0)&&y.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:[y.jsx("div",{className:"absolute bottom-full right-4 border-4 border-transparent border-b-border"}),y.jsx("div",{className:"absolute bottom-full right-4 mt-px border-4 border-transparent border-b-popover"}),qc," doesn't support feedback on approval. Your annotations won't be seen."]})]})),y.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"})]}),y.jsx("button",{onClick:Ko,className:`p-1.5 rounded-md text-xs font-medium transition-all ${R?"bg-primary/15 text-primary":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:R?"Hide annotations":"Show annotations",children:y.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:y.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"})})}),y.jsx("div",{className:"hidden",children:y.jsx(crt,{taterMode:j,onTaterModeChange:tM,onIdentityChange:V0,origin:oe,onUIPreferencesChange:X,externalOpen:T,onExternalClose:()=>L(!1),gitUser:pe})}),y.jsx(zrt,{appVersion:"0.19.11",onOpenSettings:()=>{L(!0)},onOpenExport:()=>{vn(void 0),f(!0)},onCopyAgentInstructions:AM,onDownloadAnnotations:Eg,onPrint:()=>window.print(),onCopyShareLink:jf,onOpenImport:()=>C(!0),onSaveToObsidian:()=>tc("obsidian"),onSaveToBear:()=>tc("bear"),onSaveToOctarine:()=>tc("octarine"),sharingEnabled:ir,isApiMode:ae,agentInstructionsEnabled:ae&&!Ia.archiveMode&&!Ze,obsidianConfigured:_ae(),bearConfigured:lh().enabled,octarineConfigured:Ov()})]})]}),wn.error&&y.jsxs("div",{className:"bg-destructive/10 border-b border-destructive/20 px-4 py-2 flex items-center gap-2 flex-shrink-0",children:[y.jsx("span",{className:"text-xs text-destructive",children:wn.error}),y.jsx("button",{onClick:wn.dismissError,className:"ml-auto text-xs text-destructive/60 hover:text-destructive",children:"dismiss"})]}),y.jsx(OIe.Provider,{value:Gt,children:y.jsxs("div",{"data-print-region":"content",className:`flex-1 flex overflow-hidden relative z-0 ${xt?"select-none":""}`,children:[j&&y.jsx(Qat,{}),ft===null&&!qt.isOpen&&y.jsx(iAt,{activeTab:qt.activeTab,onToggleTab:Kn,hasDiff:Ga.hasPreviousVersion,showVersionsTab:Sn!==null&&Sn.totalVersions>1,showFilesTab:Cn&&!Ia.archiveMode,hasFileAnnotations:di,className:"hidden lg:flex absolute left-0 top-0 z-10"}),qt.isOpen&&y.jsxs(y.Fragment,{children:[y.jsx(fAt,{activeTab:qt.activeTab,onTabChange:Ke=>{Kn(Ke),Ke==="archive"&&!Ia.archiveMode&&Ia.fetchPlans()},onClose:qt.close,width:Mt.width,blocks:d,annotations:n,activeSection:bt,onTocNavigate:Cg,linkedDocFilepath:wn.filepath,onLinkedDocBack:wn.isActive?li:void 0,backLabel:Pe,showFilesTab:Cn&&!Ia.archiveMode,fileAnnotationCounts:mA,highlightedFiles:z,fileBrowser:fa,onFilesSelectFile:rr,onFilesFetchAll:()=>fa.fetchAll(_n),onFilesRetryVaultDir:Ke=>fa.addVaultDir(Ke),hasFileAnnotations:di,showVersionsTab:Sn!==null&&Sn.totalVersions>1,versionInfo:Sn,versions:Ga.versions,selectedBaseVersion:Ga.diffBaseVersion,onSelectBaseVersion:Ga.selectBaseVersion,isPlanDiffActive:Gn,hasPreviousVersion:Ga.hasPreviousVersion,onActivatePlanDiff:()=>Et(!0),isLoadingVersions:Ga.isLoadingVersions,isSelectingVersion:Ga.isSelectingVersion,fetchingVersion:Ga.fetchingVersion,onFetchVersions:Ga.fetchVersions,showArchiveTab:ae&&!Ze,archivePlans:Ia.plans,selectedArchiveFile:Ia.selectedFile,onArchiveSelect:Ia.select,isLoadingArchive:Ia.isLoading}),y.jsx(lre,{...Mt.handleProps,className:"hidden lg:block",side:"left"})]}),y.jsxs(Zw,{element:"main",className:`flex-1 min-w-0 bg-grid ${!qt.isOpen&&ft===null?"lg:pl-[30px]":""}`,"data-print-region":"document",onViewportReady:It,children:[y.jsx(xb,{isOpen:!!Im,onClose:$N,onConfirm:eM,title:"Draft Recovered",message:Im?`Found ${Im.count} annotation${Im.count!==1?"s":""} from ${Im.timeAgo}. Would you like to restore them?`:"",confirmText:"Restore",cancelText:"Dismiss",showCancel:!0}),y.jsxs("div",{ref:ce,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:[!Gn&&!Ia.archiveMode&&$.stickyActionsEnabled&&y.jsx(Cat,{inputMethod:q,onInputMethodChange:fI,mode:U,onModeChange:Y0,taterMode:j,repoInfo:_t,planDiffStats:Ga.diffStats,isPlanDiffActive:Gn,hasPreviousVersion:Ga.hasPreviousVersion,onPlanDiffToggle:()=>Et(!Gn),archiveInfo:Ia.currentInfo,maxWidth:Tl,remountToken:wn.isActive?`doc:${wn.filepath}`:"plan"}),!Gn&&!Ia.archiveMode&&y.jsx("div",{"data-print-hide":!0,className:"w-full mb-3 md:mb-4 flex items-center justify-start",style:Tl==null?void 0:{maxWidth:Tl},children:y.jsx(kye,{inputMethod:q,onInputMethodChange:fI,mode:U,onModeChange:Y0,taterMode:j})}),Ga.diffBlocks&&Ga.diffStats&&y.jsx("div",{className:"w-full flex justify-center",style:{display:Gn?void 0:"none"},children:y.jsx(SAt,{diffBlocks:Ga.diffBlocks,diffStats:Ga.diffStats,diffMode:be,onDiffModeChange:$e,onPlanDiffToggle:()=>Et(!1),repoInfo:_t,baseVersionLabel:Ga.diffBaseVersion!=null?`v${Ga.diffBaseVersion}`:void 0,baseVersion:Ga.diffBaseVersion??void 0,maxWidth:yI,annotations:Hn,onAddAnnotation:EI,onSelectAnnotation:II,selectedAnnotationId:A,mode:U})}),ct==="folder"&&!t&&!wn.isActive&&y.jsx("div",{className:"w-full flex justify-center",children:y.jsxs("div",{className:"w-full max-w-3xl p-12 text-center text-muted-foreground",children:[y.jsx("p",{className:"text-lg font-medium mb-2",children:"Select a file to annotate"}),y.jsx("p",{className:"text-sm",children:"Pick a markdown file from the sidebar to begin."})]})}),y.jsxs("div",{className:"w-full flex justify-center relative",style:{display:Gn&&Ga.diffBlocks||ct==="folder"&&!t&&!wn.isActive?"none":void 0},children:[yi&&!Gn&&!Ia.archiveMode&&y.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:Tl===null?void 0:{maxWidth:Tl??832},children:y.jsx("div",{className:`pointer-events-auto flex items-center gap-1.5 text-[11px] tracking-wide ${j?"mr-[60px]":"mr-[4px]"}`,children:["wide","focus"].map((Ke,Pt)=>y.jsxs(or.Fragment,{children:[Pt>0&&y.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/30 select-none",children:"|"}),y.jsx(lat,{side:"top",align:"end",content:Ke==="wide"?"Hide panels and expand document width":"Hide panels, keep document width",children:y.jsx("button",{type:"button",onClick:()=>Rr(Ke),"aria-pressed":ft===Ke,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 ${ft===Ke?"text-foreground":"text-muted-foreground/50 hover:text-muted-foreground"}`,children:Ke.charAt(0).toUpperCase()+Ke.slice(1)})})]},Ke))})}),y.jsx(Z$e,{ref:oa,blocks:d,markdown:t,frontmatter:g,annotations:Ir,onAddAnnotation:EI,onSelectAnnotation:II,selectedAnnotationId:A,mode:U,inputMethod:q,taterMode:j,globalAttachments:He,onAddGlobalAttachment:X0,onRemoveGlobalAttachment:$0,repoInfo:_t,stickyActions:$.stickyActionsEnabled,planDiffStats:wn.isActive?null:Ga.diffStats,isPlanDiffActive:Gn,onPlanDiffToggle:()=>Et(!Gn),hasPreviousVersion:!wn.isActive&&Ga.hasPreviousVersion,showDemoBadge:!ae&&!Ho&&!vr,maxWidth:Tl,onOpenLinkedDoc:la,onOpenCodeFile:Ja.open,linkedDocInfo:wn.isActive?{filepath:wn.filepath,onBack:li,label:fa.dirs.find(Ke=>Ke.path===fa.activeDirPath)?.isVault?"Vault File":fa.activeFile?"File":void 0,backLabel:Pe}:null,imageBaseDir:fe,codePathBaseDir:sr,copyLabel:ct==="message"?"Copy message":ct==="file"||ct==="folder"?"Copy file":void 0,archiveInfo:Ia.currentInfo,sourceInfo:st,onToggleCheckbox:BI.toggle,checkboxOverrides:BI.overrides,actionsLabelMode:te},wn.isActive?`doc:${wn.filepath}`:"plan")]})]})]}),R&&ft===null&&y.jsx(lre,{...Lt.handleProps,className:"hidden md:block",side:"right"}),y.jsx(dtt,{isOpen:R&&ft===null,blocks:d,annotations:on,selectedId:A??s,onSelect:II,onDelete:W0,onEdit:Z0,codeAnnotations:r,onSelectCodeAnnotation:iM,onDeleteCodeAnnotation:J0,onEditCodeAnnotation:Hf,sharingEnabled:ir,width:Lt.width,editorAnnotations:Bt,onDeleteEditorAnnotation:An,onClose:()=>G(!1),onQuickCopy:async()=>{await navigator.clipboard.writeText(oge(Yd))},onShare:ir&&Ur?()=>{G(!1),vn("share"),f(!0)}:void 0,otherFileAnnotations:$t,onOtherFileAnnotationsClick:we})]})}),Ja.popoutProps&&y.jsx(igt,{...Ja.popoutProps,annotations:r.filter(Ke=>Ke.filePath===Ja.popoutProps?.filepath),selectedAnnotationId:s,onAddAnnotation:rM,onEditAnnotation:Hf,onDeleteAnnotation:J0,onSelectAnnotation:Ke=>{o(null),l(Ke)}}),y.jsx(Ctt,{isOpen:m,onClose:()=>{f(!1),vn(void 0)},shareUrl:Ur,shareUrlSize:Ll,shortShareUrl:ai,isGeneratingShortUrl:pI,shortUrlError:Em,onGenerateShortUrl:VN,annotationsOutput:Yd,annotationCount:on.length+r.length,taterSprite:j?y.jsx(KH,{}):void 0,sharingEnabled:ir,markdown:t,isApiMode:ae,initialTab:Fn}),y.jsx(Ett,{isOpen:b,onClose:()=>C(!1),onImport:XN,shareBaseUrl:Nt}),y.jsx(xb,{isOpen:I,onClose:()=>B(!1),title:"Add Annotations First",message:`To provide feedback, select text in the plan and add annotations. ${qc} will use your annotations to revise the plan.`,variant:"info"}),y.jsx(xb,{isOpen:w,onClose:()=>k(!1),onConfirm:()=>{k(!1),fg()},title:"Annotations Won't Be Sent",message:y.jsxs(y.Fragment,{children:[qc," doesn't yet support feedback on approval. Your ",on.length+r.length," annotation",on.length+r.length!==1?"s":""," will be lost."]}),subMessage:y.jsxs(y.Fragment,{children:["To send feedback, use ",y.jsx("strong",{children:"Send Feedback"})," instead.",y.jsx("br",{}),y.jsx("br",{}),"Want this feature? Upvote these issues:",y.jsx("br",{}),y.jsx("a",{href:"https://github.com/anthropics/claude-code/issues/16001",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"#16001"})," · ",y.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}),y.jsx(xb,{isOpen:_,onClose:()=>D(!1),onConfirm:()=>{D(!1),x==="approve"?CI():z0()},title:"Annotations Won't Be Sent",message:y.jsxs(y.Fragment,{children:["You have ",Wi," annotation",Wi!==1?"s":""," that will be lost if you ",x==="approve"?"approve":"close","."]}),subMessage:"To send your annotations, use Send Annotations instead.",confirmText:x==="approve"?"Approve Anyway":"Close Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),y.jsx(xb,{isOpen:F,onClose:()=>M(!1),onConfirm:()=>{M(!1),fg()},title:"Agent Not Found",message:O,subMessage:y.jsxs(y.Fragment,{children:["You can change the agent in ",y.jsx("strong",{children:"Settings"}),", or approve anyway and OpenCode will use the default agent."]}),confirmText:"Approve Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),y.jsx(xb,{isOpen:!!P0&&!ae,onClose:hI,title:"Shared Plan Could Not Be Loaded",message:P0,subMessage:"You are viewing a demo plan. This is sample content — it is not your data or anyone else's.",variant:"warning"}),hn&&y.jsx("div",{className:`fixed top-16 right-4 z-50 px-3 py-2 rounded-lg text-xs font-medium shadow-lg transition-opacity ${hn.type==="success"?"bg-success/15 text-success border border-success/30":"bg-destructive/15 text-destructive border border-destructive/30"}`,children:hn.message}),y.jsx(vrt,{submitted:Ee,title:Ia.archiveMode?"Archive Closed":Ee==="exited"?"Session Closed":Ee==="approved"?Ze?"Approved":"Plan Approved":Ze?"Annotations Sent":"Feedback Sent",subtitle:Ee==="exited"?"Annotation session closed without feedback.":Ia.archiveMode?"You can reopen with plannotator archive.":Ee==="approved"?Ze?`${qc} will proceed.`:`${qc} will proceed with the implementation.`:Ze?`${qc} will address your annotations on the ${ct==="message"?"message":ct==="folder"?"files":"file"}.`:`${qc} will revise the plan based on your annotations.`,agentLabel:qc}),y.jsx(Nrt,{origin:oe,isWSL:ke}),y.jsx(Spe,{isOpen:!!We,imageSrc:We?.blobUrl??"",initialName:We?.initialName,onAccept:nM,onClose:aM}),y.jsx(nit,{isOpen:ht,onComplete:Ke=>{Ge(Ke),Qe(!1)}})]})})})},Mwe=document.getElementById("root");if(!Mwe)throw new Error("Could not find root element to mount to");const ugt=KNe.createRoot(Mwe);ugt.render(y.jsx(or.StrictMode,{children:y.jsx(dgt,{})}));class Vo{constructor(e,n,a){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=e,this.start=n,this.end=a}static range(e,n){return n?!e||!e.loc||!n.loc||e.loc.lexer!==n.loc.lexer?null:new Vo(e.loc.lexer,e.loc.start,n.loc.end):e&&e.loc}}class Us{constructor(e,n){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=e,this.loc=n}range(e,n){return new Us(n,Vo.range(this,e))}}class tn{constructor(e,n){this.name=void 0,this.position=void 0,this.length=void 0,this.rawMessage=void 0;var a="KaTeX parse error: "+e,r,i,A=n&&n.loc;if(A&&A.start<=A.end){var o=A.lexer.input;r=A.start,i=A.end,r===o.length?a+=" at end of input: ":a+=" at position "+(r+1)+": ";var s=o.slice(r,i).replace(/[^]/g,"$&̲"),l;r>15?l="…"+o.slice(r-15,r):l=o.slice(0,r);var d;i+15<o.length?d=o.slice(i,i+15)+"…":d=o.slice(i),a+=l+s+d}var u=new Error(a);return u.name="ParseError",u.__proto__=tn.prototype,u.position=r,r!=null&&i!=null&&(u.length=i-r),u.rawMessage=e,u}}tn.prototype.__proto__=Error.prototype;var ggt=function(e,n){return e===void 0?n:e},pgt=/([A-Z])/g,mgt=function(e){return e.replace(pgt,"-$1").toLowerCase()},hgt={"&":"&",">":">","<":"<",'"':""","'":"'"},fgt=/[&><"']/g;function bgt(t){return String(t).replace(fgt,e=>hgt[e])}var Fwe=function t(e){return e.type==="ordgroup"||e.type==="color"?e.body.length===1?t(e.body[0]):e:e.type==="font"?t(e.body):e},Cgt=function(e){var n=Fwe(e);return n.type==="mathord"||n.type==="textord"||n.type==="atom"},Egt=function(e){if(!e)throw new Error("Expected non-null, but got "+String(e));return e},Igt=function(e){var n=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(e);return n?n[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(n[1])?null:n[1].toLowerCase():"_relative"},er={deflt:ggt,escape:bgt,hyphenate:mgt,getBaseElem:Fwe,isCharacterBox:Cgt,protocolFromUrl:Igt},mQ={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:t=>"#"+t},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:(t,e)=>(e.push(t),e)},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:t=>Math.max(0,t),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:t=>Math.max(0,t),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:t=>Math.max(0,t),cli:"-e, --max-expand <n>",cliProcessor:t=>t==="Infinity"?1/0:parseInt(t)},globalGroup:{type:"boolean",cli:!1}};function Bgt(t){if(t.default)return t.default;var e=t.type,n=Array.isArray(e)?e[0]:e;if(typeof n!="string")return n.enum[0];switch(n){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{}}}class dY{constructor(e){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,e=e||{};for(var n in mQ)if(mQ.hasOwnProperty(n)){var a=mQ[n];this[n]=e[n]!==void 0?a.processor?a.processor(e[n]):e[n]:Bgt(a)}}reportNonstrict(e,n,a){var r=this.strict;if(typeof r=="function"&&(r=r(e,n,a)),!(!r||r==="ignore")){if(r===!0||r==="error")throw new tn("LaTeX-incompatible input and strict mode is set to 'error': "+(n+" ["+e+"]"),a);r==="warn"?typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(n+" ["+e+"]")):typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+r+"': "+n+" ["+e+"]"))}}useStrictBehavior(e,n,a){var r=this.strict;if(typeof r=="function")try{r=r(e,n,a)}catch{r="error"}return!r||r==="ignore"?!1:r===!0||r==="error"?!0:r==="warn"?(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(n+" ["+e+"]")),!1):(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+r+"': "+n+" ["+e+"]")),!1)}isTrusted(e){if(e.url&&!e.protocol){var n=er.protocolFromUrl(e.url);if(n==null)return!1;e.protocol=n}var a=typeof this.trust=="function"?this.trust(e):this.trust;return!!a}}class qg{constructor(e,n,a){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=n,this.cramped=a}sup(){return Ad[ygt[this.id]]}sub(){return Ad[Qgt[this.id]]}fracNum(){return Ad[wgt[this.id]]}fracDen(){return Ad[kgt[this.id]]}cramp(){return Ad[vgt[this.id]]}text(){return Ad[Dgt[this.id]]}isTight(){return this.size>=2}}var uY=0,a_=1,_C=2,Uu=3,Aw=4,vc=5,pE=6,vo=7,Ad=[new qg(uY,0,!1),new qg(a_,0,!0),new qg(_C,1,!1),new qg(Uu,1,!0),new qg(Aw,2,!1),new qg(vc,2,!0),new qg(pE,3,!1),new qg(vo,3,!0)],ygt=[Aw,vc,Aw,vc,pE,vo,pE,vo],Qgt=[vc,vc,vc,vc,vo,vo,vo,vo],wgt=[_C,Uu,Aw,vc,pE,vo,pE,vo],kgt=[Uu,Uu,vc,vc,vo,vo,vo,vo],vgt=[a_,a_,Uu,Uu,vc,vc,vo,vo],Dgt=[uY,a_,_C,Uu,_C,Uu,_C,Uu],zn={DISPLAY:Ad[uY],TEXT:Ad[_C],SCRIPT:Ad[Aw],SCRIPTSCRIPT:Ad[pE]},RP=[{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 xgt(t){for(var e=0;e<RP.length;e++)for(var n=RP[e],a=0;a<n.blocks.length;a++){var r=n.blocks[a];if(t>=r[0]&&t<=r[1])return n.name}return null}var Gx=[];RP.forEach(t=>t.blocks.forEach(e=>Gx.push(...e)));function Lwe(t){for(var e=0;e<Gx.length;e+=2)if(t>=Gx[e]&&t<=Gx[e+1])return!0;return!1}var Mb=80,Sgt=function(e,n){return"M95,"+(622+e+n)+`
|
|
1430
1430
|
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
|
|
1431
1431
|
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
|
|
1432
1432
|
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
|