docstra 1.9.9-next.5 → 1.9.9-next.6

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.
@@ -61,11 +61,13 @@ interface DocsLinkGroup {
61
61
  type SidebarItem = {
62
62
  type: 'page';
63
63
  title: string;
64
+ nav_title?: string;
64
65
  href: string;
65
66
  icon?: string;
66
67
  } | {
67
68
  type: 'section';
68
69
  title: string;
70
+ nav_title?: string;
69
71
  href: string;
70
72
  children: SidebarItem[];
71
73
  icon?: string;
@@ -77,6 +79,7 @@ type SidebarItem = {
77
79
  } | {
78
80
  type: 'link';
79
81
  title: string;
82
+ nav_title?: string;
80
83
  href: string;
81
84
  external?: boolean;
82
85
  };
@@ -61,11 +61,13 @@ interface DocsLinkGroup {
61
61
  type SidebarItem = {
62
62
  type: 'page';
63
63
  title: string;
64
+ nav_title?: string;
64
65
  href: string;
65
66
  icon?: string;
66
67
  } | {
67
68
  type: 'section';
68
69
  title: string;
70
+ nav_title?: string;
69
71
  href: string;
70
72
  children: SidebarItem[];
71
73
  icon?: string;
@@ -77,6 +79,7 @@ type SidebarItem = {
77
79
  } | {
78
80
  type: 'link';
79
81
  title: string;
82
+ nav_title?: string;
80
83
  href: string;
81
84
  external?: boolean;
82
85
  };
@@ -1 +1 @@
1
- "use strict";"use client";var He=Object.create;var K=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,Ye=Object.prototype.hasOwnProperty;var Qe=(e,r)=>{for(var t in r)K(e,t,{get:r[t],enumerable:!0})},de=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of Ke(r))!Ye.call(e,a)&&a!==t&&K(e,a,{get:()=>r[a],enumerable:!(o=qe(r,a))||o.enumerable});return e};var R=(e,r,t)=>(t=e!=null?He(Ve(e)):{},de(r||!e||!e.__esModule?K(t,"default",{value:e,enumerable:!0}):t,e)),_e=e=>de(K({},"__esModule",{value:!0}),e);var rt={};Qe(rt,{DocstraBody:()=>et,DocstraCodeBlock:()=>tt,DocstraHeader:()=>re,DocstraLayout:()=>je,DocstraProvider:()=>We,useDocstra:()=>f});module.exports=_e(rt);var T=require("react"),ye=require("react-toast-msg");var fe=require("lucide-react");var pe=require("tailwind-merge"),ue=R(require("clsx"));function g(...e){return(0,pe.twMerge)((0,ue.default)(e))}var O=require("react"),ge=R(require("fuse.js")),be=R(require("next/link")),he=require("next/navigation"),h=require("react/jsx-runtime");function xe(){let{openSearchBox:e,setOpenSearchBox:r,page:t}=f(),[o,a]=(0,O.useState)(""),[n,s]=(0,O.useState)([]),c=(0,he.useRouter)();(0,O.useEffect)(()=>{let i=v=>{v.ctrlKey&&v.key==="k"&&(v.preventDefault(),r(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let m=(0,O.useMemo)(()=>!t||t.length===0?null:new ge.default(t,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[t]);(0,O.useEffect)(()=>{if(o&&m){let i=m.search(o);s(i.map(v=>v.item))}else o||s([])},[o,m]);let y=i=>{if(i.preventDefault(),o){let v=n[0];v&&(c.push(`/docs/${v.slug}`),a(""),r(!1))}};return(0,O.useEffect)(()=>{let i=v=>{v.key==="Escape"&&(r(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),(0,h.jsx)("div",{onClick:()=>{r(!1),a("")},className:g("fixed inset-0 z-25 flex items-start justify-center bg-white/40 backdrop-blur-md opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),children:(0,h.jsxs)("div",{onClick:i=>i.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:[(0,h.jsx)("form",{onSubmit:y,className:g("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md",o&&"rounded-b-none border-b-0"),children:e&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fe.SearchIcon,{className:"size-5.5 mx-3 shrink-0"}),(0,h.jsx)("input",{className:"w-full bg-transparent h-full outline-none text-gray-400 placeholder:text-gray-400",type:"text",placeholder:"Search docs...",spellCheck:"false",autoFocus:!0,value:o,onChange:i=>a(i.target.value),name:"searchQuery",required:!0}),(0,h.jsx)("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),(0,h.jsxs)("div",{className:g("max-h-70 overflow-x-hidden overflow-y-auto scrollbar-y w-full bg-white text-slate-700 flex flex-col",o&&"rounded-b-md border border-slate-200"),children:[n.map(i=>(0,h.jsxs)(be.default,{href:`/docs/${i.slug==="index"?"":i.slug}`,onClick:()=>{r(!1),a("")},className:"w-full hover:bg-gray-100/70 border-b border-slate-200 transition-all py-4 px-4 last:mb-2",children:[(0,h.jsx)("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),(0,h.jsx)("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),o&&n.length===0&&(0,h.jsx)("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}var F=require("react/jsx-runtime"),ve=(0,T.createContext)(null);function We({children:e,docstraConfig:r,page:t,sidebarItems:o}){let[a,n]=(0,T.useState)(!1),[s,c]=(0,T.useState)(!1),[m,y]=(0,T.useState)("npm");return(0,F.jsxs)(ve.Provider,{value:{openSidebar:a,setOpenSidebar:n,docstraConfig:r,openSearchBox:s,setOpenSearchBox:c,packageManager:m,setPackageManager:y,sidebarItems:o,page:t},children:[(0,F.jsx)(ye.ToastContainer,{}),(0,F.jsx)(xe,{}),e]})}function f(){let e=(0,T.useContext)(ve);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}var Y=require("lucide-react"),we=require("react");var V=R(require("next/link")),k=require("react/jsx-runtime");function re(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t}=f(),o="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return(0,we.useEffect)(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),(0,k.jsxs)("header",{className:"fixed w-full top-0 z-10 text-sm flex items-center justify-between border-b border-gray-100 h-18 px-4 md:px-6 bg-white",children:[(0,k.jsx)(V.default,{href:t.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:(0,k.jsx)("img",{src:t.navbar?.logo?.src||"/logo.png",alt:t.navbar?.logo?.alt||"Logo",className:g("h-9.5 w-auto",t.navbar?.logo?.className)})}),(0,k.jsxs)("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[t.navbar?.links?.map(a=>(0,k.jsx)(V.default,{href:a.href,className:"px-6 hover:text-gray-600",children:a.name},a.name)),(0,k.jsx)(V.default,{href:o||"https://github.com/sudhucodes/docstra",children:(0,k.jsx)("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,k.jsx)("path",{d:"M12 .3a12 12 0 0 0-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.08 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 0 1 1.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0 0 12 .3"})})})]}),(0,k.jsx)("button",{onClick:()=>r(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?(0,k.jsx)(Y.XIcon,{className:"size-6.5"}):(0,k.jsx)(Y.TextAlignEnd,{className:"size-6.5"})})]})}var _=require("lucide-react"),Ne=require("next/navigation");var Xe=R(require("lucide-react"));function oe(e){if(e)return Xe[e]}var ae=R(require("next/link")),Q=require("react"),l=require("react/jsx-runtime");function Ze({item:e,pathname:r,openSidebar:t,setOpenSidebar:o}){let[a,n]=(0,Q.useState)(e.defaultOpen??!0),s=e.collapsible??!0,c=oe(e.icon);return(0,l.jsxs)("div",{children:[(0,l.jsxs)(ae.default,{href:e.href,onClick:()=>s&&n(m=>!m),className:"w-full flex items-center justify-between gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",children:[(0,l.jsxs)("span",{className:"flex items-center gap-2",children:[c&&(0,l.jsx)(c,{className:"size-4 text-gray-400"}),e.title]}),s&&(0,l.jsx)(_.ChevronDownIcon,{className:g("size-4 text-black/50 transition-transform duration-300",a&&"rotate-180")})]}),(!s||a)&&(0,l.jsx)("ul",{className:"mb-4 ml-2",children:e.children.map((m,y)=>(0,l.jsx)(ke,{item:m,pathname:r,openSidebar:t,setOpenSidebar:o},`${m.type}-${y}`))})]})}function Je({item:e,pathname:r,openSidebar:t,setOpenSidebar:o}){let a=oe(e.icon);return(0,l.jsxs)(ae.default,{href:e.href,onClick:()=>t&&o(!1),className:g("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",r===e.href&&"bg-gray-100 text-gray-800"),children:[a&&(0,l.jsx)(a,{className:"size-4"}),(0,l.jsx)("span",{children:e.title})]})}function ke({item:e,pathname:r,openSidebar:t,setOpenSidebar:o}){switch(e.type){case"page":return(0,l.jsx)(Je,{item:e,pathname:r,openSidebar:t,setOpenSidebar:o});case"section":return(0,l.jsx)(Ze,{item:e,pathname:r,openSidebar:t,setOpenSidebar:o});default:return null}}function Se({sidebarItems:e}){let[r,t]=(0,Q.useState)(!1),[o,a]=(0,Q.useState)(!1),n=(0,Ne.usePathname)();return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:g("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",r&&"opacity-100 pointer-events-auto"),onClick:()=>t(!1)}),(0,l.jsxs)("aside",{className:g("fixed md:top-18 h-[calc(100svh-72px)] scrollbar-y w-screen max-md:rounded-t-lg z-21 md:w-72 pb-10 text-base md:text-sm shrink-0 border-r border-gray-200 p-4 max-md:fixed bg-white overflow-y-auto transition-all duration-300",r?"top-32":"top-full"),children:[(0,l.jsxs)("div",{className:"flex items-center select-none gap-2 cursor-pointer mt-6 mb-4 p-2.5 text-gray-500 border border-gray-200 rounded-lg hover:bg-gray-50",onClick:()=>{t(r&&!1),a(!0)},children:[(0,l.jsx)(_.SearchIcon,{className:"size-4.5"}),(0,l.jsx)("p",{children:"Search"}),(0,l.jsxs)("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[(0,l.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),(0,l.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),e.map((s,c)=>(0,l.jsx)(ke,{item:s,pathname:n,openSidebar:r,setOpenSidebar:t},`${s.type}-${c}`))]})]})}var W=require("react/jsx-runtime");function je({children:e,sidebarItems:r}){return(0,W.jsxs)("div",{className:"min-h-screen flex bg-white w-full",children:[(0,W.jsx)(Se,{sidebarItems:r}),e]})}var Ce=require("next/navigation"),Ie=require("lucide-react"),ne=R(require("next/link")),I=require("react/jsx-runtime");function De(){let r=(0,Ce.usePathname)().split("/").filter(Boolean),t=r.map((o,a)=>{let n="/"+r.slice(0,a+1).join("/"),s=o.replace(/-/g," ").replace(/\b\w/g,c=>c.toUpperCase());return{href:n,title:s}});return(0,I.jsx)("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500 not-prose",children:(0,I.jsxs)("ol",{className:"flex items-center space-x-2",children:[(0,I.jsx)("li",{children:(0,I.jsx)(ne.default,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),t.map((o,a)=>{let n=a===t.length-1;return(0,I.jsxs)("li",{className:"flex items-center space-x-2",children:[(0,I.jsx)(Ie.ChevronRight,{className:"w-4 h-4 text-gray-400"}),n?(0,I.jsx)("span",{className:"text-gray-600 font-medium",children:o.title}):(0,I.jsx)(ne.default,{href:o.href,className:"hover:text-gray-700 font-medium transition-colors",children:o.title})]},o.href)})]})})}var M=require("lucide-react"),Oe=require("next/navigation"),N=require("react");var w=require("react/jsx-runtime");function Pe(){let[e,r]=(0,N.useState)(null),[t,o]=(0,N.useState)("down"),[a,n]=(0,N.useState)(!1),[s,c]=(0,N.useState)(!1),{docstraConfig:m,page:y}=f(),i=y?.path,v=y?.tableOfContents||[],B=(0,N.useRef)(0),C=(0,N.useRef)(null),H=(0,Oe.usePathname)(),te=`${"https://github.com/"+m?.editOnGithub?.owner+"/"+m?.editOnGithub?.repo}/edit/main/${m?.editOnGithub?.path}/${i}`;(0,N.useEffect)(()=>{let p=()=>{let b=window.scrollY;o(b>B.current?"down":"up"),n(b>100),B.current=b};return window.addEventListener("scroll",p),()=>window.removeEventListener("scroll",p)},[]),(0,N.useEffect)(()=>{let p=document.querySelectorAll("h2[id], h3[id]"),b=new IntersectionObserver(P=>{if(s)return;let L=P.filter($=>$.isIntersecting).sort(($,Ae)=>$.boundingClientRect.top-Ae.boundingClientRect.top);if(L.length>0){let $=t==="down"?L[0].target.id:L[L.length-1].target.id;r($)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return p.forEach(P=>b.observe(P)),C.current=b,()=>b.disconnect()},[H,t,s]),(0,N.useEffect)(()=>{!(window.scrollY>100)&&r(v[0]?.id)},[v]),(0,N.useEffect)(()=>{if(!e)return;let p=document.querySelector(".toc-scroll-container");if(!p)return;let b=p.querySelector(`a[href="#${e}"]`);if(!b)return;let P=p.getBoundingClientRect(),L=b.getBoundingClientRect();(L.top<P.top||L.bottom>P.bottom)&&b.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),(0,N.useEffect)(()=>{if(!s)return;let p=setTimeout(()=>c(!1),800);return()=>clearTimeout(p)},[s]);let q=p=>{r(p),c(!0)};return(0,w.jsxs)("aside",{className:"sticky top-18 text-sm hidden xl:block text-gray-500 shrink-0 h-[calc(100svh-72px)] w-64 border-l border-gray-200 p-6 overflow-y-auto",children:[(0,w.jsxs)("p",{className:"flex items-center gap-2 mb-5",children:[(0,w.jsx)(M.TextAlignStartIcon,{className:"size-4"}),"On this page"]}),(0,w.jsx)("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:v.map(p=>(0,w.jsxs)("li",{children:[(0,w.jsx)(Le,{heading:p,activeId:e,handleClick:q}),p.children.map(b=>(0,w.jsx)(Le,{heading:b,activeId:e,handleClick:q,className:"pl-8"},b.id))]},p.id))}),(0,w.jsx)("hr",{className:"my-6 border-gray-200"}),m.editOnGithub&&(0,w.jsxs)("a",{href:te,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",(0,w.jsx)(M.SquareArrowOutUpRightIcon,{className:"size-4"})]}),a&&(0,w.jsxs)("button",{onClick:()=>scrollTo({top:0,behavior:"smooth"}),className:"flex items-center cursor-pointer gap-2 mt-3 text-gray-400 hover:text-gray-700 transition",children:["Scroll to top",(0,w.jsx)(M.ArrowUpCircleIcon,{className:"size-4"})]})]})}function Le({heading:e,activeId:r,handleClick:t,className:o}){return(0,w.jsx)("a",{href:`#${e.id}`,className:g("border-l border-gray-200 block py-1.5 pl-4 transition-colors",o,{"border-gray-800 text-gray-900 font-medium":r===e.id,"hover:text-gray-800 hover:border-gray-400":r!==e.id}),onClick:()=>t(e.id),children:e.text})}var U=require("react"),X=require("lucide-react");var z=require("react/jsx-runtime");function se({label:e,type:r,placeholder:t="",id:o,required:a=!1,onChange:n,value:s,readOnly:c=!1,className:m="",optional:y=!1}){return(0,z.jsxs)("div",{className:g("flex flex-col mt-4 w-full",m),children:[e&&(0,z.jsxs)("label",{htmlFor:o,className:"font-medium w-max cursor-pointer",children:[e,y&&(0,z.jsx)("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),r==="textarea"?(0,z.jsx)("textarea",{id:o,name:o,className:g("mt-2 w-full p-3 border border-gray-300 resize-none not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",m),placeholder:t,required:a,onChange:n,rows:4,value:s,readOnly:c,maxLength:500}):(0,z.jsx)("input",{type:r,id:o,name:o,className:"mt-2 w-full h-12 px-3 border border-gray-300 not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",placeholder:t,required:a,onChange:n,value:s,readOnly:c,maxLength:500})]})}var Re=require("lucide-react");var ie=require("react/jsx-runtime");function le({label:e,loading:r,type:t="submit",className:o="",disabled:a=!1,onClick:n}){return(0,ie.jsx)("button",{type:t,disabled:a,className:g("relative w-full mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg",o),"aria-label":e,onClick:n,children:r?(0,ie.jsx)(Re.Loader2Icon,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}var Z=require("formsync"),d=require("react/jsx-runtime");function Te(){let[e,r]=(0,U.useState)(null),{docstraConfig:t}=f(),[o,a]=(0,U.useState)(""),[n,s]=(0,U.useState)(!1),[c,m]=(0,U.useState)(null),y="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return(0,d.jsx)("div",{className:"border-y border-gray-200 mt-10 py-10 space-y-4",children:n?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),(0,d.jsx)(le,{onClick:()=>{s(!1),r(null),a("")},label:"Submit Again",className:"w-max text-sm"})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"font-medium",children:"How is this guide?"}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsxs)("button",{onClick:()=>r("good"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="good"?"bg-green-100 text-green-600 border-green-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[(0,d.jsx)(X.ThumbsUp,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),(0,d.jsxs)("button",{onClick:()=>r("bad"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="bad"?"bg-red-100 text-red-600 border-red-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[(0,d.jsx)(X.ThumbsDown,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&(0,d.jsxs)(Z.FormSyncForm,{className:"flex flex-col gap-2",formId:t?.feedback?.formSyncFormID||"",onSuccess:i=>{s(!0),r(null),a("")},onSubmitError:i=>{m(i.message)},children:[(0,d.jsx)(se,{value:o,id:"message",onChange:i=>a(i.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),c&&(0,d.jsx)("p",{className:"text-red-500",children:c}),(0,d.jsx)("input",{type:"hidden",name:"opinion",value:e}),(0,d.jsx)("input",{type:"hidden",name:"page",value:window.location.href}),(0,d.jsx)("input",{type:"hidden",name:"_redirect",value:window.location.href}),(0,d.jsx)(Z.FormSyncButton,{className:"relative mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg w-max text-sm",children:"Submit"}),t?.feedback?.watermark!==!1&&(0,d.jsxs)("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",(0,d.jsx)("a",{href:`https://www.formsync.app?utm_source=${y}`,className:"text-gray-800 not-prose",children:"FormSync"})]})]})]})})}var Ee=require("react/jsx-runtime");function ze(){let{pageData:e}=f();if(!e?.data?.lastUpdated)return null;let r=new Date(e.data.lastUpdated).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"});return(0,Ee.jsxs)("p",{className:"text-sm text-gray-500",children:["Last updated on ",r]})}var J=require("lucide-react"),A=require("react");var E=require("react/jsx-runtime");function Be(){let{pageData:e}=f(),[r,t]=(0,A.useState)(!1),[o,a]=(0,A.useState)(null);(0,A.useEffect)(()=>{a(window.location.href)},[]);let n=`Read from this URL: ${o} and explain it to me.`;return(0,E.jsxs)("div",{className:"flex items-center gap-3 mt-6",children:[(0,E.jsxs)("button",{title:"Copy Markdown",onClick:()=>{navigator.clipboard.writeText(e?.data.raw||""),t(!0),setTimeout(()=>t(!1),3e3)},className:"flex items-center cursor-pointer gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",children:[r?(0,E.jsx)(J.CheckIcon,{className:"size-3.5"}):(0,E.jsx)(J.CopyIcon,{className:"size-3.5"}),"Copy Markdown"]}),(0,E.jsx)("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(n)}`,className:"flex not-prose items-center gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",rel:"noreferrer noopener",children:"Ask ChatGPT"})]})}var $e=require("next/navigation"),ce=R(require("next/link")),j=require("lucide-react");var S=require("react/jsx-runtime");function Me(e){let r=[];for(let t of e)t.type==="page"?r.push({name:t.title,href:t.href,icon:t.icon}):t.type==="section"&&r.push(...Me(t.children));return r}function Ge(){let e=(0,$e.usePathname)(),{docstraConfig:r,sidebarItems:t}=f(),o=[];t&&t.length>0?o=Me(t):r?.sidebar?.links&&(o=r.sidebar.links.flatMap(c=>c.items));let a=o.findIndex(c=>c.href===e),n=a>0?o[a-1]:null,s=a<o.length-1?o[a+1]:null;return(0,S.jsxs)("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[n?(0,S.jsxs)(ce.default,{href:n.href,className:"flex flex-col not-prose items-start gap-2 border border-gray-200 hover:bg-gray-50 py-3 md:min-w-62 pl-4 pr-10 rounded-lg text-sm",children:[(0,S.jsx)("span",{className:"text-gray-500",children:"Previous"}),(0,S.jsxs)("p",{className:"flex items-center font-medium",children:[(0,S.jsx)(j.ArrowLeftIcon,{className:"size-5 mr-2"}),n.name]})]}):(0,S.jsx)("div",{}),s?(0,S.jsxs)(ce.default,{href:s.href,className:"flex flex-col not-prose items-end gap-2 border border-gray-200 hover:bg-gray-50 py-3 pr-4 md:min-w-62 pl-10 rounded-lg text-sm",children:[(0,S.jsx)("span",{className:"text-gray-500",children:"Next"}),(0,S.jsxs)("p",{className:"flex items-center font-medium",children:[s.name,(0,S.jsx)(j.ArrowRightIcon,{className:"size-5 ml-2"})]})]}):(0,S.jsx)("div",{})]})}var x=require("react/jsx-runtime");function et({children:e}){let{docstraConfig:r,page:t}=f();return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(re,{}),(0,x.jsxs)("main",{className:"flex-1 px-4 md:px-8 md:pl-80 pt-28 py-10 prose max-w-none",children:[(0,x.jsx)(De,{}),(0,x.jsx)("h1",{className:"text-3xl font-bold",children:t?.metadata?.title}),(0,x.jsx)("p",{className:"my-4 text-gray-500",children:t?.metadata?.description}),(0,x.jsx)(Be,{}),(0,x.jsx)("hr",{className:"my-10 border-gray-200"}),e,r?.feedback?.enabled&&(0,x.jsx)(Te,{}),(0,x.jsx)(ze,{}),(0,x.jsx)(Ge,{})]}),(0,x.jsx)(Pe,{})]})}var G=require("lucide-react"),ee=require("prism-react-renderer"),Fe=require("react");var Ue=require("react-toast-msg"),u=require("react/jsx-runtime"),me={npm:"npm install",pnpm:"pnpm add",yarn:"yarn add",bun:"bun add"};function tt(e){let{filename:r,copyable:t,children:o,className:a}=e,{packageManager:n,setPackageManager:s}=f(),c=!a?.includes("language-"),m=typeof o=="string"?o:o?.props?.children||"";if(c)return(0,u.jsx)("code",{className:"not-prose px-1 py-0.5 rounded border border-gray-200 bg-gray-50 text-gray-800 text-sm",children:m});let[y,i]=(0,Fe.useState)(!1),B=a?.match(/language-([\w-]+)/)?.[1]??"txt",C=B==="package-install",H=()=>{let D=C?`${me[n]} ${m.trim()}`:m.trim();navigator.clipboard.writeText(D),i(!0),Ue.toast.success("Code copied to clipboard"),setTimeout(()=>i(!1),2e3)};return(0,u.jsxs)("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200 mt-4 bg-white",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between bg-gray-50 border-b border-gray-200",children:[!C&&(0,u.jsx)("span",{className:"text-xs text-gray-400 px-4 py-3",children:r||B}),C&&(0,u.jsx)("div",{className:"flex items-center px-3",children:Object.keys(me).map(D=>(0,u.jsx)("button",{onClick:()=>s(D),className:`px-3 pb-2.5 pt-3 text-sm font-medium border-b-2 transition-all ${n===D?"border-gray-900 text-gray-900":"border-transparent text-gray-500 hover:text-gray-800"}`,children:D},D))}),t&&!C&&(0,u.jsx)("button",{onClick:H,className:"rounded-lg cursor-pointer p-2 m-2 text-gray-500 hover:bg-gray-200 transition",children:y?(0,u.jsx)(G.CheckIcon,{className:"size-4 text-green-600"}):(0,u.jsx)(G.CopyIcon,{className:"size-4"})})]}),(0,u.jsx)(ee.Highlight,{theme:ee.themes.vsLight,code:m.trim(),language:C?"bash":B,children:({tokens:D,getLineProps:te,getTokenProps:q})=>(0,u.jsxs)("pre",{className:`p-4 font-mono whitespace-pre overflow-x-auto text-sm leading-relaxed ${t&&C?"flex items-center justify-between":""}`,children:[D.map((p,b)=>(0,u.jsxs)("div",{...te({line:p}),children:[!C&&(0,u.jsx)("span",{className:"text-gray-400 mr-4 select-none",children:b+1}),C&&(0,u.jsx)("span",{className:"mr-2",children:me[n]}),p.map((P,L)=>(0,u.jsx)("span",{...q({token:P})},L))]},b)),t&&C&&(0,u.jsx)("button",{onClick:H,className:"rounded-lg cursor-pointer p-2 text-gray-500 hover:bg-gray-100 transition",children:y?(0,u.jsx)(G.CheckIcon,{className:"size-4 text-green-600"}):(0,u.jsx)(G.CopyIcon,{className:"size-4"})})]})})]})}0&&(module.exports={DocstraBody,DocstraCodeBlock,DocstraHeader,DocstraLayout,DocstraProvider,useDocstra});
1
+ "use strict";"use client";var He=Object.create;var _=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Ke=Object.getPrototypeOf,Ve=Object.prototype.hasOwnProperty;var Ye=(e,r)=>{for(var t in r)_(e,t,{get:r[t],enumerable:!0})},de=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of _e(r))!Ve.call(e,a)&&a!==t&&_(e,a,{get:()=>r[a],enumerable:!(o=qe(r,a))||o.enumerable});return e};var R=(e,r,t)=>(t=e!=null?He(Ke(e)):{},de(r||!e||!e.__esModule?_(t,"default",{value:e,enumerable:!0}):t,e)),Qe=e=>de(_({},"__esModule",{value:!0}),e);var rt={};Ye(rt,{DocstraBody:()=>et,DocstraCodeBlock:()=>tt,DocstraHeader:()=>re,DocstraLayout:()=>je,DocstraProvider:()=>We,useDocstra:()=>f});module.exports=Qe(rt);var T=require("react"),ye=require("react-toast-msg");var fe=require("lucide-react");var pe=require("tailwind-merge"),ue=R(require("clsx"));function g(...e){return(0,pe.twMerge)((0,ue.default)(e))}var O=require("react"),ge=R(require("fuse.js")),be=R(require("next/link")),he=require("next/navigation"),h=require("react/jsx-runtime");function xe(){let{openSearchBox:e,setOpenSearchBox:r,page:t}=f(),[o,a]=(0,O.useState)(""),[n,s]=(0,O.useState)([]),c=(0,he.useRouter)();(0,O.useEffect)(()=>{let i=v=>{v.ctrlKey&&v.key==="k"&&(v.preventDefault(),r(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let m=(0,O.useMemo)(()=>!t||t.length===0?null:new ge.default(t,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[t]);(0,O.useEffect)(()=>{if(o&&m){let i=m.search(o);s(i.map(v=>v.item))}else o||s([])},[o,m]);let y=i=>{if(i.preventDefault(),o){let v=n[0];v&&(c.push(`/docs/${v.slug}`),a(""),r(!1))}};return(0,O.useEffect)(()=>{let i=v=>{v.key==="Escape"&&(r(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),(0,h.jsx)("div",{onClick:()=>{r(!1),a("")},className:g("fixed inset-0 z-25 flex items-start justify-center bg-white/40 backdrop-blur-md opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),children:(0,h.jsxs)("div",{onClick:i=>i.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:[(0,h.jsx)("form",{onSubmit:y,className:g("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md",o&&"rounded-b-none border-b-0"),children:e&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fe.SearchIcon,{className:"size-5.5 mx-3 shrink-0"}),(0,h.jsx)("input",{className:"w-full bg-transparent h-full outline-none text-gray-400 placeholder:text-gray-400",type:"text",placeholder:"Search docs...",spellCheck:"false",autoFocus:!0,value:o,onChange:i=>a(i.target.value),name:"searchQuery",required:!0}),(0,h.jsx)("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),(0,h.jsxs)("div",{className:g("max-h-70 overflow-x-hidden overflow-y-auto scrollbar-y w-full bg-white text-slate-700 flex flex-col",o&&"rounded-b-md border border-slate-200"),children:[n.map(i=>(0,h.jsxs)(be.default,{href:`/docs/${i.slug==="index"?"":i.slug}`,onClick:()=>{r(!1),a("")},className:"w-full hover:bg-gray-100/70 border-b border-slate-200 transition-all py-4 px-4 last:mb-2",children:[(0,h.jsx)("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),(0,h.jsx)("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),o&&n.length===0&&(0,h.jsx)("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}var F=require("react/jsx-runtime"),ve=(0,T.createContext)(null);function We({children:e,docstraConfig:r,page:t,sidebarItems:o}){let[a,n]=(0,T.useState)(!1),[s,c]=(0,T.useState)(!1),[m,y]=(0,T.useState)("npm");return(0,F.jsxs)(ve.Provider,{value:{openSidebar:a,setOpenSidebar:n,docstraConfig:r,openSearchBox:s,setOpenSearchBox:c,packageManager:m,setPackageManager:y,sidebarItems:o,page:t},children:[(0,F.jsx)(ye.ToastContainer,{}),(0,F.jsx)(xe,{}),e]})}function f(){let e=(0,T.useContext)(ve);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}var V=require("lucide-react"),we=require("react");var K=R(require("next/link")),k=require("react/jsx-runtime");function re(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t}=f(),o="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return(0,we.useEffect)(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),(0,k.jsxs)("header",{className:"fixed w-full top-0 z-10 text-sm flex items-center justify-between border-b border-gray-100 h-18 px-4 md:px-6 bg-white",children:[(0,k.jsx)(K.default,{href:t.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:(0,k.jsx)("img",{src:t.navbar?.logo?.src||"/logo.png",alt:t.navbar?.logo?.alt||"Logo",className:g("h-9.5 w-auto",t.navbar?.logo?.className)})}),(0,k.jsxs)("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[t.navbar?.links?.map(a=>(0,k.jsx)(K.default,{href:a.href,className:"px-6 hover:text-gray-600",children:a.name},a.name)),(0,k.jsx)(K.default,{href:o||"https://github.com/sudhucodes/docstra",children:(0,k.jsx)("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,k.jsx)("path",{d:"M12 .3a12 12 0 0 0-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.08 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 0 1 1.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0 0 12 .3"})})})]}),(0,k.jsx)("button",{onClick:()=>r(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?(0,k.jsx)(V.XIcon,{className:"size-6.5"}):(0,k.jsx)(V.TextAlignEnd,{className:"size-6.5"})})]})}var Q=require("lucide-react"),Ne=require("next/navigation");var Xe=R(require("lucide-react"));function oe(e){if(e)return Xe[e]}var ae=R(require("next/link")),Y=require("react"),l=require("react/jsx-runtime");function Ze({item:e,pathname:r,openSidebar:t,setOpenSidebar:o}){let[a,n]=(0,Y.useState)(e.defaultOpen??!0),s=e.collapsible??!0,c=oe(e.icon);return(0,l.jsxs)("div",{children:[(0,l.jsxs)(ae.default,{href:e.href,onClick:()=>s&&n(m=>!m),className:"w-full flex items-center justify-between gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",children:[(0,l.jsxs)("span",{className:"flex items-center gap-2",children:[c&&(0,l.jsx)(c,{className:"size-4 text-gray-400"}),e.nav_title?e.nav_title:e.title]}),s&&(0,l.jsx)(Q.ChevronDownIcon,{className:g("size-4 text-black/50 transition-transform duration-300",a&&"rotate-180")})]}),(!s||a)&&(0,l.jsx)("ul",{className:"mb-4 ml-2",children:e.children.map((m,y)=>(0,l.jsx)(ke,{item:m,pathname:r,openSidebar:t,setOpenSidebar:o},`${m.type}-${y}`))})]})}function Je({item:e,pathname:r,openSidebar:t,setOpenSidebar:o}){let a=oe(e.icon);return(0,l.jsxs)(ae.default,{href:e.href,onClick:()=>t&&o(!1),className:g("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",r===e.href&&"bg-gray-100 text-gray-800"),children:[a&&(0,l.jsx)(a,{className:"size-4"}),(0,l.jsx)("span",{children:e.nav_title?e.nav_title:e.title})]})}function ke({item:e,pathname:r,openSidebar:t,setOpenSidebar:o}){switch(e.type){case"page":return(0,l.jsx)(Je,{item:e,pathname:r,openSidebar:t,setOpenSidebar:o});case"section":return(0,l.jsx)(Ze,{item:e,pathname:r,openSidebar:t,setOpenSidebar:o});default:return null}}function Se({sidebarItems:e}){let[r,t]=(0,Y.useState)(!1),[o,a]=(0,Y.useState)(!1),n=(0,Ne.usePathname)();return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:g("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",r&&"opacity-100 pointer-events-auto"),onClick:()=>t(!1)}),(0,l.jsxs)("aside",{className:g("fixed md:top-18 h-[calc(100svh-72px)] scrollbar-y w-screen max-md:rounded-t-lg z-21 md:w-72 pb-10 text-base md:text-sm shrink-0 border-r border-gray-200 p-4 max-md:fixed bg-white overflow-y-auto transition-all duration-300",r?"top-32":"top-full"),children:[(0,l.jsxs)("div",{className:"flex items-center select-none gap-2 cursor-pointer mt-6 mb-4 p-2.5 text-gray-500 border border-gray-200 rounded-lg hover:bg-gray-50",onClick:()=>{t(r&&!1),a(!0)},children:[(0,l.jsx)(Q.SearchIcon,{className:"size-4.5"}),(0,l.jsx)("p",{children:"Search"}),(0,l.jsxs)("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[(0,l.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),(0,l.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),e.map((s,c)=>(0,l.jsx)(ke,{item:s,pathname:n,openSidebar:r,setOpenSidebar:t},`${s.type}-${c}`))]})]})}var W=require("react/jsx-runtime");function je({children:e,sidebarItems:r}){return(0,W.jsxs)("div",{className:"min-h-screen flex bg-white w-full",children:[(0,W.jsx)(Se,{sidebarItems:r}),e]})}var Ce=require("next/navigation"),Ie=require("lucide-react"),ne=R(require("next/link")),I=require("react/jsx-runtime");function De(){let r=(0,Ce.usePathname)().split("/").filter(Boolean),t=r.map((o,a)=>{let n="/"+r.slice(0,a+1).join("/"),s=o.replace(/-/g," ").replace(/\b\w/g,c=>c.toUpperCase());return{href:n,title:s}});return(0,I.jsx)("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500 not-prose",children:(0,I.jsxs)("ol",{className:"flex items-center space-x-2",children:[(0,I.jsx)("li",{children:(0,I.jsx)(ne.default,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),t.map((o,a)=>{let n=a===t.length-1;return(0,I.jsxs)("li",{className:"flex items-center space-x-2",children:[(0,I.jsx)(Ie.ChevronRight,{className:"w-4 h-4 text-gray-400"}),n?(0,I.jsx)("span",{className:"text-gray-600 font-medium",children:o.title}):(0,I.jsx)(ne.default,{href:o.href,className:"hover:text-gray-700 font-medium transition-colors",children:o.title})]},o.href)})]})})}var M=require("lucide-react"),Oe=require("next/navigation"),N=require("react");var w=require("react/jsx-runtime");function Pe(){let[e,r]=(0,N.useState)(null),[t,o]=(0,N.useState)("down"),[a,n]=(0,N.useState)(!1),[s,c]=(0,N.useState)(!1),{docstraConfig:m,page:y}=f(),i=y?.path,v=y?.tableOfContents||[],B=(0,N.useRef)(0),C=(0,N.useRef)(null),H=(0,Oe.usePathname)(),te=`${"https://github.com/"+m?.editOnGithub?.owner+"/"+m?.editOnGithub?.repo}/edit/main/${m?.editOnGithub?.path}/${i}`;(0,N.useEffect)(()=>{let p=()=>{let b=window.scrollY;o(b>B.current?"down":"up"),n(b>100),B.current=b};return window.addEventListener("scroll",p),()=>window.removeEventListener("scroll",p)},[]),(0,N.useEffect)(()=>{let p=document.querySelectorAll("h2[id], h3[id]"),b=new IntersectionObserver(P=>{if(s)return;let L=P.filter($=>$.isIntersecting).sort(($,Ae)=>$.boundingClientRect.top-Ae.boundingClientRect.top);if(L.length>0){let $=t==="down"?L[0].target.id:L[L.length-1].target.id;r($)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return p.forEach(P=>b.observe(P)),C.current=b,()=>b.disconnect()},[H,t,s]),(0,N.useEffect)(()=>{!(window.scrollY>100)&&r(v[0]?.id)},[v]),(0,N.useEffect)(()=>{if(!e)return;let p=document.querySelector(".toc-scroll-container");if(!p)return;let b=p.querySelector(`a[href="#${e}"]`);if(!b)return;let P=p.getBoundingClientRect(),L=b.getBoundingClientRect();(L.top<P.top||L.bottom>P.bottom)&&b.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),(0,N.useEffect)(()=>{if(!s)return;let p=setTimeout(()=>c(!1),800);return()=>clearTimeout(p)},[s]);let q=p=>{r(p),c(!0)};return(0,w.jsxs)("aside",{className:"sticky top-18 text-sm hidden xl:block text-gray-500 shrink-0 h-[calc(100svh-72px)] w-64 border-l border-gray-200 p-6 overflow-y-auto",children:[(0,w.jsxs)("p",{className:"flex items-center gap-2 mb-5",children:[(0,w.jsx)(M.TextAlignStartIcon,{className:"size-4"}),"On this page"]}),(0,w.jsx)("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:v.map(p=>(0,w.jsxs)("li",{children:[(0,w.jsx)(Le,{heading:p,activeId:e,handleClick:q}),p.children.map(b=>(0,w.jsx)(Le,{heading:b,activeId:e,handleClick:q,className:"pl-8"},b.id))]},p.id))}),(0,w.jsx)("hr",{className:"my-6 border-gray-200"}),m.editOnGithub&&(0,w.jsxs)("a",{href:te,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",(0,w.jsx)(M.SquareArrowOutUpRightIcon,{className:"size-4"})]}),a&&(0,w.jsxs)("button",{onClick:()=>scrollTo({top:0,behavior:"smooth"}),className:"flex items-center cursor-pointer gap-2 mt-3 text-gray-400 hover:text-gray-700 transition",children:["Scroll to top",(0,w.jsx)(M.ArrowUpCircleIcon,{className:"size-4"})]})]})}function Le({heading:e,activeId:r,handleClick:t,className:o}){return(0,w.jsx)("a",{href:`#${e.id}`,className:g("border-l border-gray-200 block py-1.5 pl-4 transition-colors",o,{"border-gray-800 text-gray-900 font-medium":r===e.id,"hover:text-gray-800 hover:border-gray-400":r!==e.id}),onClick:()=>t(e.id),children:e.text})}var U=require("react"),X=require("lucide-react");var z=require("react/jsx-runtime");function se({label:e,type:r,placeholder:t="",id:o,required:a=!1,onChange:n,value:s,readOnly:c=!1,className:m="",optional:y=!1}){return(0,z.jsxs)("div",{className:g("flex flex-col mt-4 w-full",m),children:[e&&(0,z.jsxs)("label",{htmlFor:o,className:"font-medium w-max cursor-pointer",children:[e,y&&(0,z.jsx)("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),r==="textarea"?(0,z.jsx)("textarea",{id:o,name:o,className:g("mt-2 w-full p-3 border border-gray-300 resize-none not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",m),placeholder:t,required:a,onChange:n,rows:4,value:s,readOnly:c,maxLength:500}):(0,z.jsx)("input",{type:r,id:o,name:o,className:"mt-2 w-full h-12 px-3 border border-gray-300 not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",placeholder:t,required:a,onChange:n,value:s,readOnly:c,maxLength:500})]})}var Re=require("lucide-react");var ie=require("react/jsx-runtime");function le({label:e,loading:r,type:t="submit",className:o="",disabled:a=!1,onClick:n}){return(0,ie.jsx)("button",{type:t,disabled:a,className:g("relative w-full mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg",o),"aria-label":e,onClick:n,children:r?(0,ie.jsx)(Re.Loader2Icon,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}var Z=require("formsync"),d=require("react/jsx-runtime");function Te(){let[e,r]=(0,U.useState)(null),{docstraConfig:t}=f(),[o,a]=(0,U.useState)(""),[n,s]=(0,U.useState)(!1),[c,m]=(0,U.useState)(null),y="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return(0,d.jsx)("div",{className:"border-y border-gray-200 mt-10 py-10 space-y-4",children:n?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),(0,d.jsx)(le,{onClick:()=>{s(!1),r(null),a("")},label:"Submit Again",className:"w-max text-sm"})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"font-medium",children:"How is this guide?"}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsxs)("button",{onClick:()=>r("good"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="good"?"bg-green-100 text-green-600 border-green-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[(0,d.jsx)(X.ThumbsUp,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),(0,d.jsxs)("button",{onClick:()=>r("bad"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="bad"?"bg-red-100 text-red-600 border-red-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[(0,d.jsx)(X.ThumbsDown,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&(0,d.jsxs)(Z.FormSyncForm,{className:"flex flex-col gap-2",formId:t?.feedback?.formSyncFormID||"",onSuccess:i=>{s(!0),r(null),a("")},onSubmitError:i=>{m(i.message)},children:[(0,d.jsx)(se,{value:o,id:"message",onChange:i=>a(i.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),c&&(0,d.jsx)("p",{className:"text-red-500",children:c}),(0,d.jsx)("input",{type:"hidden",name:"opinion",value:e}),(0,d.jsx)("input",{type:"hidden",name:"page",value:window.location.href}),(0,d.jsx)("input",{type:"hidden",name:"_redirect",value:window.location.href}),(0,d.jsx)(Z.FormSyncButton,{className:"relative mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg w-max text-sm",children:"Submit"}),t?.feedback?.watermark!==!1&&(0,d.jsxs)("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",(0,d.jsx)("a",{href:`https://www.formsync.app?utm_source=${y}`,className:"text-gray-800 not-prose",children:"FormSync"})]})]})]})})}var Ee=require("react/jsx-runtime");function ze(){let{pageData:e}=f();if(!e?.data?.lastUpdated)return null;let r=new Date(e.data.lastUpdated).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"});return(0,Ee.jsxs)("p",{className:"text-sm text-gray-500",children:["Last updated on ",r]})}var J=require("lucide-react"),A=require("react");var E=require("react/jsx-runtime");function Be(){let{pageData:e}=f(),[r,t]=(0,A.useState)(!1),[o,a]=(0,A.useState)(null);(0,A.useEffect)(()=>{a(window.location.href)},[]);let n=`Read from this URL: ${o} and explain it to me.`;return(0,E.jsxs)("div",{className:"flex items-center gap-3 mt-6",children:[(0,E.jsxs)("button",{title:"Copy Markdown",onClick:()=>{navigator.clipboard.writeText(e?.data.raw||""),t(!0),setTimeout(()=>t(!1),3e3)},className:"flex items-center cursor-pointer gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",children:[r?(0,E.jsx)(J.CheckIcon,{className:"size-3.5"}):(0,E.jsx)(J.CopyIcon,{className:"size-3.5"}),"Copy Markdown"]}),(0,E.jsx)("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(n)}`,className:"flex not-prose items-center gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",rel:"noreferrer noopener",children:"Ask ChatGPT"})]})}var $e=require("next/navigation"),ce=R(require("next/link")),j=require("lucide-react");var S=require("react/jsx-runtime");function Me(e){let r=[];for(let t of e)t.type==="page"?r.push({name:t.title,href:t.href,icon:t.icon}):t.type==="section"&&r.push(...Me(t.children));return r}function Ge(){let e=(0,$e.usePathname)(),{docstraConfig:r,sidebarItems:t}=f(),o=[];t&&t.length>0?o=Me(t):r?.sidebar?.links&&(o=r.sidebar.links.flatMap(c=>c.items));let a=o.findIndex(c=>c.href===e),n=a>0?o[a-1]:null,s=a<o.length-1?o[a+1]:null;return(0,S.jsxs)("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[n?(0,S.jsxs)(ce.default,{href:n.href,className:"flex flex-col not-prose items-start gap-2 border border-gray-200 hover:bg-gray-50 py-3 md:min-w-62 pl-4 pr-10 rounded-lg text-sm",children:[(0,S.jsx)("span",{className:"text-gray-500",children:"Previous"}),(0,S.jsxs)("p",{className:"flex items-center font-medium",children:[(0,S.jsx)(j.ArrowLeftIcon,{className:"size-5 mr-2"}),n.name]})]}):(0,S.jsx)("div",{}),s?(0,S.jsxs)(ce.default,{href:s.href,className:"flex flex-col not-prose items-end gap-2 border border-gray-200 hover:bg-gray-50 py-3 pr-4 md:min-w-62 pl-10 rounded-lg text-sm",children:[(0,S.jsx)("span",{className:"text-gray-500",children:"Next"}),(0,S.jsxs)("p",{className:"flex items-center font-medium",children:[s.name,(0,S.jsx)(j.ArrowRightIcon,{className:"size-5 ml-2"})]})]}):(0,S.jsx)("div",{})]})}var x=require("react/jsx-runtime");function et({children:e}){let{docstraConfig:r,page:t}=f();return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(re,{}),(0,x.jsxs)("main",{className:"flex-1 px-4 md:px-8 md:pl-80 pt-28 py-10 prose max-w-none",children:[(0,x.jsx)(De,{}),(0,x.jsx)("h1",{className:"text-3xl font-bold",children:t?.metadata?.title}),(0,x.jsx)("p",{className:"my-4 text-gray-500",children:t?.metadata?.description}),(0,x.jsx)(Be,{}),(0,x.jsx)("hr",{className:"my-10 border-gray-200"}),e,r?.feedback?.enabled&&(0,x.jsx)(Te,{}),(0,x.jsx)(ze,{}),(0,x.jsx)(Ge,{})]}),(0,x.jsx)(Pe,{})]})}var G=require("lucide-react"),ee=require("prism-react-renderer"),Fe=require("react");var Ue=require("react-toast-msg"),u=require("react/jsx-runtime"),me={npm:"npm install",pnpm:"pnpm add",yarn:"yarn add",bun:"bun add"};function tt(e){let{filename:r,copyable:t,children:o,className:a}=e,{packageManager:n,setPackageManager:s}=f(),c=!a?.includes("language-"),m=typeof o=="string"?o:o?.props?.children||"";if(c)return(0,u.jsx)("code",{className:"not-prose px-1 py-0.5 rounded border border-gray-200 bg-gray-50 text-gray-800 text-sm",children:m});let[y,i]=(0,Fe.useState)(!1),B=a?.match(/language-([\w-]+)/)?.[1]??"txt",C=B==="package-install",H=()=>{let D=C?`${me[n]} ${m.trim()}`:m.trim();navigator.clipboard.writeText(D),i(!0),Ue.toast.success("Code copied to clipboard"),setTimeout(()=>i(!1),2e3)};return(0,u.jsxs)("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200 mt-4 bg-white",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between bg-gray-50 border-b border-gray-200",children:[!C&&(0,u.jsx)("span",{className:"text-xs text-gray-400 px-4 py-3",children:r||B}),C&&(0,u.jsx)("div",{className:"flex items-center px-3",children:Object.keys(me).map(D=>(0,u.jsx)("button",{onClick:()=>s(D),className:`px-3 pb-2.5 pt-3 text-sm font-medium border-b-2 transition-all ${n===D?"border-gray-900 text-gray-900":"border-transparent text-gray-500 hover:text-gray-800"}`,children:D},D))}),t&&!C&&(0,u.jsx)("button",{onClick:H,className:"rounded-lg cursor-pointer p-2 m-2 text-gray-500 hover:bg-gray-200 transition",children:y?(0,u.jsx)(G.CheckIcon,{className:"size-4 text-green-600"}):(0,u.jsx)(G.CopyIcon,{className:"size-4"})})]}),(0,u.jsx)(ee.Highlight,{theme:ee.themes.vsLight,code:m.trim(),language:C?"bash":B,children:({tokens:D,getLineProps:te,getTokenProps:q})=>(0,u.jsxs)("pre",{className:`p-4 font-mono whitespace-pre overflow-x-auto text-sm leading-relaxed ${t&&C?"flex items-center justify-between":""}`,children:[D.map((p,b)=>(0,u.jsxs)("div",{...te({line:p}),children:[!C&&(0,u.jsx)("span",{className:"text-gray-400 mr-4 select-none",children:b+1}),C&&(0,u.jsx)("span",{className:"mr-2",children:me[n]}),p.map((P,L)=>(0,u.jsx)("span",{...q({token:P})},L))]},b)),t&&C&&(0,u.jsx)("button",{onClick:H,className:"rounded-lg cursor-pointer p-2 text-gray-500 hover:bg-gray-100 transition",children:y?(0,u.jsx)(G.CheckIcon,{className:"size-4 text-green-600"}):(0,u.jsx)(G.CopyIcon,{className:"size-4"})})]})})]})}0&&(module.exports={DocstraBody,DocstraCodeBlock,DocstraHeader,DocstraLayout,DocstraProvider,useDocstra});
@@ -1 +1 @@
1
- "use client";import{createContext as Me,useContext as Ge,useState as K}from"react";import{ToastContainer as Fe}from"react-toast-msg";import{SearchIcon as Re}from"lucide-react";import{twMerge as Oe}from"tailwind-merge";import Pe from"clsx";function d(...e){return Oe(Pe(e))}import{useEffect as q,useMemo as Te,useState as j}from"react";import ze from"fuse.js";import Ee from"next/link";import{useRouter as Be}from"next/navigation";import{Fragment as $e,jsx as C,jsxs as G}from"react/jsx-runtime";function ee(){let{openSearchBox:e,setOpenSearchBox:r,page:t}=p(),[o,a]=j(""),[n,s]=j([]),l=Be();q(()=>{let i=g=>{g.ctrlKey&&g.key==="k"&&(g.preventDefault(),r(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let c=Te(()=>!t||t.length===0?null:new ze(t,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[t]);q(()=>{if(o&&c){let i=c.search(o);s(i.map(g=>g.item))}else o||s([])},[o,c]);let f=i=>{if(i.preventDefault(),o){let g=n[0];g&&(l.push(`/docs/${g.slug}`),a(""),r(!1))}};return q(()=>{let i=g=>{g.key==="Escape"&&(r(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),C("div",{onClick:()=>{r(!1),a("")},className:d("fixed inset-0 z-25 flex items-start justify-center bg-white/40 backdrop-blur-md opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),children:G("div",{onClick:i=>i.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:[C("form",{onSubmit:f,className:d("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md",o&&"rounded-b-none border-b-0"),children:e&&G($e,{children:[C(Re,{className:"size-5.5 mx-3 shrink-0"}),C("input",{className:"w-full bg-transparent h-full outline-none text-gray-400 placeholder:text-gray-400",type:"text",placeholder:"Search docs...",spellCheck:"false",autoFocus:!0,value:o,onChange:i=>a(i.target.value),name:"searchQuery",required:!0}),C("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),G("div",{className:d("max-h-70 overflow-x-hidden overflow-y-auto scrollbar-y w-full bg-white text-slate-700 flex flex-col",o&&"rounded-b-md border border-slate-200"),children:[n.map(i=>G(Ee,{href:`/docs/${i.slug==="index"?"":i.slug}`,onClick:()=>{r(!1),a("")},className:"w-full hover:bg-gray-100/70 border-b border-slate-200 transition-all py-4 px-4 last:mb-2",children:[C("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),C("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),o&&n.length===0&&C("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}import{jsx as te,jsxs as Ue}from"react/jsx-runtime";var re=Me(null);function Ft({children:e,docstraConfig:r,page:t,sidebarItems:o}){let[a,n]=K(!1),[s,l]=K(!1),[c,f]=K("npm");return Ue(re.Provider,{value:{openSidebar:a,setOpenSidebar:n,docstraConfig:r,openSearchBox:s,setOpenSearchBox:l,packageManager:c,setPackageManager:f,sidebarItems:o,page:t},children:[te(Fe,{}),te(ee,{}),e]})}function p(){let e=Ge(re);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}import{TextAlignEnd as Ae,XIcon as He}from"lucide-react";import{useEffect as qe}from"react";import V from"next/link";import{jsx as k,jsxs as oe}from"react/jsx-runtime";function ae(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t}=p(),o="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return qe(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),oe("header",{className:"fixed w-full top-0 z-10 text-sm flex items-center justify-between border-b border-gray-100 h-18 px-4 md:px-6 bg-white",children:[k(V,{href:t.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:k("img",{src:t.navbar?.logo?.src||"/logo.png",alt:t.navbar?.logo?.alt||"Logo",className:d("h-9.5 w-auto",t.navbar?.logo?.className)})}),oe("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[t.navbar?.links?.map(a=>k(V,{href:a.href,className:"px-6 hover:text-gray-600",children:a.name},a.name)),k(V,{href:o||"https://github.com/sudhucodes/docstra",children:k("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:k("path",{d:"M12 .3a12 12 0 0 0-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.08 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 0 1 1.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0 0 12 .3"})})})]}),k("button",{onClick:()=>r(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?k(He,{className:"size-6.5"}):k(Ae,{className:"size-6.5"})})]})}import{ChevronDownIcon as Ve,SearchIcon as Ye}from"lucide-react";import{usePathname as Qe}from"next/navigation";import*as Ke from"lucide-react";function Y(e){if(e)return Ke[e]}import ne from"next/link";import{useState as Q}from"react";import{Fragment as Xe,jsx as b,jsxs as I}from"react/jsx-runtime";function _e({item:e,pathname:r,openSidebar:t,setOpenSidebar:o}){let[a,n]=Q(e.defaultOpen??!0),s=e.collapsible??!0,l=Y(e.icon);return I("div",{children:[I(ne,{href:e.href,onClick:()=>s&&n(c=>!c),className:"w-full flex items-center justify-between gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",children:[I("span",{className:"flex items-center gap-2",children:[l&&b(l,{className:"size-4 text-gray-400"}),e.title]}),s&&b(Ve,{className:d("size-4 text-black/50 transition-transform duration-300",a&&"rotate-180")})]}),(!s||a)&&b("ul",{className:"mb-4 ml-2",children:e.children.map((c,f)=>b(se,{item:c,pathname:r,openSidebar:t,setOpenSidebar:o},`${c.type}-${f}`))})]})}function We({item:e,pathname:r,openSidebar:t,setOpenSidebar:o}){let a=Y(e.icon);return I(ne,{href:e.href,onClick:()=>t&&o(!1),className:d("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",r===e.href&&"bg-gray-100 text-gray-800"),children:[a&&b(a,{className:"size-4"}),b("span",{children:e.title})]})}function se({item:e,pathname:r,openSidebar:t,setOpenSidebar:o}){switch(e.type){case"page":return b(We,{item:e,pathname:r,openSidebar:t,setOpenSidebar:o});case"section":return b(_e,{item:e,pathname:r,openSidebar:t,setOpenSidebar:o});default:return null}}function ie({sidebarItems:e}){let[r,t]=Q(!1),[o,a]=Q(!1),n=Qe();return I(Xe,{children:[b("div",{className:d("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",r&&"opacity-100 pointer-events-auto"),onClick:()=>t(!1)}),I("aside",{className:d("fixed md:top-18 h-[calc(100svh-72px)] scrollbar-y w-screen max-md:rounded-t-lg z-21 md:w-72 pb-10 text-base md:text-sm shrink-0 border-r border-gray-200 p-4 max-md:fixed bg-white overflow-y-auto transition-all duration-300",r?"top-32":"top-full"),children:[I("div",{className:"flex items-center select-none gap-2 cursor-pointer mt-6 mb-4 p-2.5 text-gray-500 border border-gray-200 rounded-lg hover:bg-gray-50",onClick:()=>{t(r&&!1),a(!0)},children:[b(Ye,{className:"size-4.5"}),b("p",{children:"Search"}),I("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[b("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),b("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),e.map((s,l)=>b(se,{item:s,pathname:n,openSidebar:r,setOpenSidebar:t},`${s.type}-${l}`))]})]})}import{jsx as Ze,jsxs as Je}from"react/jsx-runtime";function nr({children:e,sidebarItems:r}){return Je("div",{className:"min-h-screen flex bg-white w-full",children:[Ze(ie,{sidebarItems:r}),e]})}import{usePathname as je}from"next/navigation";import{ChevronRight as et}from"lucide-react";import le from"next/link";import{jsx as R,jsxs as ce}from"react/jsx-runtime";function me(){let r=je().split("/").filter(Boolean),t=r.map((o,a)=>{let n="/"+r.slice(0,a+1).join("/"),s=o.replace(/-/g," ").replace(/\b\w/g,l=>l.toUpperCase());return{href:n,title:s}});return R("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500 not-prose",children:ce("ol",{className:"flex items-center space-x-2",children:[R("li",{children:R(le,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),t.map((o,a)=>{let n=a===t.length-1;return ce("li",{className:"flex items-center space-x-2",children:[R(et,{className:"w-4 h-4 text-gray-400"}),n?R("span",{className:"text-gray-600 font-medium",children:o.title}):R(le,{href:o.href,className:"hover:text-gray-700 font-medium transition-colors",children:o.title})]},o.href)})]})})}import{ArrowUpCircleIcon as tt,SquareArrowOutUpRightIcon as rt,TextAlignStartIcon as ot}from"lucide-react";import{usePathname as at}from"next/navigation";import{useEffect as z,useRef as de,useState as F}from"react";import{jsx as D,jsxs as E}from"react/jsx-runtime";function ue(){let[e,r]=F(null),[t,o]=F("down"),[a,n]=F(!1),[s,l]=F(!1),{docstraConfig:c,page:f}=p(),i=f?.path,g=f?.tableOfContents||[],O=de(0),y=de(null),$=at(),H=`${"https://github.com/"+c?.editOnGithub?.owner+"/"+c?.editOnGithub?.repo}/edit/main/${c?.editOnGithub?.path}/${i}`;z(()=>{let m=()=>{let u=window.scrollY;o(u>O.current?"down":"up"),n(u>100),O.current=u};return window.addEventListener("scroll",m),()=>window.removeEventListener("scroll",m)},[]),z(()=>{let m=document.querySelectorAll("h2[id], h3[id]"),u=new IntersectionObserver(S=>{if(s)return;let N=S.filter(P=>P.isIntersecting).sort((P,Le)=>P.boundingClientRect.top-Le.boundingClientRect.top);if(N.length>0){let P=t==="down"?N[0].target.id:N[N.length-1].target.id;r(P)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return m.forEach(S=>u.observe(S)),y.current=u,()=>u.disconnect()},[$,t,s]),z(()=>{!(window.scrollY>100)&&r(g[0]?.id)},[g]),z(()=>{if(!e)return;let m=document.querySelector(".toc-scroll-container");if(!m)return;let u=m.querySelector(`a[href="#${e}"]`);if(!u)return;let S=m.getBoundingClientRect(),N=u.getBoundingClientRect();(N.top<S.top||N.bottom>S.bottom)&&u.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),z(()=>{if(!s)return;let m=setTimeout(()=>l(!1),800);return()=>clearTimeout(m)},[s]);let M=m=>{r(m),l(!0)};return E("aside",{className:"sticky top-18 text-sm hidden xl:block text-gray-500 shrink-0 h-[calc(100svh-72px)] w-64 border-l border-gray-200 p-6 overflow-y-auto",children:[E("p",{className:"flex items-center gap-2 mb-5",children:[D(ot,{className:"size-4"}),"On this page"]}),D("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:g.map(m=>E("li",{children:[D(pe,{heading:m,activeId:e,handleClick:M}),m.children.map(u=>D(pe,{heading:u,activeId:e,handleClick:M,className:"pl-8"},u.id))]},m.id))}),D("hr",{className:"my-6 border-gray-200"}),c.editOnGithub&&E("a",{href:H,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",D(rt,{className:"size-4"})]}),a&&E("button",{onClick:()=>scrollTo({top:0,behavior:"smooth"}),className:"flex items-center cursor-pointer gap-2 mt-3 text-gray-400 hover:text-gray-700 transition",children:["Scroll to top",D(tt,{className:"size-4"})]})]})}function pe({heading:e,activeId:r,handleClick:t,className:o}){return D("a",{href:`#${e.id}`,className:d("border-l border-gray-200 block py-1.5 pl-4 transition-colors",o,{"border-gray-800 text-gray-900 font-medium":r===e.id,"hover:text-gray-800 hover:border-gray-400":r!==e.id}),onClick:()=>t(e.id),children:e.text})}import{useState as U}from"react";import{ThumbsUp as st,ThumbsDown as it}from"lucide-react";import{jsx as _,jsxs as fe}from"react/jsx-runtime";function W({label:e,type:r,placeholder:t="",id:o,required:a=!1,onChange:n,value:s,readOnly:l=!1,className:c="",optional:f=!1}){return fe("div",{className:d("flex flex-col mt-4 w-full",c),children:[e&&fe("label",{htmlFor:o,className:"font-medium w-max cursor-pointer",children:[e,f&&_("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),r==="textarea"?_("textarea",{id:o,name:o,className:d("mt-2 w-full p-3 border border-gray-300 resize-none not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",c),placeholder:t,required:a,onChange:n,rows:4,value:s,readOnly:l,maxLength:500}):_("input",{type:r,id:o,name:o,className:"mt-2 w-full h-12 px-3 border border-gray-300 not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",placeholder:t,required:a,onChange:n,value:s,readOnly:l,maxLength:500})]})}import{Loader2Icon as nt}from"lucide-react";import{jsx as ge}from"react/jsx-runtime";function X({label:e,loading:r,type:t="submit",className:o="",disabled:a=!1,onClick:n}){return ge("button",{type:t,disabled:a,className:d("relative w-full mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg",o),"aria-label":e,onClick:n,children:r?ge(nt,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}import{FormSyncButton as lt,FormSyncForm as ct}from"formsync";import{Fragment as be,jsx as x,jsxs as L}from"react/jsx-runtime";function he(){let[e,r]=U(null),{docstraConfig:t}=p(),[o,a]=U(""),[n,s]=U(!1),[l,c]=U(null),f="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return x("div",{className:"border-y border-gray-200 mt-10 py-10 space-y-4",children:n?L(be,{children:[x("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),x(X,{onClick:()=>{s(!1),r(null),a("")},label:"Submit Again",className:"w-max text-sm"})]}):L(be,{children:[x("p",{className:"font-medium",children:"How is this guide?"}),L("div",{className:"flex gap-2",children:[L("button",{onClick:()=>r("good"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="good"?"bg-green-100 text-green-600 border-green-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[x(st,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),L("button",{onClick:()=>r("bad"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="bad"?"bg-red-100 text-red-600 border-red-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[x(it,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&L(ct,{className:"flex flex-col gap-2",formId:t?.feedback?.formSyncFormID||"",onSuccess:i=>{s(!0),r(null),a("")},onSubmitError:i=>{c(i.message)},children:[x(W,{value:o,id:"message",onChange:i=>a(i.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),l&&x("p",{className:"text-red-500",children:l}),x("input",{type:"hidden",name:"opinion",value:e}),x("input",{type:"hidden",name:"page",value:window.location.href}),x("input",{type:"hidden",name:"_redirect",value:window.location.href}),x(lt,{className:"relative mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg w-max text-sm",children:"Submit"}),t?.feedback?.watermark!==!1&&L("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",x("a",{href:`https://www.formsync.app?utm_source=${f}`,className:"text-gray-800 not-prose",children:"FormSync"})]})]})]})})}import{jsxs as mt}from"react/jsx-runtime";function xe(){let{pageData:e}=p();if(!e?.data?.lastUpdated)return null;let r=new Date(e.data.lastUpdated).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"});return mt("p",{className:"text-sm text-gray-500",children:["Last updated on ",r]})}import{CheckIcon as dt,CopyIcon as pt}from"lucide-react";import{useEffect as ut,useState as ye}from"react";import{jsx as Z,jsxs as ve}from"react/jsx-runtime";function we(){let{pageData:e}=p(),[r,t]=ye(!1),[o,a]=ye(null);ut(()=>{a(window.location.href)},[]);let n=`Read from this URL: ${o} and explain it to me.`;return ve("div",{className:"flex items-center gap-3 mt-6",children:[ve("button",{title:"Copy Markdown",onClick:()=>{navigator.clipboard.writeText(e?.data.raw||""),t(!0),setTimeout(()=>t(!1),3e3)},className:"flex items-center cursor-pointer gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",children:[r?Z(dt,{className:"size-3.5"}):Z(pt,{className:"size-3.5"}),"Copy Markdown"]}),Z("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(n)}`,className:"flex not-prose items-center gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",rel:"noreferrer noopener",children:"Ask ChatGPT"})]})}import{usePathname as ft}from"next/navigation";import Ne from"next/link";import{ArrowLeftIcon as gt,ArrowRightIcon as bt}from"lucide-react";import{jsx as T,jsxs as B}from"react/jsx-runtime";function ke(e){let r=[];for(let t of e)t.type==="page"?r.push({name:t.title,href:t.href,icon:t.icon}):t.type==="section"&&r.push(...ke(t.children));return r}function Se(){let e=ft(),{docstraConfig:r,sidebarItems:t}=p(),o=[];t&&t.length>0?o=ke(t):r?.sidebar?.links&&(o=r.sidebar.links.flatMap(l=>l.items));let a=o.findIndex(l=>l.href===e),n=a>0?o[a-1]:null,s=a<o.length-1?o[a+1]:null;return B("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[n?B(Ne,{href:n.href,className:"flex flex-col not-prose items-start gap-2 border border-gray-200 hover:bg-gray-50 py-3 md:min-w-62 pl-4 pr-10 rounded-lg text-sm",children:[T("span",{className:"text-gray-500",children:"Previous"}),B("p",{className:"flex items-center font-medium",children:[T(gt,{className:"size-5 mr-2"}),n.name]})]}):T("div",{}),s?B(Ne,{href:s.href,className:"flex flex-col not-prose items-end gap-2 border border-gray-200 hover:bg-gray-50 py-3 pr-4 md:min-w-62 pl-10 rounded-lg text-sm",children:[T("span",{className:"text-gray-500",children:"Next"}),B("p",{className:"flex items-center font-medium",children:[s.name,T(bt,{className:"size-5 ml-2"})]})]}):T("div",{})]})}import{Fragment as ht,jsx as v,jsxs as Ce}from"react/jsx-runtime";function oo({children:e}){let{docstraConfig:r,page:t}=p();return Ce(ht,{children:[v(ae,{}),Ce("main",{className:"flex-1 px-4 md:px-8 md:pl-80 pt-28 py-10 prose max-w-none",children:[v(me,{}),v("h1",{className:"text-3xl font-bold",children:t?.metadata?.title}),v("p",{className:"my-4 text-gray-500",children:t?.metadata?.description}),v(we,{}),v("hr",{className:"my-10 border-gray-200"}),e,r?.feedback?.enabled&&v(he,{}),v(xe,{}),v(Se,{})]}),v(ue,{})]})}import{CheckIcon as Ie,CopyIcon as De}from"lucide-react";import{Highlight as xt,themes as yt}from"prism-react-renderer";import{useState as vt}from"react";import{toast as wt}from"react-toast-msg";import{jsx as h,jsxs as A}from"react/jsx-runtime";var J={npm:"npm install",pnpm:"pnpm add",yarn:"yarn add",bun:"bun add"};function po(e){let{filename:r,copyable:t,children:o,className:a}=e,{packageManager:n,setPackageManager:s}=p(),l=!a?.includes("language-"),c=typeof o=="string"?o:o?.props?.children||"";if(l)return h("code",{className:"not-prose px-1 py-0.5 rounded border border-gray-200 bg-gray-50 text-gray-800 text-sm",children:c});let[f,i]=vt(!1),O=a?.match(/language-([\w-]+)/)?.[1]??"txt",y=O==="package-install",$=()=>{let w=y?`${J[n]} ${c.trim()}`:c.trim();navigator.clipboard.writeText(w),i(!0),wt.success("Code copied to clipboard"),setTimeout(()=>i(!1),2e3)};return A("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200 mt-4 bg-white",children:[A("div",{className:"flex items-center justify-between bg-gray-50 border-b border-gray-200",children:[!y&&h("span",{className:"text-xs text-gray-400 px-4 py-3",children:r||O}),y&&h("div",{className:"flex items-center px-3",children:Object.keys(J).map(w=>h("button",{onClick:()=>s(w),className:`px-3 pb-2.5 pt-3 text-sm font-medium border-b-2 transition-all ${n===w?"border-gray-900 text-gray-900":"border-transparent text-gray-500 hover:text-gray-800"}`,children:w},w))}),t&&!y&&h("button",{onClick:$,className:"rounded-lg cursor-pointer p-2 m-2 text-gray-500 hover:bg-gray-200 transition",children:f?h(Ie,{className:"size-4 text-green-600"}):h(De,{className:"size-4"})})]}),h(xt,{theme:yt.vsLight,code:c.trim(),language:y?"bash":O,children:({tokens:w,getLineProps:H,getTokenProps:M})=>A("pre",{className:`p-4 font-mono whitespace-pre overflow-x-auto text-sm leading-relaxed ${t&&y?"flex items-center justify-between":""}`,children:[w.map((m,u)=>A("div",{...H({line:m}),children:[!y&&h("span",{className:"text-gray-400 mr-4 select-none",children:u+1}),y&&h("span",{className:"mr-2",children:J[n]}),m.map((S,N)=>h("span",{...M({token:S})},N))]},u)),t&&y&&h("button",{onClick:$,className:"rounded-lg cursor-pointer p-2 text-gray-500 hover:bg-gray-100 transition",children:f?h(Ie,{className:"size-4 text-green-600"}):h(De,{className:"size-4"})})]})})]})}export{oo as DocstraBody,po as DocstraCodeBlock,ae as DocstraHeader,nr as DocstraLayout,Ft as DocstraProvider,p as useDocstra};
1
+ "use client";import{createContext as Me,useContext as Ge,useState as _}from"react";import{ToastContainer as Fe}from"react-toast-msg";import{SearchIcon as Re}from"lucide-react";import{twMerge as Oe}from"tailwind-merge";import Pe from"clsx";function d(...e){return Oe(Pe(e))}import{useEffect as q,useMemo as Te,useState as j}from"react";import ze from"fuse.js";import Ee from"next/link";import{useRouter as Be}from"next/navigation";import{Fragment as $e,jsx as C,jsxs as G}from"react/jsx-runtime";function ee(){let{openSearchBox:e,setOpenSearchBox:r,page:t}=p(),[o,a]=j(""),[n,s]=j([]),l=Be();q(()=>{let i=g=>{g.ctrlKey&&g.key==="k"&&(g.preventDefault(),r(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let c=Te(()=>!t||t.length===0?null:new ze(t,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[t]);q(()=>{if(o&&c){let i=c.search(o);s(i.map(g=>g.item))}else o||s([])},[o,c]);let f=i=>{if(i.preventDefault(),o){let g=n[0];g&&(l.push(`/docs/${g.slug}`),a(""),r(!1))}};return q(()=>{let i=g=>{g.key==="Escape"&&(r(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),C("div",{onClick:()=>{r(!1),a("")},className:d("fixed inset-0 z-25 flex items-start justify-center bg-white/40 backdrop-blur-md opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),children:G("div",{onClick:i=>i.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:[C("form",{onSubmit:f,className:d("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md",o&&"rounded-b-none border-b-0"),children:e&&G($e,{children:[C(Re,{className:"size-5.5 mx-3 shrink-0"}),C("input",{className:"w-full bg-transparent h-full outline-none text-gray-400 placeholder:text-gray-400",type:"text",placeholder:"Search docs...",spellCheck:"false",autoFocus:!0,value:o,onChange:i=>a(i.target.value),name:"searchQuery",required:!0}),C("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),G("div",{className:d("max-h-70 overflow-x-hidden overflow-y-auto scrollbar-y w-full bg-white text-slate-700 flex flex-col",o&&"rounded-b-md border border-slate-200"),children:[n.map(i=>G(Ee,{href:`/docs/${i.slug==="index"?"":i.slug}`,onClick:()=>{r(!1),a("")},className:"w-full hover:bg-gray-100/70 border-b border-slate-200 transition-all py-4 px-4 last:mb-2",children:[C("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),C("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),o&&n.length===0&&C("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}import{jsx as te,jsxs as Ue}from"react/jsx-runtime";var re=Me(null);function Ft({children:e,docstraConfig:r,page:t,sidebarItems:o}){let[a,n]=_(!1),[s,l]=_(!1),[c,f]=_("npm");return Ue(re.Provider,{value:{openSidebar:a,setOpenSidebar:n,docstraConfig:r,openSearchBox:s,setOpenSearchBox:l,packageManager:c,setPackageManager:f,sidebarItems:o,page:t},children:[te(Fe,{}),te(ee,{}),e]})}function p(){let e=Ge(re);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}import{TextAlignEnd as Ae,XIcon as He}from"lucide-react";import{useEffect as qe}from"react";import K from"next/link";import{jsx as k,jsxs as oe}from"react/jsx-runtime";function ae(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t}=p(),o="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return qe(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),oe("header",{className:"fixed w-full top-0 z-10 text-sm flex items-center justify-between border-b border-gray-100 h-18 px-4 md:px-6 bg-white",children:[k(K,{href:t.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:k("img",{src:t.navbar?.logo?.src||"/logo.png",alt:t.navbar?.logo?.alt||"Logo",className:d("h-9.5 w-auto",t.navbar?.logo?.className)})}),oe("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[t.navbar?.links?.map(a=>k(K,{href:a.href,className:"px-6 hover:text-gray-600",children:a.name},a.name)),k(K,{href:o||"https://github.com/sudhucodes/docstra",children:k("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:k("path",{d:"M12 .3a12 12 0 0 0-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.08 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 0 1 1.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0 0 12 .3"})})})]}),k("button",{onClick:()=>r(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?k(He,{className:"size-6.5"}):k(Ae,{className:"size-6.5"})})]})}import{ChevronDownIcon as Ke,SearchIcon as Ve}from"lucide-react";import{usePathname as Ye}from"next/navigation";import*as _e from"lucide-react";function V(e){if(e)return _e[e]}import ne from"next/link";import{useState as Y}from"react";import{Fragment as Xe,jsx as b,jsxs as I}from"react/jsx-runtime";function Qe({item:e,pathname:r,openSidebar:t,setOpenSidebar:o}){let[a,n]=Y(e.defaultOpen??!0),s=e.collapsible??!0,l=V(e.icon);return I("div",{children:[I(ne,{href:e.href,onClick:()=>s&&n(c=>!c),className:"w-full flex items-center justify-between gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",children:[I("span",{className:"flex items-center gap-2",children:[l&&b(l,{className:"size-4 text-gray-400"}),e.nav_title?e.nav_title:e.title]}),s&&b(Ke,{className:d("size-4 text-black/50 transition-transform duration-300",a&&"rotate-180")})]}),(!s||a)&&b("ul",{className:"mb-4 ml-2",children:e.children.map((c,f)=>b(se,{item:c,pathname:r,openSidebar:t,setOpenSidebar:o},`${c.type}-${f}`))})]})}function We({item:e,pathname:r,openSidebar:t,setOpenSidebar:o}){let a=V(e.icon);return I(ne,{href:e.href,onClick:()=>t&&o(!1),className:d("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",r===e.href&&"bg-gray-100 text-gray-800"),children:[a&&b(a,{className:"size-4"}),b("span",{children:e.nav_title?e.nav_title:e.title})]})}function se({item:e,pathname:r,openSidebar:t,setOpenSidebar:o}){switch(e.type){case"page":return b(We,{item:e,pathname:r,openSidebar:t,setOpenSidebar:o});case"section":return b(Qe,{item:e,pathname:r,openSidebar:t,setOpenSidebar:o});default:return null}}function ie({sidebarItems:e}){let[r,t]=Y(!1),[o,a]=Y(!1),n=Ye();return I(Xe,{children:[b("div",{className:d("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",r&&"opacity-100 pointer-events-auto"),onClick:()=>t(!1)}),I("aside",{className:d("fixed md:top-18 h-[calc(100svh-72px)] scrollbar-y w-screen max-md:rounded-t-lg z-21 md:w-72 pb-10 text-base md:text-sm shrink-0 border-r border-gray-200 p-4 max-md:fixed bg-white overflow-y-auto transition-all duration-300",r?"top-32":"top-full"),children:[I("div",{className:"flex items-center select-none gap-2 cursor-pointer mt-6 mb-4 p-2.5 text-gray-500 border border-gray-200 rounded-lg hover:bg-gray-50",onClick:()=>{t(r&&!1),a(!0)},children:[b(Ve,{className:"size-4.5"}),b("p",{children:"Search"}),I("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[b("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),b("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),e.map((s,l)=>b(se,{item:s,pathname:n,openSidebar:r,setOpenSidebar:t},`${s.type}-${l}`))]})]})}import{jsx as Ze,jsxs as Je}from"react/jsx-runtime";function nr({children:e,sidebarItems:r}){return Je("div",{className:"min-h-screen flex bg-white w-full",children:[Ze(ie,{sidebarItems:r}),e]})}import{usePathname as je}from"next/navigation";import{ChevronRight as et}from"lucide-react";import le from"next/link";import{jsx as R,jsxs as ce}from"react/jsx-runtime";function me(){let r=je().split("/").filter(Boolean),t=r.map((o,a)=>{let n="/"+r.slice(0,a+1).join("/"),s=o.replace(/-/g," ").replace(/\b\w/g,l=>l.toUpperCase());return{href:n,title:s}});return R("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500 not-prose",children:ce("ol",{className:"flex items-center space-x-2",children:[R("li",{children:R(le,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),t.map((o,a)=>{let n=a===t.length-1;return ce("li",{className:"flex items-center space-x-2",children:[R(et,{className:"w-4 h-4 text-gray-400"}),n?R("span",{className:"text-gray-600 font-medium",children:o.title}):R(le,{href:o.href,className:"hover:text-gray-700 font-medium transition-colors",children:o.title})]},o.href)})]})})}import{ArrowUpCircleIcon as tt,SquareArrowOutUpRightIcon as rt,TextAlignStartIcon as ot}from"lucide-react";import{usePathname as at}from"next/navigation";import{useEffect as z,useRef as de,useState as F}from"react";import{jsx as D,jsxs as E}from"react/jsx-runtime";function ue(){let[e,r]=F(null),[t,o]=F("down"),[a,n]=F(!1),[s,l]=F(!1),{docstraConfig:c,page:f}=p(),i=f?.path,g=f?.tableOfContents||[],O=de(0),y=de(null),$=at(),H=`${"https://github.com/"+c?.editOnGithub?.owner+"/"+c?.editOnGithub?.repo}/edit/main/${c?.editOnGithub?.path}/${i}`;z(()=>{let m=()=>{let u=window.scrollY;o(u>O.current?"down":"up"),n(u>100),O.current=u};return window.addEventListener("scroll",m),()=>window.removeEventListener("scroll",m)},[]),z(()=>{let m=document.querySelectorAll("h2[id], h3[id]"),u=new IntersectionObserver(S=>{if(s)return;let N=S.filter(P=>P.isIntersecting).sort((P,Le)=>P.boundingClientRect.top-Le.boundingClientRect.top);if(N.length>0){let P=t==="down"?N[0].target.id:N[N.length-1].target.id;r(P)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return m.forEach(S=>u.observe(S)),y.current=u,()=>u.disconnect()},[$,t,s]),z(()=>{!(window.scrollY>100)&&r(g[0]?.id)},[g]),z(()=>{if(!e)return;let m=document.querySelector(".toc-scroll-container");if(!m)return;let u=m.querySelector(`a[href="#${e}"]`);if(!u)return;let S=m.getBoundingClientRect(),N=u.getBoundingClientRect();(N.top<S.top||N.bottom>S.bottom)&&u.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),z(()=>{if(!s)return;let m=setTimeout(()=>l(!1),800);return()=>clearTimeout(m)},[s]);let M=m=>{r(m),l(!0)};return E("aside",{className:"sticky top-18 text-sm hidden xl:block text-gray-500 shrink-0 h-[calc(100svh-72px)] w-64 border-l border-gray-200 p-6 overflow-y-auto",children:[E("p",{className:"flex items-center gap-2 mb-5",children:[D(ot,{className:"size-4"}),"On this page"]}),D("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:g.map(m=>E("li",{children:[D(pe,{heading:m,activeId:e,handleClick:M}),m.children.map(u=>D(pe,{heading:u,activeId:e,handleClick:M,className:"pl-8"},u.id))]},m.id))}),D("hr",{className:"my-6 border-gray-200"}),c.editOnGithub&&E("a",{href:H,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",D(rt,{className:"size-4"})]}),a&&E("button",{onClick:()=>scrollTo({top:0,behavior:"smooth"}),className:"flex items-center cursor-pointer gap-2 mt-3 text-gray-400 hover:text-gray-700 transition",children:["Scroll to top",D(tt,{className:"size-4"})]})]})}function pe({heading:e,activeId:r,handleClick:t,className:o}){return D("a",{href:`#${e.id}`,className:d("border-l border-gray-200 block py-1.5 pl-4 transition-colors",o,{"border-gray-800 text-gray-900 font-medium":r===e.id,"hover:text-gray-800 hover:border-gray-400":r!==e.id}),onClick:()=>t(e.id),children:e.text})}import{useState as U}from"react";import{ThumbsUp as st,ThumbsDown as it}from"lucide-react";import{jsx as Q,jsxs as fe}from"react/jsx-runtime";function W({label:e,type:r,placeholder:t="",id:o,required:a=!1,onChange:n,value:s,readOnly:l=!1,className:c="",optional:f=!1}){return fe("div",{className:d("flex flex-col mt-4 w-full",c),children:[e&&fe("label",{htmlFor:o,className:"font-medium w-max cursor-pointer",children:[e,f&&Q("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),r==="textarea"?Q("textarea",{id:o,name:o,className:d("mt-2 w-full p-3 border border-gray-300 resize-none not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",c),placeholder:t,required:a,onChange:n,rows:4,value:s,readOnly:l,maxLength:500}):Q("input",{type:r,id:o,name:o,className:"mt-2 w-full h-12 px-3 border border-gray-300 not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",placeholder:t,required:a,onChange:n,value:s,readOnly:l,maxLength:500})]})}import{Loader2Icon as nt}from"lucide-react";import{jsx as ge}from"react/jsx-runtime";function X({label:e,loading:r,type:t="submit",className:o="",disabled:a=!1,onClick:n}){return ge("button",{type:t,disabled:a,className:d("relative w-full mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg",o),"aria-label":e,onClick:n,children:r?ge(nt,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}import{FormSyncButton as lt,FormSyncForm as ct}from"formsync";import{Fragment as be,jsx as x,jsxs as L}from"react/jsx-runtime";function he(){let[e,r]=U(null),{docstraConfig:t}=p(),[o,a]=U(""),[n,s]=U(!1),[l,c]=U(null),f="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return x("div",{className:"border-y border-gray-200 mt-10 py-10 space-y-4",children:n?L(be,{children:[x("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),x(X,{onClick:()=>{s(!1),r(null),a("")},label:"Submit Again",className:"w-max text-sm"})]}):L(be,{children:[x("p",{className:"font-medium",children:"How is this guide?"}),L("div",{className:"flex gap-2",children:[L("button",{onClick:()=>r("good"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="good"?"bg-green-100 text-green-600 border-green-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[x(st,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),L("button",{onClick:()=>r("bad"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="bad"?"bg-red-100 text-red-600 border-red-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[x(it,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&L(ct,{className:"flex flex-col gap-2",formId:t?.feedback?.formSyncFormID||"",onSuccess:i=>{s(!0),r(null),a("")},onSubmitError:i=>{c(i.message)},children:[x(W,{value:o,id:"message",onChange:i=>a(i.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),l&&x("p",{className:"text-red-500",children:l}),x("input",{type:"hidden",name:"opinion",value:e}),x("input",{type:"hidden",name:"page",value:window.location.href}),x("input",{type:"hidden",name:"_redirect",value:window.location.href}),x(lt,{className:"relative mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg w-max text-sm",children:"Submit"}),t?.feedback?.watermark!==!1&&L("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",x("a",{href:`https://www.formsync.app?utm_source=${f}`,className:"text-gray-800 not-prose",children:"FormSync"})]})]})]})})}import{jsxs as mt}from"react/jsx-runtime";function xe(){let{pageData:e}=p();if(!e?.data?.lastUpdated)return null;let r=new Date(e.data.lastUpdated).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"});return mt("p",{className:"text-sm text-gray-500",children:["Last updated on ",r]})}import{CheckIcon as dt,CopyIcon as pt}from"lucide-react";import{useEffect as ut,useState as ye}from"react";import{jsx as Z,jsxs as ve}from"react/jsx-runtime";function we(){let{pageData:e}=p(),[r,t]=ye(!1),[o,a]=ye(null);ut(()=>{a(window.location.href)},[]);let n=`Read from this URL: ${o} and explain it to me.`;return ve("div",{className:"flex items-center gap-3 mt-6",children:[ve("button",{title:"Copy Markdown",onClick:()=>{navigator.clipboard.writeText(e?.data.raw||""),t(!0),setTimeout(()=>t(!1),3e3)},className:"flex items-center cursor-pointer gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",children:[r?Z(dt,{className:"size-3.5"}):Z(pt,{className:"size-3.5"}),"Copy Markdown"]}),Z("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(n)}`,className:"flex not-prose items-center gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",rel:"noreferrer noopener",children:"Ask ChatGPT"})]})}import{usePathname as ft}from"next/navigation";import Ne from"next/link";import{ArrowLeftIcon as gt,ArrowRightIcon as bt}from"lucide-react";import{jsx as T,jsxs as B}from"react/jsx-runtime";function ke(e){let r=[];for(let t of e)t.type==="page"?r.push({name:t.title,href:t.href,icon:t.icon}):t.type==="section"&&r.push(...ke(t.children));return r}function Se(){let e=ft(),{docstraConfig:r,sidebarItems:t}=p(),o=[];t&&t.length>0?o=ke(t):r?.sidebar?.links&&(o=r.sidebar.links.flatMap(l=>l.items));let a=o.findIndex(l=>l.href===e),n=a>0?o[a-1]:null,s=a<o.length-1?o[a+1]:null;return B("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[n?B(Ne,{href:n.href,className:"flex flex-col not-prose items-start gap-2 border border-gray-200 hover:bg-gray-50 py-3 md:min-w-62 pl-4 pr-10 rounded-lg text-sm",children:[T("span",{className:"text-gray-500",children:"Previous"}),B("p",{className:"flex items-center font-medium",children:[T(gt,{className:"size-5 mr-2"}),n.name]})]}):T("div",{}),s?B(Ne,{href:s.href,className:"flex flex-col not-prose items-end gap-2 border border-gray-200 hover:bg-gray-50 py-3 pr-4 md:min-w-62 pl-10 rounded-lg text-sm",children:[T("span",{className:"text-gray-500",children:"Next"}),B("p",{className:"flex items-center font-medium",children:[s.name,T(bt,{className:"size-5 ml-2"})]})]}):T("div",{})]})}import{Fragment as ht,jsx as v,jsxs as Ce}from"react/jsx-runtime";function oo({children:e}){let{docstraConfig:r,page:t}=p();return Ce(ht,{children:[v(ae,{}),Ce("main",{className:"flex-1 px-4 md:px-8 md:pl-80 pt-28 py-10 prose max-w-none",children:[v(me,{}),v("h1",{className:"text-3xl font-bold",children:t?.metadata?.title}),v("p",{className:"my-4 text-gray-500",children:t?.metadata?.description}),v(we,{}),v("hr",{className:"my-10 border-gray-200"}),e,r?.feedback?.enabled&&v(he,{}),v(xe,{}),v(Se,{})]}),v(ue,{})]})}import{CheckIcon as Ie,CopyIcon as De}from"lucide-react";import{Highlight as xt,themes as yt}from"prism-react-renderer";import{useState as vt}from"react";import{toast as wt}from"react-toast-msg";import{jsx as h,jsxs as A}from"react/jsx-runtime";var J={npm:"npm install",pnpm:"pnpm add",yarn:"yarn add",bun:"bun add"};function po(e){let{filename:r,copyable:t,children:o,className:a}=e,{packageManager:n,setPackageManager:s}=p(),l=!a?.includes("language-"),c=typeof o=="string"?o:o?.props?.children||"";if(l)return h("code",{className:"not-prose px-1 py-0.5 rounded border border-gray-200 bg-gray-50 text-gray-800 text-sm",children:c});let[f,i]=vt(!1),O=a?.match(/language-([\w-]+)/)?.[1]??"txt",y=O==="package-install",$=()=>{let w=y?`${J[n]} ${c.trim()}`:c.trim();navigator.clipboard.writeText(w),i(!0),wt.success("Code copied to clipboard"),setTimeout(()=>i(!1),2e3)};return A("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200 mt-4 bg-white",children:[A("div",{className:"flex items-center justify-between bg-gray-50 border-b border-gray-200",children:[!y&&h("span",{className:"text-xs text-gray-400 px-4 py-3",children:r||O}),y&&h("div",{className:"flex items-center px-3",children:Object.keys(J).map(w=>h("button",{onClick:()=>s(w),className:`px-3 pb-2.5 pt-3 text-sm font-medium border-b-2 transition-all ${n===w?"border-gray-900 text-gray-900":"border-transparent text-gray-500 hover:text-gray-800"}`,children:w},w))}),t&&!y&&h("button",{onClick:$,className:"rounded-lg cursor-pointer p-2 m-2 text-gray-500 hover:bg-gray-200 transition",children:f?h(Ie,{className:"size-4 text-green-600"}):h(De,{className:"size-4"})})]}),h(xt,{theme:yt.vsLight,code:c.trim(),language:y?"bash":O,children:({tokens:w,getLineProps:H,getTokenProps:M})=>A("pre",{className:`p-4 font-mono whitespace-pre overflow-x-auto text-sm leading-relaxed ${t&&y?"flex items-center justify-between":""}`,children:[w.map((m,u)=>A("div",{...H({line:m}),children:[!y&&h("span",{className:"text-gray-400 mr-4 select-none",children:u+1}),y&&h("span",{className:"mr-2",children:J[n]}),m.map((S,N)=>h("span",{...M({token:S})},N))]},u)),t&&y&&h("button",{onClick:$,className:"rounded-lg cursor-pointer p-2 text-gray-500 hover:bg-gray-100 transition",children:f?h(Ie,{className:"size-4 text-green-600"}):h(De,{className:"size-4"})})]})})]})}export{oo as DocstraBody,po as DocstraCodeBlock,ae as DocstraHeader,nr as DocstraLayout,Ft as DocstraProvider,p as useDocstra};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docstra",
3
- "version": "1.9.9-next.5",
3
+ "version": "1.9.9-next.6",
4
4
  "description": "The Modern Documentation Framework for Next.js",
5
5
  "files": [
6
6
  "dist"
@@ -41,7 +41,7 @@
41
41
  "prism-react-renderer": "^2.4.1",
42
42
  "react-toast-msg": "^2.5.5",
43
43
  "tailwind-merge": "^3.4.0",
44
- "docstra-mdx": "0.0.3"
44
+ "docstra-mdx": "0.0.4"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "next": ">=16.0.0",