@plannotator/pi-extension 0.14.2 → 0.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plannotator/pi-extension",
3
- "version": "0.14.2",
3
+ "version": "0.14.3",
4
4
  "type": "module",
5
5
  "description": "Plannotator extension for Pi coding agent - interactive plan review with visual annotation",
6
6
  "author": "backnotprop",
package/plannotator.html CHANGED
@@ -523,7 +523,7 @@ created: ${new Date().toISOString().slice(0,19)}Z
523
523
  source: plannotator
524
524
  tags: [plan, ...]
525
525
  ---`})]}),R.jsx("div",{className:"border-t border-border/30"}),R.jsxs("div",{className:"flex items-center justify-between",children:[R.jsxs("div",{children:[R.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),R.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Obsidian when a plan loads, before you approve or deny"})]}),R.jsx("button",{role:"switch","aria-checked":B.autoSave,onClick:()=>iA({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:R.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"}`})})]}),R.jsxs("div",{className:"flex items-center justify-between",children:[R.jsxs("div",{children:[R.jsx("div",{className:"text-xs font-medium",children:"Vault Browser"}),R.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Browse and annotate vault files from the sidebar"})]}),R.jsx("button",{role:"switch","aria-checked":B.vaultBrowserEnabled,onClick:()=>iA({vaultBrowserEnabled:!B.vaultBrowserEnabled}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${B.vaultBrowserEnabled?"bg-primary":"bg-muted"}`,children:R.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${B.vaultBrowserEnabled?"translate-x-6":"translate-x-1"}`})})]})]})]})]}),l==="bear"&&R.jsxs(R.Fragment,{children:[R.jsxs("div",{className:"flex items-center justify-between",children:[R.jsxs("div",{children:[R.jsx("div",{className:"text-sm font-medium",children:"Bear Notes"}),R.jsx("div",{className:"text-xs text-muted-foreground",children:"Auto-save approved plans to Bear"})]}),R.jsx("button",{role:"switch","aria-checked":w.enabled,onClick:()=>re({enabled:!w.enabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${w.enabled?"bg-primary":"bg-muted"}`,children:R.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${w.enabled?"translate-x-6":"translate-x-1"}`})})]}),w.enabled&&R.jsxs("div",{className:"mt-3 space-y-3",children:[R.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[R.jsx("label",{className:"text-xs text-muted-foreground",children:"Custom Tags"}),R.jsx("input",{type:"text",value:w.customTags,onChange:DA=>re({customTags:DA.target.value}),onBlur:DA=>re({customTags:ROA(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"}),R.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Comma-separated, kebab-case. Leave empty for auto-generated tags."})]}),R.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[R.jsx("label",{className:"text-xs text-muted-foreground",children:"Tag Position"}),R.jsxs("select",{value:w.tagPosition,onChange:DA=>re({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:[R.jsx("option",{value:"append",children:"Append (end of note)"}),R.jsx("option",{value:"prepend",children:"Prepend (after title)"})]})]}),R.jsx("div",{className:"border-t border-border/30"}),R.jsxs("div",{className:"flex items-center justify-between",children:[R.jsxs("div",{children:[R.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),R.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Bear when a plan loads, before you approve or deny"})]}),R.jsx("button",{role:"switch","aria-checked":w.autoSave,onClick:()=>re({autoSave:!w.autoSave}),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${w.autoSave?"bg-primary":"bg-muted"}`,children:R.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white shadow-sm transition-transform ${w.autoSave?"translate-x-6":"translate-x-1"}`})})]})]})]}),l==="octarine"&&R.jsxs(R.Fragment,{children:[R.jsxs("div",{className:"flex items-center justify-between",children:[R.jsxs("div",{children:[R.jsx("div",{className:"text-sm font-medium",children:"Octarine"}),R.jsx("div",{className:"text-xs text-muted-foreground",children:"Auto-save approved plans to Octarine"})]}),R.jsx("button",{role:"switch","aria-checked":x.enabled,onClick:()=>MA({enabled:!x.enabled}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${x.enabled?"bg-primary":"bg-muted"}`,children:R.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&&R.jsxs("div",{className:"mt-3 space-y-3",children:[R.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[R.jsx("label",{className:"text-xs text-muted-foreground",children:"Workspace Name"}),R.jsx("input",{type:"text",value:x.workspace,onChange:DA=>MA({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"}),R.jsx("div",{className:"text-[10px] text-muted-foreground",children:"The Octarine workspace name to save plans into."})]}),R.jsxs("div",{className:"space-y-1.5 pl-0.5",children:[R.jsx("label",{className:"text-xs text-muted-foreground",children:"Folder"}),R.jsx("input",{type:"text",value:x.folder,onChange:DA=>MA({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"}),R.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Subfolder within the workspace for saved plans."})]}),R.jsxs("div",{className:"text-[10px] text-muted-foreground/70",children:["Plans saved to: ",x.workspace||"..."," / ",x.folder||"plannotator","/"]}),R.jsx("div",{className:"border-t border-border/30"}),R.jsxs("div",{className:"flex items-center justify-between",children:[R.jsxs("div",{children:[R.jsx("div",{className:"text-xs font-medium",children:"Auto-save on Plan Arrival"}),R.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Automatically save to Octarine when a plan loads, before you approve or deny"})]}),R.jsx("button",{role:"switch","aria-checked":x.autoSave,onClick:()=>MA({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:R.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"}`})})]})]})]})]})]})]})}),document.body)]})};async function doA(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 Pw(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 lUA(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:Tq(n),key:Tq(new Uint8Array(a))}}async function cUA(e,A){const t=Fq(e),i=Fq(A),r=t.slice(0,12),n=t.slice(12),a=await crypto.subtle.importKey("raw",i,{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 Tq(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 Fq(e){const A=e.replace(/-/g,"+").replace(/_/g,"/"),t=atob(A);return Uint8Array.from(t,i=>i.charCodeAt(0))}function EB(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 US(e){if(e?.length)return e.map(A=>[A.path,A.name])}function XU(e){return e.map(A=>{const t=A.author||null,i=US(A.images);if(A.type===ei.GLOBAL_COMMENT)return["G",A.text||"",t,i];const r=A.type[0];return r==="D"?["D",A.originalText,t,i]:r==="C"&&A.isQuickLabel?["C",A.originalText,A.text||"",t,i??void 0,1]:[r,A.originalText,A.text||"",t,i]})}function tD(e,A){const t={D:ei.DELETION,R:ei.REPLACEMENT,C:ei.COMMENT,I:ei.INSERTION,G:ei.GLOBAL_COMMENT};return e.map((i,r)=>{const n=i[0];if(n==="G"){const I=i[1],C=i[2],E=i[3];return{id:`shared-${r}-${Date.now()}`,blockId:"",startOffset:0,endOffset:0,type:ei.GLOBAL_COMMENT,text:I||void 0,originalText:"",createdA:Date.now()+r,author:C||void 0,images:EB(E)}}const a=i[1],s=n==="D"?void 0:i[2],o=n==="D"?i[2]:i[3],g=n==="D"?i[3]:i[4],l=n==="C"&&i.length>5&&i[5]===1?!0:void 0;return{id:`shared-${r}-${Date.now()}`,blockId:"",startOffset:0,endOffset:0,type:t[n],text:s||void 0,originalText:a,createdA:Date.now()+r,author:o||void 0,images:EB(g),...l?{isQuickLabel:l}:{},...A?.[r]?{diffContext:A[r]}:{}}})}function QoA(e){const A=e.map(t=>t.diffContext||null);return A.some(t=>t!==null)?A:null}async function IUA(e,A,t,i=poA){const r=QoA(A),n={p:e,a:XU(A),g:t?.length?US(t):void 0,...r?{d:r}:{}},a=await doA(n);return`${i}/#${a}`}async function CUA(){const e=window.location.hash.slice(1);if(!e)return null;try{return await Pw(e)}catch(A){return console.warn("Failed to parse share hash:",A),null}}function EUA(e){const A=new Blob([e]).size;return A<1024?`${A} B`:`${(A/1024).toFixed(1)} KB`}const foA="https://plannotator-paste.plannotator.workers.dev",poA="https://share.plannotator.ai";async function uUA(e,A,t,i){const r=i?.pasteApiUrl??foA,n=i?.shareBaseUrl??poA;try{const a=QoA(A),s={p:e,a:XU(A),g:t?.length?US(t):void 0,...a?{d:a}:{}},o=await doA(s),{ciphertext:g,key:l}=await lUA(o),I=await fetch(`${r}/api/paste`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:g}),signal:AbortSignal.timeout(5e3)});if(!I.ok)return console.warn(`[sharing] Paste service returned ${I.status}`),null;const C=await I.json();return{shortUrl:`${n}/p/${C.id}#key=${l}`,id:C.id}}catch(a){return console.debug("[sharing] Short URL service unavailable, using hash-based sharing:",a),null}}async function Gq(e,A=foA,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 cUA(r.data,t);return await Pw(n)}return await Pw(r.data)}catch(i){return console.warn("[sharing] Failed to load from paste ID:",i),null}}function BUA(e,A,t,i,r,n,a,s,o){const[g,l]=uA.useState(!1),[I,C]=uA.useState(!0),[E,B]=uA.useState(""),[d,Q]=uA.useState(""),[f,m]=uA.useState(""),[y,w]=uA.useState(!1),[S,x]=uA.useState(""),[b,v]=uA.useState(null),[N,O]=uA.useState(null),[L,K]=uA.useState(""),H=uA.useCallback(()=>{v(null),O(null)},[]),k=uA.useCallback(()=>K(""),[]),U=uA.useCallback(async()=>{try{const P=window.location.pathname.match(/^\/p\/([A-Za-z0-9]{6,16})$/);if(P){const V=P[1],_=window.location.hash.slice(1),AA=_.startsWith("key=")?_.slice(4):void 0,X=await Gq(V,o,AA);if(X){i(X.p);const gA=tD(X.a,X.d);if(r(gA),X.g?.length){const pA=EB(X.g)??[];n(pA),O(pA)}v(gA),l(!0),a?.();const sA=window.location.pathname.replace(/\/p\/[A-Za-z0-9]+$/,"")||"/";return window.history.replaceState({},"",sA),!0}return K("Failed to load shared plan — the link may be expired or incomplete."),!1}const z=window.location.hash.slice(1),Y=await CUA();if(Y){i(Y.p);const V=tD(Y.a,Y.d);if(r(V),Y.g?.length){const _=EB(Y.g)??[];n(_),O(_)}return v(V),l(!0),a?.(),window.history.replaceState({},"",window.location.pathname),!0}return z&&K("Failed to load shared plan — the URL may have been truncated by your browser."),!1}catch(P){return console.error("Failed to load from share hash:",P),K("Failed to load shared plan — an unexpected error occurred."),!1}},[i,r,n,a,o]);uA.useEffect(()=>{U().finally(()=>C(!1))},[]),uA.useEffect(()=>{const P=()=>{window.location.hash.length>1&&U()};return window.addEventListener("hashchange",P),()=>window.removeEventListener("hashchange",P)},[U]);const G=uA.useCallback(async()=>{try{const P=await IUA(e,A,t,s);B(P),Q(EUA(P))}catch(P){console.error("Failed to generate share URL:",P),B(""),Q("")}},[e,A,t,s]);uA.useEffect(()=>{G()},[G]),uA.useEffect(()=>{m(""),x("")},[e,A]);const T=uA.useCallback(async()=>{if(e){w(!0),x("");try{const P=await uUA(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{w(!1)}}},[e,A,t,s,o]),F=uA.useCallback(async P=>{try{let z;const Y=P.match(/\/p\/([A-Za-z0-9]{6,16})(?:#key=([A-Za-z0-9_-]+))?(?:\?|#|$)/);if(Y){const sA=Y[1],pA=Y[2],nA=await Gq(sA,o,pA);if(!nA)return{success:!1,count:0,planTitle:"",error:"Failed to load from short URL — paste may have expired"};z=nA}else{const sA=P.indexOf("#");if(sA===-1)return{success:!1,count:0,planTitle:"",error:"Invalid share URL: no hash fragment or short link found"};const pA=P.slice(sA+1);if(!pA)return{success:!1,count:0,planTitle:"",error:"Invalid share URL: empty hash"};z=await Pw(pA)}const _=(z.p||"").trim().split(`
526
- `).find(sA=>sA.startsWith("#")),AA=_?_.replace(/^#+\s*/,"").trim():"Unknown Plan",X=tD(z.a,z.d);if(X.length===0)return{success:!0,count:0,planTitle:AA,error:"No annotations found in share link"};const gA=X.filter(sA=>!A.some(pA=>pA.originalText===sA.originalText&&pA.type===sA.type&&pA.text===sA.text));if(gA.length>0&&(r(sA=>{const pA=X.filter(lA=>!sA.some(oA=>oA.originalText===lA.originalText&&oA.type===lA.type&&oA.text===lA.text));if(pA.length===0)return sA;const nA=[...sA,...pA];return v(nA),nA}),z.g?.length)){const sA=EB(z.g)??[];n(pA=>{const nA=new Set(pA.map(oA=>oA.path)),lA=sA.filter(oA=>!nA.has(oA.path));return lA.length>0?[...pA,...lA]:pA}),O(sA)}return{success:!0,count:gA.length,planTitle:AA}}catch(z){return{success:!1,count:0,planTitle:"",error:z instanceof Error?z.message:"Failed to decompress share URL"}}},[A,t,r,n,o]);return{isSharedSession:g,isLoadingShared:I,shareUrl:E,shareUrlSize:d,shortShareUrl:f,isGeneratingShortUrl:y,shortUrlError:S,pendingSharedAnnotations:b,sharedGlobalAttachments:N,clearPendingSharedAnnotations:H,refreshShareUrl:G,generateShortUrl:T,importFromShareUrl:F,shareLoadError:L,clearShareLoadError:k}}function hUA(e,A){const[t,i]=uA.useState(null),r=uA.useRef(null);return uA.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 Oq(e){window.close(),setTimeout(()=>{window.closed||e()},300)}function dUA(e){const[A,t]=uA.useState({phase:"idle"});uA.useEffect(()=>{if(!e)return;const r=pAA();r==="0"?(Oq(()=>t({phase:"closeFailed"})),t({phase:"closed"})):t(r!=="off"?{phase:"counting",remaining:Number(r)}:{phase:"prompt"})},[e]),uA.useEffect(()=>{if(A.phase!=="counting")return;if(A.remaining<=0){Oq(()=>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=uA.useCallback(()=>{mAA("3"),t({phase:"counting",remaining:3})},[]);return{state:A,enableAndStart:i}}const QUA=()=>R.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),fUA=()=>R.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:R.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 pUA({submitted:e,title:A,subtitle:t,agentLabel:i}){const{state:r,enableAndStart:n}=dUA(!!e);if(!e)return null;const a=e==="approved";return R.jsx("div",{className:"fixed inset-0 z-[100] bg-background flex items-center justify-center",children:R.jsxs("div",{className:"text-center space-y-6 max-w-md px-8",children:[R.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?R.jsx(QUA,{}):R.jsx(fUA,{})}),R.jsxs("div",{className:"space-y-2",children:[R.jsx("h2",{className:"text-xl font-semibold text-foreground",children:A}),R.jsx("p",{className:"text-muted-foreground",children:t})]}),R.jsx("div",{className:"pt-4 border-t border-border space-y-2",children:r.phase==="counting"?R.jsxs(R.Fragment,{children:[R.jsxs("p",{className:"text-sm text-muted-foreground",children:["This tab will close in ",R.jsx("span",{className:"text-foreground font-medium",children:r.remaining})," second",r.remaining!==1?"s":"","..."]}),R.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change this in Settings."})]}):r.phase==="closeFailed"?R.jsxs(R.Fragment,{children:[R.jsx("p",{className:"text-sm text-muted-foreground",children:"Could not close this tab automatically. Please close it manually."}),R.jsxs("p",{className:"text-xs text-muted-foreground/60",children:["Auto-close works when the tab is opened by ",i,"."]})]}):R.jsxs(R.Fragment,{children:[R.jsxs("p",{className:"text-sm text-muted-foreground",children:["You can close this tab and return to ",R.jsx("span",{className:"text-foreground font-medium",children:i}),"."]}),r.phase==="prompt"?R.jsxs(R.Fragment,{children:[R.jsxs("label",{className:"flex items-center justify-center gap-2 cursor-pointer group",children:[R.jsx("input",{type:"checkbox",checked:!1,onChange:n,className:"accent-primary"}),R.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-foreground transition-colors",children:"Auto-close this tab after 3 seconds"})]}),R.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change the delay in Settings."})]}):R.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Your response has been sent."})]})})]})})}const mUA="https://api.github.com/repos/backnotprop/plannotator/releases/latest",Uq={"0.5.0":{title:"Code Review is here!",description:"Review git diffs with inline annotations. Run /plannotator-review to try it."}};function yUA(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 DUA(){const[e,A]=uA.useState(null);return uA.useEffect(()=>{(async()=>{try{const i="0.14.2",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:Uq[C]});return}const a=await fetch(mUA);if(!a.ok)return;const s=await a.json(),o=s.tag_name,g=yUA(i,o),l=o.replace(/^v/,""),I=Uq[l];A({currentVersion:i,latestVersion:o,updateAvailable:g,releaseUrl:s.html_url,featureHighlight:I})}catch(i){console.debug("Update check failed:",i)}})()},[]),e}const wUA="pi install npm:@plannotator/pi-extension";function vUA(){return typeof navigator<"u"&&/^Win/.test(navigator.platform)?'powershell -c "irm https://plannotator.ai/install.ps1 | iex"':"curl -fsSL https://plannotator.ai/install.sh | bash"}const SUA=({origin:e})=>{const A=DUA(),[t,i]=uA.useState(!1),[r,n]=uA.useState(!1),o=new URLSearchParams(window.location.search).get("preview-origin")||e,g=o==="pi",l=o==="opencode",I=g?wUA:vUA();if(!A?.updateAvailable||r)return null;const C=async()=>{try{await navigator.clipboard.writeText(I),i(!0),setTimeout(()=>i(!1),2e3)}catch(B){console.error("Failed to copy:",B)}};return A.featureHighlight?R.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:R.jsxs("div",{className:"bg-card border border-primary/30 rounded-xl shadow-2xl overflow-hidden",children:[R.jsx("div",{className:"bg-gradient-to-r from-primary/20 to-primary/5 px-5 py-4 border-b border-border/50",children:R.jsxs("div",{className:"flex items-start justify-between gap-3",children:[R.jsxs("div",{className:"flex items-center gap-3",children:[R.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-primary/20 flex items-center justify-center",children:R.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.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"})})}),R.jsxs("div",{children:[R.jsx("h4",{className:"text-base font-semibold text-foreground",children:A.featureHighlight.title}),R.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["New in ",A.latestVersion]})]})]}),R.jsx("button",{onClick:()=>n(!0),className:"text-muted-foreground hover:text-foreground transition-colors p-1",children:R.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),R.jsxs("div",{className:"px-5 py-4",children:[R.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed",children:A.featureHighlight.description}),R.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:["You have ",A.currentVersion]}),l&&R.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install script, then restart OpenCode."}),g&&R.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install command, then restart Pi."}),R.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[R.jsx("button",{onClick:C,className:"flex-1 px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-lg hover:opacity-90 transition-opacity",children:t?"Copied!":"Copy install command"}),R.jsx("a",{href:A.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"})]})]})]})}):R.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:R.jsx("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4",children:R.jsxs("div",{className:"flex items-start gap-3",children:[R.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center",children:R.jsx("svg",{className:"w-4 h-4 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.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"})})}),R.jsxs("div",{className:"flex-1 min-w-0",children:[R.jsxs("div",{className:"flex items-center justify-between gap-2",children:[R.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Update available"}),R.jsx("button",{onClick:()=>n(!0),className:"text-muted-foreground hover:text-foreground transition-colors",children:R.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),R.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[A.latestVersion," is available (you have ",A.currentVersion,")"]}),R.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[R.jsx("button",{onClick:C,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:t?"Copied!":"Copy install command"}),R.jsx("a",{href:A.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"})]})]})]})})})},moA="plannotator-editor-mode",bUA="selection";function RUA(){const e=et.getItem(moA);return e==="selection"||e==="comment"||e==="redline"||e==="quickLabel"?e:bUA}function NUA(e){et.setItem(moA,e)}const yoA="plannotator-input-method",MUA="drag";function kUA(){const e=et.getItem(yoA);return e==="drag"||e==="pinpoint"?e:MUA}function xUA(e){et.setItem(yoA,e)}const LUA=300,TUA=300;function FUA(e,A){const t=uA.useRef("idle"),i=uA.useRef(0),r=uA.useRef(),n=uA.useRef(e);uA.useEffect(()=>{t.current==="idle"&&(n.current=e)},[e]);const a=uA.useCallback(s=>s==="drag"?"pinpoint":"drag",[]);uA.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>=TUA?(A(n.current),t.current="idle"):(t.current="tapped",r.current=setTimeout(()=>{t.current==="tapped"&&(A(n.current),t.current="idle")},LUA)))};return window.addEventListener("keydown",s),window.addEventListener("keyup",o),()=>{clearTimeout(r.current),window.removeEventListener("keydown",s),window.removeEventListener("keyup",o)}},[e,A,a])}function Kq({storageKey:e,defaultWidth:A=288,minWidth:t=200,maxWidth:i=600,side:r="right"}){const[n,a]=uA.useState(()=>{const Q=et.getItem(e);if(Q){const f=Number(Q);if(!Number.isNaN(f)&&f>=t&&f<=i)return f}return A}),[s,o]=uA.useState(!1),g=uA.useRef(0),l=uA.useRef(0),I=uA.useRef(n),C=uA.useCallback(Q=>{I.current=Q,a(Q)},[]),E=uA.useCallback(Q=>{Q.preventDefault(),g.current=Q.clientX,l.current=I.current,o(!0)},[]),B=uA.useCallback(Q=>{Q.preventDefault(),g.current=Q.touches[0].clientX,l.current=I.current,o(!0)},[]);uA.useEffect(()=>{if(!s)return;const Q=y=>"touches"in y?y.touches[0]?.clientX??y.changedTouches[0]?.clientX??0:y.clientX,f=y=>{const w=Q(y),S=r==="right"?g.current-w:w-g.current;C(Math.min(i,Math.max(t,l.current+S)))},m=()=>{o(!1),et.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 d=uA.useCallback(()=>{C(A),et.setItem(e,String(A))},[A,e,C]);return{width:n,isDragging:s,handleProps:{isDragging:s,onMouseDown:E,onTouchStart:B,onDoubleClick:d}}}const Yq=({isDragging:e,onMouseDown:A,onTouchStart:t,onDoubleClick:i,className:r})=>R.jsxs("div",{className:`relative w-1 cursor-col-resize flex-shrink-0 group${r?` ${r}`:""}`,children:[R.jsx("div",{className:`absolute inset-y-0 inset-x-0 transition-colors ${e?"bg-primary/50":"group-hover:bg-border"}`}),R.jsx("div",{className:"absolute inset-y-0 -inset-x-2",onMouseDown:A,onTouchStart:t,onDoubleClick:i})]}),GUA=({isPanelOpen:e,onTogglePanel:A,annotationCount:t,onOpenExport:i,onOpenSettings:r,onDownloadAnnotations:n,onCopyShareLink:a,onOpenImport:s,sharingEnabled:o,className:g})=>{const[l,I]=uA.useState(!1),C=uA.useRef(null),{theme:E,setTheme:B}=WU();uA.useEffect(()=>{if(!l)return;const Q=f=>{C.current&&!C.current.contains(f.target)&&I(!1)};return document.addEventListener("pointerdown",Q),()=>document.removeEventListener("pointerdown",Q)},[l]);const d=Q=>{I(!1),Q()};return R.jsxs("div",{className:`relative ${g??""}`,ref:C,children:[R.jsx("button",{onClick:()=>I(!l),className:"p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"Menu",children:l?R.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}):R.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})})}),l&&R.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:[R.jsxs("div",{className:"px-3 py-2",children:[R.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground mb-1.5",children:"Theme"}),R.jsx("div",{className:"flex items-center gap-1 bg-muted/50 rounded-lg p-0.5",children:["light","dark","system"].map(Q=>R.jsx("button",{onClick:()=>B(Q),className:`flex-1 px-2 py-1 text-[10px] capitalize rounded-md transition-colors ${E===Q?"bg-background text-foreground shadow-sm font-medium":"text-muted-foreground hover:text-foreground"}`,children:Q},Q))})]}),R.jsx("div",{className:"my-1 border-t border-border"}),R.jsx(Nu,{onClick:()=>d(r),icon:R.jsx(OUA,{}),label:"Settings"}),R.jsx(Nu,{onClick:()=>d(A),icon:R.jsx(UUA,{}),label:e?"Hide Annotations":"Show Annotations",badge:t>0?t:void 0}),R.jsx("div",{className:"my-1 border-t border-border"}),R.jsx(Nu,{onClick:()=>d(i),icon:R.jsx(KUA,{}),label:"Export"}),R.jsx(Nu,{onClick:()=>d(n),icon:R.jsx(YUA,{}),label:"Download Annotations"}),o&&R.jsx(Nu,{onClick:()=>d(a),icon:R.jsx(HUA,{}),label:"Copy Share Link"}),o&&R.jsxs(R.Fragment,{children:[R.jsx("div",{className:"my-1 border-t border-border"}),R.jsx(Nu,{onClick:()=>d(s),icon:R.jsx(PUA,{}),label:"Import Review"})]})]})]})},Nu=({onClick:e,icon:A,label:t,badge:i})=>R.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:[R.jsx("span",{className:"text-muted-foreground",children:A}),R.jsx("span",{className:"flex-1",children:t}),i!==void 0&&R.jsx("span",{className:"text-[10px] font-mono bg-muted px-1.5 py-0.5 rounded text-muted-foreground",children:i})]}),OUA=()=>R.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[R.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"}),R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),UUA=()=>R.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.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"})}),KUA=()=>R.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.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"})}),YUA=()=>R.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.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"})}),HUA=()=>R.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.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"})}),PUA=()=>R.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4M10 17l5-5-5-5M15 12H3"})}),JUA=({isOpen:e,onComplete:A})=>{const[t,i]=uA.useState("acceptEdits");if(!e)return null;const r=()=>{IoA(t),A(t)};return Zo.createPortal(R.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-background/90 backdrop-blur-sm p-4",children:R.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-lg shadow-2xl",children:[R.jsxs("div",{className:"p-5 border-b border-border",children:[R.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[R.jsx("div",{className:"p-1.5 rounded-lg bg-primary/15",children:R.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:R.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"})})}),R.jsx("h3",{className:"font-semibold text-base",children:"New: Permission Mode Preservation"})]}),R.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."}),R.jsxs("p",{className:"text-xs text-muted-foreground/70 mt-1",children:["Requires Claude Code 2.1.7 or later. Run ",R.jsx("code",{className:"bg-muted px-1 rounded",children:"claude update"})," to update."]})]}),R.jsx("div",{className:"p-4 space-y-2",children:NG.map(n=>R.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:[R.jsx("input",{type:"radio",name:"permissionMode",value:n.value,checked:t===n.value,onChange:()=>i(n.value),className:"mt-0.5 accent-primary"}),R.jsxs("div",{className:"flex-1",children:[R.jsx("div",{className:"text-sm font-medium",children:n.label}),R.jsx("div",{className:"text-xs text-muted-foreground",children:n.description})]})]},n.value))}),R.jsxs("div",{className:"p-4 border-t border-border flex justify-between items-center",children:[R.jsx("p",{className:"text-xs text-muted-foreground",children:"You can change this later in Settings."}),R.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 zUA(e){const[A,t]=uA.useState(e),[i,r]=uA.useState("toc"),n=uA.useCallback(o=>{t(!0),o&&r(o)},[]),a=uA.useCallback(()=>{t(!1)},[]),s=uA.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 qUA{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 d=-1/0,Q=1/0;const f=()=>{for(let m=Math.max(d,-g);m<=Math.min(Q,g);m+=2){let y;const w=E[m-1],S=E[m+1];w&&(E[m-1]=void 0);let x=!1;if(S){const v=S.oldPos-m;x=S&&0<=v&&v<s}const b=w&&w.oldPos+1<o;if(!x&&!b){E[m]=void 0;continue}if(!b||x&&w.oldPos<S.oldPos?y=this.addToPath(S,!0,!1,0,i):y=this.addToPath(w,!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&&(d=Math.max(d,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 WUA extends qUA{constructor(){super(...arguments),this.tokenize=jUA}equals(A,t,i){return i.ignoreWhitespace?((!i.newlineIsToken||!A.includes(`
526
+ `).find(sA=>sA.startsWith("#")),AA=_?_.replace(/^#+\s*/,"").trim():"Unknown Plan",X=tD(z.a,z.d);if(X.length===0)return{success:!0,count:0,planTitle:AA,error:"No annotations found in share link"};const gA=X.filter(sA=>!A.some(pA=>pA.originalText===sA.originalText&&pA.type===sA.type&&pA.text===sA.text));if(gA.length>0&&(r(sA=>{const pA=X.filter(lA=>!sA.some(oA=>oA.originalText===lA.originalText&&oA.type===lA.type&&oA.text===lA.text));if(pA.length===0)return sA;const nA=[...sA,...pA];return v(nA),nA}),z.g?.length)){const sA=EB(z.g)??[];n(pA=>{const nA=new Set(pA.map(oA=>oA.path)),lA=sA.filter(oA=>!nA.has(oA.path));return lA.length>0?[...pA,...lA]:pA}),O(sA)}return{success:!0,count:gA.length,planTitle:AA}}catch(z){return{success:!1,count:0,planTitle:"",error:z instanceof Error?z.message:"Failed to decompress share URL"}}},[A,t,r,n,o]);return{isSharedSession:g,isLoadingShared:I,shareUrl:E,shareUrlSize:d,shortShareUrl:f,isGeneratingShortUrl:y,shortUrlError:S,pendingSharedAnnotations:b,sharedGlobalAttachments:N,clearPendingSharedAnnotations:H,refreshShareUrl:G,generateShortUrl:T,importFromShareUrl:F,shareLoadError:L,clearShareLoadError:k}}function hUA(e,A){const[t,i]=uA.useState(null),r=uA.useRef(null);return uA.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 Oq(e){window.close(),setTimeout(()=>{window.closed||e()},300)}function dUA(e){const[A,t]=uA.useState({phase:"idle"});uA.useEffect(()=>{if(!e)return;const r=pAA();r==="0"?(Oq(()=>t({phase:"closeFailed"})),t({phase:"closed"})):t(r!=="off"?{phase:"counting",remaining:Number(r)}:{phase:"prompt"})},[e]),uA.useEffect(()=>{if(A.phase!=="counting")return;if(A.remaining<=0){Oq(()=>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=uA.useCallback(()=>{mAA("3"),t({phase:"counting",remaining:3})},[]);return{state:A,enableAndStart:i}}const QUA=()=>R.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),fUA=()=>R.jsx("svg",{className:"w-8 h-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:R.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 pUA({submitted:e,title:A,subtitle:t,agentLabel:i}){const{state:r,enableAndStart:n}=dUA(!!e);if(!e)return null;const a=e==="approved";return R.jsx("div",{className:"fixed inset-0 z-[100] bg-background flex items-center justify-center",children:R.jsxs("div",{className:"text-center space-y-6 max-w-md px-8",children:[R.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?R.jsx(QUA,{}):R.jsx(fUA,{})}),R.jsxs("div",{className:"space-y-2",children:[R.jsx("h2",{className:"text-xl font-semibold text-foreground",children:A}),R.jsx("p",{className:"text-muted-foreground",children:t})]}),R.jsx("div",{className:"pt-4 border-t border-border space-y-2",children:r.phase==="counting"?R.jsxs(R.Fragment,{children:[R.jsxs("p",{className:"text-sm text-muted-foreground",children:["This tab will close in ",R.jsx("span",{className:"text-foreground font-medium",children:r.remaining})," second",r.remaining!==1?"s":"","..."]}),R.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change this in Settings."})]}):r.phase==="closeFailed"?R.jsxs(R.Fragment,{children:[R.jsx("p",{className:"text-sm text-muted-foreground",children:"Could not close this tab automatically. Please close it manually."}),R.jsxs("p",{className:"text-xs text-muted-foreground/60",children:["Auto-close works when the tab is opened by ",i,"."]})]}):R.jsxs(R.Fragment,{children:[R.jsxs("p",{className:"text-sm text-muted-foreground",children:["You can close this tab and return to ",R.jsx("span",{className:"text-foreground font-medium",children:i}),"."]}),r.phase==="prompt"?R.jsxs(R.Fragment,{children:[R.jsxs("label",{className:"flex items-center justify-center gap-2 cursor-pointer group",children:[R.jsx("input",{type:"checkbox",checked:!1,onChange:n,className:"accent-primary"}),R.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-foreground transition-colors",children:"Auto-close this tab after 3 seconds"})]}),R.jsx("p",{className:"text-xs text-muted-foreground/60",children:"You can change the delay in Settings."})]}):R.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Your response has been sent."})]})})]})})}const mUA="https://api.github.com/repos/backnotprop/plannotator/releases/latest",Uq={"0.5.0":{title:"Code Review is here!",description:"Review git diffs with inline annotations. Run /plannotator-review to try it."}};function yUA(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 DUA(){const[e,A]=uA.useState(null);return uA.useEffect(()=>{(async()=>{try{const i="0.14.3",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:Uq[C]});return}const a=await fetch(mUA);if(!a.ok)return;const s=await a.json(),o=s.tag_name,g=yUA(i,o),l=o.replace(/^v/,""),I=Uq[l];A({currentVersion:i,latestVersion:o,updateAvailable:g,releaseUrl:s.html_url,featureHighlight:I})}catch(i){console.debug("Update check failed:",i)}})()},[]),e}const wUA="pi install npm:@plannotator/pi-extension";function vUA(){return typeof navigator<"u"&&/^Win/.test(navigator.platform)?'powershell -c "irm https://plannotator.ai/install.ps1 | iex"':"curl -fsSL https://plannotator.ai/install.sh | bash"}const SUA=({origin:e})=>{const A=DUA(),[t,i]=uA.useState(!1),[r,n]=uA.useState(!1),o=new URLSearchParams(window.location.search).get("preview-origin")||e,g=o==="pi",l=o==="opencode",I=g?wUA:vUA();if(!A?.updateAvailable||r)return null;const C=async()=>{try{await navigator.clipboard.writeText(I),i(!0),setTimeout(()=>i(!1),2e3)}catch(B){console.error("Failed to copy:",B)}};return A.featureHighlight?R.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:R.jsxs("div",{className:"bg-card border border-primary/30 rounded-xl shadow-2xl overflow-hidden",children:[R.jsx("div",{className:"bg-gradient-to-r from-primary/20 to-primary/5 px-5 py-4 border-b border-border/50",children:R.jsxs("div",{className:"flex items-start justify-between gap-3",children:[R.jsxs("div",{className:"flex items-center gap-3",children:[R.jsx("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-primary/20 flex items-center justify-center",children:R.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.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"})})}),R.jsxs("div",{children:[R.jsx("h4",{className:"text-base font-semibold text-foreground",children:A.featureHighlight.title}),R.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["New in ",A.latestVersion]})]})]}),R.jsx("button",{onClick:()=>n(!0),className:"text-muted-foreground hover:text-foreground transition-colors p-1",children:R.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),R.jsxs("div",{className:"px-5 py-4",children:[R.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed",children:A.featureHighlight.description}),R.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:["You have ",A.currentVersion]}),l&&R.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install script, then restart OpenCode."}),g&&R.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Run the install command, then restart Pi."}),R.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[R.jsx("button",{onClick:C,className:"flex-1 px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-lg hover:opacity-90 transition-opacity",children:t?"Copied!":"Copy install command"}),R.jsx("a",{href:A.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"})]})]})]})}):R.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:R.jsx("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4",children:R.jsxs("div",{className:"flex items-start gap-3",children:[R.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center",children:R.jsx("svg",{className:"w-4 h-4 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.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"})})}),R.jsxs("div",{className:"flex-1 min-w-0",children:[R.jsxs("div",{className:"flex items-center justify-between gap-2",children:[R.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Update available"}),R.jsx("button",{onClick:()=>n(!0),className:"text-muted-foreground hover:text-foreground transition-colors",children:R.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),R.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[A.latestVersion," is available (you have ",A.currentVersion,")"]}),R.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[R.jsx("button",{onClick:C,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:t?"Copied!":"Copy install command"}),R.jsx("a",{href:A.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"})]})]})]})})})},moA="plannotator-editor-mode",bUA="selection";function RUA(){const e=et.getItem(moA);return e==="selection"||e==="comment"||e==="redline"||e==="quickLabel"?e:bUA}function NUA(e){et.setItem(moA,e)}const yoA="plannotator-input-method",MUA="drag";function kUA(){const e=et.getItem(yoA);return e==="drag"||e==="pinpoint"?e:MUA}function xUA(e){et.setItem(yoA,e)}const LUA=300,TUA=300;function FUA(e,A){const t=uA.useRef("idle"),i=uA.useRef(0),r=uA.useRef(),n=uA.useRef(e);uA.useEffect(()=>{t.current==="idle"&&(n.current=e)},[e]);const a=uA.useCallback(s=>s==="drag"?"pinpoint":"drag",[]);uA.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>=TUA?(A(n.current),t.current="idle"):(t.current="tapped",r.current=setTimeout(()=>{t.current==="tapped"&&(A(n.current),t.current="idle")},LUA)))};return window.addEventListener("keydown",s),window.addEventListener("keyup",o),()=>{clearTimeout(r.current),window.removeEventListener("keydown",s),window.removeEventListener("keyup",o)}},[e,A,a])}function Kq({storageKey:e,defaultWidth:A=288,minWidth:t=200,maxWidth:i=600,side:r="right"}){const[n,a]=uA.useState(()=>{const Q=et.getItem(e);if(Q){const f=Number(Q);if(!Number.isNaN(f)&&f>=t&&f<=i)return f}return A}),[s,o]=uA.useState(!1),g=uA.useRef(0),l=uA.useRef(0),I=uA.useRef(n),C=uA.useCallback(Q=>{I.current=Q,a(Q)},[]),E=uA.useCallback(Q=>{Q.preventDefault(),g.current=Q.clientX,l.current=I.current,o(!0)},[]),B=uA.useCallback(Q=>{Q.preventDefault(),g.current=Q.touches[0].clientX,l.current=I.current,o(!0)},[]);uA.useEffect(()=>{if(!s)return;const Q=y=>"touches"in y?y.touches[0]?.clientX??y.changedTouches[0]?.clientX??0:y.clientX,f=y=>{const w=Q(y),S=r==="right"?g.current-w:w-g.current;C(Math.min(i,Math.max(t,l.current+S)))},m=()=>{o(!1),et.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 d=uA.useCallback(()=>{C(A),et.setItem(e,String(A))},[A,e,C]);return{width:n,isDragging:s,handleProps:{isDragging:s,onMouseDown:E,onTouchStart:B,onDoubleClick:d}}}const Yq=({isDragging:e,onMouseDown:A,onTouchStart:t,onDoubleClick:i,className:r})=>R.jsxs("div",{className:`relative w-1 cursor-col-resize flex-shrink-0 group${r?` ${r}`:""}`,children:[R.jsx("div",{className:`absolute inset-y-0 inset-x-0 transition-colors ${e?"bg-primary/50":"group-hover:bg-border"}`}),R.jsx("div",{className:"absolute inset-y-0 -inset-x-2",onMouseDown:A,onTouchStart:t,onDoubleClick:i})]}),GUA=({isPanelOpen:e,onTogglePanel:A,annotationCount:t,onOpenExport:i,onOpenSettings:r,onDownloadAnnotations:n,onCopyShareLink:a,onOpenImport:s,sharingEnabled:o,className:g})=>{const[l,I]=uA.useState(!1),C=uA.useRef(null),{theme:E,setTheme:B}=WU();uA.useEffect(()=>{if(!l)return;const Q=f=>{C.current&&!C.current.contains(f.target)&&I(!1)};return document.addEventListener("pointerdown",Q),()=>document.removeEventListener("pointerdown",Q)},[l]);const d=Q=>{I(!1),Q()};return R.jsxs("div",{className:`relative ${g??""}`,ref:C,children:[R.jsx("button",{onClick:()=>I(!l),className:"p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"Menu",children:l?R.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}):R.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})})}),l&&R.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:[R.jsxs("div",{className:"px-3 py-2",children:[R.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground mb-1.5",children:"Theme"}),R.jsx("div",{className:"flex items-center gap-1 bg-muted/50 rounded-lg p-0.5",children:["light","dark","system"].map(Q=>R.jsx("button",{onClick:()=>B(Q),className:`flex-1 px-2 py-1 text-[10px] capitalize rounded-md transition-colors ${E===Q?"bg-background text-foreground shadow-sm font-medium":"text-muted-foreground hover:text-foreground"}`,children:Q},Q))})]}),R.jsx("div",{className:"my-1 border-t border-border"}),R.jsx(Nu,{onClick:()=>d(r),icon:R.jsx(OUA,{}),label:"Settings"}),R.jsx(Nu,{onClick:()=>d(A),icon:R.jsx(UUA,{}),label:e?"Hide Annotations":"Show Annotations",badge:t>0?t:void 0}),R.jsx("div",{className:"my-1 border-t border-border"}),R.jsx(Nu,{onClick:()=>d(i),icon:R.jsx(KUA,{}),label:"Export"}),R.jsx(Nu,{onClick:()=>d(n),icon:R.jsx(YUA,{}),label:"Download Annotations"}),o&&R.jsx(Nu,{onClick:()=>d(a),icon:R.jsx(HUA,{}),label:"Copy Share Link"}),o&&R.jsxs(R.Fragment,{children:[R.jsx("div",{className:"my-1 border-t border-border"}),R.jsx(Nu,{onClick:()=>d(s),icon:R.jsx(PUA,{}),label:"Import Review"})]})]})]})},Nu=({onClick:e,icon:A,label:t,badge:i})=>R.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:[R.jsx("span",{className:"text-muted-foreground",children:A}),R.jsx("span",{className:"flex-1",children:t}),i!==void 0&&R.jsx("span",{className:"text-[10px] font-mono bg-muted px-1.5 py-0.5 rounded text-muted-foreground",children:i})]}),OUA=()=>R.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[R.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"}),R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),UUA=()=>R.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.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"})}),KUA=()=>R.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.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"})}),YUA=()=>R.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.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"})}),HUA=()=>R.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.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"})}),PUA=()=>R.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4M10 17l5-5-5-5M15 12H3"})}),JUA=({isOpen:e,onComplete:A})=>{const[t,i]=uA.useState("acceptEdits");if(!e)return null;const r=()=>{IoA(t),A(t)};return Zo.createPortal(R.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-background/90 backdrop-blur-sm p-4",children:R.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-lg shadow-2xl",children:[R.jsxs("div",{className:"p-5 border-b border-border",children:[R.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[R.jsx("div",{className:"p-1.5 rounded-lg bg-primary/15",children:R.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:R.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"})})}),R.jsx("h3",{className:"font-semibold text-base",children:"New: Permission Mode Preservation"})]}),R.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."}),R.jsxs("p",{className:"text-xs text-muted-foreground/70 mt-1",children:["Requires Claude Code 2.1.7 or later. Run ",R.jsx("code",{className:"bg-muted px-1 rounded",children:"claude update"})," to update."]})]}),R.jsx("div",{className:"p-4 space-y-2",children:NG.map(n=>R.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:[R.jsx("input",{type:"radio",name:"permissionMode",value:n.value,checked:t===n.value,onChange:()=>i(n.value),className:"mt-0.5 accent-primary"}),R.jsxs("div",{className:"flex-1",children:[R.jsx("div",{className:"text-sm font-medium",children:n.label}),R.jsx("div",{className:"text-xs text-muted-foreground",children:n.description})]})]},n.value))}),R.jsxs("div",{className:"p-4 border-t border-border flex justify-between items-center",children:[R.jsx("p",{className:"text-xs text-muted-foreground",children:"You can change this later in Settings."}),R.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 zUA(e){const[A,t]=uA.useState(e),[i,r]=uA.useState("toc"),n=uA.useCallback(o=>{t(!0),o&&r(o)},[]),a=uA.useCallback(()=>{t(!1)},[]),s=uA.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 qUA{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 d=-1/0,Q=1/0;const f=()=>{for(let m=Math.max(d,-g);m<=Math.min(Q,g);m+=2){let y;const w=E[m-1],S=E[m+1];w&&(E[m-1]=void 0);let x=!1;if(S){const v=S.oldPos-m;x=S&&0<=v&&v<s}const b=w&&w.oldPos+1<o;if(!x&&!b){E[m]=void 0;continue}if(!b||x&&w.oldPos<S.oldPos?y=this.addToPath(S,!0,!1,0,i):y=this.addToPath(w,!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&&(d=Math.max(d,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 WUA extends qUA{constructor(){super(...arguments),this.tokenize=jUA}equals(A,t,i){return i.ignoreWhitespace?((!i.newlineIsToken||!A.includes(`
527
527
  `))&&(A=A.trim()),(!i.newlineIsToken||!t.includes(`
528
528
  `))&&(t=t.trim())):i.ignoreNewlineAtEof&&!i.newlineIsToken&&(A.endsWith(`
529
529
  `)&&(A=A.slice(0,-1)),t.endsWith(`
@@ -870,7 +870,7 @@ export const CursorOverlay: React.FC<CursorOverlayProps> = ({
870
870
  ---
871
871
 
872
872
  **Target:** Ship MVP in next sprint
873
- `,y4A=()=>{const[e,A]=uA.useState(m4A),[t,i]=uA.useState([]),[r,n]=uA.useState(null),[a,s]=uA.useState([]),[o,g]=uA.useState(null),[l,I]=uA.useState(!1),[C,E]=uA.useState(!1),[B,d]=uA.useState(!1),[Q,f]=uA.useState(!1),[m,y]=uA.useState(!1),[w,S]=uA.useState(""),[x,b]=uA.useState(()=>window.innerWidth>=768),[v,N]=uA.useState(!1),[O,L]=uA.useState(RUA),[K,H]=uA.useState(kUA),[k,U]=uA.useState(()=>et.getItem("plannotator-tater-mode")==="true"),[G,T]=uA.useState(()=>RG()),[F,P]=uA.useState(!1),[z,Y]=uA.useState(null),[V,_]=uA.useState([]),[AA,X]=uA.useState(!1),[gA,sA]=uA.useState(null),[pA,nA]=uA.useState(void 0),[lA,oA]=uA.useState(!0),[aA,hA]=uA.useState(!1),[IA,xA]=uA.useState(null),[BA,jA]=uA.useState(null),[iA,re]=uA.useState(!1),[MA,ce]=uA.useState("bypassPermissions"),[Ie,de]=uA.useState(!0),[OA,ne]=uA.useState(void 0),[YA,DA]=uA.useState(void 0),[qA,NA]=uA.useState(null),[_A,EA]=uA.useState(!1),[yA,j]=uA.useState(),[mA,CA]=uA.useState(null),wA=uA.useMemo(()=>t.filter(Z=>!!Z.diffContext),[t]),bA=uA.useMemo(()=>t.filter(Z=>!Z.diffContext),[t]),[FA,HA]=uA.useState(!1),[GA,XA]=uA.useState("clean"),[se,ye]=uA.useState(null),[SA,JA]=uA.useState(null),UA=uA.useRef(null),oe=uA.useRef(null),Te=Kq({storageKey:"plannotator-panel-width"}),ve=Kq({storageKey:"plannotator-toc-width",defaultWidth:240,minWidth:160,maxWidth:400,side:"left"}),eA=Te.isDragging||ve.isDragging,ae=zUA(RG().tocEnabled);uA.useEffect(()=>{G.tocEnabled?ae.open("toc"):ae.close()},[G.tocEnabled]),uA.useEffect(()=>{ae.activeTab==="toc"&&FA&&HA(!1)},[ae.activeTab]),uA.useEffect(()=>{if(!FA)return;const Z=tA=>{tA.key==="Escape"&&HA(!1)};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[FA]);const Ae=XUA(e,se,SA),Qe=$UA({markdown:e,annotations:t,selectedAnnotationId:r,globalAttachments:V,setMarkdown:A,setAnnotations:i,setSelectedAnnotationId:n,setGlobalAttachments:_,viewerRef:UA,sidebar:ae}),De=A4A(),Ge=uA.useMemo(()=>SOA(),[G]),Me=uA.useMemo(()=>{if(!Ge)return"";const Z=Zc();return jc(Z)},[Ge,G]);uA.useEffect(()=>{Ge||De.setActiveFile(null)},[Ge]),uA.useEffect(()=>{ae.activeTab==="vault"&&Ge&&Me&&De.tree.length===0&&!De.isLoading&&De.fetchTree(Me)},[ae.activeTab,Ge,Me]);const We=to.useCallback(Z=>tA=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(Z)}&path=${encodeURIComponent(tA)}`,[]),ft=to.useCallback(Z=>{Qe.open(Z,We(Me)),De.setActiveFile(Z)},[Me,Qe,De,We]),Ze=to.useCallback(Z=>{if(De.activeFile&&Me)Qe.open(Z,We(Me));else{const tA=Qe.filepath?Qe.filepath.replace(/\/[^/]+$/,""):pA;tA?Qe.open(Z,dA=>`/api/doc?path=${encodeURIComponent(dA)}&base=${encodeURIComponent(tA)}`):Qe.open(Z)}},[De.activeFile,Me,Qe,We,pA]),ut=to.useCallback(()=>{Qe.back(),De.setActiveFile(null)},[Qe,De]),qt=to.useCallback(()=>{De.fetchTree(Me)},[De,Me]),Kt=uA.useMemo(()=>a.filter(Z=>Z.type==="heading").length,[a]),ht=hUA(oe,Kt),{isSharedSession:Nt,isLoadingShared:di,shareUrl:He,shareUrlSize:zA,shortShareUrl:Se,isGeneratingShortUrl:Ve,shortUrlError:Ut,pendingSharedAnnotations:_t,clearPendingSharedAnnotations:ot,generateShortUrl:Qi,importFromShareUrl:Hi,shareLoadError:li,clearShareLoadError:ke}=BUA(e,t,V,A,i,_,()=>{oA(!1)},OA,YA),{draftBanner:me,restoreDraft:Ne,dismissDraft:be}=i4A({annotations:t,globalAttachments:V,isApiMode:F,isSharedSession:Nt,submitted:!!IA}),{editorAnnotations:fe,deleteEditorAnnotation:at}=n4A(),kA=to.useCallback(()=>{const{annotations:Z,globalAttachments:tA}=Ne();Z.length>0&&(i(Z),tA.length>0&&_(tA),setTimeout(()=>{UA.current?.applySharedAnnotations(Z.filter(dA=>!dA.diffContext))},100))},[Ne]),{getAgentWarning:Ti}=uoA(z);uA.useEffect(()=>{if(_t&&_t.length>0){const Z=setTimeout(()=>{UA.current?.clearAllHighlights(),UA.current?.applySharedAnnotations(_t.filter(tA=>!tA.diffContext)),ot()},100);return()=>clearTimeout(Z)}},[_t,ot]);const TA=Z=>{U(Z),et.setItem("plannotator-tater-mode",String(Z))},Lt=Z=>{L(Z),NUA(Z)},Da=Z=>{H(Z),xUA(Z)};FUA(K,Da),uA.useEffect(()=>{di||Nt||fetch("/api/plan").then(Z=>{if(!Z.ok)throw new Error("Not in API mode");return Z.json()}).then(Z=>{Z.plan&&A(Z.plan),P(!0),(Z.mode==="annotate"||Z.mode==="annotate-last")&&X(!0),Z.mode&&sA(Z.mode==="annotate-last"?"message":"file"),Z.filePath&&nA(Z.filePath.replace(/\/[^/]+$/,"")),Z.sharingEnabled!==void 0&&de(Z.sharingEnabled),Z.shareBaseUrl&&ne(Z.shareBaseUrl),Z.pasteApiUrl&&DA(Z.pasteApiUrl),Z.repoInfo&&NA(Z.repoInfo),Z.previousPlan!==void 0&&ye(Z.previousPlan),Z.versionInfo&&JA(Z.versionInfo),Z.origin&&(Y(Z.origin),Z.origin==="claude-code"&&XOA()&&re(!0),ce(coA().mode))}).catch(()=>{P(!1)}).finally(()=>oA(!1))},[di,Nt]),uA.useEffect(()=>{const{frontmatter:Z}=uAA(e);g(Z),s(BAA(e))},[e]);const ra=uA.useRef(!1),bn=uA.useRef({}),na=uA.useRef(null);uA.useEffect(()=>{ra.current=!1,bn.current={},na.current=null},[e]),uA.useEffect(()=>{if(!F||!e||Nt||AA||ra.current)return;const Z={},tA=[],dA=Zc();if(dA.autoSave&&dA.enabled){const le=jc(dA);le&&(Z.obsidian={vaultPath:le,folder:dA.folder||"plannotator",plan:e,...dA.filenameFormat&&{filenameFormat:dA.filenameFormat},...dA.filenameSeparator&&dA.filenameSeparator!=="space"&&{filenameSeparator:dA.filenameSeparator}},tA.push("Obsidian"))}const LA=Kc();LA.autoSave&&LA.enabled&&(Z.bear={plan:e,customTags:LA.customTags,tagPosition:LA.tagPosition},tA.push("Bear"));const WA=CB();if(WA.autoSave&&Fd()&&(Z.octarine={plan:e,workspace:WA.workspace,folder:WA.folder||"plannotator"},tA.push("Octarine")),tA.length===0)return;ra.current=!0;const te=fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Z)}).then(le=>le.json()).then(le=>{const ze={...Z.obsidian?{obsidian:!!le.results?.obsidian?.success}:{},...Z.bear?{bear:!!le.results?.bear?.success}:{},...Z.octarine?{octarine:!!le.results?.octarine?.success}:{}};bn.current=ze;const St=tA.filter(bt=>!le.results?.[bt.toLowerCase()]?.success);return St.length===0?CA({type:"success",message:`Auto-saved to ${tA.join(" & ")}`}):CA({type:"error",message:`Auto-save failed for ${St.join(" & ")}`}),ze}).catch(()=>(bn.current={},CA({type:"error",message:"Auto-save failed"}),{})).finally(()=>setTimeout(()=>CA(null),3e3));na.current=te},[F,e,Nt,AA]),uA.useEffect(()=>{const Z=tA=>{const dA=tA.clipboardData?.items;if(dA){for(const LA of dA)if(LA.type.startsWith("image/")){tA.preventDefault();const WA=LA.getAsFile();if(WA){const te=BF(WA.name,V.map(ze=>ze.name)),le=URL.createObjectURL(WA);jA({file:WA,blobUrl:le,initialName:te})}break}}};return document.addEventListener("paste",Z),()=>document.removeEventListener("paste",Z)},[V]);const Xi=async(Z,tA,dA)=>{if(BA)try{const LA=new FormData,WA=tA?new File([Z],"annotated.png",{type:"image/png"}):BA.file;LA.append("file",WA);const te=await fetch("/api/upload",{method:"POST",body:LA});if(te.ok){const le=await te.json();_(ze=>[...ze,{path:le.path,name:dA}])}}catch{}finally{URL.revokeObjectURL(BA.blobUrl),jA(null)}},$i=()=>{BA&&(URL.revokeObjectURL(BA.blobUrl),jA(null))},On=async()=>{hA(!0);try{const Z=Zc(),tA=Kc(),dA=CB(),LA=ZU(),WA=bG(),te=tA.autoSave&&na.current?await na.current:bn.current,le={};z==="claude-code"&&(le.permissionMode=MA);const ze=VOA(LA);ze&&(le.agentSwitch=ze),le.planSave={enabled:WA.enabled,...WA.customPath&&{customPath:WA.customPath}};const St=jc(Z);Z.enabled&&St&&(le.obsidian={vaultPath:St,folder:Z.folder||"plannotator",plan:e,...Z.filenameFormat&&{filenameFormat:Z.filenameFormat},...Z.filenameSeparator&&Z.filenameSeparator!=="space"&&{filenameSeparator:Z.filenameSeparator}}),tA.enabled&&!(tA.autoSave&&te.bear)&&(le.bear={plan:e,customTags:tA.customTags,tagPosition:tA.tagPosition}),Fd()&&(le.octarine={plan:e,workspace:dA.workspace,folder:dA.folder||"plannotator"});const bt=Array.from(Qe.getDocAnnotations().values()).some(Zt=>Zt.annotations.length>0||Zt.globalAttachments.length>0);(t.length>0||V.length>0||bt||fe.length>0)&&(le.feedback=mi),await fetch("/api/approve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(le)}),xA("approved")}catch{hA(!1)}},Un=async()=>{hA(!0);try{const Z=bG();await fetch("/api/deny",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:mi,planSave:{enabled:Z.enabled,...Z.customPath&&{customPath:Z.customPath}}})}),xA("denied")}catch{hA(!1)}},wa=async()=>{hA(!0);try{await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:mi,annotations:t})}),xA("denied")}catch{hA(!1)}};uA.useEffect(()=>{const Z=tA=>{if(tA.key!=="Enter"||!(tA.metaKey||tA.ctrlKey))return;const dA=tA.target?.tagName;if(!(dA==="INPUT"||dA==="TEXTAREA")&&!(l||C||B||Q||m||iA||BA)&&!(IA||aA)&&F&&!Qe.isActive){if(tA.preventDefault(),AA){t.length===0?d(!0):wa();return}if(t.length===0&&fe.length===0){if(z==="opencode"){const LA=Ti();if(LA){S(LA),y(!0);return}}On()}else Un()}};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[l,C,B,Q,m,iA,BA,IA,aA,F,Qe.isActive,t.length,AA,z,Ti]);const Ar=Z=>{i(tA=>[...tA,Z]),n(Z.id),b(!0)},Za=to.useCallback(Z=>{n(Z),Z&&window.innerWidth<768&&b(!0)},[]),er=Z=>{UA.current?.removeHighlight(Z),i(tA=>tA.filter(dA=>dA.id!==Z)),r===Z&&n(null)},ct=(Z,tA)=>{i(dA=>dA.map(LA=>LA.id===Z?{...LA,...tA}:LA))},Dt=(Z,tA)=>{i(dA=>dA.map(LA=>LA.author===Z?{...LA,author:tA}:LA))},xi=Z=>{_(tA=>[...tA,Z])},Vt=Z=>{_(tA=>tA.filter(dA=>dA.path!==Z))},Ur=Z=>{},mi=uA.useMemo(()=>{const Z=Qe.getDocAnnotations(),tA=Array.from(Z.values()).some(te=>te.annotations.length>0||te.globalAttachments.length>0),dA=t.length>0||V.length>0,LA=fe.length>0;if(!dA&&!tA&&!LA)return"No changes detected.";let WA=dA?WQA(a,t,V,gA==="message"?"Message Feedback":gA==="file"?"File Feedback":"Plan Feedback",gA??"plan"):"";return tA&&(WA+=VQA(Z)),LA&&(WA+=ZQA(fe)),WA},[a,t,V,Qe.getDocAnnotations,fe]),ln=()=>{EA(!1);const Z=new Blob([mi],{type:"text/plain"}),tA=URL.createObjectURL(Z),dA=document.createElement("a");dA.href=tA,dA.download="annotations.md",dA.click(),URL.revokeObjectURL(tA),CA({type:"success",message:"Downloaded annotations"}),setTimeout(()=>CA(null),3e3)},Cr=async Z=>{EA(!1);const tA={};if(Z==="obsidian"){const LA=Zc(),WA=jc(LA);WA&&(tA.obsidian={vaultPath:WA,folder:LA.folder||"plannotator",plan:e,...LA.filenameFormat&&{filenameFormat:LA.filenameFormat},...LA.filenameSeparator&&LA.filenameSeparator!=="space"&&{filenameSeparator:LA.filenameSeparator}})}if(Z==="bear"){const LA=Kc();tA.bear={plan:e,customTags:LA.customTags,tagPosition:LA.tagPosition}}if(Z==="octarine"){const LA=CB();tA.octarine={plan:e,workspace:LA.workspace,folder:LA.folder||"plannotator"}}const dA=Z==="obsidian"?"Obsidian":Z==="bear"?"Bear":"Octarine";try{const te=(await(await fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(tA)})).json()).results?.[Z];te?.success?CA({type:"success",message:`Saved to ${dA}`}):CA({type:"error",message:te?.error||"Save failed"})}catch{CA({type:"error",message:"Save failed"})}setTimeout(()=>CA(null),3e3)};uA.useEffect(()=>{const Z=tA=>{if(tA.key!=="s"||!(tA.metaKey||tA.ctrlKey))return;const dA=tA.target?.tagName;if(dA==="INPUT"||dA==="TEXTAREA"||l||B||Q||m||iA||BA||IA||!F)return;tA.preventDefault();const LA=EoA(),WA=D2(),te=Kc().enabled,le=Fd();LA==="download"?ln():LA==="obsidian"&&WA?Cr("obsidian"):LA==="bear"&&te?Cr("bear"):LA==="octarine"&&le?Cr("octarine"):(j("notes"),I(!0))};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[l,B,Q,m,iA,BA,IA,F,e,mi]),uA.useEffect(()=>{if(!_A)return;const Z=tA=>{tA.target.closest("[data-export-dropdown]")||EA(!1)};return document.addEventListener("pointerdown",Z),()=>document.removeEventListener("pointerdown",Z)},[_A]);const Ye=uA.useMemo(()=>z==="opencode"?"OpenCode":z==="claude-code"?"Claude Code":z==="pi"?"Pi":z==="codex"?"Codex":"Coding Agent",[z]),q=uA.useMemo(()=>({compact:832,default:1040,wide:1280})[G.planWidth]??832,[G.planWidth]);return R.jsx(xOA,{defaultTheme:"dark",children:R.jsxs("div",{className:"h-screen flex flex-col bg-background overflow-hidden",children:[R.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:[R.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[R.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:R.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Plannotator"})}),R.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.14.2"]}),z&&R.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium hidden md:inline ${z==="claude-code"?"bg-orange-500/15 text-orange-400":z==="pi"?"bg-violet-500/15 text-violet-400":"bg-zinc-500/20 text-zinc-400"}`,children:Ye})]}),R.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[F&&!Qe.isActive&&R.jsxs(R.Fragment,{children:[R.jsxs("button",{onClick:()=>{t.length===0&&fe.length===0?d(!0):AA?wa():Un()},disabled:aA,className:`p-1.5 md:px-2.5 md:py-1 rounded-md text-xs font-medium transition-all ${aA?"opacity-50 cursor-not-allowed bg-muted text-muted-foreground":"bg-accent/15 text-accent hover:bg-accent/25 border border-accent/30"}`,title:"Send Feedback",children:[R.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),R.jsx("span",{className:"hidden md:inline",children:aA?"Sending...":AA?"Send Annotations":"Send Feedback"})]}),!AA&&R.jsxs("div",{className:"relative group/approve",children:[R.jsxs("button",{onClick:()=>{if(z==="claude-code"&&t.length>0){f(!0);return}if(z==="opencode"){const Z=Ti();if(Z){S(Z),y(!0);return}}On()},disabled:aA,className:`px-2 py-1 md:px-2.5 rounded-md text-xs font-medium transition-all ${aA?"opacity-50 cursor-not-allowed bg-muted text-muted-foreground":z==="claude-code"&&t.length>0?"bg-success/50 text-success-foreground/70 hover:bg-success hover:text-success-foreground":"bg-success text-success-foreground hover:opacity-90"}`,children:[R.jsx("span",{className:"md:hidden",children:aA?"...":"OK"}),R.jsx("span",{className:"hidden md:inline",children:aA?"Approving...":"Approve"})]}),z==="claude-code"&&t.length>0&&R.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:[R.jsx("div",{className:"absolute bottom-full right-4 border-4 border-transparent border-b-border"}),R.jsx("div",{className:"absolute bottom-full right-4 mt-px border-4 border-transparent border-b-popover"}),Ye," doesn't support feedback on approval. Your annotations won't be seen."]})]}),R.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"})]}),R.jsxs("div",{className:"hidden md:flex items-center gap-2",children:[R.jsx(LOA,{}),!Qe.isActive&&R.jsx(gUA,{taterMode:k,onTaterModeChange:TA,onIdentityChange:Dt,origin:z,onUIPreferencesChange:T,externalOpen:v,onExternalClose:()=>N(!1)}),R.jsx("button",{onClick:()=>b(!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:R.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.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"})})}),R.jsxs("div",{className:"relative flex","data-export-dropdown":!0,children:[R.jsx("button",{onClick:()=>{j(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"}),R.jsx("button",{onClick:()=>EA(Z=>!Z),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:R.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}),_A&&R.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:[Ie&&R.jsxs("button",{onClick:async()=>{EA(!1);try{await navigator.clipboard.writeText(He),CA({type:"success",message:"Share link copied"})}catch{CA({type:"error",message:"Failed to copy"})}setTimeout(()=>CA(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:[R.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.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"]}),R.jsxs("button",{onClick:ln,className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[R.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.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"]}),F&&D2()&&R.jsxs("button",{onClick:()=>Cr("obsidian"),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[R.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),"Save to Obsidian"]}),F&&Kc().enabled&&R.jsxs("button",{onClick:()=>Cr("bear"),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[R.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),"Save to Bear"]}),F&&Fd()&&R.jsxs("button",{onClick:()=>Cr("octarine"),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[R.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),"Save to Octarine"]}),F&&!D2()&&!Kc().enabled&&!Fd()&&R.jsx("div",{className:"px-3 py-2 text-[10px] text-muted-foreground",children:"No notes apps configured."}),Ie&&R.jsxs(R.Fragment,{children:[R.jsx("div",{className:"my-1 border-t border-border"}),R.jsxs("button",{onClick:()=>{EA(!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:[R.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.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"]})]})]})]})]}),R.jsx(GUA,{className:"md:hidden",isPanelOpen:x,onTogglePanel:()=>b(!x),annotationCount:t.length+fe.length,onOpenExport:()=>{j(void 0),I(!0)},onOpenSettings:()=>N(!0),onDownloadAnnotations:ln,onCopyShareLink:async()=>{try{await navigator.clipboard.writeText(He),CA({type:"success",message:"Share link copied"})}catch{CA({type:"error",message:"Failed to copy"})}setTimeout(()=>CA(null),3e3)},onOpenImport:()=>E(!0),sharingEnabled:Ie})]})]}),Qe.error&&R.jsxs("div",{className:"bg-destructive/10 border-b border-destructive/20 px-4 py-2 flex items-center gap-2 flex-shrink-0",children:[R.jsx("span",{className:"text-xs text-destructive",children:Qe.error}),R.jsx("button",{onClick:Qe.dismissError,className:"ml-auto text-xs text-destructive/60 hover:text-destructive",children:"dismiss"})]}),R.jsxs("div",{className:`flex-1 flex overflow-hidden relative z-0 ${eA?"select-none":""}`,children:[k&&R.jsx(JOA,{}),!ae.isOpen&&R.jsx(a4A,{activeTab:ae.activeTab,onToggleTab:ae.toggleTab,hasDiff:Ae.hasPreviousVersion,showVaultTab:Ge,className:"hidden lg:flex"}),ae.isOpen&&R.jsxs(R.Fragment,{children:[R.jsx(C4A,{activeTab:ae.activeTab,onTabChange:ae.toggleTab,onClose:ae.close,width:ve.width,blocks:a,annotations:t,activeSection:ht,onTocNavigate:Ur,linkedDocFilepath:Qe.filepath,onLinkedDocBack:Qe.isActive?ut:void 0,showVaultTab:Ge,vaultPath:Me,vaultBrowser:De,onVaultSelectFile:ft,onVaultFetchTree:qt,versionInfo:SA,versions:Ae.versions,projectPlans:Ae.projectPlans,selectedBaseVersion:Ae.diffBaseVersion,onSelectBaseVersion:Ae.selectBaseVersion,isPlanDiffActive:FA,hasPreviousVersion:Ae.hasPreviousVersion,onActivatePlanDiff:()=>HA(!0),isLoadingVersions:Ae.isLoadingVersions,isSelectingVersion:Ae.isSelectingVersion,fetchingVersion:Ae.fetchingVersion,onFetchVersions:Ae.fetchVersions,onFetchProjectPlans:Ae.fetchProjectPlans}),R.jsx(Yq,{...ve.handleProps,className:"hidden lg:block"})]}),R.jsxs("main",{ref:oe,className:"flex-1 min-w-0 overflow-y-auto bg-grid",children:[R.jsx(Gd,{isOpen:!!me,onClose:be,onConfirm:kA,title:"Draft Recovered",message:me?`Found ${me.count} annotation${me.count!==1?"s":""} from ${me.timeAgo}. Would you like to restore them?`:"",confirmText:"Restore",cancelText:"Dismiss",showCancel:!0}),R.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:[!FA&&R.jsx("div",{className:"w-full mb-3 md:mb-4 flex items-center justify-start",style:{maxWidth:q},children:R.jsx(OOA,{inputMethod:K,onInputMethodChange:Da,mode:O,onModeChange:Lt,taterMode:k})}),Ae.diffBlocks&&Ae.diffStats&&R.jsx("div",{className:"w-full flex justify-center",style:{display:FA?void 0:"none"},children:R.jsx(p4A,{diffBlocks:Ae.diffBlocks,diffStats:Ae.diffStats,diffMode:GA,onDiffModeChange:XA,onPlanDiffToggle:()=>HA(!1),repoInfo:qA,baseVersionLabel:Ae.diffBaseVersion!=null?`v${Ae.diffBaseVersion}`:void 0,baseVersion:Ae.diffBaseVersion??void 0,maxWidth:q,annotations:wA,onAddAnnotation:Ar,onSelectAnnotation:Za,selectedAnnotationId:r,mode:O})}),R.jsx("div",{className:"w-full flex justify-center",style:{display:FA&&Ae.diffBlocks?"none":void 0},children:R.jsx(BOA,{ref:UA,blocks:a,markdown:e,frontmatter:o,annotations:bA,onAddAnnotation:Ar,onSelectAnnotation:Za,selectedAnnotationId:r,mode:O,inputMethod:K,taterMode:k,globalAttachments:V,onAddGlobalAttachment:xi,onRemoveGlobalAttachment:Vt,repoInfo:qA,stickyActions:G.stickyActionsEnabled,planDiffStats:Qe.isActive?null:Ae.diffStats,isPlanDiffActive:FA,onPlanDiffToggle:()=>HA(!FA),hasPreviousVersion:!Qe.isActive&&Ae.hasPreviousVersion,showDemoBadge:!F&&!di&&!Nt,maxWidth:q,onOpenLinkedDoc:Ze,linkedDocInfo:Qe.isActive?{filepath:Qe.filepath,onBack:ut,label:De.activeFile?"Vault File":void 0}:null,imageBaseDir:pA,copyLabel:gA==="message"?"Copy message":gA==="file"?"Copy file":void 0},Qe.isActive?`doc:${Qe.filepath}`:"plan")})]})]}),x&&R.jsx(Yq,{...Te.handleProps,className:"hidden md:block"}),R.jsx(mOA,{isOpen:x,blocks:a,annotations:t,selectedId:r,onSelect:n,onDelete:er,onEdit:ct,shareUrl:He,sharingEnabled:Ie,width:Te.width,editorAnnotations:fe,onDeleteEditorAnnotation:at,onClose:()=>b(!1),onQuickCopy:async()=>{await navigator.clipboard.writeText(hAA(mi))}})]}),R.jsx(MOA,{isOpen:l,onClose:()=>{I(!1),j(void 0)},shareUrl:He,shareUrlSize:zA,shortShareUrl:Se,isGeneratingShortUrl:Ve,shortUrlError:Ut,onGenerateShortUrl:Qi,annotationsOutput:mi,annotationCount:t.length,taterSprite:k?R.jsx(VU,{}):void 0,sharingEnabled:Ie,markdown:e,isApiMode:F,initialTab:yA}),R.jsx(kOA,{isOpen:C,onClose:()=>E(!1),onImport:Hi,shareBaseUrl:OA}),R.jsx(Gd,{isOpen:B,onClose:()=>d(!1),title:"Add Annotations First",message:`To provide feedback, select text in the plan and add annotations. ${Ye} will use your annotations to revise the plan.`,variant:"info"}),R.jsx(Gd,{isOpen:Q,onClose:()=>f(!1),onConfirm:()=>{f(!1),On()},title:"Annotations Won't Be Sent",message:R.jsxs(R.Fragment,{children:[Ye," doesn't yet support feedback on approval. Your ",t.length," annotation",t.length!==1?"s":""," will be lost."]}),subMessage:R.jsxs(R.Fragment,{children:["To send feedback, use ",R.jsx("strong",{children:"Send Feedback"})," instead.",R.jsx("br",{}),R.jsx("br",{}),"Want this feature? Upvote these issues:",R.jsx("br",{}),R.jsx("a",{href:"https://github.com/anthropics/claude-code/issues/16001",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"#16001"})," · ",R.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}),R.jsx(Gd,{isOpen:m,onClose:()=>y(!1),onConfirm:()=>{y(!1),On()},title:"Agent Not Found",message:w,subMessage:R.jsxs(R.Fragment,{children:["You can change the agent in ",R.jsx("strong",{children:"Settings"}),", or approve anyway and OpenCode will use the default agent."]}),confirmText:"Approve Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),R.jsx(Gd,{isOpen:!!li&&!F,onClose:ke,title:"Shared Plan Could Not Be Loaded",message:li,subMessage:"You are viewing a demo plan. This is sample content — it is not your data or anyone else's.",variant:"warning"}),mA&&R.jsx("div",{className:`fixed top-16 right-4 z-50 px-3 py-2 rounded-lg text-xs font-medium shadow-lg transition-opacity ${mA.type==="success"?"bg-success/15 text-success border border-success/30":"bg-destructive/15 text-destructive border border-destructive/30"}`,children:mA.message}),R.jsx(pUA,{submitted:IA,title:IA==="approved"?"Plan Approved":AA?"Annotations Sent":"Feedback Sent",subtitle:IA==="approved"?`${Ye} will proceed with the implementation.`:AA?`${Ye} will address your annotations on the ${gA==="message"?"message":"file"}.`:`${Ye} will revise the plan based on your annotations.`,agentLabel:Ye}),R.jsx(SUA,{origin:z}),R.jsx(bAA,{isOpen:!!BA,imageSrc:BA?.blobUrl??"",initialName:BA?.initialName,onAccept:Xi,onClose:$i}),R.jsx(JUA,{isOpen:iA,onComplete:Z=>{ce(Z),re(!1)}})]})})},voA=document.getElementById("root");if(!voA)throw new Error("Could not find root element to mount to");const D4A=zQA.createRoot(voA);D4A.render(R.jsx(to.StrictMode,{children:R.jsx(y4A,{})}));class is{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 is(A.loc.lexer,A.loc.start,t.loc.end):A&&A.loc}}class Ms{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 Ms(t,is.range(this,A))}}class qe{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__=qe.prototype,I.position=r,r!=null&&n!=null&&(I.length=n-r),I.rawMessage=A,I}}qe.prototype.__proto__=Error.prototype;var w4A=function(A,t){return A===void 0?t:A},v4A=/([A-Z])/g,S4A=function(A){return A.replace(v4A,"-$1").toLowerCase()},b4A={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},R4A=/[&><"']/g;function N4A(e){return String(e).replace(R4A,A=>b4A[A])}var SoA=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},M4A=function(A){var t=SoA(A);return t.type==="mathord"||t.type==="textord"||t.type==="atom"},k4A=function(A){if(!A)throw new Error("Expected non-null, but got "+String(A));return A},x4A=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"},Ni={deflt:w4A,escape:N4A,hyphenate:S4A,getBaseElem:SoA,isCharacterBox:M4A,protocolFromUrl:x4A},of={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 L4A(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 $U{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 of)if(of.hasOwnProperty(t)){var i=of[t];this[t]=A[t]!==void 0?i.processor?i.processor(A[t]):A[t]:L4A(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 qe("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=Ni.protocolFromUrl(A.url);if(t==null)return!1;A.protocol=t}var i=typeof this.trust=="function"?this.trust(A):this.trust;return!!i}}class xc{constructor(A,t,i){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=A,this.size=t,this.cramped=i}sup(){return mg[T4A[this.id]]}sub(){return mg[F4A[this.id]]}fracNum(){return mg[G4A[this.id]]}fracDen(){return mg[O4A[this.id]]}cramp(){return mg[U4A[this.id]]}text(){return mg[K4A[this.id]]}isTight(){return this.size>=2}}var A4=0,Jw=1,uB=2,Fl=3,Kf=4,lo=5,HB=6,Fa=7,mg=[new xc(A4,0,!1),new xc(Jw,0,!0),new xc(uB,1,!1),new xc(Fl,1,!0),new xc(Kf,2,!1),new xc(lo,2,!0),new xc(HB,3,!1),new xc(Fa,3,!0)],T4A=[Kf,lo,Kf,lo,HB,Fa,HB,Fa],F4A=[lo,lo,lo,lo,Fa,Fa,Fa,Fa],G4A=[uB,Fl,Kf,lo,HB,Fa,HB,Fa],O4A=[Fl,Fl,lo,lo,Fa,Fa,Fa,Fa],U4A=[Jw,Jw,Fl,Fl,lo,lo,Fa,Fa],K4A=[A4,Jw,uB,Fl,uB,Fl,uB,Fl],kt={DISPLAY:mg[A4],TEXT:mg[uB],SCRIPT:mg[Kf],SCRIPTSCRIPT:mg[HB]},MG=[{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 Y4A(e){for(var A=0;A<MG.length;A++)for(var t=MG[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 iD=[];MG.forEach(e=>e.blocks.forEach(A=>iD.push(...A)));function boA(e){for(var A=0;A<iD.length;A+=2)if(e>=iD[A]&&e<=iD[A+1])return!0;return!1}var Mu=80,H4A=function(A,t){return"M95,"+(622+A+t)+`
873
+ `,y4A=()=>{const[e,A]=uA.useState(m4A),[t,i]=uA.useState([]),[r,n]=uA.useState(null),[a,s]=uA.useState([]),[o,g]=uA.useState(null),[l,I]=uA.useState(!1),[C,E]=uA.useState(!1),[B,d]=uA.useState(!1),[Q,f]=uA.useState(!1),[m,y]=uA.useState(!1),[w,S]=uA.useState(""),[x,b]=uA.useState(()=>window.innerWidth>=768),[v,N]=uA.useState(!1),[O,L]=uA.useState(RUA),[K,H]=uA.useState(kUA),[k,U]=uA.useState(()=>et.getItem("plannotator-tater-mode")==="true"),[G,T]=uA.useState(()=>RG()),[F,P]=uA.useState(!1),[z,Y]=uA.useState(null),[V,_]=uA.useState([]),[AA,X]=uA.useState(!1),[gA,sA]=uA.useState(null),[pA,nA]=uA.useState(void 0),[lA,oA]=uA.useState(!0),[aA,hA]=uA.useState(!1),[IA,xA]=uA.useState(null),[BA,jA]=uA.useState(null),[iA,re]=uA.useState(!1),[MA,ce]=uA.useState("bypassPermissions"),[Ie,de]=uA.useState(!0),[OA,ne]=uA.useState(void 0),[YA,DA]=uA.useState(void 0),[qA,NA]=uA.useState(null),[_A,EA]=uA.useState(!1),[yA,j]=uA.useState(),[mA,CA]=uA.useState(null),wA=uA.useMemo(()=>t.filter(Z=>!!Z.diffContext),[t]),bA=uA.useMemo(()=>t.filter(Z=>!Z.diffContext),[t]),[FA,HA]=uA.useState(!1),[GA,XA]=uA.useState("clean"),[se,ye]=uA.useState(null),[SA,JA]=uA.useState(null),UA=uA.useRef(null),oe=uA.useRef(null),Te=Kq({storageKey:"plannotator-panel-width"}),ve=Kq({storageKey:"plannotator-toc-width",defaultWidth:240,minWidth:160,maxWidth:400,side:"left"}),eA=Te.isDragging||ve.isDragging,ae=zUA(RG().tocEnabled);uA.useEffect(()=>{G.tocEnabled?ae.open("toc"):ae.close()},[G.tocEnabled]),uA.useEffect(()=>{ae.activeTab==="toc"&&FA&&HA(!1)},[ae.activeTab]),uA.useEffect(()=>{if(!FA)return;const Z=tA=>{tA.key==="Escape"&&HA(!1)};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[FA]);const Ae=XUA(e,se,SA),Qe=$UA({markdown:e,annotations:t,selectedAnnotationId:r,globalAttachments:V,setMarkdown:A,setAnnotations:i,setSelectedAnnotationId:n,setGlobalAttachments:_,viewerRef:UA,sidebar:ae}),De=A4A(),Ge=uA.useMemo(()=>SOA(),[G]),Me=uA.useMemo(()=>{if(!Ge)return"";const Z=Zc();return jc(Z)},[Ge,G]);uA.useEffect(()=>{Ge||De.setActiveFile(null)},[Ge]),uA.useEffect(()=>{ae.activeTab==="vault"&&Ge&&Me&&De.tree.length===0&&!De.isLoading&&De.fetchTree(Me)},[ae.activeTab,Ge,Me]);const We=to.useCallback(Z=>tA=>`/api/reference/obsidian/doc?vaultPath=${encodeURIComponent(Z)}&path=${encodeURIComponent(tA)}`,[]),ft=to.useCallback(Z=>{Qe.open(Z,We(Me)),De.setActiveFile(Z)},[Me,Qe,De,We]),Ze=to.useCallback(Z=>{if(De.activeFile&&Me)Qe.open(Z,We(Me));else{const tA=Qe.filepath?Qe.filepath.replace(/\/[^/]+$/,""):pA;tA?Qe.open(Z,dA=>`/api/doc?path=${encodeURIComponent(dA)}&base=${encodeURIComponent(tA)}`):Qe.open(Z)}},[De.activeFile,Me,Qe,We,pA]),ut=to.useCallback(()=>{Qe.back(),De.setActiveFile(null)},[Qe,De]),qt=to.useCallback(()=>{De.fetchTree(Me)},[De,Me]),Kt=uA.useMemo(()=>a.filter(Z=>Z.type==="heading").length,[a]),ht=hUA(oe,Kt),{isSharedSession:Nt,isLoadingShared:di,shareUrl:He,shareUrlSize:zA,shortShareUrl:Se,isGeneratingShortUrl:Ve,shortUrlError:Ut,pendingSharedAnnotations:_t,clearPendingSharedAnnotations:ot,generateShortUrl:Qi,importFromShareUrl:Hi,shareLoadError:li,clearShareLoadError:ke}=BUA(e,t,V,A,i,_,()=>{oA(!1)},OA,YA),{draftBanner:me,restoreDraft:Ne,dismissDraft:be}=i4A({annotations:t,globalAttachments:V,isApiMode:F,isSharedSession:Nt,submitted:!!IA}),{editorAnnotations:fe,deleteEditorAnnotation:at}=n4A(),kA=to.useCallback(()=>{const{annotations:Z,globalAttachments:tA}=Ne();Z.length>0&&(i(Z),tA.length>0&&_(tA),setTimeout(()=>{UA.current?.applySharedAnnotations(Z.filter(dA=>!dA.diffContext))},100))},[Ne]),{getAgentWarning:Ti}=uoA(z);uA.useEffect(()=>{if(_t&&_t.length>0){const Z=setTimeout(()=>{UA.current?.clearAllHighlights(),UA.current?.applySharedAnnotations(_t.filter(tA=>!tA.diffContext)),ot()},100);return()=>clearTimeout(Z)}},[_t,ot]);const TA=Z=>{U(Z),et.setItem("plannotator-tater-mode",String(Z))},Lt=Z=>{L(Z),NUA(Z)},Da=Z=>{H(Z),xUA(Z)};FUA(K,Da),uA.useEffect(()=>{di||Nt||fetch("/api/plan").then(Z=>{if(!Z.ok)throw new Error("Not in API mode");return Z.json()}).then(Z=>{Z.plan&&A(Z.plan),P(!0),(Z.mode==="annotate"||Z.mode==="annotate-last")&&X(!0),Z.mode&&sA(Z.mode==="annotate-last"?"message":"file"),Z.filePath&&nA(Z.filePath.replace(/\/[^/]+$/,"")),Z.sharingEnabled!==void 0&&de(Z.sharingEnabled),Z.shareBaseUrl&&ne(Z.shareBaseUrl),Z.pasteApiUrl&&DA(Z.pasteApiUrl),Z.repoInfo&&NA(Z.repoInfo),Z.previousPlan!==void 0&&ye(Z.previousPlan),Z.versionInfo&&JA(Z.versionInfo),Z.origin&&(Y(Z.origin),Z.origin==="claude-code"&&XOA()&&re(!0),ce(coA().mode))}).catch(()=>{P(!1)}).finally(()=>oA(!1))},[di,Nt]),uA.useEffect(()=>{const{frontmatter:Z}=uAA(e);g(Z),s(BAA(e))},[e]);const ra=uA.useRef(!1),bn=uA.useRef({}),na=uA.useRef(null);uA.useEffect(()=>{ra.current=!1,bn.current={},na.current=null},[e]),uA.useEffect(()=>{if(!F||!e||Nt||AA||ra.current)return;const Z={},tA=[],dA=Zc();if(dA.autoSave&&dA.enabled){const le=jc(dA);le&&(Z.obsidian={vaultPath:le,folder:dA.folder||"plannotator",plan:e,...dA.filenameFormat&&{filenameFormat:dA.filenameFormat},...dA.filenameSeparator&&dA.filenameSeparator!=="space"&&{filenameSeparator:dA.filenameSeparator}},tA.push("Obsidian"))}const LA=Kc();LA.autoSave&&LA.enabled&&(Z.bear={plan:e,customTags:LA.customTags,tagPosition:LA.tagPosition},tA.push("Bear"));const WA=CB();if(WA.autoSave&&Fd()&&(Z.octarine={plan:e,workspace:WA.workspace,folder:WA.folder||"plannotator"},tA.push("Octarine")),tA.length===0)return;ra.current=!0;const te=fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Z)}).then(le=>le.json()).then(le=>{const ze={...Z.obsidian?{obsidian:!!le.results?.obsidian?.success}:{},...Z.bear?{bear:!!le.results?.bear?.success}:{},...Z.octarine?{octarine:!!le.results?.octarine?.success}:{}};bn.current=ze;const St=tA.filter(bt=>!le.results?.[bt.toLowerCase()]?.success);return St.length===0?CA({type:"success",message:`Auto-saved to ${tA.join(" & ")}`}):CA({type:"error",message:`Auto-save failed for ${St.join(" & ")}`}),ze}).catch(()=>(bn.current={},CA({type:"error",message:"Auto-save failed"}),{})).finally(()=>setTimeout(()=>CA(null),3e3));na.current=te},[F,e,Nt,AA]),uA.useEffect(()=>{const Z=tA=>{const dA=tA.clipboardData?.items;if(dA){for(const LA of dA)if(LA.type.startsWith("image/")){tA.preventDefault();const WA=LA.getAsFile();if(WA){const te=BF(WA.name,V.map(ze=>ze.name)),le=URL.createObjectURL(WA);jA({file:WA,blobUrl:le,initialName:te})}break}}};return document.addEventListener("paste",Z),()=>document.removeEventListener("paste",Z)},[V]);const Xi=async(Z,tA,dA)=>{if(BA)try{const LA=new FormData,WA=tA?new File([Z],"annotated.png",{type:"image/png"}):BA.file;LA.append("file",WA);const te=await fetch("/api/upload",{method:"POST",body:LA});if(te.ok){const le=await te.json();_(ze=>[...ze,{path:le.path,name:dA}])}}catch{}finally{URL.revokeObjectURL(BA.blobUrl),jA(null)}},$i=()=>{BA&&(URL.revokeObjectURL(BA.blobUrl),jA(null))},On=async()=>{hA(!0);try{const Z=Zc(),tA=Kc(),dA=CB(),LA=ZU(),WA=bG(),te=tA.autoSave&&na.current?await na.current:bn.current,le={};z==="claude-code"&&(le.permissionMode=MA);const ze=VOA(LA);ze&&(le.agentSwitch=ze),le.planSave={enabled:WA.enabled,...WA.customPath&&{customPath:WA.customPath}};const St=jc(Z);Z.enabled&&St&&(le.obsidian={vaultPath:St,folder:Z.folder||"plannotator",plan:e,...Z.filenameFormat&&{filenameFormat:Z.filenameFormat},...Z.filenameSeparator&&Z.filenameSeparator!=="space"&&{filenameSeparator:Z.filenameSeparator}}),tA.enabled&&!(tA.autoSave&&te.bear)&&(le.bear={plan:e,customTags:tA.customTags,tagPosition:tA.tagPosition}),Fd()&&(le.octarine={plan:e,workspace:dA.workspace,folder:dA.folder||"plannotator"});const bt=Array.from(Qe.getDocAnnotations().values()).some(Zt=>Zt.annotations.length>0||Zt.globalAttachments.length>0);(t.length>0||V.length>0||bt||fe.length>0)&&(le.feedback=mi),await fetch("/api/approve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(le)}),xA("approved")}catch{hA(!1)}},Un=async()=>{hA(!0);try{const Z=bG();await fetch("/api/deny",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:mi,planSave:{enabled:Z.enabled,...Z.customPath&&{customPath:Z.customPath}}})}),xA("denied")}catch{hA(!1)}},wa=async()=>{hA(!0);try{await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedback:mi,annotations:t})}),xA("denied")}catch{hA(!1)}};uA.useEffect(()=>{const Z=tA=>{if(tA.key!=="Enter"||!(tA.metaKey||tA.ctrlKey))return;const dA=tA.target?.tagName;if(!(dA==="INPUT"||dA==="TEXTAREA")&&!(l||C||B||Q||m||iA||BA)&&!(IA||aA)&&F&&!Qe.isActive){if(tA.preventDefault(),AA){t.length===0?d(!0):wa();return}if(t.length===0&&fe.length===0){if(z==="opencode"){const LA=Ti();if(LA){S(LA),y(!0);return}}On()}else Un()}};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[l,C,B,Q,m,iA,BA,IA,aA,F,Qe.isActive,t.length,AA,z,Ti]);const Ar=Z=>{i(tA=>[...tA,Z]),n(Z.id),b(!0)},Za=to.useCallback(Z=>{n(Z),Z&&window.innerWidth<768&&b(!0)},[]),er=Z=>{UA.current?.removeHighlight(Z),i(tA=>tA.filter(dA=>dA.id!==Z)),r===Z&&n(null)},ct=(Z,tA)=>{i(dA=>dA.map(LA=>LA.id===Z?{...LA,...tA}:LA))},Dt=(Z,tA)=>{i(dA=>dA.map(LA=>LA.author===Z?{...LA,author:tA}:LA))},xi=Z=>{_(tA=>[...tA,Z])},Vt=Z=>{_(tA=>tA.filter(dA=>dA.path!==Z))},Ur=Z=>{},mi=uA.useMemo(()=>{const Z=Qe.getDocAnnotations(),tA=Array.from(Z.values()).some(te=>te.annotations.length>0||te.globalAttachments.length>0),dA=t.length>0||V.length>0,LA=fe.length>0;if(!dA&&!tA&&!LA)return"No changes detected.";let WA=dA?WQA(a,t,V,gA==="message"?"Message Feedback":gA==="file"?"File Feedback":"Plan Feedback",gA??"plan"):"";return tA&&(WA+=VQA(Z)),LA&&(WA+=ZQA(fe)),WA},[a,t,V,Qe.getDocAnnotations,fe]),ln=()=>{EA(!1);const Z=new Blob([mi],{type:"text/plain"}),tA=URL.createObjectURL(Z),dA=document.createElement("a");dA.href=tA,dA.download="annotations.md",dA.click(),URL.revokeObjectURL(tA),CA({type:"success",message:"Downloaded annotations"}),setTimeout(()=>CA(null),3e3)},Cr=async Z=>{EA(!1);const tA={};if(Z==="obsidian"){const LA=Zc(),WA=jc(LA);WA&&(tA.obsidian={vaultPath:WA,folder:LA.folder||"plannotator",plan:e,...LA.filenameFormat&&{filenameFormat:LA.filenameFormat},...LA.filenameSeparator&&LA.filenameSeparator!=="space"&&{filenameSeparator:LA.filenameSeparator}})}if(Z==="bear"){const LA=Kc();tA.bear={plan:e,customTags:LA.customTags,tagPosition:LA.tagPosition}}if(Z==="octarine"){const LA=CB();tA.octarine={plan:e,workspace:LA.workspace,folder:LA.folder||"plannotator"}}const dA=Z==="obsidian"?"Obsidian":Z==="bear"?"Bear":"Octarine";try{const te=(await(await fetch("/api/save-notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(tA)})).json()).results?.[Z];te?.success?CA({type:"success",message:`Saved to ${dA}`}):CA({type:"error",message:te?.error||"Save failed"})}catch{CA({type:"error",message:"Save failed"})}setTimeout(()=>CA(null),3e3)};uA.useEffect(()=>{const Z=tA=>{if(tA.key!=="s"||!(tA.metaKey||tA.ctrlKey))return;const dA=tA.target?.tagName;if(dA==="INPUT"||dA==="TEXTAREA"||l||B||Q||m||iA||BA||IA||!F)return;tA.preventDefault();const LA=EoA(),WA=D2(),te=Kc().enabled,le=Fd();LA==="download"?ln():LA==="obsidian"&&WA?Cr("obsidian"):LA==="bear"&&te?Cr("bear"):LA==="octarine"&&le?Cr("octarine"):(j("notes"),I(!0))};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[l,B,Q,m,iA,BA,IA,F,e,mi]),uA.useEffect(()=>{if(!_A)return;const Z=tA=>{tA.target.closest("[data-export-dropdown]")||EA(!1)};return document.addEventListener("pointerdown",Z),()=>document.removeEventListener("pointerdown",Z)},[_A]);const Ye=uA.useMemo(()=>z==="opencode"?"OpenCode":z==="claude-code"?"Claude Code":z==="pi"?"Pi":z==="codex"?"Codex":"Coding Agent",[z]),q=uA.useMemo(()=>({compact:832,default:1040,wide:1280})[G.planWidth]??832,[G.planWidth]);return R.jsx(xOA,{defaultTheme:"dark",children:R.jsxs("div",{className:"h-screen flex flex-col bg-background overflow-hidden",children:[R.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:[R.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[R.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:R.jsx("span",{className:"text-sm font-semibold tracking-tight",children:"Plannotator"})}),R.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.14.3"]}),z&&R.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium hidden md:inline ${z==="claude-code"?"bg-orange-500/15 text-orange-400":z==="pi"?"bg-violet-500/15 text-violet-400":"bg-zinc-500/20 text-zinc-400"}`,children:Ye})]}),R.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[F&&!Qe.isActive&&R.jsxs(R.Fragment,{children:[R.jsxs("button",{onClick:()=>{t.length===0&&fe.length===0?d(!0):AA?wa():Un()},disabled:aA,className:`p-1.5 md:px-2.5 md:py-1 rounded-md text-xs font-medium transition-all ${aA?"opacity-50 cursor-not-allowed bg-muted text-muted-foreground":"bg-accent/15 text-accent hover:bg-accent/25 border border-accent/30"}`,title:"Send Feedback",children:[R.jsx("svg",{className:"w-4 h-4 md:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),R.jsx("span",{className:"hidden md:inline",children:aA?"Sending...":AA?"Send Annotations":"Send Feedback"})]}),!AA&&R.jsxs("div",{className:"relative group/approve",children:[R.jsxs("button",{onClick:()=>{if(z==="claude-code"&&t.length>0){f(!0);return}if(z==="opencode"){const Z=Ti();if(Z){S(Z),y(!0);return}}On()},disabled:aA,className:`px-2 py-1 md:px-2.5 rounded-md text-xs font-medium transition-all ${aA?"opacity-50 cursor-not-allowed bg-muted text-muted-foreground":z==="claude-code"&&t.length>0?"bg-success/50 text-success-foreground/70 hover:bg-success hover:text-success-foreground":"bg-success text-success-foreground hover:opacity-90"}`,children:[R.jsx("span",{className:"md:hidden",children:aA?"...":"OK"}),R.jsx("span",{className:"hidden md:inline",children:aA?"Approving...":"Approve"})]}),z==="claude-code"&&t.length>0&&R.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:[R.jsx("div",{className:"absolute bottom-full right-4 border-4 border-transparent border-b-border"}),R.jsx("div",{className:"absolute bottom-full right-4 mt-px border-4 border-transparent border-b-popover"}),Ye," doesn't support feedback on approval. Your annotations won't be seen."]})]}),R.jsx("div",{className:"w-px h-5 bg-border/50 mx-1 hidden md:block"})]}),R.jsxs("div",{className:"hidden md:flex items-center gap-2",children:[R.jsx(LOA,{}),!Qe.isActive&&R.jsx(gUA,{taterMode:k,onTaterModeChange:TA,onIdentityChange:Dt,origin:z,onUIPreferencesChange:T,externalOpen:v,onExternalClose:()=>N(!1)}),R.jsx("button",{onClick:()=>b(!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:R.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.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"})})}),R.jsxs("div",{className:"relative flex","data-export-dropdown":!0,children:[R.jsx("button",{onClick:()=>{j(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"}),R.jsx("button",{onClick:()=>EA(Z=>!Z),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:R.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}),_A&&R.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:[Ie&&R.jsxs("button",{onClick:async()=>{EA(!1);try{await navigator.clipboard.writeText(He),CA({type:"success",message:"Share link copied"})}catch{CA({type:"error",message:"Failed to copy"})}setTimeout(()=>CA(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:[R.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.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"]}),R.jsxs("button",{onClick:ln,className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[R.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.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"]}),F&&D2()&&R.jsxs("button",{onClick:()=>Cr("obsidian"),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[R.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),"Save to Obsidian"]}),F&&Kc().enabled&&R.jsxs("button",{onClick:()=>Cr("bear"),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[R.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),"Save to Bear"]}),F&&Fd()&&R.jsxs("button",{onClick:()=>Cr("octarine"),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors flex items-center gap-2",children:[R.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})}),"Save to Octarine"]}),F&&!D2()&&!Kc().enabled&&!Fd()&&R.jsx("div",{className:"px-3 py-2 text-[10px] text-muted-foreground",children:"No notes apps configured."}),Ie&&R.jsxs(R.Fragment,{children:[R.jsx("div",{className:"my-1 border-t border-border"}),R.jsxs("button",{onClick:()=>{EA(!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:[R.jsx("svg",{className:"w-3.5 h-3.5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:R.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"]})]})]})]})]}),R.jsx(GUA,{className:"md:hidden",isPanelOpen:x,onTogglePanel:()=>b(!x),annotationCount:t.length+fe.length,onOpenExport:()=>{j(void 0),I(!0)},onOpenSettings:()=>N(!0),onDownloadAnnotations:ln,onCopyShareLink:async()=>{try{await navigator.clipboard.writeText(He),CA({type:"success",message:"Share link copied"})}catch{CA({type:"error",message:"Failed to copy"})}setTimeout(()=>CA(null),3e3)},onOpenImport:()=>E(!0),sharingEnabled:Ie})]})]}),Qe.error&&R.jsxs("div",{className:"bg-destructive/10 border-b border-destructive/20 px-4 py-2 flex items-center gap-2 flex-shrink-0",children:[R.jsx("span",{className:"text-xs text-destructive",children:Qe.error}),R.jsx("button",{onClick:Qe.dismissError,className:"ml-auto text-xs text-destructive/60 hover:text-destructive",children:"dismiss"})]}),R.jsxs("div",{className:`flex-1 flex overflow-hidden relative z-0 ${eA?"select-none":""}`,children:[k&&R.jsx(JOA,{}),!ae.isOpen&&R.jsx(a4A,{activeTab:ae.activeTab,onToggleTab:ae.toggleTab,hasDiff:Ae.hasPreviousVersion,showVaultTab:Ge,className:"hidden lg:flex"}),ae.isOpen&&R.jsxs(R.Fragment,{children:[R.jsx(C4A,{activeTab:ae.activeTab,onTabChange:ae.toggleTab,onClose:ae.close,width:ve.width,blocks:a,annotations:t,activeSection:ht,onTocNavigate:Ur,linkedDocFilepath:Qe.filepath,onLinkedDocBack:Qe.isActive?ut:void 0,showVaultTab:Ge,vaultPath:Me,vaultBrowser:De,onVaultSelectFile:ft,onVaultFetchTree:qt,versionInfo:SA,versions:Ae.versions,projectPlans:Ae.projectPlans,selectedBaseVersion:Ae.diffBaseVersion,onSelectBaseVersion:Ae.selectBaseVersion,isPlanDiffActive:FA,hasPreviousVersion:Ae.hasPreviousVersion,onActivatePlanDiff:()=>HA(!0),isLoadingVersions:Ae.isLoadingVersions,isSelectingVersion:Ae.isSelectingVersion,fetchingVersion:Ae.fetchingVersion,onFetchVersions:Ae.fetchVersions,onFetchProjectPlans:Ae.fetchProjectPlans}),R.jsx(Yq,{...ve.handleProps,className:"hidden lg:block"})]}),R.jsxs("main",{ref:oe,className:"flex-1 min-w-0 overflow-y-auto bg-grid",children:[R.jsx(Gd,{isOpen:!!me,onClose:be,onConfirm:kA,title:"Draft Recovered",message:me?`Found ${me.count} annotation${me.count!==1?"s":""} from ${me.timeAgo}. Would you like to restore them?`:"",confirmText:"Restore",cancelText:"Dismiss",showCancel:!0}),R.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:[!FA&&R.jsx("div",{className:"w-full mb-3 md:mb-4 flex items-center justify-start",style:{maxWidth:q},children:R.jsx(OOA,{inputMethod:K,onInputMethodChange:Da,mode:O,onModeChange:Lt,taterMode:k})}),Ae.diffBlocks&&Ae.diffStats&&R.jsx("div",{className:"w-full flex justify-center",style:{display:FA?void 0:"none"},children:R.jsx(p4A,{diffBlocks:Ae.diffBlocks,diffStats:Ae.diffStats,diffMode:GA,onDiffModeChange:XA,onPlanDiffToggle:()=>HA(!1),repoInfo:qA,baseVersionLabel:Ae.diffBaseVersion!=null?`v${Ae.diffBaseVersion}`:void 0,baseVersion:Ae.diffBaseVersion??void 0,maxWidth:q,annotations:wA,onAddAnnotation:Ar,onSelectAnnotation:Za,selectedAnnotationId:r,mode:O})}),R.jsx("div",{className:"w-full flex justify-center",style:{display:FA&&Ae.diffBlocks?"none":void 0},children:R.jsx(BOA,{ref:UA,blocks:a,markdown:e,frontmatter:o,annotations:bA,onAddAnnotation:Ar,onSelectAnnotation:Za,selectedAnnotationId:r,mode:O,inputMethod:K,taterMode:k,globalAttachments:V,onAddGlobalAttachment:xi,onRemoveGlobalAttachment:Vt,repoInfo:qA,stickyActions:G.stickyActionsEnabled,planDiffStats:Qe.isActive?null:Ae.diffStats,isPlanDiffActive:FA,onPlanDiffToggle:()=>HA(!FA),hasPreviousVersion:!Qe.isActive&&Ae.hasPreviousVersion,showDemoBadge:!F&&!di&&!Nt,maxWidth:q,onOpenLinkedDoc:Ze,linkedDocInfo:Qe.isActive?{filepath:Qe.filepath,onBack:ut,label:De.activeFile?"Vault File":void 0}:null,imageBaseDir:pA,copyLabel:gA==="message"?"Copy message":gA==="file"?"Copy file":void 0},Qe.isActive?`doc:${Qe.filepath}`:"plan")})]})]}),x&&R.jsx(Yq,{...Te.handleProps,className:"hidden md:block"}),R.jsx(mOA,{isOpen:x,blocks:a,annotations:t,selectedId:r,onSelect:n,onDelete:er,onEdit:ct,shareUrl:He,sharingEnabled:Ie,width:Te.width,editorAnnotations:fe,onDeleteEditorAnnotation:at,onClose:()=>b(!1),onQuickCopy:async()=>{await navigator.clipboard.writeText(hAA(mi))}})]}),R.jsx(MOA,{isOpen:l,onClose:()=>{I(!1),j(void 0)},shareUrl:He,shareUrlSize:zA,shortShareUrl:Se,isGeneratingShortUrl:Ve,shortUrlError:Ut,onGenerateShortUrl:Qi,annotationsOutput:mi,annotationCount:t.length,taterSprite:k?R.jsx(VU,{}):void 0,sharingEnabled:Ie,markdown:e,isApiMode:F,initialTab:yA}),R.jsx(kOA,{isOpen:C,onClose:()=>E(!1),onImport:Hi,shareBaseUrl:OA}),R.jsx(Gd,{isOpen:B,onClose:()=>d(!1),title:"Add Annotations First",message:`To provide feedback, select text in the plan and add annotations. ${Ye} will use your annotations to revise the plan.`,variant:"info"}),R.jsx(Gd,{isOpen:Q,onClose:()=>f(!1),onConfirm:()=>{f(!1),On()},title:"Annotations Won't Be Sent",message:R.jsxs(R.Fragment,{children:[Ye," doesn't yet support feedback on approval. Your ",t.length," annotation",t.length!==1?"s":""," will be lost."]}),subMessage:R.jsxs(R.Fragment,{children:["To send feedback, use ",R.jsx("strong",{children:"Send Feedback"})," instead.",R.jsx("br",{}),R.jsx("br",{}),"Want this feature? Upvote these issues:",R.jsx("br",{}),R.jsx("a",{href:"https://github.com/anthropics/claude-code/issues/16001",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"#16001"})," · ",R.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}),R.jsx(Gd,{isOpen:m,onClose:()=>y(!1),onConfirm:()=>{y(!1),On()},title:"Agent Not Found",message:w,subMessage:R.jsxs(R.Fragment,{children:["You can change the agent in ",R.jsx("strong",{children:"Settings"}),", or approve anyway and OpenCode will use the default agent."]}),confirmText:"Approve Anyway",cancelText:"Cancel",variant:"warning",showCancel:!0}),R.jsx(Gd,{isOpen:!!li&&!F,onClose:ke,title:"Shared Plan Could Not Be Loaded",message:li,subMessage:"You are viewing a demo plan. This is sample content — it is not your data or anyone else's.",variant:"warning"}),mA&&R.jsx("div",{className:`fixed top-16 right-4 z-50 px-3 py-2 rounded-lg text-xs font-medium shadow-lg transition-opacity ${mA.type==="success"?"bg-success/15 text-success border border-success/30":"bg-destructive/15 text-destructive border border-destructive/30"}`,children:mA.message}),R.jsx(pUA,{submitted:IA,title:IA==="approved"?"Plan Approved":AA?"Annotations Sent":"Feedback Sent",subtitle:IA==="approved"?`${Ye} will proceed with the implementation.`:AA?`${Ye} will address your annotations on the ${gA==="message"?"message":"file"}.`:`${Ye} will revise the plan based on your annotations.`,agentLabel:Ye}),R.jsx(SUA,{origin:z}),R.jsx(bAA,{isOpen:!!BA,imageSrc:BA?.blobUrl??"",initialName:BA?.initialName,onAccept:Xi,onClose:$i}),R.jsx(JUA,{isOpen:iA,onComplete:Z=>{ce(Z),re(!1)}})]})})},voA=document.getElementById("root");if(!voA)throw new Error("Could not find root element to mount to");const D4A=zQA.createRoot(voA);D4A.render(R.jsx(to.StrictMode,{children:R.jsx(y4A,{})}));class is{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 is(A.loc.lexer,A.loc.start,t.loc.end):A&&A.loc}}class Ms{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 Ms(t,is.range(this,A))}}class qe{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__=qe.prototype,I.position=r,r!=null&&n!=null&&(I.length=n-r),I.rawMessage=A,I}}qe.prototype.__proto__=Error.prototype;var w4A=function(A,t){return A===void 0?t:A},v4A=/([A-Z])/g,S4A=function(A){return A.replace(v4A,"-$1").toLowerCase()},b4A={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},R4A=/[&><"']/g;function N4A(e){return String(e).replace(R4A,A=>b4A[A])}var SoA=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},M4A=function(A){var t=SoA(A);return t.type==="mathord"||t.type==="textord"||t.type==="atom"},k4A=function(A){if(!A)throw new Error("Expected non-null, but got "+String(A));return A},x4A=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"},Ni={deflt:w4A,escape:N4A,hyphenate:S4A,getBaseElem:SoA,isCharacterBox:M4A,protocolFromUrl:x4A},of={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 L4A(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 $U{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 of)if(of.hasOwnProperty(t)){var i=of[t];this[t]=A[t]!==void 0?i.processor?i.processor(A[t]):A[t]:L4A(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 qe("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=Ni.protocolFromUrl(A.url);if(t==null)return!1;A.protocol=t}var i=typeof this.trust=="function"?this.trust(A):this.trust;return!!i}}class xc{constructor(A,t,i){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=A,this.size=t,this.cramped=i}sup(){return mg[T4A[this.id]]}sub(){return mg[F4A[this.id]]}fracNum(){return mg[G4A[this.id]]}fracDen(){return mg[O4A[this.id]]}cramp(){return mg[U4A[this.id]]}text(){return mg[K4A[this.id]]}isTight(){return this.size>=2}}var A4=0,Jw=1,uB=2,Fl=3,Kf=4,lo=5,HB=6,Fa=7,mg=[new xc(A4,0,!1),new xc(Jw,0,!0),new xc(uB,1,!1),new xc(Fl,1,!0),new xc(Kf,2,!1),new xc(lo,2,!0),new xc(HB,3,!1),new xc(Fa,3,!0)],T4A=[Kf,lo,Kf,lo,HB,Fa,HB,Fa],F4A=[lo,lo,lo,lo,Fa,Fa,Fa,Fa],G4A=[uB,Fl,Kf,lo,HB,Fa,HB,Fa],O4A=[Fl,Fl,lo,lo,Fa,Fa,Fa,Fa],U4A=[Jw,Jw,Fl,Fl,lo,lo,Fa,Fa],K4A=[A4,Jw,uB,Fl,uB,Fl,uB,Fl],kt={DISPLAY:mg[A4],TEXT:mg[uB],SCRIPT:mg[Kf],SCRIPTSCRIPT:mg[HB]},MG=[{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 Y4A(e){for(var A=0;A<MG.length;A++)for(var t=MG[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 iD=[];MG.forEach(e=>e.blocks.forEach(A=>iD.push(...A)));function boA(e){for(var A=0;A<iD.length;A+=2)if(e>=iD[A]&&e<=iD[A+1])return!0;return!1}var Mu=80,H4A=function(A,t){return"M95,"+(622+A+t)+`
874
874
  c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
875
875
  c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
876
876
  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