react-reason-editor 1.0.28 → 1.0.29

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.
@@ -211,37 +211,37 @@ return me(Hm,{children:[/* @__PURE__ */pe(qm,{asChild:!0,children:/* @__PURE__ *
211
211
  /* @__PURE__ */pe(Zm,{children:"Del"})]})]})]})},Qm="__root__";var ef=X(({activeId:e,documents:t,onMove:n,onRename:r,onSelect:a,onDelete:o,onDuplicate:i,onAddChild:s,onAddChildFolder:l,onAddSibling:c,onAddSiblingFolder:d,onCopy:u,onPaste:h,_onNewFile:p,_onNewFolder:m,onManageTags:f},g)=>{const v=ie(()=>function(e){const t={[Qm]:{children:[],documentId:Qm,isFolder:!0,name:"Root"}};for(const n of e)t[n.id]={children:[],documentId:n.id,isFolder:!!n.isFolder,name:n.title||"Untitled"};for(const n of e){const e=n.parentId&&t[n.parentId]?n.parentId:Qm;t[e].children=[...t[e].children??[],n.id]}for(const n of Object.keys(t))n!==Qm&&(t[n].children?.length??0)>0&&(t[n].isFolder=!0);return t}(t),[t]),y=ie(()=>t.filter(e=>e.isFolder&&e.isExpanded).map(e=>e.id),[t]),[b,x]=le({expandedItems:y,selectedItems:e?[e]:[]}),[w,S]=le(null),[k,C]=le(null),N={current:!1},T=(e=>{const[t]=le(()=>({current:Bp(e)})),[n,r]=le(()=>t.current.getState());return te(()=>(t.current.setMounted(!0),t.current.rebuildTree(),()=>{t.current.setMounted(!1)}),[t]),t.current.setConfig(t=>Sm(wm(wm({},t),e),{state:wm(wm({},n),e.state),setState:t=>{var n;r(t),null==(n=e.setState)||n.call(e,t)}})),t.current})({canReorder:!0,dataLoader:{getChildren:e=>{const t=v[e];return t?t.children??[]:[]},getItem:e=>{const t=v[e];return t||{children:[],documentId:e,isFolder:!1,name:"Deleted Item"}}},features:[Zp,$p,Kp,pm,sm,hm],getItemName:e=>e.getItemData().name,onRename:(e,t)=>{const n=t.trim()||"Untitled";r?.(e.getId(),n)},indent:20,isItemFolder:e=>e.getItemData()?.isFolder??!1,onDrop:(e,t)=>{const r=e.map(e=>e.getId()).filter(e=>e!==Qm);if(0===r.length)return;const a=[...r].reverse(),o=e=>{for(const t of a)n(t,e,"child")};if("childIndex"in t){const e=t.item.getId()===Qm?null:t.item.getId(),i=(v[t.item.getId()]?.children??[]).filter(e=>!r.includes(e)),s=i[t.childIndex];if(s){for(const e of a)n(e,s,"before");return}const l=i[t.childIndex-1];if(l){for(const e of a)n(e,l,"after");return}return void o(e)}o(t.item.getId()===Qm?null:t.item.getId())},rootItemId:Qm,setState:x,state:b});te(()=>{x(t=>({...t,expandedItems:y,selectedItems:e&&v[e]?[e]:[]}))},[e,y,v]),re(g,()=>({collapseAll:()=>{N.current=!0,T.collapseAll()},edit:e=>{r&&T.getItemInstance(e).startRenaming()},expandAll:()=>{N.current=!1,T.expandAll(N)},expandToLevel:e=>{N.current=!0;const t=function(e,t){if(t<=0)return[];const n=[],r=[{depth:0,id:Qm}];for(;r.length>0;){const a=r.shift();if(!a)break;const o=e[a.id];if(o)for(const i of o.children??[]){if(!e[i]?.isFolder)continue;const o=a.depth+1;o>t||(n.push(i),r.push({depth:o,id:i}))}}return n}(v,e);x(e=>({...e,expandedItems:t}))},cancelExpand:()=>{N.current=!0}}));const A=k?v[k]?.name:"",I=T.getItems();/* @__PURE__ */
212
212
  return me(he,{children:[/* @__PURE__ */pe("div",{className:"flex h-full flex-col gap-2 overflow-auto",children:/* @__PURE__ */me(Im,{indent:20,tree:T,children:[
213
213
  /* @__PURE__ */pe(Nm,{tree:T}),I.map(t=>{const n=t.getId();return n===Qm?null:/* @__PURE__ */pe(Mm,{item:t,children:/* @__PURE__ */pe(Jm,{itemId:n,isFolder:t.isFolder(),hasCopiedItem:!!w,onAddChild:s,onAddChildFolder:l,onAddSibling:c,onAddSiblingFolder:d,onRename:r?()=>t.startRenaming():void 0,onDuplicate:i,onCopy:u?e=>{S(e),u(e)}:void 0,onPaste:h?()=>{w&&h(t.isFolder()?n:null)}:void 0,onDelete:o?()=>C(n):void 0,onManageTags:f,children:t.isRenaming()?/* @__PURE__ */pe(Dm,{className:"w-full text-left",onClick:e=>e.stopPropagation(),children:/* @__PURE__ */pe("input",{...t.getRenameInputProps(),className:"flex-1 w-full rounded border bg-background px-1 text-sm outline-none focus:ring-2 focus:ring-ring"})}):/* @__PURE__ */pe(Dm,{className:Ml("w-full text-left",e===n&&"bg-accent text-accent-foreground"),onClick:()=>a(n),onDoubleClick:()=>r&&t.startRenaming(),children:/* @__PURE__ */me("span",{className:"flex items-center gap-2 w-full min-w-0",children:[t.isFolder()?t.isExpanded()?/* @__PURE__ */pe(He,{className:"pointer-events-none size-4 shrink-0 text-muted-foreground"}):/* @__PURE__ */pe($e,{className:"pointer-events-none size-4 shrink-0 text-muted-foreground"}):/* @__PURE__ */pe(xp,{filename:t.getItemName(),size:16}),/* @__PURE__ */pe("span",{className:"flex-1 truncate",children:t.getItemName()})]})})})},n)}),
214
- /* @__PURE__ */pe(Em,{})]})}),/* @__PURE__ */pe(Rm,{open:!!k,onOpenChange:e=>!e&&C(null),children:/* @__PURE__ */me(Pm,{children:[/* @__PURE__ */me(Om,{children:[/* @__PURE__ */pe(Fm,{children:"Move to Trash?"}),/* @__PURE__ */me(Bm,{children:['Are you sure you want to move "',A,'" to trash? You can restore it later from the trash.']})]}),/* @__PURE__ */me(Lm,{children:[/* @__PURE__ */pe($m,{children:"Cancel"}),/* @__PURE__ */pe(Vm,{onClick:()=>{k&&o&&(o(k),C(null),x(e=>({...e,selectedItems:e.selectedItems?.filter(e=>e!==k)??[]})))},children:"Move to Trash"})]})]})})]})});ef.displayName="FileTree";var tf="outline-collapse-preferences",nf=X(({headings:e=[],onNavigate:t,onReorder:n,searchQuery:r=""},a)=>{const[o,i]=le(/* @__PURE__ */new Set),[s,l]=le(null),c=ie(()=>e.map(([e,t,n],r)=>({id:e,level:parseInt(n[1],10),text:t,line:r})),[e]),d=ie(()=>{const e=/* @__PURE__ */new Map;return c.forEach((t,n)=>e.set(t.id,n)),e},[c]);re(a,()=>({expandAll:()=>{i(/* @__PURE__ */new Set)},collapseAll:()=>{const e=/* @__PURE__ */new Set;c.forEach(t=>{1===t.level&&e.add(t.id)}),i(e)}})),te(()=>{try{const e=localStorage.getItem(tf);if(e){const t=JSON.parse(e);l(t.defaultCollapseLevel||null),t.defaultCollapseLevel&&m(t.defaultCollapseLevel)}}catch(zi){}},[]);const u=e=>{try{localStorage.setItem(tf,JSON.stringify({defaultCollapseLevel:e})),l(e)}catch(zi){}},h=ie(()=>{if(!r.trim())return c;const e=r.toLowerCase();return c.filter(t=>t.text.toLowerCase().includes(e))},[c,r]),p=e=>{i(t=>{const n=new Set(t);return n.has(e)?(n.delete(e),(e=>{const t=c.findIndex(t=>t.id===e);if(-1===t)return[];const n=c[t].level,r=[];for(let a=t+1;a<c.length&&!(c[a].level<=n);a++)r.push(c[a].id);return r})(e).forEach(e=>n.delete(e))):n.add(e),n})},m=e=>{const t=/* @__PURE__ */new Set;c.forEach(n=>{n.level===e&&t.add(n.id)}),i(t)};return 0===c.length?/* @__PURE__ */pe("div",{className:"flex h-full items-center justify-center p-6 text-center",children:/* @__PURE__ */me("div",{children:[
214
+ /* @__PURE__ */pe(Em,{})]})}),/* @__PURE__ */pe(Rm,{open:!!k,onOpenChange:e=>!e&&C(null),children:/* @__PURE__ */me(Pm,{children:[/* @__PURE__ */me(Om,{children:[/* @__PURE__ */pe(Fm,{children:"Move to Trash?"}),/* @__PURE__ */me(Bm,{children:['Are you sure you want to move "',A,'" to trash? You can restore it later from the trash.']})]}),/* @__PURE__ */me(Lm,{children:[/* @__PURE__ */pe($m,{children:"Cancel"}),/* @__PURE__ */pe(Vm,{onClick:()=>{k&&o&&(o(k),C(null),x(e=>({...e,selectedItems:e.selectedItems?.filter(e=>e!==k)??[]})))},children:"Move to Trash"})]})]})})]})});ef.displayName="FileTree";var tf="outline-collapse-preferences",nf=X(({headings:e=[],onNavigate:t,onReorder:n,searchQuery:r="",editorRef:a},o)=>{const[i,s]=le(/* @__PURE__ */new Set),[l,c]=le(null),d=function(e,t){const[n,r]=le(null),a=se(null);return te(()=>{if(!t?.current||0===e.length)return void r(null);const n=e=>t.current?.getElementByKey(e)??null,o=n(e[0][0]);if(a.current=null,o){let e=o.parentElement;for(;e;){const t=window.getComputedStyle(e);if("auto"===t.overflowY||"scroll"===t.overflowY){a.current=e;break}e=e.parentElement}}const i=()=>{const t=a.current,o=t?t.clientHeight:window.innerHeight,i=t?t.getBoundingClientRect().top:0,s=.3*o,l=[];for(const[r]of e){const e=n(r);if(!e)continue;const t=e.getBoundingClientRect();l.push({key:r,top:t.top-i})}r(function(e,t){let n=null;for(const{key:r,top:a}of e){if(!(a<=t))break;n=r}return!n&&e.length>0&&(n=e[0].key),n}(l,s))},s=a.current??window;return s.addEventListener("scroll",i,{passive:!0}),i(),()=>s.removeEventListener("scroll",i)},[e,t]),n}(e,a),u=ie(()=>e.map(([e,t,n],r)=>({id:e,level:parseInt(n[1],10),text:t,line:r})),[e]),h=ie(()=>{const e=/* @__PURE__ */new Map;return u.forEach((t,n)=>e.set(t.id,n)),e},[u]);re(o,()=>({expandAll:()=>{s(/* @__PURE__ */new Set)},collapseAll:()=>{const e=/* @__PURE__ */new Set;u.forEach(t=>{1===t.level&&e.add(t.id)}),s(e)}})),te(()=>{try{const e=localStorage.getItem(tf);if(e){const t=JSON.parse(e);c(t.defaultCollapseLevel||null),t.defaultCollapseLevel&&g(t.defaultCollapseLevel)}}catch(zi){}},[]);const p=e=>{try{localStorage.setItem(tf,JSON.stringify({defaultCollapseLevel:e})),c(e)}catch(zi){}},m=ie(()=>{if(!r.trim())return u;const e=r.toLowerCase();return u.filter(t=>t.text.toLowerCase().includes(e))},[u,r]),f=e=>{s(t=>{const n=new Set(t);return n.has(e)?(n.delete(e),(e=>{const t=u.findIndex(t=>t.id===e);if(-1===t)return[];const n=u[t].level,r=[];for(let a=t+1;a<u.length&&!(u[a].level<=n);a++)r.push(u[a].id);return r})(e).forEach(e=>n.delete(e))):n.add(e),n})},g=e=>{const t=/* @__PURE__ */new Set;u.forEach(n=>{n.level===e&&t.add(n.id)}),s(t)};return 0===u.length?/* @__PURE__ */pe("div",{className:"flex h-full items-center justify-center p-6 text-center",children:/* @__PURE__ */me("div",{children:[
215
215
  /* @__PURE__ */pe(We,{className:"mx-auto h-12 w-12 text-muted-foreground opacity-50 mb-3"}),
216
216
  /* @__PURE__ */pe("p",{className:"text-sm text-muted-foreground",children:"No headings found in this document"}),
217
- /* @__PURE__ */pe("p",{className:"text-xs text-muted-foreground mt-1",children:"Use the heading buttons in the toolbar"})]})}):/* @__PURE__ */pe("div",{className:"flex h-full flex-col overflow-auto",children:h.map(e=>{const n=d.get(e.id),r=c[n+1],a=r&&r.level>e.level,l=o.has(e.id);return(e=>{const t=c[e].level;for(let n=e-1;n>=0;n--)if(c[n].level<t){if(o.has(c[n].id))return!0;if(1===c[n].level)break}return!1})(n)?null:/* @__PURE__ */me(Hm,{children:[/* @__PURE__ */pe(qm,{children:/* @__PURE__ */me("div",{className:Ml("flex items-center gap-1 rounded-md cursor-pointer transition-colors hover:bg-sidebar-accent",1===e.level&&"py-1.5 mt-0.5",2===e.level&&"py-1",e.level>=3&&"py-0.5"),style:{paddingLeft:12*(e.level-1)+4+"px",paddingRight:"4px"},onClick:()=>t?.(e.id),children:[
218
- /* @__PURE__ */pe("button",{className:Ml("h-4 w-4 p-0 shrink-0 flex items-center justify-center hover:bg-transparent",!a&&"invisible"),onClick:t=>{t.stopPropagation(),p(e.id)},children:/* @__PURE__ */pe(Se,{className:Ml("h-3 w-3 transition-transform text-muted-foreground",!l&&"rotate-90")})}),
217
+ /* @__PURE__ */pe("p",{className:"text-xs text-muted-foreground mt-1",children:"Use the heading buttons in the toolbar"})]})}):/* @__PURE__ */pe("div",{className:"flex h-full flex-col overflow-auto",children:m.map(e=>{const n=h.get(e.id),r=u[n+1],a=r&&r.level>e.level,o=i.has(e.id),c=e.id===d;return(e=>{const t=u[e].level;for(let n=e-1;n>=0;n--)if(u[n].level<t){if(i.has(u[n].id))return!0;if(1===u[n].level)break}return!1})(n)?null:/* @__PURE__ */me(Hm,{children:[/* @__PURE__ */pe(qm,{children:/* @__PURE__ */me("div",{"data-active":c||void 0,className:Ml("flex items-center gap-1 rounded-md cursor-pointer transition-colors hover:bg-sidebar-accent",1===e.level&&"py-1.5 mt-0.5",2===e.level&&"py-1",e.level>=3&&"py-0.5",c&&"bg-sidebar-accent"),style:{paddingLeft:12*(e.level-1)+4+"px",paddingRight:"4px"},onClick:()=>t?.(e.id),children:[
218
+ /* @__PURE__ */pe("button",{className:Ml("h-4 w-4 p-0 shrink-0 flex items-center justify-center hover:bg-transparent",!a&&"invisible"),onClick:t=>{t.stopPropagation(),f(e.id)},children:/* @__PURE__ */pe(Se,{className:Ml("h-3 w-3 transition-transform text-muted-foreground",!o&&"rotate-90")})}),
219
219
  /* @__PURE__ */pe(We,{className:Ml("shrink-0",1===e.level&&"h-3.5 w-3.5 text-blue-500",2===e.level&&"h-3 w-3 text-indigo-400",e.level>=3&&"h-2.5 w-2.5 text-muted-foreground")}),
220
- /* @__PURE__ */pe("span",{className:Ml("flex-1 truncate",1===e.level&&"text-sm font-semibold text-foreground",2===e.level&&"text-sm font-medium text-foreground/90",3===e.level&&"text-xs text-foreground/80",e.level>=4&&"text-xs text-muted-foreground"),children:e.text})]})}),/* @__PURE__ */me(Wm,{children:[
220
+ /* @__PURE__ */pe("span",{className:Ml("flex-1 truncate",1===e.level&&"text-sm font-semibold text-foreground",2===e.level&&"text-sm font-medium text-foreground/90",3===e.level&&"text-xs text-foreground/80",e.level>=4&&"text-xs text-muted-foreground",c&&"font-medium text-foreground"),children:e.text})]})}),/* @__PURE__ */me(Wm,{children:[
221
221
  /* @__PURE__ */me(jm,{children:[/* @__PURE__ */pe(Um,{children:"Collapse to..."}),/* @__PURE__ */me(Gm,{children:[
222
- /* @__PURE__ */pe(Ym,{onClick:()=>m(1),children:"Heading 1"}),
223
- /* @__PURE__ */pe(Ym,{onClick:()=>m(2),children:"Heading 2"}),
224
- /* @__PURE__ */pe(Ym,{onClick:()=>m(3),children:"Heading 3"}),
225
- /* @__PURE__ */pe(Ym,{onClick:()=>m(4),children:"Heading 4"}),
226
- /* @__PURE__ */pe(Ym,{onClick:()=>i(/* @__PURE__ */new Set),children:"Expand All"})]})]}),
222
+ /* @__PURE__ */pe(Ym,{onClick:()=>g(1),children:"Heading 1"}),
223
+ /* @__PURE__ */pe(Ym,{onClick:()=>g(2),children:"Heading 2"}),
224
+ /* @__PURE__ */pe(Ym,{onClick:()=>g(3),children:"Heading 3"}),
225
+ /* @__PURE__ */pe(Ym,{onClick:()=>g(4),children:"Heading 4"}),
226
+ /* @__PURE__ */pe(Ym,{onClick:()=>s(/* @__PURE__ */new Set),children:"Expand All"})]})]}),
227
227
  /* @__PURE__ */pe(Xm,{}),
228
- /* @__PURE__ */pe(Km,{checked:null!==s,onCheckedChange:e=>{if(e){const e=c.find(e=>o.has(e.id));e&&u(e.level)}else u(null)},children:"Keep this collapse level as default"})]})]},e.id)})})}),rf=i("inline-flex items-center justify-center rounded-2xl border px-3 py-1.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-gray-100 text-gray-700 [a&]:hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:[a&]:hover:bg-gray-700",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",new:"text-purple-600 dark:text-purple-300 bg-purple-600/30 dark:bg-purple-600/30",beta:"text-blue-600 dark:text-blue-300 bg-blue-600/30 dark:bg-blue-600/30",highlight:"text-green-800 dark:text-green-300 bg-green-600/30 dark:bg-green-600/30"}},defaultVariants:{variant:"default"}});function af({className:e,variant:t,asChild:n=!1,...r}){/* @__PURE__ */
228
+ /* @__PURE__ */pe(Km,{checked:null!==l,onCheckedChange:e=>{if(e){const e=u.find(e=>i.has(e.id));e&&p(e.level)}else p(null)},children:"Keep this collapse level as default"})]})]},e.id)})})}),rf=i("inline-flex items-center justify-center rounded-2xl border px-3 py-1.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-gray-100 text-gray-700 [a&]:hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:[a&]:hover:bg-gray-700",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",new:"text-purple-600 dark:text-purple-300 bg-purple-600/30 dark:bg-purple-600/30",beta:"text-blue-600 dark:text-blue-300 bg-blue-600/30 dark:bg-blue-600/30",highlight:"text-green-800 dark:text-green-300 bg-green-600/30 dark:bg-green-600/30"}},defaultVariants:{variant:"default"}});function af({className:e,variant:t,asChild:n=!1,...r}){/* @__PURE__ */
229
229
  return pe(n?ce:"span",{"data-slot":"badge",className:Ml(rf({variant:t}),e),...r})}var of=[{id:"clarity",name:"Clarity",prompt:"Rewrite this paragraph for maximum clarity and straightforwardness, keeping all original meaning but removing ambiguity and simplifying complex sentences:",color:"blue"},{id:"concise",name:"Concise",prompt:"Rewrite this text to be more concise, removing redundancy and filler while preserving all key points and tone. Aim for about 50% of the original length:",color:"purple"},{id:"summarize",name:"Summarize",prompt:"Summarize the following text into a shorter paragraph, keeping the main ideas and overall tone but removing details and repetition:",color:"green"},{id:"rephrase",name:"Rephrase",prompt:"Rephrase this paragraph with fresh wording and more engaging style, varying sentence structure and word choice while preserving the core message:",color:"orange"},{id:"expand",name:"Expand",prompt:"Keep the original paragraph as-is, then expand it by adding one additional paragraph that elaborates on the main idea, gives an example, or adds helpful context for the reader:",color:"pink"}],sf="REASON-rewrite-modes",lf=()=>{try{const e=localStorage.getItem(sf);if(e)return JSON.parse(e)}catch(zi){}return of},cf=e=>{try{localStorage.setItem(sf,JSON.stringify(e))}catch(zi){}},df=({originalText:e,suggestedText:t,onApprove:n,onReject:r,onRegenerate:a,isLoading:o=!1,currentMode:i})=>{const[s,l]=le([]);if(te(()=>{l(lf())},[]),o)/* @__PURE__ */return me("div",{className:"flex items-center gap-2 rounded-lg border border-border bg-popover p-3 shadow-lg",children:[/* @__PURE__ */pe(Ze,{className:"h-4 w-4 animate-spin text-muted-foreground"}),/* @__PURE__ */pe("span",{className:"text-sm text-muted-foreground",children:"Generating AI suggestion..."})]});const c=e=>{const t={blue:"bg-blue-500/10 text-blue-700 dark:text-blue-300 hover:bg-blue-500/20 border-blue-500/20",purple:"bg-purple-500/10 text-purple-700 dark:text-purple-300 hover:bg-purple-500/20 border-purple-500/20",green:"bg-green-500/10 text-green-700 dark:text-green-300 hover:bg-green-500/20 border-green-500/20",orange:"bg-orange-500/10 text-orange-700 dark:text-orange-300 hover:bg-orange-500/20 border-orange-500/20",pink:"bg-pink-500/10 text-pink-700 dark:text-pink-300 hover:bg-pink-500/20 border-pink-500/20"};return t[e||"blue"]||t.blue};/* @__PURE__ */
230
230
  return me("div",{className:"h-full flex flex-col",children:[
231
231
  /* @__PURE__ */me("div",{className:"p-3 border-b border-sidebar-border",children:[/* @__PURE__ */pe("div",{className:"text-xs font-semibold text-sidebar-foreground mb-3",children:"AI SUGGESTION"}),a&&s.length>0&&/* @__PURE__ */me("div",{className:"mb-3",children:[/* @__PURE__ */pe("div",{className:"text-xs text-muted-foreground mb-2",children:"Rewrite Mode:"}),/* @__PURE__ */pe("div",{className:"flex flex-wrap gap-1",children:s.map(e=>/* @__PURE__ */pe(af,{variant:"outline",className:Ml("cursor-pointer text-xs px-2 py-0.5 transition-colors",c(e.color),i===e.id&&"ring-2 ring-offset-1"),onClick:()=>a(e),children:e.name},e.id))})]})]}),
232
232
  /* @__PURE__ */me("div",{className:"flex-1 overflow-auto p-3 space-y-4",children:[/* @__PURE__ */me("div",{children:[/* @__PURE__ */pe("div",{className:"text-xs font-semibold text-muted-foreground mb-2",children:"Original:"}),/* @__PURE__ */pe("div",{className:"text-sm text-foreground/70 line-through bg-muted/50 p-3 rounded-md",children:e})]}),/* @__PURE__ */me("div",{children:[/* @__PURE__ */pe("div",{className:"text-xs font-semibold text-muted-foreground mb-2",children:"Suggested:"}),/* @__PURE__ */pe("div",{className:"text-sm text-foreground font-medium bg-primary/10 p-3 rounded-md border border-primary/20",children:t})]})]}),
233
233
  /* @__PURE__ */pe("div",{className:"border-t border-sidebar-border p-3",children:/* @__PURE__ */me("div",{className:"flex flex-col gap-2",children:[/* @__PURE__ */me(tp,{variant:"default",size:"sm",onClick:n,className:"w-full h-9 bg-green-500 hover:bg-green-600 text-white",title:"Approve",children:[/* @__PURE__ */pe(ve,{className:"h-4 w-4 mr-1"}),"Approve"]}),/* @__PURE__ */me(tp,{variant:"outline",size:"sm",onClick:r,className:"w-full h-9",title:"Reject",children:[/* @__PURE__ */pe(Nt,{className:"h-4 w-4 mr-1"}),"Reject"]})]})})]})};function uf({className:e,type:t,...n}){/* @__PURE__ */
234
- return pe("input",{type:t,"data-slot":"input",className:Ml("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground flex h-11 w-full min-w-0 rounded-2xl border bg-card px-3 py-1 text-sm font-medium transition-[color] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50","focus:outline-none focus:ring-2 focus:ring-primary/50","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}function hf(...e){return e.filter(Boolean).join(" ")}var pf=X(function(e,t){const{className:n,style:r,children:a,defaultSize:o,size:i,minSize:s,maxSize:l,...c}=e,d={position:"relative",outline:"none",overflow:"auto",flex:"none",...r},u=hf("split-pane-pane",n);return pe("div",{ref:t,className:u,style:d,"data-pane":"true",...c,children:a})});function mf(e,t="polite"){if("undefined"==typeof document)return;const n=document.createElement("div");n.setAttribute("role","status"),n.setAttribute("aria-live",t),n.setAttribute("aria-atomic","true"),n.style.position="absolute",n.style.left="-10000px",n.style.width="1px",n.style.height="1px",n.style.overflow="hidden",n.textContent=e,document.body.appendChild(n),setTimeout(()=>{document.body.removeChild(n)},1e3)}function ff(e){return 1e3>e?Math.round(e)+" pixels":Math.round(e/10)/100+" thousand pixels"}function gf(e){const{direction:t,index:n,isDragging:r,disabled:a,onPointerDown:o,onKeyDown:i,className:s,style:l,currentSize:c,minSize:d,maxSize:u,children:h}=e,p="horizontal"===t?"vertical":"horizontal",m={flex:"none",position:"relative",userSelect:"none",touchAction:"none",..."horizontal"===t?{width:"1px",cursor:a?"default":"col-resize"}:{height:"1px",cursor:a?"default":"row-resize"},...r&&{cursor:"horizontal"===t?"col-resize":"row-resize"},...l},f=hf("split-pane-divider",t,r&&"dragging",s),g=function(e,t){return`${"horizontal"===t?"vertical":"horizontal"} divider ${e+1}`}(n,t);return pe("div",{role:"separator","aria-orientation":p,"aria-label":g,"aria-valuenow":c,"aria-valuemin":d,"aria-valuemax":void 0===u||u===1/0?void 0:u,"aria-description":function(e){return`Use ${"horizontal"===e?"left and right arrow keys":"up and down arrow keys"} to resize. Hold Shift for larger steps. Press Home or End to minimize or maximize.`}(t),tabIndex:a?-1:0,className:f,style:m,onPointerDown:a?void 0:o,onKeyDown:a?void 0:i,"data-divider-index":n,children:h})}function vf(e,t){if("number"==typeof e)return e;if(e.endsWith("%"))return parseFloat(e)/100*t;if(e.endsWith("px"))return parseFloat(e);const n=parseFloat(e);return isNaN(n)?0:n}function yf(e,t,n){return Math.min(Math.max(e,t),n)}function bf(e,t,n,r,a){const o=[...e],i=e[t]??0,s=e[t+1]??0,l=r[t+1]??0,c=a[t+1]??1/0;let d=yf(i+n,r[t]??0,a[t]??1/0),u=yf(s-n,l,c);const h=s-u,p=Math.min(Math.abs(d-i),Math.abs(h));return n>0?(d=i+p,u=s-p):(d=i-p,u=s+p),o[t]=d,o[t+1]=u,o}function xf(e){const{direction:t,sizes:n,minSizes:r,maxSizes:a,snapPoints:o=[],snapTolerance:i=10,step:s,onResizeStart:l,onResize:c,onResizeEnd:d}=e,[u,h]=le(!1),[p,m]=le(n),f=se(null),g=se(null),v=se(!0),y=se(null),b=se(p);b.current=p;const x=se(d);x.current=d;const w=se(n);te(()=>{u||JSON.stringify(n)===JSON.stringify(w.current)||(w.current=n,m(n))},[n,u]),te(()=>(v.current=!0,()=>{v.current=!1,g.current&&(cancelAnimationFrame(g.current),g.current=null)}),[]);const S=Q((e,n)=>{if(!f.current||!v.current)return;const{dividerIndex:l,startPosition:d,startSizes:u,pointerType:h}=f.current;let p=("horizontal"===t?e:n)-d;s&&(p=function(e,t){return t>0?Math.round(e/t)*t:e}(p,s));let g=bf(u,l,p,r,a);o.length>0&&(g=g.map(e=>function(e,t,n){for(const r of t)if(n>=Math.abs(e-r))return r;return e}(e,o,i))),m(g),c&&c(g,{sizes:g,source:"pointer",pointerType:h})},[t,s,r,a,o,i,c]),k=Q(e=>{f.current&&e.pointerId===f.current.pointerId&&(e.preventDefault(),y.current={x:e.clientX,y:e.clientY},g.current||(g.current=requestAnimationFrame(()=>{g.current=null,v.current&&y.current&&S(y.current.x,y.current.y)})))},[S]),C=Q(e=>{if(!f.current||e.pointerId!==f.current.pointerId)return;const{element:t,pointerId:n,pointerType:r}=f.current;t?.hasPointerCapture?.(n)&&t.releasePointerCapture(n),g.current&&(cancelAnimationFrame(g.current),g.current=null),h(!1);const a=b.current,o=x.current;o&&o(a,{sizes:a,source:"pointer",pointerType:r}),f.current=null},[]),N=Q(e=>n=>{n.preventDefault();const r="horizontal"===t?n.clientX:n.clientY,a=n.currentTarget;a.setPointerCapture(n.pointerId);const o=n.pointerType;f.current={dividerIndex:e,startPosition:r,startSizes:p,pointerId:n.pointerId,pointerType:o,element:a},h(!0),l&&l({sizes:p,source:"pointer",pointerType:o,originalEvent:n.nativeEvent})},[t,p,l]);return te(()=>{if(u)return document.addEventListener("pointermove",k),document.addEventListener("pointerup",C),document.addEventListener("pointercancel",C),()=>{document.removeEventListener("pointermove",k),document.removeEventListener("pointerup",C),document.removeEventListener("pointercancel",C)}},[u,k,C]),{isDragging:u,currentSizes:p,handlePointerDown:N}}var wf=10,Sf=50;function kf(e){const{direction:t,sizes:n,minSizes:r,maxSizes:a,step:o=wf,largeStep:i=Sf,onResize:s,onResizeEnd:l}=e,c=se(null);return{handleKeyDown:Q(e=>d=>{if(!("horizontal"===t?["ArrowLeft","ArrowRight"]:["ArrowUp","ArrowDown"]).includes(d.key)&&"Home"!==d.key&&"End"!==d.key&&"Escape"!==d.key)return;if(d.preventDefault(),"Escape"===d.key){if(c.current){const e=c.current;c.current=null,s&&s(e,{sizes:e,source:"keyboard",originalEvent:d.nativeEvent}),l&&l(e,{sizes:e,source:"keyboard",originalEvent:d.nativeEvent}),mf("Pane sizes restored")}return}null===c.current&&(c.current=[...n]);let u=0,h=[...n],p="arrow";switch(d.key){case"ArrowLeft":case"ArrowUp":u=-(d.shiftKey?i:o);break;case"ArrowRight":case"ArrowDown":u=d.shiftKey?i:o;break;case"Home":{p="home";const t=e+1,a=r[e]??0,o=(n[e]??0)+(n[t]??0);h[e]=a,h[t]=o-a;break}case"End":{p="end";const t=e,o=e+1,i=(n[t]??0)+(n[o]??0);h[t]=Math.min(a[t]??1/0,i-(r[o]??0)),h[o]=i-h[t];break}}if(0!==u&&(h=bf(n,e,u,r,a)),h=h.map((e,t)=>yf(e,r[t]??0,a[t]??1/0)),s&&s(h,{sizes:h,source:"keyboard",originalEvent:d.nativeEvent}),l&&l(h,{sizes:h,source:"keyboard",originalEvent:d.nativeEvent}),"home"===p)mf(`Pane ${e+1} minimized to ${ff(h[e]??0)}`);else if("end"===p)mf(`Pane ${e+1} maximized to ${ff(h[e]??0)}`);else{const t=u>0?e:e+1;mf(`Pane ${t+1} resized to ${ff(h[t]??0)}`)}},[t,n,r,a,o,i,s,l])}}function Cf(e){const{direction:t="horizontal",resizable:n=!0,snapPoints:r,snapTolerance:a=10,step:o,onResizeStart:i,onResize:s,onResizeEnd:l,className:c,style:d,divider:u,dividerStyle:h,dividerClassName:p,dividerSize:m=1,children:f}=e,g=se(null),[v,y]=le(0),b=se(0),x=ie(()=>U.toArray(f).filter(e=>"object"==typeof e&&null!==e&&"props"in e).map(e=>({props:e.props,size:e.props.size,defaultSize:e.props.defaultSize,minSize:e.props.minSize??0,maxSize:e.props.maxSize??1/0})),[f]),w=x.length,S=se(!1);2>w&&!S.current&&(S.current=!0);const{minSizes:k,maxSizes:C}=ie(()=>{if(0===v)return{minSizes:Array(w).fill(0),maxSizes:Array(w).fill(1/0)};const e=[],t=[];return x.forEach(n=>{e.push(vf(n.minSize,v)),t.push(n.maxSize===1/0?1/0:vf(n.maxSize,v))}),{minSizes:e,maxSizes:t}},[v,w,x]),N=Q(e=>{if(0===e)return Array(w).fill(0);const t=e-m*(w-1),n=x.map(e=>{const n=e.size??e.defaultSize;return void 0!==n?vf(n,t):null}),r=n.reduce((e,t)=>e+(t??0),0),a=n.filter(e=>null===e).length,o=a>0?(t-r)/a:0;return n.map(e=>null===e?o:e)},[w,x,m]),[T,A]=le(()=>N(v));te(()=>{if(0===v)return;if(!x.some(e=>void 0!==e.size))return;const e=N(v);A(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[v,x,N]);const I=Q(e=>{const t=b.current;if(b.current=e,0===e)return;const n=x.some(e=>void 0!==e.size),r=e-m*(w-1);A(a=>a.every(e=>0===e)||a.length!==w?N(e):t>0&&t!==e?n?N(e):function(e,t){const n=e.reduce((e,t)=>e+t,0);if(0===n){const n=t/e.length;return e.map(()=>n)}return e.map(e=>e/n*t)}(a,r):0===t?N(e):a)},[w,x,N,m]),M=se(0);te(()=>{const e=g.current;if(!e)return;const n=new ResizeObserver(e=>{const n=e[0];n&&(e=>{const n=Math.round("horizontal"===t?e.width:e.height);n>0&&n!==M.current&&(M.current=n,y(n),I(n))})(n.contentRect)});return n.observe(e),()=>{n.disconnect()}},[t,I]);const D=Q((e,t)=>{A(e),s?.(e,t)},[s]),{isDragging:E,currentSizes:R,handlePointerDown:_}=xf({direction:t,sizes:T,minSizes:k,maxSizes:C,snapPoints:r,snapTolerance:a,step:o,onResizeStart:i,onResize:D,onResizeEnd:l}),{handleKeyDown:z}=kf({direction:t,sizes:R,minSizes:k,maxSizes:C,step:o,onResize:D,onResizeEnd:l}),P=Q(e=>t=>{const n={...t,pointerId:1,pointerType:"mouse",nativeEvent:t.nativeEvent};_(e)(n)},[_]),O=Q(e=>t=>{const n=t.touches[0];if(!n)return;const r={...t,clientX:n.clientX,clientY:n.clientY,pointerId:n.identifier,pointerType:"touch",nativeEvent:t.nativeEvent};_(e)(r)},[_]),L=Q(()=>{},[]),F={display:"flex",flexDirection:"horizontal"===t?"row":"column",height:"100%",width:"100%",overflow:"hidden",position:"relative",...d},B=hf("split-pane",t,c);return pe("div",{ref:g,className:B,style:F,children:v>0&&(()=>{if(2>w)return null;const e=[];return x.forEach((r,a)=>{const o=R[a]??0,i={..."horizontal"===t?{width:o+"px",height:"100%"}:{height:o+"px",width:"100%"},...r.props.style};if(e.push(pe(pf,{...r.props,style:i,children:r.props.children},"pane-"+a)),w-1>a){const r=k[a],i=C[a];e.push(pe(u??gf,{direction:t,index:a,isDragging:E,disabled:!n,onPointerDown:_(a),onMouseDown:P(a),onTouchStart:O(a),onTouchEnd:L,onKeyDown:z(a),className:p,style:h,currentSize:o,minSize:r,maxSize:i===1/0?void 0:i},"divider-"+a))}}),e})()})}function Nf(e){const{key:t,storage:n=localStorage,debounce:r=300}=e,[a,o]=le(()=>{try{const e=n.getItem(t);return e?JSON.parse(e):[]}catch{return[]}});return te(()=>{if(0===a.length)return;const e=setTimeout(()=>{try{n.setItem(t,JSON.stringify(a))}catch(e){}},r);return()=>clearTimeout(e)},[a,t,n,r]),[a,o]}var Tf="undefined"==typeof window?{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},key:()=>null,length:0}:window.localStorage,Af=({panels:e,split:t,persistenceKey:n,activeDocuments:r,activeId:a,activeDocument:o,headings:i=[],isMobile:s,onSelect:l,onAdd:c,onDelete:d,onDuplicate:u,onMove:h,onManageTags:p,onRename:m,onOpenChange:f,treeRef:g,outlineRef:v,openTabs:y=[],activeTab:b,onTabChange:x,onTabClose:w,onTabRename:S,onSplitRight:k,onReopenLastClosed:C,canReopenLastClosed:N=!1,onNavigate:T,aiProps:A,tabItems:I,onNewChat:M})=>{const[D,E]=le(null),[R,_]=le(""),z=se(null),P=se(null),O=g??z,L=v??P,F=e=>{l(e),s&&f&&f(!1)},B=e=>{p?.(e),s&&f&&f(!1)},V=Q(e=>{E(e)},[]),$=Q(e=>{D&&u(D)},[D,u]),H=ie(()=>{const e=o?.content||"";if(!e)return[];const t=(new DOMParser).parseFromString(e,"text/html"),n=[];let r="",a=-1;for(const o of Array.from(t.body.children))/^h[1-6]$/i.test(o.tagName)?(a>=0&&(n[a]=r),a++,r=""):a>=0&&(r+=" "+(o.textContent||""));return a>=0&&(n[a]=r),n},[o?.content]),q=ie(()=>{const e=R.trim().toLowerCase();return e?i.filter(([,t],n)=>t.toLowerCase().includes(e)||(H[n]||"").toLowerCase().includes(e)):i},[R,i,H]),[j,U]=Nf({key:`sidebar-panels-${n}`,storage:Tf}),G=I??y.map(e=>({id:e,title:r.find(t=>t.id===e)?.title||"Untitled",kind:"file"})),W=e=>{switch(e){case"files":/* @__PURE__ */return pe("div",{className:"h-full overflow-auto",children:/* @__PURE__ */pe(ef,{ref:O,documents:r,activeId:a,onSelect:F,onMove:h,onRename:m,onDelete:d,onDuplicate:u,onAddChild:e=>c(e,!1),onAddChildFolder:e=>c(e,!0),onAddSibling:e=>{c(r.find(t=>t.id===e)?.parentId||null,!1)},onAddSiblingFolder:e=>{c(r.find(t=>t.id===e)?.parentId||null,!0)},onCopy:V,onPaste:$,onManageTags:B})});case"openTabs":/* @__PURE__ */return pe("div",{className:"h-full overflow-auto",children:/* @__PURE__ */me("div",{className:"px-1 py-1",children:[/* @__PURE__ */me("div",{className:"flex items-center justify-between px-2 py-1",children:[/* @__PURE__ */pe("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Open Tabs"}),/* @__PURE__ */me("div",{className:"flex items-center gap-0.5",children:[/* @__PURE__ */pe("button",{className:"h-5 w-5 flex items-center justify-center rounded text-muted-foreground hover:bg-sidebar-accent hover:text-foreground",title:"New File",onClick:()=>c(null,!1),children:/* @__PURE__ */pe(Be,{className:"h-3.5 w-3.5"})}),M&&/* @__PURE__ */pe("button",{className:"h-5 w-5 flex items-center justify-center rounded text-muted-foreground hover:bg-sidebar-accent hover:text-foreground",title:"New Chat",onClick:M,children:/* @__PURE__ */pe(rt,{className:"h-3.5 w-3.5"})})]})]}),0===G.length?/* @__PURE__ */pe("div",{className:"px-2 py-3 text-xs text-muted-foreground",children:"No open tabs"}):G.map(({id:e,title:t,kind:n})=>{const r="chat"===n;/* @__PURE__ */
235
- return me(Hm,{children:[/* @__PURE__ */pe(qm,{children:/* @__PURE__ */me("div",{className:Ml("group flex items-center gap-2 px-2 py-1.5 rounded-md cursor-pointer transition-colors hover:bg-sidebar-accent",e===b&&"bg-sidebar-accent text-blue-600 font-medium"),onClick:()=>x?.(e),children:[r?/* @__PURE__ */pe(nt,{className:"shrink-0 h-4 w-4 text-blue-500"}):/* @__PURE__ */pe(xp,{filename:t,size:16}),
236
- /* @__PURE__ */pe("span",{className:"flex-1 truncate text-sm",children:t}),w&&/* @__PURE__ */pe("button",{className:"shrink-0 h-4 w-4 flex items-center justify-center rounded opacity-0 group-hover:opacity-100 hover:bg-destructive/10 hover:text-destructive",onClick:t=>{t.stopPropagation(),w(e)},children:/* @__PURE__ */pe(Nt,{className:"h-3 w-3"})})]})}),/* @__PURE__ */me(Wm,{children:[S&&!r&&/* @__PURE__ */me(Ym,{onClick:()=>{const n=window.prompt("Rename document",t);n?.trim()&&S(e,n.trim())},children:[/* @__PURE__ */pe(Pe,{className:"mr-2 h-4 w-4"}),"Rename"]}),w&&/* @__PURE__ */me(Ym,{onClick:()=>w(e),className:"text-destructive focus:text-destructive",children:[/* @__PURE__ */pe(Nt,{className:"mr-2 h-4 w-4"}),"Close"]}),!r&&(k||C)&&/* @__PURE__ */pe(Xm,{}),k&&!r&&/* @__PURE__ */me(Ym,{onClick:()=>k(e),children:[/* @__PURE__ */pe(vt,{className:"mr-2 h-4 w-4"}),"Split Right"]}),C&&!r&&/* @__PURE__ */me(Ym,{onClick:C,disabled:!N,children:[/* @__PURE__ */pe(ut,{className:"mr-2 h-4 w-4"}),"Reopen Last Closed"]})]})]},e)})]})});case"outline":/* @__PURE__ */return me("div",{className:"h-full overflow-hidden flex flex-col",children:[/* @__PURE__ */me("div",{className:"px-3 py-2 border-b border-sidebar-border shrink-0",children:[/* @__PURE__ */pe("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:"Outline"}),/* @__PURE__ */me("div",{className:"relative",children:[
234
+ return pe("input",{type:t,"data-slot":"input",className:Ml("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground flex h-11 w-full min-w-0 rounded-2xl border bg-card px-3 py-1 text-sm font-medium transition-[color] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50","focus:outline-none focus:ring-2 focus:ring-primary/50","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}function hf(...e){return e.filter(Boolean).join(" ")}var pf=X(function(e,t){const{className:n,style:r,children:a,defaultSize:o,size:i,minSize:s,maxSize:l,...c}=e,d={position:"relative",outline:"none",overflow:"auto",flex:"none",...r},u=hf("split-pane-pane",n);return pe("div",{ref:t,className:u,style:d,"data-pane":"true",...c,children:a})});function mf(e,t="polite"){if("undefined"==typeof document)return;const n=document.createElement("div");n.setAttribute("role","status"),n.setAttribute("aria-live",t),n.setAttribute("aria-atomic","true"),n.style.position="absolute",n.style.left="-10000px",n.style.width="1px",n.style.height="1px",n.style.overflow="hidden",n.textContent=e,document.body.appendChild(n),setTimeout(()=>{document.body.removeChild(n)},1e3)}function ff(e){return 1e3>e?Math.round(e)+" pixels":Math.round(e/10)/100+" thousand pixels"}function gf(e){const{direction:t,index:n,isDragging:r,disabled:a,onPointerDown:o,onKeyDown:i,className:s,style:l,currentSize:c,minSize:d,maxSize:u,children:h}=e,p="horizontal"===t?"vertical":"horizontal",m={flex:"none",position:"relative",userSelect:"none",touchAction:"none",..."horizontal"===t?{width:"1px",cursor:a?"default":"col-resize"}:{height:"1px",cursor:a?"default":"row-resize"},...r&&{cursor:"horizontal"===t?"col-resize":"row-resize"},...l},f=hf("split-pane-divider",t,r&&"dragging",s),g=function(e,t){return`${"horizontal"===t?"vertical":"horizontal"} divider ${e+1}`}(n,t);return pe("div",{role:"separator","aria-orientation":p,"aria-label":g,"aria-valuenow":c,"aria-valuemin":d,"aria-valuemax":void 0===u||u===1/0?void 0:u,"aria-description":function(e){return`Use ${"horizontal"===e?"left and right arrow keys":"up and down arrow keys"} to resize. Hold Shift for larger steps. Press Home or End to minimize or maximize.`}(t),tabIndex:a?-1:0,className:f,style:m,onPointerDown:a?void 0:o,onKeyDown:a?void 0:i,"data-divider-index":n,children:h})}function vf(e,t){if("number"==typeof e)return e;if(e.endsWith("%"))return parseFloat(e)/100*t;if(e.endsWith("px"))return parseFloat(e);const n=parseFloat(e);return isNaN(n)?0:n}function yf(e,t,n){return Math.min(Math.max(e,t),n)}function bf(e,t,n,r,a){const o=[...e],i=e[t]??0,s=e[t+1]??0,l=r[t+1]??0,c=a[t+1]??1/0;let d=yf(i+n,r[t]??0,a[t]??1/0),u=yf(s-n,l,c);const h=s-u,p=Math.min(Math.abs(d-i),Math.abs(h));return n>0?(d=i+p,u=s-p):(d=i-p,u=s+p),o[t]=d,o[t+1]=u,o}function xf(e){const{direction:t,sizes:n,minSizes:r,maxSizes:a,snapPoints:o=[],snapTolerance:i=10,step:s,onResizeStart:l,onResize:c,onResizeEnd:d}=e,[u,h]=le(!1),[p,m]=le(n),f=se(null),g=se(null),v=se(!0),y=se(null),b=se(p);b.current=p;const x=se(d);x.current=d;const w=se(n);te(()=>{u||JSON.stringify(n)===JSON.stringify(w.current)||(w.current=n,m(n))},[n,u]),te(()=>(v.current=!0,()=>{v.current=!1,g.current&&(cancelAnimationFrame(g.current),g.current=null)}),[]);const S=Q((e,n)=>{if(!f.current||!v.current)return;const{dividerIndex:l,startPosition:d,startSizes:u,pointerType:h}=f.current;let p=("horizontal"===t?e:n)-d;s&&(p=function(e,t){return t>0?Math.round(e/t)*t:e}(p,s));let g=bf(u,l,p,r,a);o.length>0&&(g=g.map(e=>function(e,t,n){for(const r of t)if(n>=Math.abs(e-r))return r;return e}(e,o,i))),m(g),c&&c(g,{sizes:g,source:"pointer",pointerType:h})},[t,s,r,a,o,i,c]),k=Q(e=>{f.current&&e.pointerId===f.current.pointerId&&(e.preventDefault(),y.current={x:e.clientX,y:e.clientY},g.current||(g.current=requestAnimationFrame(()=>{g.current=null,v.current&&y.current&&S(y.current.x,y.current.y)})))},[S]),C=Q(e=>{if(!f.current||e.pointerId!==f.current.pointerId)return;const{element:t,pointerId:n,pointerType:r}=f.current;t?.hasPointerCapture?.(n)&&t.releasePointerCapture(n),g.current&&(cancelAnimationFrame(g.current),g.current=null),h(!1);const a=b.current,o=x.current;o&&o(a,{sizes:a,source:"pointer",pointerType:r}),f.current=null},[]),N=Q(e=>n=>{n.preventDefault();const r="horizontal"===t?n.clientX:n.clientY,a=n.currentTarget;a.setPointerCapture(n.pointerId);const o=n.pointerType;f.current={dividerIndex:e,startPosition:r,startSizes:p,pointerId:n.pointerId,pointerType:o,element:a},h(!0),l&&l({sizes:p,source:"pointer",pointerType:o,originalEvent:n.nativeEvent})},[t,p,l]);return te(()=>{if(u)return document.addEventListener("pointermove",k),document.addEventListener("pointerup",C),document.addEventListener("pointercancel",C),()=>{document.removeEventListener("pointermove",k),document.removeEventListener("pointerup",C),document.removeEventListener("pointercancel",C)}},[u,k,C]),{isDragging:u,currentSizes:p,handlePointerDown:N}}var wf=10,Sf=50;function kf(e){const{direction:t,sizes:n,minSizes:r,maxSizes:a,step:o=wf,largeStep:i=Sf,onResize:s,onResizeEnd:l}=e,c=se(null);return{handleKeyDown:Q(e=>d=>{if(!("horizontal"===t?["ArrowLeft","ArrowRight"]:["ArrowUp","ArrowDown"]).includes(d.key)&&"Home"!==d.key&&"End"!==d.key&&"Escape"!==d.key)return;if(d.preventDefault(),"Escape"===d.key){if(c.current){const e=c.current;c.current=null,s&&s(e,{sizes:e,source:"keyboard",originalEvent:d.nativeEvent}),l&&l(e,{sizes:e,source:"keyboard",originalEvent:d.nativeEvent}),mf("Pane sizes restored")}return}null===c.current&&(c.current=[...n]);let u=0,h=[...n],p="arrow";switch(d.key){case"ArrowLeft":case"ArrowUp":u=-(d.shiftKey?i:o);break;case"ArrowRight":case"ArrowDown":u=d.shiftKey?i:o;break;case"Home":{p="home";const t=e+1,a=r[e]??0,o=(n[e]??0)+(n[t]??0);h[e]=a,h[t]=o-a;break}case"End":{p="end";const t=e,o=e+1,i=(n[t]??0)+(n[o]??0);h[t]=Math.min(a[t]??1/0,i-(r[o]??0)),h[o]=i-h[t];break}}if(0!==u&&(h=bf(n,e,u,r,a)),h=h.map((e,t)=>yf(e,r[t]??0,a[t]??1/0)),s&&s(h,{sizes:h,source:"keyboard",originalEvent:d.nativeEvent}),l&&l(h,{sizes:h,source:"keyboard",originalEvent:d.nativeEvent}),"home"===p)mf(`Pane ${e+1} minimized to ${ff(h[e]??0)}`);else if("end"===p)mf(`Pane ${e+1} maximized to ${ff(h[e]??0)}`);else{const t=u>0?e:e+1;mf(`Pane ${t+1} resized to ${ff(h[t]??0)}`)}},[t,n,r,a,o,i,s,l])}}function Cf(e){const{direction:t="horizontal",resizable:n=!0,snapPoints:r,snapTolerance:a=10,step:o,onResizeStart:i,onResize:s,onResizeEnd:l,className:c,style:d,divider:u,dividerStyle:h,dividerClassName:p,dividerSize:m=1,children:f}=e,g=se(null),[v,y]=le(0),b=se(0),x=ie(()=>U.toArray(f).filter(e=>"object"==typeof e&&null!==e&&"props"in e).map(e=>({props:e.props,size:e.props.size,defaultSize:e.props.defaultSize,minSize:e.props.minSize??0,maxSize:e.props.maxSize??1/0})),[f]),w=x.length,S=se(!1);2>w&&!S.current&&(S.current=!0);const{minSizes:k,maxSizes:C}=ie(()=>{if(0===v)return{minSizes:Array(w).fill(0),maxSizes:Array(w).fill(1/0)};const e=[],t=[];return x.forEach(n=>{e.push(vf(n.minSize,v)),t.push(n.maxSize===1/0?1/0:vf(n.maxSize,v))}),{minSizes:e,maxSizes:t}},[v,w,x]),N=Q(e=>{if(0===e)return Array(w).fill(0);const t=e-m*(w-1),n=x.map(e=>{const n=e.size??e.defaultSize;return void 0!==n?vf(n,t):null}),r=n.reduce((e,t)=>e+(t??0),0),a=n.filter(e=>null===e).length,o=a>0?(t-r)/a:0;return n.map(e=>null===e?o:e)},[w,x,m]),[T,A]=le(()=>N(v));te(()=>{if(0===v)return;if(!x.some(e=>void 0!==e.size))return;const e=N(v);A(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[v,x,N]);const I=Q(e=>{const t=b.current;if(b.current=e,0===e)return;const n=x.some(e=>void 0!==e.size),r=e-m*(w-1);A(a=>a.every(e=>0===e)||a.length!==w?N(e):t>0&&t!==e?n?N(e):function(e,t){const n=e.reduce((e,t)=>e+t,0);if(0===n){const n=t/e.length;return e.map(()=>n)}return e.map(e=>e/n*t)}(a,r):0===t?N(e):a)},[w,x,N,m]),M=se(0);te(()=>{const e=g.current;if(!e)return;const n=new ResizeObserver(e=>{const n=e[0];n&&(e=>{const n=Math.round("horizontal"===t?e.width:e.height);n>0&&n!==M.current&&(M.current=n,y(n),I(n))})(n.contentRect)});return n.observe(e),()=>{n.disconnect()}},[t,I]);const D=Q((e,t)=>{A(e),s?.(e,t)},[s]),{isDragging:E,currentSizes:R,handlePointerDown:_}=xf({direction:t,sizes:T,minSizes:k,maxSizes:C,snapPoints:r,snapTolerance:a,step:o,onResizeStart:i,onResize:D,onResizeEnd:l}),{handleKeyDown:z}=kf({direction:t,sizes:R,minSizes:k,maxSizes:C,step:o,onResize:D,onResizeEnd:l}),P=Q(e=>t=>{const n={...t,pointerId:1,pointerType:"mouse",nativeEvent:t.nativeEvent};_(e)(n)},[_]),O=Q(e=>t=>{const n=t.touches[0];if(!n)return;const r={...t,clientX:n.clientX,clientY:n.clientY,pointerId:n.identifier,pointerType:"touch",nativeEvent:t.nativeEvent};_(e)(r)},[_]),L=Q(()=>{},[]),F={display:"flex",flexDirection:"horizontal"===t?"row":"column",height:"100%",width:"100%",overflow:"hidden",position:"relative",...d},B=hf("split-pane",t,c);return pe("div",{ref:g,className:B,style:F,children:v>0&&(()=>{if(2>w)return null;const e=[];return x.forEach((r,a)=>{const o=R[a]??0,i={..."horizontal"===t?{width:o+"px",height:"100%"}:{height:o+"px",width:"100%"},...r.props.style};if(e.push(pe(pf,{...r.props,style:i,children:r.props.children},"pane-"+a)),w-1>a){const r=k[a],i=C[a];e.push(pe(u??gf,{direction:t,index:a,isDragging:E,disabled:!n,onPointerDown:_(a),onMouseDown:P(a),onTouchStart:O(a),onTouchEnd:L,onKeyDown:z(a),className:p,style:h,currentSize:o,minSize:r,maxSize:i===1/0?void 0:i},"divider-"+a))}}),e})()})}function Nf(e){const{key:t,storage:n=localStorage,debounce:r=300}=e,[a,o]=le(()=>{try{const e=n.getItem(t);return e?JSON.parse(e):[]}catch{return[]}});return te(()=>{if(0===a.length)return;const e=setTimeout(()=>{try{n.setItem(t,JSON.stringify(a))}catch(e){}},r);return()=>clearTimeout(e)},[a,t,n,r]),[a,o]}var Tf="undefined"==typeof window?{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},key:()=>null,length:0}:window.localStorage,Af=({panels:e,split:t,persistenceKey:n,activeDocuments:r,activeId:a,activeDocument:o,headings:i=[],isMobile:s,onSelect:l,onAdd:c,onDelete:d,onDuplicate:u,onMove:h,onManageTags:p,onRename:m,onOpenChange:f,treeRef:g,outlineRef:v,editorRef:y,openTabs:b=[],activeTab:x,onTabChange:w,onTabClose:S,onTabRename:k,onSplitRight:C,onReopenLastClosed:N,canReopenLastClosed:T=!1,onNavigate:A,aiProps:I,tabItems:M,onNewChat:D})=>{const[E,R]=le(null),[_,z]=le(""),P=se(null),O=se(null),L=g??P,F=v??O,B=e=>{l(e),s&&f&&f(!1)},V=e=>{p?.(e),s&&f&&f(!1)},$=Q(e=>{R(e)},[]),H=Q(e=>{E&&u(E)},[E,u]),q=ie(()=>{const e=o?.content||"";if(!e)return[];const t=(new DOMParser).parseFromString(e,"text/html"),n=[];let r="",a=-1;for(const o of Array.from(t.body.children))/^h[1-6]$/i.test(o.tagName)?(a>=0&&(n[a]=r),a++,r=""):a>=0&&(r+=" "+(o.textContent||""));return a>=0&&(n[a]=r),n},[o?.content]),j=ie(()=>{const e=_.trim().toLowerCase();return e?i.filter(([,t],n)=>t.toLowerCase().includes(e)||(q[n]||"").toLowerCase().includes(e)):i},[_,i,q]),[U,G]=Nf({key:`sidebar-panels-${n}`,storage:Tf}),W=M??b.map(e=>({id:e,title:r.find(t=>t.id===e)?.title||"Untitled",kind:"file"})),Y=e=>{switch(e){case"files":/* @__PURE__ */return pe("div",{className:"h-full overflow-auto",children:/* @__PURE__ */pe(ef,{ref:L,documents:r,activeId:a,onSelect:B,onMove:h,onRename:m,onDelete:d,onDuplicate:u,onAddChild:e=>c(e,!1),onAddChildFolder:e=>c(e,!0),onAddSibling:e=>{c(r.find(t=>t.id===e)?.parentId||null,!1)},onAddSiblingFolder:e=>{c(r.find(t=>t.id===e)?.parentId||null,!0)},onCopy:$,onPaste:H,onManageTags:V})});case"openTabs":/* @__PURE__ */return pe("div",{className:"h-full overflow-auto",children:/* @__PURE__ */me("div",{className:"px-1 py-1",children:[/* @__PURE__ */me("div",{className:"flex items-center justify-between px-2 py-1",children:[/* @__PURE__ */pe("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Open Tabs"}),/* @__PURE__ */me("div",{className:"flex items-center gap-0.5",children:[/* @__PURE__ */pe("button",{className:"h-5 w-5 flex items-center justify-center rounded text-muted-foreground hover:bg-sidebar-accent hover:text-foreground",title:"New File",onClick:()=>c(null,!1),children:/* @__PURE__ */pe(Be,{className:"h-3.5 w-3.5"})}),D&&/* @__PURE__ */pe("button",{className:"h-5 w-5 flex items-center justify-center rounded text-muted-foreground hover:bg-sidebar-accent hover:text-foreground",title:"New Chat",onClick:D,children:/* @__PURE__ */pe(rt,{className:"h-3.5 w-3.5"})})]})]}),0===W.length?/* @__PURE__ */pe("div",{className:"px-2 py-3 text-xs text-muted-foreground",children:"No open tabs"}):W.map(({id:e,title:t,kind:n})=>{const r="chat"===n;/* @__PURE__ */
235
+ return me(Hm,{children:[/* @__PURE__ */pe(qm,{children:/* @__PURE__ */me("div",{className:Ml("group flex items-center gap-2 px-2 py-1.5 rounded-md cursor-pointer transition-colors hover:bg-sidebar-accent",e===x&&"bg-sidebar-accent text-blue-600 font-medium"),onClick:()=>w?.(e),children:[r?/* @__PURE__ */pe(nt,{className:"shrink-0 h-4 w-4 text-blue-500"}):/* @__PURE__ */pe(xp,{filename:t,size:16}),
236
+ /* @__PURE__ */pe("span",{className:"flex-1 truncate text-sm",children:t}),S&&/* @__PURE__ */pe("button",{className:"shrink-0 h-4 w-4 flex items-center justify-center rounded opacity-0 group-hover:opacity-100 hover:bg-destructive/10 hover:text-destructive",onClick:t=>{t.stopPropagation(),S(e)},children:/* @__PURE__ */pe(Nt,{className:"h-3 w-3"})})]})}),/* @__PURE__ */me(Wm,{children:[k&&!r&&/* @__PURE__ */me(Ym,{onClick:()=>{const n=window.prompt("Rename document",t);n?.trim()&&k(e,n.trim())},children:[/* @__PURE__ */pe(Pe,{className:"mr-2 h-4 w-4"}),"Rename"]}),S&&/* @__PURE__ */me(Ym,{onClick:()=>S(e),className:"text-destructive focus:text-destructive",children:[/* @__PURE__ */pe(Nt,{className:"mr-2 h-4 w-4"}),"Close"]}),!r&&(C||N)&&/* @__PURE__ */pe(Xm,{}),C&&!r&&/* @__PURE__ */me(Ym,{onClick:()=>C(e),children:[/* @__PURE__ */pe(vt,{className:"mr-2 h-4 w-4"}),"Split Right"]}),N&&!r&&/* @__PURE__ */me(Ym,{onClick:N,disabled:!T,children:[/* @__PURE__ */pe(ut,{className:"mr-2 h-4 w-4"}),"Reopen Last Closed"]})]})]},e)})]})});case"outline":/* @__PURE__ */return me("div",{className:"h-full overflow-hidden flex flex-col",children:[/* @__PURE__ */me("div",{className:"px-3 py-2 border-b border-sidebar-border shrink-0",children:[/* @__PURE__ */pe("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:"Outline"}),/* @__PURE__ */me("div",{className:"relative",children:[
237
237
  /* @__PURE__ */pe(ht,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground pointer-events-none"}),
238
- /* @__PURE__ */pe(uf,{value:R,onChange:e=>_(e.target.value),placeholder:"Filter headings & text…",className:"h-7 pl-7 pr-7 text-xs"}),R&&/* @__PURE__ */pe("button",{onClick:()=>_(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:/* @__PURE__ */pe(Nt,{className:"h-3 w-3"})})]})]}),/* @__PURE__ */pe("div",{className:"flex-1 overflow-auto",children:/* @__PURE__ */pe(nf,{ref:L,headings:q,onNavigate:T})})]});case"ai":/* @__PURE__ */return me("div",{className:"h-full overflow-hidden flex flex-col",children:[/* @__PURE__ */pe("div",{className:"px-3 py-2 border-b border-sidebar-border shrink-0",children:/* @__PURE__ */pe("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"AI Suggestions"})}),/* @__PURE__ */pe("div",{className:"flex-1 overflow-hidden",children:A?.isAiLoading?/* @__PURE__ */pe("div",{className:"h-full flex items-center justify-center p-6",children:/* @__PURE__ */me("div",{className:"text-center",children:[/* @__PURE__ */pe(Ze,{className:"h-8 w-8 animate-spin text-muted-foreground mx-auto mb-3"}),/* @__PURE__ */pe("p",{className:"text-sm text-muted-foreground",children:"Generating AI suggestion..."})]})}):A?.aiSuggestion?/* @__PURE__ */pe(df,{originalText:A.aiSuggestion.originalText,suggestedText:A.aiSuggestion.suggestedText,onApprove:()=>A.onAiApprove?.(),onReject:()=>A.onAiReject?.(),onRegenerate:e=>A.onAiRegenerate?.(e),currentMode:A.aiSuggestion.mode,isLoading:!1}):/* @__PURE__ */pe("div",{className:"h-full flex items-center justify-center p-6 text-center",children:/* @__PURE__ */pe("p",{className:"text-sm text-muted-foreground",children:"Select text and click the AI button to get suggestions"})})})]})}};return 0===e.length?/* @__PURE__ */pe("div",{className:"h-full flex items-center justify-center p-6 text-center",children:/* @__PURE__ */pe("p",{className:"text-sm text-muted-foreground",children:"No panels enabled"})}):1!==e.length&&t?/* @__PURE__ */pe("div",{className:"h-full",children:/* @__PURE__ */pe(Cf,{direction:"vertical",onResize:U,children:e.map((t,n)=>/* @__PURE__ */pe(pf,{size:j?.[n]||`${Math.round(100/e.length)}%`,minSize:"0px",children:W(t)},t))})}):/* @__PURE__ */pe("div",{className:"h-full",children:W(e[0])})},If="bg-white/10 dark:bg-black/20 backdrop-blur-md border-white/15 dark:border-white/10",Mf=({documents:e,activeId:t,activeDocument:n,onSelect:r,onAdd:a,onDelete:o,onDuplicate:i,onMove:s,onManageTags:l,onRename:c,onSearchFocus:d,isOpen:u,onOpenChange:h,isMobile:p,leftPanels:m,onLeftPanelsChange:f,leftSplit:g,onLeftSplitChange:v,rightPanels:y,onRightPanelsChange:b,rightSplit:x,onRightSplitChange:w,onSettingsClick:S,onRestore:k,newDocumentId:C,showDynamicIsland:N,onToggleDynamicIsland:T,activeFileSourceId:A="local-default",onFileSourceChange:I,headings:M=[],onNavigate:D,openTabs:E=[],activeTab:R,onTabChange:_,onTabClose:z,onTabRename:P,onSplitRight:O,onReopenLastClosed:L,canReopenLastClosed:F=!1,aiProps:B,tabItems:V,onNewChat:$})=>{const H=e.filter(e=>e.isDeleted),q=e.filter(e=>!e.isDeleted),[j,U]=le(0),G=ie(()=>{const e=new Map(q.map(e=>[e.id,e]));let t=0;for(const n of q){if(!n.isFolder)continue;let r=1,a=n.parentId;const o=/* @__PURE__ */new Set;for(;a&&e.has(a)&&!o.has(a);)o.add(a),r++,a=e.get(a)?.parentId??null;t=Math.max(t,r)}return t},[q]);te(()=>{U(e=>Math.min(e,G))},[G]);const[W,Y]=le(!0),K=se(null),X=se(null),[Z]=le(()=>Vl()),[J,Q]=le(()=>{const e=Vl();return e.find(e=>e.id===A)||e[0]||null}),[ee,ne]=le(!1);te(()=>{const e=Z.find(e=>e.id===A);e&&e.id!==J?.id&&Q(e)},[A,J?.id,Z]);const re=j>0&&j>=G,ae=0===j?G>1?"Expand Level 1":"Expand All":re?"Collapse All":`Expand Level ${j+1}`;te(()=>{if(C&&K.current){const e=setTimeout(()=>{const e=K.current;e&&"function"==typeof e.edit&&e.edit(C)},100);return()=>clearTimeout(e)}},[C]);const oe={leftPanels:m,leftSplit:g,onLeftPanelsChange:f,onLeftSplitChange:v,rightPanels:y,rightSplit:x,onRightPanelsChange:b,onRightSplitChange:w,activeId:t,onAdd:a,onSearchFocus:d,onFileManagerOpen:()=>ne(!0),sources:Z,activeSource:J,activeFileSourceId:A,onFileSourceChange:I,onSourceSelect:e=>{const t=Z.find(t=>t.id===e);t&&(Q(t),I?.(e))},allExpanded:re,expandToggleLabel:ae,outlineExpanded:W,onToggleAllExpanded:()=>{if(0===G)return;const e=j>=G?0:j+1;U(e),K.current&&(0===e?(K.current.cancelExpand?.(),K.current.collapseAll()):K.current.expandToLevel(e))},onToggleOutlineExpanded:()=>{const e=!W;Y(e),X.current&&(e?X.current.expandAll():X.current.collapseAll())},treeRef:K,outlineRef:X,deletedDocs:H,onRestore:k,onSettingsClick:S,showDynamicIsland:N,onToggleDynamicIsland:T,isMobile:p,openTabs:E,activeTab:R,onTabChange:_,onTabClose:z,documents:e,tabItems:V},ce={panels:m,split:g,persistenceKey:"left",activeDocuments:q,activeId:t,activeDocument:n,headings:M,isMobile:p,onSelect:r,onAdd:a,onDelete:o,onDuplicate:i,onMove:s,onManageTags:l,onRename:c,onOpenChange:h,treeRef:K,outlineRef:X,openTabs:E,activeTab:R,onTabChange:_,onTabClose:z,onTabRename:P,onSplitRight:O,onReopenLastClosed:L,canReopenLastClosed:F,onNavigate:D,aiProps:B,tabItems:V,onNewChat:$};return p?/* @__PURE__ */pe(Dl,{open:u,onOpenChange:h,children:/* @__PURE__ */pe(_l,{side:"left",className:Ml("w-80 p-0",If),children:/* @__PURE__ */me("aside",{className:"h-full flex flex-col",children:[
239
- /* @__PURE__ */pe(wp,{...oe}),
240
- /* @__PURE__ */pe("div",{className:"flex-1 min-h-0 overflow-hidden",children:/* @__PURE__ */pe(Af,{...ce})}),
241
- /* @__PURE__ */pe(Qh,{open:ee,onOpenChange:ne,documents:q,onSelectDocument:r})]})})}):/* @__PURE__ */me("aside",{className:Ml("h-screen w-full flex flex-col pt-14",If),children:[
242
- /* @__PURE__ */pe(wp,{...oe}),
243
- /* @__PURE__ */pe("div",{className:"flex-1 min-h-0 overflow-hidden",children:/* @__PURE__ */pe(Af,{...ce})}),
244
- /* @__PURE__ */pe(Qh,{open:ee,onOpenChange:ne,documents:q,onSelectDocument:r})]})},Df=({editor:e,theme:t,setTheme:n})=>{const[r,a]=le(!1);return s(),H(),te(()=>{$.setColor("default"),a(e?.isEditable??!0)},[]),te(()=>(e&&e.on("update",()=>{a(e.isEditable)}),()=>{e&&e.off("update",()=>{a(e.isEditable)})}),[e]),null},Ef=C(S());function Rf({className:e,...t}){/* @__PURE__ */
238
+ /* @__PURE__ */pe(uf,{value:_,onChange:e=>z(e.target.value),placeholder:"Filter headings & text…",className:"h-7 pl-7 pr-7 text-xs"}),_&&/* @__PURE__ */pe("button",{onClick:()=>z(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:/* @__PURE__ */pe(Nt,{className:"h-3 w-3"})})]})]}),/* @__PURE__ */pe("div",{className:"flex-1 overflow-auto",children:/* @__PURE__ */pe(nf,{ref:F,headings:j,onNavigate:A,editorRef:y})})]});case"ai":/* @__PURE__ */return me("div",{className:"h-full overflow-hidden flex flex-col",children:[/* @__PURE__ */pe("div",{className:"px-3 py-2 border-b border-sidebar-border shrink-0",children:/* @__PURE__ */pe("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"AI Suggestions"})}),/* @__PURE__ */pe("div",{className:"flex-1 overflow-hidden",children:I?.isAiLoading?/* @__PURE__ */pe("div",{className:"h-full flex items-center justify-center p-6",children:/* @__PURE__ */me("div",{className:"text-center",children:[/* @__PURE__ */pe(Ze,{className:"h-8 w-8 animate-spin text-muted-foreground mx-auto mb-3"}),/* @__PURE__ */pe("p",{className:"text-sm text-muted-foreground",children:"Generating AI suggestion..."})]})}):I?.aiSuggestion?/* @__PURE__ */pe(df,{originalText:I.aiSuggestion.originalText,suggestedText:I.aiSuggestion.suggestedText,onApprove:()=>I.onAiApprove?.(),onReject:()=>I.onAiReject?.(),onRegenerate:e=>I.onAiRegenerate?.(e),currentMode:I.aiSuggestion.mode,isLoading:!1}):/* @__PURE__ */pe("div",{className:"h-full flex items-center justify-center p-6 text-center",children:/* @__PURE__ */pe("p",{className:"text-sm text-muted-foreground",children:"Select text and click the AI button to get suggestions"})})})]})}};return 0===e.length?/* @__PURE__ */pe("div",{className:"h-full flex items-center justify-center p-6 text-center",children:/* @__PURE__ */pe("p",{className:"text-sm text-muted-foreground",children:"No panels enabled"})}):1!==e.length&&t?/* @__PURE__ */pe("div",{className:"h-full",children:/* @__PURE__ */pe(Cf,{direction:"vertical",onResize:G,children:e.map((t,n)=>/* @__PURE__ */pe(pf,{size:U?.[n]||`${Math.round(100/e.length)}%`,minSize:"0px",children:Y(t)},t))})}):/* @__PURE__ */pe("div",{className:"h-full",children:Y(e[0])})},If="bg-white/10 dark:bg-black/20 backdrop-blur-md border-white/15 dark:border-white/10",Mf=({documents:e,activeId:t,activeDocument:n,onSelect:r,onAdd:a,onDelete:o,onDuplicate:i,onMove:s,onManageTags:l,onRename:c,onSearchFocus:d,isOpen:u,onOpenChange:h,isMobile:p,leftPanels:m,onLeftPanelsChange:f,leftSplit:g,onLeftSplitChange:v,rightPanels:y,onRightPanelsChange:b,rightSplit:x,onRightSplitChange:w,onSettingsClick:S,onRestore:k,newDocumentId:C,showDynamicIsland:N,onToggleDynamicIsland:T,activeFileSourceId:A="local-default",onFileSourceChange:I,headings:M=[],onNavigate:D,editorRef:E,openTabs:R=[],activeTab:_,onTabChange:z,onTabClose:P,onTabRename:O,onSplitRight:L,onReopenLastClosed:F,canReopenLastClosed:B=!1,aiProps:V,tabItems:$,onNewChat:H})=>{const q=e.filter(e=>e.isDeleted),j=e.filter(e=>!e.isDeleted),[U,G]=le(0),W=ie(()=>{const e=new Map(j.map(e=>[e.id,e]));let t=0;for(const n of j){if(!n.isFolder)continue;let r=1,a=n.parentId;const o=/* @__PURE__ */new Set;for(;a&&e.has(a)&&!o.has(a);)o.add(a),r++,a=e.get(a)?.parentId??null;t=Math.max(t,r)}return t},[j]);te(()=>{G(e=>Math.min(e,W))},[W]);const[Y,K]=le(!0),X=se(null),Z=se(null),[J]=le(()=>Vl()),[Q,ee]=le(()=>{const e=Vl();return e.find(e=>e.id===A)||e[0]||null}),[ne,re]=le(!1);te(()=>{const e=J.find(e=>e.id===A);e&&e.id!==Q?.id&&ee(e)},[A,Q?.id,J]);const ae=U>0&&U>=W,oe=0===U?W>1?"Expand Level 1":"Expand All":ae?"Collapse All":`Expand Level ${U+1}`;te(()=>{if(C&&X.current){const e=setTimeout(()=>{const e=X.current;e&&"function"==typeof e.edit&&e.edit(C)},100);return()=>clearTimeout(e)}},[C]);const ce={leftPanels:m,leftSplit:g,onLeftPanelsChange:f,onLeftSplitChange:v,rightPanels:y,rightSplit:x,onRightPanelsChange:b,onRightSplitChange:w,activeId:t,onAdd:a,onSearchFocus:d,onFileManagerOpen:()=>re(!0),sources:J,activeSource:Q,activeFileSourceId:A,onFileSourceChange:I,onSourceSelect:e=>{const t=J.find(t=>t.id===e);t&&(ee(t),I?.(e))},allExpanded:ae,expandToggleLabel:oe,outlineExpanded:Y,onToggleAllExpanded:()=>{if(0===W)return;const e=U>=W?0:U+1;G(e),X.current&&(0===e?(X.current.cancelExpand?.(),X.current.collapseAll()):X.current.expandToLevel(e))},onToggleOutlineExpanded:()=>{const e=!Y;K(e),Z.current&&(e?Z.current.expandAll():Z.current.collapseAll())},treeRef:X,outlineRef:Z,deletedDocs:q,onRestore:k,onSettingsClick:S,showDynamicIsland:N,onToggleDynamicIsland:T,isMobile:p,openTabs:R,activeTab:_,onTabChange:z,onTabClose:P,documents:e,tabItems:$},de={panels:m,split:g,persistenceKey:"left",activeDocuments:j,activeId:t,activeDocument:n,headings:M,isMobile:p,onSelect:r,onAdd:a,onDelete:o,onDuplicate:i,onMove:s,onManageTags:l,onRename:c,onOpenChange:h,treeRef:X,outlineRef:Z,editorRef:E,openTabs:R,activeTab:_,onTabChange:z,onTabClose:P,onTabRename:O,onSplitRight:L,onReopenLastClosed:F,canReopenLastClosed:B,onNavigate:D,aiProps:V,tabItems:$,onNewChat:H};return p?/* @__PURE__ */pe(Dl,{open:u,onOpenChange:h,children:/* @__PURE__ */pe(_l,{side:"left",className:Ml("w-80 p-0",If),children:/* @__PURE__ */me("aside",{className:"h-full flex flex-col",children:[
239
+ /* @__PURE__ */pe(wp,{...ce}),
240
+ /* @__PURE__ */pe("div",{className:"flex-1 min-h-0 overflow-hidden",children:/* @__PURE__ */pe(Af,{...de})}),
241
+ /* @__PURE__ */pe(Qh,{open:ne,onOpenChange:re,documents:j,onSelectDocument:r})]})})}):/* @__PURE__ */me("aside",{className:Ml("h-screen w-full flex flex-col pt-14",If),children:[
242
+ /* @__PURE__ */pe(wp,{...ce}),
243
+ /* @__PURE__ */pe("div",{className:"flex-1 min-h-0 overflow-hidden",children:/* @__PURE__ */pe(Af,{...de})}),
244
+ /* @__PURE__ */pe(Qh,{open:ne,onOpenChange:re,documents:j,onSelectDocument:r})]})},Df=({editor:e,theme:t,setTheme:n})=>{const[r,a]=le(!1);return s(),H(),te(()=>{$.setColor("default"),a(e?.isEditable??!0)},[]),te(()=>(e&&e.on("update",()=>{a(e.isEditable)}),()=>{e&&e.off("update",()=>{a(e.isEditable)})}),[e]),null},Ef=C(S());function Rf({className:e,...t}){/* @__PURE__ */
245
245
  return pe(m,{"data-slot":"avatar",className:Ml("relative flex size-8 shrink-0 overflow-hidden rounded-full",e),...t})}function _f({className:e,...t}){/* @__PURE__ */
246
246
  return pe(g,{"data-slot":"avatar-image",className:Ml("aspect-square size-full",e),...t})}function zf({className:e,...t}){/* @__PURE__ */
247
247
  return pe(u,{"data-slot":"avatar-fallback",className:Ml("bg-muted flex size-full items-center justify-center rounded-full",e),...t})}function Pf({className:e,...t}){/* @__PURE__ */
@@ -261,7 +261,7 @@ return me("div",{className:"flex h-full w-full flex-col bg-editor-bg",children:[
261
261
  /* @__PURE__ */pe("h2",{className:"text-2xl font-serif font-semibold text-foreground mb-2",children:"No Note Selected"}),
262
262
  /* @__PURE__ */pe("p",{className:"text-muted-foreground",children:a?"Tap the menu to select a note":"Select a note from the sidebar or create a new one"})]})});if(n&&n!==r){const r=t.find(e=>e.id===n);/* @__PURE__ */
263
263
  return pe("div",{className:"flex-1 h-full",children:/* @__PURE__ */me(Cf,{direction:"horizontal",children:[/* @__PURE__ */pe(pf,{minSize:"300px",children:/* @__PURE__ */pe("div",{className:"flex flex-col h-full border-r border-border",children:/* @__PURE__ */pe("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */pe(uw,{ref:o,contentKey:e.id,content:e.content,onChange:t=>i(e.id,{content:t}),title:e.title,onTitleChange:t=>i(e.id,{title:t}),scrollToHeading:()=>{},onHeadingsChange:s,aiSuggestion:c,isAiLoading:d,onAiRewrite:u,onAiApprove:h,onAiReject:p,onAiRegenerate:m,onInviteClick:f,onShareClick:g,documentId:e.id})})})}),/* @__PURE__ */pe(pf,{minSize:"300px",children:/* @__PURE__ */pe("div",{className:"flex flex-col h-full",children:r?/* @__PURE__ */me(he,{children:[/* @__PURE__ */me("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-muted/30",children:[/* @__PURE__ */pe("span",{className:"text-sm font-medium",children:r.title}),/* @__PURE__ */pe(tp,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:l,title:"Close split view",children:/* @__PURE__ */pe(Nt,{className:"h-3 w-3"})})]}),/* @__PURE__ */pe("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */pe(uw,{content:r.content,onChange:e=>i(r.id,{content:e}),title:r.title,onTitleChange:e=>i(r.id,{title:e}),scrollToHeading:()=>{},onInviteClick:f,onShareClick:g,documentId:r.id})})]}):null})})]})})}/* @__PURE__ */
