@dooc-dev/dooc 0.0.27 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/edit.global.js +68 -68
- package/dist/engine/compiler/format-collections.js +8 -2
- package/dist/engine/core/html.js +1 -1
- package/dist/frontend/document-application.js +25 -17
- package/dist/manifest.global.js +51 -51
- package/dist/server/build.js +11 -8
- package/dist/server/cli.js +6 -1
- package/dist/subformats.global.js +19 -19
- package/dist/ui.global.js +15 -15
- package/dist/workspace-worker.global.js +6 -4
- package/package.json +1 -1
|
@@ -424,7 +424,7 @@ ${tables}`:preamble||tables}function stringify5(obj,{maxDepth=1e3,numbersAsFloat
|
|
|
424
424
|
`));let index4=manifest2.subformats?.findIndex(format6=>format6.ext===input.ext)??-1,config2=manifest2.subformats?.[index4];if(!config2)throw new Error("Unknown subformat");let key=input.key;if((config2.layouts?.[key]??null)!==input.base)return{status:409,body:{error:"Default changed externally. Reload and try again."}};if(parseSubformats([{...config2,layouts:{...config2.layouts,[key]:input.value}}]),key!=="sort_order"&&key!=="view"&&input.value){let field2=loadSubformat(root4,config2,domains).fields.find(field3=>field3.name===input.value);if(!field2||key==="group_by"&&!field2.enum?.length||key==="sort_by"&&!field2.enum&&!field2.format&&!field2.type)throw new Error("Default must reference a compatible schema field")}let document5=parseDocument(raw),section=manifest2.format!==void 0?"json_subformats":"subformats";return document5.setIn([section,index4,"layouts",key],input.value),writeTextfile(root4,manifestFile(root4),document5.toString(),raw)?{status:200,body:{file:manifestFile(root4)}}:{status:409,body:{error:"Manifest changed externally. Try again."}}}if(input?.action==="delete"){if(typeof input.ext!="string")throw new Error("A subformat extension is required");let raw=readTextfile(root4,manifestFile(root4)),manifest2=parseManifestText(raw,manifestFile(root4));if(manifest2.errors.length)throw new Error(manifest2.errors.join(`
|
|
425
425
|
`));let index4=manifest2.subformats?.findIndex(format6=>format6.ext===input.ext)??-1,config2=manifest2.subformats?.[index4];if(!config2)throw new Error("Unknown subformat");if(!isDeepStrictEqual(config2,parseSubformats([input.base])[0]))return{status:409,body:{error:"Subformat changed externally. Reload and try again."}};let id=subformatPageId(input.ext);if(manifest2.tree.some(node2=>node2.root&&node2.subformat===input.ext))throw new Error("Change the root document before removing its record type");if(flattenTree(manifest2.tree).some(node2=>node2.parent===id))throw new Error("Move or remove this subformat page's child pages before deleting it.");let document5=parseDocument(raw),nested=manifest2.format!==void 0;document5.deleteIn([nested?"json_subformats":"subformats",index4]);let pages=manifest2.format==="document"?document5.getIn(["document","children"],!0):document5.get(nested?"center_contents":"docs",!0);isSeq(pages)&&visit2(pages,{Map:(_key,node2)=>{if(manifest2.format==="document"&&node2.has("document")&&node2.toJSON().document?.subformat===input.ext)return visit2.REMOVE;if(node2.get("subformat")===input.ext)return visit2.REMOVE}}),!nested&&document5.hasIn(["files","icons",id])&&document5.deleteIn(["files","icons",id]);let content4=document5.toString(),next=parseManifestText(content4,manifestFile(root4));if(next.errors.length)throw new Error(next.errors.join(`
|
|
426
426
|
`));return writeTextfile(root4,manifestFile(root4),content4,raw)?{status:200,body:{file:manifestFile(root4)}}:{status:409,body:{error:"Manifest changed externally. Try again."}}}if(input?.action==="register"){let raw=readTextfile(root4,manifestFile(root4)),manifest2=parseManifestText(raw,manifestFile(root4));if(manifest2.errors.length)throw new Error(manifest2.errors.join(`
|
|
427
|
-
`));let schema5=input.schema===void 0||input.schema===""?`${input.ext}.schema.json`:input.schema,configs=parseSubformats([...manifest2.subformats??[],{ext:input.ext,format:input.format,schema:schema5,icon:input.icon===""?void 0:input.icon}]),config2=configs[configs.length-1],iconSvg=subformatIconSvg(root4,config2);if(!managedFile(config2.schema))throw new Error("Schema must be a local project file");if(input.content!==void 0&&typeof input.content!="string")throw new Error("Schema content must be text");let initial=input.content??SUBFORMAT_SCHEMA_TEMPLATE;if(compileSubformatSchema(initial,{root:root4,file:config2.schema,domains}),existsSync(textfilePath(root4,config2.schema))){if(input.content!==void 0&&readTextfile(root4,config2.schema)!==initial)return{status:409,body:{error:"Schema file already exists. Choose another path."}}}else if(!writeTextfile(root4,config2.schema,initial,null))return{status:409,body:{error:"Schema changed externally. Try again."}};if(!filesSnapshot(root4).files.some(file=>file.path===config2.schema))throw new Error("Subformat schema is not available in the workspace");let loaded=loadSubformat(root4,config2,domains),parsed2=parseDocument(raw),document5=isSeq(parsed2.contents)||parsed2.contents==null?new Document({docs:parsed2.toJS()??[]}):parsed2;document5!==parsed2&&(document5.commentBefore=parsed2.commentBefore);let key=manifest2.format!==void 0?"json_subformats":"subformats";return document5.has(key)?document5.addIn([key],config2):document5.set(key,[config2]),writeTextfile(root4,manifestFile(root4),document5.toString(),raw)?{status:200,body:{collection:{...config2,iconSvg,fields:loaded.fields,template:loaded.template,defaultFolder:manifest2.defaultSubformatFolder,records:[],change:"added"}}}:{status:409,body:{error:"Manifest changed externally. Try again."}}}if(input?.action==="create"){if(typeof input.file!="string"||typeof input.content!="string")throw new Error("A record file and content are required");let config2=readManifest(root4).subformats?.find(format6=>format6.ext===fileExtension(input.file));if(!config2)throw new Error("Choose a configured subformat extension");validateSubformatFile(root4,input.file,input.content,domains);let data2=parseSubformatRecord(input.content,config2.format);return writeTextfile(root4,input.file,input.content,null)?{status:200,body:{content:input.content,data:data2}}:{status:409,body:{error:"File already exists"}}}if(typeof input?.file!="string"||typeof input.base!="string"||typeof input.field!="string")throw new Error("A record file, original content and enum field are required");let files=filesSnapshot(root4).files.map(file=>file.path);if(!files.includes(input.file))throw new Error("Record file is not available in the workspace");let config=readManifest(root4).subformats?.find(format6=>format6.ext===fileExtension(input.file));if(!config||!files.includes(config.schema))throw new Error("Subformat schema is not available in the workspace");let format5=loadSubformat(root4,config,domains),field=format5.fields.find(field2=>field2.name===input.field);if(field?.readOnly||!(field?.enum??field?.options)?.some(value2=>value2===input.value))throw new Error("Choose a writable enum value defined by the schema");let current=readTextfile(root4,input.file);if(current!==input.base)return{status:409,body:{error:"File changed externally. Reload it before saving."}};let content3=setSubformatValue(current,format5.format,[input.field],input.value),roundTrip=parseSubformatRecord(content3,format5.format);return validateSubformatRecord(format5,roundTrip),writeTextfile(root4,input.file,content3,current)?{status:200,body:{content:content3,data:roundTrip}}:{status:409,body:{error:"File changed externally. Reload it before saving."}}}catch(error){return{status:400,body:{error:error instanceof Error?error.message:String(error)}}}},subformatRelations=(root4,configs,domains=[])=>{let loaded=configs.flatMap(config=>{try{let compiled=compileSubformatSchema(readTextfile(root4,config.schema),{root:root4,file:config.schema,domains});return[{ext:config.ext,...compiled}]}catch{return[]}}),owners=new Map(loaded.map(({ext,context})=>[context.uri,ext])),model={groups:[],tables:[],edges:[]};for(let{ext,schema:schema5,context}of loaded){let resolve2=schemaResolver(schema5,context),fields=[];for(let[name,definition3]of Object.entries(resolve2(schema5).properties??{})){let targets=new Set,list5=!1,seen=new Set,walk2=value2=>{let node2=resolve2(value2,uri=>{let owner=owners.get(uri.split("#")[0]??"");owner&&owner!==ext&&targets.add(owner)});if(seen.has(value2))return node2;seen.add(value2);let suffix=typeof node2.pattern=="string"&&/\\\.([\w-]+)\$$/.exec(node2.pattern)?.[1];suffix&&loaded.some(item=>item.ext===suffix)&&targets.add(suffix);for(let key of["anyOf","oneOf","allOf"])if(Array.isArray(node2[key]))for(let child of node2[key])walk2(child);if(schemaObject(node2.properties))for(let child of Object.values(node2.properties))walk2(child);return node2.items!==void 0&&(list5=!0,walk2(node2.items)),node2},property=walk2(definition3),type=Array.isArray(property.enum)?property.enum.map(value2=>JSON.stringify(value2)).join("|"):property.format==="date"||property.format==="date-time"?"timestamp":property.type==="string"?"string":property.type==="number"||property.type==="integer"?"number":property.type==="boolean"?"bool":"json";for(let to of targets)model.edges.push({from:ext,fieldIndex:fields.length,field:name,to,list:list5});fields.push(targets.size?{name,kind:list5?"fkList":"fk",targets:[...targets]}:{name,kind:"scalar",type})}model.tables.push({name:ext,fields,notes:[]}),model.groups.push({tables:[ext]})}return model};var resourceIndex=(root4,files,domains=[])=>{let result={codeblocks:[],urls:[],urlPreviews:[],skills:[],subformats:[],errors:[]},paths2=new Set(files),manifest2=readManifest(root4);if(result.errors.push(...manifest2.errors),result.libraries=manifest2.libraries??REFERENCE_LIBRARIES,result.libraries.includes("skills")&&manifest2.skills?.length)try{result.skills=readProjectSkills(root4).map(({file,frontmatter:frontmatter2,files:files2})=>({file,name:frontmatter2.name,description:frontmatter2.description,content:files2.get("SKILL.md")?.toString("utf8")??""}))}catch(error){result.errors.push(error instanceof Error?error.message:String(error))}let discovered=new Set(Object.keys(manifest2.formats??{}));for(let settings of Object.values(manifest2.includedFormats??{}))for(let format5 of Object.keys(settings))discovered.add(format5);let collected=new Map,collect3=(file,source2)=>{if(!paths2.has(file)){let path4=textfilePath(root4,file);if(assertNotIgnored(root4,file),!(file===manifestFile(root4)||file.startsWith(`${PROJECT_FONTS_DIR}/`)&&localFile(file.slice(PROJECT_FONTS_DIR.length+1)))||!statSync(path4,{throwIfNoEntry:!1})?.isFile())throw new Error(`File is not available in the workspace: ${file}`)}let item=collected.get(file)??{file,format:fileFormat(file),sources:[]};source2&&!item.sources.some(value2=>value2.file===source2.file&&value2.line===source2.line)&&item.sources.push(source2),collected.set(file,item),discovered.add(item.format)},selected=formatFiles(root4,manifest2,files);result.errors.push(...selected.errors.map(({file,message})=>`${file}: ${message}`));for(let file of selected.files)collect3(file);for(let node2 of flattenTree(manifest2.tree))node2.format&&discovered.add(discovered.has(node2.format)?node2.format:fenceFormat(node2.format)),isContentPage(node2)&&paths2.has(docFile(node2.id,manifest2.files))&&collect3(docFile(node2.id,manifest2.files));let formats2=new Map;for(let config of manifest2.subformats??[])try{if(!paths2.has(config.schema))throw new Error("Schema is not available in the workspace");let loaded=loadSubformat(root4,config,domains);formats2.set(config.ext,loaded),discovered.add(config.ext);let iconSvg;try{iconSvg=subformatIconSvg(root4,config)}catch{}result.subformats.push({...config,...iconSvg?{iconSvg}:{},fields:loaded.fields,template:loaded.template,defaultFolder:manifest2.defaultSubformatFolder,records:[]})}catch(error){result.errors.push(`${config.schema}: ${error instanceof Error?error.message:String(error)}`)}result.relations=subformatRelations(root4,result.subformats,domains);let urls=new Map,urlPreviews=new Map,references=new Map,validateTerms=(raw,source2)=>{let parsed2=parseTermSource(`${source2.file}#L${source2.line}`,raw);result.errors.push(...parsed2.errors.map(error=>`${source2.file}:L${source2.line+error.line}: ${error.message}`))},scan=(tree,file,offset=0)=>{let definitions2=new Map;visit(tree,"definition",node2=>{definitions2.set(node2.identifier,node2.url)}),visit(tree,node2=>{let source2={file,line:offset+(node2.position?.start.line??1)};if(node2.type==="code"){let language=node2.lang?.toLowerCase()||"text",format5=formats2.get(language.replace(/^\./,"")),extension2=format5?.ext??fenceFormat(language);discovered.add(extension2);let origin=sourceOrigin(manifest2,file);((origin?manifest2.includedFormats?.[origin]?.[extension2]:void 0)??manifest2.formats?.[extension2])?.codeblock!==!1&&result.codeblocks.push({language:format5?.format??language,format:extension2,caption:node2.meta??"",content:node2.value,source:source2}),language==="termth"&&validateTerms(node2.value,{...source2,line:source2.line+1}),language==="callouth"&&scan(parseMdast(node2.value),file,source2.line);return}let target=node2.type==="link"||node2.type==="image"?node2.url:node2.type==="linkReference"||node2.type==="imageReference"?definitions2.get(node2.identifier):void 0;if(!target)return;let preview=node2.type==="image"||node2.type==="imageReference";if(!/^(?:[a-z][a-z\d+.-]*:|[/#])/i.test(target)){try{let ref=parseFileEmbed(preview?target:target.split(/[?#]/)[0]??target),referencedFile=ref.file.replace(/^(\.\/)+/,"");if(formatReference(referencedFile)!==void 0)return;if(!preview||ref.kind!=="textfile"){collect3(referencedFile,source2);return}let language=fileFormat(referencedFile),content3=selectTextfileRange(readTextfile(root4,referencedFile),ref.range);collect3(referencedFile,source2),result.codeblocks.push({language:formats2.get(language)?.format??language,format:language,inline:!1,caption:node2.alt??"",content:content3,source:source2,reference:{file:referencedFile,line:ref.range?parseTextfileRange(ref.range)[0]:1,...ref.range?{range:ref.range}:{}}})}catch(error){result.errors.push(`${file}:L${source2.line}: ${target}: ${error instanceof Error?error.message:String(error)}`)}return}try{let url=new URL(target);if(!["http:","https:","mailto:"].includes(url.protocol))return;let entries=preview?urlPreviews:urls,key=url.href,entry=entries.get(key)??{url:key,host:url.host||url.protocol,sources:[]};entry.sources.push(source2),entries.set(key,entry)}catch{}})};for(let file of paths2){let format5=formats2.get(fileExtension(file));if(format5&&!(manifest2.subformats??[]).some(item=>item.schema===file)){try{let content3=readTextfile(root4,file);collect3(file),result.codeblocks.push({inline:!1,language:format5.format,format:format5.ext,caption:file,content:content3,source:{file,line:1}});let data2=parseSubformatRecord(content3,format5.format);validateSubformatRecord(format5,data2),result.subformats.find(item=>item.ext===format5.ext)?.records.push({file,content:content3,data:data2})}catch(error){result.errors.push(`${file}: ${error instanceof Error?error.message:String(error)}`)}continue}if(/\.(?:md|termth)$/i.test(file))try{let raw=readTextfile(root4,file);if(/\.termth$/i.test(file)){let source2={file,line:1};collect3(file),result.codeblocks.push({inline:!1,language:"termth",format:"termth",caption:"",content:raw,source:source2}),validateTerms(raw,source2)}else{let tree=parseMdast(rebaseFileLinks(raw,sourceOrigin(manifest2,file)));scan(tree,file);for(let ref of subformatReferences(tree)){if(!formats2.has(fileExtension(ref.file)))continue;let sources3=references.get(ref.file)??[];sources3.push({file,line:ref.line}),references.set(ref.file,sources3)}}}catch(error){result.errors.push(`${file}: ${error instanceof Error?error.message:String(error)}`)}}let indexed=new Set(result.codeblocks.filter(item=>item.inline===!1).map(item=>item.reference?.file??item.source.file));for(let file of collected.keys())if(!(indexed.has(file)||/\.(svg|html|png|webp|gif|mp4|webm|jpe?g|pdf|dxf)$/i.test(file)))try{let format5=fileFormat(file);result.codeblocks.push({language:formats2.get(format5)?.format??format5,format:format5,inline:!1,caption:file,content:readTextfile(root4,file),source:{file,line:1}})}catch{}result.files=[...collected.values()].sort((a2,b2)=>a2.file.localeCompare(b2.file)),result.formats=[...discovered].sort(),result.urls=result.libraries.includes("urls")?[...urls.values()].sort((a2,b2)=>a2.url.localeCompare(b2.url)):[],result.urlPreviews=result.libraries.includes("url-previews")?[...urlPreviews.values()].sort((a2,b2)=>a2.url.localeCompare(b2.url)):[];for(let collection of result.subformats)for(let record2 of collection.records)record2.references=references.get(record2.file)??[];return result};var readFormatCollection=(root4,selector,options2={},textfiles)=>{validateSubformatOptions(options2,FORMAT_META_FIELDS);let paths2=projectFiles(root4).map(file=>file.path),index4=resourceIndex(root4,paths2),records=[],add2=(file,format5,line2,inline,source2)=>{let traits=formatTraits(format5);if(inline&&!traits.includes("codes")&&traits.push("codes"),!matchesFormat(format5,selector,traits)||options2.folder&&!inFormatFolder(file,options2.folder))return;let folder=file.slice(0,file.lastIndexOf("/"))||".",data2={file,folder:file.includes("/")?folder:".",format:format5,traits,kind:inline?"codeblock":"file",line:line2},record2={file,data:data2,content:JSON.stringify(data2)};if(matchesSubformatRecord(record2,options2,FORMAT_META_FIELDS)){if(!inline&&/\.(svg|html|png|webp|gif|mp4|webm|jpe?g|pdf|dxf)$/i.test(file))record2.preview=[{type:"figureRef",name:figureName(file)}];else try{let content3=source2??textfiles?.get(file)??readTextfile(root4,file),parsed2=parseContentSource(format5,content3,file);record2.preview=parsed2&&!parsed2.errors.length&&parsed2.blocks.length?parsed2.blocks:[{type:"code",lang:format5,lines:content3.split(`
|
|
427
|
+
`));let schema5=input.schema===void 0||input.schema===""?`${input.ext}.schema.json`:input.schema,configs=parseSubformats([...manifest2.subformats??[],{ext:input.ext,format:input.format,schema:schema5,icon:input.icon===""?void 0:input.icon}]),config2=configs[configs.length-1],iconSvg=subformatIconSvg(root4,config2);if(!managedFile(config2.schema))throw new Error("Schema must be a local project file");if(input.content!==void 0&&typeof input.content!="string")throw new Error("Schema content must be text");let initial=input.content??SUBFORMAT_SCHEMA_TEMPLATE;if(compileSubformatSchema(initial,{root:root4,file:config2.schema,domains}),existsSync(textfilePath(root4,config2.schema))){if(input.content!==void 0&&readTextfile(root4,config2.schema)!==initial)return{status:409,body:{error:"Schema file already exists. Choose another path."}}}else if(!writeTextfile(root4,config2.schema,initial,null))return{status:409,body:{error:"Schema changed externally. Try again."}};if(!filesSnapshot(root4).files.some(file=>file.path===config2.schema))throw new Error("Subformat schema is not available in the workspace");let loaded=loadSubformat(root4,config2,domains),parsed2=parseDocument(raw),document5=isSeq(parsed2.contents)||parsed2.contents==null?new Document({docs:parsed2.toJS()??[]}):parsed2;document5!==parsed2&&(document5.commentBefore=parsed2.commentBefore);let key=manifest2.format!==void 0?"json_subformats":"subformats";return document5.has(key)?document5.addIn([key],config2):document5.set(key,[config2]),writeTextfile(root4,manifestFile(root4),document5.toString(),raw)?{status:200,body:{collection:{...config2,iconSvg,fields:loaded.fields,template:loaded.template,defaultFolder:manifest2.defaultSubformatFolder,records:[],change:"added"}}}:{status:409,body:{error:"Manifest changed externally. Try again."}}}if(input?.action==="create"){if(typeof input.file!="string"||typeof input.content!="string")throw new Error("A record file and content are required");let config2=readManifest(root4).subformats?.find(format6=>format6.ext===fileExtension(input.file));if(!config2)throw new Error("Choose a configured subformat extension");validateSubformatFile(root4,input.file,input.content,domains);let data2=parseSubformatRecord(input.content,config2.format);return writeTextfile(root4,input.file,input.content,null)?{status:200,body:{content:input.content,data:data2}}:{status:409,body:{error:"File already exists"}}}if(typeof input?.file!="string"||typeof input.base!="string"||typeof input.field!="string")throw new Error("A record file, original content and enum field are required");let files=filesSnapshot(root4).files.map(file=>file.path);if(!files.includes(input.file))throw new Error("Record file is not available in the workspace");let config=readManifest(root4).subformats?.find(format6=>format6.ext===fileExtension(input.file));if(!config||!files.includes(config.schema))throw new Error("Subformat schema is not available in the workspace");let format5=loadSubformat(root4,config,domains),field=format5.fields.find(field2=>field2.name===input.field);if(field?.readOnly||!(field?.enum??field?.options)?.some(value2=>value2===input.value))throw new Error("Choose a writable enum value defined by the schema");let current=readTextfile(root4,input.file);if(current!==input.base)return{status:409,body:{error:"File changed externally. Reload it before saving."}};let content3=setSubformatValue(current,format5.format,[input.field],input.value),roundTrip=parseSubformatRecord(content3,format5.format);return validateSubformatRecord(format5,roundTrip),writeTextfile(root4,input.file,content3,current)?{status:200,body:{content:content3,data:roundTrip}}:{status:409,body:{error:"File changed externally. Reload it before saving."}}}catch(error){return{status:400,body:{error:error instanceof Error?error.message:String(error)}}}},subformatRelations=(root4,configs,domains=[])=>{let loaded=configs.flatMap(config=>{try{let compiled=compileSubformatSchema(readTextfile(root4,config.schema),{root:root4,file:config.schema,domains});return[{ext:config.ext,...compiled}]}catch{return[]}}),owners=new Map(loaded.map(({ext,context})=>[context.uri,ext])),model={groups:[],tables:[],edges:[]};for(let{ext,schema:schema5,context}of loaded){let resolve2=schemaResolver(schema5,context),fields=[];for(let[name,definition3]of Object.entries(resolve2(schema5).properties??{})){let targets=new Set,list5=!1,seen=new Set,walk2=value2=>{let node2=resolve2(value2,uri=>{let owner=owners.get(uri.split("#")[0]??"");owner&&owner!==ext&&targets.add(owner)});if(seen.has(value2))return node2;seen.add(value2);let suffix=typeof node2.pattern=="string"&&/\\\.([\w-]+)\$$/.exec(node2.pattern)?.[1];suffix&&loaded.some(item=>item.ext===suffix)&&targets.add(suffix);for(let key of["anyOf","oneOf","allOf"])if(Array.isArray(node2[key]))for(let child of node2[key])walk2(child);if(schemaObject(node2.properties))for(let child of Object.values(node2.properties))walk2(child);return node2.items!==void 0&&(list5=!0,walk2(node2.items)),node2},property=walk2(definition3),type=Array.isArray(property.enum)?property.enum.map(value2=>JSON.stringify(value2)).join("|"):property.format==="date"||property.format==="date-time"?"timestamp":property.type==="string"?"string":property.type==="number"||property.type==="integer"?"number":property.type==="boolean"?"bool":"json";for(let to of targets)model.edges.push({from:ext,fieldIndex:fields.length,field:name,to,list:list5});fields.push(targets.size?{name,kind:list5?"fkList":"fk",targets:[...targets]}:{name,kind:"scalar",type})}model.tables.push({name:ext,fields,notes:[]}),model.groups.push({tables:[ext]})}return model};var resourceIndex=(root4,files,domains=[])=>{let result={codeblocks:[],urls:[],urlPreviews:[],skills:[],subformats:[],errors:[]},paths2=new Set(files),manifest2=readManifest(root4);if(result.errors.push(...manifest2.errors),result.libraries=manifest2.libraries??REFERENCE_LIBRARIES,result.libraries.includes("skills")&&manifest2.skills?.length)try{result.skills=readProjectSkills(root4).map(({file,frontmatter:frontmatter2,files:files2})=>({file,name:frontmatter2.name,description:frontmatter2.description,content:files2.get("SKILL.md")?.toString("utf8")??""}))}catch(error){result.errors.push(error instanceof Error?error.message:String(error))}let discovered=new Set(Object.keys(manifest2.formats??{}));for(let settings of Object.values(manifest2.includedFormats??{}))for(let format5 of Object.keys(settings))discovered.add(format5);let collected=new Map,collect3=(file,source2)=>{if(!paths2.has(file)){let path4=textfilePath(root4,file);if(assertNotIgnored(root4,file),!(file===manifestFile(root4)||file.startsWith(`${PROJECT_FONTS_DIR}/`)&&localFile(file.slice(PROJECT_FONTS_DIR.length+1)))||!statSync(path4,{throwIfNoEntry:!1})?.isFile())throw new Error(`File is not available in the workspace: ${file}`)}let item=collected.get(file)??{file,format:fileFormat(file),sources:[]};source2&&!item.sources.some(value2=>value2.file===source2.file&&value2.line===source2.line)&&item.sources.push(source2),collected.set(file,item),discovered.add(item.format)},selected=formatFiles(root4,manifest2,files);result.errors.push(...selected.errors.map(({file,message})=>`${file}: ${message}`));for(let file of selected.files)collect3(file);for(let node2 of flattenTree(manifest2.tree))node2.format&&discovered.add(discovered.has(node2.format)?node2.format:fenceFormat(node2.format)),isContentPage(node2)&&paths2.has(docFile(node2.id,manifest2.files))&&collect3(docFile(node2.id,manifest2.files));let formats2=new Map;for(let config of manifest2.subformats??[])try{if(!paths2.has(config.schema))throw new Error("Schema is not available in the workspace");let loaded=loadSubformat(root4,config,domains);formats2.set(config.ext,loaded),discovered.add(config.ext);let iconSvg;try{iconSvg=subformatIconSvg(root4,config)}catch{}result.subformats.push({...config,...iconSvg?{iconSvg}:{},fields:loaded.fields,template:loaded.template,defaultFolder:manifest2.defaultSubformatFolder,records:[]})}catch(error){result.errors.push(`${config.schema}: ${error instanceof Error?error.message:String(error)}`)}result.relations=subformatRelations(root4,result.subformats,domains);let urls=new Map,urlPreviews=new Map,references=new Map,validateTerms=(raw,source2)=>{let parsed2=parseTermSource(`${source2.file}#L${source2.line}`,raw);result.errors.push(...parsed2.errors.map(error=>`${source2.file}:L${source2.line+error.line}: ${error.message}`))},scan=(tree,file,offset=0)=>{let definitions2=new Map;visit(tree,"definition",node2=>{definitions2.set(node2.identifier,node2.url)}),visit(tree,node2=>{let source2={file,line:offset+(node2.position?.start.line??1)};if(node2.type==="code"){let language=node2.lang?.toLowerCase()||"text",format5=formats2.get(language.replace(/^\./,"")),extension2=format5?.ext??fenceFormat(language);discovered.add(extension2);let origin=sourceOrigin(manifest2,file);((origin?manifest2.includedFormats?.[origin]?.[extension2]:void 0)??manifest2.formats?.[extension2])?.codeblock!==!1&&result.codeblocks.push({language:format5?.format??language,format:extension2,caption:node2.meta??"",content:node2.value,source:source2}),language==="termth"&&validateTerms(node2.value,{...source2,line:source2.line+1}),language==="callouth"&&scan(parseMdast(node2.value),file,source2.line);return}let target=node2.type==="link"||node2.type==="image"?node2.url:node2.type==="linkReference"||node2.type==="imageReference"?definitions2.get(node2.identifier):void 0;if(!target)return;let preview=node2.type==="image"||node2.type==="imageReference";if(!/^(?:[a-z][a-z\d+.-]*:|[/#])/i.test(target)){try{let ref=parseFileEmbed(preview?target:target.split(/[?#]/)[0]??target),referencedFile=ref.file.replace(/^(\.\/)+/,"");if(formatReference(referencedFile)!==void 0)return;if(!preview||ref.kind!=="textfile"){collect3(referencedFile,source2);return}let language=fileFormat(referencedFile),content3=selectTextfileRange(readTextfile(root4,referencedFile),ref.range);collect3(referencedFile,source2),result.codeblocks.push({language:formats2.get(language)?.format??language,format:language,inline:!1,caption:node2.alt??"",content:content3,source:source2,reference:{file:referencedFile,line:ref.range?parseTextfileRange(ref.range)[0]:1,...ref.range?{range:ref.range}:{}}})}catch(error){result.errors.push(`${file}:L${source2.line}: ${target}: ${error instanceof Error?error.message:String(error)}`)}return}try{let url=new URL(target);if(!["http:","https:","mailto:"].includes(url.protocol))return;let entries=preview?urlPreviews:urls,key=url.href,entry=entries.get(key)??{url:key,host:url.host||url.protocol,sources:[]};entry.sources.push(source2),entries.set(key,entry)}catch{}})};for(let file of paths2){let format5=formats2.get(fileExtension(file));if(format5&&!(manifest2.subformats??[]).some(item=>item.schema===file)){try{let content3=readTextfile(root4,file);collect3(file),result.codeblocks.push({inline:!1,language:format5.format,format:format5.ext,caption:file,content:content3,source:{file,line:1}});let data2=parseSubformatRecord(content3,format5.format);validateSubformatRecord(format5,data2),result.subformats.find(item=>item.ext===format5.ext)?.records.push({file,content:content3,data:data2})}catch(error){result.errors.push(`${file}: ${error instanceof Error?error.message:String(error)}`)}continue}if(/\.(?:md|termth)$/i.test(file))try{let raw=readTextfile(root4,file);if(/\.termth$/i.test(file)){let source2={file,line:1};collect3(file),result.codeblocks.push({inline:!1,language:"termth",format:"termth",caption:"",content:raw,source:source2}),validateTerms(raw,source2)}else{let tree=parseMdast(rebaseFileLinks(raw,sourceOrigin(manifest2,file)));scan(tree,file);for(let ref of subformatReferences(tree)){if(!formats2.has(fileExtension(ref.file)))continue;let sources3=references.get(ref.file)??[];sources3.push({file,line:ref.line}),references.set(ref.file,sources3)}}}catch(error){result.errors.push(`${file}: ${error instanceof Error?error.message:String(error)}`)}}let indexed=new Set(result.codeblocks.filter(item=>item.inline===!1).map(item=>item.reference?.file??item.source.file));for(let file of collected.keys())if(!(indexed.has(file)||/\.(svg|html|png|webp|gif|mp4|webm|jpe?g|pdf|dxf)$/i.test(file)))try{let format5=fileFormat(file);result.codeblocks.push({language:formats2.get(format5)?.format??format5,format:format5,inline:!1,caption:file,content:readTextfile(root4,file),source:{file,line:1}})}catch{}result.files=[...collected.values()].sort((a2,b2)=>a2.file.localeCompare(b2.file)),result.formats=[...discovered].sort(),result.urls=result.libraries.includes("urls")?[...urls.values()].sort((a2,b2)=>a2.url.localeCompare(b2.url)):[],result.urlPreviews=result.libraries.includes("url-previews")?[...urlPreviews.values()].sort((a2,b2)=>a2.url.localeCompare(b2.url)):[];for(let collection of result.subformats)for(let record2 of collection.records)record2.references=references.get(record2.file)??[];return result};var readFormatCollection=(root4,selector,options2={},textfiles)=>{validateSubformatOptions(options2,FORMAT_META_FIELDS);let paths2=projectFiles(root4).map(file=>file.path),index4=resourceIndex(root4,paths2),alias=selector&&fenceFormat(selector),match=alias!==selector&&!index4.formats?.includes(selector)&&!paths2.some(file=>fileFormat(file)===selector)?alias:selector,records=[],add2=(file,format5,line2,inline,source2)=>{let traits=formatTraits(format5);if(inline&&!traits.includes("codes")&&traits.push("codes"),!matchesFormat(format5,match,traits)||options2.folder&&!inFormatFolder(file,options2.folder))return;let folder=file.slice(0,file.lastIndexOf("/"))||".",data2={file,folder:file.includes("/")?folder:".",format:format5,traits,kind:inline?"codeblock":"file",line:line2},record2={file,data:data2,content:JSON.stringify(data2)};if(matchesSubformatRecord(record2,options2,FORMAT_META_FIELDS)){if(!inline&&/\.(svg|html|png|webp|gif|mp4|webm|jpe?g|pdf|dxf)$/i.test(file))record2.preview=[{type:"figureRef",name:figureName(file)}];else try{let content3=source2??textfiles?.get(file)??readTextfile(root4,file),parsed2=parseContentSource(format5,content3,file);record2.preview=parsed2&&!parsed2.errors.length&&parsed2.blocks.length?parsed2.blocks:[{type:"code",lang:format5,lines:content3.split(`
|
|
428
428
|
`)}]}catch{}records.push(record2)}},files=selector&&selector!=="all"?paths2:(index4.files??[]).map(item=>item.file);for(let file of files)add2(file,fileFormat(file),1,!1);for(let block of index4.codeblocks)block.inline!==!1&&add2(block.source.file,block.format,block.source.line,!0,block.content);return{ext:`format/${selector||"all"}`,schema:`format/${selector||"all"}.schema.json`,format:"json",resource:!0,fields:FORMAT_META_FIELDS,records:sortSubformatRecords(records,FORMAT_META_FIELDS.find(field=>field.name===options2.sort_by),options2.sort_order==="desc")}},formatCollectionBlock=(collection,options2={})=>({type:"code",lang:"json",lines:JSON.stringify(formatMetadataSchema(collection.ext.slice(7)),null,2).split(`
|
|
429
429
|
`),subformat:collection,embed:{view:"grid",columns:3,rows:2,fields:["folder"],...options2}});init_browser_globals();var themeNames=root4=>{let directory2=textfilePath(root4,"themes");return existsSync(directory2)?readdirSync(directory2,{withFileTypes:!0}).filter(entry=>entry.isDirectory()&&/^[a-z][a-z0-9-]*$/.test(entry.name)).map(entry=>entry.name).sort():[]},siteThemes=(root4,manifest2=readManifest(root4))=>manifest2.themes??[...new Set([...themeNames(root4),...(manifest2.includedManifests??[]).flatMap(file=>themeNames(join4(root4,posix.dirname(file))))])],themeVariants=(root4,file,themes,manifest2=readManifest(root4))=>{let directory2=manifestDirectory(sourceOrigin(manifest2,file)),source2=file.slice(directory2.length);if(!localFile(file)||source2.startsWith("themes/"))return{};let variants=(themes??siteThemes(root4,manifest2)).map(theme=>[theme,directory2+themeVariantFile(source2,theme)]).filter(([,path4])=>existsSync(textfilePath(root4,path4))),ignored=ignoredFiles(root4,variants.map(([,path4])=>path4));return Object.fromEntries(variants.filter(([,path4])=>!ignored.has(path4)))};init_browser_globals();var DOS_DATE=33,zip=entries=>{let locals=[],centrals=[],offset=0;for(let{name,data:data2}of entries){let nameBuf=import_buffer.Buffer.from(name,"utf8"),body=deflateRawSync(data2),crc=crc322(data2),common=import_buffer.Buffer.alloc(26);common.writeUInt16LE(20,0),common.writeUInt16LE(2048,2),common.writeUInt16LE(8,4),common.writeUInt16LE(0,6),common.writeUInt16LE(DOS_DATE,8),common.writeUInt32LE(crc,10),common.writeUInt32LE(body.length,14),common.writeUInt32LE(data2.length,18),common.writeUInt16LE(nameBuf.length,22),common.writeUInt16LE(0,24);let local=import_buffer.Buffer.concat([import_buffer.Buffer.from([80,75,3,4]),common,nameBuf]),central=import_buffer.Buffer.alloc(46);central.writeUInt32LE(33639248,0),central.writeUInt16LE(798,4),common.copy(central,6),central.writeUInt32LE(33188<<16>>>0,38),central.writeUInt32LE(offset,42),locals.push(local,body),centrals.push(central,nameBuf),offset+=local.length+body.length}let dir=import_buffer.Buffer.concat(centrals),end=import_buffer.Buffer.alloc(22);return end.writeUInt32LE(101010256,0),end.writeUInt16LE(entries.length,8),end.writeUInt16LE(entries.length,10),end.writeUInt32LE(dir.length,12),end.writeUInt32LE(offset,16),import_buffer.Buffer.concat([...locals,dir,end])};var exportEntries=(root4,file=manifestFile(root4))=>{let manifest2=readManifest(root4,file);if(manifest2.errors.length)throw new Error(manifest2.errors.join(`
|
|
430
430
|
`));let themes=siteThemes(root4,manifest2),entries=new Map,origins=new Map,skillFiles=new Map;for(let source2 of[file,...manifest2.includedManifests??[]])for(let skill of readProjectSkills(root4,source2))for(let[name,data2]of skill.files)skillFiles.set(posix.join(posix.dirname(skill.file),name),data2);let add2=(file2,origin)=>{if(file2=file2.replace(/^(\.\/)+/,""),entries.has(file2))return;let skillData=skillFiles.get(file2);if(skillData){entries.set(file2,{name:file2,data:skillData});return}let settingsFile=[PROJECT_FONTS_DIR,CODE_LANGUAGES_DIR,".dooc/editor-tools"].some(dir=>file2.startsWith(`${dir}/`)&&localFile(file2.slice(dir.length+1)));if(!localFile(file2.replace(/[?#]/g,"_"))&&!settingsFile)throw new Error(`Invalid export dependency: ${file2}`);let path4=textfilePath(root4,file2);if(assertNotIgnored(root4,file2),!statSync(path4).isFile())throw new Error(`Expected a regular source file: ${file2}`);entries.set(file2,{name:file2,data:readFileSync(path4)}),origin&&origins.set(file2,origin);for(let variant of Object.values(themeVariants(root4,file2,themes,manifest2)))add2(variant,origin)},optional=(file2,origin)=>{existsSync(textfilePath(root4,file2))&&!ignoredFiles(root4,[file2]).has(file2)&&add2(file2,origin)};add2(file);for(let file2 of manifest2.includedManifests??[])add2(file2);for(let file2 of manifest2.includedAssets??[])add2(file2);manifest2.licence&&add2(manifest2.licence);let collection=formatFiles(root4,manifest2);if(collection.errors.length)throw new Error(collection.errors.map(({file:file2,message})=>`${file2}: ${message}`).join(" / "));for(let file2 of collection.files)add2(file2,sourceOrigin(manifest2,file2));optional(CONFIG_FILE);for(let node2 of flattenTree(manifest2.tree)){let{id,origin}=node2,file2=isContentPage(node2)?docFile(id,manifest2.files):void 0;if(file2&&add2(file2,origin),node2.url&&pageUrlKind(node2.url)==="file"&&add2(node2.url,origin),manifest2.files?.icons?.[id]?add2(docIconFile(id,manifest2.files)):optional(docIconFile(id,manifest2.files)),!!file2)for(let language of siteContentLanguages(root4,manifest2))optional(translationFile(file2,language,origin),origin)}for(let file2 of new Set([manifest2.icon,...Object.values(manifest2.themeIcons??{})]))file2&&add2(file2);let files=projectFiles(root4);if(flattenTree(manifest2.tree).some(node2=>node2.library||node2.format))for(let file2 of files)(file2.extension==="md"||file2.extension==="termth")&&add2(file2.path,sourceOrigin(manifest2,file2.path));for(let format5 of manifest2.subformats??[]){add2(format5.schema),format5.icon&&add2(format5.icon);for(let file2 of files)file2.extension===format5.ext&&add2(file2.path)}for(let dir of[PROJECT_FONTS_DIR,CODE_LANGUAGES_DIR,".dooc/editor-tools"]){let path4=textfilePath(root4,dir);if(existsSync(path4))for(let file2 of readdirSync(path4,{recursive:!0,withFileTypes:!0}))file2.isFile()&&optional(posix.join(dir,posix.relative(path4,file2.parentPath),file2.name))}let relative2=(source2,file2)=>{if(!source2||source2.startsWith("#")||/^(?:[a-z][\w+.-]*:|\/\/)/i.test(source2))return;if(source2.startsWith("/"))throw new Error(`Export dependencies must be relative: ${source2}`);let path4=decodeURIComponent(source2.split(/[?#]/)[0]??"");if(!path4)return;let dependency=posix.normalize(posix.join(posix.dirname(file2),path4));return add2(dependency),dependency},schemas2=new Set(manifest2.subformats?.map(format5=>format5.schema));for(let file2 of schemas2){let document5=JSON.parse(entries.get(file2)?.data.toString("utf8")??""),baseUri=pathToFileURL(textfilePath(root4,file2)).href,resources=new Set([baseUri]);visitSchema(document5,baseUri,(_schema,base2)=>resources.add(base2.split("#")[0]??base2)),visitSchema(document5,baseUri,(schema5,base2)=>{if(typeof schema5.$ref!="string")return;let uri=new URL(schema5.$ref,base2);if(uri.protocol!=="file:"||(uri.hash="",resources.has(uri.href)))return;let dependency=relative(realpathSync(root4),fileURLToPath(uri)).replaceAll("\\","/");add2(dependency),schemas2.add(dependency)})}for(let entry of entries.values()){if(skillFiles.has(entry.name))continue;let ext=fileExtension(entry.name);if(["md","callouth"].includes(ext)){let origin=origins.get(entry.name),tree=parseMdast(rebaseFileLinks(entry.data.toString("utf8"),origin)),refs=collectRefs(tree);for(let file2 of refs.figures)isRemoteTextfile(file2)||add2(file2,origin);for(let file2 of[...refs.terms,...refs.textfiles])isRemoteTextfile(file2)||(readTextfile(root4,file2),add2(file2,origin));let reference=url=>{if(/^(?:[a-z][\w+.-]*:|[/#])/i.test(url))return;let ref=parseFileReference(url,!0),file2=ref.file.replace(/^(\.\/)+/,""),selector=formatReference(file2);if(selector===void 0)add2(file2,origin);else for(let record2 of readFormatCollection(root4,selector,parseFormatQuery(ref.query??"")).records)add2(record2.file,origin)};visit(tree,"image",node2=>reference(node2.url));for(let link2 of contentLinks(tree))reference(link2.url)}else["html","htm","svg","css"].includes(ext)&&assetReferences(entry.data.toString("utf8"),ext,(url,embedded)=>(embedded&&relative2(url,entry.name),url))}for(let[name,data2]of skillFiles)entries.set(name,{name,data:data2});return[...entries.values()]},exportBundle=root4=>zip(exportEntries(root4));var REMOTE_MANIFEST_DIR="dooc-imports",remoteManifestFile=url=>{let source2=remoteManifestSource(url),key=createHash("sha256").update(JSON.stringify(source2)).digest("hex");return`${REMOTE_MANIFEST_DIR}/${key}/${basename3(source2.path)}`},isRemoteSourceFile=file=>file.split("/").includes(REMOTE_MANIFEST_DIR),sources=new Map,pending2=new Map,manifestSourcePath=file=>{file=resolve(file);for(let depth=0;depth<64;depth++){let match=[...sources].sort(([a2],[b2])=>b2.length-a2.length).find(([folder])=>file===folder||file.startsWith(`${folder}/`));if(!match)return file;file=join4(match[1],relative(match[0],file))}throw new Error("Circular remote manifest source")},prepareRemoteManifests=async(root4,load,active=new Set)=>{let visit5=async file=>{if(!existsSync(join4(root4,file)))return;let path4=textfilePath(root4,file);if(active.has(path4))throw new Error(`Circular manifest include: ${file}`);if(active.size>=64)throw new Error("Manifest nesting exceeds 64 levels");if(existsSync(path4)){active.add(path4);try{let manifest2=parseManifestText(readFileSync(path4,"utf8"),file,!1);if(manifest2.errors.length)return;for(let node2 of flattenTree(manifest2.tree)){if(!node2.url||pageUrlKind(node2.url)!=="manifest")continue;if(!isRemoteManifest(node2.url)){await visit5(join4(dirname3(file),node2.url));continue}let source2=remoteManifestSource(node2.url),cacheFile=remoteManifestFile(node2.url),identity=JSON.stringify(source2);if(active.has(identity))throw new Error(`Circular manifest include: ${node2.url}`);let destination=textfilePath(root4,join4(dirname3(file),cacheFile)),task=pending2.get(destination);task&&!existsSync(destination)&&(await task,existsSync(destination)||(pending2.delete(destination),task=void 0)),task||(task=(async()=>{active.add(identity);try{let sourceRoot=await load(source2);await prepareRemoteManifests(sourceRoot,load,active);let entries=exportEntries(sourceRoot),folder=dirname3(destination),size=0;for(let entry of entries){if(size+=entry.data.length,size>268435456)throw new Error("Remote document exceeds 256 MiB");let relativeTarget=join4(dirname3(file),dirname3(cacheFile),entry.name),target=textfilePath(root4,relativeTarget);if(target!==resolve(realpathSync(root4),relativeTarget))throw new Error("Remote document cache cannot contain symbolic links");mkdirSync(dirname3(target),{recursive:!0}),writeFileSync(target,entry.data)}sources.set(folder,sourceRoot)}finally{active.delete(identity)}})().catch(error=>{throw pending2.delete(destination),error}),pending2.set(destination,task)),await task}}finally{active.delete(path4)}}};await visit5(manifestFile(root4))};var manifests=new Map,parsed=createFileCache(),manifestFile=root4=>manifests.get(resolve(root4))??MANIFEST_FILE,sourceOrigin=(manifest2,file)=>{let page=flattenTree(manifest2.tree).find(node2=>isContentPage(node2)&&docFile(node2.id,manifest2.files)===file);return page?page.origin:manifest2.includedManifests?.filter(owner=>posix.dirname(owner)==="."||file.startsWith(`${posix.dirname(owner)}/`)).sort((a2,b2)=>b2.length-a2.length)[0]},sectionManifest=(root4,value2)=>{let file=value2===void 0?manifestFile(root4):value2;if(typeof file!="string"||file!==manifestFile(root4)&&!readManifest(root4).includedManifests?.includes(file))throw new Error("Document section is not available");return manifestSourcePath(textfilePath(root4,file))},projectRoot=(input=MANIFEST_FILE)=>{let file=resolve(input);if(!isManifestFile(basename3(file))||!existsSync(file)||!statSync(file).isFile())throw new Error(`Specify an existing dooc.yaml or <name>.dooc.yaml file: ${file}`);let root4=dirname3(file);return manifests.set(root4,basename3(file)),root4},parseManifestText=(raw,file=MANIFEST_FILE,validatePaths=!0)=>{let value2;try{value2=parse(raw)}catch(e2){return{tree:[],errors:[`${file}: invalid YAML (${e2 instanceof Error?e2.message:e2})`]}}let manifest2=parseManifest(value2);return validatePaths&&manifest2.errors.push(...documentPathErrors(flattenTree(manifest2.tree)).map(error=>`${MANIFEST_FILE}: ${error}`)),manifest2.errors=manifest2.errors.map(error=>error.replace(/^dooc\.yaml(?=:)/,()=>file)),manifest2},readManifest=(root4,file=manifestFile(root4))=>{if(!existsSync(join4(root4,file)))return{tree:[],errors:[]};let active=new Set,load=(file2,imported=!1)=>{let path4=textfilePath(root4,file2);if(imported&&assertNotIgnored(root4,file2),active.has(path4))throw new Error(`Circular manifest include: ${file2}`);if(active.size>=64)throw new Error("Manifest nesting exceeds 64 levels");active.add(path4);try{let manifest2=structuredClone(parsed.get(path4,raw=>parseManifestText(raw,file2,!1))),folder=posix.dirname(file2),qualify=value2=>posix.join(folder,value2),icons=manifest2.files?.icons??{},rebasedIcons={},visit5=nodes=>{for(let node2 of nodes){let oldId=node2.id;if(imported&&(isContentPage(node2)&&(node2.file=qualify(node2.file??docFile(oldId,manifest2.files))),node2.url&&!isRemoteManifest(node2.url)&&["content","file","manifest"].includes(pageUrlKind(node2.url))&&(node2.url=qualify(node2.url)),node2.id=fileDocumentId(node2.file??(node2.url&&pageUrlKind(node2.url)==="manifest"?node2.url:`${file2}#${oldId}`)),node2.origin=file2,icons[oldId]&&(rebasedIcons[node2.id]=qualify(icons[oldId]))),visit5(node2.children),node2.url===void 0||pageUrlKind(node2.url)!=="manifest")continue;let included=isRemoteManifest(node2.url)?qualify(remoteManifestFile(node2.url)):node2.url,child=load(included,!0);manifest2.errors.push(...child.errors),node2.resolved=child.tree[0]?.root?child.tree[0]:{id:node2.id,url:"",title:child.title,origin:included,children:child.tree},node2.resolved.title||(node2.resolved.title=child.title),manifest2.includedManifests??=[],manifest2.includedManifests.push(included,...child.includedManifests??[]),manifest2.includedAssets??=[],manifest2.includedAssets.push(...child.includedAssets??[]),manifest2.includedFormats??={},manifest2.includedFormats[included]=child.formats??{},Object.assign(manifest2.includedFormats,child.includedFormats),manifest2.files??=parseFileLayout({}),Object.assign(rebasedIcons,child.files?.icons);let includedIcon=child.files?.icons?.[node2.resolved.id];includedIcon&&!icons[oldId]&&(rebasedIcons[node2.id]=includedIcon);for(let format5 of child.subformats??[]){let existing=manifest2.subformats?.find(({ext})=>ext===format5.ext);if(existing&&JSON.stringify(existing)!==JSON.stringify(format5))throw new Error(`Conflicting subformat ${format5.ext} in ${included}`);existing||(manifest2.subformats??=[],manifest2.includedSubformats??=[],manifest2.subformats.push(format5),manifest2.includedSubformats.push(format5.ext))}}};if(imported){for(let sources3 of Object.values(manifest2.formats??{}))sources3.files&&(sources3.files=sources3.files.map(qualify)),sources3.folders&&(sources3.folders=sources3.folders.map(qualify));manifest2.includedAssets=[manifest2.icon,manifest2.licence,...Object.values(manifest2.themeIcons??{})].flatMap(asset=>asset?[qualify(asset)]:[]);for(let format5 of manifest2.subformats??[])format5.schema=qualify(format5.schema),format5.icon&&(format5.icon=qualify(format5.icon))}if(visit5(manifest2.tree),imported||manifest2.includedManifests?.length){manifest2.files??=parseFileLayout({}),imported&&(manifest2.files.documents={});for(let node2 of flattenTree(manifest2.tree))node2.file&&isContentPage(node2)&&(manifest2.files.documents[node2.id]=node2.file);manifest2.files.icons={...imported?{}:icons,...rebasedIcons}}return manifest2}finally{active.delete(path4)}};try{let manifest2=load(file),pages=flattenTree(manifest2.tree);manifest2.errors.push(...documentPathErrors(pages).map(error=>`${file}: ${error}`));let ids=pages.map(({id})=>id);return new Set(ids).size!==ids.length&&manifest2.errors.push(`${file}: Duplicate document in included manifests`),manifest2}catch(error){return{tree:[],errors:[`${file}: ${error instanceof Error?error.message:error}`]}}},writeManifest=(root4,tree,metadata={})=>{writeFileSync(join4(root4,manifestFile(root4)),serializeManifest(tree,metadata))};var translationFile=(file,language,origin)=>{if(!isContentLanguage(language))throw new Error("Expected an ISO 639-3 language code");if(!localFile(file)||!file.endsWith(".md"))throw new Error("Expected a Markdown file path");let folder=origin?posix.dirname(origin):".",source2=posix.relative(folder,file);if(!localFile(source2))throw new Error("Translation source is outside its manifest folder");return posix.join(folder,"locales",language,source2)},translationLanguages=root4=>{let dir=textfilePath(root4,"locales");return existsSync(dir)?readdirSync(dir,{withFileTypes:!0}).filter(entry=>entry.isDirectory()&&isContentLanguage(entry.name)).map(entry=>entry.name).sort():[]},siteContentLanguages=(root4,manifest2=readManifest(root4))=>manifest2.languages??[...new Set([contentLanguageCode(manifest2.defaultLang??DEFAULT_LANG),...translationLanguages(root4)])],translationFiles=root4=>{let files=[...new Set([".",...(readManifest(root4).includedManifests??[]).map(file=>posix.dirname(file))])].flatMap(folder=>translationLanguages(join4(root4,folder)).flatMap(language=>{let directory2=posix.join(folder,"locales",language);return readdirSync(textfilePath(root4,directory2),{recursive:!0,withFileTypes:!0}).filter(entry=>entry.isFile()&&entry.name.endsWith(".md")).map(entry=>relative(root4,join4(entry.parentPath,entry.name)).replaceAll("\\","/")).filter(localFile).sort()})),ignored=ignoredFiles(root4,files);return files.filter(file=>!ignored.has(file))},setDocTranslation=(root4,sourceLanguage,id,language,added)=>{if(!isDocId(id))throw new Error("Invalid document id");if(language===sourceLanguage)throw new Error("Source language cannot be removed");let manifest2=readManifest(root4);if(manifest2.errors.length)throw new Error(manifest2.errors.join(`
|
|
@@ -517,7 +517,7 @@ ${marker}`}return preserve(node2)}}}).stringify(parseMdast(body));return body.in
|
|
|
517
517
|
<template data-table-rows>${escapeHtml(JSON.stringify(rows))}</template></section>`}let th=b2.headers.map(h2=>`<th>${segmentsHtml(h2,ctx,seg)}</th>`).join(""),trs=b2.rows.map(r2=>`<tr>${r2.map(c2=>`<td>${segmentsHtml(c2,ctx,seg)}</td>`).join("")}</tr>`).join(""),table=`<table><thead><tr>${th}</tr></thead><tbody>${trs}</tbody></table>`;return b2.collapsible?`<details><summary>${escapeHtml(b2.caption??"table")}</summary>${table}</details>`:`${table}${b2.caption?`<div class="cap">${escapeHtml(b2.caption)}</div>`:""}`},n1=v2=>String(Math.round(v2*10)/10),schemaBoxHtml=t4=>{let r2=t4.radius,head=[`M${n1(t4.x)},${n1(t4.y+r2)}`,`a${r2},${r2} 0 0 1 ${r2},-${r2}`,`h${n1(t4.w-r2*2)}`,`a${r2},${r2} 0 0 1 ${r2},${r2}`,`v${n1(t4.headerH-r2)}`,`h-${n1(t4.w)}`,"z"].join(" "),rows=t4.rows.map(row=>{if(row.kind==="note")return`<text class="sg-note" x="${n1(row.x)}" y="${n1(row.baseline)}">${escapeHtml(row.name)}</text>`;let typeCls=row.kind==="pk"?" sg-key":row.kind==="scalar"?"":" sg-ref";return[`<text class="sg-fname" x="${n1(row.x)}" y="${n1(row.baseline)}">${escapeHtml(row.name)}</text>`,`<text class="sg-ftype${typeCls}" x="${n1(row.typeX)}" y="${n1(row.baseline)}" text-anchor="end">${escapeHtml(row.type)}</text>`].join("")}).join(""),hits=t4.rows.filter(row=>row.fieldIndex!=null&&(row.kind==="fk"||row.kind==="fkList")).map(row=>`<rect class="sg-hit sg-hf${t4.index}-${row.fieldIndex}" x="${n1(t4.x)}" y="${n1(row.y-9.5)}" width="${n1(t4.w)}" height="19"></rect>`).join("");return[`<g class="sg-g" data-sg-t="${t4.index}">`,`<rect class="sg-box sg-b${t4.index}" x="${n1(t4.x)}" y="${n1(t4.y)}" width="${n1(t4.w)}" height="${n1(t4.h)}" rx="${r2}"></rect>`,`<path class="sg-head" d="${head}"></path>`,`<text class="sg-tname" x="${n1(t4.rows[0]?.x??t4.x)}" y="${n1(t4.headerBaseline)}">${escapeHtml(t4.name)}</text>`,rows,`<rect class="sg-hit sg-h${t4.index}" x="${n1(t4.x)}" y="${n1(t4.y)}" width="${n1(t4.w)}" height="${n1(t4.h)}"></rect>`,hits,"</g>"].join("")},schemaGraphHtml=b2=>{if(b2.graph.tables.length===0)return`<div class="ph">${escapeHtml(b2.alt||"schema graph")}<span> \u2014 no tables declared</span></div>`;let layout=layoutSchemaGraph(b2.graph),cls=`sg-${schemaGraphUid(b2.graph)}`,arrow=`${cls}-arw`,accent="var(--doc-accent-2, #0277bd)",rules=[`.${cls}{width:100%;max-width:${layout.width}px;height:auto;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}`,`.${cls} .sg-frame{fill:color-mix(in srgb, var(--doc-fg, #000000) 3%, transparent);stroke:var(--doc-border, #dde3eb);stroke-width:1;stroke-dasharray:5 4}`,`.${cls} .sg-glabel{font-size:11.5px;fill:var(--doc-fg-3, #5b6271)}`,`.${cls} .sg-box{fill:var(--doc-panel, #ffffff);stroke:var(--doc-border, #dde3eb);stroke-width:1}`,`.${cls} .sg-head{fill:color-mix(in srgb, ${accent} 10%, transparent)}`,`.${cls} .sg-tname{font-size:12.5px;fill:var(--doc-fg, #000000)}`,`.${cls} .sg-fname{font-size:11.5px;fill:var(--doc-fg-2, #2a3140)}`,`.${cls} .sg-ftype{font-size:10.5px;fill:var(--doc-fg-3, #5b6271)}`,`.${cls} .sg-key{fill:${accent}}`,`.${cls} .sg-ref{fill:var(--doc-accent, #1b4994)}`,`.${cls} .sg-note{font-size:10.5px;fill:var(--doc-fg-4, #9099a8)}`,`.${cls} .sg-e{fill:none;stroke:color-mix(in srgb, var(--doc-fg, #000000) 26%, transparent);stroke-width:1.2}`,`.${cls} .sg-list{stroke-dasharray:5 4}`,`.${cls} .sg-hit{fill:transparent}`,`.${cls} .sg-legend{font-size:10.5px;fill:var(--doc-fg-3, #5b6271)}`,`.${cls}.sg-live{touch-action:none}`,`.${cls}.sg-live .sg-g{cursor:grab}`,`.${cls}.sg-grabbing .sg-g{cursor:grabbing}`,`.${cls} .sg-tool{opacity:0.35;transition:opacity .12s}`,`.${cls}:hover .sg-tool,.${cls}.sg-expanded .sg-tool{opacity:1}`,`.${cls} .sg-btn{cursor:pointer}`,`.${cls} .sg-btn-bg{fill:var(--doc-panel, #ffffff);stroke:var(--doc-border, #dde3eb);stroke-width:1}`,`.${cls} .sg-btn:hover .sg-btn-bg{stroke:${accent}}`,`.${cls} .sg-btn-t{font-size:12px;fill:var(--doc-fg-2, #2a3140)}`];for(let t4 of layout.tables)rules.push(`.${cls}:has(.sg-h${t4.index}:hover) .sg-e{opacity:0.12}`,`.${cls}:has(.sg-h${t4.index}:hover) .sg-et${t4.index}{opacity:1;stroke:${accent};stroke-width:1.8}`,`.${cls}:has(.sg-h${t4.index}:hover) .sg-b${t4.index}{stroke:${accent}}`);for(let e2 of layout.edges)rules.push(`.${cls}:has(.sg-hf${e2.from}-${e2.fieldIndex}:hover) .sg-ef${e2.from}-${e2.fieldIndex}{opacity:1;stroke:${accent};stroke-width:2.4}`);let frames=layout.groups.map(g2=>`<rect class="sg-frame" x="${n1(g2.x)}" y="${n1(g2.y)}" width="${n1(g2.w)}" height="${n1(g2.h)}" rx="14"></rect><text class="sg-glabel" x="${n1(g2.x+4)}" y="${n1(g2.y-7)}">${escapeHtml(g2.label)}</text>`).join(""),edges=layout.edges.map((e2,i3)=>`<path class="sg-e sg-et${e2.from} sg-et${e2.to} sg-ef${e2.from}-${e2.fieldIndex}${e2.list?" sg-list":""}" data-sg-e="${i3}" d="${e2.d}" marker-end="url(#${arrow})"></path>`).join(""),legend=layout.legendY==null?"":`<text class="sg-legend" x="${SCHEMA_LAYOUT_MARGIN}" y="${n1(layout.legendY)}">Solid = fk (1:1) / dashed = fk[] (1:N) / hover to highlight related references</text>`,desc=`${b2.graph.tables.length} tables, ${b2.graph.edges.length} references: ${b2.graph.tables.map(t4=>t4.name).join(", ")}`,clientData=schemaGraphClientData(cls,b2.graph,layout,b2.source),svg=[`<svg xmlns="http://www.w3.org/2000/svg" class="${cls}" viewBox="0 0 ${layout.width} ${layout.height}" role="img" data-sg-layout="${escapeHtml(JSON.stringify(clientData))}">`,`<title>${escapeHtml(b2.alt??b2.caption??"schema graph")}</title>`,`<desc>${escapeHtml(desc)}</desc>`,`<defs><marker id="${arrow}" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" style="fill:context-stroke"></path></marker></defs>`,`<style>${rules.join(`
|
|
518
518
|
`)}</style>`,'<g class="sg-view">',frames,edges,layout.tables.map(schemaBoxHtml).join(""),"</g>",legend,"</svg>"].join("");return`<figure class="fig"${b2.alt?` aria-label="${escapeHtml(b2.alt)}"`:""}>${svg}${b2.caption?`<figcaption class="cap">${escapeHtml(b2.caption)}</figcaption>`:""}</figure>`},graphBoxHtml=n2=>[`<g class="gr-g" data-gr-n="${n2.index}">`,`<rect class="gr-box gr-b${n2.index}" x="${n1(n2.x)}" y="${n1(n2.y)}" width="${n1(n2.w)}" height="${n1(n2.h)}" rx="${n2.radius}"></rect>`,`<text class="gr-nlabel" x="${n1(n2.textX)}" y="${n1(n2.baseline)}" text-anchor="middle">${escapeHtml(n2.label)}</text>`,`<rect class="gr-hit gr-h${n2.index}" x="${n1(n2.x)}" y="${n1(n2.y)}" width="${n1(n2.w)}" height="${n1(n2.h)}"></rect>`,"</g>"].join(""),graphHtml=b2=>{if(b2.graph.nodes.length===0)return`<div class="ph">${escapeHtml(b2.alt||"graph")}<span> \u2014 no nodes declared</span></div>`;let layout=layoutGraph(b2.graph),cls=`gr-${graphUid(b2.graph)}`,arrow=`${cls}-arw`,accent="var(--doc-accent-2, #0277bd)",rules=[`.${cls}{width:100%;max-width:${layout.width}px;height:auto;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}`,`.${cls} .gr-frame{fill:color-mix(in srgb, var(--doc-fg, #000000) 3%, transparent);stroke:var(--doc-border, #dde3eb);stroke-width:1;stroke-dasharray:5 4}`,`.${cls} .gr-glabel{font-size:11.5px;fill:var(--doc-fg-3, #5b6271)}`,`.${cls} .gr-box{fill:var(--doc-panel, #ffffff);stroke:var(--doc-border, #dde3eb);stroke-width:1}`,`.${cls} .gr-nlabel{font-size:12.5px;fill:var(--doc-fg, #000000)}`,`.${cls} .gr-e{fill:none;stroke:color-mix(in srgb, var(--doc-fg, #000000) 26%, transparent);stroke-width:1.2}`,`.${cls} .gr-dashed{stroke-dasharray:5 4}`,`.${cls} .gr-elabel{font-size:10.5px;fill:var(--doc-fg-3, #5b6271)}`,`.${cls} .gr-hit{fill:transparent}`,`.${cls} .gr-legend{font-size:10.5px;fill:var(--doc-fg-3, #5b6271)}`];for(let n2 of layout.nodes)rules.push(`.${cls}:has(.gr-h${n2.index}:hover) .gr-e{opacity:0.12}`,`.${cls}:has(.gr-h${n2.index}:hover) .gr-et${n2.index}{opacity:1;stroke:${accent};stroke-width:1.8}`,`.${cls}:has(.gr-h${n2.index}:hover) .gr-b${n2.index}{stroke:${accent}}`);let frames=layout.regions.map(g2=>`<rect class="gr-frame" x="${n1(g2.x)}" y="${n1(g2.y)}" width="${n1(g2.w)}" height="${n1(g2.h)}" rx="14"></rect><text class="gr-glabel" x="${n1(g2.x+4)}" y="${n1(g2.y-7)}">${escapeHtml(g2.label)}</text>`).join(""),edges=layout.edges.map((e2,i3)=>{let marker=e2.kind==="undirected"?"":` marker-end="url(#${arrow})"`,dash=e2.kind==="dashed"?" gr-dashed":"",path4=`<path class="gr-e gr-et${e2.from} gr-et${e2.to}${dash}" data-gr-e="${i3}" d="${e2.d}"${marker}></path>`;return e2.label==null?path4:`${path4}<text class="gr-elabel" x="${n1(e2.labelX??0)}" y="${n1(e2.labelY??0)}" text-anchor="${e2.labelAnchor==="middle"?"middle":"start"}">${escapeHtml(e2.label)}</text>`}).join(""),legend=layout.legendY==null?"":`<text class="gr-legend" x="${GRAPH_LAYOUT_MARGIN}" y="${n1(layout.legendY)}">${escapeHtml(GRAPH_LEGEND)}</text>`,desc=`${b2.graph.nodes.length} nodes, ${b2.graph.edges.length} edges: ${b2.graph.nodes.map(n2=>n2.label).join(", ")}`,svg=[`<svg xmlns="http://www.w3.org/2000/svg" class="${cls}" viewBox="0 0 ${layout.width} ${layout.height}" role="img">`,`<title>${escapeHtml(b2.alt??b2.caption??"graph")}</title>`,`<desc>${escapeHtml(desc)}</desc>`,`<defs><marker id="${arrow}" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" style="fill:context-stroke"></path></marker></defs>`,`<style>${rules.join(`
|
|
519
519
|
`)}</style>`,frames,edges,layout.nodes.map(graphBoxHtml).join(""),legend,"</svg>"].join("");return`<figure class="fig"${b2.alt?` aria-label="${escapeHtml(b2.alt)}"`:""}>${svg}${b2.caption?`<figcaption class="cap">${escapeHtml(b2.caption)}</figcaption>`:""}</figure>`},TERM_ICON='<svg class="term-icon" viewBox="0 0 20 20" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 3h11v14H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Zm-2 12a2 2 0 0 1 2-2h11M7 10l2-5 2 5M8 8h2"/></svg>',termsHtml=(terms,language,sortable=!1)=>{let entries=terms.map((entry,sourceOrder)=>({...entry,sourceOrder})).sort(termComparator(language));return`<section class="terms" aria-label="Terms">${sortable?`<div class="dict-toolbar"><span>${entries.length} terms</span><label>Sort <select data-dict-sort><option value="asc">Name A \u2192 Z</option><option value="desc">Name Z \u2192 A</option><option value="source">Source order</option></select></label></div>`:""}<div class="dict">${entries.map((e2,i3)=>`<fieldset class="dict-card" data-source-order="${e2.sourceOrder}" data-sort-order="${i3}" data-term="${escapeHtml(e2.id)}"><legend id="${termAnchor(e2.id)}">${TERM_ICON}<a class="term-name" href="/_files/terms#${encodeURIComponent(termAnchor(e2.id))}"${e2.description?` aria-describedby="term-description-${encodeURIComponent(e2.id)}"`:""}>${escapeHtml(e2.name)}${e2.description?`<span class="term-description" role="tooltip" id="term-description-${encodeURIComponent(e2.id)}">${escapeHtml(e2.description)}</span>`:""}</a></legend><p class="term-definition">${escapeHtml(e2.definition)}</p></fieldset>`).join("")}</div></section>`},resourceDownloadHtml=(file,href)=>`<a class="resource-download" href="${escapeHtml(href)}" download="${escapeHtml(textfileName(file))}" data-resource-download title="${escapeHtml(`Download ${textfileName(file)}`)}" aria-label="${escapeHtml(`Download ${textfileName(file)}`)}"><svg viewBox="0 0 20 20" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 2v10m-4-4 4 4 4-4M3 13v4h14v-4"/></svg></a>`,subformatTableHtml=(collection,label2)=>`<div class="subformat-table" tabindex="0" role="region" aria-label="${escapeHtml(label2)}"><table><thead><tr><th scope="col" data-i18n="File name">File name</th>${collection.fields.map(field=>`<th scope="col">${escapeHtml(field.title)}</th>`).join("")}</tr></thead><tbody>${collection.records.map((record2,index4)=>`<tr data-record-file="${escapeHtml(record2.file)}"><th scope="row"><button type="button" data-subformat-record="${index4}" aria-haspopup="dialog" title="${escapeHtml(record2.file)}">${escapeHtml(textfileName(record2.file))}</button></th>${collection.fields.map(field=>`<td><span>${Object.hasOwn(record2.data,field.name)?escapeHtml(typeof record2.data[field.name]=="object"?JSON.stringify(record2.data[field.name]):String(record2.data[field.name])):""}</span></td>`).join("")}</tr>`).join("")}</tbody></table></div>${collection.records.length?"":'<p data-i18n="No results">No results</p>'}`,RESOURCE_EXPAND='<button class="resource-download resource-expand" type="button" data-resource-expand title="Expand" aria-label="Expand"><svg viewBox="0 0 20 20" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 8V3h5M17 8V3h-5M3 12v5h5M17 12v5h-5"/></svg></button>',blockHtml=(b2,ctx,seg)=>{let html3=blockContentHtml(b2,ctx,seg);if(!ctx.downloads||b2.type==="code"&&(b2.unavailable||b2.subformat))return html3;let file=b2.sourceFile??(b2.type==="code"?b2.filename:b2.type==="figureRef"?ctx.figures.get(b2.name)?.file:b2.type==="external"?b2.url:void 0);if(!file)return html3;let remote=b2.type==="external"?new URL(file):void 0,href=ctx.downloads.get(file.replace(/^(\.\/)+/,""))??(remote&&/^https?:$/.test(remote.protocol)&&!remote.username&&!remote.password?file:void 0);if(!href)return html3;let link2=resourceDownloadHtml(file,href),copy='<button class="codecopy"';return b2.type==="code"&&html3.includes(copy)?html3.replace(copy,link2+copy):`<div class="downloadable-resource"><div class="resource-download-tools">${RESOURCE_EXPAND}${link2}</div>${html3}</div>`},blockContentHtml=(b2,ctx,seg)=>{switch(b2.type){case"themeVariants":return`<div data-theme-variants><div data-theme-variant="">${blockHtml(b2.default,ctx,seg)}</div>${Object.entries(b2.variants).map(([theme,block])=>`<div data-theme-variant="${escapeHtml(theme)}" hidden>${blockHtml(block,ctx,seg)}</div>`).join("")}</div>`;case"external":{let url=new URL(b2.url);return!/^https?:$/.test(url.protocol)||url.username||url.password?`<p>${escapeHtml(b2.url)}</p>`:`<div class="external-embed" data-embed-url="${escapeHtml(b2.url)}"><a href="${escapeHtml(b2.url)}" target="_blank" rel="noopener noreferrer">${escapeHtml(b2.alt||b2.url)}</a></div>`}case"h":return`<h${b2.level} id="${escapeHtml(b2.slug)}">${segmentsHtml(b2.text,ctx,seg)}${ctx.sectionUrl===void 0?"":`<button class="section-fold" type="button" aria-expanded="true" title="Collapse section" aria-label="Collapse section" data-i18n-title="Collapse section" data-i18n-aria-label="Collapse section"><svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m4 6 4 4 4-4"/></svg></button><button class="section-copy" type="button" data-section-url="${escapeHtml(ctx.sectionUrl)}#${encodeURIComponent(b2.slug)}" title="Copy section URL" aria-label="Copy section URL" data-i18n-title="Copy section URL" data-i18n-aria-label="Copy section URL"><svg viewBox="0 0 20 20" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"><path d="m8 12 4-4m-5 2-2 2a3 3 0 0 0 4 4l2-2m-2-8 2-2a3 3 0 0 1 4 4l-2 2"/></svg>${CHECK_ICON}</button>`}</h${b2.level}>`;case"p":return`<p>${segmentsHtml(b2.text,ctx,seg)}</p>`;case"quote":return`<blockquote>${b2.blocks.map(block=>blockHtml(block,ctx,seg)).join(`
|
|
520
|
-
`)}</blockquote>`;case"list":return listHtml(b2.items,ctx,seg,b2.ordered===!0);case"code":{if(b2.subformat){let label2=b2.embed?.title??b2.alt??b2.subformat.ext,fields=b2.embed?.fields?.flatMap(name=>b2.subformat?.fields.filter(field=>field.name===name)??[])??b2.subformat.fields,previews=b2.subformat.resource?`<template data-format-previews>${b2.subformat.records.map(record2=>`<div data-format-preview="${escapeHtml(JSON.stringify(record2.data))}">${blocksHtml(record2.preview??[],ctx)}</div>`).join("")}</template>`:"",collection=b2.subformat.resource?{...b2.subformat,records:b2.subformat.records.map(({preview,...record2})=>record2)}:b2.subformat;return`<section class="subformat-embed${b2.subformat.resource?" format-collection":""}"${b2.subformat.resource?" data-format-collection":""} data-subformat-embed="${escapeHtml(b2.subformat.ext)}" data-subformat-embed-view="${escapeHtml(b2.embed?.view??"card")}" data-subformat-embed-options="${escapeHtml(JSON.stringify(b2.embed??{}))}" aria-label="${escapeHtml(label2)}">${b2.embed?.title?`<h2 class="subformat-embed-title">${escapeHtml(b2.embed.title)}</h2>`:""}<div class="subformat-embed-toolbar"><button type="button" class="pbtn subformat-search-toggle" data-subformat-search aria-expanded="false" aria-label="Search records" title="Search records" data-i18n-aria-label="Search records" data-i18n-title="Search records"><svg width="16" height="16" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="${SEARCH_ICON_PATH}"/></svg></button><label class="resource-search" hidden><input type="search" data-resource-search placeholder="Search records" aria-label="Search records" data-i18n-placeholder="Search records" data-i18n-aria-label="Search records"></label><span class="resource-count" data-resource-count role="status" aria-live="polite">${b2.subformat.records.length}</span></div><template data-subformats>${escapeHtml(JSON.stringify([collection]))}</template>${previews}<div data-subformat-board tabindex="0" role="region" aria-label="${escapeHtml(label2)}">${subformatTableHtml({...b2.subformat,fields},label2)}</div></section>`}if(b2.lang==="mermaid"&&!b2.unavailable)return`<pre data-mermaid="pending" aria-label="${escapeHtml(b2.alt||"Mermaid diagram")}" style="overflow:auto;background:var(--doc-bg);color:var(--doc-fg);padding:1rem">${escapeHtml(b2.lines.join(`
|
|
520
|
+
`)}</blockquote>`;case"list":return listHtml(b2.items,ctx,seg,b2.ordered===!0);case"code":{if(b2.subformat){let label2=b2.embed?.title??b2.alt??b2.subformat.ext,fields=b2.embed?.fields?.flatMap(name=>b2.subformat?.fields.filter(field=>field.name===name)??[])??b2.subformat.fields,previews=b2.subformat.resource?`<template data-format-previews>${b2.subformat.records.map(record2=>`<div data-format-preview="${escapeHtml(JSON.stringify(record2.data))}">${blocksHtml(record2.preview??[],ctx)}<a class="resource-source" href="/_files/file/${encodeURIComponent(record2.file)}">${escapeHtml(record2.file)}</a></div>`).join("")}</template>`:"",collection=b2.subformat.resource?{...b2.subformat,records:b2.subformat.records.map(({preview,...record2})=>record2)}:b2.subformat;return`<section class="subformat-embed${b2.subformat.resource?" format-collection":""}"${b2.subformat.resource?" data-format-collection":""} data-subformat-embed="${escapeHtml(b2.subformat.ext)}" data-subformat-embed-view="${escapeHtml(b2.embed?.view??"card")}" data-subformat-embed-options="${escapeHtml(JSON.stringify(b2.embed??{}))}" aria-label="${escapeHtml(label2)}">${b2.embed?.title?`<h2 class="subformat-embed-title">${escapeHtml(b2.embed.title)}</h2>`:""}<div class="subformat-embed-toolbar"><button type="button" class="pbtn subformat-search-toggle" data-subformat-search aria-expanded="false" aria-label="Search records" title="Search records" data-i18n-aria-label="Search records" data-i18n-title="Search records"><svg width="16" height="16" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="${SEARCH_ICON_PATH}"/></svg></button><label class="resource-search" hidden><input type="search" data-resource-search placeholder="Search records" aria-label="Search records" data-i18n-placeholder="Search records" data-i18n-aria-label="Search records"></label><span class="resource-count" data-resource-count role="status" aria-live="polite">${b2.subformat.records.length}</span></div><template data-subformats>${escapeHtml(JSON.stringify([collection]))}</template>${previews}<div data-subformat-board tabindex="0" role="region" aria-label="${escapeHtml(label2)}">${subformatTableHtml({...b2.subformat,fields},label2)}</div></section>`}if(b2.lang==="mermaid"&&!b2.unavailable)return`<pre data-mermaid="pending" aria-label="${escapeHtml(b2.alt||"Mermaid diagram")}" style="overflow:auto;background:var(--doc-bg);color:var(--doc-fg);padding:1rem">${escapeHtml(b2.lines.join(`
|
|
521
521
|
`))}</pre>`;let filename=b2.filename?textfileName(b2.filename):"",lang=b2.filename?/^.+(\.[^.]+)$/.exec(filename)?.[1]:b2.lang??"text",langLabel=lang?`<span class="codeblk-lang">${escapeHtml(lang)}</span>`:"",filenameLabel=filename?`<span class="codeblk-filename">${escapeHtml(filename)}</span>`:"",title=b2.filename?` title="${escapeHtml(`${b2.filename}${b2.range??""}`)}"${b2.alt?` role="region" aria-label="${escapeHtml(b2.alt)}"`:""}`:"";if(b2.filename&&b2.unavailable){let message=b2.unavailable==="missing"?"File not found":"File could not be loaded";return`<div class="codeblk textfile unavailable"${title}><span class="codeblk-head">${langLabel}${filenameLabel}</span><p class="textfile-unavailable" role="status">${b2.alt?`${escapeHtml(b2.alt)} \u2014 `:""}<span data-i18n="${message}">${message}</span></p></div>`}return`<div class="codeblk${b2.filename?" textfile":""}" data-lang="${escapeHtml(b2.lang??"text")}"${title}><span class="codeblk-head">${langLabel}${filenameLabel}<button class="codecopy" type="button" title="copy" aria-label="copy code"><svg class="ic-copy" viewBox="0 0 24 24" width="14" height="14" aria-hidden="true"><path fill="currentColor" d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>${CHECK_ICON}</button><button class="codefold" type="button" aria-expanded="true" aria-label="Collapse code" title="Collapse code" data-i18n-aria-label="Collapse code" data-i18n-title="Collapse code"><svg viewBox="0 0 20 20" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m5 7.5 5 5 5-5"/></svg></button></span><pre><code>${escapeHtml(b2.lines.join(`
|
|
522
522
|
`))}</code></pre></div>`}case"table":return tableHtml(b2,ctx,seg);case"callout":{let title=b2.title?`<div class="callout-title">${escapeHtml(b2.title)}</div>`:"",body=b2.body.map(it2=>it2.type==="p"?`<p>${segmentsHtml(it2.text,ctx,seg)}</p>`:listHtml(it2.items,ctx,seg,it2.ordered===!0)).join("");return`<aside class="callout"${b2.alt?` aria-label="${escapeHtml(b2.alt)}"`:""}>${title}<div class="callout-body">${body}</div></aside>`}case"figureRef":{let fig=ctx.figures.get(b2.name);return fig?b2.alt!==void 0?`<figure class="fig">${(ctx.figurePreview??figureFrameHtml)(fig,"fig-frame",b2.alt)}</figure>`:figureHtml(fig,ctx,!0,b2.caption):`<div class="ph">${escapeHtml(b2.alt||`Fig. ${b2.name}`)}<span> \u2014 not found in figures/</span></div>`}case"term":return termsHtml([b2.entry],ctx.language);case"figures":return[...ctx.figures.values()].map(f2=>`<h2 id="${escapeHtml(f2.name)}">${escapeHtml(f2.title??f2.name)}</h2>${figureHtml(f2,ctx,!1)}`).join(`
|
|
523
523
|
`);case"schemaGraph":return schemaGraphHtml(b2);case"graph":return graphHtml(b2);default:return`<div class="ph">${escapeHtml(`Unknown block (${b2.type})`)}<span> \u2014 docs reader needs an update</span></div>`}},blocksHtml=(blocks,ctx=emptyCtx)=>{let seg=inlineSegmenter({terms:ctx.terms});return blocks.map(b2=>blockHtml(b2,ctx,seg)).filter(h2=>h2!=="").join(`
|
|
@@ -832,7 +832,7 @@ body.edit:has(#preview-panes:not(.split) .preview-pane.active .git-page) #panel
|
|
|
832
832
|
--doc-fg-4:#9099a8; --doc-accent-2:#0277bd; --doc-accent-fg:#ffffff;
|
|
833
833
|
--doc-ok-2:#2ea043; --doc-warn-2:#f59f00; --doc-danger-2:#f04848; --doc-info-2:#4a8bff;`,initializeThemes=(themes=["light","dark"])=>{let root4=document.documentElement,read=key=>{try{let value2=localStorage.getItem(key);return value2==="light"||value2==="dark"?value2:"auto"}catch{return"auto"}},stored=read("docs-preview:theme");root4.dataset.theme=themes.length===1?themes[0]??"auto":themes.includes(stored)?stored:"auto",root4.dataset.editorTheme=read("docs-editor:theme")},mountThemePickers=(icons,themes=["light","dark"])=>{let root4=document.documentElement,documentChoices=themes.length===1?themes:["auto",...themes],documentDefault=root4.dataset.theme??"auto";documentChoices.includes(documentDefault)||(documentDefault=documentChoices[0]??"auto"),root4.dataset.theme=documentDefault,root4.dataset.editorTheme??="auto";let t4=key=>window.__docsTranslate?.(key)??key,popup=document.createElement("div");popup.className="theme-picker",popup.id="theme-picker",popup.popover="auto",popup.setAttribute("role","menu"),document.body.append(popup);let trigger,target=button=>button.dataset.themePicker==="editor"?root4:button.closest(".preview-pane")??root4,current=button=>button.dataset.themePicker==="editor"?root4.dataset.editorTheme??"auto":target(button).dataset.theme??"auto",previewThemes=new WeakMap,sync=()=>{for(let pane of document.querySelectorAll(".preview-pane"))pane.classList.contains("resources-pane")?previewThemes.has(pane)||previewThemes.set(pane,pane.dataset.theme??documentDefault):previewThemes.has(pane)&&(pane.dataset.theme=previewThemes.get(pane),previewThemes.delete(pane));for(let pane of document.querySelectorAll(".resources-pane, #sidebar, #panel")){let theme=pane.id==="sidebar"&&!document.body.classList.contains("edit")?root4.dataset.theme:root4.dataset.editorTheme;pane.dataset.theme!==theme&&(pane.dataset.theme=theme)}for(let pane of document.querySelectorAll(".preview-pane:not(.resources-pane)"))documentChoices.includes(pane.dataset.theme??"")||(pane.dataset.theme=documentDefault);for(let button of document.querySelectorAll("[data-theme-picker]")){let value2=current(button),markup=icons[value2==="auto"?"":value2]??"",valueLabel=button.querySelector("[data-picker-value]");if(button.dataset.themeIcon!==value2){let icon=valueLabel?button.closest(".editor-setting")?.querySelector("[data-setting-theme-icon]"):button;icon&&(icon.innerHTML=markup),button.dataset.themeIcon=value2}let name=t4(value2==="auto"?"Auto":value2==="light"?"Light":"Dark");valueLabel&&valueLabel.textContent!==name&&(valueLabel.textContent=name);let label2=t4(button.dataset.themePicker==="editor"?"Editor theme":"Preview theme");button.title=`${label2}: ${name}`,button.setAttribute("aria-label",button.title),button.setAttribute("aria-haspopup","menu"),button.setAttribute("aria-controls",popup.id)}};document.addEventListener("click",event=>{let button=event.target instanceof Element?event.target.closest("[data-theme-picker]"):null;if(!button)return;if(trigger===button&&popup.matches(":popover-open")){popup.hidePopover();return}popup.matches(":popover-open")&&popup.hidePopover(),trigger=button,popup.dataset.theme=current(button),popup.replaceChildren();for(let value2 of button.dataset.themePicker==="editor"?["auto","light","dark"]:documentChoices){let option=document.createElement("button");option.type="button",option.dataset.value=value2,option.setAttribute("role","menuitemradio"),option.setAttribute("aria-checked",String(value2===current(button))),option.innerHTML=icons[value2==="auto"?"":value2]??"",option.append(document.createTextNode(t4(value2==="auto"?"Auto":value2==="light"?"Light":"Dark"))),popup.append(option)}let rect=button.getBoundingClientRect();popup.style.left=`${Math.max(8,Math.min(rect.left,innerWidth-156))}px`,popup.style.top=`${Math.min(rect.bottom+6,innerHeight-140)}px`,popup.showPopover(),button.setAttribute("aria-expanded","true"),popup.querySelector('[aria-checked="true"]')?.focus()}),popup.addEventListener("click",event=>{let option=event.target instanceof Element?event.target.closest("[data-value]"):null;if(!option||!trigger)return;let value2=option.dataset.value??"auto",editor=trigger.dataset.themePicker==="editor";editor?root4.dataset.editorTheme=value2:(target(trigger).dataset.theme=value2,documentDefault=value2);try{localStorage.setItem(editor?"docs-editor:theme":"docs-preview:theme",value2)}catch{}popup.hidePopover(),trigger.focus(),sync()}),popup.addEventListener("keydown",event=>{let options2=[...popup.querySelectorAll("button")],index4=options2.indexOf(document.activeElement);(event.key==="ArrowDown"||event.key==="ArrowUp")&&(event.preventDefault(),options2[(index4+(event.key==="ArrowDown"?1:options2.length-1))%options2.length]?.focus()),event.key==="Escape"&&trigger?.focus()}),popup.addEventListener("toggle",()=>{popup.matches(":popover-open")||trigger?.setAttribute("aria-expanded","false")}),document.addEventListener("docs:ui-language",sync),new MutationObserver(sync).observe(root4,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-theme","data-editor-theme"]}),sync()};init_browser_globals();function mountToc(doc){let owner=doc;owner.__docsTocDispose?.();let controller=new AbortController,mounted=new Map,sequence=0,frame=0,schedule=()=>{frame||(frame=requestAnimationFrame(()=>{frame=0;for(let{update}of mounted.values())update()}))},resize=new ResizeObserver(schedule),initialize2=()=>{for(let[toolbar,{article,dispose:dispose2}]of mounted)(!toolbar.isConnected||!article.isConnected)&&(dispose2(),resize.unobserve(article),mounted.delete(toolbar));for(let toolbar of doc.querySelectorAll("article > .doc-title")){if(mounted.has(toolbar))continue;let article=toolbar.closest("article");if(!article)continue;let pane=toolbar.closest(".preview-pane"),scroller=pane??toolbar.closest("main")??doc.scrollingElement,header=(pane??article.parentElement)?.querySelector(":scope > .pane-actions, :scope > .page-actions"),listeners=new AbortController,options2={signal:listeners.signal},controls=header?doc.createElement("div"):toolbar;header&&(controls.className="page-controls",controls.append(...toolbar.childNodes),header.prepend(controls));let state={article,update:()=>{},dispose:()=>{listeners.abort(),controls!==toolbar&&(toolbar.append(...controls.childNodes),controls.remove())}};mounted.set(toolbar,state);let nav=controls.querySelector(".in-toc"),button=nav?.querySelector(".toc-current"),list5=nav?.querySelector("ul");if(!nav||!button||!list5||!scroller)continue;list5.id=`toc-options-${++sequence}`,button.setAttribute("aria-controls",list5.id);let sections=[...nav.querySelectorAll("[data-toc-target]")].map(link2=>({link:link2,heading:article.querySelector(`#${CSS.escape(link2.dataset.tocTarget??"")}`)})).filter(section=>section.heading!==null),active,update=()=>{let top=(header?.getBoundingClientRect().bottom??pane?.getBoundingClientRect().top??0)+20,current=sections[0];for(let section of sections)!section.heading?.closest("[data-section-hidden]")&&(section.heading?.getBoundingClientRect().top??1/0)<=top&&(current=section);scroller.scrollTop>0&&scroller.scrollTop>=scroller.scrollHeight-scroller.clientHeight-1&&(current=sections.findLast(section=>!section.heading?.closest("[data-section-hidden]"))),current?.link!==active&&(active?.removeAttribute("aria-current"),active=current?.link,active&&(active.setAttribute("aria-current","location"),button.textContent=button.title=active.textContent??""))};button.addEventListener("click",()=>{if(list5.matches(":popover-open")){list5.hidePopover();return}let rect=button.getBoundingClientRect(),width=Math.min(240,innerWidth-16);list5.style.width=`${width}px`,list5.style.left=`${Math.max(8,Math.min(rect.left,innerWidth-width-8))}px`,list5.style.top=`${rect.bottom+6}px`,list5.showPopover(),list5.scrollTop=Math.max(0,(active?.offsetTop??0)-list5.clientHeight/2),active?.focus({preventScroll:!0})},options2),list5.addEventListener("toggle",()=>{button.setAttribute("aria-expanded",String(list5.matches(":popover-open")))},options2),list5.addEventListener("keydown",event=>{let index4=sections.findIndex(({link:link2})=>link2===doc.activeElement);if(["ArrowDown","ArrowUp","Home","End"].includes(event.key)){event.preventDefault();let next=event.key==="Home"?0:event.key==="End"?sections.length-1:(index4+(event.key==="ArrowDown"?1:sections.length-1))%sections.length;sections[next]?.link.focus()}event.key==="Escape"&&button.focus({preventScroll:!0})},options2),list5.addEventListener("click",event=>{if(event.button!==0||event.metaKey||event.ctrlKey||event.shiftKey||event.altKey)return;let link2=event.target.closest("[data-toc-target]"),heading2=sections.find(section=>section.link===link2)?.heading;heading2&&(list5.hidePopover(),button.focus({preventScroll:!0}),heading2.dispatchEvent(new Event("docs:reveal-section",{bubbles:!0})),pane&&(event.preventDefault(),heading2.scrollIntoView({block:"start"})))},options2),state.update=update,resize.observe(article)}schedule()},observer=new MutationObserver(initialize2);observer.observe(doc.documentElement,{childList:!0,subtree:!0}),doc.addEventListener("scroll",schedule,{capture:!0,passive:!0,signal:controller.signal}),doc.addEventListener("load",schedule,{capture:!0,signal:controller.signal}),doc.addEventListener("docs:font-change",schedule,{signal:controller.signal}),window.addEventListener("resize",schedule,{signal:controller.signal}),initialize2();let dispose=()=>{controller.abort(),observer.disconnect(),resize.disconnect(),cancelAnimationFrame(frame);for(let{dispose:dispose2}of mounted.values())dispose2();mounted.clear()};return owner.__docsTocDispose=dispose,dispose}init_browser_globals();function mountVideos(doc){let mobile=window.matchMedia("(max-width: 600px)"),mounted=new WeakMap,nextSettingsId=0,activeOptions,closeOptions=()=>{activeOptions?.matches(":popover-open")&&activeOptions.hidePopover()},label2=key=>window.__docsTranslate?.(key)??key,name=(element,key)=>{element.dataset.i18nAriaLabel=key,element.dataset.i18nTitle=key,element.setAttribute("aria-label",label2(key)),element.title=label2(key)},icon=path4=>`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${path4}</svg>`,playIcon=icon('<path d="m8 5 11 7-11 7Z"/>'),pauseIcon=icon('<path d="M8 5v14M16 5v14"/>'),soundIcon=icon('<path d="m11 5-6 4H2v6h3l6 4ZM15 8a6 6 0 0 1 0 8m3-11a10 10 0 0 1 0 14"/>'),muteIcon=icon('<path d="m11 5-6 4H2v6h3l6 4Zm5 4 6 6m0-6-6 6"/>'),clock=value2=>{let seconds=Math.floor(Number.isFinite(value2)?Math.max(0,value2):0),minutes=Math.floor(seconds/60);return`${minutes>=60?`${Math.floor(minutes/60)}:`:""}${minutes>=60?String(minutes%60).padStart(2,"0"):minutes}:${String(seconds%60).padStart(2,"0")}`},initialize2=()=>{for(let video2 of doc.querySelectorAll("video[data-dooc-video]")){if(mounted.has(video2)||video2.closest("a")||video2.closest(".format-list-preview")&&!video2.closest(".resource-modal"))continue;video2.parentElement?.classList.contains("video-player")&&video2.parentElement.replaceWith(video2);let player=doc.createElement("div");player.className="video-player",video2.before(player),player.append(video2);let bar=doc.createElement("div");bar.className="video-controls";let button=(key,markup)=>{let element=doc.createElement("button");return element.type="button",name(element,key),element.innerHTML=markup,element},play=button("Play",playIcon),seek=doc.createElement("input");seek.type="range",seek.min="0",seek.max="0",seek.step="0.1",seek.value="0",seek.className="video-seek",name(seek,"Seek");let time=doc.createElement("span");time.className="video-time";let mute=button("Mute",soundIcon),volume=doc.createElement("input");volume.type="range",volume.min="0",volume.max="1",volume.step="0.05",volume.className="video-volume",name(volume,"Volume");let settings=button("Video settings",icon('<path d="M4 7h2m6 0h8M4 17h8m6 0h2"/><circle cx="9" cy="7" r="3"/><circle cx="15" cy="17" r="3"/>'));settings.setAttribute("aria-expanded","false");let options2=doc.createElement("div");options2.className="video-settings",options2.id=`video-settings-${++nextSettingsId}`,options2.popover="auto",options2.setAttribute("role","dialog"),name(options2,"Video settings"),settings.setAttribute("aria-haspopup","dialog"),settings.setAttribute("aria-controls",options2.id);let speedLabel=doc.createElement("label"),speedText=doc.createElement("span");speedText.dataset.i18n="Playback speed",speedText.textContent=label2("Playback speed");let speed=doc.createElement("input");speed.type="range",speed.min="1",speed.max="5",speed.step="0.25",speed.className="video-speed",name(speed,"Playback speed");let speedValue=doc.createElement("span");speedValue.className="video-speed-value",speedLabel.append(speedText,speedValue,speed),options2.append(speedLabel);let fullscreen=button("Fullscreen",icon('<path d="M9 3H3v6m12-6h6v6M3 15v6h6m12-6v6h-6"/>'));fullscreen.hidden=!doc.fullscreenEnabled||!!video2.closest(".format-card");let status2=doc.createElement("p");status2.className="video-status",status2.setAttribute("role","status"),status2.hidden=!0;let fail=key=>{status2.dataset.i18n=key,status2.textContent=label2(key),status2.hidden=!1},sync=()=>{let overlay=mobile.matches&&!video2.closest(".format-card")||!!doc.fullscreenElement?.contains(video2);video2.controls=overlay,bar.hidden=overlay,overlay&&options2.matches(":popover-open")&&(options2.hidePopover(),settings.setAttribute("aria-expanded","false"));let paused=video2.paused||video2.ended;name(play,paused?"Play":"Pause"),play.dataset.paused!==String(paused)&&(play.innerHTML=paused?playIcon:pauseIcon,play.dataset.paused=String(paused));let duration=Number.isFinite(video2.duration)?video2.duration:0;seek.disabled=duration<=0||!!video2.error,play.disabled=!!video2.error,seek.max=String(duration),seek.value=String(video2.currentTime),seek.style.setProperty("--video-progress",`${duration>0?Math.min(100,video2.currentTime/duration*100):0}%`),seek.setAttribute("aria-valuetext",`${clock(video2.currentTime)} / ${clock(duration)}`),time.textContent=`${clock(video2.currentTime)} / ${clock(duration)}`;let silent=video2.muted||video2.volume===0;name(mute,silent?"Unmute":"Mute"),mute.dataset.muted!==String(silent)&&(mute.innerHTML=silent?muteIcon:soundIcon,mute.dataset.muted=String(silent)),volume.value=String(video2.muted?0:video2.volume),volume.style.setProperty("--video-progress",`${Number(volume.value)*100}%`),volume.setAttribute("aria-valuetext",`${Math.round(Number(volume.value)*100)}%`),speed.value=String(video2.playbackRate),speed.style.setProperty("--video-progress",`${(Number(speed.value)-1)/4*100}%`),speed.setAttribute("aria-valuetext",`${video2.playbackRate}\xD7`),speedValue.textContent=`${video2.playbackRate}\xD7`};play.addEventListener("click",async()=>{if(!video2.paused&&!video2.ended)video2.pause();else{status2.hidden=!0;try{await video2.play()}catch{fail("Video could not be played")}}}),seek.addEventListener("input",()=>{video2.currentTime=Number(seek.value),sync()}),mute.addEventListener("click",()=>{video2.muted||video2.volume===0?(video2.muted=!1,video2.volume===0&&(video2.volume=1)):video2.muted=!0,sync()}),volume.addEventListener("input",()=>{video2.volume=Number(volume.value),video2.muted=video2.volume===0,sync()}),settings.addEventListener("click",()=>{if(options2.matches(":popover-open")){options2.hidePopover();return}options2.showPopover(),activeOptions=options2;let rect=settings.getBoundingClientRect();options2.style.left=`${Math.max(8,Math.min(rect.right-options2.offsetWidth,window.innerWidth-options2.offsetWidth-8))}px`,options2.style.top=`${Math.max(8,Math.min(rect.bottom+6,window.innerHeight-options2.offsetHeight-8))}px`,settings.setAttribute("aria-expanded","true"),speed.focus({preventScroll:!0})}),options2.addEventListener("toggle",()=>{let open2=options2.matches(":popover-open");settings.setAttribute("aria-expanded",String(open2)),!open2&&activeOptions===options2&&(activeOptions=void 0)}),options2.addEventListener("keydown",event=>{event.key==="Escape"&&(event.preventDefault(),options2.hidePopover(),settings.setAttribute("aria-expanded","false"),settings.focus())}),speed.addEventListener("input",()=>{video2.playbackRate=Number(speed.value),sync()}),fullscreen.addEventListener("click",async()=>{video2.controls=!0;try{await video2.requestFullscreen()}catch{fail("Fullscreen is unavailable")}sync()});for(let type of["loadedmetadata","durationchange","timeupdate","play","pause","ended","volumechange","ratechange","emptied"])video2.addEventListener(type,sync);video2.addEventListener("error",()=>{fail("Video could not be played"),sync()}),bar.append(play,seek,time,mute,volume,settings,fullscreen),player.append(bar,options2,status2),mounted.set(video2,sync),sync(),video2.error&&fail("Video could not be played")}},syncAll=()=>{for(let video2 of doc.querySelectorAll("video[data-dooc-video]"))mounted.get(video2)?.()};mobile.addEventListener("change",syncAll),window.addEventListener("resize",closeOptions),doc.addEventListener("scroll",event=>{event.target instanceof Node&&!activeOptions?.contains(event.target)&&closeOptions()},!0),doc.addEventListener("fullscreenchange",syncAll),doc.addEventListener("docs:ui-language",syncAll),new MutationObserver(records=>{records.some(record2=>[...record2.addedNodes].some(node2=>node2 instanceof Element&&(node2.matches("video[data-dooc-video]")||node2.querySelector("video[data-dooc-video]"))))&&initialize2()}).observe(doc.documentElement,{childList:!0,subtree:!0}),initialize2()}var DEFAULT_SITE_LANGUAGES={languages:[ja]},createDocumentApplication=(root4,host)=>{let historicalReadOnly=!1,{fontCss,readWorkspaceSource,sourceFileBase,gitBaseBody,gitBaseText,setSubformatChanges,runCodeTool:runCodeTool2,validateCodeTools:validateCodeTools2,validateTextfileCode:validateTextfileCode2}=host,CONTENT_PREFIX="content/",toEntry=(doc,source2)=>({id:doc.id,url:doc.url,root:doc.root,name:doc.name,origin:doc.origin,included:doc.included,...doc.subformat?{subformat:doc.subformat}:{},...doc.library?{library:doc.library}:{},...doc.format?{format:doc.format}:{},...doc.parent==null?{}:{parent:doc.parent},file:`${doc.id}.md`,sourceFile:doc.file,frontmatter:source2.frontmatter,lang:doc.lang,body:doc.body,blocks:doc.blocks,toc:doc.toc,blockLines:source2.lines,raw:source2.raw,errors:source2.errors,...doc.icon==null?{}:{icon:doc.icon},figureRefs:doc.refs.figures,termRefs:doc.refs.terms,terms:source2.terms,referencedFiles:source2.referencedFiles}),siteLanguages=DEFAULT_SITE_LANGUAGES,compiler2=createCompiler(root4),ops=createDocOps(root4),siteFrom=({title,icon:icon2,iconVariants,docs,terms,figures,sources:sources3,siteErrors,defaultLang,previews,contentLanguages:contentLanguages2,themes,subformats},languages=DEFAULT_SITE_LANGUAGES.languages,code4={})=>{let entries=docs.flatMap(doc=>{let source2=sources3.get(doc.file);return source2?[toEntry(doc,source2)]:[]});if(!entries.some(entry=>entry.root)){let id="document-root";for(;entries.some(entry=>entry.id===id);)id+="-root";for(let entry of entries)entry.parent??=id;entries.unshift({id,root:!0,url:"",file:"",frontmatter:{title:title??"Contents"},lang:defaultLang,body:"",blocks:[],toc:[],blockLines:[],raw:"",errors:[]})}return{previews,subformats,codeLanguages:[...new Set([...code4.codeLanguages??CODE_LANGS,...(subformats??[]).map(({ext})=>`.${ext}`)])],codeGrammars:subformatCodeGrammars(code4.codeGrammars??[],subformats),...contentLanguages2?{contentLanguages:contentLanguages2}:{},...themes?{themes}:{},...title===void 0?{}:{title},...icon2===void 0?{}:{icon:icon2},...iconVariants===void 0?{}:{iconVariants},entries,ctx:{docLinks:new Map(docs.filter(isContentPage).map(doc=>[doc.file,docHref(docs,doc.id)])),figures:new Map(figures.map(f2=>[f2.name,f2])),terms,termLinks:new Map([...terms.map(term=>[term.id,`/_files/terms#${encodeURIComponent(termAnchor(term.id))}`]),...docs.flatMap(doc=>doc.blocks.flatMap(block=>block.type==="term"?[[block.entry.id,`/${doc.id}#${encodeURIComponent(termAnchor(block.entry.id))}`]]:[]))])},errors:siteErrors,languages,defaultLang}},localeCompilers=new Map,sharedBranch,editDownloads=!1,workspaceSource,applicationPreviews=defaultPreviewSettings(),watchTextfiles,watchEntryTextfiles=entries=>{watchTextfiles?.(entries.flatMap(entry=>[...entry.origin?[entry.origin]:[],...isContentPage(entry)?[entry.sourceFile??CONTENT_PREFIX+entry.file]:[],...entry.referencedFiles??[]]))},loadSite=(locale,route,mode="preview")=>withIgnoredFilesCache(()=>{let previews=applicationPreviews,manifest2=readManifest(root4),source2=contentLanguageCode(manifest2.defaultLang??DEFAULT_LANG);locale??=source2;let selected=compiler2;locale!==source2&&(selected=localeCompilers.get(locale)??createCompiler(root4,{locale,previews}),localeCompilers.set(locale,selected));let nodes=flattenTree(manifest2.tree),currentId=resolveDocPath(nodes,route??"/"),current=nodes.find(node2=>node2.id===currentId),documentIds=route!==void 0&&!route.startsWith("/_")&&!current?.subformat&&!current?.library&&!current?.format?new Set(current?[current.id]:[]):void 0;if(documentIds&&mode==="edit"&&(!current||!isContentPage(current))){let editor=nodes.find(isContentPage);editor&&documentIds.add(editor.id)}let site=siteFrom(selected.compile(documentIds),siteLanguages.languages,siteLanguages),sourceLanguage=contentLanguageCode(site.defaultLang);for(let entry of site.entries)entry.translatedLanguages=[sourceLanguage],entry.iconFile=docIconFile(entry.id,manifest2.files);try{let translated=new Set(translationFiles(root4));for(let language of siteContentLanguages(root4,manifest2).filter(language2=>language2!==sourceLanguage))for(let entry of site.entries)isContentPage(entry)&&translated.has(translationFile(docFile(entry.id,manifest2.files),language,entry.origin))&&entry.translatedLanguages?.push(language)}catch(error){site.errors.push(String(error))}watchEntryTextfiles(site.entries),watchTextfiles?.([manifest2.icon,...Object.values(manifest2.themeIcons??{})].filter(file=>!!file));let workspace=workspaceSource??readWorkspaceSource(root4),subformats=site.entries.flatMap(entry=>entry.subformat?[entry.subformat]:[]),snapshot=manifest2.errors.length?void 0:filesSnapshot(root4);return!documentIds&&workspace?.protocol==="git"&&subformats.length&&setSubformatChanges(root4,subformats,snapshot?.revision),{...site,ctx:{...site.ctx,figurePreview:deferredFigureHtml,...editDownloads?{downloads:new Map((snapshot?.files??[]).map(({path:path4})=>[path4,`/api/download?file=${encodeURIComponent(path4)}`]))}:{}},fonts:loadProjectFonts(root4),workspace,sourceBase:sourceFileBase(root4),filePaths:snapshot?.files.map(file=>file.path),contentLanguage:locale}}),loadNavigation=(locale,currentId)=>withIgnoredFilesCache(()=>{let manifest2=readManifest(root4),title=manifest2.titles?.[locale]??manifest2.title,nodes=flattenTree(manifest2.tree),{icons}=loadIcons(root4,new Set(nodes.map(({id})=>id)),manifest2.icon,manifest2.files),entries=nodes.map(node2=>{let format5=manifest2.subformats?.find(({ext})=>ext===node2.subformat),iconSvg;if(format5)try{iconSvg=subformatIconSvg(root4,format5)}catch{}return{...node2,included:!!node2.resolved,file:`${node2.id}.md`,sourceFile:isContentPage(node2)?docFile(node2.id,manifest2.files):void 0,frontmatter:{title:node2.title??node2.library??node2.format??node2.subformat??(isContentPage(node2)?(docFile(node2.id,manifest2.files).split("/").pop()??node2.id).replace(/\.md$/i,""):(node2.root?title:node2.name)??"Contents")},icon:icons.get(node2.id),subformat:format5?{...format5,fields:[],records:[],iconSvg}:void 0}});if(!entries.some(entry=>entry.root)){let id="document-root";for(;entries.some(entry=>entry.id===id);)id+="-root";for(let entry of entries)entry.parent??=id;entries.unshift({id,root:!0,url:"",file:"",frontmatter:{title:title??"Contents"}})}let current=entries.find(({id})=>id===currentId);if(current){let source2=contentLanguageCode(manifest2.defaultLang??DEFAULT_LANG),translated=new Set(translationFiles(root4));current.translatedLanguages=[source2,...siteContentLanguages(root4,manifest2).filter(language=>language!==source2&&isContentPage(current)&&translated.has(translationFile(docFile(current.id,manifest2.files),language,current.origin)))]}let icon2;if(manifest2.icon)try{icon2=squareSvg(readTextfile(root4,manifest2.icon))}catch{}return{entries,title,icon:icon2,subformats:manifest2.subformats,contentLanguage:locale,themes:manifest2.themes,workspace:workspaceSource??readWorkspaceSource(root4)}}),draftContext=site=>({previews:site.previews,root:root4,docs:site.entries.filter(isContentPage).map(e2=>({id:e2.id,url:e2.url,root:e2.root,name:e2.name,origin:e2.origin,...e2.parent==null?{}:{parent:e2.parent},file:e2.sourceFile??CONTENT_PREFIX+e2.file,toc:e2.toc,...e2.frontmatter?{title:e2.frontmatter.title}:{}})),figures:site.ctx.figures,defaultLang:site.defaultLang}),isLinkedEntry=entry=>!!entry.included||!!(entry.url&&["link","redirect"].includes(pageUrlKind(entry.url))),docLinks=(site,html3)=>html3.replace(/href="\/([a-z0-9][a-z0-9-]*)(?=["?#])/g,(whole,id)=>{let entry=site.entries.find(entry2=>entry2.id===id);if(!entry)return whole;let jump=docHref(site.entries,id);return`${isLinkedEntry(entry)?"data-document-link ":""}${/^https?:\/\//i.test(jump)?`data-jump-url="${escapeHtml(jump)}" `:""}href="${escapeHtml(docHref(site.entries,id,!0))}`}),pageDownload=(site,entry)=>{let file=entry.sourceFile??CONTENT_PREFIX+entry.file,href=site.ctx.downloads?.get(file);return href?{pageDownload:{file,href}}:{}},renderEntry=(site,entry,fallbackTitle)=>docLinks(site,docHtml(entry.frontmatter??{title:fallbackTitle},entry.blocks,[...site.errors,...entry.errors],{...site.ctx,...pageDownload(site,entry),terms:entry.terms??site.ctx.terms,lang:webLanguage(entry.lang),tocTitle:translate(entry.lang,"Contents"),sectionUrl:`${docPath(site.entries,entry.id)}?lang=${encodeURIComponent(site.contentLanguage??entry.lang)}`,language:resolveLanguage(entry.lang,site.languages)},entry.toc)),draftEntry=(site,file,raw,textfiles)=>{let known=site.entries.find(entry2=>entry2.file===file),{doc,source:source2}=compileDraft({...draftContext(site),defaultLang:known?.lang??site.defaultLang,textfiles},known?.sourceFile??CONTENT_PREFIX+file,raw),entry=toEntry(doc,source2);return watchEntryTextfiles([entry]),entry},filePreviewResults=(entry,site)=>{let results=new Map,bodyOffset=entry.raw.slice(0,entry.raw.length-entry.body.length).split(`
|
|
834
834
|
`).length-1;for(let{line:line2,file,kind}of fileReferences(entry.body,site.previews,entry.origin)){let errors=results.get(file)??[];if(errors.push(...entry.errors.filter(error=>error.startsWith(`L${bodyOffset+line2}:`))),kind==="term")errors.push(...entry.errors.filter(error=>error.startsWith(`${file}:`)));else if(kind==="textfile"){errors.push(...entry.errors.filter(error=>error.startsWith(`${file}:`)));for(let block of walkBlocks(entry.blocks))block.type!=="code"||block.filename?.replace(/^(\.\/)+/,"")!==file||(block.unavailable&&errors.push(block.unavailable==="missing"?"File not found":"File could not be loaded"),errors.push(...entry.errors.filter(error=>error.startsWith(`${block.filename}${block.range??""}:`))))}else site.ctx.figures.get(figureName(file))?.file!==file&&errors.push("File not found"),errors.push(...site.errors.filter(error=>error.startsWith(`${file}:`)));results.set(file,[...new Set(errors)])}return Object.fromEntries(results)},entryGitBase=(entry,site)=>site.workspace?.protocol==="git"?gitBaseBody(root4,entry.sourceFile??CONTENT_PREFIX+entry.file):null,renderDraft=(site,file,raw,textfiles)=>{let entry=draftEntry(site,file,raw,textfiles);return{gitBase:entryGitBase(entry,site),frontmatter:entry.frontmatter,sourceFile:entry.sourceFile,origin:entry.origin,html:renderEntry(site,entry,""),errors:[...site.errors,...entry.errors],toc:entry.toc,blockLines:entry.blockLines,filePreviews:filePreviewResults(entry,site),previews:site.previews}},renderSignature=(site,entry)=>JSON.stringify([site.ctx.terms,site.errors,entry.errors,entry.frontmatter,entry.lang])+site.entries.map(e2=>[e2.sourceFile??CONTENT_PREFIX+e2.file,docPath(site.entries,e2.id)]).sort().join(`
|
|
835
|
-
`),entryHtmlCache=new Map,renderEntryHtml=(site,entry)=>{if(entry.
|
|
835
|
+
`),entryHtmlCache=new Map,renderEntryHtml=(site,entry)=>{if(entry.format)return{html:`<article class="res-page resource-library">${renderFormatCollection(site,entry.format,"",docDisplayName(entry.frontmatter,entry.id))}</article>`,errors:[...site.errors,...entry.errors]};if(entry.library){let index4=resourceIndex(site.root??root4,site.filePaths??filesSnapshot(site.root??root4).files.map(item=>item.path),site.previews?.domains);return{html:`<article class="res-page resource-library subformat-page">${libraryPageHtml(index4,entry.library,docDisplayName(entry.frontmatter,entry.id))}</article>`,errors:[...site.errors,...entry.errors]}}if(entry.subformat)return{html:`<article class="res-page resource-library subformat-page">${resourceLibraryHtml({codeblocks:[],urls:[],urlPreviews:[],skills:[],subformats:[entry.subformat],errors:[...site.errors,...entry.errors]},"subformats",docDisplayName(entry.frontmatter,entry.id))}</article>`,errors:[...site.errors,...entry.errors]};let sig=renderSignature(site,entry),cached2=entryHtmlCache.get(entry.file);if(cached2&&cached2.blocks===entry.blocks&&cached2.sig===sig&&cached2.figures===site.ctx.figures&&cached2.figurePreview===site.ctx.figurePreview&&cached2.downloads===site.ctx.downloads)return cached2.value;let value2={html:renderEntry(site,entry,entry.id),errors:[...site.errors,...entry.errors]};return entryHtmlCache.set(entry.file,{blocks:entry.blocks,sig,figures:site.ctx.figures,figurePreview:site.ctx.figurePreview,downloads:site.ctx.downloads,value:value2}),value2},renderDocFile=(site,file,raw)=>{let entry=draftEntry(site,file,raw);return{gitBase:entryGitBase(entry,site),sourceFile:entry.sourceFile,origin:entry.origin,raw,frontmatter:entry.frontmatter,body:entry.body,html:renderEntry(site,entry,""),errors:[...site.errors,...entry.errors],toc:entry.toc,blockLines:entry.blockLines,filePreviews:filePreviewResults(entry,site),previews:site.previews}},docQueryResponse=(site,file)=>{let target=resolveContentFile(file);return target?existsSync(target.abs)?{status:200,body:renderDocFile(site,target.name,site.entries.find(entry=>entry.file===target.name)?.raw??readFileSync(target.abs,"utf8"))}:{status:404,body:{error:`${target.name} not found`}}:{status:400,body:{error:"file must be <id>.md"}}},asString=v2=>typeof v2=="string"?v2:"",sanitizeFrontmatter=v2=>{let o2=typeof v2=="object"&&v2!=null?v2:{},lang=asString(o2.lang).trim();return{title:asString(o2.title).trim(),...lang?{lang}:{}}},isExternallyModified=(baseRaw,currentRaw)=>typeof baseRaw=="string"&&baseRaw!==currentRaw,resolveContentFile=rel=>{let id=typeof rel=="string"?docIdOfFile(rel):void 0;if(flattenTree(readManifest(root4).tree).some(node2=>node2.id===id&&!isContentPage(node2)))return;let file=id==null?void 0:docFile(id,readManifest(root4).files);return id==null||!file||ignoredFiles(root4,[file]).has(file)?void 0:{id,name:`${id}.md`,abs:textfilePath(root4,file)}},DOC_FROM_C=`
|
|
836
836
|
--doc-bg:var(--c-bg0); --doc-bg-2:var(--c-bg1); --doc-bg-3:var(--c-surface);
|
|
837
837
|
--doc-panel:var(--c-surface); --doc-panel-2:var(--c-raised); --doc-rail:var(--c-bg1);
|
|
838
838
|
--doc-border:var(--c-line-soft); --doc-border-2:var(--c-line);
|
|
@@ -1881,6 +1881,8 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
|
|
|
1881
1881
|
.format-preview :is(img, video, iframe):not(.resource-modal *) { max-width: 100%; max-height: 220px; object-fit: contain; }
|
|
1882
1882
|
.format-card > .format-preview { display: grid; flex: 1; align-items: center; min-height: 180px; padding: 12px; box-sizing: border-box; background: var(--doc-bg-2); }
|
|
1883
1883
|
.format-card > .format-preview .fig > :is(img, iframe) { margin-inline: auto; }
|
|
1884
|
+
.format-card > .format-preview:has(.fig > :is(img, iframe[data-doc-figure-frame="svg"])) { container-type: size; grid-template-columns: minmax(0, 1fr); }
|
|
1885
|
+
.format-card > .format-preview .fig > :is(img, iframe[data-doc-figure-frame="svg"]):not(.resource-modal *) { max-height: 100cqh; }
|
|
1884
1886
|
.format-card > .format-preview:has(video) { display: block; min-height: 0; max-height: none; padding: 0; overflow: visible; }
|
|
1885
1887
|
.format-card > .format-preview .video-player > video:not(.resource-modal *) { height: 180px; border-radius: 0; }
|
|
1886
1888
|
.format-card .video-controls:not(.resource-modal *) { flex-wrap: wrap; padding: 6px 10px; gap: 4px; border-top: 1px solid var(--c-line); }
|
|
@@ -2612,7 +2614,7 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2612
2614
|
.nav-row.drop-before { box-shadow: inset 0 2px 0 var(--c-accent); }
|
|
2613
2615
|
.nav-row.drop-after, #sidebar-head.drop-after { box-shadow: inset 0 -2px 0 var(--c-accent); }
|
|
2614
2616
|
.nav-row.drop-into > a { background: color-mix(in srgb, var(--c-accent) 18%, transparent); }
|
|
2615
|
-
`,entryIcon=(e2,cls)=>{let svg=e2.icon??e2.subformat?.iconSvg;return svg?svgImg(svg,cls):e2.subformat?SUBFORMATS_ICON:e2.library||e2.format?libraryIcon(e2.library??e2.format??"")??STATICS_ICON:DOCS_ICON},navGroupsHtml=(mode,site,currentId,currentRes)=>{historicalReadOnly&&(mode="preview");let rootPage=site.entries.find(entry=>entry.root),open2=new Set(currentId==null?[]:[...ancestorsOf(site.entries,currentId).map(e2=>e2.id),currentId]),list5=(parent,depth)=>{let items=childrenOf(site.entries,parent).map(e2=>{let label2=escapeHtml(docDisplayName(e2.frontmatter,e2.id)),cur=e2.id===currentId?" cur":"",link2=depth===0?`<a class="nav-link${cur}" href="/${e2.id}" title="${label2}">${entryIcon(e2,"nav-icon doc-icon")}<span class="nav-label">${label2}</span></a>`:`<a class="nav-tree-link${cur}" href="/${e2.id}" title="${label2}">${entryIcon(e2,"doc-icon")}<span class="nav-label">${label2}</span></a>`,actions="",editableIcon="";mode==="edit"&&!e2.origin&&(link2=`<a class="${depth===0?"nav-link":"nav-tree-link"}${cur}" href="/${e2.id}" title="${label2}" aria-keyshortcuts="F2"><span class="nav-doc-name"><span class="nav-label">${label2}</span></span></a>`,editableIcon=`<span class="nav-doc-icon" title="icon" data-i18n-title="icon">${entryIcon(e2,"doc-icon")}<input type="file" accept=".svg,image/svg+xml" aria-label="icon" data-i18n-aria-label="icon">${e2.icon?'<button class="nav-icon-clear" type="button" title="Remove icon" data-i18n-title="Remove icon" aria-label="Remove icon" data-i18n-aria-label="Remove icon">\xD7</button>':""}</span>`,actions=`<button class="new" type="button" data-parent="${escapeHtml(e2.id)}" popovertarget="nav-page-menu" aria-haspopup="menu" title="Add doc" data-i18n-title="Add doc" aria-label="Add doc" data-i18n-aria-label="Add doc">${PLUS_ICON}</button><button class="nav-delete" type="button" data-doc-action="delete" title="Delete doc" data-i18n-title="Delete doc" aria-label="Delete doc" data-i18n-aria-label="Delete doc">${DELETE_ICON}</button>`);let toggle=childrenOf(site.entries,e2.id).length>0?`<button class="nav-tree-toggle" type="button" aria-expanded="${open2.has(e2.id)}" aria-label="Toggle ${label2}">${DISCLOSURE_ICON}</button>`:mode==="edit"?'<span class="nav-tree-spacer" aria-hidden="true"></span>':"";return`<div class="nav-item${open2.has(e2.id)?" open":""}" data-doc-id="${escapeHtml(e2.id)}"${isContentPage(e2)?"":" data-subformat-nav"}><div class="nav-row${mode==="edit"&&!e2.origin?" nav-doc-row":""}"${mode==="edit"&&!e2.origin?' draggable="true"':""}>${editableIcon}${link2}${actions}${toggle}</div>${list5(e2.id,depth+1)}</div>`}).join(""),placeholder=mode==="edit"&&depth===0?`<div class="nav-item nav-placeholder"><div class="nav-row"><button class="nav-create" type="button" data-parent="${rootPage?.file?escapeHtml(rootPage.id):""}" popovertarget="nav-page-menu" aria-haspopup="menu" title="Add doc" data-i18n-title="Add doc" aria-label="Add doc" data-i18n-aria-label="Add doc">${PLUS_ICON}</button></div></div>`:"";return depth===0?`<div class="nav-list nav-root" id="nav-docs" data-parent="${rootPage?.file?escapeHtml(rootPage.id):""}"${rootPage&&!isContentPage(rootPage)?" data-root-resource":""}${rootPage&&isLinkedEntry(rootPage)?" data-document-link":""}>${items}${placeholder}</div>`:`<div class="nav-list nav-tree" data-parent="${escapeHtml(parent??"")}" style="--nav-depth:${depth+1}">${items}${placeholder}</div>`},html3=list5(rootPage?.id,0)+'<div id="document-versions" hidden></div>'+(mode==="edit"?`<template data-page-libraries>${escapeHtml(JSON.stringify([...REFERENCE_LIBRARIES].filter(view=>!site.entries.some(entry=>entry.library===view))))}</template><template data-page-subformats>${escapeHtml(JSON.stringify((site.subformats??[]).map(format5=>({ext:format5.ext,added:site.entries.some(entry=>entry.subformat?.ext===format5.ext)}))))}</template>${navFilesHtml(site,currentRes)}`:""),links=docLinks(site,html3);return site.contentLanguage?languageLinks(links,site.contentLanguage):links},RESOURCE_KINDS=["markdown","figures","html","icons","terms"],siteResources=site=>[...site.entries.filter(isContentPage).map(entry=>({kind:"markdown",file:entry.file,path:entry.sourceFile??CONTENT_PREFIX+entry.file})),...site.ctx.terms.map(term=>({kind:"terms",file:term.id,path:isTermFile(term.id)?term.id:CONTENT_PREFIX+(site.entries.find(entry=>entry.blocks.some(block=>block.type==="term"&&block.entry.id===term.id))?.file??"")})),...[...site.ctx.figures.values()].map(f2=>({kind:f2.kind==="html"?"html":"figures",file:f2.file.replace(/^figures\//,""),path:f2.file})),...site.entries.filter(e2=>e2.icon!=null).map(e2=>({kind:"icons",file:`${e2.id}.svg`,path:e2.iconFile??`${ICONS_DIR}/${e2.id}.svg`}))],resourceHref=(kind,file)=>`/_files${kind?`/${kind}`:""}${file?`/${encodeURIComponent(file)}`:""}`,navFilesHtml=(site,currentRes)=>{let source2=site.workspace,format5=currentRes?.startsWith("_format")||["codeblocks","_library/codeblocks","dictionary","code"].includes(currentRes??""),library=!format5&&(currentRes?.startsWith("_library")||isReferenceLibrary(currentRes)),hint=`<div class="files-drop-hint" aria-hidden="true">${UPLOAD_ICON}<span data-i18n="Upload files">Upload files</span></div>`,location2=source2?.protocol==="git"?`<summary class="workspace-location" aria-label="Workspace tools" data-i18n-aria-label="Workspace tools" data-workspace-protocol="git" title="${escapeHtml(`${source2.repo??"repo"}[${source2.branch}]`)}">${GIT_ICON}<span class="workspace-address"><span class="git-repo-name">${escapeHtml(source2.repo??"repo")}</span><span class="git-branch-caption">[${escapeHtml(source2.branch)}]</span></span>${CHEVRON_ICON}</summary>`:`<summary class="workspace-location" aria-label="Workspace tools" data-i18n-aria-label="Workspace tools" id="nav-storage" data-workspace-protocol="storage" title="${escapeHtml(workspaceName(site))}">${workspaceIcon(site)}<span class="workspace-address">${escapeHtml(source2?.folder??"Files")} / ${escapeHtml(source2?.service??"Local")}</span>${CHEVRON_ICON}</summary>`,git=source2?.protocol==="git"&&sharedBranch===void 0?`<div class="nav-resources" id="nav-git"><div class="nav-item" data-node-id="_git"><div class="nav-row"><a class="nav-link${currentRes==="_git"?" cur":""}" href="/_git" title="Git controls" data-i18n-title="Git controls">${GIT_ICON}<span class="nav-label">Git</span></a></div></div></div>`:"",extensions=`<div class="nav-resources" id="nav-extensions" data-scope="${createHash("sha256").update(root4).digest("hex")}"><div class="nav-item" data-node-id="_extensions"><div class="nav-row"><a class="nav-link${currentRes==="_extensions"?" cur":""}" href="/_extensions" title="Plugins" data-i18n-title="Plugins">${PLUGINS_ICON}<span class="nav-label" data-i18n="Plugins">Plugins</span></a></div></div><div class="extensions-drop-hint" aria-hidden="true">${PLUGINS_ICON}<span data-i18n="Add plugins">Add plugins</span></div></div>`,subformats=`<div class="nav-resources" id="nav-subformats"><div class="nav-item" data-node-id="_subformats"><div class="nav-row"><a class="nav-link${currentRes==="_subformats"?" cur":""}" href="/_subformats" title="Subformats" data-i18n-title="Subformats">${SUBFORMATS_ICON}<span class="nav-label" data-i18n="Subformats">Subformats</span></a></div></div></div><div class="nav-resources" id="nav-llm"><div class="nav-item" data-node-id="_llm"><div class="nav-row"><a class="nav-link${currentRes==="_llm"?" cur":""}" href="/_llm" title="LLM">${LLM_ICON}<span class="nav-label">LLM</span></a></div></div></div>`;return`<details id="nav-tools" open>${location2}<div class="nav-tool-cards"><div class="nav-resources" id="nav-manifest"><div class="nav-item" data-node-id="_manifest"><div class="nav-row"><a class="nav-link${currentRes==="_manifest"?" cur":""}" href="/_manifest" title="dooc.yaml">${GEAR_ICON}<span class="nav-label">dooc.yaml</span></a></div></div></div><div class="nav-resources" id="nav-files"><div class="nav-item" data-node-id="_files"><div class="nav-row"><a class="nav-link${currentRes!==void 0&¤tRes!=="_manifest"&¤tRes!=="_git"&¤tRes!=="_extensions"&¤tRes!=="_subformats"&¤tRes!=="_llm"&&!library&&!format5?" cur":""}" href="/_files" title="Files" data-i18n-title="Files">${FOLDER_ICON}<span class="nav-label" data-i18n="Files">Files</span></a><span class="files-upload-status" role="status"></span></div></div>${hint}</div><div class="nav-resources" id="nav-library"><div class="nav-item" data-node-id="_library"><div class="nav-row"><a class="nav-link${library?" cur":""}" href="/_library" title="Library" data-i18n-title="Library">${STATICS_ICON}<span class="nav-label" data-i18n="Library">Library</span></a></div></div></div><div class="nav-resources" id="nav-format"><div class="nav-item" data-node-id="_format"><div class="nav-row"><a class="nav-link${format5?" cur":""}" href="/_format" title="Format" data-i18n-title="Format">${libraryIcon("codeblocks")??STATICS_ICON}<span class="nav-label" data-i18n="Format">Format</span></a></div></div></div>${subformats}${git}${extensions}</div></details>`},formatSize=bytes=>bytes<1024?`${bytes} B`:bytes<1024*1024?`${(bytes/1024).toFixed(1)} KB`:`${(bytes/1024/1024).toFixed(1)} MB`,sizeOf=path4=>{try{return formatSize(statSync(join4(root4,path4)).size)}catch{return"\u2014"}},resourcePreview=(site,r2)=>{if(r2.kind==="markdown"){let entry=site.entries.find(e3=>e3.file===r2.file);return`<pre class="res-markdown">${escapeHtml(entry?.raw??"")}</pre>`}if(r2.kind==="terms")return termsHtml(site.ctx.terms.filter(term=>term.id===r2.file));if(r2.kind==="figures"||r2.kind==="html"){let f2=site.ctx.figures.get(figureName(r2.path));return f2?f2.kind==="image"?f2.markup.replace("<img ",'<img class="res-img" '):(site.ctx.figurePreview??figureFrameHtml)(f2,`fig-frame res-${f2.kind}`):""}let e2=site.entries.find(x3=>`${x3.id}.svg`===r2.file);return e2?.icon?svgImg(e2.icon,"res-img res-icon"):""},resourceUsage=(site,r2)=>r2.kind==="markdown"?site.entries.filter(e2=>e2.file===r2.file):r2.kind==="figures"||r2.kind==="html"?site.entries.filter(e2=>e2.figureRefs?.includes(figureName(r2.path))):r2.kind==="icons"?site.entries.filter(e2=>`${e2.id}.svg`===r2.file):site.entries.filter(e2=>e2.termRefs?.includes(r2.file)),resourceCards=(site,list5)=>list5.length===0?"":`<div class="res-grid">${list5.map(r2=>{let used=resourceUsage(site,r2).length;return`<a class="res-card" href="${resourceHref(r2.kind,r2.file)}"><div class="res-thumb">${resourcePreview(site,r2)}</div><div class="res-meta"><span class="res-name">${escapeHtml(r2.file)}</span><span class="res-sub">${sizeOf(r2.path)} \xB7 used by ${used}</span></div></a>`}).join("")}</div>`,textfilePreview=(site,file,source2)=>{let language=(file.split(".").at(-1)??"text").toLowerCase(),parsed2=parseContentSource(language,source2,file),errors=parsed2?.errors.map(({message})=>message)??[];if(errors.length)return{html:"",errors};try{return{html:blocksHtml(parsed2?.blocks??[{type:"code",lang:language,lines:source2.split(/\r?\n/),filename:file}],site.ctx),errors}}catch(error){return{html:"",errors:[error instanceof Error?error.message:String(error)]}}},textfilePreviewHtml=(site,file,source2)=>{let{html:html3,errors}=textfilePreview(site,file,source2);return errors.length?`<div class="errors" role="status">${errors.map(escapeHtml).join("<br>")}</div>`:html3},textfilePreviewErrors=(site,file,source2)=>{let errors=textfilePreview(site,file,source2).errors;try{validateSubformatFile(root4,file,source2,site.previews?.domains)}catch(error){errors.push(error instanceof Error?error.message:String(error))}if(/\.(md|markdown)$/i.test(file)){let{doc,source:parsed2}=compileDraft(draftContext(site),file,source2);errors.push(...parsed2.errors);try{blocksHtml(doc.blocks,site.ctx)}catch(error){errors.push(error instanceof Error?error.message:String(error))}}return errors},readProjectFile=(file,projectRoot2=root4)=>{try{return filesSnapshot(projectRoot2).files.some(item=>item.path===file)?readFileSync(textfilePath(projectRoot2,file)):isSkillFile(file)?readProjectSkills(projectRoot2).find(skill=>skill.file===file)?.files.get("SKILL.md"):void 0}catch{return}},filePage=(site,file,content3,download=site.ctx.downloads?.get(file))=>{let preview="",sourceFile;if(/\.(svg|png|jpe?g|gif|webp)$/i.test(file)){let extension2=file.split(".").pop()?.toLowerCase();preview=`<img alt="" src="data:image/${extension2==="svg"?"svg+xml":extension2==="jpg"?"jpeg":extension2};base64,${content3.toString("base64")}">`,extension2==="svg"&&(sourceFile=file)}else if(/\.(pdf|dxf|html)$/i.test(file))preview=formatPreview(site,[file])(file),/\.pdf$/i.test(file)||(sourceFile=file);else if(/\.(mp4|webm|ogg)$/i.test(file))preview=`<video data-dooc-video controls playsinline preload="metadata" aria-label="Video preview" src="data:video/${file.split(".").pop()};base64,${content3.toString("base64")}"></video>`;else try{let source2=new TextDecoder("utf-8",{fatal:!0}).decode(content3);if(source2.includes("\0"))throw new Error("Binary file");sourceFile=file,preview=textfilePreviewHtml({...site,ctx:{...site.ctx,downloads:void 0}},file,source2)}catch{preview=BOX_ICON}return{title:file,sourceFile,main:`<article class="res-page res-file-page"><nav class="res-crumbs"><a href="/_files">${workspaceText(site)}</a></nav><h1>${escapeHtml(file)}${download?resourceDownloadHtml(file,download):""}</h1><div class="res-preview${sourceFile?" res-text-preview":""}">${preview}</div></article>`}},formatPreview=(site,files)=>{let missing=files.filter(file=>/\.(svg|html|png|webp|gif|mp4|webm|jpe?g|pdf|dxf)$/i.test(file)).filter(file=>!site.ctx.figures.has(figureName(file))),figures=new Map(site.ctx.figures);if(missing.length)for(let figure of loadFigures(join4(site.root??root4,"figures"),missing).figures)figures.set(figure.name,figure);return file=>{let figure=figures.get(figureName(file));if(figure)return blocksHtml([{type:"figureRef",name:figure.name}],{...site.ctx,figures,figurePreview:figureFrameHtml});try{return textfilePreviewHtml(site,file,readTextfile(site.root??root4,file))}catch{return""}}},renderFormatCollection=(site,selector,query="")=>{let collection=readFormatCollection(site.root??root4,selector,parseFormatQuery(query)),missing=collection.records.filter(record2=>record2.preview?.some(block=>block.type==="figureRef"&&!site.ctx.figures.has(block.name))).map(record2=>record2.file),figures=new Map(site.ctx.figures);if(missing.length)for(let figure of loadFigures(join4(site.root??root4,"figures"),missing).figures)figures.set(figure.name,figure);return blocksHtml([formatCollectionBlock(collection,parseFormatQuery(query))],{...site.ctx,figures,figurePreview:figureFrameHtml})},resourcesMain=(site,rest)=>{let download=file2=>{let href=site.ctx.downloads?.get(file2);return href?resourceDownloadHtml(file2,href):""};if(rest==="_manifest"){let file2=manifestFile(site.root??root4);return{title:file2,sourceFile:file2,main:`<article class="res-page resource-library manifest-page"><div id="manifest-manager" data-file="${escapeHtml(file2)}"></div></article>`}}if(rest==="_llm")return{title:"LLM",main:'<article class="res-page resource-library llm-page"><div id="llm-providers"></div></article>'};if(rest==="_extensions")return{title:"Plugins",main:'<article class="res-page resource-library"><div id="extensions-manager"></div></article>'};if(rest==="_git")return site.workspace?.protocol==="git"&&sharedBranch===void 0?{title:`${site.workspace.repo??"repo"} [${site.workspace.branch}]`,main:'<article class="res-page resource-library git-page"><div id="git-manager"></div></article>'}:void 0;if(/^_format(?:[/?]|$)/.test(rest)){let[path4,query=""]=rest.split("?"),selector=path4?.slice(8)??"";selector&&formatSelector(selector);let files=site.filePaths??filesSnapshot(site.root??root4).files.map(item=>item.path),formats2=[...new Set(files.map(fileFormat))].sort(),choices=new Set(["",...Object.keys(FORMAT_TRAITS),...formats2]);for(let[trait,members]of Object.entries(FORMAT_TRAITS)){for(let[child,formats3]of Object.entries(FORMAT_TRAITS))child!==trait&&formats3.every(format5=>members.includes(format5))&&choices.add(`${trait}/${child}`);for(let format5 of formats2)matchesFormat(format5,trait)&&choices.add(`${trait}/${format5}`)}choices.add(selector);let navigation=`<nav class="format-navigation" aria-label="Format collections" data-i18n-aria-label="Format collections"><label><span data-i18n="Collection">Collection</span><select data-format-path>${[...choices].map(value2=>`<option value="${escapeHtml(value2)}"${value2===selector?" selected":""}${value2?"":' data-i18n="All formats"'}>${escapeHtml(value2||"All formats")}</option>`).join("")}</select></label><code>format/${escapeHtml(selector||"all")}</code></nav>`,content3=!query&&site.subformats?.some(format5=>format5.ext===selector)?formatPageHtml(resourceIndex(site.root??root4,files,site.previews?.domains),selector,selector):renderFormatCollection(site,selector,query);return{title:"Format",main:`<article class="res-page resource-library resource-results">${navigation}${content3}</article>`}}if(rest==="_library"||rest.startsWith("_library/")){let view=rest.slice(8).replace(/^\//,"")||(readManifest(site.root??root4).libraries?.[0]??"urls");return isReferenceLibrary(view)||["codeblocks","dictionary","code"].includes(view)?resourcesMain(site,view):void 0}let all2=siteResources(site),[kind,...tail]=rest===""?[]:rest.split("/"),file=tail.length>0?decodeURIComponent(tail.join("/")):void 0;if(kind==null)return{title:workspaceName(site),main:'<article class="res-page files-page resource-library"><div id="files-manager"></div></article>'};if(!file&&(kind==="dictionary"||kind==="code"))return resourcesMain(site,"codeblocks");if(kind==="schema"&&file){let config=site.subformats?.find(format5=>format5.ext===file);if(!config)return;let title=`${config.ext} \u2014 JSON Schema`,schemaRoot=site.root??root4,content3;try{if(!filesSnapshot(schemaRoot).files.some(item=>item.path===config.schema))throw new Error("Subformat schema is not available in the workspace");let raw=readTextfile(schemaRoot,config.schema),{schema:schema5,context}=compileSubformatSchema(raw,{root:schemaRoot,file:config.schema,domains:site.previews?.domains});content3=jsonSchemaHtml(schema5,context),content3+=`<details><summary data-i18n="JSON text">JSON text</summary>${blocksHtml([{type:"code",lang:"json",lines:raw.split(`
|
|
2617
|
+
`,entryIcon=(e2,cls)=>{let svg=e2.icon??e2.subformat?.iconSvg;return svg?svgImg(svg,cls):e2.subformat?SUBFORMATS_ICON:e2.library||e2.format?libraryIcon(e2.library??e2.format??"")??STATICS_ICON:DOCS_ICON},navGroupsHtml=(mode,site,currentId,currentRes)=>{historicalReadOnly&&(mode="preview");let rootPage=site.entries.find(entry=>entry.root),open2=new Set(currentId==null?[]:[...ancestorsOf(site.entries,currentId).map(e2=>e2.id),currentId]),list5=(parent,depth)=>{let items=childrenOf(site.entries,parent).map(e2=>{let label2=escapeHtml(docDisplayName(e2.frontmatter,e2.id)),cur=e2.id===currentId?" cur":"",link2=depth===0?`<a class="nav-link${cur}" href="/${e2.id}" title="${label2}">${entryIcon(e2,"nav-icon doc-icon")}<span class="nav-label">${label2}</span></a>`:`<a class="nav-tree-link${cur}" href="/${e2.id}" title="${label2}">${entryIcon(e2,"doc-icon")}<span class="nav-label">${label2}</span></a>`,actions="",editableIcon="";mode==="edit"&&!e2.origin&&(link2=`<a class="${depth===0?"nav-link":"nav-tree-link"}${cur}" href="/${e2.id}" title="${label2}" aria-keyshortcuts="F2"><span class="nav-doc-name"><span class="nav-label">${label2}</span></span></a>`,editableIcon=`<span class="nav-doc-icon" title="icon" data-i18n-title="icon">${entryIcon(e2,"doc-icon")}<input type="file" accept=".svg,image/svg+xml" aria-label="icon" data-i18n-aria-label="icon">${e2.icon?'<button class="nav-icon-clear" type="button" title="Remove icon" data-i18n-title="Remove icon" aria-label="Remove icon" data-i18n-aria-label="Remove icon">\xD7</button>':""}</span>`,actions=`<button class="new" type="button" data-parent="${escapeHtml(e2.id)}" popovertarget="nav-page-menu" aria-haspopup="menu" title="Add doc" data-i18n-title="Add doc" aria-label="Add doc" data-i18n-aria-label="Add doc">${PLUS_ICON}</button><button class="nav-delete" type="button" data-doc-action="delete" title="Delete doc" data-i18n-title="Delete doc" aria-label="Delete doc" data-i18n-aria-label="Delete doc">${DELETE_ICON}</button>`);let toggle=childrenOf(site.entries,e2.id).length>0?`<button class="nav-tree-toggle" type="button" aria-expanded="${open2.has(e2.id)}" aria-label="Toggle ${label2}">${DISCLOSURE_ICON}</button>`:mode==="edit"?'<span class="nav-tree-spacer" aria-hidden="true"></span>':"";return`<div class="nav-item${open2.has(e2.id)?" open":""}" data-doc-id="${escapeHtml(e2.id)}"${isContentPage(e2)?"":" data-subformat-nav"}><div class="nav-row${mode==="edit"&&!e2.origin?" nav-doc-row":""}"${mode==="edit"&&!e2.origin?' draggable="true"':""}>${editableIcon}${link2}${actions}${toggle}</div>${list5(e2.id,depth+1)}</div>`}).join(""),placeholder=mode==="edit"&&depth===0?`<div class="nav-item nav-placeholder"><div class="nav-row"><button class="nav-create" type="button" data-parent="${rootPage?.file?escapeHtml(rootPage.id):""}" popovertarget="nav-page-menu" aria-haspopup="menu" title="Add doc" data-i18n-title="Add doc" aria-label="Add doc" data-i18n-aria-label="Add doc">${PLUS_ICON}</button></div></div>`:"";return depth===0?`<div class="nav-list nav-root" id="nav-docs" data-parent="${rootPage?.file?escapeHtml(rootPage.id):""}"${rootPage&&!isContentPage(rootPage)?" data-root-resource":""}${rootPage&&isLinkedEntry(rootPage)?" data-document-link":""}>${items}${placeholder}</div>`:`<div class="nav-list nav-tree" data-parent="${escapeHtml(parent??"")}" style="--nav-depth:${depth+1}">${items}${placeholder}</div>`},html3=list5(rootPage?.id,0)+'<div id="document-versions" hidden></div>'+(mode==="edit"?`<template data-page-libraries>${escapeHtml(JSON.stringify([...REFERENCE_LIBRARIES].filter(view=>!site.entries.some(entry=>entry.library===view))))}</template><template data-page-subformats>${escapeHtml(JSON.stringify((site.subformats??[]).map(format5=>({ext:format5.ext,added:site.entries.some(entry=>entry.subformat?.ext===format5.ext)}))))}</template>${navFilesHtml(site,currentRes)}`:""),links=docLinks(site,html3);return site.contentLanguage?languageLinks(links,site.contentLanguage):links},RESOURCE_KINDS=["markdown","figures","html","icons","terms"],siteResources=site=>[...site.entries.filter(isContentPage).map(entry=>({kind:"markdown",file:entry.file,path:entry.sourceFile??CONTENT_PREFIX+entry.file})),...site.ctx.terms.map(term=>({kind:"terms",file:term.id,path:isTermFile(term.id)?term.id:CONTENT_PREFIX+(site.entries.find(entry=>entry.blocks.some(block=>block.type==="term"&&block.entry.id===term.id))?.file??"")})),...[...site.ctx.figures.values()].map(f2=>({kind:f2.kind==="html"?"html":"figures",file:f2.file.replace(/^figures\//,""),path:f2.file})),...site.entries.filter(e2=>e2.icon!=null).map(e2=>({kind:"icons",file:`${e2.id}.svg`,path:e2.iconFile??`${ICONS_DIR}/${e2.id}.svg`}))],resourceHref=(kind,file)=>`/_files${kind?`/${kind}`:""}${file?`/${encodeURIComponent(file)}`:""}`,navFilesHtml=(site,currentRes)=>{let source2=site.workspace,format5=currentRes?.startsWith("_format")||["codeblocks","_library/codeblocks","dictionary","code"].includes(currentRes??""),library=!format5&&(currentRes?.startsWith("_library")||isReferenceLibrary(currentRes)),hint=`<div class="files-drop-hint" aria-hidden="true">${UPLOAD_ICON}<span data-i18n="Upload files">Upload files</span></div>`,location2=source2?.protocol==="git"?`<summary class="workspace-location" aria-label="Workspace tools" data-i18n-aria-label="Workspace tools" data-workspace-protocol="git" title="${escapeHtml(`${source2.repo??"repo"}[${source2.branch}]`)}">${GIT_ICON}<span class="workspace-address"><span class="git-repo-name">${escapeHtml(source2.repo??"repo")}</span><span class="git-branch-caption">[${escapeHtml(source2.branch)}]</span></span>${CHEVRON_ICON}</summary>`:`<summary class="workspace-location" aria-label="Workspace tools" data-i18n-aria-label="Workspace tools" id="nav-storage" data-workspace-protocol="storage" title="${escapeHtml(workspaceName(site))}">${workspaceIcon(site)}<span class="workspace-address">${escapeHtml(source2?.folder??"Files")} / ${escapeHtml(source2?.service??"Local")}</span>${CHEVRON_ICON}</summary>`,git=source2?.protocol==="git"&&sharedBranch===void 0?`<div class="nav-resources" id="nav-git"><div class="nav-item" data-node-id="_git"><div class="nav-row"><a class="nav-link${currentRes==="_git"?" cur":""}" href="/_git" title="Git controls" data-i18n-title="Git controls">${GIT_ICON}<span class="nav-label">Git</span></a></div></div></div>`:"",extensions=`<div class="nav-resources" id="nav-extensions" data-scope="${createHash("sha256").update(root4).digest("hex")}"><div class="nav-item" data-node-id="_extensions"><div class="nav-row"><a class="nav-link${currentRes==="_extensions"?" cur":""}" href="/_extensions" title="Plugins" data-i18n-title="Plugins">${PLUGINS_ICON}<span class="nav-label" data-i18n="Plugins">Plugins</span></a></div></div><div class="extensions-drop-hint" aria-hidden="true">${PLUGINS_ICON}<span data-i18n="Add plugins">Add plugins</span></div></div>`,subformats=`<div class="nav-resources" id="nav-subformats"><div class="nav-item" data-node-id="_subformats"><div class="nav-row"><a class="nav-link${currentRes==="_subformats"?" cur":""}" href="/_subformats" title="Subformats" data-i18n-title="Subformats">${SUBFORMATS_ICON}<span class="nav-label" data-i18n="Subformats">Subformats</span></a></div></div></div><div class="nav-resources" id="nav-llm"><div class="nav-item" data-node-id="_llm"><div class="nav-row"><a class="nav-link${currentRes==="_llm"?" cur":""}" href="/_llm" title="LLM">${LLM_ICON}<span class="nav-label">LLM</span></a></div></div></div>`;return`<details id="nav-tools" open>${location2}<div class="nav-tool-cards"><div class="nav-resources" id="nav-manifest"><div class="nav-item" data-node-id="_manifest"><div class="nav-row"><a class="nav-link${currentRes==="_manifest"?" cur":""}" href="/_manifest" title="dooc.yaml">${GEAR_ICON}<span class="nav-label">dooc.yaml</span></a></div></div></div><div class="nav-resources" id="nav-files"><div class="nav-item" data-node-id="_files"><div class="nav-row"><a class="nav-link${currentRes!==void 0&¤tRes!=="_manifest"&¤tRes!=="_git"&¤tRes!=="_extensions"&¤tRes!=="_subformats"&¤tRes!=="_llm"&&!library&&!format5?" cur":""}" href="/_files" title="Files" data-i18n-title="Files">${FOLDER_ICON}<span class="nav-label" data-i18n="Files">Files</span></a><span class="files-upload-status" role="status"></span></div></div>${hint}</div><div class="nav-resources" id="nav-library"><div class="nav-item" data-node-id="_library"><div class="nav-row"><a class="nav-link${library?" cur":""}" href="/_library" title="Library" data-i18n-title="Library">${STATICS_ICON}<span class="nav-label" data-i18n="Library">Library</span></a></div></div></div><div class="nav-resources" id="nav-format"><div class="nav-item" data-node-id="_format"><div class="nav-row"><a class="nav-link${format5?" cur":""}" href="/_format" title="Format" data-i18n-title="Format">${libraryIcon("codeblocks")??STATICS_ICON}<span class="nav-label" data-i18n="Format">Format</span></a></div></div></div>${subformats}${git}${extensions}</div></details>`},formatSize=bytes=>bytes<1024?`${bytes} B`:bytes<1024*1024?`${(bytes/1024).toFixed(1)} KB`:`${(bytes/1024/1024).toFixed(1)} MB`,sizeOf=path4=>{try{return formatSize(statSync(join4(root4,path4)).size)}catch{return"\u2014"}},resourcePreview=(site,r2)=>{if(r2.kind==="markdown"){let entry=site.entries.find(e3=>e3.file===r2.file);return`<pre class="res-markdown">${escapeHtml(entry?.raw??"")}</pre>`}if(r2.kind==="terms")return termsHtml(site.ctx.terms.filter(term=>term.id===r2.file));if(r2.kind==="figures"||r2.kind==="html"){let f2=site.ctx.figures.get(figureName(r2.path));return f2?f2.kind==="image"?f2.markup.replace("<img ",'<img class="res-img" '):(site.ctx.figurePreview??figureFrameHtml)(f2,`fig-frame res-${f2.kind}`):""}let e2=site.entries.find(x3=>`${x3.id}.svg`===r2.file);return e2?.icon?svgImg(e2.icon,"res-img res-icon"):""},resourceUsage=(site,r2)=>r2.kind==="markdown"?site.entries.filter(e2=>e2.file===r2.file):r2.kind==="figures"||r2.kind==="html"?site.entries.filter(e2=>e2.figureRefs?.includes(figureName(r2.path))):r2.kind==="icons"?site.entries.filter(e2=>`${e2.id}.svg`===r2.file):site.entries.filter(e2=>e2.termRefs?.includes(r2.file)),resourceCards=(site,list5)=>list5.length===0?"":`<div class="res-grid">${list5.map(r2=>{let used=resourceUsage(site,r2).length;return`<a class="res-card" href="${resourceHref(r2.kind,r2.file)}"><div class="res-thumb">${resourcePreview(site,r2)}</div><div class="res-meta"><span class="res-name">${escapeHtml(r2.file)}</span><span class="res-sub">${sizeOf(r2.path)} \xB7 used by ${used}</span></div></a>`}).join("")}</div>`,textfilePreview=(site,file,source2)=>{let language=(file.split(".").at(-1)??"text").toLowerCase(),parsed2=parseContentSource(language,source2,file),errors=parsed2?.errors.map(({message})=>message)??[];if(errors.length)return{html:"",errors};try{return{html:blocksHtml(parsed2?.blocks??[{type:"code",lang:language,lines:source2.split(/\r?\n/),filename:file}],site.ctx),errors}}catch(error){return{html:"",errors:[error instanceof Error?error.message:String(error)]}}},textfilePreviewHtml=(site,file,source2)=>{let{html:html3,errors}=textfilePreview(site,file,source2);return errors.length?`<div class="errors" role="status">${errors.map(escapeHtml).join("<br>")}</div>`:html3},textfilePreviewErrors=(site,file,source2)=>{let errors=textfilePreview(site,file,source2).errors;try{validateSubformatFile(root4,file,source2,site.previews?.domains)}catch(error){errors.push(error instanceof Error?error.message:String(error))}if(/\.(md|markdown)$/i.test(file)){let{doc,source:parsed2}=compileDraft(draftContext(site),file,source2);errors.push(...parsed2.errors);try{blocksHtml(doc.blocks,site.ctx)}catch(error){errors.push(error instanceof Error?error.message:String(error))}}return errors},readProjectFile=(file,projectRoot2=root4)=>{try{return filesSnapshot(projectRoot2).files.some(item=>item.path===file)?readFileSync(textfilePath(projectRoot2,file)):isSkillFile(file)?readProjectSkills(projectRoot2).find(skill=>skill.file===file)?.files.get("SKILL.md"):void 0}catch{return}},filePage=(site,file,content3,download=site.ctx.downloads?.get(file))=>{let preview="",sourceFile;if(/\.(svg|png|jpe?g|gif|webp)$/i.test(file)){let extension2=file.split(".").pop()?.toLowerCase();preview=`<img alt="" src="data:image/${extension2==="svg"?"svg+xml":extension2==="jpg"?"jpeg":extension2};base64,${content3.toString("base64")}">`,extension2==="svg"&&(sourceFile=file)}else if(/\.(pdf|dxf|html)$/i.test(file))preview=formatPreview(site,[file])(file),/\.pdf$/i.test(file)||(sourceFile=file);else if(/\.(mp4|webm|ogg)$/i.test(file))preview=`<video data-dooc-video controls playsinline preload="metadata" aria-label="Video preview" src="data:video/${file.split(".").pop()};base64,${content3.toString("base64")}"></video>`;else try{let source2=new TextDecoder("utf-8",{fatal:!0}).decode(content3);if(source2.includes("\0"))throw new Error("Binary file");sourceFile=file,preview=textfilePreviewHtml({...site,ctx:{...site.ctx,downloads:void 0}},file,source2)}catch{preview=BOX_ICON}return{title:file,sourceFile,main:`<article class="res-page res-file-page"><nav class="res-crumbs"><a href="/_files">${workspaceText(site)}</a></nav><h1>${escapeHtml(file)}${download?resourceDownloadHtml(file,download):""}</h1><div class="res-preview${sourceFile?" res-text-preview":""}">${preview}</div></article>`}},formatPreview=(site,files)=>{let missing=files.filter(file=>/\.(svg|html|png|webp|gif|mp4|webm|jpe?g|pdf|dxf)$/i.test(file)).filter(file=>!site.ctx.figures.has(figureName(file))),figures=new Map(site.ctx.figures);if(missing.length)for(let figure of loadFigures(join4(site.root??root4,"figures"),missing).figures)figures.set(figure.name,figure);return file=>{let figure=figures.get(figureName(file));if(figure)return blocksHtml([{type:"figureRef",name:figure.name}],{...site.ctx,figures,figurePreview:figureFrameHtml});try{return textfilePreviewHtml(site,file,readTextfile(site.root??root4,file))}catch{return""}}},renderFormatCollection=(site,selector,query="",title=selector)=>{let project=site.root??root4,alias=selector&&fenceFormat(selector);if(!query&&site.subformats?.some(({ext})=>ext===selector||ext===alias)){let files=site.filePaths??filesSnapshot(project).files.map(item=>item.path),index4=resourceIndex(project,files,site.previews?.domains),format5=index4.formats?.includes(selector)?selector:alias;if(index4.subformats.some(({ext})=>ext===format5))return`<div class="subformat-page">${formatPageHtml(index4,format5,title)}</div>`}let options2=parseFormatQuery(query),collection=readFormatCollection(project,selector,options2),missing=collection.records.filter(record2=>record2.preview?.some(block=>block.type==="figureRef"&&!site.ctx.figures.has(block.name))).map(record2=>record2.file),figures=new Map(site.ctx.figures);if(missing.length)for(let figure of loadFigures(join4(project,"figures"),missing).figures)figures.set(figure.name,figure);return blocksHtml([formatCollectionBlock(collection,options2)],{...site.ctx,figures,figurePreview:figureFrameHtml})},resourcesMain=(site,rest)=>{let download=file2=>{let href=site.ctx.downloads?.get(file2);return href?resourceDownloadHtml(file2,href):""};if(rest==="_manifest"){let file2=manifestFile(site.root??root4);return{title:file2,sourceFile:file2,main:`<article class="res-page resource-library manifest-page"><div id="manifest-manager" data-file="${escapeHtml(file2)}"></div></article>`}}if(rest==="_llm")return{title:"LLM",main:'<article class="res-page resource-library llm-page"><div id="llm-providers"></div></article>'};if(rest==="_extensions")return{title:"Plugins",main:'<article class="res-page resource-library"><div id="extensions-manager"></div></article>'};if(rest==="_git")return site.workspace?.protocol==="git"&&sharedBranch===void 0?{title:`${site.workspace.repo??"repo"} [${site.workspace.branch}]`,main:'<article class="res-page resource-library git-page"><div id="git-manager"></div></article>'}:void 0;if(/^_format(?:[/?]|$)/.test(rest)){let[path4,query=""]=rest.split("?"),selector=path4?.slice(8)??"";selector&&formatSelector(selector);let files=site.filePaths??filesSnapshot(site.root??root4).files.map(item=>item.path),formats2=[...new Set(files.map(fileFormat))].sort(),choices=new Set(["",...Object.keys(FORMAT_TRAITS),...formats2]);for(let[trait,members]of Object.entries(FORMAT_TRAITS)){for(let[child,formats3]of Object.entries(FORMAT_TRAITS))child!==trait&&formats3.every(format5=>members.includes(format5))&&choices.add(`${trait}/${child}`);for(let format5 of formats2)matchesFormat(format5,trait)&&choices.add(`${trait}/${format5}`)}choices.add(selector);let navigation=`<nav class="format-navigation" aria-label="Format collections" data-i18n-aria-label="Format collections"><label><span data-i18n="Collection">Collection</span><select data-format-path>${[...choices].map(value2=>`<option value="${escapeHtml(value2)}"${value2===selector?" selected":""}${value2?"":' data-i18n="All formats"'}>${escapeHtml(value2||"All formats")}</option>`).join("")}</select></label><code>format/${escapeHtml(selector||"all")}</code></nav>`,content3=renderFormatCollection(site,selector,query);return{title:"Format",main:`<article class="res-page resource-library resource-results">${navigation}${content3}</article>`}}if(rest==="_library"||rest.startsWith("_library/")){let view=rest.slice(8).replace(/^\//,"")||(readManifest(site.root??root4).libraries?.[0]??"urls");return isReferenceLibrary(view)||["codeblocks","dictionary","code"].includes(view)?resourcesMain(site,view):void 0}let all2=siteResources(site),[kind,...tail]=rest===""?[]:rest.split("/"),file=tail.length>0?decodeURIComponent(tail.join("/")):void 0;if(kind==null)return{title:workspaceName(site),main:'<article class="res-page files-page resource-library"><div id="files-manager"></div></article>'};if(!file&&(kind==="dictionary"||kind==="code"))return resourcesMain(site,"codeblocks");if(kind==="schema"&&file){let config=site.subformats?.find(format5=>format5.ext===file);if(!config)return;let title=`${config.ext} \u2014 JSON Schema`,schemaRoot=site.root??root4,content3;try{if(!filesSnapshot(schemaRoot).files.some(item=>item.path===config.schema))throw new Error("Subformat schema is not available in the workspace");let raw=readTextfile(schemaRoot,config.schema),{schema:schema5,context}=compileSubformatSchema(raw,{root:schemaRoot,file:config.schema,domains:site.previews?.domains});content3=jsonSchemaHtml(schema5,context),content3+=`<details><summary data-i18n="JSON text">JSON text</summary>${blocksHtml([{type:"code",lang:"json",lines:raw.split(`
|
|
2616
2618
|
`)}])}</details>`}catch(error){content3=`<p class="err" role="alert">${escapeHtml(error instanceof Error?error.message:String(error))}</p>`}return{title,main:`<article class="res-page json-schema-page"><h1>${escapeHtml(title)}</h1><p><a href="/_files/file/${encodeURIComponent(config.schema)}" data-resource-source="${escapeHtml(config.schema)}">${escapeHtml(config.schema)}</a></p>${content3}</article>`}}if(!file&&(kind==="codeblocks"||isReferenceLibrary(kind)||kind==="_subformats")){let index4=resourceIndex(site.root??root4,site.filePaths??filesSnapshot(site.root??root4).files.map(item=>item.path),site.previews?.domains);return site.workspace?.protocol==="git"&&index4.subformats.length&&setSubformatChanges(root4,index4.subformats),{title:kind==="_subformats"?"Subformats":kind==="codeblocks"?"Format":"Library",main:`<article class="res-page files-page resource-library">${kind==="_subformats"?"":resourceTabs(kind,index4.libraries)}${resourceLibraryHtml(index4,kind==="_subformats"?"subformats":kind,void 0,!1,formatPreview(site,index4.files?.map(item=>item.file)??[]))}</article>`}}if(kind==="file"&&file){let resource=all2.find(item=>item.path===file);if(resource)return resourcesMain(site,`${resource.kind}/${encodeURIComponent(resource.file)}`);let content3=readProjectFile(file,site.root);return content3&&filePage(site,file,content3)}if(!RESOURCE_KINDS.includes(kind))return;let k=kind,crumbs=`<nav class="res-crumbs"><a href="/_files">${workspaceText(site)}</a> \u203A ${file?`<a href="${resourceHref(k)}" data-i18n="${k}">${k}</a> \u203A ${escapeHtml(file)}`:k}</nav>`;if(file==null)return{title:`${k} \u2014 ${workspaceName(site)}`,main:`<article class="res-page">${k==="terms"?"":crumbs}<h1 data-i18n="${k}">${translate("eng",k)}</h1>${k==="terms"?termsHtml(site.ctx.terms,resolveLanguage(site.contentLanguage??site.defaultLang,site.languages),!0):resourceCards(site,all2.filter(r3=>r3.kind===k))}</article>`};let r2=all2.find(x3=>x3.kind===k&&x3.file===file);if(!r2)return;let fig=k==="figures"||k==="html"?site.ctx.figures.get(figureName(r2.path)):void 0,used=resourceUsage(site,r2),snippet=k==="terms"?isTermFile(r2.file)?`[](${termFileUrl(r2.file)})`:void 0:fig?``:void 0,rows=[["path",`<code>${escapeHtml(r2.path)}</code>`],["size",sizeOf(r2.path)],...fig?[["kind",fig.kind]]:[],...fig?.title?[["title",escapeHtml(fig.title)]]:[],...fig?.desc?[["desc",escapeHtml(fig.desc)]]:[],...snippet?[["syntax",`<code class="res-snippet">${escapeHtml(snippet)}</code>`]]:[],[k==="icons"||k==="markdown"?"doc":"used in",used.length===0?'<span class="res-sub" data-i18n="none">none</span>':used.map(e2=>`<a href="/${e2.id}">${escapeHtml(docDisplayName(e2.frontmatter,e2.id))}</a>`).join(", ")]];return{title:`${r2.file} \u2014 Files`,.../\.(?:svg|html|termth|md|markdown)$/i.test(r2.path)?{sourceFile:r2.path}:{},main:`<article class="res-page res-file-page">${crumbs}<h1>${escapeHtml(r2.file)}${download(r2.path)}</h1><div class="res-preview${k==="icons"?" square":""}">${resourcePreview(site,r2)}</div><details class="res-details"><summary data-i18n="File details">File details</summary><dl class="res-dl">${rows.map(([dt2,dd])=>`<dt data-i18n="${dt2}">${dt2}</dt><dd>${dd}</dd>`).join("")}</dl></details></article>`}},figurePage=(site,fig)=>{let title=fig.title??fig.file;return{title,main:docHtml({title},[{type:"figureRef",name:fig.name}],[],site.ctx)}},linkedFilePage=(site,file)=>{let fig=[...site.ctx.figures.values()].find(fig2=>fig2.file===file);if(fig)return figurePage(site,fig);let content3=site.readLinkedFile?site.readLinkedFile(file):readProjectFile(file,site.root);if(!content3)return;let page2=filePage(site,file,content3,site.ctx.downloads&&(site.ctx.downloads.get(file)??`data:application/octet-stream;base64,${content3.toString("base64")}`));return{title:page2.title,main:page2.main.replace(/<nav class="res-crumbs">.*?<\/nav>/,"")}},pageTitle=(mode,title,site)=>mode==="preview"?site.entries.find(entry=>entry.root)?.frontmatter?.title??site.title??title:title===site.title?title:`${title} \u2014 ${site.title??"dooc edit"}`,page=(mode,site,opts)=>{let currentDocument=site.entries.find(entry=>entry.id===opts.currentId),rootPage=site.entries.find(entry=>entry.root),rootJump=rootPage?docHref(site.entries,rootPage.id):"",rootCurrent=currentDocument?.root&&(!opts.currentRes||opts.currentRes==="/"),nav=navGroupsHtml(historicalReadOnly||opts.loading?"preview":mode,site,opts.currentId,opts.currentRes),siteTitle=escapeHtml(site.title??"dooc"),iconImg=`<img id="site-icon" alt=""${site.icon?` src="${svgDataUri(site.icon)}"`:" hidden"}>`,iconVariants=Object.entries(site.iconVariants??{}),tabIcons={"":site.icon,...site.iconVariants},favicons=mode==="preview"?Object.entries(tabIcons).flatMap(([theme,svg])=>svg&&["","light","dark"].includes(theme)?`<link data-document-icon="${theme}" rel="icon" type="image/svg+xml" href="${svgDataUri(squareSvg(svg)??svg)}"${theme?` media="(prefers-color-scheme: ${theme})"`:""}>`:[]).join(`
|
|
2617
2619
|
`):"",iconHtml=iconVariants.length?`<span class="site-icon-variants" data-theme-variants><span data-theme-variant="">${iconImg}</span>${iconVariants.map(([theme,svg])=>`<img data-theme-variant="${escapeHtml(theme)}" alt="" src="${svgDataUri(svg)}" hidden>`).join("")}</span>`:iconImg,siteIcon=`<span id="site-icon-slot"${mode==="edit"?' title="Change site icon" data-i18n-title="Change site icon"':""}>${iconHtml}${DOCS_ICON}${mode==="edit"?'<input type="file" accept=".svg,image/svg+xml" aria-label="Change site icon" data-i18n-aria-label="Change site icon">':""}</span>`,output=opts.publish?.output,script2=js2=>output?`<script src="${escapeHtml(output.asset(js2,"js"))}"><\/script>`:`<script>${inlineScript(js2)}<\/script>`,css=`${fontCss(!!opts.publish)}${CSS2}${mode==="edit"?EDIT_CSS:""}`,stylesheet=output?`<link rel="stylesheet" href="${escapeHtml(output.asset(css,"css"))}">`:`<style>${css}</style>`,self2=output?"'self' ":"",bootScripts=opts.boot!=null?`<script id="boot" type="application/json">${JSON.stringify(opts.boot).replace(/</g,"\\u003c")}<\/script>
|
|
2618
2620
|
<script src="/assets/edit.js"><\/script>
|
package/package.json
CHANGED