@plannotator/opencode 0.16.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -25931,8 +25931,9 @@ function createExternalAnnotationHandler(mode) {
25931
25931
  }
25932
25932
  });
25933
25933
  return {
25934
- async handle(req, url) {
25934
+ async handle(req, url, options) {
25935
25935
  if (url.pathname === STREAM && req.method === "GET") {
25936
+ options?.disableIdleTimeout?.();
25936
25937
  let heartbeatTimer = null;
25937
25938
  let ctrl;
25938
25939
  const stream = new ReadableStream({
@@ -26083,7 +26084,7 @@ async function startPlannotatorServer(options) {
26083
26084
  try {
26084
26085
  server = Bun.serve({
26085
26086
  port: configuredPort,
26086
- async fetch(req) {
26087
+ async fetch(req, server2) {
26087
26088
  const url = new URL(req.url);
26088
26089
  if (url.pathname === "/api/plan/version") {
26089
26090
  const vParam = url.searchParams.get("v");
@@ -26213,7 +26214,9 @@ async function startPlannotatorServer(options) {
26213
26214
  const editorResponse = await editorAnnotations?.handle(req, url);
26214
26215
  if (editorResponse)
26215
26216
  return editorResponse;
26216
- const externalResponse = await externalAnnotations?.handle(req, url);
26217
+ const externalResponse = await externalAnnotations?.handle(req, url, {
26218
+ disableIdleTimeout: () => server2.timeout(req, 0)
26219
+ });
26217
26220
  if (externalResponse)
26218
26221
  return externalResponse;
26219
26222
  if (url.pathname === "/api/save-notes" && req.method === "POST") {
@@ -27846,7 +27849,7 @@ async function startReviewServer(options) {
27846
27849
  try {
27847
27850
  server2 = Bun.serve({
27848
27851
  port: configuredPort,
27849
- async fetch(req) {
27852
+ async fetch(req, server3) {
27850
27853
  const url = new URL(req.url);
27851
27854
  if (url.pathname === "/api/diff" && req.method === "GET") {
27852
27855
  return Response.json({
@@ -27998,7 +28001,9 @@ async function startReviewServer(options) {
27998
28001
  const editorResponse = await editorAnnotations.handle(req, url);
27999
28002
  if (editorResponse)
28000
28003
  return editorResponse;
28001
- const externalResponse = await externalAnnotations.handle(req, url);
28004
+ const externalResponse = await externalAnnotations.handle(req, url, {
28005
+ disableIdleTimeout: () => server3.timeout(req, 0)
28006
+ });
28002
28007
  if (externalResponse)
28003
28008
  return externalResponse;
28004
28009
  if (url.pathname === "/api/feedback" && req.method === "POST") {
@@ -28137,7 +28142,7 @@ async function startAnnotateServer(options) {
28137
28142
  try {
28138
28143
  server2 = Bun.serve({
28139
28144
  port: configuredPort,
28140
- async fetch(req) {
28145
+ async fetch(req, server3) {
28141
28146
  const url = new URL(req.url);
28142
28147
  if (url.pathname === "/api/plan" && req.method === "GET") {
28143
28148
  return Response.json({
@@ -28193,7 +28198,9 @@ async function startAnnotateServer(options) {
28193
28198
  return handleDraftDelete(draftKey);
28194
28199
  return handleDraftLoad(draftKey);
28195
28200
  }
28196
- const externalResponse = await externalAnnotations.handle(req, url);
28201
+ const externalResponse = await externalAnnotations.handle(req, url, {
28202
+ disableIdleTimeout: () => server3.timeout(req, 0)
28203
+ });
28197
28204
  if (externalResponse)
28198
28205
  return externalResponse;
28199
28206
  if (url.pathname === "/api/feedback" && req.method === "POST") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plannotator/opencode",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "Plannotator plugin for OpenCode - interactive plan review with visual annotation",
5
5
  "author": "backnotprop",
6
6
  "license": "MIT OR Apache-2.0",
@@ -38,7 +38,7 @@
38
38
  "@opencode-ai/plugin": "^1.1.10"
39
39
  },
40
40
  "devDependencies": {
41
- "@plannotator/server": "0.16.0",
41
+ "@plannotator/server": "0.16.1",
42
42
  "@plannotator/shared": "0.0.1"
43
43
  },
44
44
  "peerDependencies": {
package/plannotator.html CHANGED
@@ -497,7 +497,7 @@ created: ${new Date().toISOString().slice(0,19)}Z
497
497
  source: plannotator
498
498
  tags: [plan, ...]
499
499
  ---`})]}),w.jsx("div",{className:"border-t border-border/30"}),w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Obsidian when a plan loads, before you approve or deny"})]}),w.jsx("button",{role:"switch","aria-checked":Q.autoSave,onClick:()=>ae({autoSave:!Q.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${Q.autoSave?"bg-primary":"bg-muted"}`,children:w.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${Q.autoSave?"translate-x-6":"translate-x-1"}`})})]}),w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-xs font-medium",children:"Vault Browser"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Browse and annotate vault files from the sidebar"})]}),w.jsx("button",{role:"switch","aria-checked":Q.vaultBrowserEnabled,onClick:()=>ae({vaultBrowserEnabled:!Q.vaultBrowserEnabled}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${Q.vaultBrowserEnabled?"bg-primary":"bg-muted"}`,children:w.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${Q.vaultBrowserEnabled?"translate-x-6":"translate-x-1"}`})})]})]})]})]}),C==="bear"&&w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-sm font-medium",children:"Bear Notes"}),w.jsx("div",{className:"text-xs text-muted-foreground",children:"Auto-save approved plans to Bear"})]}),w.jsx("button",{role:"switch","aria-checked":x.enabled,onClick:()=>NA({enabled:!x.enabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${x.enabled?"bg-primary":"bg-muted"}`,children:w.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${x.enabled?"translate-x-6":"translate-x-1"}`})})]}),x.enabled&&w.jsxs("div",{className:"mt-3 space-y-3",children:[w.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[w.jsx("label",{className:"text-xs text-muted-foreground",children:"Custom Tags"}),w.jsx("input",{type:"text",value:x.customTags,onChange:dA=>NA({customTags:dA.target.value}),onBlur:dA=>NA({customTags:$OA(dA.target.value)}),placeholder:"plan, work",className:"w-full px-3 py-2 bg-muted rounded-lg text-xs font-mono placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary/50"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Comma-separated, kebab-case. Leave empty for auto-generated tags."})]}),w.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[w.jsx("label",{className:"text-xs text-muted-foreground",children:"Tag Position"}),w.jsxs("select",{value:x.tagPosition,onChange:dA=>NA({tagPosition:dA.target.value}),className:"w-full px-3 py-2 bg-muted rounded-lg text-xs focus:outline-none focus:ring-1 focus:ring-primary/50",children:[w.jsx("option",{value:"append",children:"Append (end of note)"}),w.jsx("option",{value:"prepend",children:"Prepend (after title)"})]})]}),w.jsx("div",{className:"border-t border-border/30"}),w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Bear when a plan loads, before you approve or deny"})]}),w.jsx("button",{role:"switch","aria-checked":x.autoSave,onClick:()=>NA({autoSave:!x.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${x.autoSave?"bg-primary":"bg-muted"}`,children:w.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${x.autoSave?"translate-x-6":"translate-x-1"}`})})]})]})]}),C==="octarine"&&w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-sm font-medium",children:"Octarine"}),w.jsx("div",{className:"text-xs text-muted-foreground",children:"Auto-save approved plans to Octarine"})]}),w.jsx("button",{role:"switch","aria-checked":b.enabled,onClick:()=>XA({enabled:!b.enabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${b.enabled?"bg-primary":"bg-muted"}`,children:w.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${b.enabled?"translate-x-6":"translate-x-1"}`})})]}),b.enabled&&w.jsxs("div",{className:"mt-3 space-y-3",children:[w.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[w.jsx("label",{className:"text-xs text-muted-foreground",children:"Workspace Name"}),w.jsx("input",{type:"text",value:b.workspace,onChange:dA=>XA({workspace:dA.target.value}),placeholder:"My Workspace",className:"w-full px-3 py-2 bg-muted rounded-lg text-xs font-mono placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary/50"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"The Octarine workspace name to save plans into."})]}),w.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[w.jsx("label",{className:"text-xs text-muted-foreground",children:"Folder"}),w.jsx("input",{type:"text",value:b.folder,onChange:dA=>XA({folder:dA.target.value}),placeholder:"plannotator",className:"w-full px-3 py-2 bg-muted rounded-lg text-xs font-mono placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary/50"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Subfolder within the workspace for saved plans."})]}),w.jsxs("div",{className:"text-[10px] text-muted-foreground/70",children:["Plans saved to: ",b.workspace||"..."," / ",b.folder||"plannotator","/"]}),w.jsx("div",{className:"border-t border-border/30"}),w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsxs("div",{children:[w.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),w.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Octarine when a plan loads, before you approve or deny"})]}),w.jsx("button",{role:"switch","aria-checked":b.autoSave,onClick:()=>XA({autoSave:!b.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${b.autoSave?"bg-primary":"bg-muted"}`,children:w.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${b.autoSave?"translate-x-6":"translate-x-1"}`})})]})]})]})]})]})]})}),document.body)]})},jq=({onClick:e,disabled:A=!1,isLoading:t=!1,label:i="Send Feedback",loadingLabel:r="Sending...",title:n="Send Feedback",muted:a=!1})=>w.jsxs("button",{onClick:e,disabled:A,className:`p-1.5 md:px-2.5 md:py-1 rounded-md text-xs font-medium transition-all ${a?"opacity-50 cursor-not-allowed bg-accent/10 text-accent/50":A?"opacity-50 cursor-not-allowed bg-muted text-muted-foreground":"bg-accent/15 text-accent hover:bg-accent/25 border border-accent/30"}`,title:n,children:[w.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),w.jsx("span",{className:"hidden md:inline",children:t?r:i})]}),_q=({onClick:e,disabled:A=!1,isLoading:t=!1,label:i="Approve",loadingLabel:r="Approving...",mobileLabel:n="OK",mobileLoadingLabel:a="...",title:s,dimmed:o=!1,muted:g=!1})=>w.jsxs("button",{onClick:e,disabled:A,className:`px-2 py-1 md:px-2.5 rounded-md text-xs font-medium transition-all ${g?"opacity-40 cursor-not-allowed bg-muted text-muted-foreground":A?"opacity-50 cursor-not-allowed bg-muted text-muted-foreground":o?"bg-success/50 text-success-foreground/70 hover:bg-success hover:text-success-foreground":"bg-success text-success-foreground hover:opacity-90"}`,title:s,children:[w.jsx("span",{className:"md:hidden",children:t?a:n}),w.jsx("span",{className:"hidden md:inline",children:t?r:i})]});async function OoA(e){const A=JSON.stringify(e),t=new TextEncoder().encode(A),i=new CompressionStream("deflate-raw"),r=i.writable.getWriter();r.write(t),r.close();const n=await new Response(i.readable).arrayBuffer(),a=new Uint8Array(n);let s="";for(let g=0;g<a.length;g++)s+=String.fromCharCode(a[g]);return btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async function av(e){const A=e.replace(/-/g,"+").replace(/_/g,"/"),t=atob(A),i=Uint8Array.from(t,o=>o.charCodeAt(0)),r=new DecompressionStream("deflate-raw"),n=r.writable.getWriter();n.write(i),n.close();const a=await new Response(r.readable).arrayBuffer(),s=new TextDecoder().decode(a);return JSON.parse(s)}async function _UA(e){const A=await crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt"]),t=crypto.getRandomValues(new Uint8Array(12)),i=new TextEncoder().encode(e),r=await crypto.subtle.encrypt({name:"AES-GCM",iv:t},A,i),n=new Uint8Array(t.length+r.byteLength);n.set(t,0),n.set(new Uint8Array(r),t.length);const a=await crypto.subtle.exportKey("raw",A);return{ciphertext:Xq(n),key:Xq(new Uint8Array(a))}}async function XUA(e,A){const t=$q(e),i=$q(A),r=t.slice(0,12),n=t.slice(12),a=await crypto.subtle.importKey("raw",i.buffer,{name:"AES-GCM",length:256},!1,["decrypt"]),s=await crypto.subtle.decrypt({name:"AES-GCM",iv:r},a,n);return new TextDecoder().decode(s)}function Xq(e){let A="";for(let t=0;t<e.length;t++)A+=String.fromCharCode(e[t]);return btoa(A).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function $q(e){const A=e.replace(/-/g,"+").replace(/_/g,"/"),t=atob(A);return Uint8Array.from(t,i=>i.charCodeAt(0))}function vB(e){if(e?.length)return e.map(A=>{if(typeof A=="string"){const t=A.split("/").pop()?.replace(/\.[^.]+$/,"")||"image";return{path:A,name:t}}return{path:A[0],name:A[1]}})}function c4(e){if(e?.length)return e.map(A=>[A.path,A.name])}function UoA(e){return e.map(A=>{const t=A.author||null,i=c4(A.images);return A.type===li.GLOBAL_COMMENT?["G",A.text||"",t,i]:A.type===li.DELETION?["D",A.originalText,t,i]:A.isQuickLabel?["C",A.originalText,A.text||"",t,i??void 0,1]:["C",A.originalText,A.text||"",t,i]})}function uD(e,A,t){const i={D:li.DELETION,C:li.COMMENT,G:li.GLOBAL_COMMENT};return e.map((r,n)=>{const a=r[0];if(a==="G"){const C=r[1],E=r[2],B=r[3];return{id:`shared-${n}-${Date.now()}`,blockId:"",startOffset:0,endOffset:0,type:li.GLOBAL_COMMENT,text:C||void 0,originalText:"",createdA:Date.now()+n,author:E||void 0,images:vB(B),...t?.[n]?{source:t[n]}:{}}}const s=r[1],o=a==="D"?void 0:r[2],g=a==="D"?r[2]:r[3],l=a==="D"?r[3]:r[4],I=a==="C"&&r.length>5&&r[5]===1?!0:void 0;return{id:`shared-${n}-${Date.now()}`,blockId:"",startOffset:0,endOffset:0,type:i[a],text:o||void 0,originalText:s,createdA:Date.now()+n,author:g||void 0,images:vB(l),...I?{isQuickLabel:I}:{},...A?.[n]?{diffContext:A[n]}:{},...t?.[n]?{source:t[n]}:{}}})}function KoA(e){const A=e.map(t=>t.diffContext||null);return A.some(t=>t!==null)?A:null}function YoA(e){const A=e.map(t=>t.source||void 0);return A.some(t=>t!==void 0)?A:null}async function $UA(e,A,t,i=PoA){const r=KoA(A),n=YoA(A),a={p:e,a:UoA(A),g:t?.length?c4(t):void 0,...r?{d:r}:{},...n?{s:n}:{}},s=await OoA(a);return`${i}/#${s}`}async function A4A(){const A=window.location.hash.slice(1).split("?")[0];if(!A)return null;try{return await av(A)}catch(t){return console.warn("Failed to parse share hash:",t),null}}function e4A(e){const A=new Blob([e]).size;return A<1024?`${A} B`:`${(A/1024).toFixed(1)} KB`}const HoA="https://plannotator-paste.plannotator.workers.dev",PoA="https://share.plannotator.ai";async function t4A(e,A,t,i){const r=i?.pasteApiUrl??HoA,n=i?.shareBaseUrl??PoA;try{const a=KoA(A),s=YoA(A),o={p:e,a:UoA(A),g:t?.length?c4(t):void 0,...a?{d:a}:{},...s?{s}:{}},g=await OoA(o),{ciphertext:l,key:I}=await _UA(g),C=await fetch(`${r}/api/paste`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:l}),signal:AbortSignal.timeout(5e3)});if(!C.ok)return console.warn(`[sharing] Paste service returned ${C.status}`),null;const E=await C.json();return{shortUrl:`${n}/p/${E.id}#key=${I}`,id:E.id}}catch(a){return console.debug("[sharing] Short URL service unavailable, using hash-based sharing:",a),null}}async function AW(e,A=HoA,t){try{const i=await fetch(`${A}/api/paste/${e}`,{signal:AbortSignal.timeout(1e4)});if(!i.ok)return console.warn(`[sharing] Paste fetch returned ${i.status} for id ${e}`),null;const r=await i.json();if(t){const n=await XUA(r.data,t);return await av(n)}return await av(r.data)}catch(i){return console.warn("[sharing] Failed to load from paste ID:",i),null}}function i4A(e,A,t,i,r,n,a,s,o){const[g,l]=cA.useState(!1),[I,C]=cA.useState(!0),[E,B]=cA.useState(""),[h,Q]=cA.useState(""),[f,m]=cA.useState(""),[y,v]=cA.useState(!1),[S,x]=cA.useState(""),[R,b]=cA.useState(null),[N,F]=cA.useState(null),[L,K]=cA.useState(""),H=cA.useCallback(()=>{b(null),F(null)},[]),k=cA.useCallback(()=>K(""),[]),U=cA.useCallback(async()=>{try{const P=window.location.pathname.match(/^\/p\/([A-Za-z0-9]{6,16})$/);if(P){const V=P[1],j=window.location.hash.slice(1),AA=j.startsWith("key=")?j.slice(4):void 0,X=await AW(V,o,AA);if(X){i(X.p);const sA=uD(X.a,X.d,X.s);if(r(sA),X.g?.length){const hA=vB(X.g)??[];n(hA),F(hA)}b(sA),l(!0),a?.();const nA=window.location.pathname.replace(/\/p\/[A-Za-z0-9]+$/,"")||"/";return window.history.replaceState({},"",nA),!0}return K("Failed to load shared plan — the link may be expired or incomplete."),!1}const q=window.location.hash.slice(1),Y=await A4A();if(Y){i(Y.p);const V=uD(Y.a,Y.d,Y.s);if(r(V),Y.g?.length){const j=vB(Y.g)??[];n(j),F(j)}return b(V),l(!0),a?.(),window.history.replaceState({},"",window.location.pathname),!0}return q&&K("Failed to load shared plan — the URL may have been truncated by your browser."),!1}catch(P){return console.error("Failed to load from share hash:",P),K("Failed to load shared plan — an unexpected error occurred."),!1}},[i,r,n,a,o]);cA.useEffect(()=>{U().finally(()=>C(!1))},[]),cA.useEffect(()=>{const P=()=>{window.location.hash.length>1&&U()};return window.addEventListener("hashchange",P),()=>window.removeEventListener("hashchange",P)},[U]);const O=cA.useCallback(async()=>{try{const P=await $UA(e,A,t,s);B(P),Q(e4A(P))}catch(P){console.error("Failed to generate share URL:",P),B(""),Q("")}},[e,A,t,s]);cA.useEffect(()=>{O()},[O]),cA.useEffect(()=>{m(""),x("")},[e,A]);const T=cA.useCallback(async()=>{if(e){v(!0),x("");try{const P=await t4A(e,A,t,{pasteApiUrl:o,shareBaseUrl:s});P?m(P.shortUrl):(m(""),x("Short URL service unavailable"))}catch{m(""),x("Failed to generate short URL")}finally{v(!1)}}},[e,A,t,s,o]),G=cA.useCallback(async P=>{try{let q;const Y=P.match(/\/p\/([A-Za-z0-9]{6,16})(?:#key=([A-Za-z0-9_-]+))?(?:\?|#|$)/);if(Y){const nA=Y[1],hA=Y[2],rA=await AW(nA,o,hA);if(!rA)return{success:!1,count:0,planTitle:"",error:"Failed to load from short URL — paste may have expired"};q=rA}else{const nA=P.indexOf("#");if(nA===-1)return{success:!1,count:0,planTitle:"",error:"Invalid share URL: no hash fragment or short link found"};const hA=P.slice(nA+1);if(!hA)return{success:!1,count:0,planTitle:"",error:"Invalid share URL: empty hash"};q=await av(hA)}const j=(q.p||"").trim().split(`
500
- `).find(nA=>nA.startsWith("#")),AA=j?j.replace(/^#+\s*/,"").trim():"Unknown Plan",X=uD(q.a,q.d,q.s);if(X.length===0)return{success:!0,count:0,planTitle:AA,error:"No annotations found in share link"};const sA=X.filter(nA=>!A.some(hA=>hA.originalText===nA.originalText&&hA.type===nA.type&&hA.text===nA.text));if(sA.length>0&&(r(nA=>{const hA=X.filter(oA=>!nA.some(gA=>gA.originalText===oA.originalText&&gA.type===oA.type&&gA.text===oA.text));if(hA.length===0)return nA;const rA=[...nA,...hA];return b(rA),rA}),q.g?.length)){const nA=vB(q.g)??[];n(hA=>{const rA=new Set(hA.map(gA=>gA.path)),oA=nA.filter(gA=>!rA.has(gA.path));return oA.length>0?[...hA,...oA]:hA}),F(nA)}return{success:!0,count:sA.length,planTitle:AA}}catch(q){return{success:!1,count:0,planTitle:"",error:q instanceof Error?q.message:"Failed to decompress share URL"}}},[A,t,r,n,o]);return{isSharedSession:g,isLoadingShared:I,shareUrl:E,shareUrlSize:h,shortShareUrl:f,isGeneratingShortUrl:y,shortUrlError:S,pendingSharedAnnotations:R,sharedGlobalAttachments:N,clearPendingSharedAnnotations:H,refreshShareUrl:O,generateShortUrl:T,importFromShareUrl:G,shareLoadError:L,clearShareLoadError:k}}var BD=(e=>(e.Approve="approve",e.Feedback="feedback",e))(BD||{});function r4A(e=window.location){const A=new URLSearchParams(e.search);let t=A.get("cb"),i=A.get("ct");if(!t||!i){const r=e.hash.indexOf("?");if(r!==-1){const n=new URLSearchParams(e.hash.slice(r+1));t=t??n.get("cb"),i=i??n.get("ct")}}if(!t||!i)return null;try{const{protocol:r}=new URL(t);if(r!=="https:"&&r!=="http:")return null}catch{return null}return{callbackUrl:t,token:i}}async function n4A(e,A,t){const i=e==="approve"?"Plan approved! The bot will proceed to implementation.":"Feedback sent! The bot will re-plan with your annotations.";try{const r=await fetch(A.callbackUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,token:A.token,annotated_url:t})});return r.ok?{type:"success",message:i}:{type:"error",message:r.status===401?"Plan link expired — request a new one from the bot.":"Callback failed."}}catch{return{type:"error",message:"Callback failed."}}}function a4A(e,A){const[t,i]=cA.useState(null),r=cA.useRef(null);return cA.useEffect(()=>{const n=e.current;if(!n)return;const a=n.querySelectorAll('[data-block-type="heading"]');if(a.length===0)return;const s=new Map;return r.current=new IntersectionObserver(o=>{o.forEach(I=>{s.set(I.target,I.isIntersecting)});let g=null,l=1/0;for(const[I,C]of s)if(C){const E=I.getBoundingClientRect();E.top<l&&(l=E.top,g=I)}if(g){const I=g.getAttribute("data-block-id");I&&i(I)}},{root:n,rootMargin:"-80px 0px -80% 0px",threshold:[0,.1,.5,1]}),a.forEach(o=>{r.current?.observe(o)}),()=>{r.current?.disconnect()}},[e,A]),t}function eW(e){window.close(),setTimeout(()=>{window.closed||e()},300)}function s4A(e){const[A,t]=cA.useState({phase:"idle"});cA.useEffect(()=>{if(!e)return;const r=GAA();r==="0"?(eW(()=>t({phase:"closeFailed"})),t({phase:"closed"})):t(r!=="off"?{phase:"counting",remaining:Number(r)}:{phase:"prompt"})},[e]),cA.useEffect(()=>{if(A.phase!=="counting")return;if(A.remaining<=0){eW(()=>t({phase:"closeFailed"}));return}const r=setTimeout(()=>t(n=>n.phase==="counting"?{phase:"counting",remaining:n.remaining-1}:n),1e3);return()=>clearTimeout(r)},[A]);const i=cA.useCallback(()=>{OAA("3"),t({phase:"counting",remaining:3})},[]);return{state:A,enableAndStart:i}}const o4A=()=>w.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),g4A=()=>w.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})});function l4A({submitted:e,title:A,subtitle:t,agentLabel:i}){const{state:r,enableAndStart:n}=s4A(!!e);if(!e)return null;const a=e==="approved";return w.jsx("div",{className:"fixed inset-0 z-[100] bg-background flex items-center justify-center",children:w.jsxs("div",{className:"text-center space-y-6 max-w-md px-8",children:[w.jsx("div",{className:`mx-auto w-16 h-16 rounded-full flex items-center justify-center ${a?"bg-success/20 text-success":"bg-accent/20 text-accent"}`,children:a?w.jsx(o4A,{}):w.jsx(g4A,{})}),w.jsxs("div",{className:"space-y-2",children:[w.jsx("h2",{className:"text-xl font-semibold text-foreground",children:A}),w.jsx("p",{className:"text-muted-foreground",children:t})]}),w.jsx("div",{className:"pt-4 border-t border-border space-y-2",children:r.phase==="counting"?w.jsxs(w.Fragment,{children:[w.jsxs("p",{className:"text-sm text-muted-foreground",children:["This tab will close in ",w.jsx("span",{className:"text-foreground font-medium",children:r.remaining})," second",r.remaining!==1?"s":"","..."]}),w.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change this in Settings."})]}):r.phase==="closeFailed"?w.jsxs(w.Fragment,{children:[w.jsx("p",{className:"text-sm text-muted-foreground",children:"Could not close this tab automatically. Please close it manually."}),w.jsxs("p",{className:"text-xs text-muted-foreground/60",children:["Auto-close works when the tab is opened by ",i,"."]})]}):w.jsxs(w.Fragment,{children:[w.jsxs("p",{className:"text-sm text-muted-foreground",children:["You can close this tab and return to ",w.jsx("span",{className:"text-foreground font-medium",children:i}),"."]}),r.phase==="prompt"?w.jsxs(w.Fragment,{children:[w.jsxs("label",{className:"flex items-center justify-center gap-2 cursor-pointer group",children:[w.jsx("input",{type:"checkbox",checked:!1,onChange:n,className:"accent-primary"}),w.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-foreground transition-colors",children:"Auto-close this tab after 3 seconds"})]}),w.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change the delay in Settings."})]}):w.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Your response has been sent."})]})})]})})}const c4A="https://api.github.com/repos/backnotprop/plannotator/releases/latest",tW={"0.5.0":{title:"Code Review is here!",description:"Review git diffs with inline annotations. Run /plannotator-review to try it."}};function I4A(e,A){const t=n=>n.replace(/^v/,""),i=t(e).split(".").map(Number),r=t(A).split(".").map(Number);for(let n=0;n<Math.max(i.length,r.length);n++){const a=i[n]||0,s=r[n]||0;if(s>a)return!0;if(s<a)return!1}return!1}function C4A(){const[e,A]=cA.useState(null);return cA.useEffect(()=>{(async()=>{try{const i="0.16.0",n=new URLSearchParams(window.location.search).get("preview-update");if(n){const C=n.replace(/^v/,"");A({currentVersion:i,latestVersion:n,updateAvailable:!0,releaseUrl:`https://github.com/backnotprop/plannotator/releases/tag/v${C}`,featureHighlight:tW[C]});return}const a=await fetch(c4A);if(!a.ok)return;const s=await a.json(),o=s.tag_name,g=I4A(i,o),l=o.replace(/^v/,""),I=tW[l];A({currentVersion:i,latestVersion:o,updateAvailable:g,releaseUrl:s.html_url,featureHighlight:I})}catch(i){console.debug("Update check failed:",i)}})()},[]),e}const E4A="pi install npm:@plannotator/pi-extension";function u4A(e){return GyA&&!e?'powershell -c "irm https://plannotator.ai/install.ps1 | iex"':"curl -fsSL https://plannotator.ai/install.sh | bash"}const B4A=({origin:e,isWSL:A=!1})=>{const t=C4A(),[i,r]=cA.useState(!1),[n,a]=cA.useState(!1),g=new URLSearchParams(window.location.search).get("preview-origin")||e,l=g==="pi",I=g==="opencode",C=l?E4A:u4A(A);if(!t?.updateAvailable||n)return null;const E=async()=>{try{await navigator.clipboard.writeText(C),r(!0),setTimeout(()=>r(!1),2e3)}catch(h){console.error("Failed to copy:",h)}};return t.featureHighlight?w.jsx("div",{className:"fixed bottom-4 right-4 z-50 max-w-md animate-in slide-in-from-bottom-2 fade-in duration-300",children:w.jsxs("div",{className:"bg-card border border-primary/30 rounded-xl shadow-2xl overflow-hidden",children:[w.jsx("div",{className:"bg-gradient-to-r from-primary/20 to-primary/5 px-5 py-4 border-b border-border/50",children:w.jsxs("div",{className:"flex items-start justify-between gap-3",children:[w.jsxs("div",{className:"flex items-center gap-3",children:[w.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-primary/20 flex items-center justify-center",children:w.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}),w.jsxs("div",{children:[w.jsx("h4",{className:"text-base font-semibold text-foreground",children:t.featureHighlight.title}),w.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["New in ",t.latestVersion]})]})]}),w.jsx("button",{onClick:()=>a(!0),className:"text-muted-foreground hover:text-foreground transition-colors p-1",children:w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),w.jsxs("div",{className:"px-5 py-4",children:[w.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed",children:t.featureHighlight.description}),w.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:["You have ",t.currentVersion]}),I&&w.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install script, then restart OpenCode."}),l&&w.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install command, then restart Pi."}),w.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[w.jsx("button",{onClick:E,className:"flex-1 px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-lg hover:opacity-90 transition-opacity",children:i?"Copied!":"Copy install command"}),w.jsx("a",{href:t.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground border border-border rounded-lg hover:bg-muted transition-colors",children:"Release notes"})]})]})]})}):w.jsx("div",{className:"fixed bottom-4 right-4 z-50 max-w-sm animate-in slide-in-from-bottom-2 fade-in duration-300",children:w.jsx("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4",children:w.jsxs("div",{className:"flex items-start gap-3",children:[w.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center",children:w.jsx("svg",{className:"w-4 h-4 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})})}),w.jsxs("div",{className:"flex-1 min-w-0",children:[w.jsxs("div",{className:"flex items-center justify-between gap-2",children:[w.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Update available"}),w.jsx("button",{onClick:()=>a(!0),className:"text-muted-foreground hover:text-foreground transition-colors",children:w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),w.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[t.latestVersion," is available (you have ",t.currentVersion,")"]}),w.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[w.jsx("button",{onClick:E,className:"flex-1 px-3 py-1.5 text-xs font-medium bg-primary text-primary-foreground rounded-md hover:opacity-90 transition-opacity",children:i?"Copied!":"Copy install command"}),w.jsx("a",{href:t.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:"px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground border border-border rounded-md hover:bg-muted transition-colors",children:"Notes"})]})]})]})})})},JoA="plannotator-editor-mode",d4A="selection";function h4A(){const e=qe.getItem(JoA);return e==="selection"||e==="comment"||e==="redline"||e==="quickLabel"?e:d4A}function Q4A(e){qe.setItem(JoA,e)}const zoA="plannotator-input-method",f4A="drag";function p4A(){const e=qe.getItem(zoA);return e==="drag"||e==="pinpoint"?e:f4A}function m4A(e){qe.setItem(zoA,e)}const y4A=300,D4A=300;function w4A(e,A){const t=cA.useRef("idle"),i=cA.useRef(0),r=cA.useRef(void 0),n=cA.useRef(e);cA.useEffect(()=>{t.current==="idle"&&(n.current=e)},[e]);const a=cA.useCallback(s=>s==="drag"?"pinpoint":"drag",[]);cA.useEffect(()=>{const s=g=>{if(g.key!=="Alt"||g.repeat)return;const l=g.target?.tagName;l==="INPUT"||l==="TEXTAREA"||g.target?.isContentEditable||document.querySelector("[data-quick-label-picker]")||(t.current==="idle"?(n.current=e,i.current=Date.now(),t.current="held",A(a(e))):t.current==="tapped"&&(clearTimeout(r.current),t.current="idle",n.current=a(n.current)))},o=g=>{g.key==="Alt"&&t.current==="held"&&(Date.now()-i.current>=D4A?(A(n.current),t.current="idle"):(t.current="tapped",r.current=setTimeout(()=>{t.current==="tapped"&&(A(n.current),t.current="idle")},y4A)))};return window.addEventListener("keydown",s),window.addEventListener("keyup",o),()=>{clearTimeout(r.current),window.removeEventListener("keydown",s),window.removeEventListener("keyup",o)}},[e,A,a])}function v4A(){cA.useEffect(()=>{const e=()=>document.documentElement.classList.add("plannotator-print"),A=()=>document.documentElement.classList.remove("plannotator-print"),t=()=>{!document.hidden&&document.documentElement.classList.contains("plannotator-print")&&document.documentElement.classList.remove("plannotator-print")};return window.addEventListener("beforeprint",e),window.addEventListener("afterprint",A),document.addEventListener("visibilitychange",t),()=>{window.removeEventListener("beforeprint",e),window.removeEventListener("afterprint",A),document.removeEventListener("visibilitychange",t),document.documentElement.classList.remove("plannotator-print")}},[])}function iW({storageKey:e,defaultWidth:A=288,minWidth:t=200,maxWidth:i=600,side:r="right"}){const[n,a]=cA.useState(()=>{const Q=qe.getItem(e);if(Q){const f=Number(Q);if(!Number.isNaN(f)&&f>=t&&f<=i)return f}return A}),[s,o]=cA.useState(!1),g=cA.useRef(0),l=cA.useRef(0),I=cA.useRef(n),C=cA.useCallback(Q=>{I.current=Q,a(Q)},[]),E=cA.useCallback(Q=>{Q.preventDefault(),g.current=Q.clientX,l.current=I.current,o(!0)},[]),B=cA.useCallback(Q=>{Q.preventDefault(),g.current=Q.touches[0].clientX,l.current=I.current,o(!0)},[]);cA.useEffect(()=>{if(!s)return;const Q=y=>"touches"in y?y.touches[0]?.clientX??y.changedTouches[0]?.clientX??0:y.clientX,f=y=>{const v=Q(y),S=r==="right"?g.current-v:v-g.current;C(Math.min(i,Math.max(t,l.current+S)))},m=()=>{o(!1),qe.setItem(e,String(I.current))};return document.addEventListener("mousemove",f),document.addEventListener("mouseup",m),document.addEventListener("touchmove",f,{passive:!1}),document.addEventListener("touchend",m),document.addEventListener("touchcancel",m),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",m),document.removeEventListener("touchmove",f),document.removeEventListener("touchend",m),document.removeEventListener("touchcancel",m)}},[s,t,i,e,r,C]);const h=cA.useCallback(()=>{C(A),qe.setItem(e,String(A))},[A,e,C]);return{width:n,isDragging:s,handleProps:{isDragging:s,onMouseDown:E,onTouchStart:B,onDoubleClick:h}}}const rW=({isDragging:e,onMouseDown:A,onTouchStart:t,onDoubleClick:i,className:r,side:n})=>w.jsxs("div",{className:`relative w-0 cursor-col-resize flex-shrink-0 group z-10${r?` ${r}`:""}`,children:[w.jsx("div",{className:`absolute inset-y-0 -left-0.5 -right-0.5 transition-colors ${e?"bg-primary/50":"group-hover:bg-border"}`}),w.jsx("div",{className:`absolute inset-y-0 ${n==="left"?"-right-2 -left-1":n==="right"?"-left-2 -right-1":"-inset-x-2"}`,onMouseDown:A,onTouchStart:t,onDoubleClick:i})]}),S4A=({isPanelOpen:e,onTogglePanel:A,annotationCount:t,onOpenExport:i,onOpenSettings:r,onDownloadAnnotations:n,onCopyShareLink:a,onOpenImport:s,onPrint:o,sharingEnabled:g,className:l})=>{const[I,C]=cA.useState(!1),E=cA.useRef(null),{theme:B,setTheme:h}=a4();cA.useEffect(()=>{if(!I)return;const f=m=>{E.current&&!E.current.contains(m.target)&&C(!1)};return document.addEventListener("pointerdown",f),()=>document.removeEventListener("pointerdown",f)},[I]);const Q=f=>{C(!1),f()};return w.jsxs("div",{className:`relative ${l??""}`,ref:E,children:[w.jsx("button",{onClick:()=>C(!I),className:"p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"Menu",children:I?w.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}):w.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})})}),I&&w.jsxs("div",{className:"absolute top-full right-0 mt-1 w-56 bg-popover border border-border rounded-lg shadow-xl z-[70] py-1",children:[w.jsxs("div",{className:"px-3 py-2",children:[w.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground mb-1.5",children:"Theme"}),w.jsx("div",{className:"flex items-center gap-1 bg-muted/50 rounded-lg p-0.5",children:["light","dark","system"].map(f=>w.jsx("button",{onClick:()=>h(f),className:`flex-1 px-2 py-1 text-[10px] capitalize rounded-md transition-colors ${B===f?"bg-background text-foreground shadow-sm font-medium":"text-muted-foreground hover:text-foreground"}`,children:f},f))})]}),w.jsx("div",{className:"my-1 border-t border-border"}),w.jsx(RC,{onClick:()=>Q(r),icon:w.jsx(b4A,{}),label:"Settings"}),w.jsx(RC,{onClick:()=>Q(A),icon:w.jsx(R4A,{}),label:e?"Hide Annotations":"Show Annotations",badge:t>0?t:void 0}),w.jsx("div",{className:"my-1 border-t border-border"}),w.jsx(RC,{onClick:()=>Q(i),icon:w.jsx(N4A,{}),label:"Export"}),w.jsx(RC,{onClick:()=>Q(n),icon:w.jsx(M4A,{}),label:"Download Annotations"}),w.jsx(RC,{onClick:()=>Q(o),icon:w.jsx(L4A,{}),label:"Print Plan"}),g&&w.jsx(RC,{onClick:()=>Q(a),icon:w.jsx(k4A,{}),label:"Copy Share Link"}),g&&w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"my-1 border-t border-border"}),w.jsx(RC,{onClick:()=>Q(s),icon:w.jsx(x4A,{}),label:"Import Review"})]})]})]})},RC=({onClick:e,icon:A,label:t,badge:i})=>w.jsxs("button",{onClick:e,className:"w-full text-left px-3 py-2 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("span",{className:"text-muted-foreground",children:A}),w.jsx("span",{className:"flex-1",children:t}),i!==void 0&&w.jsx("span",{className:"text-[10px] font-mono bg-muted px-1.5 py-0.5 rounded text-muted-foreground",children:i})]}),b4A=()=>w.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),R4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),N4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})}),M4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),k4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),x4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4M10 17l5-5-5-5M15 12H3"})}),L4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"})}),T4A=({isOpen:e,onComplete:A})=>{const[t,i]=cA.useState("acceptEdits");if(!e)return null;const r=()=>{boA(t),A(t)};return ng.createPortal(w.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-background/90 backdrop-blur-sm p-4",children:w.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-lg shadow-2xl",children:[w.jsxs("div",{className:"p-5 border-b border-border",children:[w.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[w.jsx("div",{className:"p-1.5 rounded-lg bg-primary/15",children:w.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0"})})}),w.jsx("h3",{className:"font-semibold text-base",children:"New: Permission Mode Preservation"})]}),w.jsx("p",{className:"text-sm text-muted-foreground",children:"Claude Code 2.1.7+ supports preserving your permission mode after plan approval. Choose your preferred automation level."}),w.jsxs("p",{className:"text-xs text-muted-foreground/70 mt-1",children:["Requires Claude Code 2.1.7 or later. Run ",w.jsx("code",{className:"bg-muted px-1 rounded",children:"claude update"})," to update."]})]}),w.jsx("div",{className:"p-4 space-y-2",children:PG.map(n=>w.jsxs("label",{className:`flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all border ${t===n.value?"border-primary bg-primary/10":"border-transparent bg-muted/50 hover:bg-muted"}`,children:[w.jsx("input",{type:"radio",name:"permissionMode",value:n.value,checked:t===n.value,onChange:()=>i(n.value),className:"mt-0.5 accent-primary"}),w.jsxs("div",{className:"flex-1",children:[w.jsx("div",{className:"text-sm font-medium",children:n.label}),w.jsx("div",{className:"text-xs text-muted-foreground",children:n.description})]})]},n.value))}),w.jsxs("div",{className:"p-4 border-t border-border flex justify-between items-center",children:[w.jsx("p",{className:"text-xs text-muted-foreground",children:"You can change this later in Settings."}),w.jsx("button",{onClick:r,className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:opacity-90 transition-opacity",children:"Continue"})]})]})}),document.body)};function F4A(e){const[A,t]=cA.useState(e),[i,r]=cA.useState("toc"),n=cA.useCallback(o=>{t(!0),o&&r(o)},[]),a=cA.useCallback(()=>{t(!1)},[]),s=cA.useCallback(o=>{A?i===o?t(!1):r(o):(t(!0),r(o))},[A,i]);return{isOpen:A,activeTab:i,open:n,close:a,toggleTab:s}}class G4A{diff(A,t,i={}){let r;typeof i=="function"?(r=i,i={}):"callback"in i&&(r=i.callback);const n=this.castInput(A,i),a=this.castInput(t,i),s=this.removeEmpty(this.tokenize(n,i)),o=this.removeEmpty(this.tokenize(a,i));return this.diffWithOptionsObj(s,o,i,r)}diffWithOptionsObj(A,t,i,r){var n;const a=m=>{if(m=this.postProcess(m,i),r){setTimeout(function(){r(m)},0);return}else return m},s=t.length,o=A.length;let g=1,l=s+o;i.maxEditLength!=null&&(l=Math.min(l,i.maxEditLength));const I=(n=i.timeout)!==null&&n!==void 0?n:1/0,C=Date.now()+I,E=[{oldPos:-1,lastComponent:void 0}];let B=this.extractCommon(E[0],t,A,0,i);if(E[0].oldPos+1>=o&&B+1>=s)return a(this.buildValues(E[0].lastComponent,t,A));let h=-1/0,Q=1/0;const f=()=>{for(let m=Math.max(h,-g);m<=Math.min(Q,g);m+=2){let y;const v=E[m-1],S=E[m+1];v&&(E[m-1]=void 0);let x=!1;if(S){const b=S.oldPos-m;x=S&&0<=b&&b<s}const R=v&&v.oldPos+1<o;if(!x&&!R){E[m]=void 0;continue}if(!R||x&&v.oldPos<S.oldPos?y=this.addToPath(S,!0,!1,0,i):y=this.addToPath(v,!1,!0,1,i),B=this.extractCommon(y,t,A,m,i),y.oldPos+1>=o&&B+1>=s)return a(this.buildValues(y.lastComponent,t,A))||!0;E[m]=y,y.oldPos+1>=o&&(Q=Math.min(Q,m-1)),B+1>=s&&(h=Math.max(h,m+1))}g++};if(r)(function m(){setTimeout(function(){if(g>l||Date.now()>C)return r(void 0);f()||m()},0)})();else for(;g<=l&&Date.now()<=C;){const m=f();if(m)return m}}addToPath(A,t,i,r,n){const a=A.lastComponent;return a&&!n.oneChangePerToken&&a.added===t&&a.removed===i?{oldPos:A.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:i,previousComponent:a.previousComponent}}:{oldPos:A.oldPos+r,lastComponent:{count:1,added:t,removed:i,previousComponent:a}}}extractCommon(A,t,i,r,n){const a=t.length,s=i.length;let o=A.oldPos,g=o-r,l=0;for(;g+1<a&&o+1<s&&this.equals(i[o+1],t[g+1],n);)g++,o++,l++,n.oneChangePerToken&&(A.lastComponent={count:1,previousComponent:A.lastComponent,added:!1,removed:!1});return l&&!n.oneChangePerToken&&(A.lastComponent={count:l,previousComponent:A.lastComponent,added:!1,removed:!1}),A.oldPos=o,g}equals(A,t,i){return i.comparator?i.comparator(A,t):A===t||!!i.ignoreCase&&A.toLowerCase()===t.toLowerCase()}removeEmpty(A){const t=[];for(let i=0;i<A.length;i++)A[i]&&t.push(A[i]);return t}castInput(A,t){return A}tokenize(A,t){return Array.from(A)}join(A){return A.join("")}postProcess(A,t){return A}get useLongestToken(){return!1}buildValues(A,t,i){const r=[];let n;for(;A;)r.push(A),n=A.previousComponent,delete A.previousComponent,A=n;r.reverse();const a=r.length;let s=0,o=0,g=0;for(;s<a;s++){const l=r[s];if(l.removed)l.value=this.join(i.slice(g,g+l.count)),g+=l.count;else{if(!l.added&&this.useLongestToken){let I=t.slice(o,o+l.count);I=I.map(function(C,E){const B=i[g+E];return B.length>C.length?B:C}),l.value=this.join(I)}else l.value=this.join(t.slice(o,o+l.count));o+=l.count,l.added||(g+=l.count)}}return r}}class O4A extends G4A{constructor(){super(...arguments),this.tokenize=Y4A}equals(A,t,i){return i.ignoreWhitespace?((!i.newlineIsToken||!A.includes(`
500
+ `).find(nA=>nA.startsWith("#")),AA=j?j.replace(/^#+\s*/,"").trim():"Unknown Plan",X=uD(q.a,q.d,q.s);if(X.length===0)return{success:!0,count:0,planTitle:AA,error:"No annotations found in share link"};const sA=X.filter(nA=>!A.some(hA=>hA.originalText===nA.originalText&&hA.type===nA.type&&hA.text===nA.text));if(sA.length>0&&(r(nA=>{const hA=X.filter(oA=>!nA.some(gA=>gA.originalText===oA.originalText&&gA.type===oA.type&&gA.text===oA.text));if(hA.length===0)return nA;const rA=[...nA,...hA];return b(rA),rA}),q.g?.length)){const nA=vB(q.g)??[];n(hA=>{const rA=new Set(hA.map(gA=>gA.path)),oA=nA.filter(gA=>!rA.has(gA.path));return oA.length>0?[...hA,...oA]:hA}),F(nA)}return{success:!0,count:sA.length,planTitle:AA}}catch(q){return{success:!1,count:0,planTitle:"",error:q instanceof Error?q.message:"Failed to decompress share URL"}}},[A,t,r,n,o]);return{isSharedSession:g,isLoadingShared:I,shareUrl:E,shareUrlSize:h,shortShareUrl:f,isGeneratingShortUrl:y,shortUrlError:S,pendingSharedAnnotations:R,sharedGlobalAttachments:N,clearPendingSharedAnnotations:H,refreshShareUrl:O,generateShortUrl:T,importFromShareUrl:G,shareLoadError:L,clearShareLoadError:k}}var BD=(e=>(e.Approve="approve",e.Feedback="feedback",e))(BD||{});function r4A(e=window.location){const A=new URLSearchParams(e.search);let t=A.get("cb"),i=A.get("ct");if(!t||!i){const r=e.hash.indexOf("?");if(r!==-1){const n=new URLSearchParams(e.hash.slice(r+1));t=t??n.get("cb"),i=i??n.get("ct")}}if(!t||!i)return null;try{const{protocol:r}=new URL(t);if(r!=="https:"&&r!=="http:")return null}catch{return null}return{callbackUrl:t,token:i}}async function n4A(e,A,t){const i=e==="approve"?"Plan approved! The bot will proceed to implementation.":"Feedback sent! The bot will re-plan with your annotations.";try{const r=await fetch(A.callbackUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,token:A.token,annotated_url:t})});return r.ok?{type:"success",message:i}:{type:"error",message:r.status===401?"Plan link expired — request a new one from the bot.":"Callback failed."}}catch{return{type:"error",message:"Callback failed."}}}function a4A(e,A){const[t,i]=cA.useState(null),r=cA.useRef(null);return cA.useEffect(()=>{const n=e.current;if(!n)return;const a=n.querySelectorAll('[data-block-type="heading"]');if(a.length===0)return;const s=new Map;return r.current=new IntersectionObserver(o=>{o.forEach(I=>{s.set(I.target,I.isIntersecting)});let g=null,l=1/0;for(const[I,C]of s)if(C){const E=I.getBoundingClientRect();E.top<l&&(l=E.top,g=I)}if(g){const I=g.getAttribute("data-block-id");I&&i(I)}},{root:n,rootMargin:"-80px 0px -80% 0px",threshold:[0,.1,.5,1]}),a.forEach(o=>{r.current?.observe(o)}),()=>{r.current?.disconnect()}},[e,A]),t}function eW(e){window.close(),setTimeout(()=>{window.closed||e()},300)}function s4A(e){const[A,t]=cA.useState({phase:"idle"});cA.useEffect(()=>{if(!e)return;const r=GAA();r==="0"?(eW(()=>t({phase:"closeFailed"})),t({phase:"closed"})):t(r!=="off"?{phase:"counting",remaining:Number(r)}:{phase:"prompt"})},[e]),cA.useEffect(()=>{if(A.phase!=="counting")return;if(A.remaining<=0){eW(()=>t({phase:"closeFailed"}));return}const r=setTimeout(()=>t(n=>n.phase==="counting"?{phase:"counting",remaining:n.remaining-1}:n),1e3);return()=>clearTimeout(r)},[A]);const i=cA.useCallback(()=>{OAA("3"),t({phase:"counting",remaining:3})},[]);return{state:A,enableAndStart:i}}const o4A=()=>w.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),g4A=()=>w.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})});function l4A({submitted:e,title:A,subtitle:t,agentLabel:i}){const{state:r,enableAndStart:n}=s4A(!!e);if(!e)return null;const a=e==="approved";return w.jsx("div",{className:"fixed inset-0 z-[100] bg-background flex items-center justify-center",children:w.jsxs("div",{className:"text-center space-y-6 max-w-md px-8",children:[w.jsx("div",{className:`mx-auto w-16 h-16 rounded-full flex items-center justify-center ${a?"bg-success/20 text-success":"bg-accent/20 text-accent"}`,children:a?w.jsx(o4A,{}):w.jsx(g4A,{})}),w.jsxs("div",{className:"space-y-2",children:[w.jsx("h2",{className:"text-xl font-semibold text-foreground",children:A}),w.jsx("p",{className:"text-muted-foreground",children:t})]}),w.jsx("div",{className:"pt-4 border-t border-border space-y-2",children:r.phase==="counting"?w.jsxs(w.Fragment,{children:[w.jsxs("p",{className:"text-sm text-muted-foreground",children:["This tab will close in ",w.jsx("span",{className:"text-foreground font-medium",children:r.remaining})," second",r.remaining!==1?"s":"","..."]}),w.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change this in Settings."})]}):r.phase==="closeFailed"?w.jsxs(w.Fragment,{children:[w.jsx("p",{className:"text-sm text-muted-foreground",children:"Could not close this tab automatically. Please close it manually."}),w.jsxs("p",{className:"text-xs text-muted-foreground/60",children:["Auto-close works when the tab is opened by ",i,"."]})]}):w.jsxs(w.Fragment,{children:[w.jsxs("p",{className:"text-sm text-muted-foreground",children:["You can close this tab and return to ",w.jsx("span",{className:"text-foreground font-medium",children:i}),"."]}),r.phase==="prompt"?w.jsxs(w.Fragment,{children:[w.jsxs("label",{className:"flex items-center justify-center gap-2 cursor-pointer group",children:[w.jsx("input",{type:"checkbox",checked:!1,onChange:n,className:"accent-primary"}),w.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-foreground transition-colors",children:"Auto-close this tab after 3 seconds"})]}),w.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change the delay in Settings."})]}):w.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Your response has been sent."})]})})]})})}const c4A="https://api.github.com/repos/backnotprop/plannotator/releases/latest",tW={"0.5.0":{title:"Code Review is here!",description:"Review git diffs with inline annotations. Run /plannotator-review to try it."}};function I4A(e,A){const t=n=>n.replace(/^v/,""),i=t(e).split(".").map(Number),r=t(A).split(".").map(Number);for(let n=0;n<Math.max(i.length,r.length);n++){const a=i[n]||0,s=r[n]||0;if(s>a)return!0;if(s<a)return!1}return!1}function C4A(){const[e,A]=cA.useState(null);return cA.useEffect(()=>{(async()=>{try{const i="0.16.1",n=new URLSearchParams(window.location.search).get("preview-update");if(n){const C=n.replace(/^v/,"");A({currentVersion:i,latestVersion:n,updateAvailable:!0,releaseUrl:`https://github.com/backnotprop/plannotator/releases/tag/v${C}`,featureHighlight:tW[C]});return}const a=await fetch(c4A);if(!a.ok)return;const s=await a.json(),o=s.tag_name,g=I4A(i,o),l=o.replace(/^v/,""),I=tW[l];A({currentVersion:i,latestVersion:o,updateAvailable:g,releaseUrl:s.html_url,featureHighlight:I})}catch(i){console.debug("Update check failed:",i)}})()},[]),e}const E4A="pi install npm:@plannotator/pi-extension";function u4A(e){return GyA&&!e?'powershell -c "irm https://plannotator.ai/install.ps1 | iex"':"curl -fsSL https://plannotator.ai/install.sh | bash"}const B4A=({origin:e,isWSL:A=!1})=>{const t=C4A(),[i,r]=cA.useState(!1),[n,a]=cA.useState(!1),g=new URLSearchParams(window.location.search).get("preview-origin")||e,l=g==="pi",I=g==="opencode",C=l?E4A:u4A(A);if(!t?.updateAvailable||n)return null;const E=async()=>{try{await navigator.clipboard.writeText(C),r(!0),setTimeout(()=>r(!1),2e3)}catch(h){console.error("Failed to copy:",h)}};return t.featureHighlight?w.jsx("div",{className:"fixed bottom-4 right-4 z-50 max-w-md animate-in slide-in-from-bottom-2 fade-in duration-300",children:w.jsxs("div",{className:"bg-card border border-primary/30 rounded-xl shadow-2xl overflow-hidden",children:[w.jsx("div",{className:"bg-gradient-to-r from-primary/20 to-primary/5 px-5 py-4 border-b border-border/50",children:w.jsxs("div",{className:"flex items-start justify-between gap-3",children:[w.jsxs("div",{className:"flex items-center gap-3",children:[w.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-primary/20 flex items-center justify-center",children:w.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}),w.jsxs("div",{children:[w.jsx("h4",{className:"text-base font-semibold text-foreground",children:t.featureHighlight.title}),w.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["New in ",t.latestVersion]})]})]}),w.jsx("button",{onClick:()=>a(!0),className:"text-muted-foreground hover:text-foreground transition-colors p-1",children:w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),w.jsxs("div",{className:"px-5 py-4",children:[w.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed",children:t.featureHighlight.description}),w.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:["You have ",t.currentVersion]}),I&&w.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install script, then restart OpenCode."}),l&&w.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install command, then restart Pi."}),w.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[w.jsx("button",{onClick:E,className:"flex-1 px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-lg hover:opacity-90 transition-opacity",children:i?"Copied!":"Copy install command"}),w.jsx("a",{href:t.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground border border-border rounded-lg hover:bg-muted transition-colors",children:"Release notes"})]})]})]})}):w.jsx("div",{className:"fixed bottom-4 right-4 z-50 max-w-sm animate-in slide-in-from-bottom-2 fade-in duration-300",children:w.jsx("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4",children:w.jsxs("div",{className:"flex items-start gap-3",children:[w.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center",children:w.jsx("svg",{className:"w-4 h-4 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})})}),w.jsxs("div",{className:"flex-1 min-w-0",children:[w.jsxs("div",{className:"flex items-center justify-between gap-2",children:[w.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Update available"}),w.jsx("button",{onClick:()=>a(!0),className:"text-muted-foreground hover:text-foreground transition-colors",children:w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),w.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[t.latestVersion," is available (you have ",t.currentVersion,")"]}),w.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[w.jsx("button",{onClick:E,className:"flex-1 px-3 py-1.5 text-xs font-medium bg-primary text-primary-foreground rounded-md hover:opacity-90 transition-opacity",children:i?"Copied!":"Copy install command"}),w.jsx("a",{href:t.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:"px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground border border-border rounded-md hover:bg-muted transition-colors",children:"Notes"})]})]})]})})})},JoA="plannotator-editor-mode",d4A="selection";function h4A(){const e=qe.getItem(JoA);return e==="selection"||e==="comment"||e==="redline"||e==="quickLabel"?e:d4A}function Q4A(e){qe.setItem(JoA,e)}const zoA="plannotator-input-method",f4A="drag";function p4A(){const e=qe.getItem(zoA);return e==="drag"||e==="pinpoint"?e:f4A}function m4A(e){qe.setItem(zoA,e)}const y4A=300,D4A=300;function w4A(e,A){const t=cA.useRef("idle"),i=cA.useRef(0),r=cA.useRef(void 0),n=cA.useRef(e);cA.useEffect(()=>{t.current==="idle"&&(n.current=e)},[e]);const a=cA.useCallback(s=>s==="drag"?"pinpoint":"drag",[]);cA.useEffect(()=>{const s=g=>{if(g.key!=="Alt"||g.repeat)return;const l=g.target?.tagName;l==="INPUT"||l==="TEXTAREA"||g.target?.isContentEditable||document.querySelector("[data-quick-label-picker]")||(t.current==="idle"?(n.current=e,i.current=Date.now(),t.current="held",A(a(e))):t.current==="tapped"&&(clearTimeout(r.current),t.current="idle",n.current=a(n.current)))},o=g=>{g.key==="Alt"&&t.current==="held"&&(Date.now()-i.current>=D4A?(A(n.current),t.current="idle"):(t.current="tapped",r.current=setTimeout(()=>{t.current==="tapped"&&(A(n.current),t.current="idle")},y4A)))};return window.addEventListener("keydown",s),window.addEventListener("keyup",o),()=>{clearTimeout(r.current),window.removeEventListener("keydown",s),window.removeEventListener("keyup",o)}},[e,A,a])}function v4A(){cA.useEffect(()=>{const e=()=>document.documentElement.classList.add("plannotator-print"),A=()=>document.documentElement.classList.remove("plannotator-print"),t=()=>{!document.hidden&&document.documentElement.classList.contains("plannotator-print")&&document.documentElement.classList.remove("plannotator-print")};return window.addEventListener("beforeprint",e),window.addEventListener("afterprint",A),document.addEventListener("visibilitychange",t),()=>{window.removeEventListener("beforeprint",e),window.removeEventListener("afterprint",A),document.removeEventListener("visibilitychange",t),document.documentElement.classList.remove("plannotator-print")}},[])}function iW({storageKey:e,defaultWidth:A=288,minWidth:t=200,maxWidth:i=600,side:r="right"}){const[n,a]=cA.useState(()=>{const Q=qe.getItem(e);if(Q){const f=Number(Q);if(!Number.isNaN(f)&&f>=t&&f<=i)return f}return A}),[s,o]=cA.useState(!1),g=cA.useRef(0),l=cA.useRef(0),I=cA.useRef(n),C=cA.useCallback(Q=>{I.current=Q,a(Q)},[]),E=cA.useCallback(Q=>{Q.preventDefault(),g.current=Q.clientX,l.current=I.current,o(!0)},[]),B=cA.useCallback(Q=>{Q.preventDefault(),g.current=Q.touches[0].clientX,l.current=I.current,o(!0)},[]);cA.useEffect(()=>{if(!s)return;const Q=y=>"touches"in y?y.touches[0]?.clientX??y.changedTouches[0]?.clientX??0:y.clientX,f=y=>{const v=Q(y),S=r==="right"?g.current-v:v-g.current;C(Math.min(i,Math.max(t,l.current+S)))},m=()=>{o(!1),qe.setItem(e,String(I.current))};return document.addEventListener("mousemove",f),document.addEventListener("mouseup",m),document.addEventListener("touchmove",f,{passive:!1}),document.addEventListener("touchend",m),document.addEventListener("touchcancel",m),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",m),document.removeEventListener("touchmove",f),document.removeEventListener("touchend",m),document.removeEventListener("touchcancel",m)}},[s,t,i,e,r,C]);const h=cA.useCallback(()=>{C(A),qe.setItem(e,String(A))},[A,e,C]);return{width:n,isDragging:s,handleProps:{isDragging:s,onMouseDown:E,onTouchStart:B,onDoubleClick:h}}}const rW=({isDragging:e,onMouseDown:A,onTouchStart:t,onDoubleClick:i,className:r,side:n})=>w.jsxs("div",{className:`relative w-0 cursor-col-resize flex-shrink-0 group z-10${r?` ${r}`:""}`,children:[w.jsx("div",{className:`absolute inset-y-0 -left-0.5 -right-0.5 transition-colors ${e?"bg-primary/50":"group-hover:bg-border"}`}),w.jsx("div",{className:`absolute inset-y-0 ${n==="left"?"-right-2 -left-1":n==="right"?"-left-2 -right-1":"-inset-x-2"}`,onMouseDown:A,onTouchStart:t,onDoubleClick:i})]}),S4A=({isPanelOpen:e,onTogglePanel:A,annotationCount:t,onOpenExport:i,onOpenSettings:r,onDownloadAnnotations:n,onCopyShareLink:a,onOpenImport:s,onPrint:o,sharingEnabled:g,className:l})=>{const[I,C]=cA.useState(!1),E=cA.useRef(null),{theme:B,setTheme:h}=a4();cA.useEffect(()=>{if(!I)return;const f=m=>{E.current&&!E.current.contains(m.target)&&C(!1)};return document.addEventListener("pointerdown",f),()=>document.removeEventListener("pointerdown",f)},[I]);const Q=f=>{C(!1),f()};return w.jsxs("div",{className:`relative ${l??""}`,ref:E,children:[w.jsx("button",{onClick:()=>C(!I),className:"p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"Menu",children:I?w.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}):w.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})})}),I&&w.jsxs("div",{className:"absolute top-full right-0 mt-1 w-56 bg-popover border border-border rounded-lg shadow-xl z-[70] py-1",children:[w.jsxs("div",{className:"px-3 py-2",children:[w.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground mb-1.5",children:"Theme"}),w.jsx("div",{className:"flex items-center gap-1 bg-muted/50 rounded-lg p-0.5",children:["light","dark","system"].map(f=>w.jsx("button",{onClick:()=>h(f),className:`flex-1 px-2 py-1 text-[10px] capitalize rounded-md transition-colors ${B===f?"bg-background text-foreground shadow-sm font-medium":"text-muted-foreground hover:text-foreground"}`,children:f},f))})]}),w.jsx("div",{className:"my-1 border-t border-border"}),w.jsx(RC,{onClick:()=>Q(r),icon:w.jsx(b4A,{}),label:"Settings"}),w.jsx(RC,{onClick:()=>Q(A),icon:w.jsx(R4A,{}),label:e?"Hide Annotations":"Show Annotations",badge:t>0?t:void 0}),w.jsx("div",{className:"my-1 border-t border-border"}),w.jsx(RC,{onClick:()=>Q(i),icon:w.jsx(N4A,{}),label:"Export"}),w.jsx(RC,{onClick:()=>Q(n),icon:w.jsx(M4A,{}),label:"Download Annotations"}),w.jsx(RC,{onClick:()=>Q(o),icon:w.jsx(L4A,{}),label:"Print Plan"}),g&&w.jsx(RC,{onClick:()=>Q(a),icon:w.jsx(k4A,{}),label:"Copy Share Link"}),g&&w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"my-1 border-t border-border"}),w.jsx(RC,{onClick:()=>Q(s),icon:w.jsx(x4A,{}),label:"Import Review"})]})]})]})},RC=({onClick:e,icon:A,label:t,badge:i})=>w.jsxs("button",{onClick:e,className:"w-full text-left px-3 py-2 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("span",{className:"text-muted-foreground",children:A}),w.jsx("span",{className:"flex-1",children:t}),i!==void 0&&w.jsx("span",{className:"text-[10px] font-mono bg-muted px-1.5 py-0.5 rounded text-muted-foreground",children:i})]}),b4A=()=>w.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),R4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),N4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})}),M4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),k4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),x4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4M10 17l5-5-5-5M15 12H3"})}),L4A=()=>w.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"})}),T4A=({isOpen:e,onComplete:A})=>{const[t,i]=cA.useState("acceptEdits");if(!e)return null;const r=()=>{boA(t),A(t)};return ng.createPortal(w.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-background/90 backdrop-blur-sm p-4",children:w.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-lg shadow-2xl",children:[w.jsxs("div",{className:"p-5 border-b border-border",children:[w.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[w.jsx("div",{className:"p-1.5 rounded-lg bg-primary/15",children:w.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0"})})}),w.jsx("h3",{className:"font-semibold text-base",children:"New: Permission Mode Preservation"})]}),w.jsx("p",{className:"text-sm text-muted-foreground",children:"Claude Code 2.1.7+ supports preserving your permission mode after plan approval. Choose your preferred automation level."}),w.jsxs("p",{className:"text-xs text-muted-foreground/70 mt-1",children:["Requires Claude Code 2.1.7 or later. Run ",w.jsx("code",{className:"bg-muted px-1 rounded",children:"claude update"})," to update."]})]}),w.jsx("div",{className:"p-4 space-y-2",children:PG.map(n=>w.jsxs("label",{className:`flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all border ${t===n.value?"border-primary bg-primary/10":"border-transparent bg-muted/50 hover:bg-muted"}`,children:[w.jsx("input",{type:"radio",name:"permissionMode",value:n.value,checked:t===n.value,onChange:()=>i(n.value),className:"mt-0.5 accent-primary"}),w.jsxs("div",{className:"flex-1",children:[w.jsx("div",{className:"text-sm font-medium",children:n.label}),w.jsx("div",{className:"text-xs text-muted-foreground",children:n.description})]})]},n.value))}),w.jsxs("div",{className:"p-4 border-t border-border flex justify-between items-center",children:[w.jsx("p",{className:"text-xs text-muted-foreground",children:"You can change this later in Settings."}),w.jsx("button",{onClick:r,className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:opacity-90 transition-opacity",children:"Continue"})]})]})}),document.body)};function F4A(e){const[A,t]=cA.useState(e),[i,r]=cA.useState("toc"),n=cA.useCallback(o=>{t(!0),o&&r(o)},[]),a=cA.useCallback(()=>{t(!1)},[]),s=cA.useCallback(o=>{A?i===o?t(!1):r(o):(t(!0),r(o))},[A,i]);return{isOpen:A,activeTab:i,open:n,close:a,toggleTab:s}}class G4A{diff(A,t,i={}){let r;typeof i=="function"?(r=i,i={}):"callback"in i&&(r=i.callback);const n=this.castInput(A,i),a=this.castInput(t,i),s=this.removeEmpty(this.tokenize(n,i)),o=this.removeEmpty(this.tokenize(a,i));return this.diffWithOptionsObj(s,o,i,r)}diffWithOptionsObj(A,t,i,r){var n;const a=m=>{if(m=this.postProcess(m,i),r){setTimeout(function(){r(m)},0);return}else return m},s=t.length,o=A.length;let g=1,l=s+o;i.maxEditLength!=null&&(l=Math.min(l,i.maxEditLength));const I=(n=i.timeout)!==null&&n!==void 0?n:1/0,C=Date.now()+I,E=[{oldPos:-1,lastComponent:void 0}];let B=this.extractCommon(E[0],t,A,0,i);if(E[0].oldPos+1>=o&&B+1>=s)return a(this.buildValues(E[0].lastComponent,t,A));let h=-1/0,Q=1/0;const f=()=>{for(let m=Math.max(h,-g);m<=Math.min(Q,g);m+=2){let y;const v=E[m-1],S=E[m+1];v&&(E[m-1]=void 0);let x=!1;if(S){const b=S.oldPos-m;x=S&&0<=b&&b<s}const R=v&&v.oldPos+1<o;if(!x&&!R){E[m]=void 0;continue}if(!R||x&&v.oldPos<S.oldPos?y=this.addToPath(S,!0,!1,0,i):y=this.addToPath(v,!1,!0,1,i),B=this.extractCommon(y,t,A,m,i),y.oldPos+1>=o&&B+1>=s)return a(this.buildValues(y.lastComponent,t,A))||!0;E[m]=y,y.oldPos+1>=o&&(Q=Math.min(Q,m-1)),B+1>=s&&(h=Math.max(h,m+1))}g++};if(r)(function m(){setTimeout(function(){if(g>l||Date.now()>C)return r(void 0);f()||m()},0)})();else for(;g<=l&&Date.now()<=C;){const m=f();if(m)return m}}addToPath(A,t,i,r,n){const a=A.lastComponent;return a&&!n.oneChangePerToken&&a.added===t&&a.removed===i?{oldPos:A.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:i,previousComponent:a.previousComponent}}:{oldPos:A.oldPos+r,lastComponent:{count:1,added:t,removed:i,previousComponent:a}}}extractCommon(A,t,i,r,n){const a=t.length,s=i.length;let o=A.oldPos,g=o-r,l=0;for(;g+1<a&&o+1<s&&this.equals(i[o+1],t[g+1],n);)g++,o++,l++,n.oneChangePerToken&&(A.lastComponent={count:1,previousComponent:A.lastComponent,added:!1,removed:!1});return l&&!n.oneChangePerToken&&(A.lastComponent={count:l,previousComponent:A.lastComponent,added:!1,removed:!1}),A.oldPos=o,g}equals(A,t,i){return i.comparator?i.comparator(A,t):A===t||!!i.ignoreCase&&A.toLowerCase()===t.toLowerCase()}removeEmpty(A){const t=[];for(let i=0;i<A.length;i++)A[i]&&t.push(A[i]);return t}castInput(A,t){return A}tokenize(A,t){return Array.from(A)}join(A){return A.join("")}postProcess(A,t){return A}get useLongestToken(){return!1}buildValues(A,t,i){const r=[];let n;for(;A;)r.push(A),n=A.previousComponent,delete A.previousComponent,A=n;r.reverse();const a=r.length;let s=0,o=0,g=0;for(;s<a;s++){const l=r[s];if(l.removed)l.value=this.join(i.slice(g,g+l.count)),g+=l.count;else{if(!l.added&&this.useLongestToken){let I=t.slice(o,o+l.count);I=I.map(function(C,E){const B=i[g+E];return B.length>C.length?B:C}),l.value=this.join(I)}else l.value=this.join(t.slice(o,o+l.count));o+=l.count,l.added||(g+=l.count)}}return r}}class O4A extends G4A{constructor(){super(...arguments),this.tokenize=Y4A}equals(A,t,i){return i.ignoreWhitespace?((!i.newlineIsToken||!A.includes(`
501
501
  `))&&(A=A.trim()),(!i.newlineIsToken||!t.includes(`
502
502
  `))&&(t=t.trim())):i.ignoreNewlineAtEof&&!i.newlineIsToken&&(A.endsWith(`
503
503
  `)&&(A=A.slice(0,-1)),t.endsWith(`
@@ -844,7 +844,7 @@ export const CursorOverlay: React.FC<CursorOverlayProps> = ({
844
844
  ---
845
845
 
846
846
  **Target:** Ship MVP in next sprint
847
- `;function wKA({blocks:e,annotations:A,addAnnotation:t,removeAnnotation:i}){const[r,n]=cA.useState(new Map),a=cA.useRef(e);a.current=e;const s=cA.useRef(A);s.current=A,cA.useEffect(()=>{if(r.size===0)return;const l=new Set(e.map(C=>C.id)),I=[...r.keys()].filter(C=>!l.has(C));I.length>0&&n(C=>{const E=new Map(C);return I.forEach(B=>E.delete(B)),E})},[e]);const o=cA.useCallback((l,I)=>{const C=a.current,E=s.current,B=C.find(Q=>Q.id===l);if(B&&I===B.checked)n(f=>{const m=new Map(f);return m.delete(l),m}),E.filter(f=>f.blockId===l&&f.id.startsWith("ann-checkbox-")).forEach(f=>i(f.id));else if(E.filter(f=>f.blockId===l&&f.id.startsWith("ann-checkbox-")).forEach(f=>i(f.id)),n(f=>{const m=new Map(f);return m.set(l,I),m}),B){const f=C.indexOf(B);let m="";for(let x=f-1;x>=0;x--)if(C[x].type==="heading"){m=C[x].content;break}const y=I?"Mark as completed":"Mark as not completed",v=m?` (under "${m}")`:` (line ${B.startLine})`,S={id:`ann-checkbox-${l}-${Date.now()}`,blockId:l,startOffset:0,endOffset:B.content.length,type:li.COMMENT,text:`${y}${v}: ${B.content}`,originalText:B.content,createdA:Date.now()};t(S)}},[t,i]),g=cA.useCallback(l=>{n(I=>{const C=new Map(I);return C.delete(l),C})},[]);return{overrides:r,toggle:o,revertOverride:g}}const vKA=()=>{const[e,A]=cA.useState(DKA),[t,i]=cA.useState([]),[r,n]=cA.useState(null),[a,s]=cA.useState([]),[o,g]=cA.useState(null),[l,I]=cA.useState(!1),[C,E]=cA.useState(!1),[B,h]=cA.useState(!1),[Q,f]=cA.useState(!1),[m,y]=cA.useState(!1),[v,S]=cA.useState(""),[x,R]=cA.useState(()=>window.innerWidth>=768),[b,N]=cA.useState(!1),[F,L]=cA.useState(h4A),[K,H]=cA.useState(p4A),[k,U]=cA.useState(()=>qe.getItem("plannotator-tater-mode")==="true"),[O,T]=cA.useState(()=>HG()),[G,P]=cA.useState(!1),[q,Y]=cA.useState(null),[V,j]=cA.useState(),[AA,X]=cA.useState(!1),[sA,nA]=cA.useState([]),[hA,rA]=cA.useState(!1),[oA,gA]=cA.useState(null),[aA,uA]=cA.useState(void 0),[CA,LA]=cA.useState(!0),[BA,VA]=cA.useState(!1),[tA,ne]=cA.useState(null),[RA,ce]=cA.useState(null),[Ie,Qe]=cA.useState(!1),[OA,ie]=cA.useState("bypassPermissions"),[YA,ZA]=cA.useState(!0),[ae,NA]=cA.useState(void 0),[XA,EA]=cA.useState(void 0),[vA,Z]=cA.useState(null),[mA,pA]=cA.useState(null);cA.useEffect(()=>{document.title=vA?`${vA.display} · Plannotator`:"Plannotator"},[vA]);const[kA,MA]=cA.useState(!1),[TA,dA]=cA.useState(),[wA,PA]=cA.useState(null),[_A,Ee]=cA.useState(!1),[yA,UA]=cA.useState("clean"),[KA,te]=cA.useState(null),[Ge,Se]=cA.useState(null),eA=cA.useRef(null),le=cA.useRef(null);v4A();const se=iW({storageKey:"plannotator-panel-width"}),ve=iW({storageKey:"plannotator-toc-width",defaultWidth:240,minWidth:160,maxWidth:400,side:"left"}),ke=se.isDragging||ve.isDragging,Le=F4A(HG().tocEnabled);cA.useEffect(()=>{O.tocEnabled?Le.open("toc"):Le.close()},[O.tocEnabled]),cA.useEffect(()=>{Le.activeTab==="toc"&&_A&&Ee(!1)},[Le.activeTab]),cA.useEffect(()=>{if(!_A)return;const ee=Ue=>{Ue.key==="Escape"&&Ee(!1)};return document.addEventListener("keydown",ee),()=>document.removeEventListener("keydown",ee)},[_A]);const Re=P4A(e,KA,Ge),Ne=J4A({markdown:e,annotations:t,selectedAnnotationId:r,globalAttachments:sA,setMarkdown:A,setAnnotations:i,setSelectedAnnotationId:n,setGlobalAttachments:nA,viewerRef:eA,sidebar:Le}),it=j4A({markdown:e,viewerRef:eA,linkedDocHook:Ne,setMarkdown:A,setAnnotations:i,setSelectedAnnotationId:n,setSubmitted:ne}),ze=z4A(),It=cA.useMemo(()=>_OA(),[O]),bt=cA.useMemo(()=>{if(!It)return"";const ee=iI();return rI(ee)},[It,O]);cA.useEffect(()=>{It||ze.setActiveFile(null)},[It]),cA.useEffect(()=>{Le.activeTab==="vault"&&It&&bt&&ze.tree.length===0&&!ze.isLoading&&ze.fetchTree(bt)},[Le.activeTab,It,bt]);const Tt=Yn.useCallback(ee=>Ue=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(ee)}&path=${encodeURIComponent(Ue)}`,[]),yt=Yn.useCallback(ee=>{Ne.open(ee,Tt(bt)),ze.setActiveFile(ee)},[bt,Ne,ze,Tt]),pt=tKA(),Ii=cA.useMemo(()=>!!mA||Vq(),[mA,O]),Pe=cA.useMemo(()=>{const ee=mA?[mA]:[],Ue=Vq()?l4().directories:[];return[...new Set([...ee,...Ue])]},[mA,O]);cA.useEffect(()=>{Ii||pt.setActiveFile(null)},[Ii]),cA.useEffect(()=>{if(Le.activeTab==="files"&&Ii&&Pe.length>0){const ee=pt.dirs.map(ot=>ot.path);(Pe.length!==ee.length||Pe.some(ot=>!ee.includes(ot)))&&pt.fetchAll(Pe)}},[Le.activeTab,Ii,Pe]);const zA=Yn.useCallback((ee,Ue)=>{const ot=kt=>`/api/doc?path=${encodeURIComponent(kt)}&base=${encodeURIComponent(Ue)}`;Ne.open(ee,ot,"files"),pt.setActiveFile(ee),ze.setActiveFile(null)},[Ne,pt]),be=Yn.useCallback(ee=>{if(ze.activeFile&&bt)Ne.open(ee,Tt(bt));else if(pt.activeFile&&pt.activeDirPath){const Ue=Ne.filepath?.replace(/\/[^/]+$/,"")||pt.activeDirPath;Ne.open(ee,ot=>`/api/doc?path=${encodeURIComponent(ot)}&base=${encodeURIComponent(Ue)}`)}else{const Ue=Ne.filepath?Ne.filepath.replace(/\/[^/]+$/,""):aA;Ue?Ne.open(ee,ot=>`/api/doc?path=${encodeURIComponent(ot)}&base=${encodeURIComponent(Ue)}`):Ne.open(ee)}},[ze.activeFile,bt,pt.activeFile,pt.activeDirPath,Ne,Tt,aA]),_e=Yn.useCallback(()=>{Ne.back(),ze.setActiveFile(null),pt.setActiveFile(null),it.clearSelection()},[Ne,ze,pt,it]),Jt=Yn.useCallback(()=>{ze.fetchTree(bt)},[ze,bt]),si=cA.useMemo(()=>a.filter(ee=>ee.type==="heading").length,[a]),Ct=a4A(le,si),{editorAnnotations:ei,deleteEditorAnnotation:Zi}=X4A(),{externalAnnotations:ri,updateExternalAnnotation:Te,deleteExternalAnnotation:ye}=eKA({enabled:G}),De=cA.useMemo(()=>ri.length===0?t:[...t.filter(Ue=>Ue.source?!ri.some(ot=>ot.source===Ue.source&&ot.type===Ue.type&&ot.originalText===Ue.originalText):!0),...ri],[t,ri]),Me=cA.useMemo(()=>De.filter(ee=>!!ee.diffContext),[De]),me=cA.useMemo(()=>De.filter(ee=>!ee.diffContext),[De]),{isSharedSession:nt,isLoadingShared:xA,shareUrl:di,shareUrlSize:FA,shortShareUrl:Ut,isGeneratingShortUrl:As,shortUrlError:es,pendingSharedAnnotations:Fn,clearPendingSharedAnnotations:ts,generateShortUrl:nr,importFromShareUrl:ar,shareLoadError:Na,clearShareLoadError:Ea}=i4A(e,De,sA,A,i,nA,()=>{LA(!1)},ae,XA),{draftBanner:Gn,restoreDraft:sr,dismissDraft:vs}=Z4A({annotations:De,globalAttachments:sA,isApiMode:G,isSharedSession:nt,submitted:!!tA}),or=Yn.useCallback(()=>{const{annotations:ee,globalAttachments:Ue}=sr();ee.length>0&&(i(ee),Ue.length>0&&nA(Ue),setTimeout(()=>{eA.current?.applySharedAnnotations(ee.filter(ot=>!ot.diffContext))},100))},[sr]),{getAgentWarning:Et}=MoA(q);cA.useEffect(()=>{if(Fn&&Fn.length>0){const ee=setTimeout(()=>{eA.current?.clearAllHighlights(),eA.current?.applySharedAnnotations(Fn.filter(Ue=>!Ue.diffContext)),ts()},100);return()=>clearTimeout(ee)}},[Fn,ts]);const Rt=ee=>{U(ee),qe.setItem("plannotator-tater-mode",String(ee))},Oi=ee=>{L(ee),Q4A(ee)},Xt=ee=>{H(ee),m4A(ee)};w4A(K,Xt),cA.useEffect(()=>{xA||nt||fetch("/api/plan").then(ee=>{if(!ee.ok)throw new Error("Not in API mode");return ee.json()}).then(ee=>{Gs.init(ee.serverConfig),j(ee.serverConfig?.gitUser),ee.mode==="archive"?(A(ee.plan||""),ee.archivePlans&&it.init(ee.archivePlans),it.fetchPlans(),ZA(!1),Le.open("archive")):ee.mode==="annotate-folder"?A(""):ee.plan&&A(ee.plan),P(!0),(ee.mode==="annotate"||ee.mode==="annotate-last"||ee.mode==="annotate-folder")&&rA(!0),ee.mode==="annotate-folder"&&Le.open("files"),ee.mode&&ee.mode!=="archive"&&gA(ee.mode==="annotate-last"?"message":ee.mode==="annotate-folder"?"folder":"file"),ee.filePath&&uA(ee.mode==="annotate-folder"?ee.filePath:ee.filePath.replace(/\/[^/]+$/,"")),ee.sharingEnabled!==void 0&&ZA(ee.sharingEnabled),ee.shareBaseUrl&&NA(ee.shareBaseUrl),ee.pasteApiUrl&&EA(ee.pasteApiUrl),ee.repoInfo&&Z(ee.repoInfo),ee.projectRoot&&pA(ee.projectRoot),ee.previousPlan!==void 0&&te(ee.previousPlan),ee.versionInfo&&Se(ee.versionInfo),ee.origin&&(Y(ee.origin),ee.origin==="claude-code"&&yUA()&&Qe(!0),ie(SoA().mode)),ee.isWSL&&X(!0)}).catch(()=>{P(!1)}).finally(()=>LA(!1))},[xA,nt]),cA.useEffect(()=>{const{frontmatter:ee}=MAA(e);g(ee),s(kAA(e))},[e]);const xr=cA.useRef(!1),Yi=cA.useRef({}),tn=cA.useRef(null);cA.useEffect(()=>{xr.current=!1,Yi.current={},tn.current=null},[e]),cA.useEffect(()=>{if(!G||!e||nt||hA||it.archiveMode||xr.current)return;const ee={},Ue=[],ot=iI();if(ot.autoSave&&ot.enabled){const Cr=rI(ot);Cr&&(ee.obsidian={vaultPath:Cr,folder:ot.folder||"plannotator",plan:e,...ot.filenameFormat&&{filenameFormat:ot.filenameFormat},...ot.filenameSeparator&&ot.filenameSeparator!=="space"&&{filenameSeparator:ot.filenameSeparator}},Ue.push("Obsidian"))}const kt=Zc();kt.autoSave&&kt.enabled&&(ee.bear={plan:e,customTags:kt.customTags,tagPosition:kt.tagPosition},Ue.push("Bear"));const pi=wB();if(pi.autoSave&&Vh()&&(ee.octarine={plan:e,workspace:pi.workspace,folder:pi.folder||"plannotator"},Ue.push("Octarine")),Ue.length===0)return;xr.current=!0;const fr=fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ee)}).then(Cr=>Cr.json()).then(Cr=>{const Lo={...ee.obsidian?{obsidian:!!Cr.results?.obsidian?.success}:{},...ee.bear?{bear:!!Cr.results?.bear?.success}:{},...ee.octarine?{octarine:!!Cr.results?.octarine?.success}:{}};Yi.current=Lo;const nC=Ue.filter(aC=>!Cr.results?.[aC.toLowerCase()]?.success);return nC.length===0?PA({type:"success",message:`Auto-saved to ${Ue.join(" & ")}`}):PA({type:"error",message:`Auto-save failed for ${nC.join(" & ")}`}),Lo}).catch(()=>(Yi.current={},PA({type:"error",message:"Auto-save failed"}),{})).finally(()=>setTimeout(()=>PA(null),3e3));tn.current=fr},[G,e,nt,hA]),cA.useEffect(()=>{const ee=Ue=>{const ot=Ue.clipboardData?.items;if(ot){for(const kt of ot)if(kt.type.startsWith("image/")){Ue.preventDefault();const pi=kt.getAsFile();if(pi){const fr=NF(pi.name,sA.map(Lo=>Lo.name)),Cr=URL.createObjectURL(pi);ce({file:pi,blobUrl:Cr,initialName:fr})}break}}};return document.addEventListener("paste",ee),()=>document.removeEventListener("paste",ee)},[sA]);const rn=async(ee,Ue,ot)=>{if(RA)try{const kt=new FormData,pi=Ue?new File([ee],"annotated.png",{type:"image/png"}):RA.file;kt.append("file",pi);const fr=await fetch("/api/upload",{method:"POST",body:kt});if(fr.ok){const Cr=await fr.json();nA(Lo=>[...Lo,{path:Cr.path,name:ot}])}}catch{}finally{URL.revokeObjectURL(RA.blobUrl),ce(null)}},Ve=()=>{RA&&(URL.revokeObjectURL(RA.blobUrl),ce(null))},z=async()=>{VA(!0);try{const ee=iI(),Ue=Zc(),ot=wB(),kt=o4(),pi=rv(),fr=Ue.autoSave&&tn.current?await tn.current:Yi.current,Cr={};q==="claude-code"&&(Cr.permissionMode=OA);const Lo=QUA(kt);Lo&&(Cr.agentSwitch=Lo),Cr.planSave={enabled:pi.enabled,...pi.customPath&&{customPath:pi.customPath}};const nC=rI(ee);ee.enabled&&nC&&(Cr.obsidian={vaultPath:nC,folder:ee.folder||"plannotator",plan:e,...ee.filenameFormat&&{filenameFormat:ee.filenameFormat},...ee.filenameSeparator&&ee.filenameSeparator!=="space"&&{filenameSeparator:ee.filenameSeparator}}),Ue.enabled&&!(Ue.autoSave&&fr.bear)&&(Cr.bear={plan:e,customTags:Ue.customTags,tagPosition:Ue.tagPosition}),Vh()&&(Cr.octarine={plan:e,workspace:ot.workspace,folder:ot.folder||"plannotator"});const aC=Array.from(Ne.getDocAnnotations().values()).some(mp=>mp.annotations.length>0||mp.globalAttachments.length>0);(De.length>0||sA.length>0||aC||ei.length>0)&&(Cr.feedback=Bt),await fetch("/api/approve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Cr)}),ne("approved")}catch{VA(!1)}},_=async()=>{VA(!0);try{const ee=rv();await fetch("/api/deny",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:Bt,planSave:{enabled:ee.enabled,...ee.customPath&&{customPath:ee.customPath}}})}),ne("denied")}catch{VA(!1)}},IA=async()=>{VA(!0);try{await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:Bt,annotations:De})}),ne("denied")}catch{VA(!1)}};cA.useEffect(()=>{const ee=Ue=>{if(Ue.key!=="Enter"||!(Ue.metaKey||Ue.ctrlKey))return;const ot=Ue.target?.tagName;if(ot==="INPUT"||ot==="TEXTAREA"||l||C||B||Q||m||Ie||RA||tA||BA||!G||Ne.isActive)return;if(Ue.preventDefault(),hA){IA();return}const kt=Ne.getDocAnnotations(),pi=Array.from(kt.values()).some(fr=>fr.annotations.length>0||fr.globalAttachments.length>0);if(De.length===0&&ei.length===0&&!pi){if(q==="opencode"){const fr=Et();if(fr){S(fr),y(!0);return}}z()}else _()};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[l,C,B,Q,m,Ie,RA,tA,BA,G,Ne.isActive,t.length,ri.length,hA,q,Et]);const DA=ee=>{i(Ue=>[...Ue,ee]),n(ee.id),R(!0)},GA=Yn.useCallback(ee=>{n(ee),ee&&window.innerWidth<768&&R(!0)},[]),jA=ee=>{eA.current?.removeHighlight(ee),i(Ue=>Ue.filter(ot=>ot.id!==ee)),r===ee&&n(null)},ge=wKA({blocks:a,annotations:t,addAnnotation:DA,removeAnnotation:jA}),fe=ee=>{const Ue=De.find(ot=>ot.id===ee);if(Ue?.source&&ri.some(ot=>ot.id===ee)){ye(ee),r===ee&&n(null);return}ee.startsWith("ann-checkbox-")&&Ue&&ge.revertOverride(Ue.blockId),jA(ee)},Xe=(ee,Ue)=>{if(De.find(kt=>kt.id===ee)?.source&&ri.some(kt=>kt.id===ee)){Te(ee,Ue);return}i(kt=>kt.map(pi=>pi.id===ee?{...pi,...Ue}:pi))},zt=(ee,Ue)=>{i(ot=>ot.map(kt=>kt.author===ee?{...kt,author:Ue}:kt))},Kt=ee=>{nA(Ue=>[...Ue,ee])},ti=ee=>{nA(Ue=>Ue.filter(ot=>ot.path!==ee))},$t=ee=>{},Bt=cA.useMemo(()=>{const ee=Ne.getDocAnnotations(),Ue=Array.from(ee.values()).some(fr=>fr.annotations.length>0||fr.globalAttachments.length>0),ot=De.length>0||sA.length>0,kt=ei.length>0;if(!ot&&!Ue&&!kt)return"User reviewed the document and has no feedback.";let pi=ot?EfA(a,De,sA,oA==="message"?"Message Feedback":oA==="folder"?"Folder Feedback":oA==="file"?"File Feedback":"Plan Feedback",oA??"plan"):"";return Ue&&(pi+=ufA(ee)),kt&&(pi+=BfA(ei)),pi},[a,De,sA,Ne.getDocAnnotations,ei]),Nt=Yn.useMemo(()=>r4A(),[]),Ui=Yn.useCallback(async ee=>{if(!(!Nt||BA||!di)){VA(!0);try{const Ue=await n4A(ee,Nt,di);Ue&&(PA(Ue),setTimeout(()=>PA(null),4e3),Ue.type==="success"&&ne(ee===BD.Approve?"approved":"denied"))}finally{VA(!1)}}},[Nt,BA,di]),On=Yn.useCallback(()=>Ui(BD.Approve),[Ui]),Un=Yn.useCallback(()=>Ui(BD.Feedback),[Ui]),Hi=()=>{MA(!1);const ee=new Blob([Bt],{type:"text/plain"}),Ue=URL.createObjectURL(ee),ot=document.createElement("a");ot.href=Ue,ot.download="annotations.md",ot.click(),URL.revokeObjectURL(Ue),PA({type:"success",message:"Downloaded annotations"}),setTimeout(()=>PA(null),3e3)},Ir=async ee=>{MA(!1);const Ue={};if(ee==="obsidian"){const kt=iI(),pi=rI(kt);pi&&(Ue.obsidian={vaultPath:pi,folder:kt.folder||"plannotator",plan:e,...kt.filenameFormat&&{filenameFormat:kt.filenameFormat},...kt.filenameSeparator&&kt.filenameSeparator!=="space"&&{filenameSeparator:kt.filenameSeparator}})}if(ee==="bear"){const kt=Zc();Ue.bear={plan:e,customTags:kt.customTags,tagPosition:kt.tagPosition}}if(ee==="octarine"){const kt=wB();Ue.octarine={plan:e,workspace:kt.workspace,folder:kt.folder||"plannotator"}}const ot=ee==="obsidian"?"Obsidian":ee==="bear"?"Bear":"Octarine";try{const fr=(await(await fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ue)})).json()).results?.[ee];fr?.success?PA({type:"success",message:`Saved to ${ot}`}):PA({type:"error",message:fr?.error||"Save failed"})}catch{PA({type:"error",message:"Save failed"})}setTimeout(()=>PA(null),3e3)};cA.useEffect(()=>{const ee=Ue=>{if(Ue.key!=="s"||!(Ue.metaKey||Ue.ctrlKey))return;const ot=Ue.target?.tagName;if(ot==="INPUT"||ot==="TEXTAREA"||l||B||Q||m||Ie||RA||tA||!G)return;Ue.preventDefault();const kt=NoA(),pi=Ux(),fr=Zc().enabled,Cr=Vh();kt==="download"?Hi():kt==="obsidian"&&pi?Ir("obsidian"):kt==="bear"&&fr?Ir("bear"):kt==="octarine"&&Cr?Ir("octarine"):(dA("notes"),I(!0))};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[l,B,Q,m,Ie,RA,tA,G,e,Bt]),cA.useEffect(()=>{const ee=Ue=>{if(Ue.key!=="p"||!(Ue.metaKey||Ue.ctrlKey))return;const ot=Ue.target?.tagName;ot==="INPUT"||ot==="TEXTAREA"||l||B||Q||m||Ie||RA||tA||(Ue.preventDefault(),window.print())};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[l,B,Q,m,Ie,RA,tA]),cA.useEffect(()=>{if(!kA)return;const ee=Ue=>{Ue.target.closest("[data-export-dropdown]")||MA(!1)};return document.addEventListener("pointerdown",ee),()=>document.removeEventListener("pointerdown",ee)},[kA]);const Qn=cA.useMemo(()=>cfA(q),[q]),nn=cA.useMemo(()=>({compact:832,default:1040,wide:1280})[O.planWidth]??832,[O.planWidth]);return w.jsx(iUA,{defaultTheme:"dark",children:w.jsxs("div",{"data-print-region":"root",className:"h-screen flex flex-col bg-background overflow-hidden",children:[w.jsxs("header",{className:"h-12 flex items-center justify-between px-2 md:px-4 border-b border-border/50 bg-card/50 backdrop-blur-xl sticky top-0 z-[50]",children:[w.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[w.jsx("a",{href:"https://plannotator.ai",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 md:gap-2 hover:opacity-80 transition-opacity",children:w.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Plannotator"})}),w.jsxs("a",{href:"https://github.com/backnotprop/plannotator/releases",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground font-mono opacity-60 hidden md:inline hover:opacity-100 transition-opacity",children:["v","0.16.0"]}),q&&w.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium hidden md:inline ${IfA(q)}`,children:Qn})]}),w.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[Nt&&!G&&nt&&w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"}),w.jsx(jq,{onClick:Un,disabled:BA||!di,isLoading:BA,title:"Send feedback to bot"}),w.jsx(_q,{onClick:On,disabled:BA||!di,isLoading:BA,title:"Approve design and notify bot"})]}),G&&!Ne.isActive&&it.archiveMode&&w.jsxs(w.Fragment,{children:[w.jsxs("button",{onClick:it.copy,className:"px-2.5 py-1 rounded-md text-xs font-medium transition-all bg-muted text-foreground hover:bg-muted/80 border border-border",title:"Copy plan content",children:[w.jsx("span",{className:"hidden md:inline",children:"Copy"}),w.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})]}),w.jsx("button",{onClick:it.done,className:"px-2.5 py-1 rounded-md text-xs font-medium transition-all bg-success text-success-foreground hover:opacity-90",title:"Close archive",children:"Done"})]}),G&&!Ne.isActive&&!it.archiveMode&&w.jsxs(w.Fragment,{children:[w.jsx(jq,{onClick:()=>{if(hA){IA();return}const ee=Ne.getDocAnnotations(),Ue=Array.from(ee.values()).some(ot=>ot.annotations.length>0||ot.globalAttachments.length>0);De.length===0&&ei.length===0&&!Ue?h(!0):_()},disabled:BA,isLoading:BA,label:hA?De.length>0||ei.length>0||Ne.docAnnotationCount>0?"Send Annotations":"Done":"Send Feedback",title:hA?De.length>0||ei.length>0||Ne.docAnnotationCount>0?"Send Annotations":"Done":"Send Feedback"}),!hA&&w.jsxs("div",{className:"relative group/approve",children:[w.jsx(_q,{onClick:()=>{if(q==="claude-code"&&De.length>0){f(!0);return}if(q==="opencode"){const ee=Et();if(ee){S(ee),y(!0);return}}z()},disabled:BA,isLoading:BA,dimmed:q==="claude-code"&&De.length>0}),q==="claude-code"&&De.length>0&&w.jsxs("div",{className:"absolute top-full right-0 mt-2 px-3 py-2 bg-popover border border-border rounded-lg shadow-xl text-xs text-foreground w-56 text-center opacity-0 invisible group-hover/approve:opacity-100 group-hover/approve:visible transition-all pointer-events-none z-50",children:[w.jsx("div",{className:"absolute bottom-full right-4 border-4 border-transparent border-b-border"}),w.jsx("div",{className:"absolute bottom-full right-4 mt-px border-4 border-transparent border-b-popover"}),Qn," doesn't support feedback on approval. Your annotations won't be seen."]})]}),w.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"})]}),w.jsxs("div",{className:"hidden md:flex items-center gap-2",children:[w.jsx(rUA,{}),!Ne.isActive&&w.jsx(jUA,{taterMode:k,onTaterModeChange:Rt,onIdentityChange:zt,origin:q,onUIPreferencesChange:T,externalOpen:b,onExternalClose:()=>N(!1),gitUser:V}),w.jsx("button",{onClick:()=>R(!x),className:`p-1.5 rounded-md text-xs font-medium transition-all ${x?"bg-primary/15 text-primary":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})}),w.jsxs("div",{className:"relative flex","data-export-dropdown":!0,children:[w.jsx("button",{onClick:()=>{dA(void 0),I(!0)},className:"px-2.5 py-1 rounded-l-md text-xs font-medium bg-muted hover:bg-muted/80 transition-colors",title:"Export",children:"Export"}),w.jsx("button",{onClick:()=>MA(ee=>!ee),className:"px-1.5 rounded-r-md text-xs bg-muted hover:bg-muted/80 border-l border-border/50 transition-colors flex items-center",title:"Quick save options",children:w.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}),kA&&w.jsxs("div",{className:"absolute top-full right-0 mt-1 w-48 bg-popover border border-border rounded-lg shadow-xl z-50 py-1",children:[YA&&w.jsxs("button",{onClick:async()=>{MA(!1);try{await navigator.clipboard.writeText(di),PA({type:"success",message:"Share link copied"})}catch{PA({type:"error",message:"Failed to copy"})}setTimeout(()=>PA(null),3e3)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),"Copy Share Link"]}),w.jsxs("button",{onClick:Hi,className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),"Download Annotations"]}),w.jsxs("button",{onClick:()=>{MA(!1),window.print()},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"})}),"Print Plan",w.jsxs("span",{className:"ml-auto text-[10px] text-muted-foreground/60",children:[cs,"+P"]})]}),w.jsx("div",{className:"my-1 border-t border-border"}),G&&Ux()&&w.jsxs("button",{onClick:()=>Ir("obsidian"),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),"Save to Obsidian"]}),G&&Zc().enabled&&w.jsxs("button",{onClick:()=>Ir("bear"),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),"Save to Bear"]}),G&&Vh()&&w.jsxs("button",{onClick:()=>Ir("octarine"),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),"Save to Octarine"]}),G&&!Ux()&&!Zc().enabled&&!Vh()&&w.jsx("div",{className:"px-3 py-2 text-[10px] text-muted-foreground",children:"No notes apps configured."}),YA&&w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"my-1 border-t border-border"}),w.jsxs("button",{onClick:()=>{MA(!1),E(!0)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4M10 17l5-5-5-5M15 12H3"})}),"Import Review"]})]})]})]})]}),w.jsx(S4A,{className:"md:hidden",isPanelOpen:x,onTogglePanel:()=>R(!x),annotationCount:De.length+ei.length,onOpenExport:()=>{dA(void 0),I(!0)},onOpenSettings:()=>N(!0),onDownloadAnnotations:Hi,onCopyShareLink:async()=>{try{await navigator.clipboard.writeText(di),PA({type:"success",message:"Share link copied"})}catch{PA({type:"error",message:"Failed to copy"})}setTimeout(()=>PA(null),3e3)},onOpenImport:()=>E(!0),onPrint:()=>window.print(),sharingEnabled:YA})]})]}),Ne.error&&w.jsxs("div",{className:"bg-destructive/10 border-b border-destructive/20 px-4 py-2 flex items-center gap-2 flex-shrink-0",children:[w.jsx("span",{className:"text-xs text-destructive",children:Ne.error}),w.jsx("button",{onClick:Ne.dismissError,className:"ml-auto text-xs text-destructive/60 hover:text-destructive",children:"dismiss"})]}),w.jsxs("div",{"data-print-region":"content",className:`flex-1 flex overflow-hidden relative z-0 ${ke?"select-none":""}`,children:[k&&w.jsx(EUA,{}),!Le.isOpen&&w.jsx(iKA,{activeTab:Le.activeTab,onToggleTab:Le.toggleTab,hasDiff:Re.hasPreviousVersion,showFilesTab:Ii&&!it.archiveMode,showVaultTab:It,className:"hidden lg:flex"}),Le.isOpen&&w.jsxs(w.Fragment,{children:[w.jsx(uKA,{activeTab:Le.activeTab,onTabChange:ee=>{Le.toggleTab(ee),ee==="archive"&&!it.archiveMode&&it.fetchPlans()},onClose:Le.close,width:ve.width,blocks:a,annotations:t,activeSection:Ct,onTocNavigate:$t,linkedDocFilepath:Ne.filepath,onLinkedDocBack:Ne.isActive?_e:void 0,showFilesTab:Ii&&!it.archiveMode,fileBrowser:pt,onFilesSelectFile:zA,onFilesFetchAll:()=>pt.fetchAll(Pe),showVaultTab:It&&!it.archiveMode,vaultPath:bt,vaultBrowser:ze,onVaultSelectFile:yt,onVaultFetchTree:Jt,versionInfo:Ge,versions:Re.versions,selectedBaseVersion:Re.diffBaseVersion,onSelectBaseVersion:Re.selectBaseVersion,isPlanDiffActive:_A,hasPreviousVersion:Re.hasPreviousVersion,onActivatePlanDiff:()=>Ee(!0),isLoadingVersions:Re.isLoadingVersions,isSelectingVersion:Re.isSelectingVersion,fetchingVersion:Re.fetchingVersion,onFetchVersions:Re.fetchVersions,showArchiveTab:G&&!hA,archivePlans:it.plans,selectedArchiveFile:it.selectedFile,onArchiveSelect:it.select,isLoadingArchive:it.isLoading}),w.jsx(rW,{...ve.handleProps,className:"hidden lg:block",side:"left"})]}),w.jsxs("main",{"data-print-region":"document",ref:le,className:"flex-1 min-w-0 overflow-y-auto bg-grid",children:[w.jsx(Zh,{isOpen:!!Gn,onClose:vs,onConfirm:or,title:"Draft Recovered",message:Gn?`Found ${Gn.count} annotation${Gn.count!==1?"s":""} from ${Gn.timeAgo}. Would you like to restore them?`:"",confirmText:"Restore",cancelText:"Dismiss",showCancel:!0}),w.jsxs("div",{className:"min-h-full flex flex-col items-center px-2 py-3 md:px-10 md:py-8 xl:px-16 relative z-10",children:[!_A&&!it.archiveMode&&w.jsx("div",{"data-print-hide":!0,className:"w-full mb-3 md:mb-4 flex items-center justify-start",style:{maxWidth:nn},children:w.jsx(oUA,{inputMethod:K,onInputMethodChange:Xt,mode:F,onModeChange:Oi,taterMode:k})}),Re.diffBlocks&&Re.diffStats&&w.jsx("div",{className:"w-full flex justify-center",style:{display:_A?void 0:"none"},children:w.jsx(yKA,{diffBlocks:Re.diffBlocks,diffStats:Re.diffStats,diffMode:yA,onDiffModeChange:UA,onPlanDiffToggle:()=>Ee(!1),repoInfo:vA,baseVersionLabel:Re.diffBaseVersion!=null?`v${Re.diffBaseVersion}`:void 0,baseVersion:Re.diffBaseVersion??void 0,maxWidth:nn,annotations:Me,onAddAnnotation:DA,onSelectAnnotation:GA,selectedAnnotationId:r,mode:F})}),oA==="folder"&&!e&&!Ne.isActive&&w.jsx("div",{className:"w-full flex justify-center",children:w.jsxs("div",{className:"w-full max-w-3xl p-12 text-center text-muted-foreground",children:[w.jsx("p",{className:"text-lg font-medium mb-2",children:"Select a file to annotate"}),w.jsx("p",{className:"text-sm",children:"Pick a markdown file from the sidebar to begin."})]})}),w.jsx("div",{className:"w-full flex justify-center",style:{display:_A&&Re.diffBlocks||oA==="folder"&&!e&&!Ne.isActive?"none":void 0},children:w.jsx(KOA,{ref:eA,blocks:a,markdown:e,frontmatter:o,annotations:me,onAddAnnotation:DA,onSelectAnnotation:GA,selectedAnnotationId:r,mode:F,inputMethod:K,taterMode:k,globalAttachments:sA,onAddGlobalAttachment:Kt,onRemoveGlobalAttachment:ti,repoInfo:vA,stickyActions:O.stickyActionsEnabled,planDiffStats:Ne.isActive?null:Re.diffStats,isPlanDiffActive:_A,onPlanDiffToggle:()=>Ee(!_A),hasPreviousVersion:!Ne.isActive&&Re.hasPreviousVersion,showDemoBadge:!G&&!xA&&!nt,maxWidth:nn,onOpenLinkedDoc:be,linkedDocInfo:Ne.isActive?{filepath:Ne.filepath,onBack:_e,label:ze.activeFile?"Vault File":pt.activeFile?"File":void 0}:null,imageBaseDir:aA,copyLabel:oA==="message"?"Copy message":oA==="file"||oA==="folder"?"Copy file":void 0,archiveInfo:it.currentInfo,onToggleCheckbox:ge.toggle,checkboxOverrides:ge.overrides},Ne.isActive?`doc:${Ne.filepath}`:"plan")})]})]}),x&&w.jsx(rW,{...se.handleProps,className:"hidden md:block",side:"right"}),w.jsx(qOA,{isOpen:x,blocks:a,annotations:De,selectedId:r,onSelect:n,onDelete:fe,onEdit:Xe,shareUrl:di,sharingEnabled:YA,width:se.width,editorAnnotations:ei,onDeleteEditorAnnotation:Zi,onClose:()=>R(!1),onQuickCopy:async()=>{await navigator.clipboard.writeText(xAA(Bt))}})]}),w.jsx(eUA,{isOpen:l,onClose:()=>{I(!1),dA(void 0)},shareUrl:di,shareUrlSize:FA,shortShareUrl:Ut,isGeneratingShortUrl:As,shortUrlError:es,onGenerateShortUrl:nr,annotationsOutput:Bt,annotationCount:De.length,taterSprite:k?w.jsx(s4,{}):void 0,sharingEnabled:YA,markdown:e,isApiMode:G,initialTab:TA}),w.jsx(tUA,{isOpen:C,onClose:()=>E(!1),onImport:ar,shareBaseUrl:ae}),w.jsx(Zh,{isOpen:B,onClose:()=>h(!1),title:"Add Annotations First",message:`To provide feedback, select text in the plan and add annotations. ${Qn} will use your annotations to revise the plan.`,variant:"info"}),w.jsx(Zh,{isOpen:Q,onClose:()=>f(!1),onConfirm:()=>{f(!1),z()},title:"Annotations Won't Be Sent",message:w.jsxs(w.Fragment,{children:[Qn," doesn't yet support feedback on approval. Your ",De.length," annotation",De.length!==1?"s":""," will be lost."]}),subMessage:w.jsxs(w.Fragment,{children:["To send feedback, use ",w.jsx("strong",{children:"Send Feedback"})," instead.",w.jsx("br",{}),w.jsx("br",{}),"Want this feature? Upvote these issues:",w.jsx("br",{}),w.jsx("a",{href:"https://github.com/anthropics/claude-code/issues/16001",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"#16001"})," · ",w.jsx("a",{href:"https://github.com/anthropics/claude-code/issues/15755",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"#15755"})]}),confirmText:"Approve Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),w.jsx(Zh,{isOpen:m,onClose:()=>y(!1),onConfirm:()=>{y(!1),z()},title:"Agent Not Found",message:v,subMessage:w.jsxs(w.Fragment,{children:["You can change the agent in ",w.jsx("strong",{children:"Settings"}),", or approve anyway and OpenCode will use the default agent."]}),confirmText:"Approve Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),w.jsx(Zh,{isOpen:!!Na&&!G,onClose:Ea,title:"Shared Plan Could Not Be Loaded",message:Na,subMessage:"You are viewing a demo plan. This is sample content — it is not your data or anyone else's.",variant:"warning"}),wA&&w.jsx("div",{className:`fixed top-16 right-4 z-50 px-3 py-2 rounded-lg text-xs font-medium shadow-lg transition-opacity ${wA.type==="success"?"bg-success/15 text-success border border-success/30":"bg-destructive/15 text-destructive border border-destructive/30"}`,children:wA.message}),w.jsx(l4A,{submitted:tA,title:it.archiveMode?"Archive Closed":tA==="approved"?"Plan Approved":hA?"Annotations Sent":"Feedback Sent",subtitle:it.archiveMode?"You can reopen with plannotator archive.":tA==="approved"?`${Qn} will proceed with the implementation.`:hA?`${Qn} will address your annotations on the ${oA==="message"?"message":oA==="folder"?"files":"file"}.`:`${Qn} will revise the plan based on your annotations.`,agentLabel:Qn}),w.jsx(B4A,{origin:q,isWSL:AA}),w.jsx(JAA,{isOpen:!!RA,imageSrc:RA?.blobUrl??"",initialName:RA?.initialName,onAccept:rn,onClose:Ve}),w.jsx(T4A,{isOpen:Ie,onComplete:ee=>{ie(ee),Qe(!1)}})]})})},ZoA=document.getElementById("root");if(!ZoA)throw new Error("Could not find root element to mount to");const SKA=lfA.createRoot(ZoA);SKA.render(w.jsx(Yn.StrictMode,{children:w.jsx(vKA,{})}));class ls{constructor(A,t,i){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=A,this.start=t,this.end=i}static range(A,t){return t?!A||!A.loc||!t.loc||A.loc.lexer!==t.loc.lexer?null:new ls(A.loc.lexer,A.loc.start,t.loc.end):A&&A.loc}}class Ys{constructor(A,t){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=A,this.loc=t}range(A,t){return new Ys(t,ls.range(this,A))}}class je{constructor(A,t){this.name=void 0,this.position=void 0,this.length=void 0,this.rawMessage=void 0;var i="KaTeX parse error: "+A,r,n,a=t&&t.loc;if(a&&a.start<=a.end){var s=a.lexer.input;r=a.start,n=a.end,r===s.length?i+=" at end of input: ":i+=" at position "+(r+1)+": ";var o=s.slice(r,n).replace(/[^]/g,"$&̲"),g;r>15?g="…"+s.slice(r-15,r):g=s.slice(0,r);var l;n+15<s.length?l=s.slice(n,n+15)+"…":l=s.slice(n),i+=g+o+l}var I=new Error(i);return I.name="ParseError",I.__proto__=je.prototype,I.position=r,r!=null&&n!=null&&(I.length=n-r),I.rawMessage=A,I}}je.prototype.__proto__=Error.prototype;var bKA=function(A,t){return A===void 0?t:A},RKA=/([A-Z])/g,NKA=function(A){return A.replace(RKA,"-$1").toLowerCase()},MKA={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},kKA=/[&><"']/g;function xKA(e){return String(e).replace(kKA,A=>MKA[A])}var joA=function e(A){return A.type==="ordgroup"||A.type==="color"?A.body.length===1?e(A.body[0]):A:A.type==="font"?e(A.body):A},LKA=function(A){var t=joA(A);return t.type==="mathord"||t.type==="textord"||t.type==="atom"},TKA=function(A){if(!A)throw new Error("Expected non-null, but got "+String(A));return A},FKA=function(A){var t=/^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(A);return t?t[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():"_relative"},Ti={deflt:bKA,escape:xKA,hyphenate:NKA,getBaseElem:joA,isCharacterBox:LKA,protocolFromUrl:FKA},mf={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format <type>"},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color <color>",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:e=>"#"+e},macros:{type:"object",cli:"-m, --macro <def>",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(e,A)=>(A.push(e),A)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:"--min-rule-thickness <size>",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:e=>Math.max(0,e),cli:"-s, --max-size <n>",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:e=>Math.max(0,e),cli:"-e, --max-expand <n>",cliProcessor:e=>e==="Infinity"?1/0:parseInt(e)},globalGroup:{type:"boolean",cli:!1}};function GKA(e){if(e.default)return e.default;var A=e.type,t=Array.isArray(A)?A[0]:A;if(typeof t!="string")return t.enum[0];switch(t){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{}}}class I4{constructor(A){this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,A=A||{};for(var t in mf)if(mf.hasOwnProperty(t)){var i=mf[t];this[t]=A[t]!==void 0?i.processor?i.processor(A[t]):A[t]:GKA(i)}}reportNonstrict(A,t,i){var r=this.strict;if(typeof r=="function"&&(r=r(A,t,i)),!(!r||r==="ignore")){if(r===!0||r==="error")throw new je("LaTeX-incompatible input and strict mode is set to 'error': "+(t+" ["+A+"]"),i);r==="warn"?typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(t+" ["+A+"]")):typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+r+"': "+t+" ["+A+"]"))}}useStrictBehavior(A,t,i){var r=this.strict;if(typeof r=="function")try{r=r(A,t,i)}catch{r="error"}return!r||r==="ignore"?!1:r===!0||r==="error"?!0:r==="warn"?(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(t+" ["+A+"]")),!1):(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+r+"': "+t+" ["+A+"]")),!1)}isTrusted(A){if(A.url&&!A.protocol){var t=Ti.protocolFromUrl(A.url);if(t==null)return!1;A.protocol=t}var i=typeof this.trust=="function"?this.trust(A):this.trust;return!!i}}class Hc{constructor(A,t,i){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=A,this.size=t,this.cramped=i}sup(){return Mg[OKA[this.id]]}sub(){return Mg[UKA[this.id]]}fracNum(){return Mg[KKA[this.id]]}fracDen(){return Mg[YKA[this.id]]}cramp(){return Mg[HKA[this.id]]}text(){return Mg[PKA[this.id]]}isTight(){return this.size>=2}}var C4=0,sv=1,SB=2,ql=3,$f=4,fo=5,ed=6,Ya=7,Mg=[new Hc(C4,0,!1),new Hc(sv,0,!0),new Hc(SB,1,!1),new Hc(ql,1,!0),new Hc($f,2,!1),new Hc(fo,2,!0),new Hc(ed,3,!1),new Hc(Ya,3,!0)],OKA=[$f,fo,$f,fo,ed,Ya,ed,Ya],UKA=[fo,fo,fo,fo,Ya,Ya,Ya,Ya],KKA=[SB,ql,$f,fo,ed,Ya,ed,Ya],YKA=[ql,ql,fo,fo,Ya,Ya,Ya,Ya],HKA=[sv,sv,ql,ql,fo,fo,Ya,Ya],PKA=[C4,sv,SB,ql,SB,ql,SB,ql],Gt={DISPLAY:Mg[C4],TEXT:Mg[SB],SCRIPT:Mg[$f],SCRIPTSCRIPT:Mg[ed]},zG=[{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 JKA(e){for(var A=0;A<zG.length;A++)for(var t=zG[A],i=0;i<t.blocks.length;i++){var r=t.blocks[i];if(e>=r[0]&&e<=r[1])return t.name}return null}var dD=[];zG.forEach(e=>e.blocks.forEach(A=>dD.push(...A)));function _oA(e){for(var A=0;A<dD.length;A+=2)if(e>=dD[A]&&e<=dD[A+1])return!0;return!1}var Pu=80,zKA=function(A,t){return"M95,"+(622+A+t)+`
847
+ `;function wKA({blocks:e,annotations:A,addAnnotation:t,removeAnnotation:i}){const[r,n]=cA.useState(new Map),a=cA.useRef(e);a.current=e;const s=cA.useRef(A);s.current=A,cA.useEffect(()=>{if(r.size===0)return;const l=new Set(e.map(C=>C.id)),I=[...r.keys()].filter(C=>!l.has(C));I.length>0&&n(C=>{const E=new Map(C);return I.forEach(B=>E.delete(B)),E})},[e]);const o=cA.useCallback((l,I)=>{const C=a.current,E=s.current,B=C.find(Q=>Q.id===l);if(B&&I===B.checked)n(f=>{const m=new Map(f);return m.delete(l),m}),E.filter(f=>f.blockId===l&&f.id.startsWith("ann-checkbox-")).forEach(f=>i(f.id));else if(E.filter(f=>f.blockId===l&&f.id.startsWith("ann-checkbox-")).forEach(f=>i(f.id)),n(f=>{const m=new Map(f);return m.set(l,I),m}),B){const f=C.indexOf(B);let m="";for(let x=f-1;x>=0;x--)if(C[x].type==="heading"){m=C[x].content;break}const y=I?"Mark as completed":"Mark as not completed",v=m?` (under "${m}")`:` (line ${B.startLine})`,S={id:`ann-checkbox-${l}-${Date.now()}`,blockId:l,startOffset:0,endOffset:B.content.length,type:li.COMMENT,text:`${y}${v}: ${B.content}`,originalText:B.content,createdA:Date.now()};t(S)}},[t,i]),g=cA.useCallback(l=>{n(I=>{const C=new Map(I);return C.delete(l),C})},[]);return{overrides:r,toggle:o,revertOverride:g}}const vKA=()=>{const[e,A]=cA.useState(DKA),[t,i]=cA.useState([]),[r,n]=cA.useState(null),[a,s]=cA.useState([]),[o,g]=cA.useState(null),[l,I]=cA.useState(!1),[C,E]=cA.useState(!1),[B,h]=cA.useState(!1),[Q,f]=cA.useState(!1),[m,y]=cA.useState(!1),[v,S]=cA.useState(""),[x,R]=cA.useState(()=>window.innerWidth>=768),[b,N]=cA.useState(!1),[F,L]=cA.useState(h4A),[K,H]=cA.useState(p4A),[k,U]=cA.useState(()=>qe.getItem("plannotator-tater-mode")==="true"),[O,T]=cA.useState(()=>HG()),[G,P]=cA.useState(!1),[q,Y]=cA.useState(null),[V,j]=cA.useState(),[AA,X]=cA.useState(!1),[sA,nA]=cA.useState([]),[hA,rA]=cA.useState(!1),[oA,gA]=cA.useState(null),[aA,uA]=cA.useState(void 0),[CA,LA]=cA.useState(!0),[BA,VA]=cA.useState(!1),[tA,ne]=cA.useState(null),[RA,ce]=cA.useState(null),[Ie,Qe]=cA.useState(!1),[OA,ie]=cA.useState("bypassPermissions"),[YA,ZA]=cA.useState(!0),[ae,NA]=cA.useState(void 0),[XA,EA]=cA.useState(void 0),[vA,Z]=cA.useState(null),[mA,pA]=cA.useState(null);cA.useEffect(()=>{document.title=vA?`${vA.display} · Plannotator`:"Plannotator"},[vA]);const[kA,MA]=cA.useState(!1),[TA,dA]=cA.useState(),[wA,PA]=cA.useState(null),[_A,Ee]=cA.useState(!1),[yA,UA]=cA.useState("clean"),[KA,te]=cA.useState(null),[Ge,Se]=cA.useState(null),eA=cA.useRef(null),le=cA.useRef(null);v4A();const se=iW({storageKey:"plannotator-panel-width"}),ve=iW({storageKey:"plannotator-toc-width",defaultWidth:240,minWidth:160,maxWidth:400,side:"left"}),ke=se.isDragging||ve.isDragging,Le=F4A(HG().tocEnabled);cA.useEffect(()=>{O.tocEnabled?Le.open("toc"):Le.close()},[O.tocEnabled]),cA.useEffect(()=>{Le.activeTab==="toc"&&_A&&Ee(!1)},[Le.activeTab]),cA.useEffect(()=>{if(!_A)return;const ee=Ue=>{Ue.key==="Escape"&&Ee(!1)};return document.addEventListener("keydown",ee),()=>document.removeEventListener("keydown",ee)},[_A]);const Re=P4A(e,KA,Ge),Ne=J4A({markdown:e,annotations:t,selectedAnnotationId:r,globalAttachments:sA,setMarkdown:A,setAnnotations:i,setSelectedAnnotationId:n,setGlobalAttachments:nA,viewerRef:eA,sidebar:Le}),it=j4A({markdown:e,viewerRef:eA,linkedDocHook:Ne,setMarkdown:A,setAnnotations:i,setSelectedAnnotationId:n,setSubmitted:ne}),ze=z4A(),It=cA.useMemo(()=>_OA(),[O]),bt=cA.useMemo(()=>{if(!It)return"";const ee=iI();return rI(ee)},[It,O]);cA.useEffect(()=>{It||ze.setActiveFile(null)},[It]),cA.useEffect(()=>{Le.activeTab==="vault"&&It&&bt&&ze.tree.length===0&&!ze.isLoading&&ze.fetchTree(bt)},[Le.activeTab,It,bt]);const Tt=Yn.useCallback(ee=>Ue=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(ee)}&path=${encodeURIComponent(Ue)}`,[]),yt=Yn.useCallback(ee=>{Ne.open(ee,Tt(bt)),ze.setActiveFile(ee)},[bt,Ne,ze,Tt]),pt=tKA(),Ii=cA.useMemo(()=>!!mA||Vq(),[mA,O]),Pe=cA.useMemo(()=>{const ee=mA?[mA]:[],Ue=Vq()?l4().directories:[];return[...new Set([...ee,...Ue])]},[mA,O]);cA.useEffect(()=>{Ii||pt.setActiveFile(null)},[Ii]),cA.useEffect(()=>{if(Le.activeTab==="files"&&Ii&&Pe.length>0){const ee=pt.dirs.map(ot=>ot.path);(Pe.length!==ee.length||Pe.some(ot=>!ee.includes(ot)))&&pt.fetchAll(Pe)}},[Le.activeTab,Ii,Pe]);const zA=Yn.useCallback((ee,Ue)=>{const ot=kt=>`/api/doc?path=${encodeURIComponent(kt)}&base=${encodeURIComponent(Ue)}`;Ne.open(ee,ot,"files"),pt.setActiveFile(ee),ze.setActiveFile(null)},[Ne,pt]),be=Yn.useCallback(ee=>{if(ze.activeFile&&bt)Ne.open(ee,Tt(bt));else if(pt.activeFile&&pt.activeDirPath){const Ue=Ne.filepath?.replace(/\/[^/]+$/,"")||pt.activeDirPath;Ne.open(ee,ot=>`/api/doc?path=${encodeURIComponent(ot)}&base=${encodeURIComponent(Ue)}`)}else{const Ue=Ne.filepath?Ne.filepath.replace(/\/[^/]+$/,""):aA;Ue?Ne.open(ee,ot=>`/api/doc?path=${encodeURIComponent(ot)}&base=${encodeURIComponent(Ue)}`):Ne.open(ee)}},[ze.activeFile,bt,pt.activeFile,pt.activeDirPath,Ne,Tt,aA]),_e=Yn.useCallback(()=>{Ne.back(),ze.setActiveFile(null),pt.setActiveFile(null),it.clearSelection()},[Ne,ze,pt,it]),Jt=Yn.useCallback(()=>{ze.fetchTree(bt)},[ze,bt]),si=cA.useMemo(()=>a.filter(ee=>ee.type==="heading").length,[a]),Ct=a4A(le,si),{editorAnnotations:ei,deleteEditorAnnotation:Zi}=X4A(),{externalAnnotations:ri,updateExternalAnnotation:Te,deleteExternalAnnotation:ye}=eKA({enabled:G}),De=cA.useMemo(()=>ri.length===0?t:[...t.filter(Ue=>Ue.source?!ri.some(ot=>ot.source===Ue.source&&ot.type===Ue.type&&ot.originalText===Ue.originalText):!0),...ri],[t,ri]),Me=cA.useMemo(()=>De.filter(ee=>!!ee.diffContext),[De]),me=cA.useMemo(()=>De.filter(ee=>!ee.diffContext),[De]),{isSharedSession:nt,isLoadingShared:xA,shareUrl:di,shareUrlSize:FA,shortShareUrl:Ut,isGeneratingShortUrl:As,shortUrlError:es,pendingSharedAnnotations:Fn,clearPendingSharedAnnotations:ts,generateShortUrl:nr,importFromShareUrl:ar,shareLoadError:Na,clearShareLoadError:Ea}=i4A(e,De,sA,A,i,nA,()=>{LA(!1)},ae,XA),{draftBanner:Gn,restoreDraft:sr,dismissDraft:vs}=Z4A({annotations:De,globalAttachments:sA,isApiMode:G,isSharedSession:nt,submitted:!!tA}),or=Yn.useCallback(()=>{const{annotations:ee,globalAttachments:Ue}=sr();ee.length>0&&(i(ee),Ue.length>0&&nA(Ue),setTimeout(()=>{eA.current?.applySharedAnnotations(ee.filter(ot=>!ot.diffContext))},100))},[sr]),{getAgentWarning:Et}=MoA(q);cA.useEffect(()=>{if(Fn&&Fn.length>0){const ee=setTimeout(()=>{eA.current?.clearAllHighlights(),eA.current?.applySharedAnnotations(Fn.filter(Ue=>!Ue.diffContext)),ts()},100);return()=>clearTimeout(ee)}},[Fn,ts]);const Rt=ee=>{U(ee),qe.setItem("plannotator-tater-mode",String(ee))},Oi=ee=>{L(ee),Q4A(ee)},Xt=ee=>{H(ee),m4A(ee)};w4A(K,Xt),cA.useEffect(()=>{xA||nt||fetch("/api/plan").then(ee=>{if(!ee.ok)throw new Error("Not in API mode");return ee.json()}).then(ee=>{Gs.init(ee.serverConfig),j(ee.serverConfig?.gitUser),ee.mode==="archive"?(A(ee.plan||""),ee.archivePlans&&it.init(ee.archivePlans),it.fetchPlans(),ZA(!1),Le.open("archive")):ee.mode==="annotate-folder"?A(""):ee.plan&&A(ee.plan),P(!0),(ee.mode==="annotate"||ee.mode==="annotate-last"||ee.mode==="annotate-folder")&&rA(!0),ee.mode==="annotate-folder"&&Le.open("files"),ee.mode&&ee.mode!=="archive"&&gA(ee.mode==="annotate-last"?"message":ee.mode==="annotate-folder"?"folder":"file"),ee.filePath&&uA(ee.mode==="annotate-folder"?ee.filePath:ee.filePath.replace(/\/[^/]+$/,"")),ee.sharingEnabled!==void 0&&ZA(ee.sharingEnabled),ee.shareBaseUrl&&NA(ee.shareBaseUrl),ee.pasteApiUrl&&EA(ee.pasteApiUrl),ee.repoInfo&&Z(ee.repoInfo),ee.projectRoot&&pA(ee.projectRoot),ee.previousPlan!==void 0&&te(ee.previousPlan),ee.versionInfo&&Se(ee.versionInfo),ee.origin&&(Y(ee.origin),ee.origin==="claude-code"&&yUA()&&Qe(!0),ie(SoA().mode)),ee.isWSL&&X(!0)}).catch(()=>{P(!1)}).finally(()=>LA(!1))},[xA,nt]),cA.useEffect(()=>{const{frontmatter:ee}=MAA(e);g(ee),s(kAA(e))},[e]);const xr=cA.useRef(!1),Yi=cA.useRef({}),tn=cA.useRef(null);cA.useEffect(()=>{xr.current=!1,Yi.current={},tn.current=null},[e]),cA.useEffect(()=>{if(!G||!e||nt||hA||it.archiveMode||xr.current)return;const ee={},Ue=[],ot=iI();if(ot.autoSave&&ot.enabled){const Cr=rI(ot);Cr&&(ee.obsidian={vaultPath:Cr,folder:ot.folder||"plannotator",plan:e,...ot.filenameFormat&&{filenameFormat:ot.filenameFormat},...ot.filenameSeparator&&ot.filenameSeparator!=="space"&&{filenameSeparator:ot.filenameSeparator}},Ue.push("Obsidian"))}const kt=Zc();kt.autoSave&&kt.enabled&&(ee.bear={plan:e,customTags:kt.customTags,tagPosition:kt.tagPosition},Ue.push("Bear"));const pi=wB();if(pi.autoSave&&Vh()&&(ee.octarine={plan:e,workspace:pi.workspace,folder:pi.folder||"plannotator"},Ue.push("Octarine")),Ue.length===0)return;xr.current=!0;const fr=fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ee)}).then(Cr=>Cr.json()).then(Cr=>{const Lo={...ee.obsidian?{obsidian:!!Cr.results?.obsidian?.success}:{},...ee.bear?{bear:!!Cr.results?.bear?.success}:{},...ee.octarine?{octarine:!!Cr.results?.octarine?.success}:{}};Yi.current=Lo;const nC=Ue.filter(aC=>!Cr.results?.[aC.toLowerCase()]?.success);return nC.length===0?PA({type:"success",message:`Auto-saved to ${Ue.join(" & ")}`}):PA({type:"error",message:`Auto-save failed for ${nC.join(" & ")}`}),Lo}).catch(()=>(Yi.current={},PA({type:"error",message:"Auto-save failed"}),{})).finally(()=>setTimeout(()=>PA(null),3e3));tn.current=fr},[G,e,nt,hA]),cA.useEffect(()=>{const ee=Ue=>{const ot=Ue.clipboardData?.items;if(ot){for(const kt of ot)if(kt.type.startsWith("image/")){Ue.preventDefault();const pi=kt.getAsFile();if(pi){const fr=NF(pi.name,sA.map(Lo=>Lo.name)),Cr=URL.createObjectURL(pi);ce({file:pi,blobUrl:Cr,initialName:fr})}break}}};return document.addEventListener("paste",ee),()=>document.removeEventListener("paste",ee)},[sA]);const rn=async(ee,Ue,ot)=>{if(RA)try{const kt=new FormData,pi=Ue?new File([ee],"annotated.png",{type:"image/png"}):RA.file;kt.append("file",pi);const fr=await fetch("/api/upload",{method:"POST",body:kt});if(fr.ok){const Cr=await fr.json();nA(Lo=>[...Lo,{path:Cr.path,name:ot}])}}catch{}finally{URL.revokeObjectURL(RA.blobUrl),ce(null)}},Ve=()=>{RA&&(URL.revokeObjectURL(RA.blobUrl),ce(null))},z=async()=>{VA(!0);try{const ee=iI(),Ue=Zc(),ot=wB(),kt=o4(),pi=rv(),fr=Ue.autoSave&&tn.current?await tn.current:Yi.current,Cr={};q==="claude-code"&&(Cr.permissionMode=OA);const Lo=QUA(kt);Lo&&(Cr.agentSwitch=Lo),Cr.planSave={enabled:pi.enabled,...pi.customPath&&{customPath:pi.customPath}};const nC=rI(ee);ee.enabled&&nC&&(Cr.obsidian={vaultPath:nC,folder:ee.folder||"plannotator",plan:e,...ee.filenameFormat&&{filenameFormat:ee.filenameFormat},...ee.filenameSeparator&&ee.filenameSeparator!=="space"&&{filenameSeparator:ee.filenameSeparator}}),Ue.enabled&&!(Ue.autoSave&&fr.bear)&&(Cr.bear={plan:e,customTags:Ue.customTags,tagPosition:Ue.tagPosition}),Vh()&&(Cr.octarine={plan:e,workspace:ot.workspace,folder:ot.folder||"plannotator"});const aC=Array.from(Ne.getDocAnnotations().values()).some(mp=>mp.annotations.length>0||mp.globalAttachments.length>0);(De.length>0||sA.length>0||aC||ei.length>0)&&(Cr.feedback=Bt),await fetch("/api/approve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Cr)}),ne("approved")}catch{VA(!1)}},_=async()=>{VA(!0);try{const ee=rv();await fetch("/api/deny",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:Bt,planSave:{enabled:ee.enabled,...ee.customPath&&{customPath:ee.customPath}}})}),ne("denied")}catch{VA(!1)}},IA=async()=>{VA(!0);try{await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:Bt,annotations:De})}),ne("denied")}catch{VA(!1)}};cA.useEffect(()=>{const ee=Ue=>{if(Ue.key!=="Enter"||!(Ue.metaKey||Ue.ctrlKey))return;const ot=Ue.target?.tagName;if(ot==="INPUT"||ot==="TEXTAREA"||l||C||B||Q||m||Ie||RA||tA||BA||!G||Ne.isActive)return;if(Ue.preventDefault(),hA){IA();return}const kt=Ne.getDocAnnotations(),pi=Array.from(kt.values()).some(fr=>fr.annotations.length>0||fr.globalAttachments.length>0);if(De.length===0&&ei.length===0&&!pi){if(q==="opencode"){const fr=Et();if(fr){S(fr),y(!0);return}}z()}else _()};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[l,C,B,Q,m,Ie,RA,tA,BA,G,Ne.isActive,t.length,ri.length,hA,q,Et]);const DA=ee=>{i(Ue=>[...Ue,ee]),n(ee.id),R(!0)},GA=Yn.useCallback(ee=>{n(ee),ee&&window.innerWidth<768&&R(!0)},[]),jA=ee=>{eA.current?.removeHighlight(ee),i(Ue=>Ue.filter(ot=>ot.id!==ee)),r===ee&&n(null)},ge=wKA({blocks:a,annotations:t,addAnnotation:DA,removeAnnotation:jA}),fe=ee=>{const Ue=De.find(ot=>ot.id===ee);if(Ue?.source&&ri.some(ot=>ot.id===ee)){ye(ee),r===ee&&n(null);return}ee.startsWith("ann-checkbox-")&&Ue&&ge.revertOverride(Ue.blockId),jA(ee)},Xe=(ee,Ue)=>{if(De.find(kt=>kt.id===ee)?.source&&ri.some(kt=>kt.id===ee)){Te(ee,Ue);return}i(kt=>kt.map(pi=>pi.id===ee?{...pi,...Ue}:pi))},zt=(ee,Ue)=>{i(ot=>ot.map(kt=>kt.author===ee?{...kt,author:Ue}:kt))},Kt=ee=>{nA(Ue=>[...Ue,ee])},ti=ee=>{nA(Ue=>Ue.filter(ot=>ot.path!==ee))},$t=ee=>{},Bt=cA.useMemo(()=>{const ee=Ne.getDocAnnotations(),Ue=Array.from(ee.values()).some(fr=>fr.annotations.length>0||fr.globalAttachments.length>0),ot=De.length>0||sA.length>0,kt=ei.length>0;if(!ot&&!Ue&&!kt)return"User reviewed the document and has no feedback.";let pi=ot?EfA(a,De,sA,oA==="message"?"Message Feedback":oA==="folder"?"Folder Feedback":oA==="file"?"File Feedback":"Plan Feedback",oA??"plan"):"";return Ue&&(pi+=ufA(ee)),kt&&(pi+=BfA(ei)),pi},[a,De,sA,Ne.getDocAnnotations,ei]),Nt=Yn.useMemo(()=>r4A(),[]),Ui=Yn.useCallback(async ee=>{if(!(!Nt||BA||!di)){VA(!0);try{const Ue=await n4A(ee,Nt,di);Ue&&(PA(Ue),setTimeout(()=>PA(null),4e3),Ue.type==="success"&&ne(ee===BD.Approve?"approved":"denied"))}finally{VA(!1)}}},[Nt,BA,di]),On=Yn.useCallback(()=>Ui(BD.Approve),[Ui]),Un=Yn.useCallback(()=>Ui(BD.Feedback),[Ui]),Hi=()=>{MA(!1);const ee=new Blob([Bt],{type:"text/plain"}),Ue=URL.createObjectURL(ee),ot=document.createElement("a");ot.href=Ue,ot.download="annotations.md",ot.click(),URL.revokeObjectURL(Ue),PA({type:"success",message:"Downloaded annotations"}),setTimeout(()=>PA(null),3e3)},Ir=async ee=>{MA(!1);const Ue={};if(ee==="obsidian"){const kt=iI(),pi=rI(kt);pi&&(Ue.obsidian={vaultPath:pi,folder:kt.folder||"plannotator",plan:e,...kt.filenameFormat&&{filenameFormat:kt.filenameFormat},...kt.filenameSeparator&&kt.filenameSeparator!=="space"&&{filenameSeparator:kt.filenameSeparator}})}if(ee==="bear"){const kt=Zc();Ue.bear={plan:e,customTags:kt.customTags,tagPosition:kt.tagPosition}}if(ee==="octarine"){const kt=wB();Ue.octarine={plan:e,workspace:kt.workspace,folder:kt.folder||"plannotator"}}const ot=ee==="obsidian"?"Obsidian":ee==="bear"?"Bear":"Octarine";try{const fr=(await(await fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ue)})).json()).results?.[ee];fr?.success?PA({type:"success",message:`Saved to ${ot}`}):PA({type:"error",message:fr?.error||"Save failed"})}catch{PA({type:"error",message:"Save failed"})}setTimeout(()=>PA(null),3e3)};cA.useEffect(()=>{const ee=Ue=>{if(Ue.key!=="s"||!(Ue.metaKey||Ue.ctrlKey))return;const ot=Ue.target?.tagName;if(ot==="INPUT"||ot==="TEXTAREA"||l||B||Q||m||Ie||RA||tA||!G)return;Ue.preventDefault();const kt=NoA(),pi=Ux(),fr=Zc().enabled,Cr=Vh();kt==="download"?Hi():kt==="obsidian"&&pi?Ir("obsidian"):kt==="bear"&&fr?Ir("bear"):kt==="octarine"&&Cr?Ir("octarine"):(dA("notes"),I(!0))};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[l,B,Q,m,Ie,RA,tA,G,e,Bt]),cA.useEffect(()=>{const ee=Ue=>{if(Ue.key!=="p"||!(Ue.metaKey||Ue.ctrlKey))return;const ot=Ue.target?.tagName;ot==="INPUT"||ot==="TEXTAREA"||l||B||Q||m||Ie||RA||tA||(Ue.preventDefault(),window.print())};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[l,B,Q,m,Ie,RA,tA]),cA.useEffect(()=>{if(!kA)return;const ee=Ue=>{Ue.target.closest("[data-export-dropdown]")||MA(!1)};return document.addEventListener("pointerdown",ee),()=>document.removeEventListener("pointerdown",ee)},[kA]);const Qn=cA.useMemo(()=>cfA(q),[q]),nn=cA.useMemo(()=>({compact:832,default:1040,wide:1280})[O.planWidth]??832,[O.planWidth]);return w.jsx(iUA,{defaultTheme:"dark",children:w.jsxs("div",{"data-print-region":"root",className:"h-screen flex flex-col bg-background overflow-hidden",children:[w.jsxs("header",{className:"h-12 flex items-center justify-between px-2 md:px-4 border-b border-border/50 bg-card/50 backdrop-blur-xl sticky top-0 z-[50]",children:[w.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[w.jsx("a",{href:"https://plannotator.ai",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 md:gap-2 hover:opacity-80 transition-opacity",children:w.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Plannotator"})}),w.jsxs("a",{href:"https://github.com/backnotprop/plannotator/releases",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground font-mono opacity-60 hidden md:inline hover:opacity-100 transition-opacity",children:["v","0.16.1"]}),q&&w.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium hidden md:inline ${IfA(q)}`,children:Qn})]}),w.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[Nt&&!G&&nt&&w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"}),w.jsx(jq,{onClick:Un,disabled:BA||!di,isLoading:BA,title:"Send feedback to bot"}),w.jsx(_q,{onClick:On,disabled:BA||!di,isLoading:BA,title:"Approve design and notify bot"})]}),G&&!Ne.isActive&&it.archiveMode&&w.jsxs(w.Fragment,{children:[w.jsxs("button",{onClick:it.copy,className:"px-2.5 py-1 rounded-md text-xs font-medium transition-all bg-muted text-foreground hover:bg-muted/80 border border-border",title:"Copy plan content",children:[w.jsx("span",{className:"hidden md:inline",children:"Copy"}),w.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})]}),w.jsx("button",{onClick:it.done,className:"px-2.5 py-1 rounded-md text-xs font-medium transition-all bg-success text-success-foreground hover:opacity-90",title:"Close archive",children:"Done"})]}),G&&!Ne.isActive&&!it.archiveMode&&w.jsxs(w.Fragment,{children:[w.jsx(jq,{onClick:()=>{if(hA){IA();return}const ee=Ne.getDocAnnotations(),Ue=Array.from(ee.values()).some(ot=>ot.annotations.length>0||ot.globalAttachments.length>0);De.length===0&&ei.length===0&&!Ue?h(!0):_()},disabled:BA,isLoading:BA,label:hA?De.length>0||ei.length>0||Ne.docAnnotationCount>0?"Send Annotations":"Done":"Send Feedback",title:hA?De.length>0||ei.length>0||Ne.docAnnotationCount>0?"Send Annotations":"Done":"Send Feedback"}),!hA&&w.jsxs("div",{className:"relative group/approve",children:[w.jsx(_q,{onClick:()=>{if(q==="claude-code"&&De.length>0){f(!0);return}if(q==="opencode"){const ee=Et();if(ee){S(ee),y(!0);return}}z()},disabled:BA,isLoading:BA,dimmed:q==="claude-code"&&De.length>0}),q==="claude-code"&&De.length>0&&w.jsxs("div",{className:"absolute top-full right-0 mt-2 px-3 py-2 bg-popover border border-border rounded-lg shadow-xl text-xs text-foreground w-56 text-center opacity-0 invisible group-hover/approve:opacity-100 group-hover/approve:visible transition-all pointer-events-none z-50",children:[w.jsx("div",{className:"absolute bottom-full right-4 border-4 border-transparent border-b-border"}),w.jsx("div",{className:"absolute bottom-full right-4 mt-px border-4 border-transparent border-b-popover"}),Qn," doesn't support feedback on approval. Your annotations won't be seen."]})]}),w.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"})]}),w.jsxs("div",{className:"hidden md:flex items-center gap-2",children:[w.jsx(rUA,{}),!Ne.isActive&&w.jsx(jUA,{taterMode:k,onTaterModeChange:Rt,onIdentityChange:zt,origin:q,onUIPreferencesChange:T,externalOpen:b,onExternalClose:()=>N(!1),gitUser:V}),w.jsx("button",{onClick:()=>R(!x),className:`p-1.5 rounded-md text-xs font-medium transition-all ${x?"bg-primary/15 text-primary":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:w.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})})}),w.jsxs("div",{className:"relative flex","data-export-dropdown":!0,children:[w.jsx("button",{onClick:()=>{dA(void 0),I(!0)},className:"px-2.5 py-1 rounded-l-md text-xs font-medium bg-muted hover:bg-muted/80 transition-colors",title:"Export",children:"Export"}),w.jsx("button",{onClick:()=>MA(ee=>!ee),className:"px-1.5 rounded-r-md text-xs bg-muted hover:bg-muted/80 border-l border-border/50 transition-colors flex items-center",title:"Quick save options",children:w.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}),kA&&w.jsxs("div",{className:"absolute top-full right-0 mt-1 w-48 bg-popover border border-border rounded-lg shadow-xl z-50 py-1",children:[YA&&w.jsxs("button",{onClick:async()=>{MA(!1);try{await navigator.clipboard.writeText(di),PA({type:"success",message:"Share link copied"})}catch{PA({type:"error",message:"Failed to copy"})}setTimeout(()=>PA(null),3e3)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),"Copy Share Link"]}),w.jsxs("button",{onClick:Hi,className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),"Download Annotations"]}),w.jsxs("button",{onClick:()=>{MA(!1),window.print()},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"})}),"Print Plan",w.jsxs("span",{className:"ml-auto text-[10px] text-muted-foreground/60",children:[cs,"+P"]})]}),w.jsx("div",{className:"my-1 border-t border-border"}),G&&Ux()&&w.jsxs("button",{onClick:()=>Ir("obsidian"),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),"Save to Obsidian"]}),G&&Zc().enabled&&w.jsxs("button",{onClick:()=>Ir("bear"),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),"Save to Bear"]}),G&&Vh()&&w.jsxs("button",{onClick:()=>Ir("octarine"),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),"Save to Octarine"]}),G&&!Ux()&&!Zc().enabled&&!Vh()&&w.jsx("div",{className:"px-3 py-2 text-[10px] text-muted-foreground",children:"No notes apps configured."}),YA&&w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"my-1 border-t border-border"}),w.jsxs("button",{onClick:()=>{MA(!1),E(!0)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[w.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:w.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4M10 17l5-5-5-5M15 12H3"})}),"Import Review"]})]})]})]})]}),w.jsx(S4A,{className:"md:hidden",isPanelOpen:x,onTogglePanel:()=>R(!x),annotationCount:De.length+ei.length,onOpenExport:()=>{dA(void 0),I(!0)},onOpenSettings:()=>N(!0),onDownloadAnnotations:Hi,onCopyShareLink:async()=>{try{await navigator.clipboard.writeText(di),PA({type:"success",message:"Share link copied"})}catch{PA({type:"error",message:"Failed to copy"})}setTimeout(()=>PA(null),3e3)},onOpenImport:()=>E(!0),onPrint:()=>window.print(),sharingEnabled:YA})]})]}),Ne.error&&w.jsxs("div",{className:"bg-destructive/10 border-b border-destructive/20 px-4 py-2 flex items-center gap-2 flex-shrink-0",children:[w.jsx("span",{className:"text-xs text-destructive",children:Ne.error}),w.jsx("button",{onClick:Ne.dismissError,className:"ml-auto text-xs text-destructive/60 hover:text-destructive",children:"dismiss"})]}),w.jsxs("div",{"data-print-region":"content",className:`flex-1 flex overflow-hidden relative z-0 ${ke?"select-none":""}`,children:[k&&w.jsx(EUA,{}),!Le.isOpen&&w.jsx(iKA,{activeTab:Le.activeTab,onToggleTab:Le.toggleTab,hasDiff:Re.hasPreviousVersion,showFilesTab:Ii&&!it.archiveMode,showVaultTab:It,className:"hidden lg:flex"}),Le.isOpen&&w.jsxs(w.Fragment,{children:[w.jsx(uKA,{activeTab:Le.activeTab,onTabChange:ee=>{Le.toggleTab(ee),ee==="archive"&&!it.archiveMode&&it.fetchPlans()},onClose:Le.close,width:ve.width,blocks:a,annotations:t,activeSection:Ct,onTocNavigate:$t,linkedDocFilepath:Ne.filepath,onLinkedDocBack:Ne.isActive?_e:void 0,showFilesTab:Ii&&!it.archiveMode,fileBrowser:pt,onFilesSelectFile:zA,onFilesFetchAll:()=>pt.fetchAll(Pe),showVaultTab:It&&!it.archiveMode,vaultPath:bt,vaultBrowser:ze,onVaultSelectFile:yt,onVaultFetchTree:Jt,versionInfo:Ge,versions:Re.versions,selectedBaseVersion:Re.diffBaseVersion,onSelectBaseVersion:Re.selectBaseVersion,isPlanDiffActive:_A,hasPreviousVersion:Re.hasPreviousVersion,onActivatePlanDiff:()=>Ee(!0),isLoadingVersions:Re.isLoadingVersions,isSelectingVersion:Re.isSelectingVersion,fetchingVersion:Re.fetchingVersion,onFetchVersions:Re.fetchVersions,showArchiveTab:G&&!hA,archivePlans:it.plans,selectedArchiveFile:it.selectedFile,onArchiveSelect:it.select,isLoadingArchive:it.isLoading}),w.jsx(rW,{...ve.handleProps,className:"hidden lg:block",side:"left"})]}),w.jsxs("main",{"data-print-region":"document",ref:le,className:"flex-1 min-w-0 overflow-y-auto bg-grid",children:[w.jsx(Zh,{isOpen:!!Gn,onClose:vs,onConfirm:or,title:"Draft Recovered",message:Gn?`Found ${Gn.count} annotation${Gn.count!==1?"s":""} from ${Gn.timeAgo}. Would you like to restore them?`:"",confirmText:"Restore",cancelText:"Dismiss",showCancel:!0}),w.jsxs("div",{className:"min-h-full flex flex-col items-center px-2 py-3 md:px-10 md:py-8 xl:px-16 relative z-10",children:[!_A&&!it.archiveMode&&w.jsx("div",{"data-print-hide":!0,className:"w-full mb-3 md:mb-4 flex items-center justify-start",style:{maxWidth:nn},children:w.jsx(oUA,{inputMethod:K,onInputMethodChange:Xt,mode:F,onModeChange:Oi,taterMode:k})}),Re.diffBlocks&&Re.diffStats&&w.jsx("div",{className:"w-full flex justify-center",style:{display:_A?void 0:"none"},children:w.jsx(yKA,{diffBlocks:Re.diffBlocks,diffStats:Re.diffStats,diffMode:yA,onDiffModeChange:UA,onPlanDiffToggle:()=>Ee(!1),repoInfo:vA,baseVersionLabel:Re.diffBaseVersion!=null?`v${Re.diffBaseVersion}`:void 0,baseVersion:Re.diffBaseVersion??void 0,maxWidth:nn,annotations:Me,onAddAnnotation:DA,onSelectAnnotation:GA,selectedAnnotationId:r,mode:F})}),oA==="folder"&&!e&&!Ne.isActive&&w.jsx("div",{className:"w-full flex justify-center",children:w.jsxs("div",{className:"w-full max-w-3xl p-12 text-center text-muted-foreground",children:[w.jsx("p",{className:"text-lg font-medium mb-2",children:"Select a file to annotate"}),w.jsx("p",{className:"text-sm",children:"Pick a markdown file from the sidebar to begin."})]})}),w.jsx("div",{className:"w-full flex justify-center",style:{display:_A&&Re.diffBlocks||oA==="folder"&&!e&&!Ne.isActive?"none":void 0},children:w.jsx(KOA,{ref:eA,blocks:a,markdown:e,frontmatter:o,annotations:me,onAddAnnotation:DA,onSelectAnnotation:GA,selectedAnnotationId:r,mode:F,inputMethod:K,taterMode:k,globalAttachments:sA,onAddGlobalAttachment:Kt,onRemoveGlobalAttachment:ti,repoInfo:vA,stickyActions:O.stickyActionsEnabled,planDiffStats:Ne.isActive?null:Re.diffStats,isPlanDiffActive:_A,onPlanDiffToggle:()=>Ee(!_A),hasPreviousVersion:!Ne.isActive&&Re.hasPreviousVersion,showDemoBadge:!G&&!xA&&!nt,maxWidth:nn,onOpenLinkedDoc:be,linkedDocInfo:Ne.isActive?{filepath:Ne.filepath,onBack:_e,label:ze.activeFile?"Vault File":pt.activeFile?"File":void 0}:null,imageBaseDir:aA,copyLabel:oA==="message"?"Copy message":oA==="file"||oA==="folder"?"Copy file":void 0,archiveInfo:it.currentInfo,onToggleCheckbox:ge.toggle,checkboxOverrides:ge.overrides},Ne.isActive?`doc:${Ne.filepath}`:"plan")})]})]}),x&&w.jsx(rW,{...se.handleProps,className:"hidden md:block",side:"right"}),w.jsx(qOA,{isOpen:x,blocks:a,annotations:De,selectedId:r,onSelect:n,onDelete:fe,onEdit:Xe,shareUrl:di,sharingEnabled:YA,width:se.width,editorAnnotations:ei,onDeleteEditorAnnotation:Zi,onClose:()=>R(!1),onQuickCopy:async()=>{await navigator.clipboard.writeText(xAA(Bt))}})]}),w.jsx(eUA,{isOpen:l,onClose:()=>{I(!1),dA(void 0)},shareUrl:di,shareUrlSize:FA,shortShareUrl:Ut,isGeneratingShortUrl:As,shortUrlError:es,onGenerateShortUrl:nr,annotationsOutput:Bt,annotationCount:De.length,taterSprite:k?w.jsx(s4,{}):void 0,sharingEnabled:YA,markdown:e,isApiMode:G,initialTab:TA}),w.jsx(tUA,{isOpen:C,onClose:()=>E(!1),onImport:ar,shareBaseUrl:ae}),w.jsx(Zh,{isOpen:B,onClose:()=>h(!1),title:"Add Annotations First",message:`To provide feedback, select text in the plan and add annotations. ${Qn} will use your annotations to revise the plan.`,variant:"info"}),w.jsx(Zh,{isOpen:Q,onClose:()=>f(!1),onConfirm:()=>{f(!1),z()},title:"Annotations Won't Be Sent",message:w.jsxs(w.Fragment,{children:[Qn," doesn't yet support feedback on approval. Your ",De.length," annotation",De.length!==1?"s":""," will be lost."]}),subMessage:w.jsxs(w.Fragment,{children:["To send feedback, use ",w.jsx("strong",{children:"Send Feedback"})," instead.",w.jsx("br",{}),w.jsx("br",{}),"Want this feature? Upvote these issues:",w.jsx("br",{}),w.jsx("a",{href:"https://github.com/anthropics/claude-code/issues/16001",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"#16001"})," · ",w.jsx("a",{href:"https://github.com/anthropics/claude-code/issues/15755",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"#15755"})]}),confirmText:"Approve Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),w.jsx(Zh,{isOpen:m,onClose:()=>y(!1),onConfirm:()=>{y(!1),z()},title:"Agent Not Found",message:v,subMessage:w.jsxs(w.Fragment,{children:["You can change the agent in ",w.jsx("strong",{children:"Settings"}),", or approve anyway and OpenCode will use the default agent."]}),confirmText:"Approve Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),w.jsx(Zh,{isOpen:!!Na&&!G,onClose:Ea,title:"Shared Plan Could Not Be Loaded",message:Na,subMessage:"You are viewing a demo plan. This is sample content — it is not your data or anyone else's.",variant:"warning"}),wA&&w.jsx("div",{className:`fixed top-16 right-4 z-50 px-3 py-2 rounded-lg text-xs font-medium shadow-lg transition-opacity ${wA.type==="success"?"bg-success/15 text-success border border-success/30":"bg-destructive/15 text-destructive border border-destructive/30"}`,children:wA.message}),w.jsx(l4A,{submitted:tA,title:it.archiveMode?"Archive Closed":tA==="approved"?"Plan Approved":hA?"Annotations Sent":"Feedback Sent",subtitle:it.archiveMode?"You can reopen with plannotator archive.":tA==="approved"?`${Qn} will proceed with the implementation.`:hA?`${Qn} will address your annotations on the ${oA==="message"?"message":oA==="folder"?"files":"file"}.`:`${Qn} will revise the plan based on your annotations.`,agentLabel:Qn}),w.jsx(B4A,{origin:q,isWSL:AA}),w.jsx(JAA,{isOpen:!!RA,imageSrc:RA?.blobUrl??"",initialName:RA?.initialName,onAccept:rn,onClose:Ve}),w.jsx(T4A,{isOpen:Ie,onComplete:ee=>{ie(ee),Qe(!1)}})]})})},ZoA=document.getElementById("root");if(!ZoA)throw new Error("Could not find root element to mount to");const SKA=lfA.createRoot(ZoA);SKA.render(w.jsx(Yn.StrictMode,{children:w.jsx(vKA,{})}));class ls{constructor(A,t,i){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=A,this.start=t,this.end=i}static range(A,t){return t?!A||!A.loc||!t.loc||A.loc.lexer!==t.loc.lexer?null:new ls(A.loc.lexer,A.loc.start,t.loc.end):A&&A.loc}}class Ys{constructor(A,t){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=A,this.loc=t}range(A,t){return new Ys(t,ls.range(this,A))}}class je{constructor(A,t){this.name=void 0,this.position=void 0,this.length=void 0,this.rawMessage=void 0;var i="KaTeX parse error: "+A,r,n,a=t&&t.loc;if(a&&a.start<=a.end){var s=a.lexer.input;r=a.start,n=a.end,r===s.length?i+=" at end of input: ":i+=" at position "+(r+1)+": ";var o=s.slice(r,n).replace(/[^]/g,"$&̲"),g;r>15?g="…"+s.slice(r-15,r):g=s.slice(0,r);var l;n+15<s.length?l=s.slice(n,n+15)+"…":l=s.slice(n),i+=g+o+l}var I=new Error(i);return I.name="ParseError",I.__proto__=je.prototype,I.position=r,r!=null&&n!=null&&(I.length=n-r),I.rawMessage=A,I}}je.prototype.__proto__=Error.prototype;var bKA=function(A,t){return A===void 0?t:A},RKA=/([A-Z])/g,NKA=function(A){return A.replace(RKA,"-$1").toLowerCase()},MKA={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},kKA=/[&><"']/g;function xKA(e){return String(e).replace(kKA,A=>MKA[A])}var joA=function e(A){return A.type==="ordgroup"||A.type==="color"?A.body.length===1?e(A.body[0]):A:A.type==="font"?e(A.body):A},LKA=function(A){var t=joA(A);return t.type==="mathord"||t.type==="textord"||t.type==="atom"},TKA=function(A){if(!A)throw new Error("Expected non-null, but got "+String(A));return A},FKA=function(A){var t=/^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(A);return t?t[2]!==":"||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():"_relative"},Ti={deflt:bKA,escape:xKA,hyphenate:NKA,getBaseElem:joA,isCharacterBox:LKA,protocolFromUrl:FKA},mf={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format <type>"},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color <color>",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:e=>"#"+e},macros:{type:"object",cli:"-m, --macro <def>",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(e,A)=>(A.push(e),A)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:"--min-rule-thickness <size>",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:e=>Math.max(0,e),cli:"-s, --max-size <n>",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:e=>Math.max(0,e),cli:"-e, --max-expand <n>",cliProcessor:e=>e==="Infinity"?1/0:parseInt(e)},globalGroup:{type:"boolean",cli:!1}};function GKA(e){if(e.default)return e.default;var A=e.type,t=Array.isArray(A)?A[0]:A;if(typeof t!="string")return t.enum[0];switch(t){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{}}}class I4{constructor(A){this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,A=A||{};for(var t in mf)if(mf.hasOwnProperty(t)){var i=mf[t];this[t]=A[t]!==void 0?i.processor?i.processor(A[t]):A[t]:GKA(i)}}reportNonstrict(A,t,i){var r=this.strict;if(typeof r=="function"&&(r=r(A,t,i)),!(!r||r==="ignore")){if(r===!0||r==="error")throw new je("LaTeX-incompatible input and strict mode is set to 'error': "+(t+" ["+A+"]"),i);r==="warn"?typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(t+" ["+A+"]")):typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+r+"': "+t+" ["+A+"]"))}}useStrictBehavior(A,t,i){var r=this.strict;if(typeof r=="function")try{r=r(A,t,i)}catch{r="error"}return!r||r==="ignore"?!1:r===!0||r==="error"?!0:r==="warn"?(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+(t+" ["+A+"]")),!1):(typeof console<"u"&&console.warn("LaTeX-incompatible input and strict mode is set to "+("unrecognized '"+r+"': "+t+" ["+A+"]")),!1)}isTrusted(A){if(A.url&&!A.protocol){var t=Ti.protocolFromUrl(A.url);if(t==null)return!1;A.protocol=t}var i=typeof this.trust=="function"?this.trust(A):this.trust;return!!i}}class Hc{constructor(A,t,i){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=A,this.size=t,this.cramped=i}sup(){return Mg[OKA[this.id]]}sub(){return Mg[UKA[this.id]]}fracNum(){return Mg[KKA[this.id]]}fracDen(){return Mg[YKA[this.id]]}cramp(){return Mg[HKA[this.id]]}text(){return Mg[PKA[this.id]]}isTight(){return this.size>=2}}var C4=0,sv=1,SB=2,ql=3,$f=4,fo=5,ed=6,Ya=7,Mg=[new Hc(C4,0,!1),new Hc(sv,0,!0),new Hc(SB,1,!1),new Hc(ql,1,!0),new Hc($f,2,!1),new Hc(fo,2,!0),new Hc(ed,3,!1),new Hc(Ya,3,!0)],OKA=[$f,fo,$f,fo,ed,Ya,ed,Ya],UKA=[fo,fo,fo,fo,Ya,Ya,Ya,Ya],KKA=[SB,ql,$f,fo,ed,Ya,ed,Ya],YKA=[ql,ql,fo,fo,Ya,Ya,Ya,Ya],HKA=[sv,sv,ql,ql,fo,fo,Ya,Ya],PKA=[C4,sv,SB,ql,SB,ql,SB,ql],Gt={DISPLAY:Mg[C4],TEXT:Mg[SB],SCRIPT:Mg[$f],SCRIPTSCRIPT:Mg[ed]},zG=[{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 JKA(e){for(var A=0;A<zG.length;A++)for(var t=zG[A],i=0;i<t.blocks.length;i++){var r=t.blocks[i];if(e>=r[0]&&e<=r[1])return t.name}return null}var dD=[];zG.forEach(e=>e.blocks.forEach(A=>dD.push(...A)));function _oA(e){for(var A=0;A<dD.length;A+=2)if(e>=dD[A]&&e<=dD[A+1])return!0;return!1}var Pu=80,zKA=function(A,t){return"M95,"+(622+A+t)+`
848
848
  c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
849
849
  c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
850
850
  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