264
- return pe("div",{className:"h-full flex flex-col",children:/* @__PURE__ */pe(uw,{ref:o,contentKey:e.id,content:e.content,onChange:t=>i(e.id,{content:t}),title:e.title,onTitleChange:t=>i(e.id,{title:t}),scrollToHeading:()=>{},onHeadingsChange:s,aiSuggestion:c,isAiLoading:d,onAiRewrite:u,onAiApprove:h,onAiReject:p,onAiRegenerate:m,onInviteClick:f,onShareClick:g,documentId:e.id})})}uw.displayName="TiptapEditorWrapper";var pw="bg-white/10 dark:bg-black/20 backdrop-blur-md border-white/15 dark:border-white/10",mw={top:!1,right:!1,bottom:!1,left:!0,topRight:!1,bottomRight:!1,bottomLeft:!1,topLeft:!1},fw=Object.fromEntries(fp.map(({type:e,label:t})=>[e,t]));function gw({panels:e,split:t,documents:n,activeId:r,activeDocument:a,onSelect:o,onAdd:i,onDelete:s,onDuplicate:l,onMove:c,onManageTags:d,onRename:u,headings:h,onNavigate:p,openTabs:m,activeTab:f,onTabChange:g,onTabClose:v,onTabRename:y,onSplitRight:b,onReopenLastClosed:x,canReopenLastClosed:w,outlineRef:S,tabItems:k,onNewChat:C,aiProps:N,onClose:T,isMobile:A,isOpen:I,onOpenChange:M}){const[D,E]=le(320),R=1===e.length?fw[e[0]]:"Right Panel",_=/* @__PURE__ */me("div",{className:"h-full overflow-hidden flex flex-col",children:[/* @__PURE__ */me("div",{className:"px-3 py-2 border-b border-sidebar-border/60 flex items-center justify-between select-none shrink-0",children:[/* @__PURE__ */pe("h3",{className:"text-sm font-semibold text-sidebar-foreground",children:R}),/* @__PURE__ */pe(tp,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:T,children:/* @__PURE__ */pe(Nt,{className:"h-4 w-4"})})]}),/* @__PURE__ */pe("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */pe(Af,{panels:e,split:t,persistenceKey:"right",activeDocuments:n,activeId:r,activeDocument:a,headings:h,onSelect:o,onAdd:i,onDelete:s,onDuplicate:l,onMove:c,onManageTags:d,onRename:u,outlineRef:S,openTabs:m,activeTab:f,onTabChange:g,onTabClose:v,onTabRename:y,onSplitRight:b,onReopenLastClosed:x,canReopenLastClosed:w,onNavigate:p,tabItems:k,onNewChat:C,aiProps:N})})]});return A?/* @__PURE__ */pe(Dl,{open:I,onOpenChange:M,children:/* @__PURE__ */pe(_l,{side:"right",className:Ml("w-80 p-0",pw),children:/* @__PURE__ */pe("aside",{className:"h-full flex flex-col",children:_})})}):/* @__PURE__ */pe(Vt,{size:{width:D,height:"100%"},onResizeStop:(e,t,n)=>E(n.offsetWidth),minWidth:260,maxWidth:640,enable:mw,className:Ml("h-full flex flex-col border-l shrink-0",pw),children:_})}function vw({className:e,children:t,...n}){/* @__PURE__ */
264
+ return pe("div",{className:"h-full flex flex-col",children:/* @__PURE__ */pe(uw,{ref:o,contentKey:e.id,content:e.content,onChange:t=>i(e.id,{content:t}),title:e.title,onTitleChange:t=>i(e.id,{title:t}),scrollToHeading:()=>{},onHeadingsChange:s,aiSuggestion:c,isAiLoading:d,onAiRewrite:u,onAiApprove:h,onAiReject:p,onAiRegenerate:m,onInviteClick:f,onShareClick:g,documentId:e.id})})}uw.displayName="TiptapEditorWrapper";var pw="bg-white/10 dark:bg-black/20 backdrop-blur-md border-white/15 dark:border-white/10",mw={top:!1,right:!1,bottom:!1,left:!0,topRight:!1,bottomRight:!1,bottomLeft:!1,topLeft:!1},fw=Object.fromEntries(fp.map(({type:e,label:t})=>[e,t]));function gw({panels:e,split:t,documents:n,activeId:r,activeDocument:a,onSelect:o,onAdd:i,onDelete:s,onDuplicate:l,onMove:c,onManageTags:d,onRename:u,headings:h,onNavigate:p,openTabs:m,activeTab:f,onTabChange:g,onTabClose:v,onTabRename:y,onSplitRight:b,onReopenLastClosed:x,canReopenLastClosed:w,outlineRef:S,editorRef:k,tabItems:C,onNewChat:N,aiProps:T,onClose:A,isMobile:I,isOpen:M,onOpenChange:D}){const[E,R]=le(320),_=1===e.length?fw[e[0]]:"Right Panel",z=/* @__PURE__ */me("div",{className:"h-full overflow-hidden flex flex-col",children:[/* @__PURE__ */me("div",{className:"px-3 py-2 border-b border-sidebar-border/60 flex items-center justify-between select-none shrink-0",children:[/* @__PURE__ */pe("h3",{className:"text-sm font-semibold text-sidebar-foreground",children:_}),/* @__PURE__ */pe(tp,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:A,children:/* @__PURE__ */pe(Nt,{className:"h-4 w-4"})})]}),/* @__PURE__ */pe("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */pe(Af,{panels:e,split:t,persistenceKey:"right",activeDocuments:n,activeId:r,activeDocument:a,headings:h,onSelect:o,onAdd:i,onDelete:s,onDuplicate:l,onMove:c,onManageTags:d,onRename:u,outlineRef:S,editorRef:k,openTabs:m,activeTab:f,onTabChange:g,onTabClose:v,onTabRename:y,onSplitRight:b,onReopenLastClosed:x,canReopenLastClosed:w,onNavigate:p,tabItems:C,onNewChat:N,aiProps:T})})]});return I?/* @__PURE__ */pe(Dl,{open:M,onOpenChange:D,children:/* @__PURE__ */pe(_l,{side:"right",className:Ml("w-80 p-0",pw),children:/* @__PURE__ */pe("aside",{className:"h-full flex flex-col",children:z})})}):/* @__PURE__ */pe(Vt,{size:{width:E,height:"100%"},onResizeStop:(e,t,n)=>R(n.offsetWidth),minWidth:260,maxWidth:640,enable:mw,className:Ml("h-full flex flex-col border-l shrink-0",pw),children:z})}function vw({className:e,children:t,...n}){/* @__PURE__ */
265
265
  return me(Tl,{"data-slot":"scroll-area",className:Ml("relative",e),...n,children:[
266
266
  /* @__PURE__ */pe(Al,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1 [&>div]:!block",children:t}),
267
267
  /* @__PURE__ */pe(yw,{}),
@@ -446,7 +446,7 @@ return me(he,{children:[/* @__PURE__ */pe(rD,{children:s&&/* @__PURE__ */pe(CE.d
446
446
  /* @__PURE__ */pe("div",{className:"h-2 w-2 shrink-0 rounded-full bg-foreground"}),
447
447
  /* @__PURE__ */pe("div",{className:"relative flex h-full flex-1 items-center overflow-hidden text-left",children:/* @__PURE__ */pe(rD,{mode:"popLayout",initial:!1,children:/* @__PURE__ */pe(CE.span,{initial:{opacity:0,y:15},animate:{opacity:1,y:0},exit:{opacity:0,y:-15},transition:{duration:.35,ease:[.16,1,.3,1]},className:"block w-full overflow-hidden text-ellipsis whitespace-nowrap text-sm font-medium text-foreground",children:f},r??"empty")})}),
448
448
  /* @__PURE__ */pe(TE,{percentage:c})]}),/* @__PURE__ */me(CE.div,{initial:!1,animate:{opacity:s?1:0,scale:s?1:1.05},transition:{...NE,delay:s?.1:0},className:Ml("absolute inset-0 flex flex-col",!s&&"pointer-events-none"),children:[/* @__PURE__ */me("div",{className:"flex shrink-0 items-center justify-between px-6 pb-3 pt-5",children:[/* @__PURE__ */pe("span",{className:"text-[11px] font-semibold tracking-[0.08em] text-muted-foreground",children:"TABLE OF CONTENTS"}),/* @__PURE__ */pe("button",{onClick:e=>{e.stopPropagation(),l(!1)},className:"text-muted-foreground transition-colors hover:text-foreground",children:/* @__PURE__ */pe(Nt,{className:"h-5 w-5"})})]}),/* @__PURE__ */pe("div",{className:"flex-1 overflow-y-auto px-3 pb-4",children:/* @__PURE__ */pe("div",{className:"flex flex-col gap-0.5",children:e.map(([e,n,a])=>{const s=parseInt(a[1],10),c=r===e,d=o===e,u=14*Math.max(0,s-m)+12;/* @__PURE__ */
449
- return me("button",{onMouseEnter:()=>i(e),onMouseLeave:()=>i(null),onClick:n=>{n.stopPropagation(),t(e),l(!1)},style:{paddingLeft:`${u}px`},className:Ml("group flex w-full shrink-0 cursor-pointer items-center rounded-lg border-none py-2 pr-3 text-left text-sm transition-all duration-300 ease-out",c&&"bg-foreground/10 font-medium text-foreground",!c&&d&&"bg-foreground/5 text-foreground/85",!c&&!d&&"bg-transparent text-foreground/45"),children:[/* @__PURE__ */pe("span",{className:"flex-1 overflow-hidden text-ellipsis whitespace-nowrap transition-transform duration-300 group-hover:translate-x-1",children:n}),/* @__PURE__ */pe(CE.div,{initial:!1,animate:{scale:c?1:0,opacity:c?1:0},transition:{duration:.3,ease:"easeOut"},className:"ml-3 h-1.5 w-1.5 shrink-0 rounded-full bg-foreground"})]},e)})})})]})]})})]})}var IE=({mainContent:e,belowMainContent:t,openFilesSidebarSignal:n,extraTabs:r,activeExtraTabId:a,onExtraTabSelect:o,onExtraTabClose:i,onExtraTabAdd:s,onFileTabSelect:l,initialDocId:c,onActiveDocumentChange:d})=>{const{theme:u,setTheme:h}=Gw(),p=OS(n),[m,f]=le(void 0),g=se(!1);te(()=>{!g.current&&c&&p.documents.some(e=>e.id===c)&&(g.current=!0,c!==p.activeDocId&&p.handleSelectDocument(c))},[c,p.documents,p.activeDocId,p.handleSelectDocument]),te(()=>{d?.(p.activeDocId)},[p.activeDocId,d]);const[v,y]=Nf({key:"reason-docs-sidebar",storage:Tf}),b=ie(()=>{const e=p.openTabs.map(e=>({id:e,title:p.documents.find(t=>t.id===e)?.title||"Untitled",kind:"file"})),t=(r??[]).map(e=>({id:e.id,title:e.title,kind:e.kind}));return[...e,...t]},[p.openTabs,p.documents,r]),x=a??p.activeDocId,w=e=>{r?.some(t=>t.id===e)?o?.(e):(p.handleTabChange(e),l?.())},S=e=>{r?.some(t=>t.id===e)?i?.(e):p.handleTabClose(e)},k=(e,t)=>{p.handleAddDocument(e,t),t||l?.()},C=e=>{p.handleSelectDocument(e),l?.()},N={documents:p.documents,activeId:p.activeDocId,activeDocument:p.activeDocument,onSelect:C,onAdd:k,onDelete:p.handleDeleteDocument,onDuplicate:p.handleDuplicateDocument,onToggleExpand:p.handleToggleExpand,onMove:p.handleMoveDocument,onManageTags:p.handleManageTags,onRename:(e,t)=>p.handleUpdateDocument(e,{title:t}),searchQuery:p.searchQuery,onSearchChange:p.setSearchQuery,onSearchClear:()=>p.setSearchQuery(""),onSearchFocus:()=>p.setIsSearchModalOpen(!0),isOpen:p.isSidebarOpen,onOpenChange:p.setIsSidebarOpen,isMobile:p.isMobile,leftPanels:p.leftPanels,onLeftPanelsChange:p.setLeftPanels,leftSplit:p.leftSplit,onLeftSplitChange:p.setLeftSplit,rightPanels:p.rightPanels,onRightPanelsChange:p.setRightPanels,rightSplit:p.rightSplit,onRightSplitChange:p.setRightSplit,onSettingsClick:e=>{f(e),p.setIsSettingsOpen(!0)},onInviteClick:()=>p.setIsInviteModalOpen(!0),onRestore:p.handleRestoreDocument,onPermanentDelete:p.handlePermanentDelete,newDocumentId:p.newDocumentId,showDynamicIsland:p.showDynamicIsland,onToggleDynamicIsland:()=>p.setShowDynamicIsland(!p.showDynamicIsland),activeFileSourceId:p.activeFileSourceId,onFileSourceChange:p.handleFileSourceChange,onNavigate:e=>p.editorRef.current?.scrollToHeading(e),openTabs:p.openTabs,activeTab:x,onTabChange:w,onTabClose:S,onTabRename:(e,t)=>p.handleUpdateDocument(e,{title:t}),onSplitRight:p.handleSplitRight,onReopenLastClosed:p.handleReopenLastClosed,canReopenLastClosed:p.closedTabsHistory.length>0,tabItems:b,onNewChat:s,aiProps:{isAiLoading:p.isAiLoading,aiSuggestion:p.aiSuggestion,onAiApprove:p.handleAIApprove,onAiReject:p.handleAIReject,onAiRegenerate:p.handleAIRegenerate}},T={activeDocument:p.activeDocument,documents:p.documents,splitViewDocId:p.splitViewDocId,activeDocId:p.activeDocId,isMobile:p.isMobile,editorRef:p.editorRef,onUpdateDocument:p.handleUpdateDocument,onHeadingsChange:p.setHeadings,onCloseSplitView:()=>p.setSplitViewDocId(null),aiSuggestion:p.aiSuggestion,isAiLoading:p.isAiLoading,onAiRewrite:p.handleAIRewrite,onAiApprove:p.handleAIApprove,onAiReject:p.handleAIReject,onAiRegenerate:p.handleAIRegenerate,onInviteClick:()=>p.setIsInviteModalOpen(!0),onShareClick:()=>p.setIsInviteModalOpen(!0)},A=p.rightPanels.length>0&&/* @__PURE__ */pe(gw,{panels:p.rightPanels,split:p.rightSplit,documents:p.documents,activeId:p.activeDocId,activeDocument:p.activeDocument,onSelect:C,onAdd:k,onDelete:p.handleDeleteDocument,onDuplicate:p.handleDuplicateDocument,onMove:p.handleMoveDocument,onManageTags:p.handleManageTags,onRename:(e,t)=>p.handleUpdateDocument(e,{title:t}),headings:p.headings,onNavigate:e=>p.editorRef.current?.scrollToHeading(e),openTabs:p.openTabs,activeTab:x,onTabChange:w,onTabClose:S,onTabRename:(e,t)=>p.handleUpdateDocument(e,{title:t}),onSplitRight:p.handleSplitRight,onReopenLastClosed:p.handleReopenLastClosed,canReopenLastClosed:p.closedTabsHistory.length>0,tabItems:b,onNewChat:s,aiProps:{isAiLoading:p.isAiLoading,aiSuggestion:p.aiSuggestion,onAiApprove:p.handleAIApprove,onAiReject:p.handleAIReject,onAiRegenerate:p.handleAIRegenerate},onClose:()=>p.setRightPanels([]),isMobile:p.isMobile,isOpen:p.isRightSidebarOpen,onOpenChange:p.setIsRightSidebarOpen});/* @__PURE__ */
449
+ return me("button",{onMouseEnter:()=>i(e),onMouseLeave:()=>i(null),onClick:n=>{n.stopPropagation(),t(e),l(!1)},style:{paddingLeft:`${u}px`},className:Ml("group flex w-full shrink-0 cursor-pointer items-center rounded-lg border-none py-2 pr-3 text-left text-sm transition-all duration-300 ease-out",c&&"bg-foreground/10 font-medium text-foreground",!c&&d&&"bg-foreground/5 text-foreground/85",!c&&!d&&"bg-transparent text-foreground/45"),children:[/* @__PURE__ */pe("span",{className:"flex-1 overflow-hidden text-ellipsis whitespace-nowrap transition-transform duration-300 group-hover:translate-x-1",children:n}),/* @__PURE__ */pe(CE.div,{initial:!1,animate:{scale:c?1:0,opacity:c?1:0},transition:{duration:.3,ease:"easeOut"},className:"ml-3 h-1.5 w-1.5 shrink-0 rounded-full bg-foreground"})]},e)})})})]})]})})]})}var IE=({mainContent:e,belowMainContent:t,openFilesSidebarSignal:n,extraTabs:r,activeExtraTabId:a,onExtraTabSelect:o,onExtraTabClose:i,onExtraTabAdd:s,onFileTabSelect:l,initialDocId:c,onActiveDocumentChange:d})=>{const{theme:u,setTheme:h}=Gw(),p=OS(n),[m,f]=le(void 0),g=se(!1);te(()=>{!g.current&&c&&p.documents.some(e=>e.id===c)&&(g.current=!0,c!==p.activeDocId&&p.handleSelectDocument(c))},[c,p.documents,p.activeDocId,p.handleSelectDocument]),te(()=>{d?.(p.activeDocId)},[p.activeDocId,d]);const[v,y]=Nf({key:"reason-docs-sidebar",storage:Tf}),b=ie(()=>{const e=p.openTabs.map(e=>({id:e,title:p.documents.find(t=>t.id===e)?.title||"Untitled",kind:"file"})),t=(r??[]).map(e=>({id:e.id,title:e.title,kind:e.kind}));return[...e,...t]},[p.openTabs,p.documents,r]),x=a??p.activeDocId,w=e=>{r?.some(t=>t.id===e)?o?.(e):(p.handleTabChange(e),l?.())},S=e=>{r?.some(t=>t.id===e)?i?.(e):p.handleTabClose(e)},k=(e,t)=>{p.handleAddDocument(e,t),t||l?.()},C=e=>{p.handleSelectDocument(e),l?.()},N={documents:p.documents,activeId:p.activeDocId,activeDocument:p.activeDocument,onSelect:C,onAdd:k,onDelete:p.handleDeleteDocument,onDuplicate:p.handleDuplicateDocument,onToggleExpand:p.handleToggleExpand,onMove:p.handleMoveDocument,onManageTags:p.handleManageTags,onRename:(e,t)=>p.handleUpdateDocument(e,{title:t}),searchQuery:p.searchQuery,onSearchChange:p.setSearchQuery,onSearchClear:()=>p.setSearchQuery(""),onSearchFocus:()=>p.setIsSearchModalOpen(!0),isOpen:p.isSidebarOpen,onOpenChange:p.setIsSidebarOpen,isMobile:p.isMobile,leftPanels:p.leftPanels,onLeftPanelsChange:p.setLeftPanels,leftSplit:p.leftSplit,onLeftSplitChange:p.setLeftSplit,rightPanels:p.rightPanels,onRightPanelsChange:p.setRightPanels,rightSplit:p.rightSplit,onRightSplitChange:p.setRightSplit,onSettingsClick:e=>{f(e),p.setIsSettingsOpen(!0)},onInviteClick:()=>p.setIsInviteModalOpen(!0),onRestore:p.handleRestoreDocument,onPermanentDelete:p.handlePermanentDelete,newDocumentId:p.newDocumentId,showDynamicIsland:p.showDynamicIsland,onToggleDynamicIsland:()=>p.setShowDynamicIsland(!p.showDynamicIsland),activeFileSourceId:p.activeFileSourceId,onFileSourceChange:p.handleFileSourceChange,onNavigate:e=>p.editorRef.current?.scrollToHeading(e),editorRef:p.editorRef,openTabs:p.openTabs,activeTab:x,onTabChange:w,onTabClose:S,onTabRename:(e,t)=>p.handleUpdateDocument(e,{title:t}),onSplitRight:p.handleSplitRight,onReopenLastClosed:p.handleReopenLastClosed,canReopenLastClosed:p.closedTabsHistory.length>0,tabItems:b,onNewChat:s,aiProps:{isAiLoading:p.isAiLoading,aiSuggestion:p.aiSuggestion,onAiApprove:p.handleAIApprove,onAiReject:p.handleAIReject,onAiRegenerate:p.handleAIRegenerate}},T={activeDocument:p.activeDocument,documents:p.documents,splitViewDocId:p.splitViewDocId,activeDocId:p.activeDocId,isMobile:p.isMobile,editorRef:p.editorRef,onUpdateDocument:p.handleUpdateDocument,onHeadingsChange:p.setHeadings,onCloseSplitView:()=>p.setSplitViewDocId(null),aiSuggestion:p.aiSuggestion,isAiLoading:p.isAiLoading,onAiRewrite:p.handleAIRewrite,onAiApprove:p.handleAIApprove,onAiReject:p.handleAIReject,onAiRegenerate:p.handleAIRegenerate,onInviteClick:()=>p.setIsInviteModalOpen(!0),onShareClick:()=>p.setIsInviteModalOpen(!0)},A=p.rightPanels.length>0&&/* @__PURE__ */pe(gw,{panels:p.rightPanels,split:p.rightSplit,documents:p.documents,activeId:p.activeDocId,activeDocument:p.activeDocument,onSelect:C,onAdd:k,onDelete:p.handleDeleteDocument,onDuplicate:p.handleDuplicateDocument,onMove:p.handleMoveDocument,onManageTags:p.handleManageTags,onRename:(e,t)=>p.handleUpdateDocument(e,{title:t}),headings:p.headings,onNavigate:e=>p.editorRef.current?.scrollToHeading(e),editorRef:p.editorRef,openTabs:p.openTabs,activeTab:x,onTabChange:w,onTabClose:S,onTabRename:(e,t)=>p.handleUpdateDocument(e,{title:t}),onSplitRight:p.handleSplitRight,onReopenLastClosed:p.handleReopenLastClosed,canReopenLastClosed:p.closedTabsHistory.length>0,tabItems:b,onNewChat:s,aiProps:{isAiLoading:p.isAiLoading,aiSuggestion:p.aiSuggestion,onAiApprove:p.handleAIApprove,onAiReject:p.handleAIReject,onAiRegenerate:p.handleAIRegenerate},onClose:()=>p.setRightPanels([]),isMobile:p.isMobile,isOpen:p.isRightSidebarOpen,onOpenChange:p.setIsRightSidebarOpen});/* @__PURE__ */
450
450
  return me("div",{className:"h-screen w-screen flex flex-col overflow-hidden",children:[p.isMobile?/* @__PURE__ */me("div",{className:"flex-1 flex flex-col overflow-hidden",children:[/* @__PURE__ */me("div",{className:"flex items-center justify-between h-10 px-1 border-b border-sidebar-border/60 shrink-0",children:[/* @__PURE__ */pe(tp,{variant:"ghost",size:"sm",className:"size-8 p-0",onClick:()=>p.setIsSidebarOpen(!0),"aria-label":"Open sidebar",children:/* @__PURE__ */pe(tt,{className:"h-5 w-5"})}),p.rightPanels.length>0&&/* @__PURE__ */pe(tp,{variant:"ghost",size:"sm",className:"size-8 p-0",onClick:()=>p.setIsRightSidebarOpen(!0),"aria-label":"Open right panel",children:/* @__PURE__ */pe(lt,{className:"h-5 w-5"})})]}),/* @__PURE__ */me("div",{className:"flex-1 flex overflow-hidden",children:[
451
451
  /* @__PURE__ */pe(Mf,{...N,headings:p.headings}),
452
452
  /* @__PURE__ */me("main",{className:"flex-1 overflow-hidden flex flex-col",children:[/* @__PURE__ */pe("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:e??/* @__PURE__ */pe(hw,{...T})}),t&&/* @__PURE__ */pe("div",{className:"shrink-0 px-2 pt-1 pb-[60px] sm:pb-2 sm:pr-56",children:t})]}),A]})]}):/* @__PURE__ */pe("div",{className:"flex-1 overflow-hidden",children:/* @__PURE__ */me(Cf,{direction:"horizontal",onResize:y,children:[/* @__PURE__ */pe(pf,{size:v?.[0]||"250px",minSize:"0px",maxSize:"600px",children:/* @__PURE__ */pe("div",{className:"overflow-y-auto overflow-x-hidden bg-background",children:/* @__PURE__ */pe(Mf,{...N,headings:p.headings})})}),/* @__PURE__ */pe(pf,{children:/* @__PURE__ */me("div",{className:"h-screen flex flex-col bg-background",children:[/* @__PURE__ */me("div",{className:"flex-1 flex min-h-0",children:[/* @__PURE__ */pe("div",{className:"flex-1 min-h-0 overflow-auto",children:e??/* @__PURE__ */pe(hw,{...T})}),A]}),t&&/* @__PURE__ */pe("div",{className:"shrink-0 px-2 pb-2",children:t})]})})]})}),p.headings.length>0&&0===p.rightPanels.length&&p.showDynamicIsland&&/* @__PURE__ */pe(AE,{headings:p.headings,onNavigate:e=>p.editorRef.current?.scrollToHeading(e),editorRef:p.editorRef}),
@@ -1,6 +1,7 @@
1
1
  import { RefObject } from 'react';
2
2
  import { SidebarPanelType, SidebarAiProps, OpenTabItem } from '../layout/sidebar/types';
3
3
  import { OutlineViewHandle } from '../search/OutlineView';
4
+ import { ActiveHeadingEditorHandle } from '../search/useActiveHeading';
4
5
  import { TocEntry } from '../app-types/toc';
5
6
  import { Document } from '../documents/DocumentTree';
6
7
  /** Props for the {@link RightPanel} component. */
@@ -30,6 +31,7 @@ interface RightPanelProps {
30
31
  onReopenLastClosed?: () => void;
31
32
  canReopenLastClosed?: boolean;
32
33
  outlineRef?: RefObject<OutlineViewHandle | null>;
34
+ editorRef?: RefObject<ActiveHeadingEditorHandle | null>;
33
35
  tabItems?: OpenTabItem[];
34
36
  onNewChat?: () => void;
35
37
  aiProps: SidebarAiProps;
@@ -47,5 +49,5 @@ interface RightPanelProps {
47
49
  * by dragging its left edge; its body renders whichever panels are enabled
48
50
  * for the right sidebar.
49
51
  */
50
- export declare function RightPanel({ panels, split, documents, activeId, activeDocument, onSelect, onAdd, onDelete, onDuplicate, onMove, onManageTags, onRename, headings, onNavigate, openTabs, activeTab, onTabChange, onTabClose, onTabRename, onSplitRight, onReopenLastClosed, canReopenLastClosed, outlineRef, tabItems, onNewChat, aiProps, onClose, isMobile, isOpen, onOpenChange, }: RightPanelProps): import("react").JSX.Element;
52
+ export declare function RightPanel({ panels, split, documents, activeId, activeDocument, onSelect, onAdd, onDelete, onDuplicate, onMove, onManageTags, onRename, headings, onNavigate, openTabs, activeTab, onTabChange, onTabClose, onTabRename, onSplitRight, onReopenLastClosed, canReopenLastClosed, outlineRef, editorRef, tabItems, onNewChat, aiProps, onClose, isMobile, isOpen, onOpenChange, }: RightPanelProps): import("react").JSX.Element;
51
53
  export {};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const e=require("./editorConfig-Cx4ilZJV.cjs"),o=require("./ReasonDocs-C1t3Tdl5.cjs"),r=require("./RichTextProvider-CSKrKcEv.cjs"),t=require("./externalLibsMode-Dm8a-Jd9.cjs");exports.NovelEditor=e.NovelEditor,exports.ReasonDocs=o.Index,exports.RichTextProvider=r.RichTextProvider,exports.externalLibsModeActions=t.externalLibsModeActions,exports.getExternalLibsMode=t.getExternalLibsMode,exports.useExternalLibsMode=t.useExternalLibsMode,exports.useNovelEditor=e.useNovelEditor;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const e=require("./editorConfig-Cx4ilZJV.cjs"),o=require("./ReasonDocs-BsqLLRX5.cjs"),r=require("./RichTextProvider-CSKrKcEv.cjs"),t=require("./externalLibsMode-Dm8a-Jd9.cjs");exports.NovelEditor=e.NovelEditor,exports.ReasonDocs=o.Index,exports.RichTextProvider=r.RichTextProvider,exports.externalLibsModeActions=t.externalLibsModeActions,exports.getExternalLibsMode=t.getExternalLibsMode,exports.useExternalLibsMode=t.useExternalLibsMode,exports.useNovelEditor=e.useNovelEditor;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as o,i as s}from"./editorConfig-BDVG1hyU.js";import{t as r}from"./ReasonDocs-BkV43EyN.js";import{t as a}from"./RichTextProvider-CHcaIPMd.js";import{n as t,r as i,t as e}from"./externalLibsMode-DEDBnK98.js";export{s as NovelEditor,r as ReasonDocs,a as RichTextProvider,e as externalLibsModeActions,t as getExternalLibsMode,i as useExternalLibsMode,o as useNovelEditor};
1
+ import{a as o,i as s}from"./editorConfig-BDVG1hyU.js";import{t as r}from"./ReasonDocs-CK-Glhub.js";import{t as a}from"./RichTextProvider-CHcaIPMd.js";import{n as t,r as i,t as e}from"./externalLibsMode-DEDBnK98.js";export{s as NovelEditor,r as ReasonDocs,a as RichTextProvider,e as externalLibsModeActions,t as getExternalLibsMode,i as useExternalLibsMode,o as useNovelEditor};
@@ -1,2 +1,2 @@
1
1
  import { SidebarProps } from './types';
2
- export declare const Sidebar: ({ documents, activeId, activeDocument, onSelect, onAdd, onDelete, onDuplicate, onMove, onManageTags, onRename, onSearchFocus, isOpen, onOpenChange, isMobile, leftPanels, onLeftPanelsChange, leftSplit, onLeftSplitChange, rightPanels, onRightPanelsChange, rightSplit, onRightSplitChange, onSettingsClick, onRestore, newDocumentId, showDynamicIsland, onToggleDynamicIsland, activeFileSourceId, onFileSourceChange, headings, onNavigate, openTabs, activeTab, onTabChange, onTabClose, onTabRename, onSplitRight, onReopenLastClosed, canReopenLastClosed, aiProps, tabItems, onNewChat, }: SidebarProps) => import("react").JSX.Element;
2
+ export declare const Sidebar: ({ documents, activeId, activeDocument, onSelect, onAdd, onDelete, onDuplicate, onMove, onManageTags, onRename, onSearchFocus, isOpen, onOpenChange, isMobile, leftPanels, onLeftPanelsChange, leftSplit, onLeftSplitChange, rightPanels, onRightPanelsChange, rightSplit, onRightSplitChange, onSettingsClick, onRestore, newDocumentId, showDynamicIsland, onToggleDynamicIsland, activeFileSourceId, onFileSourceChange, headings, onNavigate, editorRef, openTabs, activeTab, onTabChange, onTabClose, onTabRename, onSplitRight, onReopenLastClosed, canReopenLastClosed, aiProps, tabItems, onNewChat, }: SidebarProps) => import("react").JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import { RefObject } from 'react';
2
2
  import { OutlineViewHandle } from '../../search/OutlineView';
3
+ import { ActiveHeadingEditorHandle } from '../../search/useActiveHeading';
3
4
  import { Document } from '../../documents/DocumentTree';
4
5
  import { SidebarPanelType, SidebarAiProps, OpenTabItem } from './types';
5
6
  import { TocEntry } from '../../app-types/toc';
@@ -48,6 +49,8 @@ interface SidebarContentProps {
48
49
  treeRef?: RefObject<DocumentTreeHandle | null>;
49
50
  /** Ref forwarded to the `OutlineView` component for imperative control. */
50
51
  outlineRef?: RefObject<OutlineViewHandle | null>;
52
+ /** Editor handle passed to `OutlineView` to scroll-spy the active heading. */
53
+ editorRef?: RefObject<ActiveHeadingEditorHandle | null>;
51
54
  /** Currently open tab IDs shown in the top pane. */
52
55
  openTabs?: string[];
53
56
  /** ID of the currently active tab. */
@@ -77,5 +80,5 @@ interface SidebarContentProps {
77
80
  * Renders the enabled panels for one side of the layout, stacked in a
78
81
  * resizable vertical split when more than one panel is active.
79
82
  */
80
- export declare const SidebarContent: ({ panels, split, persistenceKey, activeDocuments, activeId, activeDocument, headings, isMobile, onSelect, onAdd, onDelete, onDuplicate, onMove, onManageTags, onRename, onOpenChange, treeRef, outlineRef, openTabs, activeTab, onTabChange, onTabClose, onTabRename, onSplitRight, onReopenLastClosed, canReopenLastClosed, onNavigate, aiProps, tabItems, onNewChat, }: SidebarContentProps) => import("react").JSX.Element;
83
+ export declare const SidebarContent: ({ panels, split, persistenceKey, activeDocuments, activeId, activeDocument, headings, isMobile, onSelect, onAdd, onDelete, onDuplicate, onMove, onManageTags, onRename, onOpenChange, treeRef, outlineRef, editorRef, openTabs, activeTab, onTabChange, onTabClose, onTabRename, onSplitRight, onReopenLastClosed, canReopenLastClosed, onNavigate, aiProps, tabItems, onNewChat, }: SidebarContentProps) => import("react").JSX.Element;
81
84
  export {};
@@ -1,5 +1,7 @@
1
+ import { RefObject } from 'react';
1
2
  import { Document } from '../../documents/DocumentTree';
2
3
  import { TocEntry } from '../../app-types/toc';
4
+ import { ActiveHeadingEditorHandle } from '../../search/useActiveHeading';
3
5
  /** A single togglable panel kind that can appear in the left or right sidebar. */
4
6
  export type SidebarPanelType = "ai" | "files" | "outline" | "openTabs";
5
7
  /** The kind of resource a tab in the "Open Tabs" panel represents. */
@@ -68,6 +70,7 @@ export interface SidebarProps {
68
70
  onFileSourceChange?: (sourceId: string) => void;
69
71
  headings?: TocEntry[];
70
72
  onNavigate?: (key: string) => void;
73
+ editorRef?: RefObject<ActiveHeadingEditorHandle | null>;
71
74
  openTabs?: string[];
72
75
  activeTab?: string | null;
73
76
  onTabChange?: (id: string) => void;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const e=require("./ReasonDocs-C1t3Tdl5.cjs");exports.ReasonDocs=e.Index;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const e=require("./ReasonDocs-BsqLLRX5.cjs");exports.ReasonDocs=e.Index;
@@ -1 +1 @@
1
- import{t as o}from"./ReasonDocs-BkV43EyN.js";export{o as ReasonDocs};
1
+ import{t as o}from"./ReasonDocs-CK-Glhub.js";export{o as ReasonDocs};
@@ -1,4 +1,6 @@
1
+ import { RefObject } from 'react';
1
2
  import { TocEntry } from '../app-types/toc';
3
+ import { ActiveHeadingEditorHandle } from './useActiveHeading';
2
4
  /**
3
5
  * Imperative handle exposed to parent components via a forwarded ref.
4
6
  * Allows programmatic expand/collapse of the entire outline.
@@ -19,6 +21,12 @@ interface OutlineViewProps {
19
21
  onReorder?: (fromIndex: number, toIndex: number) => void;
20
22
  /** Filters the heading list to items whose text contains this query. */
21
23
  searchQuery?: string;
24
+ /**
25
+ * Ref to the editor's imperative handle, used to resolve heading DOM
26
+ * elements for scroll-spy active-heading highlighting. When omitted, no
27
+ * heading is ever highlighted as active.
28
+ */
29
+ editorRef?: RefObject<ActiveHeadingEditorHandle | null>;
22
30
  }
23
31
  /**
24
32
  * Collapsible document outline panel. Renders a heading tree built from
@@ -0,0 +1,32 @@
1
+ import { RefObject } from 'react';
2
+ import { TocEntry } from '../app-types/toc';
3
+ /** Minimal shape this hook needs from an editor ref — matches `TiptapEditorHandle`. */
4
+ export interface ActiveHeadingEditorHandle {
5
+ getElementByKey: (key: string) => HTMLElement | null;
6
+ }
7
+ interface HeadingTop {
8
+ key: string;
9
+ /** Heading element's top offset relative to the scroll container's top. */
10
+ top: number;
11
+ }
12
+ /**
13
+ * Given each visible heading's top offset (relative to the scroll
14
+ * container) and a threshold distance from the container's top, returns the
15
+ * key of the last heading whose top is at or above the threshold — i.e. the
16
+ * heading the reader has scrolled past most recently. Falls back to the
17
+ * first heading when none qualify (e.g. the reader is above the first
18
+ * heading), and to `null` when there are no headings at all.
19
+ */
20
+ export declare function computeActiveHeadingKey(headings: HeadingTop[], threshold: number): string | null;
21
+ /**
22
+ * Tracks the currently active heading key while the document scrolls.
23
+ * Resolves heading DOM elements via `editorRef.current.getElementByKey`, so
24
+ * it stays in sync with whatever container the editor actually scrolls in
25
+ * (found by walking up from the first heading to its nearest scrollable
26
+ * ancestor, falling back to `window`).
27
+ *
28
+ * Returns `null` when there is no `editorRef`/no headings, or before the
29
+ * first scroll-position measurement.
30
+ */
31
+ export declare function useActiveHeading(headings: TocEntry[], editorRef?: RefObject<ActiveHeadingEditorHandle | null>): string | null;
32
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-reason-editor",
3
- "version": "1.0.28",
3
+ "version": "1.0.29",
4
4
  "description": "A modern WYSIWYG rich text editor based on tiptap and shadcn ui for React",
5
5
  "repository": {
6
6
  "type": "git",