canofold 0.2.0

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.
@@ -0,0 +1,664 @@
1
+ import{a as H,b as B,c as yt,d as F,e as bt,f as _,g as wt,h as Pt,i as St,k as Et}from"./chunk-4E7M3CIK.js";import{a as V,b as g,d as kt,e as vt}from"./chunk-ENPRUF6E.js";import{a as xt,b as Ct,c as Mt,d as Dt,e as Nt,f as At}from"./chunk-OATSOVSV.js";import{a as ht,c as j,j as gt}from"./chunk-4OALGQQB.js";import{a as Z}from"./chunk-M6T5RSNJ.js";import{a as q}from"./chunk-3TIVCYR7.js";import{b as G}from"./chunk-EAYVCA3Z.js";import{a as X,b as $,c as ee,d as K,e as R,f as ft,h as T}from"./chunk-JK7ZNBUA.js";import{a as s}from"./chunk-AYDF3IFZ.js";import{randomUUID as Ln}from"crypto";import{mkdir as Rn,rename as Me,rm as pe,writeFile as Tn}from"fs/promises";import{basename as nr,dirname as lt,join as ct,relative as On,resolve as $n}from"path";import{mkdir as Ee,open as cr,rm as dr,writeFile as Ae}from"fs/promises";import{dirname as ur,join as O,posix as Tt}from"path";import{analyzeMarkdown as Lt}from"@canofold/markdown/server/analyze";function Rt({description:e,body:t}){if(e.trim())return e.trim();let o=t.split(/\n\n+/).find(r=>{let a=r.trim();if(!a)return!1;let i=Lt(a);return i.text&&i.headings.length===0});return o?Lt(o.trim()).text:""}s(Rt,"createDeterministicSummary");var pr=1;function Ot(e){return e.replace(/\r?\n/g," ").replace(/([\\[\]])/g,"\\$1")}s(Ot,"markdownLinkLabel");function $t(e,t){let o=`${t.routePath}index.md`;return{title:t.title,description:t.description,routePath:g(e,t.routePath),markdownPath:g(e,o),version:t.version,locale:t.locale,status:t.status,tags:Array.isArray(t.frontmatter.tags)?t.frontmatter.tags.filter(r=>typeof r=="string"):[],owner:typeof t.frontmatter.owner=="string"?t.frontmatter.owner:void 0,headings:t.headings,lastUpdated:t.lastUpdated,frontmatter:yt(t.frontmatter)}}s($t,"pageMetadata");async function fe(e,t){await Ee(ur(e),{recursive:!0});let o=await cr(e,"w");try{for await(let r of t)await o.write(r)}finally{await o.close()}}s(fe,"writePieces");async function Ne(e,t,o){async function*r(){yield`{"${t}":[`;let a=!0;for(let i of o)yield`${a?"":","}
2
+ ${JSON.stringify(i,null,2)}`,a=!1;yield`${a?"":`
3
+ `}]}
4
+ `}s(r,"pieces"),await fe(e,r())}s(Ne,"writeJsonArray");function mr(e,t){return t.pages.filter(o=>o.ai&&(e.ai.versions==="all"||o.version===t.currentVersion))}s(mr,"selectedPages");function fr(e){if(e==='"'||e==="\\")return 2;let t=e.codePointAt(0)??0;return t===8||t===9||t===10||t===12||t===13?2:t<32?6:Buffer.byteLength(e)}s(fr,"jsonEscapedCharacterBytes");function hr(e,t,o){let r=Buffer.byteLength(JSON.stringify({...e,part:999999999,parts:999999999,content:""})+`
5
+ `),a=o-r;if(a<1)throw new Error(`AI chunkSizeBytes ${o} is too small for page metadata`);let i=[],l=0,n=0,d=0;for(let c of t){let p=fr(c);n>l&&d+p>a&&(i.push(t.slice(l,n)),l=n,d=0),n+=c.length,d+=p}i.push(t.slice(l,n));let u=i.map((c,p)=>({...e,part:p+1,parts:i.length,content:c}));for(let c of u)if(Buffer.byteLength(JSON.stringify(c)+`
6
+ `)>o)throw new Error(`Unable to keep AI content record within ${o} bytes: ${e.routePath}`);return u}s(hr,"splitContentRecord");async function gr(e,t,o,r,a){let i=Tt.join("ai","content",o,r),l=[],n="",d=0;async function u(){if(!n)return;let c=`${String(l.length+1).padStart(4,"0")}.jsonl`,p=Tt.join(i,c),m=Buffer.byteLength(n);await Ae(O(e,p),n),l.push({path:g(t,`/${p}`),bytes:m,records:d,fingerprint:B(Buffer.from(n))}),n="",d=0}s(u,"flush"),await Ee(O(e,i),{recursive:!0});for(let c of a){let p=$t(t,c),m={routePath:p.routePath,markdownPath:p.markdownPath,title:c.title,description:c.description,version:c.version,locale:c.locale};for(let w of hr(m,c.body,t.ai.chunkSizeBytes)){let h=JSON.stringify(w)+`
7
+ `;n&&Buffer.byteLength(n)+Buffer.byteLength(h)>t.ai.chunkSizeBytes&&await u(),n+=h,d+=1}}return await u(),l}s(gr,"writePartition");function yr(e){let t=Buffer.byteLength(`
8
+
9
+ ---
10
+
11
+ `);return e.reduce((o,r,a)=>o+Buffer.byteLength(r.body)+(a?t:0),0)}s(yr,"llmsFullBytes");async function Ft(e,t,o){let r=R(e,t.outputDir),a=O(r,"ai"),i=O(a,"content");await Ee(a,{recursive:!0}),await dr(i,{recursive:!0,force:!0});let l=mr(t,o),n=l.map(m=>$t(t,m)),d=new Map;for(let m of l){let w=`${m.version}\0${m.locale}`,h=d.get(w)??[];h.push(m),d.set(w,h)}let u=[];for(let[m,w]of d){let[h="",S=""]=m.split("\0"),C=await gr(r,t,h,S,w);u.push({version:h,locale:S,pages:w.length,sourceBytes:w.reduce((b,f)=>b+Buffer.byteLength(f.body),0),shards:C})}if(await Ne(O(a,"pages.json"),"pages",n),t.ai.pageSummaries&&await Ne(O(a,"summaries.json"),"summaries",l.map(m=>({routePath:g(t,m.routePath),summary:Rt({description:m.description,body:m.body})}))),t.ai.codeExamples){function*m(){for(let w of l)for(let h of w.codeExamples)yield{routePath:g(t,w.routePath),...h}}s(m,"examples"),await Ne(O(a,"code-examples.json"),"examples",m())}t.ai.markdownIndex&&await fe(O(a,"index.md"),n.map(m=>`- [${Ot(m.title||m.routePath)}](${m.markdownPath})
12
+ `)),t.ai.llmsTxt&&await fe(O(r,"llms.txt"),n.map(m=>`- [${Ot(m.title||m.routePath)}](${m.routePath})
13
+ `));let c=yr(l),p="disabled";if(t.ai.llmsFullTxt)if(c<=t.ai.llmsFullMaxBytes){async function*m(){for(let[w,h]of l.entries())w&&(yield`
14
+
15
+ ---
16
+
17
+ `),yield h.body}s(m,"bodies"),await fe(O(r,"llms-full.txt"),m()),p="full"}else{if(t.ai.llmsFullOverflow==="error")throw new Error(`llms-full.txt requires ${c} bytes, exceeding ai.llmsFullMaxBytes ${t.ai.llmsFullMaxBytes}`);await Ae(O(r,"llms-full.txt"),["# Canofold AI content manifest","",`The full Markdown corpus requires ${c} bytes and exceeds the configured single-file budget of ${t.ai.llmsFullMaxBytes} bytes.`,"",`Use ${g(t,"/ai/manifest.json")} to load the complete versioned and locale-partitioned content shards.`,""].join(`
18
+ `)),p="manifest",Z(`llms-full.txt exceeded ${t.ai.llmsFullMaxBytes} bytes; wrote a bounded manifest pointer instead`)}await Ae(O(a,"manifest.json"),JSON.stringify({schemaVersion:pr,currentVersion:o.currentVersion,includedVersions:t.ai.versions,totals:{pages:l.length,sourceBytes:l.reduce((m,w)=>m+Buffer.byteLength(w.body),0)},budgets:{chunkSizeBytes:t.ai.chunkSizeBytes,llmsFullMaxBytes:t.ai.llmsFullMaxBytes},llmsFull:{enabled:t.ai.llmsFullTxt,mode:p,sourceBytes:c,path:t.ai.llmsFullTxt?g(t,"/llms-full.txt"):null},partitions:u},null,2))}s(Ft,"writeAiOutputs");import{cp as tn,mkdir as Ze,rm as et,writeFile as xe}from"fs/promises";import{dirname as Ho,join as W}from"path";import{renderToStaticMarkup as on}from"react-dom/server";import{createMarkdownRenderer as rn}from"@canofold/markdown/server";import{detectMarkdownAssets as zo}from"@canofold/markdown/server/analyze";import{createRequire as br}from"module";import{readFile as Bt}from"fs/promises";import{dirname as _t,join as Ut}from"path";var qt=br(import.meta.url);function jt(e){return qt.resolve(e)}s(jt,"resolveFromModule");function Ht(e){try{return qt.resolve(e,{paths:[process.cwd()]})}catch(t){throw new Error(`Cannot resolve ${e} from ${process.cwd()}. Install @canofold/plugins to include math styles.`,{cause:t})}}s(Ht,"resolveFromProject");async function wr(){return Bt(new URL("./styles.input.css",import.meta.url),"utf8")}s(wr,"readInputCss");function zt(){return Ut(_t(Ht("@canofold/plugins/math.css")),"fonts")}s(zt,"mathFontsDir");function Gt(){return Ut(_t(jt("@canofold/markdown/base.css")),"file-icons")}s(Gt,"markdownFileIconsDir");async function Le(e,t=!1){return Bt(t?Ht(e):jt(e),"utf8")}s(Le,"readPublishedCss");async function kr({math:e=!1}={}){let[t,o,r,a]=await Promise.all([wr(),Le("@canofold/markdown/base.css"),Le("@canofold/markdown/theme.css"),e?Le("@canofold/plugins/math.css",!0):void 0]);return`/* Markdown base */
19
+ ${o}
20
+ /* Default theme */
21
+ ${r}
22
+ ${a?`/* Math */
23
+ ${a}
24
+ `:""}/* Canofold shell */
25
+ ${t}
26
+ `}s(kr,"compileCss");var It=new Map;function Kt(e={}){let t=e.math===!0,o=It.get(t);return o||(o=kr({math:t}),It.set(t,o)),o}s(Kt,"buildCssCached");import{Bot as vr,Box as Pr,Code2 as Sr,FileCode2 as xr,FileText as Cr,Gauge as Mr,Globe2 as Dr,Layers3 as Nr,Rocket as Ar,Search as Er,Sparkles as Lr,SquareTerminal as Rr}from"lucide-react";import{Fragment as Or,jsx as E,jsxs as te}from"react/jsx-runtime";var Tr={ai:vr,box:Pr,code:Sr,file:Cr,"file-code":xr,gauge:Mr,globe:Dr,layers:Nr,rocket:Ar,search:Er,sparkles:Lr,terminal:Rr};function Vt({name:e,className:t}){if(!e)return null;let o=Tr[e];return E(o,{"aria-hidden":"true",className:t,strokeWidth:1.8})}s(Vt,"HomeIcon");function Wt({page:e,config:t}){let o=e.frontmatter.hero??{},r=e.frontmatter.features??[],a=o.actions??[];return te(Or,{children:[te("section",{className:`cf-hero${o.image?" cf-hero-with-visual":""}`,children:[te("div",{className:"cf-hero-copy",children:[E("h1",{className:"cf-hero-title",children:e.title}),o.accent?E("p",{className:"cf-hero-accent",children:o.accent}):null,o.tagline?E("p",{className:"cf-hero-tagline",children:o.tagline}):null,a.length>0?E("div",{className:"cf-hero-actions",children:a.map(i=>te("a",{className:`cf-btn ${i.primary?"cf-btn-primary":"cf-btn-secondary"}`,href:g(t,i.link),children:[E(Vt,{name:i.icon}),i.text]},i.link))}):null]}),o.image?E("div",{className:"cf-hero-visual",children:E("img",{src:g(t,o.image),alt:o.imageAlt??"",decoding:"async",fetchPriority:"high"})}):null]}),r.length>0?E("section",{className:"cf-feature-section",children:E("div",{className:"cf-features",children:r.map((i,l)=>te("article",{className:"cf-feature",children:[i.image||i.icon?E("div",{className:"cf-feature-icon",children:i.image?E("img",{src:g(t,i.image),alt:"",width:"32",height:"32",decoding:"async"}):E(Vt,{name:i.icon})}):null,E("h3",{children:i.title}),E("p",{children:i.details})]},`${i.title}-${l}`))})}):null]})}s(Wt,"HomeHero");import{ChevronDown as Gr,Code2 as Kr,Eye as Vr}from"lucide-react";var $r={labels:{skipToContent:"\u8DF3\u5230\u6B63\u6587",search:"\u641C\u7D22\u6587\u6863",searchEmpty:"\u6CA1\u6709\u627E\u5230\u5339\u914D\u6587\u6863",searchUnavailable:"\u641C\u7D22\u7D22\u5F15\u6682\u65F6\u4E0D\u53EF\u7528",language:"\u8BED\u8A00",primaryNavigation:"\u4E3B\u5BFC\u822A",theme:"\u5207\u6362\u4E3B\u9898",openSidebar:"\u6253\u5F00\u4FA7\u8FB9\u680F",onThisPage:"\u672C\u9875\u76EE\u5F55",edit:"\u7F16\u8F91\u6B64\u9875",updated:"\u6700\u540E\u66F4\u65B0",previous:"\u4E0A\u4E00\u9875",next:"\u4E0B\u4E00\u9875",close:"\u5173\u95ED",source:"\u6E90\u6587\u6863",preview:"\u9884\u89C8\u6548\u679C",copySource:"\u590D\u5236\u6E90\u6587\u6863",sourceCopied:"\u6E90\u6587\u6863\u5DF2\u590D\u5236",quickActions:"\u5FEB\u6377\u5165\u53E3",github:"GitHub \u4ED3\u5E93",docsNavigation:"\u6587\u6863\u5BFC\u822A",pageNavigation:"\u9875\u9762\u5BFC\u822A",advertisement:"\u63A8\u5E7F",version:"\u6587\u6863\u7248\u672C"},brandTagline:"\u9762\u5411 AI \u7684 React/MDX \u6587\u6863",markdownElementGroups:[{id:"headings",label:"\u6807\u9898\u4E0E\u6B63\u6587",detail:"H1-H6 \xB7 p \xB7 hr",hash:"\u6807\u9898\u4E0E\u6B63\u6587"},{id:"inline",label:"\u884C\u5185\u8BED\u4E49",detail:"a \xB7 strong \xB7 code",hash:"\u884C\u5185\u8BED\u4E49"},{id:"lists",label:"\u5217\u8868\u4E0E\u4EFB\u52A1",detail:"ul \xB7 ol \xB7 task",hash:"\u5217\u8868\u4E0E\u4EFB\u52A1"},{id:"callouts",label:"\u5F15\u7528\u4E0E\u63D0\u793A",detail:"quote \xB7 callout",hash:"\u5F15\u7528\u4E0E\u63D0\u793A"},{id:"code",label:"\u4EE3\u7801\u4E0E\u7EC8\u7AEF",detail:"Shiki \xB7 pre \xB7 diff",hash:"\u4EE3\u7801\u4E0E\u7EC8\u7AEF"},{id:"tables",label:"\u8868\u683C\u4E0E\u6570\u636E",detail:"table \xB7 CSV \xB7 sort",hash:"\u8868\u683C\u4E0E\u6570\u636E"},{id:"media",label:"\u5A92\u4F53\u4E0E\u5D4C\u5165",detail:"img \xB7 video \xB7 iframe",hash:"\u5A92\u4F53\u4E0E\u5D4C\u5165"},{id:"diagrams",label:"\u56FE\u8868\u4E0E\u6570\u5B66",detail:"Mermaid \xB7 PlantUML \xB7 KaTeX",hash:"\u56FE\u8868\u4E0E\u6570\u5B66"},{id:"disclosure",label:"\u6298\u53E0\u4E0E\u811A\u6CE8",detail:"details \xB7 footnotes",hash:"\u6298\u53E0\u4E0E\u811A\u6CE8"},{id:"extensions",label:"\u6269\u5C55\u5185\u5BB9\u7EC4\u4EF6",detail:"tabs \xB7 steps \xB7 cards \xB7 tree",hash:"\u6269\u5C55\u5185\u5BB9\u7EC4\u4EF6"},{id:"api",label:"API \u4E0E\u4FA7\u6CE8",detail:"API \xB7 aside",hash:"api-\u4E0E\u4FA7\u6CE8"},{id:"metadata",label:"\u6587\u6863\u5143\u4FE1\u606F",detail:"meta \xB7 breadcrumb \xB7 pagination",hash:"\u6587\u6863\u5143\u4FE1\u606F"}],quickActions:{headingsTitle:"\u6807\u9898 H1-H6",headingsDescription:"\u67E5\u770B\u5B8C\u6574\u6807\u9898\u5C42\u7EA7\u4E0E\u6B63\u6587\u8282\u594F",codeTitle:"\u4EE3\u7801\u4E0E\u8BED\u6CD5\u9AD8\u4EAE",codeDescription:"Shiki \u9AD8\u4EAE\u3001diff \u884C\u72B6\u6001\u4E0E\u590D\u5236",tableTitle:"\u8868\u683C\u4E0E\u6570\u636E\u64CD\u4F5C",tableDescription:"\u6392\u5E8F\u3001\u590D\u5236 CSV \u4E0E\u653E\u5927\u9884\u89C8",diagramTitle:"Mermaid\u3001PlantUML \u4E0E\u6570\u5B66\u516C\u5F0F",diagramDescription:"\u56FE\u8868\u9884\u89C8\u3001\u6E90\u7801\u4E0E\u7F29\u653E",sourceDescription:"\u6253\u5F00\u5F53\u524D\u9875\u9762\u7684 Markdown \u539F\u6587",themeDescription:"\u5728\u6D45\u8272\u4E0E\u6DF1\u8272\u9605\u8BFB\u6A21\u5F0F\u95F4\u5207\u6362"}},Fr={labels:{skipToContent:"Skip to content",search:"Search docs",searchEmpty:"No matching documents",searchUnavailable:"Search index is unavailable",language:"Language",primaryNavigation:"Primary navigation",theme:"Toggle theme",openSidebar:"Open sidebar",onThisPage:"On this page",edit:"Edit this page",updated:"Last updated",previous:"Previous",next:"Next",close:"Close",source:"Source",preview:"Preview",copySource:"Copy source",sourceCopied:"Markdown source copied",quickActions:"Quick actions",github:"GitHub repository",docsNavigation:"Docs navigation",pageNavigation:"Page navigation",advertisement:"Advertisement",version:"Documentation version"},brandTagline:"AI-friendly React/MDX documentation",markdownElementGroups:[{id:"headings",label:"Headings & prose",detail:"H1-H6 \xB7 p \xB7 hr",hash:"headings-and-prose"},{id:"inline",label:"Inline semantics",detail:"a \xB7 strong \xB7 code",hash:"inline-semantics"},{id:"lists",label:"Lists & tasks",detail:"ul \xB7 ol \xB7 task",hash:"lists-and-tasks"},{id:"callouts",label:"Quotes & callouts",detail:"quote \xB7 callout",hash:"quotes-and-callouts"},{id:"code",label:"Code & terminal",detail:"Shiki \xB7 pre \xB7 diff",hash:"code-and-terminal"},{id:"tables",label:"Tables & data",detail:"table \xB7 CSV \xB7 sort",hash:"tables-and-data"},{id:"media",label:"Media & embeds",detail:"img \xB7 video \xB7 iframe",hash:"media-and-embeds"},{id:"diagrams",label:"Diagrams & math",detail:"Mermaid \xB7 PlantUML \xB7 KaTeX",hash:"diagrams-and-math"},{id:"disclosure",label:"Disclosure & notes",detail:"details \xB7 footnotes",hash:"disclosure-and-notes"},{id:"extensions",label:"Extended components",detail:"tabs \xB7 steps \xB7 cards \xB7 tree",hash:"extended-content-components"},{id:"api",label:"API & sidenote",detail:"API \xB7 aside",hash:"api-and-sidenote"},{id:"metadata",label:"Document metadata",detail:"meta \xB7 breadcrumb \xB7 pagination",hash:"document-metadata"}],quickActions:{headingsTitle:"Headings H1-H6",headingsDescription:"Inspect the complete heading scale and prose rhythm",codeTitle:"Code and syntax highlighting",codeDescription:"Shiki highlighting, diff line states, and copy",tableTitle:"Tables and data actions",tableDescription:"Sort, copy CSV, and zoom",diagramTitle:"Mermaid, PlantUML, and math",diagramDescription:"Diagram preview, source, and scale",sourceDescription:"Open the current page Markdown source",themeDescription:"Switch between light and dark reading modes"}},Ir={copyCode:"\u590D\u5236\u4EE3\u7801",copyFailed:"\u590D\u5236\u5931\u8D25",copySnippet:"\u590D\u5236\u7247\u6BB5",copyTerminal:"\u590D\u5236\u7EC8\u7AEF\u8F93\u51FA",terminalTitle:"\u7EC8\u7AEF",tabsTitle:"\u9009\u9879\u5361",tabItem:"\u9009\u9879 {index}",codeGroupTitle:"\u4EE3\u7801\u7EC4",codeGroupItem:"\u4EE3\u7801 {index}",taskCompleted:"\u5DF2\u5B8C\u6210\u4EFB\u52A1",taskIncomplete:"\u672A\u5B8C\u6210\u4EFB\u52A1",copySectionLink:"\u590D\u5236\u7AE0\u8282\u94FE\u63A5",tableTitle:"\u8868\u683C",copyTableCsv:"\u590D\u5236\u4E3A CSV",downloadTableCsv:"\u4E0B\u8F7D CSV",zoomTable:"\u653E\u5927\u8868\u683C",closeTablePreview:"\u5173\u95ED\u8868\u683C\u9884\u89C8",sortTableColumn:"\u6309\u7B2C {column} \u5217\u6392\u5E8F",zoomImage:"\u653E\u5927\u56FE\u7247",closeImagePreview:"\u5173\u95ED\u56FE\u7247\u9884\u89C8",imageGallery:"\u56FE\u7247\u753B\u5ECA",closeImageGallery:"\u5173\u95ED\u56FE\u7247\u753B\u5ECA",previousGalleryImage:"\u4E0A\u4E00\u5F20\u56FE\u7247",nextGalleryImage:"\u4E0B\u4E00\u5F20\u56FE\u7247",galleryThumbnails:"\u56FE\u7247\u753B\u5ECA\u7F29\u7565\u56FE",galleryImage:"\u56FE\u7247"},Jt={zh:{title:"\u9875\u9762\u672A\u627E\u5230",description:"\u8BE5\u9875\u9762\u4E0D\u5B58\u5728\u3001\u5DF2\u88AB\u79FB\u52A8\u6216\u5730\u5740\u6709\u8BEF\u3002",home:"\u8FD4\u56DE\u9996\u9875 \u2192"},en:{title:"Page not found",description:"The page you're looking for doesn't exist or has been moved.",home:"Go back home \u2192"}};function he(e){return e.toLowerCase().split("-")[0]??e.toLowerCase()}s(he,"languageCode");function Xt(e,t){if(!e)return;let o=t.toLowerCase();return Object.entries(e).find(([r])=>r.toLowerCase()===o)?.[1]}s(Xt,"localizedValue");function Re(e,t){return Xt(t,e)}s(Re,"localeMessagesFor");function Yt(e,t){let o=he(e)==="zh"?$r:Fr,r=Re(e,t);return{labels:{...o.labels,...r?.labels},brandTagline:r?.brandTagline??o.brandTagline,markdownElementGroups:o.markdownElementGroups.map(a=>({...a,...r?.markdownElementGroups?.[a.id]})),quickActions:{...o.quickActions,...r?.quickActions}}}s(Yt,"layoutContentFor");function ge(e,t){let o=Re(e,t)?.markdown,r=he(e)==="zh"?Ir:void 0;if(!(!r&&!o))return{...r,...o}}s(ge,"markdownLabelsFor");function Te(e,t){return{...he(e)==="zh"?Jt.zh:Jt.en,...Re(e,t)?.notFound}}s(Te,"notFoundContentFor");function Qt(e,t){let o=Xt(t,e);if(o)return o;let r=he(e);if(r==="zh")return"\u7B80\u4F53\u4E2D\u6587";if(r==="en")return"English";try{return new Intl.DisplayNames([e],{type:"language"}).of(e)??e}catch{return e}}s(Qt,"localeNameFor");var ye="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='7' fill='%230088FF'/%3E%3Cpath d='M9 7h10l4 4v14H9z' fill='none' stroke='white' stroke-width='2' stroke-linejoin='round'/%3E%3Cpath d='M19 7v5h5' fill='none' stroke='white' stroke-width='2'/%3E%3Ccircle cx='21' cy='22' r='5' fill='%230088FF' stroke='white' stroke-width='2'/%3E%3C/svg%3E";import{ChevronDown as Zt,Languages as Br,Moon as _r,PanelLeft as Ur,Search as qr,Sun as jr}from"lucide-react";import{Fragment as to,jsx as y,jsxs as D}from"react/jsx-runtime";function Hr(){return D("svg",{className:"cf-brand-mark",width:"32",height:"32",viewBox:"0 0 512 512","aria-hidden":"true",children:[D("defs",{children:[D("linearGradient",{id:"cf-brand-top",x1:"90",y1:"60",x2:"400",y2:"260",gradientUnits:"userSpaceOnUse",children:[y("stop",{offset:"0",stopColor:"#1768FF"}),y("stop",{offset:"0.5",stopColor:"#119BFA"}),y("stop",{offset:"1",stopColor:"#18D8D3"})]}),D("linearGradient",{id:"cf-brand-fold",x1:"70",y1:"220",x2:"210",y2:"300",gradientUnits:"userSpaceOnUse",children:[y("stop",{offset:"0",stopColor:"#2C7BFF"}),y("stop",{offset:"1",stopColor:"#554FF5"})]}),D("linearGradient",{id:"cf-brand-bottom",x1:"200",y1:"270",x2:"90",y2:"460",gradientUnits:"userSpaceOnUse",children:[y("stop",{offset:"0",stopColor:"#554FF5"}),y("stop",{offset:"0.62",stopColor:"#7845FA"}),y("stop",{offset:"1",stopColor:"#8637F5"})]}),D("mask",{id:"cf-brand-spark-cut",maskUnits:"userSpaceOnUse",x:"0",y:"0",width:"512",height:"512",children:[y("rect",{width:"512",height:"512",fill:"#fff"}),y("path",{d:"M112 201C117 229 139 251 167 256C139 261 117 283 112 311C107 283 85 261 57 256C85 251 107 229 112 201Z",fill:"#000"})]})]}),D("g",{mask:"url(#cf-brand-spark-cut)",fill:"none",strokeLinejoin:"round",children:[y("path",{d:"M348 138A150 150 0 0 0 107 243",stroke:"url(#cf-brand-top)",strokeWidth:"86",strokeLinecap:"round"}),y("path",{d:"M78 256C118 228 158 228 208 256",stroke:"url(#cf-brand-fold)",strokeWidth:"70",strokeLinecap:"round"}),y("path",{d:"M107 269A150 150 0 0 0 348 374",stroke:"url(#cf-brand-bottom)",strokeWidth:"86",strokeLinecap:"round"})]})]})}s(Hr,"BrandMark");function Oe({size:e=16}){return y(qr,{size:e,strokeWidth:2,"aria-hidden":"true"})}s(Oe,"SearchIcon");function zr(){return D(to,{children:[y(jr,{className:"cf-icon-sun",size:18,strokeWidth:2,"aria-hidden":"true"}),y(_r,{className:"cf-icon-moon",size:18,strokeWidth:2,"aria-hidden":"true"})]})}s(zr,"ThemeIcon");function $e(e,t){let o=t.split("/").filter(Boolean);return t.startsWith("/")&&(e.page.routePath===t||e.page.routePath.startsWith(t)||e.page.group!==""&&o.includes(e.page.group))}s($e,"navItemIsActive");function eo({model:e}){let{config:t,page:o,home:r,labels:a,localeRoot:i,navItems:l,versionLabel:n,versionOptions:d,languageOptions:u,hasSidebarItems:c}=e;return D("header",{className:r?"cf-header cf-header-home":"cf-header",children:[D("div",{className:"cf-header-inner",children:[!r&&c?y("button",{className:"cf-sidebar-toggle",type:"button","data-canofold-sidebar-open":"","data-canofold-sidebar-open-label":a.openSidebar,"data-canofold-sidebar-close-label":a.close,"aria-label":a.openSidebar,"aria-expanded":"false",children:y(Ur,{size:18,strokeWidth:2,"aria-hidden":"true"})}):null,y("a",{className:"cf-brand",href:i,"aria-label":t.title,children:t.theme.logo?D(to,{children:[y("img",{className:t.theme.logoDark?"cf-brand-logo cf-brand-logo-light":"cf-brand-logo",src:g(t,t.theme.logo),alt:t.title}),t.theme.logoDark?y("img",{className:"cf-brand-logo cf-brand-logo-dark",src:g(t,t.theme.logoDark),alt:t.title}):null]}):y(Hr,{})}),t.search.enabled?D("button",{className:"cf-search-trigger",type:"button","data-canofold-search-open":"","aria-haspopup":"dialog","aria-label":a.search,children:[y(Oe,{size:15}),y("span",{children:a.search}),y("kbd",{className:"cf-kbd",children:"\u2318K"})]}):null,D("div",{className:"cf-header-right",children:[l.length>0?y("nav",{className:"cf-header-nav","aria-label":a.primaryNavigation,children:l.map(p=>{let m=$e(e,p.routePath),w=/^https?:\/\//.test(p.routePath);return y("a",{className:m?"cf-header-link cf-header-link-active":"cf-header-link",href:g(t,p.routePath),"aria-current":m?"page":void 0,...w?{target:"_blank",rel:"noreferrer"}:{},children:p.title},p.routePath)})}):null,d.length>1?D("details",{className:"cf-menu cf-version-menu","data-canofold-menu":"",children:[D("summary",{className:"cf-version-badge","aria-label":a.version,children:[y("span",{children:n}),y(Zt,{size:13,strokeWidth:2,"aria-hidden":"true"})]}),y("div",{className:"cf-menu-list",children:d.map(p=>y("a",{className:p.id===o.version?"cf-menu-item cf-menu-item-active":"cf-menu-item",href:g(t,p.routePath),children:y("span",{children:p.label})},p.id))})]}):y("span",{className:"cf-version-badge",children:n}),u.length>1?D("details",{className:"cf-menu cf-lang","data-canofold-menu":"",children:[D("summary",{className:"cf-icon-button cf-lang-trigger","aria-label":a.language,children:[y(Br,{size:19,strokeWidth:1.9,"aria-hidden":"true"}),y(Zt,{size:13,strokeWidth:2,"aria-hidden":"true"})]}),y("div",{className:"cf-menu-list cf-language-menu-list",children:u.map(p=>y("a",{className:p.locale===o.locale?"cf-menu-item cf-language-menu-item cf-menu-item-active":"cf-menu-item cf-language-menu-item",href:g(t,p.routePath),lang:p.locale,"aria-current":p.locale===o.locale?"page":void 0,children:Qt(p.locale,t.i18n.localeNames)},p.locale))})]}):null,t.theme.darkMode?y("button",{className:"cf-icon-button",type:"button","data-canofold-theme-toggle":"","aria-label":a.theme,children:y(zr,{})}):null,t.github?y("a",{className:"cf-icon-button cf-github-link",href:t.github,target:"_blank",rel:"noreferrer","aria-label":a.github,children:y("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:y("path",{d:"M12 2C6.48 2 2 6.58 2 12.25c0 4.53 2.87 8.37 6.84 9.73.5.1.68-.22.68-.49 0-.24-.01-.87-.01-1.71-2.78.62-3.37-1.37-3.37-1.37-.45-1.18-1.11-1.5-1.11-1.5-.91-.64.07-.62.07-.62 1 .07 1.53 1.06 1.53 1.06.89 1.56 2.34 1.11 2.91.85.09-.66.35-1.11.63-1.37-2.22-.26-4.56-1.14-4.56-5.07 0-1.12.39-2.03 1.03-2.75-.1-.26-.45-1.3.1-2.71 0 0 .84-.27 2.75 1.05a9.36 9.36 0 0 1 5 0c1.91-1.32 2.75-1.05 2.75-1.05.55 1.41.2 2.45.1 2.71.64.72 1.03 1.63 1.03 2.75 0 3.94-2.34 4.81-4.57 5.06.36.32.68.94.68 1.9 0 1.37-.01 2.47-.01 2.81 0 .27.18.6.69.49A10.26 10.26 0 0 0 22 12.25C22 6.58 17.52 2 12 2z"})})}):null]})]}),r?null:y("div",{className:"cf-progress","aria-hidden":"true",children:y("span",{"data-canofold-progress":""})})]})}s(eo,"LayoutHeader");import{jsx as k,jsxs as N}from"react/jsx-runtime";function ro(e,t){return e.type==="link"?e.routePath===t:e.items.some(o=>ro(o,t))}s(ro,"sidebarContainsRoute");function oo(e){return{"--cf-sidebar-indent":`${Math.min(e,4)*10}px`}}s(oo,"sidebarDepthStyle");function ao({item:e,model:t,depth:o=0}){let r={"data-depth":o,style:oo(o)};if(e.type==="link"){let i=e.routePath===t.page.routePath;return k("a",{...r,className:i?"cf-sidebar-link cf-sidebar-link-active":"cf-sidebar-link",href:g(t.config,e.routePath),"aria-current":i?"page":void 0,"data-canofold-sidebar-link":"",children:e.title})}let a=ro(e,t.page.routePath);return N("details",{className:"cf-sidebar-subgroup",open:a||!e.collapsed,"data-depth":o,children:[N("summary",{className:"cf-sidebar-subgroup-title",style:oo(o),children:[e.title,k(Gr,{className:"cf-chevron",size:12,strokeWidth:2.5,"aria-hidden":"true"})]}),k("div",{className:"cf-sidebar-subgroup-items",children:e.items.map((i,l)=>k(ao,{item:i,model:t,depth:o+1},i.type==="link"?i.routePath:i.segment||l))})]})}s(ao,"SidebarEntry");function no({model:e}){let{config:t,labels:o,navItems:r,sidebarGroups:a}=e,i=[e.page.version,e.page.locale,e.page.group].join(":");return N("aside",{className:"cf-sidebar","data-canofold-sidebar":"","data-canofold-sidebar-key":i,children:[r.length>0?k("nav",{className:"cf-sidebar-primary-nav","aria-label":o.primaryNavigation,children:r.map(l=>{let n=$e(e,l.routePath),d=/^https?:\/\//.test(l.routePath);return k("a",{className:n?"cf-sidebar-primary-link cf-sidebar-primary-link-active":"cf-sidebar-primary-link",href:g(t,l.routePath),"aria-current":n?"page":void 0,"data-canofold-sidebar-link":"",...d?{target:"_blank",rel:"noreferrer"}:{},children:l.title},l.routePath)})}):null,k("nav",{className:"cf-sidebar-nav","aria-label":o.docsNavigation,children:a.map((l,n)=>k("div",{className:"cf-sidebar-items cf-sidebar-root",children:l.items.map((d,u)=>k(ao,{item:d,model:e,depth:0},d.type==="link"?d.routePath:d.segment||u))},l.segment||n))})]})}s(no,"Sidebar");function Wr({model:e}){let{editHref:t,labels:o,page:r}=e,a=new Intl.DateTimeFormat(r.locale,{dateStyle:"medium"}).format(new Date(r.lastUpdated));return N("footer",{className:"cf-page-footer",children:[N("div",{className:"cf-page-meta",children:[N("div",{className:"cf-page-meta-actions",children:[t?k("a",{href:t,children:o.edit}):null,k("button",{className:"cf-page-source",type:"button","data-canofold-source-open":"","aria-haspopup":"dialog",children:o.source})]}),N("span",{children:[o.updated," ",a]})]}),N("nav",{className:"cf-doc-pagination","aria-label":o.pageNavigation,children:[r.previous?N("a",{className:"cf-doc-pagination-link",href:g(e.config,r.previous.routePath),children:[k("span",{className:"cf-doc-pagination-label",children:o.previous}),k("strong",{className:"cf-doc-pagination-title",children:r.previous.title})]}):k("span",{}),r.next?N("a",{className:"cf-doc-pagination-link cf-doc-pagination-link-next",href:g(e.config,r.next.routePath),children:[k("span",{className:"cf-doc-pagination-label",children:o.next}),k("strong",{className:"cf-doc-pagination-title",children:r.next.title})]}):null]})]})}s(Wr,"PageFooter");function Jr({model:e}){let{config:t,labels:o,outlineHeadings:r}=e,a=t.advertising;return N("aside",{className:"cf-outline","data-canofold-outline":"","aria-label":o.onThisPage,children:[r.length>0?k("nav",{className:"cf-outline-nav",children:r.map(i=>k("a",{className:`cf-outline-link cf-outline-link-${i.level}`,"data-canofold-outline-link":"",href:`#${i.slug}`,children:i.text},i.slug))}):null,a?N("a",{className:"cf-outline-ad",href:g(t,a.href),target:"_blank",rel:"sponsored noopener noreferrer","aria-label":a.alt,children:[k("span",{children:a.label??o.advertisement}),k("img",{src:g(t,a.image),alt:a.alt,loading:"lazy"})]}):null]})}s(Jr,"Outline");function Xr({model:e,children:t}){let{config:o,labels:r,page:a}=e,i=a.body.trim(),l={...ge(a.locale,o.i18n.messages),...o.markdown.labels};return N("div",{className:"cf-shell cf-shell-playground",children:[k("div",{className:"cf-sidebar-backdrop","data-canofold-sidebar-backdrop":"","aria-hidden":"true",hidden:!0}),k(no,{model:e}),k("main",{id:"canofold-main",className:"cf-main cf-playground-main",tabIndex:-1,"data-pagefind-body":a.search?"":void 0,children:N("div",{className:"cf-playground","data-canofold-playground":"","data-canofold-playground-labels":JSON.stringify(l),"data-canofold-playground-preview-label":r.preview,"data-view":"preview",children:[N("button",{className:"cf-playground-toggle",type:"button","data-canofold-playground-toggle":"","data-source-label":r.source,"data-preview-label":r.preview,"aria-label":r.source,title:r.source,children:[k(Kr,{className:"cf-playground-toggle-source",size:18,strokeWidth:2,"aria-hidden":"true"}),k(Vr,{className:"cf-playground-toggle-preview",size:18,strokeWidth:2,"aria-hidden":"true"})]}),k("section",{className:"cf-playground-pane cf-playground-source","aria-label":r.source,"data-pagefind-ignore":"",children:k("textarea",{defaultValue:i,"aria-label":r.source,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"data-canofold-playground-source":""})}),k("div",{className:"cf-playground-resizer",role:"separator","aria-label":`${r.source} / ${r.preview}`,"aria-orientation":"vertical","aria-valuemin":25,"aria-valuemax":75,"aria-valuenow":45,tabIndex:0,"data-canofold-playground-resizer":""}),k("section",{className:"cf-playground-pane cf-playground-preview","aria-label":r.preview,children:k("div",{className:"cf-playground-preview-scroll","data-canofold-playground-preview":"",children:t})})]})})]})}s(Xr,"Playground");function so({model:e,children:t}){return e.page.frontmatter.layout==="playground"?k(Xr,{model:e,children:t}):N("div",{className:"cf-shell",children:[k("div",{className:"cf-sidebar-backdrop","data-canofold-sidebar-backdrop":"","aria-hidden":"true",hidden:!0}),k(no,{model:e}),N("main",{id:"canofold-main",className:"cf-main",tabIndex:-1,"data-pagefind-body":e.page.search?"":void 0,children:[t,k(Wr,{model:e})]}),k(Jr,{model:e})]})}s(so,"LayoutDocument");function be(e){return ht(e.relativePath,e.locale)}s(be,"subPath");function oe(e,t){let o=e.find(r=>r.id===t);if(!o)throw new Error(`Missing Markdown element group: ${t}`);return o.hash}s(oe,"markdownGroupHash");function io({config:e,graph:t,page:o,home:r,assets:a,rawSource:i}){let l=t.pages.filter(f=>f.version===o.version&&be(f)===be(o)),n=t.locales.map(f=>{let M=l.find(x=>x.locale===f);return{locale:f,routePath:M?.routePath??j(f,t.defaultLocale,o.versionBase)}}),d=t.versions.map(f=>{let M=t.pages.find(x=>x.version===f.id&&x.locale===o.locale&&be(x)===be(o));return{id:f.id,label:f.label,routePath:M?.routePath??j(o.locale,t.defaultLocale,f.base)}}),u=t.sidebar[o.version]?.[o.locale]??[],c=Yt(o.locale,e.i18n.messages),p=j(o.locale,t.defaultLocale,o.versionBase),m=`${p}markdown/playground/`,w=t.pages.some(f=>f.locale===o.locale&&f.routePath===m),h=s(f=>f.type==="link"?f.routePath===o.routePath:f.items.some(h),"isActiveItem"),S=s(f=>f.items.some(h),"isActiveGroup"),C=u.filter(f=>f.title===""||f.segment===o.group||S(f)),b=typeof o.frontmatter.seoTitle=="string"?o.frontmatter.seoTitle.trim():"";return{config:e,page:o,home:r,assets:a,title:b||(o.title&&o.title!==e.title?`${o.title} | ${e.title}`:e.title),description:o.description||e.description,...e.editUrl&&o.version===t.currentVersion?{editHref:`${e.editUrl.replace(/\/$/,"")}/${o.relativePath}`}:{},alternatePages:l,languageOptions:n,versionOptions:d,navItems:t.nav[o.version]?.[o.locale]??[],content:c,labels:c.labels,brandTagline:e.i18n.messages?.[o.locale]?.brandTagline||e.description||c.brandTagline,versionLabel:t.versions.length===1&&o.version==="current"?`v${q}`:t.versions.find(f=>f.id===o.version)?.label??o.version,localeRoot:g(e,p),markdownShowcaseHref:g(e,m),hasMarkdownShowcase:w,sidebarGroups:C,hasSidebarItems:C.some(f=>f.items.length>0),outlineHeadings:o.headings.filter(f=>f.level>=1&&f.level<=6),searchProvider:kt(e.search.provider),searchIndexUrl:o.version===t.currentVersion?g(e,`/search/${o.locale}.json`):g(e,`/search/${o.version}/${o.locale}.json`),searchBundleUrl:g(e,"/pagefind/pagefind.js"),markdownClientScript:`window.__canofoldEnhanceMarkdown = async (target) => {
27
+ const pageRoot = document.querySelector('[data-canofold-page-root]')
28
+ if (!pageRoot) return () => {}
29
+ const root = target || pageRoot
30
+ const behaviors = JSON.parse(pageRoot.getAttribute('data-markdown-behaviors') || '[]')
31
+ const pluginClients = JSON.parse(pageRoot.getAttribute('data-markdown-plugin-clients') || '[]')
32
+ const disposers = []
33
+ try {
34
+ if (behaviors.length) {
35
+ const clientUrl = pageRoot.getAttribute('data-markdown-client-url')
36
+ if (clientUrl) {
37
+ const { enhanceMarkdown } = await import(clientUrl)
38
+ const enhancement = enhanceMarkdown(root, { behaviors })
39
+ disposers.push(() => enhancement.dispose())
40
+ await enhancement.ready
41
+ }
42
+ }
43
+ for (const pluginUrl of pluginClients) {
44
+ const plugin = await import(pluginUrl)
45
+ const enhancement = await plugin.enhance?.(root)
46
+ if (typeof enhancement === 'function') disposers.push(enhancement)
47
+ else if (enhancement?.dispose) disposers.push(() => enhancement.dispose())
48
+ await enhancement?.ready
49
+ }
50
+ return () => disposers.reverse().forEach((dispose) => dispose())
51
+ } catch (error) {
52
+ disposers.reverse().forEach((dispose) => dispose())
53
+ throw error
54
+ }
55
+ }
56
+ const bootstrapMarkdown = async () => {
57
+ window.__canofoldMarkdownDispose?.()
58
+ const generation = (window.__canofoldMarkdownGeneration || 0) + 1
59
+ window.__canofoldMarkdownGeneration = generation
60
+ const root = document.querySelector('[data-canofold-page-root]')
61
+ if (!root) return
62
+ const dispose = await window.__canofoldEnhanceMarkdown(root)
63
+ if (window.__canofoldMarkdownGeneration !== generation || !root.isConnected) {
64
+ dispose()
65
+ return
66
+ }
67
+ window.__canofoldMarkdownDispose = () => {
68
+ window.__canofoldMarkdownGeneration += 1
69
+ dispose()
70
+ }
71
+ }
72
+ window.__canofoldBootstrapMarkdown = () => {
73
+ const ready = bootstrapMarkdown()
74
+ window.__canofoldMarkdownReady = ready
75
+ return ready
76
+ }
77
+ window.__canofoldBootstrapMarkdown()`,rawSource:i}}s(io,"createLayoutModel");import{Braces as Yr,Clipboard as Qr,ExternalLink as Zr,Heading2 as ea,SunMoon as ta,Table2 as oa,Workflow as ra,X as aa}from"lucide-react";import{Fragment as Fe,jsx as v,jsxs as L}from"react/jsx-runtime";function Y({href:e,action:t,icon:o,title:r,description:a}){let i=L(Fe,{children:[v("span",{className:"cf-command-glyph","aria-hidden":"true",children:o}),L("span",{children:[v("strong",{children:r}),v("small",{children:a})]})]});return e?v("a",{className:"cf-command-item",href:e,children:i}):v("button",{className:"cf-command-item",type:"button","data-canofold-search-action":t,children:i})}s(Y,"QuickAction");function na({model:e}){let{config:t,page:o,home:r,labels:a,content:i,markdownShowcaseHref:l,hasMarkdownShowcase:n}=e,d=i.markdownElementGroups,u=i.quickActions;return t.search.enabled?L("div",{className:"cf-search-modal","data-canofold-search":"","data-locale":o.locale,"data-version":o.version,"data-search-provider":e.searchProvider,"data-search-index-url":e.searchIndexUrl,"data-search-bundle-url":e.searchBundleUrl,"data-empty-label":a.searchEmpty,"data-error-label":a.searchUnavailable,hidden:!0,children:[v("div",{className:"cf-search-backdrop","data-canofold-search-close":"","aria-hidden":"true"}),L("div",{className:"cf-search-panel",role:"dialog","aria-modal":"true","aria-label":a.search,tabIndex:-1,children:[L("div",{className:"cf-search-field",children:[v(Oe,{}),v("input",{className:"cf-search-input",type:"search",placeholder:`${a.search}...`,"aria-label":a.search}),v("button",{className:"cf-search-close",type:"button","data-canofold-search-close":"","aria-label":a.close,children:"Esc"})]}),L("div",{className:"cf-search-body",children:[L("div",{className:"cf-search-default","data-canofold-search-default":"",children:[v("p",{className:"cf-search-section-label",children:a.quickActions}),n?L(Fe,{children:[v(Y,{href:`${l}#${oe(d,"headings")}`,icon:v(ea,{size:17,strokeWidth:2}),title:u.headingsTitle,description:u.headingsDescription}),v(Y,{href:`${l}#${oe(d,"code")}`,icon:v(Yr,{size:17,strokeWidth:2}),title:u.codeTitle,description:u.codeDescription}),v(Y,{href:`${l}#${oe(d,"tables")}`,icon:v(oa,{size:17,strokeWidth:2}),title:u.tableTitle,description:u.tableDescription}),v(Y,{href:`${l}#${oe(d,"diagrams")}`,icon:v(ra,{size:17,strokeWidth:2}),title:u.diagramTitle,description:u.diagramDescription})]}):null,r?null:v(Y,{action:"source",icon:v(Zr,{size:17,strokeWidth:2}),title:a.source,description:u.sourceDescription}),t.theme.darkMode?v(Y,{action:"theme",icon:v(ta,{size:17,strokeWidth:2}),title:a.theme,description:u.themeDescription}):null]}),v("div",{className:"cf-search-results","data-canofold-search-results":"","aria-live":"polite",hidden:!0})]})]})]}):null}s(na,"SearchModal");function sa({model:e}){let{home:t,labels:o,page:r}=e;return t?null:L("div",{className:"cf-source-sheet","data-canofold-source-sheet":"",hidden:!0,children:[v("div",{className:"cf-source-backdrop","data-canofold-source-close":"","aria-hidden":"true"}),L("aside",{className:"cf-source-panel",role:"dialog","aria-modal":"true","aria-label":o.source,tabIndex:-1,children:[L("div",{className:"cf-source-head",children:[L("div",{children:[v("p",{children:o.source}),v("span",{children:r.sourceRelativePath})]}),L("div",{className:"cf-source-actions",children:[v("button",{className:"cf-icon-button",type:"button","data-canofold-source-copy":"","data-canofold-action-success":o.sourceCopied,"aria-label":o.copySource,children:v(Qr,{size:16,strokeWidth:2,"aria-hidden":"true"})}),v("button",{className:"cf-icon-button",type:"button","data-canofold-source-close":"","aria-label":o.close,children:v(aa,{size:16,strokeWidth:2,"aria-hidden":"true"})})]})]}),v("textarea",{"data-canofold-source-text":"","aria-label":o.source,spellCheck:!1,readOnly:!0,defaultValue:e.rawSource})]})]})}s(sa,"SourceSheet");function lo({model:e}){return L(Fe,{children:[v(na,{model:e}),v(sa,{model:e})]})}s(lo,"LayoutOverlays");var we="try{var t=localStorage.getItem('canofold-theme');if(t==='dark'||(!t&&window.matchMedia('(prefers-color-scheme:dark)').matches)){document.documentElement.classList.add('dark')}}catch(e){}";var co=`window.__canofoldBootstrapShell = () => {
78
+ window.__canofoldShellDispose?.()
79
+ const controller = new AbortController()
80
+ const signal = controller.signal
81
+ const on = (target, event, listener, options = {}) => target.addEventListener(event, listener, { ...options, signal })
82
+ const d = document
83
+ const root = d.documentElement
84
+ const q = (selector, parent = d) => parent.querySelector(selector)
85
+ const qa = (selector, parent = d) => Array.from(parent.querySelectorAll(selector))
86
+ let navigationController
87
+
88
+ const homeHeader = q('.cf-header-home')
89
+ function syncHomeHeader() {
90
+ const progress = Math.min(1, Math.max(0, window.scrollY / 96))
91
+ homeHeader?.style.setProperty('--cf-header-surface-mix', progress * 68 + '%')
92
+ homeHeader?.style.setProperty('--cf-header-backdrop-blur', progress * 22 + 'px')
93
+ homeHeader?.style.setProperty('--cf-header-backdrop-saturation', 100 + progress * 60 + '%')
94
+ }
95
+ syncHomeHeader()
96
+ on(window, 'scroll', syncHomeHeader, { passive: true })
97
+
98
+ function disposePage() {
99
+ window.__canofoldSearchDispose?.()
100
+ window.__canofoldMarkdownDispose?.()
101
+ window.__canofoldOutlineDispose?.()
102
+ window.__canofoldShellDispose?.()
103
+ }
104
+
105
+ async function bootstrapPage() {
106
+ window.__canofoldBootstrapShell?.()
107
+ window.__canofoldBootstrapOutline?.()
108
+ window.__canofoldBootstrapSearch?.()
109
+ await window.__canofoldBootstrapMarkdown?.()
110
+ const pageRoot = q('[data-canofold-page-root]')
111
+ const pageModule = pageRoot?.getAttribute('data-canofold-playground-client-url')
112
+ if (pageModule) {
113
+ const loadModule = window.__canofoldLoadPageModule || ((url) => import(url))
114
+ await loadModule(pageModule)
115
+ window.__canofoldBootstrapPlayground?.()
116
+ }
117
+ }
118
+
119
+ function captureUpdateState(pageRoot) {
120
+ const readingLine = 64
121
+ const headings = qa('[id]', pageRoot)
122
+ let anchor
123
+ for (const heading of headings) {
124
+ if (heading.getBoundingClientRect().top <= readingLine) anchor = heading
125
+ else break
126
+ }
127
+ const maximum = Math.max(1, root.scrollHeight - window.innerHeight)
128
+ return {
129
+ anchorId: anchor?.id || null,
130
+ anchorTop: anchor?.getBoundingClientRect().top || 0,
131
+ ratio: window.scrollY / maximum,
132
+ details: qa('details', pageRoot).map((item) => item.open),
133
+ tabs: qa('[data-cf-behavior="tabs"]', pageRoot).map((item) => ({
134
+ id: item.getAttribute('data-cf-tabs-id'),
135
+ value: q('[role="tab"][data-cf-tab][aria-selected="true"]', item)?.getAttribute('data-cf-tab') || null
136
+ }))
137
+ }
138
+ }
139
+
140
+ function restoreUpdateStructure(pageRoot, state) {
141
+ qa('details', pageRoot).forEach((item, index) => {
142
+ if (state.details[index] !== undefined) item.open = state.details[index]
143
+ })
144
+ }
145
+
146
+ function restoreUpdateTabs(pageRoot, state) {
147
+ state.tabs.forEach((saved) => {
148
+ if (!saved.id || !saved.value) return
149
+ const tabs = qa('[data-cf-behavior="tabs"]', pageRoot).find(
150
+ (item) => item.getAttribute('data-cf-tabs-id') === saved.id
151
+ )
152
+ const trigger = tabs && qa('[role="tab"][data-cf-tab]', tabs).find(
153
+ (item) => item.getAttribute('data-cf-tab') === saved.value
154
+ )
155
+ trigger?.click()
156
+ })
157
+ }
158
+
159
+ function restoreReadingPosition(state) {
160
+ requestAnimationFrame(() => {
161
+ const anchor = state.anchorId && d.getElementById(state.anchorId)
162
+ if (anchor) {
163
+ window.scrollBy(0, anchor.getBoundingClientRect().top - state.anchorTop)
164
+ return
165
+ }
166
+ const maximum = Math.max(0, root.scrollHeight - window.innerHeight)
167
+ window.scrollTo(0, state.ratio * maximum)
168
+ })
169
+ }
170
+
171
+ function syncPageHead(nextDocument) {
172
+ d.title = nextDocument.title
173
+ const currentNodes = qa('[data-canofold-page-head]', d.head)
174
+ const nextNodes = qa('[data-canofold-page-head]', nextDocument.head)
175
+ const available = new Map()
176
+ currentNodes.forEach((node) => {
177
+ const nodes = available.get(node.outerHTML) || []
178
+ nodes.push(node)
179
+ available.set(node.outerHTML, nodes)
180
+ })
181
+ const retained = new Set()
182
+ nextNodes.forEach((node) => {
183
+ const matches = available.get(node.outerHTML)
184
+ const current = matches?.shift()
185
+ if (current) retained.add(current)
186
+ else d.head.appendChild(d.importNode(node, true))
187
+ })
188
+ currentNodes.forEach((node) => {
189
+ if (!retained.has(node)) node.remove()
190
+ })
191
+ }
192
+
193
+ function syncDocumentElement(nextDocument) {
194
+ const dark = root.classList.contains('dark')
195
+ root.className = nextDocument.documentElement.className
196
+ if (dark) root.classList.add('dark')
197
+ root.lang = nextDocument.documentElement.lang
198
+ const direction = nextDocument.documentElement.getAttribute('dir')
199
+ if (direction) root.setAttribute('dir', direction)
200
+ else root.removeAttribute('dir')
201
+ d.body.className = nextDocument.body.className
202
+ }
203
+
204
+ function syncSidebarState(currentSidebar, nextSidebar) {
205
+ const currentLinks = qa('[data-canofold-sidebar-link]', currentSidebar)
206
+ const nextLinks = qa('[data-canofold-sidebar-link]', nextSidebar)
207
+ const currentDetails = qa('details', currentSidebar)
208
+ const nextDetails = qa('details', nextSidebar)
209
+ if (
210
+ currentLinks.length !== nextLinks.length ||
211
+ currentDetails.length !== nextDetails.length ||
212
+ currentLinks.some((link, index) => link.getAttribute('href') !== nextLinks[index]?.getAttribute('href'))
213
+ ) return false
214
+ currentLinks.forEach((link, index) => {
215
+ const nextLink = nextLinks[index]
216
+ link.className = nextLink.className
217
+ const current = nextLink.getAttribute('aria-current')
218
+ if (current) link.setAttribute('aria-current', current)
219
+ else link.removeAttribute('aria-current')
220
+ })
221
+ currentDetails.forEach((details, index) => {
222
+ if (nextDetails[index]?.open) details.open = true
223
+ })
224
+ return true
225
+ }
226
+
227
+ async function applyPageDocument(nextDocument, options = {}) {
228
+ const currentRoot = q('[data-canofold-page-root]')
229
+ const nextRoot = q('[data-canofold-page-root]', nextDocument)
230
+ if (!currentRoot || !nextRoot) return false
231
+ const updateState = options.mode === 'update' ? captureUpdateState(currentRoot) : null
232
+ const sidebarScrollTop = options.sidebarScrollTop ?? q('[data-canofold-sidebar]', currentRoot)?.scrollTop ?? 0
233
+ disposePage()
234
+ const imported = d.importNode(nextRoot, true)
235
+ if (options.mode === 'navigation') {
236
+ const currentSidebar = q('[data-canofold-sidebar]', currentRoot)
237
+ const nextSidebar = q('[data-canofold-sidebar]', imported)
238
+ if (
239
+ currentSidebar &&
240
+ nextSidebar &&
241
+ currentSidebar.getAttribute('data-canofold-sidebar-key') &&
242
+ currentSidebar.getAttribute('data-canofold-sidebar-key') ===
243
+ nextSidebar.getAttribute('data-canofold-sidebar-key') &&
244
+ syncSidebarState(currentSidebar, nextSidebar)
245
+ ) {
246
+ nextSidebar.replaceWith(currentSidebar)
247
+ }
248
+ }
249
+ currentRoot.replaceWith(imported)
250
+ syncPageHead(nextDocument)
251
+ syncDocumentElement(nextDocument)
252
+ if (updateState) restoreUpdateStructure(imported, updateState)
253
+ const nextSidebar = q('[data-canofold-sidebar]', imported)
254
+ if (!updateState && nextSidebar) nextSidebar.scrollTop = sidebarScrollTop
255
+ await bootstrapPage()
256
+ if (updateState) {
257
+ restoreUpdateTabs(imported, updateState)
258
+ restoreReadingPosition(updateState)
259
+ } else {
260
+ if (nextSidebar) nextSidebar.scrollTop = sidebarScrollTop
261
+ if (options.focus) q('#canofold-main', imported)?.focus({ preventScroll: true })
262
+ if (options.hash) {
263
+ let id = options.hash.slice(1)
264
+ try { id = decodeURIComponent(id) } catch {}
265
+ d.getElementById(id)?.scrollIntoView()
266
+ } else {
267
+ window.scrollTo(0, options.scrollY ?? 0)
268
+ }
269
+ }
270
+ return true
271
+ }
272
+ window.__canofoldApplyPageDocument = applyPageDocument
273
+
274
+ function currentNavigationState() {
275
+ return {
276
+ scrollY: window.scrollY,
277
+ sidebarScrollTop: q('[data-canofold-sidebar]')?.scrollTop || 0
278
+ }
279
+ }
280
+
281
+ function historyStateWithNavigation(state) {
282
+ const current = history.state && typeof history.state === 'object' ? history.state : {}
283
+ return { ...current, __canofold: state }
284
+ }
285
+
286
+ function saveCurrentHistoryState() {
287
+ try { history.replaceState(historyStateWithNavigation(currentNavigationState()), '', location.href) } catch {}
288
+ }
289
+
290
+ async function navigatePage(url, { push = true, state } = {}) {
291
+ navigationController?.abort()
292
+ navigationController = new AbortController()
293
+ const response = await fetch(url, {
294
+ cache: 'no-store',
295
+ headers: { accept: 'text/html' },
296
+ signal: navigationController.signal
297
+ })
298
+ if (!response.ok || !(response.headers.get('content-type') || '').includes('text/html')) return false
299
+ const nextDocument = new DOMParser().parseFromString(await response.text(), 'text/html')
300
+ if (!q('[data-canofold-page-root]', nextDocument)) return false
301
+ const navigationState = state || {
302
+ scrollY: 0,
303
+ sidebarScrollTop: q('[data-canofold-sidebar]')?.scrollTop || 0
304
+ }
305
+ if (push) {
306
+ saveCurrentHistoryState()
307
+ history.pushState(historyStateWithNavigation(navigationState), '', url)
308
+ }
309
+ return applyPageDocument(nextDocument, {
310
+ mode: 'navigation',
311
+ hash: url.hash,
312
+ scrollY: navigationState.scrollY,
313
+ sidebarScrollTop: navigationState.sidebarScrollTop,
314
+ focus: push
315
+ })
316
+ }
317
+
318
+ function markAction(button, text) {
319
+ if (!button) return
320
+ const label = button.getAttribute('aria-label') || ''
321
+ button.dataset.actionState = 'success'
322
+ button.setAttribute('aria-label', text)
323
+ clearTimeout(button._dfActionTimer)
324
+ button._dfActionTimer = setTimeout(() => {
325
+ delete button.dataset.actionState
326
+ if (label) button.setAttribute('aria-label', label)
327
+ }, 1500)
328
+ }
329
+
330
+ function copyFallback(text) {
331
+ const area = d.createElement('textarea')
332
+ area.value = text
333
+ area.style.position = 'fixed'
334
+ area.style.opacity = '0'
335
+ d.body.appendChild(area)
336
+ area.focus()
337
+ area.select()
338
+ let copied = false
339
+ try {
340
+ copied = d.execCommand('copy')
341
+ } finally {
342
+ area.remove()
343
+ }
344
+ return copied ? Promise.resolve() : Promise.reject(new Error('Copy command failed'))
345
+ }
346
+
347
+ function copyText(text) {
348
+ if (navigator.clipboard && window.isSecureContext) {
349
+ return navigator.clipboard.writeText(text).catch(() => copyFallback(text))
350
+ }
351
+ return copyFallback(text)
352
+ }
353
+
354
+ qa('[data-canofold-theme-toggle]').forEach((button) => {
355
+ button.setAttribute('aria-pressed', String(root.classList.contains('dark')))
356
+ on(button, 'click', () => {
357
+ const on = root.classList.toggle('dark')
358
+ button.setAttribute('aria-pressed', String(on))
359
+ try { localStorage.setItem('canofold-theme', on ? 'dark' : 'light') } catch {}
360
+ })
361
+ })
362
+
363
+ const sourceSheet = q('[data-canofold-source-sheet]')
364
+ let sourceLastFocus
365
+ function focusable(container) {
366
+ return qa('a[href],button:not([disabled]),input:not([disabled]),textarea:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])', container)
367
+ .filter((element) => element.tabIndex >= 0 && !element.hidden && element.getAttribute('aria-hidden') !== 'true')
368
+ }
369
+ function setSource(value, invoker) {
370
+ if (!sourceSheet) return
371
+ if (value) {
372
+ sourceLastFocus = invoker || d.activeElement
373
+ sourceSheet.hidden = false
374
+ root.classList.add('cf-source-open')
375
+ requestAnimationFrame(() => (focusable(sourceSheet)[0] || q('.cf-source-panel', sourceSheet))?.focus())
376
+ } else {
377
+ const wasOpen = !sourceSheet.hidden
378
+ sourceSheet.hidden = true
379
+ root.classList.remove('cf-source-open')
380
+ if (wasOpen && sourceLastFocus && typeof sourceLastFocus.focus === 'function') sourceLastFocus.focus()
381
+ sourceLastFocus = undefined
382
+ }
383
+ }
384
+ qa('[data-canofold-source-open]').forEach((button) => on(button, 'click', () => {
385
+ setSource(true, button)
386
+ }))
387
+ qa('[data-canofold-source-close]').forEach((button) => on(button, 'click', () => {
388
+ setSource(false)
389
+ }))
390
+ qa('[data-canofold-source-copy]').forEach((button) => on(button, 'click', () => {
391
+ const source = q('[data-canofold-source-text]')
392
+ const success = button.getAttribute('data-canofold-action-success') || 'Markdown source copied'
393
+ if (source) copyText(source.value).then(() => markAction(button, success)).catch(() => {})
394
+ }))
395
+
396
+ qa('[data-canofold-playground-toggle]').forEach((button) => on(button, 'click', () => {
397
+ const playground = button.closest('[data-canofold-playground]')
398
+ if (!playground) return
399
+ const nextView = playground.dataset.view === 'source' ? 'preview' : 'source'
400
+ playground.dataset.view = nextView
401
+ const nextLabel = nextView === 'source'
402
+ ? button.getAttribute('data-preview-label')
403
+ : button.getAttribute('data-source-label')
404
+ if (nextLabel) {
405
+ button.setAttribute('aria-label', nextLabel)
406
+ button.setAttribute('title', nextLabel)
407
+ }
408
+ }))
409
+
410
+ qa('[data-canofold-playground-resizer]').forEach((resizer) => {
411
+ const playground = resizer.closest('[data-canofold-playground]')
412
+ if (!playground) return
413
+ const min = Number(resizer.getAttribute('aria-valuemin')) || 25
414
+ const max = Number(resizer.getAttribute('aria-valuemax')) || 75
415
+ const clamp = (value) => Math.min(max, Math.max(min, value))
416
+ const setSplit = (value) => {
417
+ const next = clamp(value)
418
+ playground.style.setProperty('--cf-playground-source-width', next + '%')
419
+ resizer.setAttribute('aria-valuenow', String(Math.round(next)))
420
+ }
421
+ const splitFromPointer = (event) => {
422
+ const rect = playground.getBoundingClientRect()
423
+ if (!rect.width) return
424
+ const fromStart = (event.clientX - rect.left) / rect.width * 100
425
+ setSplit(getComputedStyle(playground).direction === 'rtl' ? 100 - fromStart : fromStart)
426
+ }
427
+ let dragging = false
428
+ on(resizer, 'pointerdown', (event) => {
429
+ if (event.button !== 0) return
430
+ dragging = true
431
+ playground.dataset.resizing = ''
432
+ resizer.setPointerCapture?.(event.pointerId)
433
+ splitFromPointer(event)
434
+ event.preventDefault()
435
+ })
436
+ on(resizer, 'pointermove', (event) => {
437
+ if (dragging) splitFromPointer(event)
438
+ })
439
+ const stopDragging = (event) => {
440
+ if (!dragging) return
441
+ dragging = false
442
+ delete playground.dataset.resizing
443
+ if (resizer.hasPointerCapture?.(event.pointerId)) resizer.releasePointerCapture(event.pointerId)
444
+ }
445
+ on(resizer, 'pointerup', stopDragging)
446
+ on(resizer, 'pointercancel', stopDragging)
447
+ on(resizer, 'keydown', (event) => {
448
+ const current = Number(resizer.getAttribute('aria-valuenow')) || 45
449
+ const rtl = getComputedStyle(playground).direction === 'rtl'
450
+ let next
451
+ if (event.key === 'Home') next = min
452
+ if (event.key === 'End') next = max
453
+ if (event.key === 'ArrowLeft') next = current + (rtl ? 2 : -2)
454
+ if (event.key === 'ArrowRight') next = current + (rtl ? -2 : 2)
455
+ if (next === undefined) return
456
+ setSplit(next)
457
+ event.preventDefault()
458
+ })
459
+ on(resizer, 'dblclick', () => setSplit(45))
460
+ })
461
+
462
+ const bar = q('[data-canofold-progress]')
463
+ function progress() {
464
+ if (!bar) return
465
+ const max = root.scrollHeight - window.innerHeight
466
+ const scrollTop = window.scrollY || root.scrollTop || 0
467
+ const ratio = max > 0 ? Math.min(1, Math.max(0, scrollTop / max)) : 0
468
+ bar.style.transform = 'scaleX(' + ratio + ')'
469
+ }
470
+ progress()
471
+ on(window, 'scroll', progress, { passive: true })
472
+ on(window, 'resize', progress)
473
+
474
+ const sidebar = q('[data-canofold-sidebar]')
475
+ const backdrop = q('[data-canofold-sidebar-backdrop]')
476
+ const open = q('[data-canofold-sidebar-open]')
477
+ function setSidebar(value) {
478
+ if (!sidebar) return
479
+ sidebar.dataset.open = String(value)
480
+ if (backdrop) backdrop.hidden = !value
481
+ if (open) {
482
+ open.setAttribute('aria-expanded', String(value))
483
+ open.setAttribute(
484
+ 'aria-label',
485
+ value ? open.dataset.canofoldSidebarCloseLabel : open.dataset.canofoldSidebarOpenLabel
486
+ )
487
+ }
488
+ }
489
+ if (open) {
490
+ on(open, 'click', () => setSidebar(open.getAttribute('aria-expanded') !== 'true'))
491
+ }
492
+ if (backdrop) on(backdrop, 'click', () => setSidebar(false))
493
+ qa('[data-canofold-sidebar-link]').forEach((link) => on(link, 'click', () => setSidebar(false)))
494
+
495
+ on(d, 'click', (event) => {
496
+ qa('[data-canofold-menu][open]').forEach((menu) => {
497
+ if (!menu.contains(event.target)) menu.removeAttribute('open')
498
+ })
499
+ if (
500
+ event.defaultPrevented ||
501
+ event.button !== 0 ||
502
+ event.metaKey ||
503
+ event.ctrlKey ||
504
+ event.shiftKey ||
505
+ event.altKey ||
506
+ !(event.target instanceof Element)
507
+ ) return
508
+ const anchor = event.target.closest('a[href]')
509
+ if (!anchor || anchor.hasAttribute('download') || anchor.hasAttribute('data-canofold-no-navigation')) return
510
+ if (anchor.target && anchor.target !== '_self') return
511
+ const url = new URL(anchor.href, location.href)
512
+ if (url.origin !== location.origin || !['http:', 'https:'].includes(url.protocol)) return
513
+ if (url.pathname === location.pathname && url.search === location.search) {
514
+ if (url.hash) return
515
+ event.preventDefault()
516
+ window.scrollTo(0, 0)
517
+ return
518
+ }
519
+ event.preventDefault()
520
+ void navigatePage(url).then((applied) => {
521
+ if (!applied) location.assign(url.href)
522
+ }).catch((error) => {
523
+ if (error?.name !== 'AbortError') location.assign(url.href)
524
+ })
525
+ })
526
+ on(window, 'popstate', (event) => {
527
+ const state = event.state?.__canofold || { scrollY: 0, sidebarScrollTop: 0 }
528
+ const url = new URL(location.href)
529
+ void navigatePage(url, { push: false, state }).then((applied) => {
530
+ if (!applied) location.reload()
531
+ }).catch((error) => {
532
+ if (error?.name !== 'AbortError') location.reload()
533
+ })
534
+ })
535
+ on(d, 'keydown', (event) => {
536
+ if (event.key === 'Tab' && sourceSheet && !sourceSheet.hidden) {
537
+ const items = focusable(sourceSheet)
538
+ if (!items.length) return
539
+ const first = items[0]
540
+ const last = items[items.length - 1]
541
+ if (event.shiftKey && d.activeElement === first) {
542
+ event.preventDefault()
543
+ last.focus()
544
+ } else if (!event.shiftKey && d.activeElement === last) {
545
+ event.preventDefault()
546
+ first.focus()
547
+ }
548
+ return
549
+ }
550
+ if (event.key !== 'Escape') return
551
+ setSidebar(false)
552
+ qa('[data-canofold-menu][open]').forEach((menu) => menu.removeAttribute('open'))
553
+ setSource(false)
554
+ })
555
+ window.__canofoldShellDispose = () => {
556
+ controller.abort()
557
+ qa('[data-action-state]').forEach((button) => clearTimeout(button._dfActionTimer))
558
+ root.classList.remove('cf-source-open')
559
+ }
560
+ }
561
+ window.__canofoldBootstrapShell()`,uo=`window.__canofoldBootstrapOutline = () => {
562
+ window.__canofoldOutlineDispose?.()
563
+ const controller = new AbortController()
564
+ const signal = controller.signal
565
+ const links = Array.from(document.querySelectorAll('[data-canofold-outline-link]'))
566
+ const map = Object.create(null)
567
+ links.forEach((link) => {
568
+ const href = link.getAttribute('href') || ''
569
+ try { map[decodeURIComponent(href.slice(1))] = link } catch {}
570
+ })
571
+ const headings = Object.keys(map).map((id) => document.getElementById(id)).filter(Boolean)
572
+ let current
573
+ let queued = false
574
+ let frame
575
+ let hashTimer
576
+ function setActive(link) {
577
+ if (current === link) return
578
+ if (current) delete current.dataset.active
579
+ current = link
580
+ if (!link) return
581
+ link.dataset.active = 'true'
582
+ const panel = link.closest('[data-canofold-outline]')
583
+ if (!panel) return
584
+ const linkRect = link.getBoundingClientRect()
585
+ const panelRect = panel.getBoundingClientRect()
586
+ if (linkRect.top < panelRect.top + 48) {
587
+ panel.scrollTop -= panelRect.top + 48 - linkRect.top
588
+ } else if (linkRect.bottom > panelRect.bottom - 24) {
589
+ panel.scrollTop += linkRect.bottom - panelRect.bottom + 24
590
+ }
591
+ }
592
+ function update() {
593
+ queued = false
594
+ if (!headings.length) return
595
+ const header = document.querySelector('.cf-header')?.getBoundingClientRect().height || 58
596
+ const readingLine = header + 48
597
+ let active = headings[0]
598
+ for (const heading of headings) {
599
+ if (heading.getBoundingClientRect().top <= readingLine) active = heading
600
+ else break
601
+ }
602
+ if (window.innerHeight + window.scrollY >= document.documentElement.scrollHeight - 2) {
603
+ active = headings[headings.length - 1]
604
+ }
605
+ if (active) setActive(map[active.id])
606
+ }
607
+ function schedule() {
608
+ if (queued) return
609
+ queued = true
610
+ frame = requestAnimationFrame(update)
611
+ }
612
+ window.addEventListener('scroll', schedule, { passive: true, signal })
613
+ window.addEventListener('resize', schedule, { signal })
614
+ window.addEventListener('hashchange', () => { hashTimer = setTimeout(update, 0) }, { signal })
615
+ update()
616
+ window.__canofoldOutlineDispose = () => {
617
+ controller.abort()
618
+ if (frame) cancelAnimationFrame(frame)
619
+ if (hashTimer) clearTimeout(hashTimer)
620
+ }
621
+ }
622
+ window.__canofoldBootstrapOutline()`;import{Fragment as ia,jsx as P,jsxs as re}from"react/jsx-runtime";function po({config:e,graph:t,page:o,home:r=!1,markdownAssets:a,rawSource:i,children:l}){let n=io({config:e,graph:t,page:o,home:r,assets:a,rawSource:i}),d=n.assets.behaviors.length>0,u=n.assets.pluginClients.map(h=>g(e,`/assets/canofold-plugins/${h.id}.js`)),c=V(e,o.routePath),p=g(e,e.theme.favicon??ye),m=[e.layout.header?void 0:"cf-header-hidden",o.frontmatter.layout==="playground"?"cf-playground-page":void 0].filter(Boolean).join(" "),w=o.frontmatter.layout==="playground";return re("html",{lang:o.locale,className:m||void 0,children:[re("head",{children:[P("meta",{charSet:"utf-8"}),P("meta",{name:"viewport",content:"width=device-width, initial-scale=1"}),P("title",{children:n.title}),P("meta",{name:"description",content:n.description,"data-canofold-page-head":""}),P("meta",{property:"og:title",content:n.title,"data-canofold-page-head":""}),P("meta",{property:"og:description",content:n.description,"data-canofold-page-head":""}),e.search.enabled&&o.search?re(ia,{children:[P("meta",{"data-pagefind-meta":"title[content]",content:o.title,"data-canofold-page-head":""}),P("meta",{"data-pagefind-meta":"description[content]",content:o.description,"data-canofold-page-head":""}),P("meta",{"data-pagefind-filter":`version:${o.version}`,"data-canofold-page-head":""}),P("meta",{"data-pagefind-filter":`locale:${o.locale}`,"data-canofold-page-head":""}),P("meta",{"data-pagefind-filter":`status:${o.status}`,"data-canofold-page-head":""}),(Array.isArray(o.frontmatter.tags)?o.frontmatter.tags:[]).filter(h=>typeof h=="string").map(h=>P("meta",{"data-pagefind-filter":`tag:${h}`,"data-canofold-page-head":""},h))]}):null,c?P("meta",{property:"og:url",content:c,"data-canofold-page-head":""}):null,P("meta",{name:"twitter:card",content:"summary"}),P("link",{rel:"icon",href:p}),c?P("link",{rel:"canonical",href:c,"data-canofold-page-head":""}):null,e.siteUrl?n.alternatePages.map(h=>P("link",{rel:"alternate",hrefLang:h.locale,href:V(e,h.routePath),"data-canofold-page-head":""},h.locale)):null,P("link",{rel:"stylesheet",href:g(e,"/assets/canofold.css")}),n.assets.pluginStyles.map(h=>P("link",{rel:"stylesheet",href:g(e,`/assets/canofold-plugins/${h.id}.css`),"data-canofold-page-head":""},h.id)),e.theme.darkMode?P("script",{dangerouslySetInnerHTML:{__html:we}}):null]}),re("body",{children:[re("div",{className:"cf-page-root",style:{"--cf-canofold-config-icon":`url(${JSON.stringify(p)})`},"data-canofold-page-root":"","data-markdown-behaviors":d?JSON.stringify(n.assets.behaviors):void 0,"data-markdown-client-url":d?g(e,"/assets/canofold-markdown/index.js"):void 0,"data-markdown-plugin-clients":u.length>0?JSON.stringify(u):void 0,"data-canofold-playground-client-url":w?g(e,"/assets/canofold-playground/index.js"):void 0,children:[P("a",{className:"cf-skip-link",href:"#canofold-main",children:n.labels.skipToContent}),e.layout.header?P(eo,{model:n}):null,r?P("main",{id:"canofold-main",className:"cf-home",tabIndex:-1,"data-pagefind-body":o.search?"":void 0,children:l}):P(so,{model:n,children:l}),P(lo,{model:n})]}),P("script",{type:"module",dangerouslySetInnerHTML:{__html:n.markdownClientScript}}),w?P("script",{type:"module",src:g(e,"/assets/canofold-playground/index.js")}):null,P("script",{dangerouslySetInnerHTML:{__html:co}}),P("script",{dangerouslySetInnerHTML:{__html:uo}}),e.search.enabled?P("script",{type:"module",src:g(e,"/assets/canofold-search.js")}):null]})]})}s(po,"Layout");import{createMarkdownRenderer as Ma}from"@canofold/markdown/server";import*as Da from"react";import*as Na from"react/jsx-runtime";import{analyzeMdxModuleBoundary as la}from"@canofold/markdown/server/analyze";var ca=["react","react/jsx-runtime"],da=new Set(ca);function Ie(e){return da.has(e)}s(Ie,"isDocsImportSpecifier");function Be(e){return e.startsWith(".")||Ie(e)}s(Be,"isAllowedDocsImport");function ke(e){let t=la(e);for(let o of t.unsupportedReferences){let r=o.kind==="dynamic-import"?"Dynamic import":"Re-export";throw new Error(`${r} is not allowed in MDX${o.specifier?`: ${o.specifier}`:""}`)}for(let{specifier:o}of t.imports)if(!Be(o))throw new Error(`External import is not allowed: ${o}`);return{source:t.sourceWithoutImports,imports:t.imports}}s(ke,"prepareMdxSource");import{access as ua,readFile as pa,realpath as Pe}from"fs/promises";import{dirname as ma,extname as ho,isAbsolute as He,relative as go,resolve as mo,sep as yo}from"path";import{build as fa}from"esbuild";import*as ha from"react";import*as ga from"react/jsx-runtime";import{detectMarkdownAssets as ya}from"@canofold/markdown/server/analyze";var _e=[".tsx",".ts",".jsx",".js"],fo={react:ha,"react/jsx-runtime":ga};function ba(e){if(Object.hasOwn(fo,e))return fo[e];throw new Error(`External import is not allowed in local docs components: ${e}`)}s(ba,"requireLocalComponentRuntime");function ve(e,t){let o=go(e,t);return o===""||!o.startsWith(`..${yo}`)&&o!==".."&&!He(o)}s(ve,"isInsideRoot");async function Ue(e){try{return await ua(e),!0}catch{return!1}}s(Ue,"fileExists");async function qe(e,t){let o=await Pe(e);if(!t)return o;let r=await Pe(t),a=go(r,o);if(a===".."||a.startsWith(`..${yo}`)||He(a))throw new Error(`Local component import escapes the project root: ${e}`);return o}s(qe,"assertInsideProjectRoot");async function je(e,t,o){let r=mo(ma(e),t),a=ho(r);if(a&&!_e.includes(a))throw new Error(`Unsupported local component import: ${t}`);if(a&&await Ue(r))return qe(r,o);for(let i of _e){let l=`${r}${i}`;if(await Ue(l))return qe(l,o)}for(let i of _e){let l=mo(r,`index${i}`);if(await Ue(l))return qe(l,o)}throw new Error(`Local component import not found: ${t}`)}s(je,"resolveLocalModule");async function wa(e,t){let o=t?await Pe(t):void 0,r=new Set([e]),i=(await fa({entryPoints:[e],bundle:!0,outfile:"local-component.js",write:!1,platform:"node",format:"cjs",target:"node22",jsx:"automatic",plugins:[{name:"canofold-components-alias",setup(l){l.onResolve({filter:/^(?:react|react\/jsx-runtime)$/},n=>({path:n.path,external:!0})),l.onResolve({filter:/.*/},async n=>{if(!He(n.path)||!n.importer||!(o?ve(o,n.importer):r.has(n.importer)))return;let u=await je(n.importer,n.path,t);return r.add(u),{path:u}}),l.onResolve({filter:/^\./},async n=>{if(n.importer&&!(o?ve(o,n.importer):r.has(n.importer)))return;let d=await je(n.importer,n.path,t);return r.add(d),{path:d}}),l.onLoad({filter:/\.(?:[jt]sx?)$/},async n=>{let d=await Pe(n.path);(o?ve(o,d):r.has(d))&&r.add(d)}),l.onResolve({filter:/^react-dom$/},n=>(n.importer?o?ve(o,n.importer):r.has(n.importer):!1)?{errors:[{text:"External import is not allowed in local docs components: react-dom"}]}:void 0),l.onResolve({filter:/^[^./].*/},n=>{if(!Be(n.path))return{errors:[{text:`External import is not allowed in local docs components: ${n.path}`}]}})}}]})).outputFiles.find(l=>ho(l.path)===".js");if(!i)throw new Error(`Failed to bundle local component: ${e}`);return{code:i.text,sourcePaths:[...r]}}s(wa,"bundleLocalModule");async function ka(e){let t={exports:{}};return new Function("module","exports","require",e.code)(t,t.exports,ba),t.exports}s(ka,"importBundle");function va(e){return e.filter(t=>t.specifier.startsWith("."))}s(va,"localImports");async function bo(e,t,o){let r=va(e);if(!r.length)return[];if(!t)throw new Error("Local MDX component imports require the Markdown source file path");let a=new Map;return Promise.all(r.map(async i=>{let l=await je(t,i.specifier,o),n=a.get(l);return n||(n=wa(l,o),a.set(l,n)),{localImport:i,bundle:await n}}))}s(bo,"bundleLocalImports");async function wo(e,t,o){let r=await bo(e,t,o);return[...new Set(r.flatMap(({bundle:a})=>a.sourcePaths))].sort()}s(wo,"localComponentDependencyPaths");async function Pa(e){let t={},o=new Map;for(let{localImport:r,bundle:a}of e){let i=o.get(a);i||(i=ka(a),o.set(a,i));let l=await i;for(let n of r.bindings)if(n.namespace)t[n.local]=l;else{if(!Object.hasOwn(l,n.imported))throw new Error(`Local module ${JSON.stringify(r.specifier)} does not export ${JSON.stringify(n.imported)}`);t[n.local]=l[n.imported]}}return t}s(Pa,"componentsFromBundles");function Sa(e,t){e.behaviors=[...new Set([...e.behaviors,...t.behaviors])],e.math||=t.math,e.pluginClients=[...new Map([...e.pluginClients,...t.pluginClients].map(o=>[o.id,o])).values()],e.pluginStyles=[...new Map([...e.pluginStyles,...t.pluginStyles].map(o=>[o.id,o])).values()]}s(Sa,"mergeAssets");function xa(){return{behaviors:[],math:!1,pluginClients:[],pluginStyles:[]}}s(xa,"emptyAssets");async function Ca(e,t=[]){let o=xa(),r=new Set;for(let{bundle:a}of e)for(let i of a.sourcePaths)r.has(i)||(r.add(i),Sa(o,ya(await pa(i,"utf8"),t,"mdx")));return o}s(Ca,"assetsFromBundles");async function ko(e,t,o,r=[]){let a=await bo(e,t,o),[i,l]=await Promise.all([Pa(a),Ca(a,r)]);return{components:i,assets:l}}s(ko,"loadLocalComponentBundle");function Aa(...e){return{behaviors:[...new Set(e.flatMap(t=>t.behaviors))],math:e.some(t=>t.math),pluginClients:[...new Map(e.flatMap(t=>t.pluginClients).map(t=>[t.id,t])).values()],pluginStyles:[...new Map(e.flatMap(t=>t.pluginStyles).map(t=>[t.id,t])).values()]}}s(Aa,"mergeAssets");function Ea(e,t){let o={react:Da,"react/jsx-runtime":Na},r={...t};for(let a of e){if(!Ie(a.specifier))continue;let i=o[a.specifier];for(let l of a.bindings){if(l.namespace){r[l.local]=i;continue}if(l.imported==="default"&&a.specifier==="react"){r[l.local]=i.default??i;continue}if(!Object.hasOwn(i,l.imported))throw new Error(`Module ${JSON.stringify(a.specifier)} does not export ${JSON.stringify(l.imported)}`);r[l.local]=i[l.imported]}}return r}s(Ea,"bindImports");async function vo(e,t,o,r,a,i,l=Ma()){let n=ke(e),{components:d,assets:u}=await ko(n.imports,t,o,r?.plugins),c=await l.renderMdx(n.source,{markdown:r,classNames:a,urlTransform:i,as:"article",components:{...Ea(n.imports,d)}});return{content:c.content,assets:Aa(c.assets,u)}}s(vo,"renderMdxResult");import{mkdir as La}from"fs/promises";import{dirname as Ra,join as Ta}from"path";import{fileURLToPath as Oa}from"url";function $a(){let e=import.meta.url.endsWith(".js")?"./search-client.js":"./searchClientRuntime.ts";return Oa(new URL(e,import.meta.url))}s($a,"searchRuntimeEntry");async function Po(e){let{build:t}=await import("esbuild"),o=Ta(e,"assets/canofold-search.js");await La(Ra(o),{recursive:!0}),await t({entryPoints:[$a()],bundle:!0,format:"iife",platform:"browser",target:"es2022",outfile:o,minify:!0,sourcemap:!1,legalComments:"none",logLevel:"silent"})}s(Po,"buildSearchBundle");import{DEFAULT_SEMANTIC_COLORS as A,DEFAULT_MARKDOWN_THEME as Ge,markdownThemeDeclarations as Fa,resolveMarkdownTheme as Ia}from"@canofold/markdown/theme";var Ba={canofold:{light:A.light.blue,dark:A.dark.blue},cyan:{light:A.light.cyan,dark:A.dark.cyan},emerald:{light:A.light.green,dark:A.dark.green},blue:{light:A.light.blue,dark:A.dark.blue},green:{light:A.light.green,dark:A.dark.green},red:{light:A.light.red,dark:A.dark.red},orange:{light:A.light.orange,dark:A.dark.orange},violet:{light:A.light.indigo,dark:A.dark.indigo},neutral:{light:"oklch(0.3 0 0)",dark:"oklch(0.85 0 0)"}};function So(e){let t=Ge.colors[e];return{background:t.canvas,foreground:t.foreground,text:t.text,muted:t.muted,muted2:t.mutedSubtle,card:t.surface,card2:t.surfaceSecondary,soft:t.surfaceSoft,popover:t.surfaceElevated,border:t.border,borderStrong:t.borderStrong,hairline:t.hairline,primarySoft:t.primarySoft,primaryForeground:t.primaryForeground,primaryDeep:t.primaryDeep,accent:t.accent,info:t.info,infoDeep:t.infoDeep,success:t.success,successDeep:t.successDeep,warning:t.warning,warningDeep:t.warningDeep,danger:t.danger,dangerDeep:t.dangerDeep,codeBackground:t.codeBackground,codeForeground:t.codeForeground,overlay:t.overlay,shadow:t.shadow,shadowSmall:t.shadowSmall}}s(So,"paletteFromMarkdown");var _a={paper:{light:So("light"),dark:So("dark")},neutral:{light:{background:"oklch(0.994 0.003 95)",foreground:"oklch(0.205 0.008 80)",text:"color-mix(in oklab, var(--cf-ink) 88%, var(--cf-ink-secondary))",muted:"oklch(0.505 0.01 80)",muted2:"oklch(0.62 0.01 80)",card:"oklch(0.985 0.004 95)",card2:"oklch(0.96 0.004 95)",soft:"oklch(0.955 0.006 95)",popover:"oklch(0.997 0.002 95)",border:"transparent",borderStrong:"transparent",hairline:"oklch(0.93 0.004 90)"},dark:{background:"oklch(0.17 0.006 85)",foreground:"oklch(0.92 0.005 90)",text:"color-mix(in oklab, var(--cf-ink) 88%, var(--cf-ink-secondary))",muted:"oklch(0.66 0.01 88)",muted2:"oklch(0.54 0.01 88)",card:"oklch(0.205 0.006 85)",card2:"oklch(0.235 0.006 85)",soft:"oklch(0.255 0.007 85)",popover:"oklch(0.21 0.006 85)",border:"transparent",borderStrong:"transparent",hairline:"oklch(1 0 0 / 6%)"}},slate:{light:{background:"oklch(0.99 0.004 250)",foreground:"oklch(0.22 0.018 255)",text:"color-mix(in oklab, var(--cf-ink) 88%, var(--cf-ink-secondary))",muted:"oklch(0.49 0.02 255)",muted2:"oklch(0.61 0.018 255)",card:"oklch(0.982 0.005 250)",card2:"oklch(0.955 0.007 250)",soft:"oklch(0.95 0.01 250)",popover:"oklch(0.996 0.003 250)",border:"transparent",borderStrong:"transparent",hairline:"oklch(0.93 0.008 250)"},dark:{background:"oklch(0.17 0.014 255)",foreground:"oklch(0.92 0.006 250)",text:"color-mix(in oklab, var(--cf-ink) 88%, var(--cf-ink-secondary))",muted:"oklch(0.68 0.018 250)",muted2:"oklch(0.54 0.018 250)",card:"oklch(0.21 0.014 255)",card2:"oklch(0.25 0.014 255)",soft:"oklch(0.27 0.014 255)",popover:"oklch(0.215 0.014 255)",border:"transparent",borderStrong:"transparent",hairline:"oklch(1 0 0 / 6%)"}},zinc:{light:{background:"oklch(0.992 0 0)",foreground:"oklch(0.21 0.005 285)",text:"color-mix(in oklab, var(--cf-ink) 88%, var(--cf-ink-secondary))",muted:"oklch(0.5 0.01 285)",muted2:"oklch(0.62 0.008 285)",card:"oklch(0.982 0.002 285)",card2:"oklch(0.955 0.003 285)",soft:"oklch(0.95 0.003 285)",popover:"oklch(0.996 0 0)",border:"transparent",borderStrong:"transparent",hairline:"oklch(0.93 0.003 285)"},dark:{background:"oklch(0.17 0.004 285)",foreground:"oklch(0.92 0.003 285)",text:"color-mix(in oklab, var(--cf-ink) 88%, var(--cf-ink-secondary))",muted:"oklch(0.67 0.006 285)",muted2:"oklch(0.54 0.006 285)",card:"oklch(0.21 0.004 285)",card2:"oklch(0.245 0.004 285)",soft:"oklch(0.265 0.004 285)",popover:"oklch(0.215 0.004 285)",border:"transparent",borderStrong:"transparent",hairline:"oklch(1 0 0 / 6%)"}},stone:{light:{background:"oklch(0.992 0.004 70)",foreground:"oklch(0.22 0.01 70)",text:"color-mix(in oklab, var(--cf-ink) 88%, var(--cf-ink-secondary))",muted:"oklch(0.5 0.012 70)",muted2:"oklch(0.62 0.012 70)",card:"oklch(0.982 0.005 70)",card2:"oklch(0.955 0.006 70)",soft:"oklch(0.95 0.007 70)",popover:"oklch(0.996 0.003 70)",border:"transparent",borderStrong:"transparent",hairline:"oklch(0.93 0.006 70)"},dark:{background:"oklch(0.17 0.008 70)",foreground:"oklch(0.92 0.005 70)",text:"color-mix(in oklab, var(--cf-ink) 88%, var(--cf-ink-secondary))",muted:"oklch(0.67 0.01 70)",muted2:"oklch(0.54 0.01 70)",card:"oklch(0.21 0.008 70)",card2:"oklch(0.245 0.008 70)",soft:"oklch(0.265 0.008 70)",popover:"oklch(0.215 0.008 70)",border:"transparent",borderStrong:"transparent",hairline:"oklch(1 0 0 / 6%)"}}};function ze(e){return typeof e=="number"?`${e}px`:e}s(ze,"cssLength");function Ua(e,t){return Ba[t]?.[e]??t}s(Ua,"accentFor");function xo(e,t){let o=Ua(t,e.theme.accentColor),r=_a[e.theme.baseColor][t],a=e.theme.accentColor==="canofold",i=Ge.colors[t];return{...r,primary:o,primarySoft:a&&r.primarySoft?r.primarySoft:`color-mix(in oklab, ${o} 12%, var(--cf-surface))`,primaryForeground:a&&r.primaryForeground?r.primaryForeground:`color-mix(in oklab, ${o} 76%, var(--cf-ink))`,primaryDeep:a&&r.primaryDeep?r.primaryDeep:`color-mix(in oklab, ${o} 84%, var(--cf-ink))`,accent:r.accent??o,info:r.info??i.info,infoDeep:r.infoDeep??i.infoDeep,success:r.success??i.success,successDeep:r.successDeep??i.successDeep,warning:r.warning??i.warning,warningDeep:r.warningDeep??i.warningDeep,danger:r.danger??i.danger,dangerDeep:r.dangerDeep??i.dangerDeep,codeBackground:r.codeBackground??r.card2??r.card,codeForeground:r.codeForeground??r.foreground,overlay:r.overlay??i.overlay,shadow:r.shadow??i.shadow,shadowSmall:r.shadowSmall??i.shadowSmall}}s(xo,"resolveTokens");function Co(e,t){let o=Ge.colors[t];return{canvas:e.background??o.canvas,foreground:e.foreground??o.foreground,text:e.text??o.text,muted:e.muted??o.muted,mutedSubtle:e.muted2??o.mutedSubtle,surface:e.card??o.surface,surfaceSecondary:e.card2??o.surfaceSecondary,surfaceSoft:e.soft??o.surfaceSoft,surfaceElevated:e.popover??o.surfaceElevated,border:e.border??o.border,borderStrong:e.borderStrong??o.borderStrong,hairline:e.hairline??o.hairline,primary:e.primary??o.primary,primarySoft:e.primarySoft??o.primarySoft,primaryForeground:e.primaryForeground??o.primaryForeground,primaryDeep:e.primaryDeep??o.primaryDeep,accent:e.accent??o.accent,info:e.info??o.info,infoDeep:e.infoDeep??o.infoDeep,success:e.success??o.success,successDeep:e.successDeep??o.successDeep,warning:e.warning??o.warning,warningDeep:e.warningDeep??o.warningDeep,danger:e.danger??o.danger,dangerDeep:e.dangerDeep??o.dangerDeep,codeBackground:e.codeBackground??o.codeBackground,codeForeground:e.codeForeground??o.codeForeground,overlay:e.overlay??o.overlay,shadow:e.shadow??o.shadow,shadowSmall:e.shadowSmall??o.shadowSmall}}s(Co,"themeColors");function qa(e){let t=ze(e.theme.radius);return Ia({colors:{light:{...Co(xo(e,"light"),"light"),...e.theme.tokens.colors?.light},dark:{...Co(xo(e,"dark"),"dark"),...e.theme.tokens.colors?.dark}},typography:e.theme.tokens.typography,layout:e.theme.tokens.layout,geometry:{radiusSmall:t,radiusMedium:t,radiusLarge:t,...e.theme.tokens.geometry},motion:e.theme.tokens.motion})}s(qa,"resolveCanofoldTheme");function Mo(e,t){let o=t.colors[e].primary;return`${Fa(t,e)}
623
+ --cf-accent-50: color-mix(in oklab, ${o} 8%, var(--cf-surface));
624
+ --cf-accent-100: color-mix(in oklab, ${o} 16%, var(--cf-surface));
625
+ --cf-accent-200: color-mix(in oklab, ${o} 28%, var(--cf-surface));
626
+ --cf-accent-300: color-mix(in oklab, ${o} 48%, var(--cf-surface));
627
+ --cf-accent-400: color-mix(in oklab, ${o} 78%, var(--cf-surface));
628
+ --cf-accent-600: color-mix(in oklab, ${o} 88%, var(--cf-ink));
629
+ --cf-accent-700: color-mix(in oklab, ${o} 76%, var(--cf-ink));
630
+ --cf-accent-800: color-mix(in oklab, ${o} 62%, var(--cf-ink));
631
+ --cf-accent-900: color-mix(in oklab, ${o} 48%, var(--cf-ink));`}s(Mo,"paletteCss");function Do(e){let t=qa(e),o=ze(e.theme.sidebarWidth),r=ze(e.theme.outlineWidth),a=`:root {
632
+ ${Mo("light",t)}
633
+ --cf-sidebar-width: ${o};
634
+ --cf-outline-width: ${r};
635
+ }`;return e.theme.darkMode?`${a}
636
+ .dark {
637
+ ${Mo("dark",t)}
638
+ }`:a}s(Do,"buildThemeVariables");function ja(e,t){if(t==="/")return e;let o=t.replace(/\/$/,"");return e===o||e.startsWith(`${o}/`)||!e.startsWith("/")||e.startsWith("//")?e:`${o}${e}`}s(ja,"withBasePath");function No(e){return t=>ja(t,e)}s(No,"createBasePathUrlTransform");import{rm as Ha}from"fs/promises";import{fileURLToPath as za}from"url";import{join as Ga}from"path";import{build as Ka}from"esbuild";function ae(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}s(ae,"jsonForJavaScript");function Va(){let e=import.meta.url.endsWith(".js")?"./playground-client.js":"./playgroundClient.tsx";return za(new URL(e,import.meta.url))}s(Va,"playgroundRuntimeEntry");async function Ao(e,t,o){let r=Ga(t,"assets/canofold-playground");await Ha(r,{recursive:!0,force:!0});let a=o.markdown.plugins.map(u=>{if(!u.browserCompiler)throw new Error(`Markdown plugin "${u.name}" must declare browserCompiler to support Playground realtime preview`);return u.browserCompiler}),i=a.map((u,c)=>`import { ${u.exportName} as canofoldPlugin${c} } from ${ae(u.module)}`).join(`
639
+ `),l=a.map((u,c)=>u.options===void 0?`canofoldPlugin${c}()`:`canofoldPlugin${c}(${ae(u.options)})`).join(`,
640
+ `),n={html:o.markdown.html,code:o.markdown.code,features:o.markdown.features},d=`import { mountPlaygrounds } from ${ae(Va())}
641
+ ${i}
642
+
643
+ const options = {
644
+ basePath: ${ae(o.basePath)},
645
+ markdown: { ...${ae(n)}, plugins: [
646
+ ${l}
647
+ ] }
648
+ }
649
+ window.__canofoldBootstrapPlayground = () => mountPlaygrounds(options)
650
+ window.__canofoldBootstrapPlayground()`;await Ka({absWorkingDir:e,stdin:{contents:d,loader:"js",resolveDir:e,sourcefile:"canofold-playground-entry.js"},bundle:!0,format:"esm",platform:"browser",target:"es2022",outdir:r,entryNames:"index",chunkNames:"chunks/[name]-[hash]",assetNames:"assets/[name]-[hash]",splitting:!0,minify:!0,sourcemap:!1,define:{"process.env.NODE_ENV":JSON.stringify("production")},logLevel:"silent"})}s(Ao,"buildPlaygroundBundle");import{copyFile as se,cp as Ro,lstat as Wa,mkdir as Se,readFile as Ve,readdir as To,realpath as Eo,rm as Oo,stat as Ja}from"fs/promises";import{createRequire as $o}from"module";import{dirname as ie,join as I,posix as z,relative as Xa,resolve as ne}from"path";import{analyzeMarkdown as Ya}from"@canofold/markdown/server/analyze";var We=$o(import.meta.url);async function Qa(e,t){await Ro(e,t,{recursive:!0,filter:s(async o=>(await Ja(o)).isDirectory()||o.endsWith(".js"),"filter")})}s(Qa,"copyJavaScriptDirectory");async function Fo(e){let t=We.resolve("@canofold/markdown/client"),o=I(e,"assets/canofold-markdown");await Qa(ie(t),o)}s(Fo,"copyMarkdownClient");var Za=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function Lo(e,t,o){if(!Za.test(t.id))throw new Error(`Invalid Markdown plugin ${o} id: ${t.id}`);let r=e.get(t.id);if(r&&JSON.stringify(r)!==JSON.stringify(t))throw new Error(`Markdown plugin ${o} id "${t.id}" is declared by both "${r.module}" and "${t.module}"`);e.set(t.id,t)}s(Lo,"registerPluginAsset");function Ke(e,t){if(!e||e.startsWith("/")||e.includes("\\")||e.split("/").some(o=>o===""||o==="."||o===".."))throw new Error(`Invalid Markdown plugin ${t} path: ${e}`)}s(Ke,"assertSafePluginResourcePath");async function Io(e,t,o){await Se(t,{recursive:!0});for(let r of await To(e,{withFileTypes:!0})){if(r.isSymbolicLink())throw new Error(`Markdown plugin resources must not use symbolic links: ${I(e,r.name)}`);let a=I(e,r.name),i=I(t,r.name);r.isDirectory()?await Io(a,i,o):r.isFile()&&(!o.extensions||o.extensions.some(l=>r.name.endsWith(l)))&&await se(a,i)}}s(Io,"copyPluginResourceDirectory");async function en(e,t){let o=We.resolve(t.module);if(await se(o,I(e,`${t.id}.js`)),!t.resources?.length)return;let r=I(e,t.id),a=$o(o);for(let i of t.resources){Ke(i.output,"resource output");let l=a.resolve(i.module),n=ne(r,i.output);if(!ee(r,n))throw new Error(`Markdown plugin resource output escapes its client directory: ${i.output}`);await Se(ie(n),{recursive:!0}),await se(l,n);for(let d of i.directories??[]){Ke(d.source,"resource source"),Ke(d.output,"resource directory output");let u=ie(l),c=ne(u,d.source),p=ne(r,d.output);if(!ee(u,c)||!ee(r,p))throw new Error(`Markdown plugin resource directory escapes its declared root: ${d.source}`);await Io(c,p,d)}}}s(en,"copyMarkdownPluginClient");function ce(e,t,o){e.pluginClients.forEach(r=>Lo(t,r,"client")),e.pluginStyles.forEach(r=>Lo(o,r,"style"))}s(ce,"registerPluginAssets");async function Bo(e,t,o){let r=I(e,"assets/canofold-plugins");await Oo(r,{recursive:!0,force:!0}),!(t.size===0&&o.size===0)&&(await Se(r,{recursive:!0}),await Promise.all([...[...t.values()].map(a=>en(r,a)),...[...o.values()].map(a=>se(We.resolve(a.module),I(r,`${a.id}.css`)))]))}s(Bo,"copyMarkdownPluginAssets");async function Je(e,t){try{await Ro(e,t,{recursive:!0,force:!0})}catch(o){throw new Error(`Failed to copy required KaTeX fonts from ${e}`,{cause:o})}}s(Je,"copyRequiredMathFonts");async function Xe(e,t){let o=[];async function r(i,l){for(let n of await To(i,{withFileTypes:!0})){if(n.isSymbolicLink())throw new Error(`Public assets must not be symbolic links: ${z.join(l,n.name)}`);let d=I(i,n.name),u=z.join(l,n.name);n.isDirectory()?await r(d,u):n.isFile()&&o.push({source:d,outputPath:u})}}s(r,"walk");let a=new Set(t.versions.items.map(i=>i.docsDir));for(let i of a){let l=I(K(e,i,`public directory for ${i}`),"public");try{await r(l,"")}catch(n){if(n.code!=="ENOENT")throw n}}return o}s(Xe,"collectPublicAssets");function _o(e){let t=Ya(e);return[...new Set([...t.images,...t.links])].map(o=>(o.split("#")[0]??"").split("?")[0]??"").filter(o=>o&&!o.startsWith("/")&&!/^(?:[a-z][a-z\d+.-]*:|\/\/|#)/i.test(o)&&!/\.mdx?$/i.test(o))}s(_o,"relativeAssetTargets");function Uo(e){return e.split("/").map(t=>{let o=decodeURIComponent(t);if(o.includes("/")||o.includes("\\"))throw new Error(`Invalid relative asset path: ${e}`);return o}).join("/")}s(Uo,"decodeRelativeUrlPath");async function Ye(e,t){let o=[];for(let r of t){let a=K(e,r.docsDir,"docsDir"),i=await Eo(a);for(let l of _o(r.body)){let n=Uo(l),d=ne(ie(r.sourcePath),n),u;try{u=await Wa(d)}catch(m){if(m.code==="ENOENT")continue;throw m}if(u.isSymbolicLink())throw new Error(`Relative assets must not use symbolic links: ${l}`);if(!u.isFile())continue;let c=await Eo(d),p=ne(i,Xa(a,d));if($(c)!==$(p))throw new Error(`Relative assets must not use symbolic links: ${l}`);if(!ee(i,c))throw new Error(`Relative asset must stay inside docsDir: ${l}`);o.push({source:c,outputPath:z.resolve("/",z.dirname(r.outputPath),n).slice(1)})}}return o}s(Ye,"collectPageAssets");function le(e){let t=new Set;for(let o of e){if("assetOutputPaths"in o&&o.assetOutputPaths){o.assetOutputPaths.forEach(r=>t.add(r));continue}if("body"in o)for(let r of _o(o.body)){let a=Uo(r);t.add(z.resolve("/",z.dirname(o.outputPath),a).slice(1))}}return t}s(le,"pageAssetOutputPathsFor");async function qo(e,t,o,r){if(!t.length)return;let a=new Set([...le(o),...r].map($)),i=[...le(t)].filter(l=>!a.has($(l)));await Promise.all(i.map(l=>Oo(T(e,l,`stale page asset ${l}`),{force:!0})))}s(qo,"removeStalePageAssets");async function Qe(e,t,o){let r=new Set([...o].map($)),a=s(u=>{let c=[],p=z.dirname(u);for(;p!==".";)c.push(p),p=z.dirname(p);return c},"ancestorsOf"),i=new Set([...r].flatMap(u=>a(u))),l=Pt.map($),n=new Map,d=new Set;for(let u of t){let c=$(u.outputPath),p=a(c);if(r.has(c)||i.has(c)||p.some(h=>r.has(h))||l.some(h=>c===h||c.startsWith(`${h}/`)))throw new Error(`Static asset conflicts with generated output: ${u.outputPath}`);let m=n.get(c);if(m&&m!==u.source){let[h,S]=await Promise.all([Ve(m),Ve(u.source)]);if(!h.equals(S))throw new Error(`Multiple static assets target the same output path: ${u.outputPath}`)}if(m)continue;if(d.has(c)||p.some(h=>n.has(h)))throw new Error(`Multiple static assets target overlapping output paths: ${u.outputPath}`);n.set(c,u.source);for(let h of p)d.add(h);let w=T(e,u.outputPath,`static asset ${u.outputPath}`);await Se(ie(w),{recursive:!0}),await se(u.source,w)}}s(Qe,"copyStaticAssets");async function jo(e,t){return t.length?(await Promise.all(t.map(async r=>{let a=await Ve(K(e,r,"styles entry"),"utf8");return`/* User style: ${r} */
651
+ ${a}`}))).join(`
652
+ `):""}s(jo,"readCustomStyles");import{Fragment as cn,jsx as tt,jsxs as dn}from"react/jsx-runtime";var an={behaviors:[],math:!1,pluginClients:[],pluginStyles:[]};function nn(e,t){let o=new Map,r=new Map;ce(e,o,r);for(let a of t)ce({behaviors:[],math:a.assets?.math===!0,pluginClients:[...a.assets?.clients??[]],pluginStyles:[...a.assets?.styles??[]]},o,r);return{behaviors:e.behaviors,math:e.math||t.some(a=>a.assets?.math===!0),pluginClients:[...o.values()],pluginStyles:[...r.values()]}}s(nn,"playgroundMarkdownAssets");function sn(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}s(sn,"jsonForInlineScript");function ln(e,t){let o=t.defaultLocale,r=Te(o,e.i18n.messages),a=_(e.title),i=_(g(e,e.theme.favicon??ye)),l=_(g(e,"/assets/canofold.css")),n=t.versions.find(S=>S.id===t.currentVersion),d=g(e,j(o,t.defaultLocale,n?.base??"/")),u=_(d),c=_(r.title),p=_(r.description),m=_(r.home),w=t.versions.flatMap(S=>t.locales.map(C=>{let b=Te(C,e.i18n.messages),f=g(e,j(C,t.defaultLocale,S.base));return{locale:C,prefix:f,home:f,title:b.title,description:b.description,homeLabel:b.home,documentTitle:`404 - ${b.title} | ${e.title}`}})).sort((S,C)=>C.prefix.length-S.prefix.length),h=`(function(){var p=${sn(w)},n=location.pathname,m=p.find(function(x){var r=x.prefix.replace(//$/,'');return n===r||n.indexOf(x.prefix)===0});if(!m)return;document.documentElement.lang=m.locale;document.title=m.documentTitle;var t=document.getElementById('canofold-404-title'),d=document.getElementById('canofold-404-description'),h=document.getElementById('canofold-404-home');if(t)t.textContent=m.title;if(d)d.textContent=m.description;if(h){h.textContent=m.homeLabel;h.setAttribute('href',m.home)}})()`;return`<!doctype html><html lang="${_(o)}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>404 - ${c} | ${a}</title><meta name="robots" content="noindex"><link rel="icon" href="${i}"><link rel="stylesheet" href="${l}"><script>${we}</script></head><body><div class="cf-not-found"><span class="cf-not-found-code">404</span><h1 id="canofold-404-title" class="cf-not-found-title">${c}</h1><p id="canofold-404-description" class="cf-not-found-desc">${p}</p><a id="canofold-404-home" href="${u}" class="cf-not-found-link">${m}</a></div><script>${h}</script></body></html>`}s(ln,"render404Page");async function Go({cwd:e,config:t,graph:o,pages:r=o.pages,previousPages:a=[],renderer:i=rn(),writeSharedAssets:l=!0}){let n=R(e,t.outputDir),d=St(t,o),u=o.pages.some(b=>b.frontmatter.layout==="playground"),c=[];if(await Ze(W(n,"assets"),{recursive:!0}),l){let b=u&&t.markdown.plugins.some(U=>U.assets?.math===!0)||o.pages.some(U=>zo(U.body,t.markdown.plugins,G(U.relativePath)?"mdx":"markdown").math),[f,M]=await Promise.all([Kt({math:b}),jo(e,t.styles)]);await xe(W(n,"assets/canofold.css"),`${f}
653
+ ${Do(t)}
654
+ ${M}
655
+ `),await tn(Gt(),W(n,"assets/file-icons"),{recursive:!0,force:!0});let x=W(n,"assets/fonts");if(b){let U=zt();await Je(U,x)}else await et(x,{recursive:!0,force:!0});t.search.enabled&&await Po(n),u?await Ao(e,n,t):await et(W(n,"assets/canofold-playground"),{recursive:!0,force:!0});let[me,De]=await Promise.all([Xe(e,t),Ye(e,o.pages)]);c=me,await Qe(n,[...c,...De],d),await xe(W(n,"404.html"),ln(t,o))}else{let[b,f]=await Promise.all([Xe(e,t),Ye(e,r)]);c=b,await Qe(n,f,d)}let p=l?r:o.pages,m=new Map,w=new Map,h=new Set;p.forEach(b=>{let f=zo(b.body,t.markdown.plugins,G(b.relativePath)?"mdx":"markdown");ce(f,m,w),f.behaviors.forEach(M=>h.add(M))});let S=8,C=No(t.basePath);await F(r,S,async b=>{let f=b.routePath===j(b.locale,o.defaultLocale,b.versionBase),M,x=an,me={...t.markdown,locale:b.locale,labels:{...ge(b.locale,t.i18n.messages),...t.markdown.labels}};if(G(b.relativePath)){let J={...me,html:"trusted"},mt=await vo(b.body,b.sourcePath,e,J,void 0,C,i);M=mt.content,x=mt.assets}else{let J=await i.render(b.body,{markdown:me,as:"article",urlTransform:C});M=J.content,x=J.assets}b.frontmatter.layout==="playground"&&(x=nn(x,t.markdown.plugins)),ce(x,m,w),x.behaviors.forEach(J=>h.add(J));let De=!!(b.frontmatter.hero||b.frontmatter.features?.length),U=b.body.trim().length>0,ir=f?dn(cn,{children:[De?tt(Wt,{page:b,config:t}):null,U?M:null]}):M??tt("article",{className:"cf-content"}),dt=T(n,b.markdownOutputPath,`page ${b.sourceRelativePath}`),ut=b.transformedSource,lr="<!doctype html>"+on(tt(po,{config:t,graph:o,page:b,home:f,markdownAssets:x,rawSource:ut,children:ir})),pt=T(n,b.outputPath,`page ${b.sourceRelativePath}`);await Ze(Ho(pt),{recursive:!0}),await xe(pt,lr),await Ze(Ho(dt),{recursive:!0}),await xe(dt,ut)}),h.size>0?await Fo(n):await et(W(n,"assets/canofold-markdown"),{recursive:!0,force:!0}),await Bo(n,m,w),await qo(n,a,o.pages,[...d,...c.map(b=>b.outputPath)])}s(Go,"renderSite");import{writeFile as un}from"fs/promises";import{join as pn}from"path";async function Ko(e,t){let o=V(t,"/sitemap.xml");await un(pn(R(e,t.outputDir),"robots.txt"),`User-agent: *
656
+ Allow: /
657
+ ${o?`Sitemap: ${o}
658
+ `:""}`)}s(Ko,"writeRobots");import{writeFile as mn}from"fs/promises";import{join as fn}from"path";async function Vo(e,t,o){if(!t.siteUrl)return;let r=s(i=>i.replace(/[&<>"']/g,l=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;"})[l]??l),"escapeXml"),a=o.pages.map(i=>` <url><loc>${r(V(t,i.routePath))}</loc></url>`).join(`
659
+ `);await mn(fn(R(e,t.outputDir),"sitemap.xml"),`<?xml version="1.0" encoding="UTF-8"?>
660
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
661
+ ${a}
662
+ </urlset>
663
+ `)}s(Vo,"writeSitemap");import{createMarkdownRenderer as Fn}from"@canofold/markdown/server";import{satisfies as In,valid as Bn,validRange as _n}from"semver";function Wo({current:e,previous:t,outputExists:o,outputValid:r=o,forceClean:a=!1}){if(a)return{mode:"clean",changedPageKeys:Object.keys(e.pages),removedPageKeys:[],reason:"forced"};if(!t)return{mode:"clean",changedPageKeys:Object.keys(e.pages),removedPageKeys:[],reason:"missing-manifest"};if(!o)return{mode:"clean",changedPageKeys:Object.keys(e.pages),removedPageKeys:Object.keys(t.pages).filter(n=>!e.pages[n]),reason:"missing-output"};if(!r)return{mode:"clean",changedPageKeys:Object.keys(e.pages),removedPageKeys:Object.keys(t.pages).filter(n=>!e.pages[n]),reason:"invalid-output"};if(e.buildFingerprint===t.buildFingerprint)return{mode:"cached",changedPageKeys:[],removedPageKeys:[],reason:"unchanged-inputs"};if(e.sharedFingerprint!==t.sharedFingerprint)return{mode:"clean",changedPageKeys:Object.keys(e.pages),removedPageKeys:Object.keys(t.pages).filter(n=>!e.pages[n]),reason:"shared-inputs-changed"};let i=Object.entries(e.pages).filter(([n,d])=>t.pages[n]?.fingerprint!==d.fingerprint).map(([n])=>n),l=Object.keys(t.pages).filter(n=>!e.pages[n]);return i.length===0&&l.length===0?{mode:"clean",changedPageKeys:Object.keys(e.pages),removedPageKeys:[],reason:"unclassified-inputs-changed"}:{mode:"incremental",changedPageKeys:i,removedPageKeys:l,reason:"page-inputs-changed"}}s(Wo,"planBuild");import{copyFile as hn,mkdir as gn,readFile as Jo,readdir as yn,stat as bn}from"fs/promises";import{dirname as wn,relative as kn,resolve as ot}from"path";var rt=16;function Xo(e,t){return kn(ot(e),ot(t)).replace(/\\/g,"/")}s(Xo,"portablePath");async function Yo(e){async function t(o){let r=await yn(o,{withFileTypes:!0});return(await Promise.all(r.map(async a=>{let i=ot(o,a.name);if(a.isSymbolicLink())throw new Error(`Generated output must not be a symbolic link: ${i}`);return a.isDirectory()?t(i):a.isFile()?[i]:[]}))).flat()}return s(t,"walk"),t(e)}s(Yo,"outputFilesUnder");async function Qo(e){let t=(await Yo(e)).sort(),o=await F(t,rt,async r=>{let a=await Jo(r);return[Xo(e,r),{fingerprint:B(a),size:a.byteLength}]});return Object.fromEntries(o)}s(Qo,"captureBuildOutputs");async function Zo(e,t){try{let o=Object.keys(t).sort(),r=(await Yo(e)).map(i=>Xo(e,i)).sort();return r.length!==o.length||r.some((i,l)=>i!==o[l])?!1:(await F(Object.entries(t),rt,async([i,l])=>{let n=T(e,i,`cached output ${i}`),d=await bn(n);return!d.isFile()||d.size!==l.size?!1:B(await Jo(n))===l.fingerprint})).every(Boolean)}catch(o){if(o.code==="ENOENT")return!1;throw o}}s(Zo,"verifyBuildOutputs");async function er(e,t,o){await F(Object.keys(o),rt,async r=>{let a=T(e,r,`cached output ${r}`),i=T(t,r,`staged output ${r}`);await gn(wn(i),{recursive:!0}),await hn(a,i)})}s(er,"copyBuildOutputs");import{readFile as st,readdir as Pn}from"fs/promises";import{dirname as tr,join as Q,relative as Sn,resolve as ue}from"path";import{fileURLToPath as at}from"url";import{detectMarkdownAssets as xn}from"@canofold/markdown/server/analyze";var Ce=16;function it(e,t){return Sn(ue(e),ue(t)).replace(/\\/g,"/")}s(it,"portablePath");function de(e){return JSON.stringify([e.version,e.sourceRelativePath])}s(de,"buildPageKey");async function or(e){async function t(o){let r=await Pn(o,{withFileTypes:!0});return(await Promise.all(r.map(async a=>{let i=Q(o,a.name);if(a.isDirectory())return t(i);if(a.isSymbolicLink())throw new Error(`Documentation support files must not use symbolic links: ${it(e,i)}`);return!a.isFile()||/\.mdx?$/i.test(a.name)?[]:[i]}))).flat()}return s(t,"walk"),t(e)}s(or,"supportFilesUnder");async function Cn(e){let t=[...new Set(e.map(r=>ue(r)))].sort(),o=(await F(t,Ce,async r=>{try{return{path:r,fingerprint:B(await st(r))}}catch(a){if(!a||typeof a!="object"||!("code"in a)||a.code!=="ENOENT")throw a;return null}})).filter(r=>r!==null);return H(o)}s(Cn,"fingerprintExistingFiles");async function nt(e){try{return await or(e)}catch(t){if(t&&typeof t=="object"&&"code"in t&&t.code==="ENOENT")return[];throw t}}s(nt,"filesUnderIfPresent");async function Mn(){let e=tr(at(import.meta.url)),t=[];try{let o=at(import.meta.resolve("@canofold/markdown/theme")),r=tr(o);t.push(Q(r,"tokens.css"),Q(r,"styles.css"),Q(r,"theme.css"),Q(r,"base.css"),o)}catch{}return Cn([...await nt(e),...await nt(Q(e,"render")),...await nt(at(new URL("../render",import.meta.url))),...t])}s(Mn,"runtimeFingerprint");async function Dn(e,t,o){let r=[...new Set(t.versions.items.map(n=>n.docsDir))].map(n=>K(e,n,"docsDir")),a=(await Promise.all(r.map(n=>or(n)))).flat();for(let n of t.styles)a.push(K(e,n,"styles"));let i=[...new Set(a.map(n=>ue(n)))].filter(n=>!o.has(n)).sort(),l=await F(i,Ce,async n=>({path:it(e,n),fingerprint:B(await st(n))}));return H(l)}s(Dn,"supportFingerprint");function Nn(e){return{sourceRelativePath:e.sourceRelativePath,relativePath:e.relativePath,version:e.version,versionBase:e.versionBase,docsDir:e.docsDir,locale:e.locale,routePath:e.routePath,outputPath:e.outputPath,markdownOutputPath:e.markdownOutputPath,title:e.title,description:e.description,order:e.order,group:e.group,status:e.status,search:e.search,ai:e.ai,body:e.body,transformedSource:e.transformedSource,headings:e.headings,searchText:e.searchText,codeExamples:e.codeExamples,lastUpdated:e.lastUpdated,...e.previous?{previous:e.previous}:{},...e.next?{next:e.next}:{},frontmatter:e.frontmatter}}s(Nn,"serializablePage");function An(e,t){return{sidebar:e.sidebar[t.version]?.[t.locale]??[],nav:e.nav[t.version]?.[t.locale]??[],locales:e.locales,defaultLocale:e.defaultLocale,versions:e.versions,currentVersion:e.currentVersion}}s(An,"pageLayoutContext");function En(e){let t=e.search.provider;return{...e,markdown:{...e.markdown,plugins:e.markdown.plugins.map(o=>({name:o.name,version:o.version??"",cacheKey:o.cacheKey??null}))},search:{...e.search,provider:typeof t=="string"?t:{id:t.id,client:t.client,version:t.version??"",cacheKey:t.cacheKey??null}}}}s(En,"serializableConfig");async function rr(e,t,o,r=H({extensions:[]})){let a=new Map;await F(o.pages,Ce,async c=>{if(!G(c.relativePath))return;let p=ke(c.body).imports,m=await wo(p,c.sourcePath,e),w=await F(m,Ce,async h=>({path:it(e,h),fingerprint:B(await st(h))}));a.set(de(c),w.sort((h,S)=>h.path.localeCompare(S.path)))});let i=new Set([...a.values()].flat().map(c=>ue(e,c.path))),l=H(En(t)),n=H({canofoldVersion:q,runtimeFingerprint:await Mn(),configFingerprint:l,benchmarkReport:process.env.CANOFOLD_BENCHMARK_REPORT==="1",extensionFingerprint:r,math:o.pages.some(c=>xn(c.body,t.markdown.plugins,G(c.relativePath)?"mdx":"markdown").math),playground:o.pages.some(c=>c.frontmatter.layout==="playground"),support:await Dn(e,t,i)}),d=Object.fromEntries(o.pages.map(c=>[de(c),{fingerprint:H({page:Nn(c),localComponents:a.get(de(c))??[],layout:An(o,c)}),outputPath:c.outputPath,markdownOutputPath:c.markdownOutputPath,assetOutputPaths:[...le([c])].sort()}])),u=H({sharedFingerprint:n,pages:d});return{schemaVersion:3,canofoldVersion:q,buildFingerprint:u,sharedFingerprint:n,pages:d,outputs:{}}}s(rr,"createBuildManifest");function Un(e,t){if(!Bn(e))throw new Error(`Invalid Canofold version: ${e}`);if(!_n(t))throw new Error(`Invalid requiredVersion range: ${t}`);return In(e,t)}s(Un,"versionSatisfies");function qn(e){if(e.requiredVersion&&!Un(q,e.requiredVersion))throw new Error(`Canofold ${q} does not satisfy requiredVersion ${e.requiredVersion}`)}s(qn,"assertRequiredVersion");async function ar({cwd:e,config:t,graph:o,pages:r,previousPages:a,renderer:i,writeSharedAssets:l,extensions:n}){await Go({cwd:e,config:t,graph:o,pages:r,previousPages:a,renderer:i,writeSharedAssets:l}),await vt(e,t,o),await Vo(e,t,o),await Ko(e,t),await Ft(e,t,o),await wt(e,t,o),await n.generate(R(e,t.outputDir),o.pages),process.env.CANOFOLD_BENCHMARK_REPORT==="1"&&await Tn(ct(R(e,t.outputDir),".benchmark.json"),JSON.stringify({maxRssBytes:process.resourceUsage().maxRSS*1024}))}s(ar,"writeBuildOutputs");function sr(e){return ct(lt(e),`.${nr(e)}.backup`)}s(sr,"outputBackupRoot");async function jn(e){let t=sr(e);await X(t)&&(await X(e)?await pe(t,{recursive:!0,force:!0}):await Me(t,e))}s(jn,"recoverInterruptedOutputReplacement");async function Hn(e,t){let o=sr(e),r=await X(e);try{r&&await Me(e,o),await Me(t,e)}catch(a){throw r&&await X(o)&&(await pe(e,{recursive:!0,force:!0}),await Me(o,e)),a}await pe(o,{recursive:!0,force:!0})}s(Hn,"replaceOutputDirectory");async function zn(e,t,o,r){let a=R(e,t.outputDir),i=new Set(r.flatMap(l=>[l.outputPath,l.markdownOutputPath]).map($));await Promise.all(o.flatMap(l=>[l.outputPath,l.markdownOutputPath].filter(n=>!i.has($(n))).map(n=>pe(T(a,n,`removed page output ${n}`),{force:!0}))))}s(zn,"removeDeletedPageOutputs");async function Gn(e,t,o,r,a){await jn(r);let i=await Et(e.cwd,Ct(e.cwd),o.extensions),l=await bt(e.cwd,o,i),n=await rr(e.cwd,o,l,i.fingerprint),d=e.noCache?void 0:await Mt(t),u=await X(r),c=u&&d?await Zo(r,d.outputs):u,p=Wo({current:n,previous:d,outputExists:u,outputValid:c,forceClean:e.forceClean||e.noCache}),m=e.renderer??Fn();if(p.mode==="cached")return Z(`Built ${o.outputDir} (cache hit)`),{config:o,graph:l,incremental:!1,cached:!0,mode:p.mode,changedPages:[],partialReload:!1,reason:p.reason};let w=new Map(l.pages.map(f=>[de(f),f])),h=p.changedPageKeys.flatMap(f=>{let M=w.get(f);return M?[M]:[]}),S=ct(lt(r),`.${nr(r)}.tmp-${Ln()}`),C={...o,outputDir:On($n(e.cwd),S)};await Rn(lt(S),{recursive:!0});try{if(p.mode==="incremental"){await er(r,S,d?.outputs??{}),await ar({cwd:e.cwd,config:C,graph:l,pages:h,previousPages:d?Object.values(d.pages):[],renderer:m,writeSharedAssets:!1,extensions:i});let f=p.removedPageKeys.flatMap(M=>{let x=d?.pages[M];return x?[x]:[]});await zn(e.cwd,C,f,Object.values(n.pages))}else m.clear(),await ar({cwd:e.cwd,config:C,graph:l,pages:l.pages,renderer:m,writeSharedAssets:!0,extensions:i});await a(),await Hn(r,S)}finally{await pe(S,{recursive:!0,force:!0})}let b={...n,outputs:await Qo(r)};return await a(),await Dt(t,b),Z(`Built ${o.outputDir} (${p.mode}: ${p.reason})`),{config:o,graph:l,incremental:p.mode==="incremental",cached:!1,mode:p.mode,changedPages:[...new Set(h.map(f=>f.sourceRelativePath))],partialReload:p.mode==="incremental"&&p.changedPageKeys.length===1&&p.removedPageKeys.length===0&&d?.pages[p.changedPageKeys[0]??""]?.outputPath===n.pages[p.changedPageKeys[0]??""]?.outputPath,reason:p.reason}}s(Gn,"runBuildLocked");async function bc(e){let t=xt(e.cwd);await ft(e.cwd,t,"build cache");let o=await gt(e.cwd);qn(o);let r=await At(e.cwd,o,t);return Nt(t,a=>Gn(e,t,o,r,a))}s(bc,"runBuild");export{Un as a,bc as b};
664
+ //# sourceMappingURL=chunk-56TT2V3X.js.map