cc-viewer 1.8.10 → 1.8.12

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.
Files changed (123) hide show
  1. package/dist/assets/App-DHrbDDV6.js +2 -0
  2. package/dist/assets/MdxEditorPanel-wI6uv35-.js +1 -0
  3. package/dist/assets/{Mobile-Uo_qQRwl.js → Mobile-21VVMV8T.js} +1 -1
  4. package/dist/assets/{ProxyStatsModal-BnPXrvTb.js → ProxyStatsModal-BWmbUCzo.js} +1 -1
  5. package/dist/assets/{_baseUniq-D2aO8mv4.js → _baseUniq-B3e4JaL0.js} +1 -1
  6. package/dist/assets/{arc-DOjcnBTh.js → arc-DnoPn_qY.js} +1 -1
  7. package/dist/assets/architectureDiagram-Q4EWVU46-DrPKTbxH.js +1 -0
  8. package/dist/assets/blockDiagram-DXYQGD6D-CEaO0Vcw.js +1 -0
  9. package/dist/assets/c4Diagram-AHTNJAMY-BLaawFeg.js +1 -0
  10. package/dist/assets/{channel-DUff3FBt.js → channel-DnYR1fF4.js} +1 -1
  11. package/dist/assets/{chunk-4BX2VUAB-CFnsROfz.js → chunk-4BX2VUAB-Bfd4edKZ.js} +1 -1
  12. package/dist/assets/{chunk-4TB4RGXK-C95jMPjB.js → chunk-4TB4RGXK-t2nMQmY7.js} +1 -1
  13. package/dist/assets/{chunk-55IACEB6-CeWf2Y2b.js → chunk-55IACEB6-C6tLOjGX.js} +1 -1
  14. package/dist/assets/{chunk-EDXVE4YY-ClUoTJxv.js → chunk-EDXVE4YY-dWCvxbCb.js} +1 -1
  15. package/dist/assets/{chunk-FMBD7UC4-Dk62kqb8.js → chunk-FMBD7UC4-BHELZLPK.js} +1 -1
  16. package/dist/assets/{chunk-OYMX7WX6-CZuykSsu.js → chunk-OYMX7WX6-C8XTkH1S.js} +1 -1
  17. package/dist/assets/{chunk-QZHKN3VN-DYtx68Um.js → chunk-QZHKN3VN-CD0j6SAs.js} +1 -1
  18. package/dist/assets/{chunk-YZCP3GAM-rLSq0tSC.js → chunk-YZCP3GAM-D4dKfXJJ.js} +1 -1
  19. package/dist/assets/classDiagram-6PBFFD2Q-BecPAAuk.js +1 -0
  20. package/dist/assets/classDiagram-v2-HSJHXN6E-BecPAAuk.js +1 -0
  21. package/dist/assets/clone-B0_ghF3F.js +1 -0
  22. package/dist/assets/cose-bilkent-S5V4N54A-BF2HsiSD.js +1 -0
  23. package/dist/assets/dagre-KV5264BT-f3h967yx.js +1 -0
  24. package/dist/assets/diagram-5BDNPKRD-B9PzHQfh.js +1 -0
  25. package/dist/assets/diagram-G4DWMVQ6-kR953Bqm.js +1 -0
  26. package/dist/assets/diagram-MMDJMWI5-DAewa2eg.js +1 -0
  27. package/dist/assets/diagram-TYMM5635-C8HNTH6I.js +1 -0
  28. package/dist/assets/erDiagram-SMLLAGMA-BQ5P8wWK.js +1 -0
  29. package/dist/assets/flowDiagram-DWJPFMVM-BIpEkrMR.js +1 -0
  30. package/dist/assets/ganttDiagram-T4ZO3ILL-CWqSfB5v.js +1 -0
  31. package/dist/assets/gitGraphDiagram-UUTBAWPF-Ba-9yEbQ.js +1 -0
  32. package/dist/assets/{graph-Bi8xMAuo.js → graph-D3zXKQ6P.js} +1 -1
  33. package/dist/assets/index-Bm3A5VLb.js +1 -0
  34. package/dist/assets/index-C9N0rZ7Z.js +1 -0
  35. package/dist/assets/index-D1yGak8I.css +1 -0
  36. package/dist/assets/index-DClD_EkN.js +1 -0
  37. package/dist/assets/index-DSd5P3WQ.js +1 -0
  38. package/dist/assets/index-DbUpoAFu.js +2 -0
  39. package/dist/assets/index-G3xd-gLo.js +1 -0
  40. package/dist/assets/index-HLrnYsI1.js +1 -0
  41. package/dist/assets/index-Q8wp4Nof.js +1 -0
  42. package/dist/assets/infoDiagram-42DDH7IO-Cxm79ZJR.js +1 -0
  43. package/dist/assets/ishikawaDiagram-UXIWVN3A-Cd0vZP1B.js +1 -0
  44. package/dist/assets/journeyDiagram-VCZTEJTY-B2b57HXk.js +1 -0
  45. package/dist/assets/{jszip.min-x3xOZxY_.js → jszip.min-Bj5uiEb2.js} +1 -1
  46. package/dist/assets/kanban-definition-6JOO6SKY-YCERiUCO.js +1 -0
  47. package/dist/assets/{layout-05qDuweB.js → layout-Do5TlO2U.js} +1 -1
  48. package/dist/assets/{linear-DQEG_N-F.js → linear-BiJNTDgN.js} +1 -1
  49. package/dist/assets/{mermaid.core-DcaXqkk5.js → mermaid.core-Dg0McRZt.js} +2 -2
  50. package/dist/assets/{min-DSpvw5zG.js → min-T51iefht.js} +1 -1
  51. package/dist/assets/mindmap-definition-QFDTVHPH-Cu_GJxY3.js +1 -0
  52. package/dist/assets/pieDiagram-DEJITSTG-DldHHZXi.js +1 -0
  53. package/dist/assets/quadrantDiagram-34T5L4WZ-BzyTPNAJ.js +1 -0
  54. package/dist/assets/requirementDiagram-MS252O5E-C5xxFkvG.js +1 -0
  55. package/dist/assets/sankeyDiagram-XADWPNL6-OxdjoaE1.js +1 -0
  56. package/dist/assets/seqResourceLoaders-9DpRRuAz.js +2 -0
  57. package/dist/assets/{seqResourceLoaders-1EWxJwEP.css → seqResourceLoaders-Ddih0S9q.css} +1 -1
  58. package/dist/assets/sequenceDiagram-FGHM5R23-C7c89uIS.js +1 -0
  59. package/dist/assets/stateDiagram-FHFEXIEX-ssdJnDrO.js +1 -0
  60. package/dist/assets/stateDiagram-v2-QKLJ7IA2-BP-0WClK.js +1 -0
  61. package/dist/assets/timeline-definition-GMOUNBTQ-sWScEpSM.js +1 -0
  62. package/dist/assets/{vendor-antd-FhK5cQx7.js → vendor-antd-DKIytXho.js} +1 -1
  63. package/dist/assets/vendor-codemirror-4qgXq03k.js +1 -0
  64. package/dist/assets/vendor-mdxeditor-D5Z5D9fq.js +2 -0
  65. package/dist/assets/{vendor-qrcode-BAwwP1Nd.js → vendor-qrcode-B7lb5qk1.js} +1 -1
  66. package/dist/assets/vendor-virtuoso-BqoXlbhH.js +1 -0
  67. package/dist/assets/vennDiagram-DHZGUBPP-DNfXR0ge.js +1 -0
  68. package/dist/assets/{wardley-RL74JXVD-Djh5alV9.js → wardley-RL74JXVD-JXd--CRD.js} +1 -1
  69. package/dist/assets/wardleyDiagram-NUSXRM2D-DHmNyVPM.js +1 -0
  70. package/dist/assets/xychartDiagram-5P7HB3ND-CTb0gltZ.js +1 -0
  71. package/dist/index.html +5 -6
  72. package/package.json +1 -1
  73. package/server/lib/skills-api.js +48 -26
  74. package/server/routes/files-content.js +2 -1
  75. package/server/routes/files-fs.js +76 -1
  76. package/server/routes/skills.js +44 -26
  77. package/dist/assets/App-DJIVcbMa.js +0 -2
  78. package/dist/assets/MdxEditorPanel-CTCAo0Gg.js +0 -1
  79. package/dist/assets/architectureDiagram-Q4EWVU46-Drea2H7X.js +0 -1
  80. package/dist/assets/blockDiagram-DXYQGD6D-Bc9eijBD.js +0 -1
  81. package/dist/assets/c4Diagram-AHTNJAMY-D-umzFnM.js +0 -1
  82. package/dist/assets/classDiagram-6PBFFD2Q-DT8RQXlO.js +0 -1
  83. package/dist/assets/classDiagram-v2-HSJHXN6E-DT8RQXlO.js +0 -1
  84. package/dist/assets/clone-_dhVVwEt.js +0 -1
  85. package/dist/assets/cose-bilkent-S5V4N54A-B5H6ewon.js +0 -1
  86. package/dist/assets/dagre-KV5264BT-BO2R2WP7.js +0 -1
  87. package/dist/assets/diagram-5BDNPKRD-Y3GNif-g.js +0 -1
  88. package/dist/assets/diagram-G4DWMVQ6-Du3_TylQ.js +0 -1
  89. package/dist/assets/diagram-MMDJMWI5-DB_Ynyjc.js +0 -1
  90. package/dist/assets/diagram-TYMM5635-_Rfjm82W.js +0 -1
  91. package/dist/assets/erDiagram-SMLLAGMA-D5XhBiiV.js +0 -1
  92. package/dist/assets/flowDiagram-DWJPFMVM-CxWJ7sAQ.js +0 -1
  93. package/dist/assets/ganttDiagram-T4ZO3ILL-D-a8fh00.js +0 -1
  94. package/dist/assets/gitGraphDiagram-UUTBAWPF-q5WMk0Ce.js +0 -1
  95. package/dist/assets/index-3Z3ucdlB.js +0 -1
  96. package/dist/assets/index-BB66PLo6.js +0 -1
  97. package/dist/assets/index-BBEH6Ppx.js +0 -1
  98. package/dist/assets/index-BRtbpMRz.js +0 -1
  99. package/dist/assets/index-BWPHHS6P.js +0 -1
  100. package/dist/assets/index-C3wsDB-y.js +0 -1
  101. package/dist/assets/index-C4Jei4gi.js +0 -2
  102. package/dist/assets/index-D3GEPgde.css +0 -1
  103. package/dist/assets/index-O2Mx9uLd.js +0 -1
  104. package/dist/assets/infoDiagram-42DDH7IO-CE2mUuLF.js +0 -1
  105. package/dist/assets/ishikawaDiagram-UXIWVN3A-C5sNQIVL.js +0 -1
  106. package/dist/assets/journeyDiagram-VCZTEJTY-g7HXOeyX.js +0 -1
  107. package/dist/assets/kanban-definition-6JOO6SKY-D3Mus6hc.js +0 -1
  108. package/dist/assets/mindmap-definition-QFDTVHPH-DomUIop7.js +0 -1
  109. package/dist/assets/pieDiagram-DEJITSTG-COTLcC5G.js +0 -1
  110. package/dist/assets/quadrantDiagram-34T5L4WZ-DMg8C3Up.js +0 -1
  111. package/dist/assets/requirementDiagram-MS252O5E-DF9beYd7.js +0 -1
  112. package/dist/assets/sankeyDiagram-XADWPNL6-MvERK2UP.js +0 -1
  113. package/dist/assets/seqResourceLoaders-DfTPNrje.js +0 -2
  114. package/dist/assets/sequenceDiagram-FGHM5R23-B8k_nyzc.js +0 -1
  115. package/dist/assets/stateDiagram-FHFEXIEX-D-9fTYas.js +0 -1
  116. package/dist/assets/stateDiagram-v2-QKLJ7IA2-CO0tv8rD.js +0 -1
  117. package/dist/assets/timeline-definition-GMOUNBTQ-CbK1g9CO.js +0 -1
  118. package/dist/assets/vendor-codemirror-DL3yyKRQ.js +0 -1
  119. package/dist/assets/vendor-mdxeditor-DgyrvHzS.js +0 -2
  120. package/dist/assets/vendor-virtuoso-B_7lc2Ot.js +0 -1
  121. package/dist/assets/vennDiagram-DHZGUBPP-DYjGtMA5.js +0 -1
  122. package/dist/assets/wardleyDiagram-NUSXRM2D-al50Jlxp.js +0 -1
  123. package/dist/assets/xychartDiagram-5P7HB3ND-Bl969-3U.js +0 -1
@@ -0,0 +1 @@
1
+ var _a;import{s as setAccDescription,g as getAccDescription,q as getDiagramTitle,p as setDiagramTitle,a as getAccTitle,b as setAccTitle,_ as __name,l as log,H as selectSvgElement,e as configureSvgSize,y as clear,c as getConfig2$1,i as sanitizeText}from"./mermaid.core-Dg0McRZt.js";import{p as populateCommonDb}from"./chunk-4BX2VUAB-Bfd4edKZ.js";import{p as parse}from"./wardley-RL74JXVD-JXd--CRD.js";import"./vendor-mdxeditor-D5Z5D9fq.js";import"./vendor-antd-DKIytXho.js";import"./vendor-codemirror-4qgXq03k.js";import"./vendor-markdown-DOJHsAxX.js";import"./min-T51iefht.js";import"./_baseUniq-B3e4JaL0.js";var toPercent=__name((value,context)=>{const normalized=value<=1?100*value:value;if(normalized<0||normalized>100)throw new Error(`${context} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${value}`);return normalized},"toPercent"),toCoordinates=__name((visibility,evolution,context)=>({x:toPercent(evolution,`${context} evolution`),y:toPercent(visibility,`${context} visibility`)}),"toCoordinates"),getFlowFromPort=__name(port=>{if(port)return"+<>"===port?"bidirectional":"+<"===port?"backward":"+>"===port?"forward":void 0},"getFlowFromPort"),extractFlowFromArrow=__name(arrow=>{if(!(null==arrow?void 0:arrow.startsWith("+")))return{};const labelMatch=/^\+'([^']*)'/.exec(arrow),flowLabel=null==labelMatch?void 0:labelMatch[1];return arrow.includes("<>")?{flow:"bidirectional",label:flowLabel}:arrow.includes("<")?{flow:"backward",label:flowLabel}:arrow.includes(">")?{flow:"forward",label:flowLabel}:{label:flowLabel}},"extractFlowFromArrow"),populateDb=__name((ast,db)=>{if(populateCommonDb(ast,db),ast.size&&db.setSize(ast.size.width,ast.size.height),ast.evolution){const stages=ast.evolution.stages.map(stage=>stage.secondName?`${stage.name.trim()} / ${stage.secondName.trim()}`:stage.name.trim()),stageBoundaries=ast.evolution.stages.filter(stage=>void 0!==stage.boundary).map(stage=>stage.boundary);db.updateAxes({stages:stages,stageBoundaries:stageBoundaries})}if(ast.anchors.forEach(anchor=>{const coords=toCoordinates(anchor.visibility,anchor.evolution,`Anchor "${anchor.name}"`);db.addNode(anchor.name,anchor.name,coords.x,coords.y,"anchor")}),ast.components.forEach(component=>{var _a2;const coords=toCoordinates(component.visibility,component.evolution,`Component "${component.name}"`),labelOffsetX=component.label?(component.label.negX?-1:1)*component.label.offsetX:void 0,labelOffsetY=component.label?(component.label.negY?-1:1)*component.label.offsetY:void 0,sourceStrategy=null==(_a2=component.decorator)?void 0:_a2.strategy;db.addNode(component.name,component.name,coords.x,coords.y,"component",labelOffsetX,labelOffsetY,component.inertia,sourceStrategy)}),ast.notes.forEach(note=>{const coords=toCoordinates(note.visibility,note.evolution,`Note "${note.text}"`);db.addNote(note.text,coords.x,coords.y)}),ast.pipelines.forEach(pipeline=>{const parentNode=db.getNode(pipeline.parent);if(!parentNode||"number"!=typeof parentNode.y)throw new Error(`Pipeline "${pipeline.parent}" must reference an existing component with coordinates.`);const parentY=parentNode.y;db.startPipeline(pipeline.parent),pipeline.components.forEach(component=>{const componentId=`${pipeline.parent}_${component.name}`,labelOffsetX=component.label?(component.label.negX?-1:1)*component.label.offsetX:void 0,labelOffsetY=component.label?(component.label.negY?-1:1)*component.label.offsetY:void 0,x=toPercent(component.evolution,`Pipeline component "${component.name}" evolution`);db.addNode(componentId,component.name,x,parentY,"pipeline-component",labelOffsetX,labelOffsetY),db.addPipelineComponent(pipeline.parent,componentId)})}),ast.links.forEach(link=>{const isDashed=!!link.arrow&&(link.arrow.includes("-.->")||link.arrow.includes(".-."));let flow=getFlowFromPort(link.fromPort)??getFlowFromPort(link.toPort);const{flow:arrowFlow,label:flowLabel}=extractFlowFromArrow(link.arrow);!flow&&arrowFlow&&(flow=arrowFlow);const annotation=link.linkLabel,label=flowLabel??annotation;db.addLink(link.from,link.to,isDashed,label,flow)}),ast.evolves.forEach(evolve=>{const node=db.getNode(evolve.component);if(void 0!==(null==node?void 0:node.y)){const target=toPercent(evolve.target,`Evolve target for "${evolve.component}"`);db.addTrend(evolve.component,target,node.y)}}),ast.annotations.length>0){const annotationsBox=ast.annotations[0],coords=toCoordinates(annotationsBox.x,annotationsBox.y,"Annotations box");db.setAnnotationsBox(coords.x,coords.y)}ast.annotation.forEach(annotation=>{const coords=toCoordinates(annotation.x,annotation.y,`Annotation ${annotation.number}`);db.addAnnotation(annotation.number,[{x:coords.x,y:coords.y}],annotation.text)}),ast.accelerators.forEach(accelerator=>{const coords=toCoordinates(accelerator.x,accelerator.y,`Accelerator "${accelerator.name}"`);db.addAccelerator(accelerator.name,coords.x,coords.y)}),ast.deaccelerators.forEach(deaccelerator=>{const coords=toCoordinates(deaccelerator.x,deaccelerator.y,`Deaccelerator "${deaccelerator.name}"`);db.addDeaccelerator(deaccelerator.name,coords.x,coords.y)})},"populateDb"),parser={parser:{yy:void 0},parse:__name(async input=>{var _a2;const ast=await parse("wardley",input);log.debug(ast);const db=null==(_a2=parser.parser)?void 0:_a2.yy;if(!db||"function"!=typeof db.addNode)throw new Error("parser.parser?.yy was not a WardleyDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");populateDb(ast,db)},"parse")},builder=new(__name(_a=class{constructor(){this.nodes=new Map,this.links=[],this.trends=new Map,this.pipelines=new Map,this.annotations=[],this.notes=[],this.accelerators=[],this.deaccelerators=[],this.axes={}}addNode(node){const existing=this.nodes.get(node.id)??{id:node.id,label:node.label},merged={...existing,...node,className:node.className??existing.className,labelOffsetX:node.labelOffsetX??existing.labelOffsetX,labelOffsetY:node.labelOffsetY??existing.labelOffsetY};this.nodes.set(node.id,merged)}addLink(link){this.links.push(link)}addTrend(trend){this.trends.set(trend.nodeId,trend)}startPipeline(nodeId){this.pipelines.set(nodeId,{nodeId:nodeId,componentIds:[]});const node=this.nodes.get(nodeId);node&&(node.isPipelineParent=!0)}addPipelineComponent(pipelineNodeId,componentId){const pipeline=this.pipelines.get(pipelineNodeId);pipeline&&pipeline.componentIds.push(componentId);const node=this.nodes.get(componentId);node&&(node.inPipeline=!0)}addAnnotation(annotation){this.annotations.push(annotation)}addNote(note){this.notes.push(note)}addAccelerator(accelerator){this.accelerators.push(accelerator)}addDeaccelerator(deaccelerator){this.deaccelerators.push(deaccelerator)}setAnnotationsBox(x,y){this.annotationsBox={x:x,y:y}}setAxes(partial){this.axes={...this.axes,...partial}}setSize(width,height){this.size={width:width,height:height}}getNode(id){return this.nodes.get(id)}build(){const nodes=[];for(const node of this.nodes.values()){if("number"!=typeof node.x||"number"!=typeof node.y)throw new Error(`Node "${node.label}" is missing coordinates`);nodes.push(node)}return{nodes:nodes,links:[...this.links],trends:[...this.trends.values()],pipelines:[...this.pipelines.values()],annotations:[...this.annotations],notes:[...this.notes],accelerators:[...this.accelerators],deaccelerators:[...this.deaccelerators],annotationsBox:this.annotationsBox,axes:{...this.axes},size:this.size}}clear(){this.nodes.clear(),this.links=[],this.trends.clear(),this.pipelines.clear(),this.annotations=[],this.notes=[],this.accelerators=[],this.deaccelerators=[],this.annotationsBox=void 0,this.axes={},this.size=void 0}},"WardleyBuilder"),_a);function textSanitizer(text){const config=getConfig2$1();return sanitizeText(text.trim(),config)}function getConfig2(){return getConfig2$1()["wardley-beta"]}function addNode(id,label,x,y,className,labelOffsetX,labelOffsetY,inertia,sourceStrategy){builder.addNode({id:id,label:textSanitizer(label),x:x,y:y,className:className,labelOffsetX:labelOffsetX,labelOffsetY:labelOffsetY,inertia:inertia,sourceStrategy:sourceStrategy})}function addLink(sourceId,targetId,dashed=!1,label,flow){builder.addLink({source:sourceId,target:targetId,dashed:dashed,label:label,flow:flow})}function addTrend(nodeId,targetX,targetY){builder.addTrend({nodeId:nodeId,targetX:targetX,targetY:targetY})}function addAnnotation(number,coordinates,text){builder.addAnnotation({number:number,coordinates:coordinates,text:text?textSanitizer(text):void 0})}function addNote(text,x,y){builder.addNote({text:textSanitizer(text),x:x,y:y})}function addAccelerator(name,x,y){builder.addAccelerator({name:textSanitizer(name),x:x,y:y})}function addDeaccelerator(name,x,y){builder.addDeaccelerator({name:textSanitizer(name),x:x,y:y})}function setAnnotationsBox(x,y){builder.setAnnotationsBox(x,y)}function setSize(width,height){builder.setSize(width,height)}function startPipeline(nodeId){builder.startPipeline(nodeId)}function addPipelineComponent(pipelineNodeId,componentId){builder.addPipelineComponent(pipelineNodeId,componentId)}function updateAxes(partial){const sanitized={};partial.xLabel&&(sanitized.xLabel=textSanitizer(partial.xLabel)),partial.yLabel&&(sanitized.yLabel=textSanitizer(partial.yLabel)),partial.stages&&(sanitized.stages=partial.stages.map(stage=>textSanitizer(stage))),partial.stageBoundaries&&(sanitized.stageBoundaries=partial.stageBoundaries),builder.setAxes(sanitized)}function getNode(id){return builder.getNode(id)}function getWardleyData(){return builder.build()}function clear2(){builder.clear(),clear()}__name(textSanitizer,"textSanitizer"),__name(getConfig2,"getConfig"),__name(addNode,"addNode"),__name(addLink,"addLink"),__name(addTrend,"addTrend"),__name(addAnnotation,"addAnnotation"),__name(addNote,"addNote"),__name(addAccelerator,"addAccelerator"),__name(addDeaccelerator,"addDeaccelerator"),__name(setAnnotationsBox,"setAnnotationsBox"),__name(setSize,"setSize"),__name(startPipeline,"startPipeline"),__name(addPipelineComponent,"addPipelineComponent"),__name(updateAxes,"updateAxes"),__name(getNode,"getNode"),__name(getWardleyData,"getWardleyData"),__name(clear2,"clear");var wardleyDb_default={getConfig:getConfig2,addNode:addNode,addLink:addLink,addTrend:addTrend,addAnnotation:addAnnotation,addNote:addNote,addAccelerator:addAccelerator,addDeaccelerator:addDeaccelerator,setAnnotationsBox:setAnnotationsBox,setSize:setSize,startPipeline:startPipeline,addPipelineComponent:addPipelineComponent,updateAxes:updateAxes,getNode:getNode,getWardleyData:getWardleyData,clear:clear2,setAccTitle:setAccTitle,getAccTitle:getAccTitle,setDiagramTitle:setDiagramTitle,getDiagramTitle:getDiagramTitle,getAccDescription:getAccDescription,setAccDescription:setAccDescription},DEFAULT_STAGES=["Genesis","Custom Built","Product","Commodity"],getTheme=__name(()=>{var _a2,_b,_c,_d,_e,_f,_g,_h,_i,_j,_k,_l;const{themeVariables:themeVariables}=getConfig2$1();return{backgroundColor:(null==(_a2=themeVariables.wardley)?void 0:_a2.backgroundColor)??themeVariables.background??"#fff",axisColor:(null==(_b=themeVariables.wardley)?void 0:_b.axisColor)??"#000",axisTextColor:(null==(_c=themeVariables.wardley)?void 0:_c.axisTextColor)??themeVariables.primaryTextColor??"#222",gridColor:(null==(_d=themeVariables.wardley)?void 0:_d.gridColor)??"rgba(100, 100, 100, 0.2)",componentFill:(null==(_e=themeVariables.wardley)?void 0:_e.componentFill)??"#fff",componentStroke:(null==(_f=themeVariables.wardley)?void 0:_f.componentStroke)??"#000",componentLabelColor:(null==(_g=themeVariables.wardley)?void 0:_g.componentLabelColor)??themeVariables.primaryTextColor??"#222",linkStroke:(null==(_h=themeVariables.wardley)?void 0:_h.linkStroke)??"#000",evolutionStroke:(null==(_i=themeVariables.wardley)?void 0:_i.evolutionStroke)??"#dc3545",annotationStroke:(null==(_j=themeVariables.wardley)?void 0:_j.annotationStroke)??"#000",annotationTextColor:(null==(_k=themeVariables.wardley)?void 0:_k.annotationTextColor)??themeVariables.primaryTextColor??"#222",annotationFill:(null==(_l=themeVariables.wardley)?void 0:_l.annotationFill)??themeVariables.background??"#fff"}},"getTheme"),getConfigValues=__name(()=>{const wardleyConfig=getConfig2$1()["wardley-beta"];return{width:(null==wardleyConfig?void 0:wardleyConfig.width)??900,height:(null==wardleyConfig?void 0:wardleyConfig.height)??600,padding:(null==wardleyConfig?void 0:wardleyConfig.padding)??48,nodeRadius:(null==wardleyConfig?void 0:wardleyConfig.nodeRadius)??6,nodeLabelOffset:(null==wardleyConfig?void 0:wardleyConfig.nodeLabelOffset)??8,axisFontSize:(null==wardleyConfig?void 0:wardleyConfig.axisFontSize)??12,labelFontSize:(null==wardleyConfig?void 0:wardleyConfig.labelFontSize)??10,showGrid:(null==wardleyConfig?void 0:wardleyConfig.showGrid)??!1,useMaxWidth:(null==wardleyConfig?void 0:wardleyConfig.useMaxWidth)??!0}},"getConfigValues"),diagram={parser:parser,db:wardleyDb_default,renderer:{draw:__name((text,id,_version,diagObj)=>{var _a2,_b;log.debug("Rendering Wardley map\n"+text);const configValues=getConfigValues(),theme=getTheme(),squareSize=1.6*configValues.nodeRadius,db=diagObj.db,data=db.getWardleyData(),title=db.getDiagramTitle(),width=(null==(_a2=data.size)?void 0:_a2.width)??configValues.width,height=(null==(_b=data.size)?void 0:_b.height)??configValues.height,svg=selectSvgElement(id);svg.selectAll("*").remove(),configureSvgSize(svg,height,width,configValues.useMaxWidth),svg.attr("viewBox",`0 0 ${width} ${height}`);const root=svg.append("g").attr("class","wardley-map"),defs=svg.append("defs");defs.append("marker").attr("id",`arrow-${id}`).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",6).attr("markerHeight",6).attr("orient","auto-start-reverse").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("fill",theme.evolutionStroke).attr("stroke","none"),defs.append("marker").attr("id",`link-arrow-end-${id}`).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("fill",theme.linkStroke).attr("stroke","none"),defs.append("marker").attr("id",`link-arrow-start-${id}`).attr("viewBox","0 0 10 10").attr("refX",1).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("path").attr("d","M 10 0 L 0 5 L 10 10 z").attr("fill",theme.linkStroke).attr("stroke","none"),root.append("rect").attr("class","wardley-background").attr("width",width).attr("height",height).attr("fill",theme.backgroundColor);const chartWidth=width-2*configValues.padding,chartHeight=height-2*configValues.padding;title&&root.append("text").attr("class","wardley-title").attr("x",width/2).attr("y",configValues.padding/2).attr("fill",theme.axisTextColor).attr("font-size",1.05*configValues.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").attr("dominant-baseline","middle").text(title);const projectX=__name(value=>configValues.padding+value/100*chartWidth,"projectX"),projectY=__name(value=>height-configValues.padding-value/100*chartHeight,"projectY"),axisGroup=root.append("g").attr("class","wardley-axes");axisGroup.append("line").attr("x1",configValues.padding).attr("x2",width-configValues.padding).attr("y1",height-configValues.padding).attr("y2",height-configValues.padding).attr("stroke",theme.axisColor).attr("stroke-width",1),axisGroup.append("line").attr("x1",configValues.padding).attr("x2",configValues.padding).attr("y1",configValues.padding).attr("y2",height-configValues.padding).attr("stroke",theme.axisColor).attr("stroke-width",1);const xLabel=data.axes.xLabel??"Evolution",yLabel=data.axes.yLabel??"Visibility";axisGroup.append("text").attr("class","wardley-axis-label wardley-axis-label-x").attr("x",configValues.padding+chartWidth/2).attr("y",height-configValues.padding/4).attr("fill",theme.axisTextColor).attr("font-size",configValues.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").text(xLabel),axisGroup.append("text").attr("class","wardley-axis-label wardley-axis-label-y").attr("x",configValues.padding/3).attr("y",configValues.padding+chartHeight/2).attr("fill",theme.axisTextColor).attr("font-size",configValues.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").attr("transform",`rotate(-90 ${configValues.padding/3} ${configValues.padding+chartHeight/2})`).text(yLabel);const stages=data.axes.stages&&data.axes.stages.length>0?data.axes.stages:DEFAULT_STAGES;if(stages.length>0){const stageGroup=root.append("g").attr("class","wardley-stages"),boundaries=data.axes.stageBoundaries,stagePositions=[];if(boundaries&&boundaries.length===stages.length){let prevBoundary=0;boundaries.forEach(boundary=>{stagePositions.push({start:prevBoundary,end:boundary}),prevBoundary=boundary})}else{const stageWidth=1/stages.length;stages.forEach((_,index)=>{stagePositions.push({start:index*stageWidth,end:(index+1)*stageWidth})})}stages.forEach((stage,index)=>{const pos=stagePositions[index],startX=configValues.padding+pos.start*chartWidth,centerX=(startX+(configValues.padding+pos.end*chartWidth))/2;index>0&&stageGroup.append("line").attr("x1",startX).attr("x2",startX).attr("y1",configValues.padding).attr("y2",height-configValues.padding).attr("stroke","#000").attr("stroke-width",1).attr("stroke-dasharray","5 5").attr("opacity",.8),stageGroup.append("text").attr("class","wardley-stage-label").attr("x",centerX).attr("y",height-configValues.padding/1.5).attr("fill",theme.axisTextColor).attr("font-size",configValues.axisFontSize-2).attr("text-anchor","middle").text(stage)})}if(configValues.showGrid){const gridGroup=root.append("g").attr("class","wardley-grid");for(let i=1;i<4;i++){const ratio=i/4,x=configValues.padding+chartWidth*ratio;gridGroup.append("line").attr("x1",x).attr("x2",x).attr("y1",configValues.padding).attr("y2",height-configValues.padding).attr("stroke",theme.gridColor).attr("stroke-dasharray","2 6"),gridGroup.append("line").attr("x1",configValues.padding).attr("x2",width-configValues.padding).attr("y1",height-configValues.padding-chartHeight*ratio).attr("y2",height-configValues.padding-chartHeight*ratio).attr("stroke",theme.gridColor).attr("stroke-dasharray","2 6")}}const positions=new Map;if(data.nodes.forEach(node=>{positions.set(node.id,{x:projectX(node.x),y:projectY(node.y),node:node})}),data.pipelines.length>0){const pipelineGroup=root.append("g").attr("class","wardley-pipelines"),pipelineLinksGroup=root.append("g").attr("class","wardley-pipeline-links");data.pipelines.forEach(pipeline=>{if(0===pipeline.componentIds.length)return;const sortedComponents=pipeline.componentIds.map(id2=>({id:id2,pos:positions.get(id2),node:data.nodes.find(n=>n.id===id2)})).filter(c=>c.pos&&c.node).sort((a,b)=>a.node.x-b.node.x);for(let i=0;i<sortedComponents.length-1;i++){const current=sortedComponents[i],next=sortedComponents[i+1];pipelineLinksGroup.append("line").attr("class","wardley-pipeline-evolution-link").attr("x1",current.pos.x).attr("y1",current.pos.y).attr("x2",next.pos.x).attr("y2",next.pos.y).attr("stroke",theme.linkStroke).attr("stroke-width",1).attr("stroke-dasharray","4 4")}let minX=1/0,maxX=-1/0,y=0;if(pipeline.componentIds.forEach(componentId=>{const pos=positions.get(componentId);pos&&(minX=Math.min(minX,pos.x),maxX=Math.max(maxX,pos.x),y=pos.y)}),minX!==1/0&&maxX!==-1/0){const padding=15,height2=4*configValues.nodeRadius,boxTop=y-height2/2,parentPos=positions.get(pipeline.nodeId);if(parentPos){const centerX=(minX+maxX)/2;parentPos.x=centerX,parentPos.y=boxTop-squareSize/6}pipelineGroup.append("rect").attr("class","wardley-pipeline-box").attr("x",minX-padding).attr("y",boxTop).attr("width",maxX-minX+2*padding).attr("height",height2).attr("fill","none").attr("stroke",theme.axisColor).attr("stroke-width",1.5).attr("rx",4).attr("ry",4)}})}const linksGroup=root.append("g").attr("class","wardley-links"),pipelineMap=new Map;data.pipelines.forEach(pipeline=>{pipelineMap.set(pipeline.nodeId,new Set(pipeline.componentIds))});const validLinks=data.links.filter(link=>{if(!positions.has(link.source)||!positions.has(link.target))return!1;const pipelineComponents=pipelineMap.get(link.target);return!(null==pipelineComponents?void 0:pipelineComponents.has(link.source))});linksGroup.selectAll("line").data(validLinks).enter().append("line").attr("class",link=>"wardley-link"+(link.dashed?" wardley-link--dashed":"")).attr("x1",link=>{const sourcePos=positions.get(link.source),targetPos=positions.get(link.target),radius=data.nodes.find(n=>n.id===link.source).isPipelineParent?squareSize/Math.sqrt(2):configValues.nodeRadius,dx=targetPos.x-sourcePos.x,dy=targetPos.y-sourcePos.y,distance=Math.sqrt(dx*dx+dy*dy);return sourcePos.x+dx/distance*radius}).attr("y1",link=>{const sourcePos=positions.get(link.source),targetPos=positions.get(link.target),radius=data.nodes.find(n=>n.id===link.source).isPipelineParent?squareSize/Math.sqrt(2):configValues.nodeRadius,dx=targetPos.x-sourcePos.x,dy=targetPos.y-sourcePos.y,distance=Math.sqrt(dx*dx+dy*dy);return sourcePos.y+dy/distance*radius}).attr("x2",link=>{const sourcePos=positions.get(link.source),targetPos=positions.get(link.target),radius=data.nodes.find(n=>n.id===link.target).isPipelineParent?squareSize/Math.sqrt(2):configValues.nodeRadius,dx=sourcePos.x-targetPos.x,dy=sourcePos.y-targetPos.y,distance=Math.sqrt(dx*dx+dy*dy);return targetPos.x+dx/distance*radius}).attr("y2",link=>{const sourcePos=positions.get(link.source),targetPos=positions.get(link.target),radius=data.nodes.find(n=>n.id===link.target).isPipelineParent?squareSize/Math.sqrt(2):configValues.nodeRadius,dx=sourcePos.x-targetPos.x,dy=sourcePos.y-targetPos.y,distance=Math.sqrt(dx*dx+dy*dy);return targetPos.y+dy/distance*radius}).attr("stroke",theme.linkStroke).attr("stroke-width",1).attr("stroke-dasharray",link=>link.dashed?"6 6":null).attr("marker-end",link=>"forward"===link.flow||"bidirectional"===link.flow?`url(#link-arrow-end-${id})`:null).attr("marker-start",link=>"backward"===link.flow||"bidirectional"===link.flow?`url(#link-arrow-start-${id})`:null),linksGroup.selectAll("text").data(validLinks.filter(link=>link.label)).enter().append("text").attr("class","wardley-link-label").attr("x",link=>{const sourcePos=positions.get(link.source),targetPos=positions.get(link.target),midX=(sourcePos.x+targetPos.x)/2,dy=targetPos.y-sourcePos.y,dx=targetPos.x-sourcePos.x;return midX+8*(dy/Math.sqrt(dx*dx+dy*dy))}).attr("y",link=>{const sourcePos=positions.get(link.source),targetPos=positions.get(link.target),midY=(sourcePos.y+targetPos.y)/2,dx=targetPos.x-sourcePos.x,dy=targetPos.y-sourcePos.y;return midY+8*(-dx/Math.sqrt(dx*dx+dy*dy))}).attr("fill",theme.axisTextColor).attr("font-size",configValues.labelFontSize).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("transform",link=>{const sourcePos=positions.get(link.source),targetPos=positions.get(link.target),midX=(sourcePos.x+targetPos.x)/2,midY=(sourcePos.y+targetPos.y)/2,dx=targetPos.x-sourcePos.x,dy=targetPos.y-sourcePos.y,distance=Math.sqrt(dx*dx+dy*dy),labelX=midX+8*(dy/distance),labelY=midY+8*(-dx/distance);let angle=180*Math.atan2(dy,dx)/Math.PI;return(angle>90||angle<-90)&&(angle+=180),`rotate(${angle} ${labelX} ${labelY})`}).text(link=>link.label);const trendGroup=root.append("g").attr("class","wardley-trends"),trendsWithPositions=data.trends.map(trend=>{const origin=positions.get(trend.nodeId);if(!origin)return null;const targetX=projectX(trend.targetX),targetY=projectY(trend.targetY),dx=targetX-origin.x,dy=targetY-origin.y,distance=Math.sqrt(dx*dx+dy*dy),shortenBy=configValues.nodeRadius+2;return{origin:origin,targetX:targetX,targetY:targetY,adjustedX2:distance>shortenBy?targetX-dx/distance*shortenBy:targetX,adjustedY2:distance>shortenBy?targetY-dy/distance*shortenBy:targetY}}).filter(trend=>null!==trend);trendGroup.selectAll("line").data(trendsWithPositions).enter().append("line").attr("class","wardley-trend").attr("x1",trend=>trend.origin.x).attr("y1",trend=>trend.origin.y).attr("x2",trend=>trend.adjustedX2).attr("y2",trend=>trend.adjustedY2).attr("stroke",theme.evolutionStroke).attr("stroke-width",1).attr("stroke-dasharray","4 4").attr("marker-end",`url(#arrow-${id})`);const nodeEnter=root.append("g").attr("class","wardley-nodes").selectAll("g").data(data.nodes).enter().append("g").attr("class",node=>["wardley-node",node.className?`wardley-node--${node.className}`:""].filter(Boolean).join(" "));nodeEnter.filter(node=>"outsource"===node.sourceStrategy).append("circle").attr("class","wardley-outsource-overlay").attr("cx",node=>positions.get(node.id).x).attr("cy",node=>positions.get(node.id).y).attr("r",2*configValues.nodeRadius).attr("fill","#666").attr("stroke",theme.componentStroke).attr("stroke-width",1),nodeEnter.filter(node=>"buy"===node.sourceStrategy).append("circle").attr("class","wardley-buy-overlay").attr("cx",node=>positions.get(node.id).x).attr("cy",node=>positions.get(node.id).y).attr("r",2*configValues.nodeRadius).attr("fill","#ccc").attr("stroke",theme.componentStroke).attr("stroke-width",1),nodeEnter.filter(node=>"build"===node.sourceStrategy).append("circle").attr("class","wardley-build-overlay").attr("cx",node=>positions.get(node.id).x).attr("cy",node=>positions.get(node.id).y).attr("r",2*configValues.nodeRadius).attr("fill","#eee").attr("stroke","#000").attr("stroke-width",1);const marketNodes=nodeEnter.filter(node=>"market"===node.sourceStrategy);marketNodes.append("circle").attr("class","wardley-market-overlay").attr("cx",node=>positions.get(node.id).x).attr("cy",node=>positions.get(node.id).y).attr("r",2*configValues.nodeRadius).attr("fill","white").attr("stroke",theme.componentStroke).attr("stroke-width",1),nodeEnter.filter(node=>!node.isPipelineParent&&"market"!==node.sourceStrategy&&"anchor"!==node.className).append("circle").attr("cx",node=>positions.get(node.id).x).attr("cy",node=>positions.get(node.id).y).attr("r",configValues.nodeRadius).attr("fill",theme.componentFill).attr("stroke",theme.componentStroke).attr("stroke-width",1);const smallCircleRadius=.7*configValues.nodeRadius,triangleRadius=1.2*configValues.nodeRadius;if(marketNodes.append("line").attr("class","wardley-market-line").attr("x1",node=>positions.get(node.id).x).attr("y1",node=>positions.get(node.id).y-triangleRadius).attr("x2",node=>positions.get(node.id).x-triangleRadius*Math.cos(Math.PI/6)).attr("y2",node=>positions.get(node.id).y+triangleRadius*Math.sin(Math.PI/6)).attr("stroke",theme.componentStroke).attr("stroke-width",1),marketNodes.append("line").attr("class","wardley-market-line").attr("x1",node=>positions.get(node.id).x-triangleRadius*Math.cos(Math.PI/6)).attr("y1",node=>positions.get(node.id).y+triangleRadius*Math.sin(Math.PI/6)).attr("x2",node=>positions.get(node.id).x+triangleRadius*Math.cos(Math.PI/6)).attr("y2",node=>positions.get(node.id).y+triangleRadius*Math.sin(Math.PI/6)).attr("stroke",theme.componentStroke).attr("stroke-width",1),marketNodes.append("line").attr("class","wardley-market-line").attr("x1",node=>positions.get(node.id).x+triangleRadius*Math.cos(Math.PI/6)).attr("y1",node=>positions.get(node.id).y+triangleRadius*Math.sin(Math.PI/6)).attr("x2",node=>positions.get(node.id).x).attr("y2",node=>positions.get(node.id).y-triangleRadius).attr("stroke",theme.componentStroke).attr("stroke-width",1),marketNodes.append("circle").attr("class","wardley-market-dot").attr("cx",node=>positions.get(node.id).x).attr("cy",node=>positions.get(node.id).y-triangleRadius).attr("r",smallCircleRadius).attr("fill","white").attr("stroke",theme.componentStroke).attr("stroke-width",2),marketNodes.append("circle").attr("class","wardley-market-dot").attr("cx",node=>positions.get(node.id).x-triangleRadius*Math.cos(Math.PI/6)).attr("cy",node=>positions.get(node.id).y+triangleRadius*Math.sin(Math.PI/6)).attr("r",smallCircleRadius).attr("fill","white").attr("stroke",theme.componentStroke).attr("stroke-width",2),marketNodes.append("circle").attr("class","wardley-market-dot").attr("cx",node=>positions.get(node.id).x+triangleRadius*Math.cos(Math.PI/6)).attr("cy",node=>positions.get(node.id).y+triangleRadius*Math.sin(Math.PI/6)).attr("r",smallCircleRadius).attr("fill","white").attr("stroke",theme.componentStroke).attr("stroke-width",2),nodeEnter.filter(node=>!0===node.isPipelineParent).append("rect").attr("x",node=>positions.get(node.id).x-squareSize/2).attr("y",node=>positions.get(node.id).y-squareSize/2).attr("width",squareSize).attr("height",squareSize).attr("fill",theme.componentFill).attr("stroke",theme.componentStroke).attr("stroke-width",1),nodeEnter.filter(node=>!0===node.inertia).append("line").attr("class","wardley-inertia").attr("x1",node=>{const pos=positions.get(node.id);let offset=node.isPipelineParent?squareSize/2+15:configValues.nodeRadius+15;return node.sourceStrategy&&(offset+=configValues.nodeRadius+10),pos.x+offset}).attr("y1",node=>{const pos=positions.get(node.id),lineHeight=node.isPipelineParent?squareSize:2*configValues.nodeRadius;return pos.y-lineHeight/2}).attr("x2",node=>{const pos=positions.get(node.id);let offset=node.isPipelineParent?squareSize/2+15:configValues.nodeRadius+15;return node.sourceStrategy&&(offset+=configValues.nodeRadius+10),pos.x+offset}).attr("y2",node=>{const pos=positions.get(node.id),lineHeight=node.isPipelineParent?squareSize:2*configValues.nodeRadius;return pos.y+lineHeight/2}).attr("stroke",theme.componentStroke).attr("stroke-width",6),nodeEnter.append("text").attr("x",node=>{const pos=positions.get(node.id);if("anchor"===node.className)return void 0!==node.labelOffsetX?pos.x+node.labelOffsetX:pos.x;let defaultOffset=configValues.nodeLabelOffset;node.sourceStrategy&&void 0===node.labelOffsetX&&(defaultOffset+=10);const customOffset=node.labelOffsetX??defaultOffset;return pos.x+customOffset}).attr("y",node=>{const pos=positions.get(node.id);if("anchor"===node.className)return void 0!==node.labelOffsetY?pos.y+node.labelOffsetY:pos.y-3;let defaultOffset=-configValues.nodeLabelOffset;node.sourceStrategy&&void 0===node.labelOffsetY&&(defaultOffset-=10);const customOffset=node.labelOffsetY??defaultOffset;return pos.y+customOffset}).attr("class","wardley-node-label").attr("fill",node=>"evolved"===node.className?theme.evolutionStroke:"anchor"===node.className?"#000":theme.componentLabelColor).attr("font-size",configValues.labelFontSize).attr("font-weight",node=>"anchor"===node.className?"bold":"normal").attr("text-anchor",node=>"anchor"===node.className?"middle":"start").attr("dominant-baseline",node=>"anchor"===node.className?"middle":"auto").text(node=>node.label),data.annotations.length>0){const annotationsGroup=root.append("g").attr("class","wardley-annotations");if(data.annotations.forEach(annotation=>{const projectedCoords=annotation.coordinates.map(coord=>({x:projectX(coord.x),y:projectY(coord.y)}));if(projectedCoords.length>1)for(let i=0;i<projectedCoords.length-1;i++)annotationsGroup.append("line").attr("class","wardley-annotation-line").attr("x1",projectedCoords[i].x).attr("y1",projectedCoords[i].y).attr("x2",projectedCoords[i+1].x).attr("y2",projectedCoords[i+1].y).attr("stroke",theme.axisColor).attr("stroke-width",1.5).attr("stroke-dasharray","4 4");projectedCoords.forEach(coord=>{const annotationNode=annotationsGroup.append("g").attr("class","wardley-annotation");annotationNode.append("circle").attr("cx",coord.x).attr("cy",coord.y).attr("r",10).attr("fill","white").attr("stroke",theme.axisColor).attr("stroke-width",1.5),annotationNode.append("text").attr("x",coord.x).attr("y",coord.y).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",10).attr("fill",theme.axisTextColor).attr("font-weight","bold").text(annotation.number)})}),data.annotationsBox){let boxX=projectX(data.annotationsBox.x),boxY=projectY(data.annotationsBox.y);const padding=10,lineHeight=16,fontSize=11,textBoxGroup=annotationsGroup.append("g").attr("class","wardley-annotations-box"),sortedAnnotations=[...data.annotations].filter(a=>a.text).sort((a,b)=>a.number-b.number),textElements=[];if(sortedAnnotations.forEach((annotation,idx)=>{const text2=textBoxGroup.append("text").attr("x",boxX+padding).attr("y",boxY+padding+(idx+1)*lineHeight).attr("font-size",fontSize).attr("fill",theme.axisTextColor).attr("text-anchor","start").attr("dominant-baseline","middle").text(`${annotation.number}. ${annotation.text}`);textElements.push(text2)}),textElements.length>0){let maxWidth=0,maxHeight=0;textElements.forEach(text2=>{const textNode=text2.node(),textWidth=textNode.getComputedTextLength();maxWidth=Math.max(maxWidth,textWidth);const bbox=textNode.getBBox();maxHeight=Math.max(maxHeight,bbox.height)});const boxWidth=maxWidth+2*padding+105,boxHeight=sortedAnnotations.length*lineHeight+2*padding+maxHeight/2,minX=configValues.padding,maxX=width-configValues.padding-boxWidth,minY=configValues.padding,maxY=height-configValues.padding-boxHeight;boxX=Math.max(minX,Math.min(boxX,maxX)),boxY=Math.max(minY,Math.min(boxY,maxY)),textElements.forEach((text2,idx)=>{text2.attr("x",boxX+padding).attr("y",boxY+padding+(idx+1)*lineHeight)}),textBoxGroup.insert("rect","text").attr("x",boxX).attr("y",boxY).attr("width",boxWidth).attr("height",boxHeight).attr("fill","white").attr("stroke",theme.axisColor).attr("stroke-width",1.5).attr("rx",4).attr("ry",4)}}}if(data.notes.length>0){const notesGroup=root.append("g").attr("class","wardley-notes");data.notes.forEach(note=>{const noteX=projectX(note.x),noteY=projectY(note.y);notesGroup.append("text").attr("x",noteX).attr("y",noteY).attr("text-anchor","start").attr("font-size",11).attr("fill",theme.axisTextColor).attr("font-weight","bold").text(note.text)})}if(data.accelerators.length>0){const acceleratorsGroup=root.append("g").attr("class","wardley-accelerators");data.accelerators.forEach(accelerator=>{const accX=projectX(accelerator.x),accY=projectY(accelerator.y),arrowPath=`\n M ${accX} ${accY-15}\n L ${accX+60-20} ${accY-15}\n L ${accX+60-20} ${accY-15-8}\n L ${accX+60} ${accY}\n L ${accX+60-20} ${accY+15+8}\n L ${accX+60-20} ${accY+15}\n L ${accX} ${accY+15}\n Z\n `;acceleratorsGroup.append("path").attr("d",arrowPath).attr("fill","white").attr("stroke",theme.componentStroke).attr("stroke-width",1),acceleratorsGroup.append("text").attr("x",accX+30).attr("y",accY+15+15).attr("text-anchor","middle").attr("font-size",10).attr("fill",theme.axisTextColor).attr("font-weight","bold").text(accelerator.name)})}if(data.deaccelerators.length>0){const deacceleratorsGroup=root.append("g").attr("class","wardley-deaccelerators");data.deaccelerators.forEach(deaccelerator=>{const decX=projectX(deaccelerator.x),decY=projectY(deaccelerator.y),arrowPath=`\n M ${decX+60} ${decY-15}\n L ${decX+20} ${decY-15}\n L ${decX+20} ${decY-15-8}\n L ${decX} ${decY}\n L ${decX+20} ${decY+15+8}\n L ${decX+20} ${decY+15}\n L ${decX+60} ${decY+15}\n Z\n `;deacceleratorsGroup.append("path").attr("d",arrowPath).attr("fill","white").attr("stroke",theme.componentStroke).attr("stroke-width",1),deacceleratorsGroup.append("text").attr("x",decX+30).attr("y",decY+15+15).attr("text-anchor","middle").attr("font-size",10).attr("fill",theme.axisTextColor).attr("font-weight","bold").text(deaccelerator.name)})}},"draw")},styles:__name(()=>"","styles")};export{diagram};
@@ -0,0 +1 @@
1
+ var _a,_b,_c,_d,_e,_f,_g,_h,_i,_j;import{s as setAccDescription,g as getAccDescription,q as getDiagramTitle,p as setDiagramTitle,a as getAccTitle,b as setAccTitle,_ as __name,l as log,H as selectSvgElement,e as configureSvgSize,y as clear,C as getConfig,i as sanitizeText,E as cleanAndMerge,F as defaultConfig_default,I as getThemeVariables3,aB as computeDimensionOfText,Q as line}from"./mermaid.core-Dg0McRZt.js";import{i as initRange}from"./init-DMZMl1PR.js";import{o as ordinal}from"./ordinal-DA-_8pMy.js";import{l as linear}from"./linear-BiJNTDgN.js";import"./vendor-mdxeditor-D5Z5D9fq.js";import"./vendor-antd-DKIytXho.js";import"./vendor-codemirror-4qgXq03k.js";import"./vendor-markdown-DOJHsAxX.js";import"./defaultLocale-DZ7E7S9R.js";function band(){var step,bandwidth,scale=ordinal().unknown(void 0),domain=scale.domain,ordinalRange=scale.range,r0=0,r1=1,round=!1,paddingInner=0,paddingOuter=0,align=.5;function rescale(){var n=domain().length,reverse=r1<r0,start=reverse?r1:r0,stop=reverse?r0:r1;step=(stop-start)/Math.max(1,n-paddingInner+2*paddingOuter),round&&(step=Math.floor(step)),start+=(stop-start-step*(n-paddingInner))*align,bandwidth=step*(1-paddingInner),round&&(start=Math.round(start),bandwidth=Math.round(bandwidth));var values=function(start,stop,step){start=+start,stop=+stop,step=(n=arguments.length)<2?(stop=start,start=0,1):n<3?1:+step;for(var i=-1,n=0|Math.max(0,Math.ceil((stop-start)/step)),range2=new Array(n);++i<n;)range2[i]=start+i*step;return range2}(n).map(function(i){return start+step*i});return ordinalRange(reverse?values.reverse():values)}return delete scale.unknown,scale.domain=function(_){return arguments.length?(domain(_),rescale()):domain()},scale.range=function(_){return arguments.length?([r0,r1]=_,r0=+r0,r1=+r1,rescale()):[r0,r1]},scale.rangeRound=function(_){return[r0,r1]=_,r0=+r0,r1=+r1,round=!0,rescale()},scale.bandwidth=function(){return bandwidth},scale.step=function(){return step},scale.round=function(_){return arguments.length?(round=!!_,rescale()):round},scale.padding=function(_){return arguments.length?(paddingInner=Math.min(1,paddingOuter=+_),rescale()):paddingInner},scale.paddingInner=function(_){return arguments.length?(paddingInner=Math.min(1,_),rescale()):paddingInner},scale.paddingOuter=function(_){return arguments.length?(paddingOuter=+_,rescale()):paddingOuter},scale.align=function(_){return arguments.length?(align=Math.max(0,Math.min(1,_)),rescale()):align},scale.copy=function(){return band(domain(),[r0,r1]).round(round).paddingInner(paddingInner).paddingOuter(paddingOuter).align(align)},initRange.apply(rescale(),arguments)}var parser=function(){var o=__name(function(k,v,o2,l){for(o2=o2||{},l=k.length;l--;o2[k[l]]=v);return o2},"o"),$V0=[1,10,12,14,16,18,19,21,23],$V1=[2,6],$V2=[1,3],$V3=[1,5],$V4=[1,6],$V5=[1,7],$V6=[1,5,10,12,14,16,18,19,21,23,34,35,36],$V7=[1,25],$V8=[1,26],$V9=[1,28],$Va=[1,29],$Vb=[1,30],$Vc=[1,31],$Vd=[1,32],$Ve=[1,33],$Vf=[1,34],$Vg=[1,35],$Vh=[1,36],$Vi=[1,37],$Vj=[1,43],$Vk=[1,42],$Vl=[1,47],$Vm=[1,50],$Vn=[1,10,12,14,16,18,19,21,23,34,35,36],$Vo=[1,10,12,14,16,18,19,21,23,24,26,27,28,34,35,36],$Vp=[1,10,12,14,16,18,19,21,23,24,26,27,28,34,35,36,41,42,43,44,45,46,47,48,49,50],$Vq=[1,64],parser2={trace:__name(function(){},"trace"),yy:{},symbols_:{error:2,start:3,eol:4,XYCHART:5,chartConfig:6,document:7,CHART_ORIENTATION:8,statement:9,title:10,text:11,X_AXIS:12,parseXAxis:13,Y_AXIS:14,parseYAxis:15,LINE:16,plotData:17,BAR:18,acc_title:19,acc_title_value:20,acc_descr:21,acc_descr_value:22,acc_descr_multiline_value:23,SQUARE_BRACES_START:24,commaSeparatedNumbers:25,SQUARE_BRACES_END:26,NUMBER_WITH_DECIMAL:27,COMMA:28,xAxisData:29,bandData:30,ARROW_DELIMITER:31,commaSeparatedTexts:32,yAxisData:33,NEWLINE:34,SEMI:35,EOF:36,alphaNum:37,STR:38,MD_STR:39,alphaNumToken:40,AMP:41,NUM:42,ALPHA:43,PLUS:44,EQUALS:45,MULT:46,DOT:47,BRKT:48,MINUS:49,UNDERSCORE:50,$accept:0,$end:1},terminals_:{2:"error",5:"XYCHART",8:"CHART_ORIENTATION",10:"title",12:"X_AXIS",14:"Y_AXIS",16:"LINE",18:"BAR",19:"acc_title",20:"acc_title_value",21:"acc_descr",22:"acc_descr_value",23:"acc_descr_multiline_value",24:"SQUARE_BRACES_START",26:"SQUARE_BRACES_END",27:"NUMBER_WITH_DECIMAL",28:"COMMA",31:"ARROW_DELIMITER",34:"NEWLINE",35:"SEMI",36:"EOF",38:"STR",39:"MD_STR",41:"AMP",42:"NUM",43:"ALPHA",44:"PLUS",45:"EQUALS",46:"MULT",47:"DOT",48:"BRKT",49:"MINUS",50:"UNDERSCORE"},productions_:[0,[3,2],[3,3],[3,2],[3,1],[6,1],[7,0],[7,2],[9,2],[9,2],[9,2],[9,2],[9,2],[9,3],[9,2],[9,3],[9,2],[9,2],[9,1],[17,3],[25,3],[25,1],[13,1],[13,2],[13,1],[29,1],[29,3],[30,3],[32,3],[32,1],[15,1],[15,2],[15,1],[33,3],[4,1],[4,1],[4,1],[11,1],[11,1],[11,1],[37,1],[37,2],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1]],performAction:__name(function(yytext,yyleng,yylineno,yy,yystate,$$,_$){var $0=$$.length-1;switch(yystate){case 5:yy.setOrientation($$[$0]);break;case 9:yy.setDiagramTitle($$[$0].text.trim());break;case 12:yy.setLineData({text:"",type:"text"},$$[$0]);break;case 13:yy.setLineData($$[$0-1],$$[$0]);break;case 14:yy.setBarData({text:"",type:"text"},$$[$0]);break;case 15:yy.setBarData($$[$0-1],$$[$0]);break;case 16:this.$=$$[$0].trim(),yy.setAccTitle(this.$);break;case 17:case 18:this.$=$$[$0].trim(),yy.setAccDescription(this.$);break;case 19:case 27:this.$=$$[$0-1];break;case 20:this.$=[Number($$[$0-2]),...$$[$0]];break;case 21:this.$=[Number($$[$0])];break;case 22:yy.setXAxisTitle($$[$0]);break;case 23:yy.setXAxisTitle($$[$0-1]);break;case 24:yy.setXAxisTitle({type:"text",text:""});break;case 25:yy.setXAxisBand($$[$0]);break;case 26:yy.setXAxisRangeData(Number($$[$0-2]),Number($$[$0]));break;case 28:this.$=[$$[$0-2],...$$[$0]];break;case 29:this.$=[$$[$0]];break;case 30:yy.setYAxisTitle($$[$0]);break;case 31:yy.setYAxisTitle($$[$0-1]);break;case 32:yy.setYAxisTitle({type:"text",text:""});break;case 33:yy.setYAxisRangeData(Number($$[$0-2]),Number($$[$0]));break;case 37:case 38:this.$={text:$$[$0],type:"text"};break;case 39:this.$={text:$$[$0],type:"markdown"};break;case 40:this.$=$$[$0];break;case 41:this.$=$$[$0-1]+""+$$[$0]}},"anonymous"),table:[o($V0,$V1,{3:1,4:2,7:4,5:$V2,34:$V3,35:$V4,36:$V5}),{1:[3]},o($V0,$V1,{4:2,7:4,3:8,5:$V2,34:$V3,35:$V4,36:$V5}),o($V0,$V1,{4:2,7:4,6:9,3:10,5:$V2,8:[1,11],34:$V3,35:$V4,36:$V5}),{1:[2,4],9:12,10:[1,13],12:[1,14],14:[1,15],16:[1,16],18:[1,17],19:[1,18],21:[1,19],23:[1,20]},o($V6,[2,34]),o($V6,[2,35]),o($V6,[2,36]),{1:[2,1]},o($V0,$V1,{4:2,7:4,3:21,5:$V2,34:$V3,35:$V4,36:$V5}),{1:[2,3]},o($V6,[2,5]),o($V0,[2,7],{4:22,34:$V3,35:$V4,36:$V5}),{11:23,37:24,38:$V7,39:$V8,40:27,41:$V9,42:$Va,43:$Vb,44:$Vc,45:$Vd,46:$Ve,47:$Vf,48:$Vg,49:$Vh,50:$Vi},{11:39,13:38,24:$Vj,27:$Vk,29:40,30:41,37:24,38:$V7,39:$V8,40:27,41:$V9,42:$Va,43:$Vb,44:$Vc,45:$Vd,46:$Ve,47:$Vf,48:$Vg,49:$Vh,50:$Vi},{11:45,15:44,27:$Vl,33:46,37:24,38:$V7,39:$V8,40:27,41:$V9,42:$Va,43:$Vb,44:$Vc,45:$Vd,46:$Ve,47:$Vf,48:$Vg,49:$Vh,50:$Vi},{11:49,17:48,24:$Vm,37:24,38:$V7,39:$V8,40:27,41:$V9,42:$Va,43:$Vb,44:$Vc,45:$Vd,46:$Ve,47:$Vf,48:$Vg,49:$Vh,50:$Vi},{11:52,17:51,24:$Vm,37:24,38:$V7,39:$V8,40:27,41:$V9,42:$Va,43:$Vb,44:$Vc,45:$Vd,46:$Ve,47:$Vf,48:$Vg,49:$Vh,50:$Vi},{20:[1,53]},{22:[1,54]},o($Vn,[2,18]),{1:[2,2]},o($Vn,[2,8]),o($Vn,[2,9]),o($Vo,[2,37],{40:55,41:$V9,42:$Va,43:$Vb,44:$Vc,45:$Vd,46:$Ve,47:$Vf,48:$Vg,49:$Vh,50:$Vi}),o($Vo,[2,38]),o($Vo,[2,39]),o($Vp,[2,40]),o($Vp,[2,42]),o($Vp,[2,43]),o($Vp,[2,44]),o($Vp,[2,45]),o($Vp,[2,46]),o($Vp,[2,47]),o($Vp,[2,48]),o($Vp,[2,49]),o($Vp,[2,50]),o($Vp,[2,51]),o($Vn,[2,10]),o($Vn,[2,22],{30:41,29:56,24:$Vj,27:$Vk}),o($Vn,[2,24]),o($Vn,[2,25]),{31:[1,57]},{11:59,32:58,37:24,38:$V7,39:$V8,40:27,41:$V9,42:$Va,43:$Vb,44:$Vc,45:$Vd,46:$Ve,47:$Vf,48:$Vg,49:$Vh,50:$Vi},o($Vn,[2,11]),o($Vn,[2,30],{33:60,27:$Vl}),o($Vn,[2,32]),{31:[1,61]},o($Vn,[2,12]),{17:62,24:$Vm},{25:63,27:$Vq},o($Vn,[2,14]),{17:65,24:$Vm},o($Vn,[2,16]),o($Vn,[2,17]),o($Vp,[2,41]),o($Vn,[2,23]),{27:[1,66]},{26:[1,67]},{26:[2,29],28:[1,68]},o($Vn,[2,31]),{27:[1,69]},o($Vn,[2,13]),{26:[1,70]},{26:[2,21],28:[1,71]},o($Vn,[2,15]),o($Vn,[2,26]),o($Vn,[2,27]),{11:59,32:72,37:24,38:$V7,39:$V8,40:27,41:$V9,42:$Va,43:$Vb,44:$Vc,45:$Vd,46:$Ve,47:$Vf,48:$Vg,49:$Vh,50:$Vi},o($Vn,[2,33]),o($Vn,[2,19]),{25:73,27:$Vq},{26:[2,28]},{26:[2,20]}],defaultActions:{8:[2,1],10:[2,3],21:[2,2],72:[2,28],73:[2,20]},parseError:__name(function(str,hash){if(!hash.recoverable){var error=new Error(str);throw error.hash=hash,error}this.trace(str)},"parseError"),parse:__name(function(input){var self=this,stack=[0],tstack=[],vstack=[null],lstack=[],table=this.table,yytext="",yylineno=0,yyleng=0,args=lstack.slice.call(arguments,1),lexer2=Object.create(this.lexer),sharedState={yy:{}};for(var k in this.yy)Object.prototype.hasOwnProperty.call(this.yy,k)&&(sharedState.yy[k]=this.yy[k]);lexer2.setInput(input,sharedState.yy),sharedState.yy.lexer=lexer2,sharedState.yy.parser=this,void 0===lexer2.yylloc&&(lexer2.yylloc={});var yyloc=lexer2.yylloc;lstack.push(yyloc);var ranges=lexer2.options&&lexer2.options.ranges;function lex(){var token;return"number"!=typeof(token=tstack.pop()||lexer2.lex()||1)&&(token instanceof Array&&(token=(tstack=token).pop()),token=self.symbols_[token]||token),token}"function"==typeof sharedState.yy.parseError?this.parseError=sharedState.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError,__name(function(n){stack.length=stack.length-2*n,vstack.length=vstack.length-n,lstack.length=lstack.length-n},"popStack"),__name(lex,"lex");for(var symbol,state,action,r,p,len,newState,expected,yyval={};;){if(state=stack[stack.length-1],this.defaultActions[state]?action=this.defaultActions[state]:(null==symbol&&(symbol=lex()),action=table[state]&&table[state][symbol]),void 0===action||!action.length||!action[0]){var errStr="";for(p in expected=[],table[state])this.terminals_[p]&&p>2&&expected.push("'"+this.terminals_[p]+"'");errStr=lexer2.showPosition?"Parse error on line "+(yylineno+1)+":\n"+lexer2.showPosition()+"\nExpecting "+expected.join(", ")+", got '"+(this.terminals_[symbol]||symbol)+"'":"Parse error on line "+(yylineno+1)+": Unexpected "+(1==symbol?"end of input":"'"+(this.terminals_[symbol]||symbol)+"'"),this.parseError(errStr,{text:lexer2.match,token:this.terminals_[symbol]||symbol,line:lexer2.yylineno,loc:yyloc,expected:expected})}if(action[0]instanceof Array&&action.length>1)throw new Error("Parse Error: multiple actions possible at state: "+state+", token: "+symbol);switch(action[0]){case 1:stack.push(symbol),vstack.push(lexer2.yytext),lstack.push(lexer2.yylloc),stack.push(action[1]),symbol=null,yyleng=lexer2.yyleng,yytext=lexer2.yytext,yylineno=lexer2.yylineno,yyloc=lexer2.yylloc;break;case 2:if(len=this.productions_[action[1]][1],yyval.$=vstack[vstack.length-len],yyval._$={first_line:lstack[lstack.length-(len||1)].first_line,last_line:lstack[lstack.length-1].last_line,first_column:lstack[lstack.length-(len||1)].first_column,last_column:lstack[lstack.length-1].last_column},ranges&&(yyval._$.range=[lstack[lstack.length-(len||1)].range[0],lstack[lstack.length-1].range[1]]),void 0!==(r=this.performAction.apply(yyval,[yytext,yyleng,yylineno,sharedState.yy,action[1],vstack,lstack].concat(args))))return r;len&&(stack=stack.slice(0,-1*len*2),vstack=vstack.slice(0,-1*len),lstack=lstack.slice(0,-1*len)),stack.push(this.productions_[action[1]][0]),vstack.push(yyval.$),lstack.push(yyval._$),newState=table[stack[stack.length-2]][stack[stack.length-1]],stack.push(newState);break;case 3:return!0}}return!0},"parse")},lexer=function(){return{EOF:1,parseError:__name(function(str,hash){if(!this.yy.parser)throw new Error(str);this.yy.parser.parseError(str,hash)},"parseError"),setInput:__name(function(input,yy){return this.yy=yy||this.yy||{},this._input=input,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:__name(function(){var ch=this._input[0];return this.yytext+=ch,this.yyleng++,this.offset++,this.match+=ch,this.matched+=ch,ch.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),ch},"input"),unput:__name(function(ch){var len=ch.length,lines=ch.split(/(?:\r\n?|\n)/g);this._input=ch+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-len),this.offset-=len;var oldLines=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),lines.length-1&&(this.yylineno-=lines.length-1);var r=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:lines?(lines.length===oldLines.length?this.yylloc.first_column:0)+oldLines[oldLines.length-lines.length].length-lines[0].length:this.yylloc.first_column-len},this.options.ranges&&(this.yylloc.range=[r[0],r[0]+this.yyleng-len]),this.yyleng=this.yytext.length,this},"unput"),more:__name(function(){return this._more=!0,this},"more"),reject:__name(function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"reject"),less:__name(function(n){this.unput(this.match.slice(n))},"less"),pastInput:__name(function(){var past=this.matched.substr(0,this.matched.length-this.match.length);return(past.length>20?"...":"")+past.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:__name(function(){var next=this.match;return next.length<20&&(next+=this._input.substr(0,20-next.length)),(next.substr(0,20)+(next.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:__name(function(){var pre=this.pastInput(),c=new Array(pre.length+1).join("-");return pre+this.upcomingInput()+"\n"+c+"^"},"showPosition"),test_match:__name(function(match,indexed_rule){var token,lines,backup;if(this.options.backtrack_lexer&&(backup={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(backup.yylloc.range=this.yylloc.range.slice(0))),(lines=match[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=lines.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:lines?lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+match[0].length},this.yytext+=match[0],this.match+=match[0],this.matches=match,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(match[0].length),this.matched+=match[0],token=this.performAction.call(this,this.yy,this,indexed_rule,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),token)return token;if(this._backtrack){for(var k in backup)this[k]=backup[k];return!1}return!1},"test_match"),next:__name(function(){if(this.done)return this.EOF;var token,match,tempMatch,index;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var rules=this._currentRules(),i=0;i<rules.length;i++)if((tempMatch=this._input.match(this.rules[rules[i]]))&&(!match||tempMatch[0].length>match[0].length)){if(match=tempMatch,index=i,this.options.backtrack_lexer){if(!1!==(token=this.test_match(tempMatch,rules[i])))return token;if(this._backtrack){match=!1;continue}return!1}if(!this.options.flex)break}return match?!1!==(token=this.test_match(match,rules[index]))&&token:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:__name(function(){var r=this.next();return r||this.lex()},"lex"),begin:__name(function(condition){this.conditionStack.push(condition)},"begin"),popState:__name(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:__name(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:__name(function(n){return(n=this.conditionStack.length-1-Math.abs(n||0))>=0?this.conditionStack[n]:"INITIAL"},"topState"),pushState:__name(function(condition){this.begin(condition)},"pushState"),stateStackSize:__name(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:__name(function(yy,yy_,$avoiding_name_collisions,YY_START){switch($avoiding_name_collisions){case 0:case 1:case 5:case 44:break;case 2:case 3:return this.popState(),34;case 4:return 34;case 6:return 10;case 7:return this.pushState("acc_title"),19;case 8:return this.popState(),"acc_title_value";case 9:return this.pushState("acc_descr"),21;case 10:return this.popState(),"acc_descr_value";case 11:this.pushState("acc_descr_multiline");break;case 12:case 26:case 28:this.popState();break;case 13:return"acc_descr_multiline_value";case 14:case 15:return 5;case 16:return 8;case 17:return this.pushState("axis_data"),"X_AXIS";case 18:return this.pushState("axis_data"),"Y_AXIS";case 19:return this.pushState("axis_band_data"),24;case 20:return 31;case 21:return this.pushState("data"),16;case 22:return this.pushState("data"),18;case 23:return this.pushState("data_inner"),24;case 24:return 27;case 25:return this.popState(),26;case 27:this.pushState("string");break;case 29:return"STR";case 30:return 24;case 31:return 26;case 32:return 43;case 33:return"COLON";case 34:return 44;case 35:return 28;case 36:return 45;case 37:return 46;case 38:return 48;case 39:return 50;case 40:return 47;case 41:return 41;case 42:return 49;case 43:return 42;case 45:return 35;case 46:return 36}},"anonymous"),rules:[/^(?:%%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:(\r?\n))/i,/^(?:(\r?\n))/i,/^(?:[\n\r]+)/i,/^(?:%%[^\n]*)/i,/^(?:title\b)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:\})/i,/^(?:[^\}]*)/i,/^(?:xychart-beta\b)/i,/^(?:xychart\b)/i,/^(?:(?:vertical|horizontal))/i,/^(?:x-axis\b)/i,/^(?:y-axis\b)/i,/^(?:\[)/i,/^(?:-->)/i,/^(?:line\b)/i,/^(?:bar\b)/i,/^(?:\[)/i,/^(?:[+-]?(?:\d+(?:\.\d+)?|\.\d+))/i,/^(?:\])/i,/^(?:(?:`\) \{ this\.pushState\(md_string\); \}\n<md_string>\(\?:\(\?!`"\)\.\)\+ \{ return MD_STR; \}\n<md_string>\(\?:`))/i,/^(?:["])/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:[A-Za-z]+)/i,/^(?::)/i,/^(?:\+)/i,/^(?:,)/i,/^(?:=)/i,/^(?:\*)/i,/^(?:#)/i,/^(?:[\_])/i,/^(?:\.)/i,/^(?:&)/i,/^(?:-)/i,/^(?:[0-9]+)/i,/^(?:\s+)/i,/^(?:;)/i,/^(?:$)/i],conditions:{data_inner:{rules:[0,1,4,5,6,7,9,11,14,15,16,17,18,21,22,24,25,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},data:{rules:[0,1,3,4,5,6,7,9,11,14,15,16,17,18,21,22,23,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},axis_band_data:{rules:[0,1,4,5,6,7,9,11,14,15,16,17,18,21,22,25,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},axis_data:{rules:[0,1,2,4,5,6,7,9,11,14,15,16,17,18,19,20,21,22,24,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},acc_descr_multiline:{rules:[12,13],inclusive:!1},acc_descr:{rules:[10],inclusive:!1},acc_title:{rules:[8],inclusive:!1},title:{rules:[],inclusive:!1},md_string:{rules:[],inclusive:!1},string:{rules:[28,29],inclusive:!1},INITIAL:{rules:[0,1,4,5,6,7,9,11,14,15,16,17,18,21,22,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0}}}}();function Parser(){this.yy={}}return parser2.lexer=lexer,__name(Parser,"Parser"),Parser.prototype=parser2,parser2.Parser=Parser,new Parser}();parser.parser=parser;var xychart_default=parser;function isBarPlot(data){return"bar"===data.type}function isBandAxisData(data){return"band"===data.type}function isLinearAxisData(data){return"linear"===data.type}__name(isBarPlot,"isBarPlot"),__name(isBandAxisData,"isBandAxisData"),__name(isLinearAxisData,"isLinearAxisData");var TextDimensionCalculatorWithFont=(__name(_a=class{constructor(parentGroup){this.parentGroup=parentGroup}getMaxDimension(texts,fontSize){if(!this.parentGroup)return{width:texts.reduce((acc,cur)=>Math.max(cur.length,acc),0)*fontSize,height:fontSize};const dimension={width:0,height:0},elem=this.parentGroup.append("g").attr("visibility","hidden").attr("font-size",fontSize);for(const t of texts){const bbox=computeDimensionOfText(elem,1,t),width=bbox?bbox.width:t.length*fontSize,height=bbox?bbox.height:fontSize;dimension.width=Math.max(dimension.width,width),dimension.height=Math.max(dimension.height,height)}return elem.remove(),dimension}},"TextDimensionCalculatorWithFont"),_a),BaseAxis=(__name(_b=class{constructor(axisConfig,title,textDimensionCalculator,axisThemeConfig){this.axisConfig=axisConfig,this.title=title,this.textDimensionCalculator=textDimensionCalculator,this.axisThemeConfig=axisThemeConfig,this.boundingRect={x:0,y:0,width:0,height:0},this.axisPosition="left",this.showTitle=!1,this.showLabel=!1,this.showTick=!1,this.showAxisLine=!1,this.outerPadding=0,this.titleTextHeight=0,this.labelTextHeight=0,this.range=[0,10],this.boundingRect={x:0,y:0,width:0,height:0},this.axisPosition="left"}setRange(range2){this.range=range2,"left"===this.axisPosition||"right"===this.axisPosition?this.boundingRect.height=range2[1]-range2[0]:this.boundingRect.width=range2[1]-range2[0],this.recalculateScale()}getRange(){return[this.range[0]+this.outerPadding,this.range[1]-this.outerPadding]}setAxisPosition(axisPosition){this.axisPosition=axisPosition,this.setRange(this.range)}getTickDistance(){const range2=this.getRange();return Math.abs(range2[0]-range2[1])/this.getTickValues().length}getAxisOuterPadding(){return this.outerPadding}getLabelDimension(){return this.textDimensionCalculator.getMaxDimension(this.getTickValues().map(tick=>tick.toString()),this.axisConfig.labelFontSize)}recalculateOuterPaddingToDrawBar(){.7*this.getTickDistance()>2*this.outerPadding&&(this.outerPadding=Math.floor(.7*this.getTickDistance()/2)),this.recalculateScale()}calculateSpaceIfDrawnHorizontally(availableSpace){let availableHeight=availableSpace.height;if(this.axisConfig.showAxisLine&&availableHeight>this.axisConfig.axisLineWidth&&(availableHeight-=this.axisConfig.axisLineWidth,this.showAxisLine=!0),this.axisConfig.showLabel){const spaceRequired=this.getLabelDimension(),maxPadding=.2*availableSpace.width;this.outerPadding=Math.min(spaceRequired.width/2,maxPadding);const heightRequired=spaceRequired.height+2*this.axisConfig.labelPadding;this.labelTextHeight=spaceRequired.height,heightRequired<=availableHeight&&(availableHeight-=heightRequired,this.showLabel=!0)}if(this.axisConfig.showTick&&availableHeight>=this.axisConfig.tickLength&&(this.showTick=!0,availableHeight-=this.axisConfig.tickLength),this.axisConfig.showTitle&&this.title){const spaceRequired=this.textDimensionCalculator.getMaxDimension([this.title],this.axisConfig.titleFontSize),heightRequired=spaceRequired.height+2*this.axisConfig.titlePadding;this.titleTextHeight=spaceRequired.height,heightRequired<=availableHeight&&(availableHeight-=heightRequired,this.showTitle=!0)}this.boundingRect.width=availableSpace.width,this.boundingRect.height=availableSpace.height-availableHeight}calculateSpaceIfDrawnVertical(availableSpace){let availableWidth=availableSpace.width;if(this.axisConfig.showAxisLine&&availableWidth>this.axisConfig.axisLineWidth&&(availableWidth-=this.axisConfig.axisLineWidth,this.showAxisLine=!0),this.axisConfig.showLabel){const spaceRequired=this.getLabelDimension(),maxPadding=.2*availableSpace.height;this.outerPadding=Math.min(spaceRequired.height/2,maxPadding);const widthRequired=spaceRequired.width+2*this.axisConfig.labelPadding;widthRequired<=availableWidth&&(availableWidth-=widthRequired,this.showLabel=!0)}if(this.axisConfig.showTick&&availableWidth>=this.axisConfig.tickLength&&(this.showTick=!0,availableWidth-=this.axisConfig.tickLength),this.axisConfig.showTitle&&this.title){const spaceRequired=this.textDimensionCalculator.getMaxDimension([this.title],this.axisConfig.titleFontSize),widthRequired=spaceRequired.height+2*this.axisConfig.titlePadding;this.titleTextHeight=spaceRequired.height,widthRequired<=availableWidth&&(availableWidth-=widthRequired,this.showTitle=!0)}this.boundingRect.width=availableSpace.width-availableWidth,this.boundingRect.height=availableSpace.height}calculateSpace(availableSpace){return"left"===this.axisPosition||"right"===this.axisPosition?this.calculateSpaceIfDrawnVertical(availableSpace):this.calculateSpaceIfDrawnHorizontally(availableSpace),this.recalculateScale(),{width:this.boundingRect.width,height:this.boundingRect.height}}setBoundingBoxXY(point){this.boundingRect.x=point.x,this.boundingRect.y=point.y}getDrawableElementsForLeftAxis(){const drawableElement=[];if(this.showAxisLine){const x=this.boundingRect.x+this.boundingRect.width-this.axisConfig.axisLineWidth/2;drawableElement.push({type:"path",groupTexts:["left-axis","axisl-line"],data:[{path:`M ${x},${this.boundingRect.y} L ${x},${this.boundingRect.y+this.boundingRect.height} `,strokeFill:this.axisThemeConfig.axisLineColor,strokeWidth:this.axisConfig.axisLineWidth}]})}if(this.showLabel&&drawableElement.push({type:"text",groupTexts:["left-axis","label"],data:this.getTickValues().map(tick=>({text:tick.toString(),x:this.boundingRect.x+this.boundingRect.width-(this.showLabel?this.axisConfig.labelPadding:0)-(this.showTick?this.axisConfig.tickLength:0)-(this.showAxisLine?this.axisConfig.axisLineWidth:0),y:this.getScaleValue(tick),fill:this.axisThemeConfig.labelColor,fontSize:this.axisConfig.labelFontSize,rotation:0,verticalPos:"middle",horizontalPos:"right"}))}),this.showTick){const x=this.boundingRect.x+this.boundingRect.width-(this.showAxisLine?this.axisConfig.axisLineWidth:0);drawableElement.push({type:"path",groupTexts:["left-axis","ticks"],data:this.getTickValues().map(tick=>({path:`M ${x},${this.getScaleValue(tick)} L ${x-this.axisConfig.tickLength},${this.getScaleValue(tick)}`,strokeFill:this.axisThemeConfig.tickColor,strokeWidth:this.axisConfig.tickWidth}))})}return this.showTitle&&drawableElement.push({type:"text",groupTexts:["left-axis","title"],data:[{text:this.title,x:this.boundingRect.x+this.axisConfig.titlePadding,y:this.boundingRect.y+this.boundingRect.height/2,fill:this.axisThemeConfig.titleColor,fontSize:this.axisConfig.titleFontSize,rotation:270,verticalPos:"top",horizontalPos:"center"}]}),drawableElement}getDrawableElementsForBottomAxis(){const drawableElement=[];if(this.showAxisLine){const y=this.boundingRect.y+this.axisConfig.axisLineWidth/2;drawableElement.push({type:"path",groupTexts:["bottom-axis","axis-line"],data:[{path:`M ${this.boundingRect.x},${y} L ${this.boundingRect.x+this.boundingRect.width},${y}`,strokeFill:this.axisThemeConfig.axisLineColor,strokeWidth:this.axisConfig.axisLineWidth}]})}if(this.showLabel&&drawableElement.push({type:"text",groupTexts:["bottom-axis","label"],data:this.getTickValues().map(tick=>({text:tick.toString(),x:this.getScaleValue(tick),y:this.boundingRect.y+this.axisConfig.labelPadding+(this.showTick?this.axisConfig.tickLength:0)+(this.showAxisLine?this.axisConfig.axisLineWidth:0),fill:this.axisThemeConfig.labelColor,fontSize:this.axisConfig.labelFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}))}),this.showTick){const y=this.boundingRect.y+(this.showAxisLine?this.axisConfig.axisLineWidth:0);drawableElement.push({type:"path",groupTexts:["bottom-axis","ticks"],data:this.getTickValues().map(tick=>({path:`M ${this.getScaleValue(tick)},${y} L ${this.getScaleValue(tick)},${y+this.axisConfig.tickLength}`,strokeFill:this.axisThemeConfig.tickColor,strokeWidth:this.axisConfig.tickWidth}))})}return this.showTitle&&drawableElement.push({type:"text",groupTexts:["bottom-axis","title"],data:[{text:this.title,x:this.range[0]+(this.range[1]-this.range[0])/2,y:this.boundingRect.y+this.boundingRect.height-this.axisConfig.titlePadding-this.titleTextHeight,fill:this.axisThemeConfig.titleColor,fontSize:this.axisConfig.titleFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}]}),drawableElement}getDrawableElementsForTopAxis(){const drawableElement=[];if(this.showAxisLine){const y=this.boundingRect.y+this.boundingRect.height-this.axisConfig.axisLineWidth/2;drawableElement.push({type:"path",groupTexts:["top-axis","axis-line"],data:[{path:`M ${this.boundingRect.x},${y} L ${this.boundingRect.x+this.boundingRect.width},${y}`,strokeFill:this.axisThemeConfig.axisLineColor,strokeWidth:this.axisConfig.axisLineWidth}]})}if(this.showLabel&&drawableElement.push({type:"text",groupTexts:["top-axis","label"],data:this.getTickValues().map(tick=>({text:tick.toString(),x:this.getScaleValue(tick),y:this.boundingRect.y+(this.showTitle?this.titleTextHeight+2*this.axisConfig.titlePadding:0)+this.axisConfig.labelPadding,fill:this.axisThemeConfig.labelColor,fontSize:this.axisConfig.labelFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}))}),this.showTick){const y=this.boundingRect.y;drawableElement.push({type:"path",groupTexts:["top-axis","ticks"],data:this.getTickValues().map(tick=>({path:`M ${this.getScaleValue(tick)},${y+this.boundingRect.height-(this.showAxisLine?this.axisConfig.axisLineWidth:0)} L ${this.getScaleValue(tick)},${y+this.boundingRect.height-this.axisConfig.tickLength-(this.showAxisLine?this.axisConfig.axisLineWidth:0)}`,strokeFill:this.axisThemeConfig.tickColor,strokeWidth:this.axisConfig.tickWidth}))})}return this.showTitle&&drawableElement.push({type:"text",groupTexts:["top-axis","title"],data:[{text:this.title,x:this.boundingRect.x+this.boundingRect.width/2,y:this.boundingRect.y+this.axisConfig.titlePadding,fill:this.axisThemeConfig.titleColor,fontSize:this.axisConfig.titleFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}]}),drawableElement}getDrawableElements(){if("left"===this.axisPosition)return this.getDrawableElementsForLeftAxis();if("right"===this.axisPosition)throw Error("Drawing of right axis is not implemented");return"bottom"===this.axisPosition?this.getDrawableElementsForBottomAxis():"top"===this.axisPosition?this.getDrawableElementsForTopAxis():[]}},"BaseAxis"),_b),BandAxis=(__name(_c=class extends BaseAxis{constructor(axisConfig,axisThemeConfig,categories,title,textDimensionCalculator){super(axisConfig,title,textDimensionCalculator,axisThemeConfig),this.categories=categories,this.scale=band().domain(this.categories).range(this.getRange())}setRange(range2){super.setRange(range2)}recalculateScale(){this.scale=band().domain(this.categories).range(this.getRange()).paddingInner(1).paddingOuter(0).align(.5),log.trace("BandAxis axis final categories, range: ",this.categories,this.getRange())}getTickValues(){return this.categories}getScaleValue(value){return this.scale(value)??this.getRange()[0]}},"BandAxis"),_c),LinearAxis=(__name(_d=class extends BaseAxis{constructor(axisConfig,axisThemeConfig,domain,title,textDimensionCalculator){super(axisConfig,title,textDimensionCalculator,axisThemeConfig),this.domain=domain,this.scale=linear().domain(this.domain).range(this.getRange())}getTickValues(){return this.scale.ticks()}recalculateScale(){const domain=[...this.domain];"left"===this.axisPosition&&domain.reverse(),this.scale=linear().domain(domain).range(this.getRange())}getScaleValue(value){return this.scale(value)}},"LinearAxis"),_d);function getAxis(data,axisConfig,axisThemeConfig,tmpSVGGroup2){const textDimensionCalculator=new TextDimensionCalculatorWithFont(tmpSVGGroup2);return isBandAxisData(data)?new BandAxis(axisConfig,axisThemeConfig,data.categories,data.title,textDimensionCalculator):new LinearAxis(axisConfig,axisThemeConfig,[data.min,data.max],data.title,textDimensionCalculator)}__name(getAxis,"getAxis");var ChartTitle=(__name(_e=class{constructor(textDimensionCalculator,chartConfig,chartData,chartThemeConfig){this.textDimensionCalculator=textDimensionCalculator,this.chartConfig=chartConfig,this.chartData=chartData,this.chartThemeConfig=chartThemeConfig,this.boundingRect={x:0,y:0,width:0,height:0},this.showChartTitle=!1}setBoundingBoxXY(point){this.boundingRect.x=point.x,this.boundingRect.y=point.y}calculateSpace(availableSpace){const titleDimension=this.textDimensionCalculator.getMaxDimension([this.chartData.title],this.chartConfig.titleFontSize),widthRequired=Math.max(titleDimension.width,availableSpace.width),heightRequired=titleDimension.height+2*this.chartConfig.titlePadding;return titleDimension.width<=widthRequired&&titleDimension.height<=heightRequired&&this.chartConfig.showTitle&&this.chartData.title&&(this.boundingRect.width=widthRequired,this.boundingRect.height=heightRequired,this.showChartTitle=!0),{width:this.boundingRect.width,height:this.boundingRect.height}}getDrawableElements(){const drawableElem=[];return this.showChartTitle&&drawableElem.push({groupTexts:["chart-title"],type:"text",data:[{fontSize:this.chartConfig.titleFontSize,text:this.chartData.title,verticalPos:"middle",horizontalPos:"center",x:this.boundingRect.x+this.boundingRect.width/2,y:this.boundingRect.y+this.boundingRect.height/2,fill:this.chartThemeConfig.titleColor,rotation:0}]}),drawableElem}},"ChartTitle"),_e);function getChartTitleComponent(chartConfig,chartData,chartThemeConfig,tmpSVGGroup2){const textDimensionCalculator=new TextDimensionCalculatorWithFont(tmpSVGGroup2);return new ChartTitle(textDimensionCalculator,chartConfig,chartData,chartThemeConfig)}__name(getChartTitleComponent,"getChartTitleComponent");var LinePlot=(__name(_f=class{constructor(plotData,xAxis,yAxis,orientation,plotIndex2){this.plotData=plotData,this.xAxis=xAxis,this.yAxis=yAxis,this.orientation=orientation,this.plotIndex=plotIndex2}getDrawableElement(){const finalData=this.plotData.data.map(d=>[this.xAxis.getScaleValue(d[0]),this.yAxis.getScaleValue(d[1])]);let path;return path="horizontal"===this.orientation?line().y(d=>d[0]).x(d=>d[1])(finalData):line().x(d=>d[0]).y(d=>d[1])(finalData),path?[{groupTexts:["plot",`line-plot-${this.plotIndex}`],type:"path",data:[{path:path,strokeFill:this.plotData.strokeFill,strokeWidth:this.plotData.strokeWidth}]}]:[]}},"LinePlot"),_f),BarPlot=(__name(_g=class{constructor(barData,boundingRect,xAxis,yAxis,orientation,plotIndex2){this.barData=barData,this.boundingRect=boundingRect,this.xAxis=xAxis,this.yAxis=yAxis,this.orientation=orientation,this.plotIndex=plotIndex2}getDrawableElement(){const finalData=this.barData.data.map(d=>[this.xAxis.getScaleValue(d[0]),this.yAxis.getScaleValue(d[1])]),barWidth=.95*Math.min(2*this.xAxis.getAxisOuterPadding(),this.xAxis.getTickDistance()),barWidthHalf=barWidth/2;return"horizontal"===this.orientation?[{groupTexts:["plot",`bar-plot-${this.plotIndex}`],type:"rect",data:finalData.map(data=>({x:this.boundingRect.x,y:data[0]-barWidthHalf,height:barWidth,width:data[1]-this.boundingRect.x,fill:this.barData.fill,strokeWidth:0,strokeFill:this.barData.fill}))}]:[{groupTexts:["plot",`bar-plot-${this.plotIndex}`],type:"rect",data:finalData.map(data=>({x:data[0]-barWidthHalf,y:data[1],width:barWidth,height:this.boundingRect.y+this.boundingRect.height-data[1],fill:this.barData.fill,strokeWidth:0,strokeFill:this.barData.fill}))}]}},"BarPlot"),_g),BasePlot=(__name(_h=class{constructor(chartConfig,chartData,chartThemeConfig){this.chartConfig=chartConfig,this.chartData=chartData,this.chartThemeConfig=chartThemeConfig,this.boundingRect={x:0,y:0,width:0,height:0}}setAxes(xAxis,yAxis){this.xAxis=xAxis,this.yAxis=yAxis}setBoundingBoxXY(point){this.boundingRect.x=point.x,this.boundingRect.y=point.y}calculateSpace(availableSpace){return this.boundingRect.width=availableSpace.width,this.boundingRect.height=availableSpace.height,{width:this.boundingRect.width,height:this.boundingRect.height}}getDrawableElements(){if(!this.xAxis||!this.yAxis)throw Error("Axes must be passed to render Plots");const drawableElem=[];for(const[i,plot]of this.chartData.plots.entries())switch(plot.type){case"line":{const linePlot=new LinePlot(plot,this.xAxis,this.yAxis,this.chartConfig.chartOrientation,i);drawableElem.push(...linePlot.getDrawableElement())}break;case"bar":{const barPlot=new BarPlot(plot,this.boundingRect,this.xAxis,this.yAxis,this.chartConfig.chartOrientation,i);drawableElem.push(...barPlot.getDrawableElement())}}return drawableElem}},"BasePlot"),_h);function getPlotComponent(chartConfig,chartData,chartThemeConfig){return new BasePlot(chartConfig,chartData,chartThemeConfig)}__name(getPlotComponent,"getPlotComponent");var tmpSVGGroup,Orchestrator=(__name(_i=class{constructor(chartConfig,chartData,chartThemeConfig,tmpSVGGroup2){this.chartConfig=chartConfig,this.chartData=chartData,this.componentStore={title:getChartTitleComponent(chartConfig,chartData,chartThemeConfig,tmpSVGGroup2),plot:getPlotComponent(chartConfig,chartData,chartThemeConfig),xAxis:getAxis(chartData.xAxis,chartConfig.xAxis,{titleColor:chartThemeConfig.xAxisTitleColor,labelColor:chartThemeConfig.xAxisLabelColor,tickColor:chartThemeConfig.xAxisTickColor,axisLineColor:chartThemeConfig.xAxisLineColor},tmpSVGGroup2),yAxis:getAxis(chartData.yAxis,chartConfig.yAxis,{titleColor:chartThemeConfig.yAxisTitleColor,labelColor:chartThemeConfig.yAxisLabelColor,tickColor:chartThemeConfig.yAxisTickColor,axisLineColor:chartThemeConfig.yAxisLineColor},tmpSVGGroup2)}}calculateVerticalSpace(){let availableWidth=this.chartConfig.width,availableHeight=this.chartConfig.height,plotX=0,plotY=0,chartWidth=Math.floor(availableWidth*this.chartConfig.plotReservedSpacePercent/100),chartHeight=Math.floor(availableHeight*this.chartConfig.plotReservedSpacePercent/100),spaceUsed=this.componentStore.plot.calculateSpace({width:chartWidth,height:chartHeight});availableWidth-=spaceUsed.width,availableHeight-=spaceUsed.height,spaceUsed=this.componentStore.title.calculateSpace({width:this.chartConfig.width,height:availableHeight}),plotY=spaceUsed.height,availableHeight-=spaceUsed.height,this.componentStore.xAxis.setAxisPosition("bottom"),spaceUsed=this.componentStore.xAxis.calculateSpace({width:availableWidth,height:availableHeight}),availableHeight-=spaceUsed.height,this.componentStore.yAxis.setAxisPosition("left"),spaceUsed=this.componentStore.yAxis.calculateSpace({width:availableWidth,height:availableHeight}),plotX=spaceUsed.width,availableWidth-=spaceUsed.width,availableWidth>0&&(chartWidth+=availableWidth,availableWidth=0),availableHeight>0&&(chartHeight+=availableHeight,availableHeight=0),this.componentStore.plot.calculateSpace({width:chartWidth,height:chartHeight}),this.componentStore.plot.setBoundingBoxXY({x:plotX,y:plotY}),this.componentStore.xAxis.setRange([plotX,plotX+chartWidth]),this.componentStore.xAxis.setBoundingBoxXY({x:plotX,y:plotY+chartHeight}),this.componentStore.yAxis.setRange([plotY,plotY+chartHeight]),this.componentStore.yAxis.setBoundingBoxXY({x:0,y:plotY}),this.chartData.plots.some(p=>isBarPlot(p))&&this.componentStore.xAxis.recalculateOuterPaddingToDrawBar()}calculateHorizontalSpace(){let availableWidth=this.chartConfig.width,availableHeight=this.chartConfig.height,titleYEnd=0,plotX=0,plotY=0,chartWidth=Math.floor(availableWidth*this.chartConfig.plotReservedSpacePercent/100),chartHeight=Math.floor(availableHeight*this.chartConfig.plotReservedSpacePercent/100),spaceUsed=this.componentStore.plot.calculateSpace({width:chartWidth,height:chartHeight});availableWidth-=spaceUsed.width,availableHeight-=spaceUsed.height,spaceUsed=this.componentStore.title.calculateSpace({width:this.chartConfig.width,height:availableHeight}),titleYEnd=spaceUsed.height,availableHeight-=spaceUsed.height,this.componentStore.xAxis.setAxisPosition("left"),spaceUsed=this.componentStore.xAxis.calculateSpace({width:availableWidth,height:availableHeight}),availableWidth-=spaceUsed.width,plotX=spaceUsed.width,this.componentStore.yAxis.setAxisPosition("top"),spaceUsed=this.componentStore.yAxis.calculateSpace({width:availableWidth,height:availableHeight}),availableHeight-=spaceUsed.height,plotY=titleYEnd+spaceUsed.height,availableWidth>0&&(chartWidth+=availableWidth,availableWidth=0),availableHeight>0&&(chartHeight+=availableHeight,availableHeight=0),this.componentStore.plot.calculateSpace({width:chartWidth,height:chartHeight}),this.componentStore.plot.setBoundingBoxXY({x:plotX,y:plotY}),this.componentStore.yAxis.setRange([plotX,plotX+chartWidth]),this.componentStore.yAxis.setBoundingBoxXY({x:plotX,y:titleYEnd}),this.componentStore.xAxis.setRange([plotY,plotY+chartHeight]),this.componentStore.xAxis.setBoundingBoxXY({x:0,y:plotY}),this.chartData.plots.some(p=>isBarPlot(p))&&this.componentStore.xAxis.recalculateOuterPaddingToDrawBar()}calculateSpace(){"horizontal"===this.chartConfig.chartOrientation?this.calculateHorizontalSpace():this.calculateVerticalSpace()}getDrawableElement(){this.calculateSpace();const drawableElem=[];this.componentStore.plot.setAxes(this.componentStore.xAxis,this.componentStore.yAxis);for(const component of Object.values(this.componentStore))drawableElem.push(...component.getDrawableElements());return drawableElem}},"Orchestrator"),_i),XYChartBuilder=(__name(_j=class{static build(config,chartData,chartThemeConfig,tmpSVGGroup2){return new Orchestrator(config,chartData,chartThemeConfig,tmpSVGGroup2).getDrawableElement()}},"XYChartBuilder"),_j),plotIndex=0,xyChartConfig=getChartDefaultConfig(),xyChartThemeConfig=getChartDefaultThemeConfig(),xyChartData=getChartDefaultData(),plotColorPalette=xyChartThemeConfig.plotColorPalette.split(",").map(color=>color.trim()),hasSetXAxis=!1,hasSetYAxis=!1;function getChartDefaultThemeConfig(){const defaultThemeVariables=getThemeVariables3(),config=getConfig();return cleanAndMerge(defaultThemeVariables.xyChart,config.themeVariables.xyChart)}function getChartDefaultConfig(){const config=getConfig();return cleanAndMerge(defaultConfig_default.xyChart,config.xyChart)}function getChartDefaultData(){return{yAxis:{type:"linear",title:"",min:1/0,max:-1/0},xAxis:{type:"band",title:"",categories:[]},title:"",plots:[]}}function textSanitizer(text){const config=getConfig();return sanitizeText(text.trim(),config)}function setTmpSVGG(SVGG){tmpSVGGroup=SVGG}function setOrientation(orientation){xyChartConfig.chartOrientation="horizontal"===orientation?"horizontal":"vertical"}function setXAxisTitle(title){xyChartData.xAxis.title=textSanitizer(title.text)}function setXAxisRangeData(min,max){xyChartData.xAxis={type:"linear",title:xyChartData.xAxis.title,min:min,max:max},hasSetXAxis=!0}function setXAxisBand(categories){xyChartData.xAxis={type:"band",title:xyChartData.xAxis.title,categories:categories.map(c=>textSanitizer(c.text))},hasSetXAxis=!0}function setYAxisTitle(title){xyChartData.yAxis.title=textSanitizer(title.text)}function setYAxisRangeData(min,max){xyChartData.yAxis={type:"linear",title:xyChartData.yAxis.title,min:min,max:max},hasSetYAxis=!0}function setYAxisRangeFromPlotData(data){const minValue=Math.min(...data),maxValue=Math.max(...data),prevMinValue=isLinearAxisData(xyChartData.yAxis)?xyChartData.yAxis.min:1/0,prevMaxValue=isLinearAxisData(xyChartData.yAxis)?xyChartData.yAxis.max:-1/0;xyChartData.yAxis={type:"linear",title:xyChartData.yAxis.title,min:Math.min(prevMinValue,minValue),max:Math.max(prevMaxValue,maxValue)}}function transformDataWithoutCategory(data){let retData=[];if(0===data.length)return retData;if(!hasSetXAxis){const prevMinValue=isLinearAxisData(xyChartData.xAxis)?xyChartData.xAxis.min:1/0,prevMaxValue=isLinearAxisData(xyChartData.xAxis)?xyChartData.xAxis.max:-1/0;setXAxisRangeData(Math.min(prevMinValue,1),Math.max(prevMaxValue,data.length))}if(hasSetYAxis||setYAxisRangeFromPlotData(data),isBandAxisData(xyChartData.xAxis)&&(retData=xyChartData.xAxis.categories.map((c,i)=>[c,data[i]])),isLinearAxisData(xyChartData.xAxis)){const min=xyChartData.xAxis.min,max=xyChartData.xAxis.max,step=(max-min)/(data.length-1),categories=[];for(let i=min;i<=max;i+=step)categories.push(`${i}`);retData=categories.map((c,i)=>[c,data[i]])}return retData}function getPlotColorFromPalette(plotIndex2){return plotColorPalette[0===plotIndex2?0:plotIndex2%plotColorPalette.length]}function setLineData(title,data){const plotData=transformDataWithoutCategory(data);xyChartData.plots.push({type:"line",strokeFill:getPlotColorFromPalette(plotIndex),strokeWidth:2,data:plotData}),plotIndex++}function setBarData(title,data){const plotData=transformDataWithoutCategory(data);xyChartData.plots.push({type:"bar",fill:getPlotColorFromPalette(plotIndex),data:plotData}),plotIndex++}function getDrawableElem(){if(0===xyChartData.plots.length)throw Error("No Plot to render, please provide a plot with some data");return xyChartData.title=getDiagramTitle(),XYChartBuilder.build(xyChartConfig,xyChartData,xyChartThemeConfig,tmpSVGGroup)}function getChartThemeConfig(){return xyChartThemeConfig}function getChartConfig(){return xyChartConfig}function getXYChartData(){return xyChartData}__name(getChartDefaultThemeConfig,"getChartDefaultThemeConfig"),__name(getChartDefaultConfig,"getChartDefaultConfig"),__name(getChartDefaultData,"getChartDefaultData"),__name(textSanitizer,"textSanitizer"),__name(setTmpSVGG,"setTmpSVGG"),__name(setOrientation,"setOrientation"),__name(setXAxisTitle,"setXAxisTitle"),__name(setXAxisRangeData,"setXAxisRangeData"),__name(setXAxisBand,"setXAxisBand"),__name(setYAxisTitle,"setYAxisTitle"),__name(setYAxisRangeData,"setYAxisRangeData"),__name(setYAxisRangeFromPlotData,"setYAxisRangeFromPlotData"),__name(transformDataWithoutCategory,"transformDataWithoutCategory"),__name(getPlotColorFromPalette,"getPlotColorFromPalette"),__name(setLineData,"setLineData"),__name(setBarData,"setBarData"),__name(getDrawableElem,"getDrawableElem"),__name(getChartThemeConfig,"getChartThemeConfig"),__name(getChartConfig,"getChartConfig"),__name(getXYChartData,"getXYChartData");var diagram={parser:xychart_default,db:{getDrawableElem:getDrawableElem,clear:__name(function(){clear(),plotIndex=0,xyChartConfig=getChartDefaultConfig(),xyChartData={yAxis:{type:"linear",title:"",min:1/0,max:-1/0},xAxis:{type:"band",title:"",categories:[]},title:"",plots:[]},xyChartThemeConfig=getChartDefaultThemeConfig(),plotColorPalette=xyChartThemeConfig.plotColorPalette.split(",").map(color=>color.trim()),hasSetXAxis=!1,hasSetYAxis=!1},"clear"),setAccTitle:setAccTitle,getAccTitle:getAccTitle,setDiagramTitle:setDiagramTitle,getDiagramTitle:getDiagramTitle,getAccDescription:getAccDescription,setAccDescription:setAccDescription,setOrientation:setOrientation,setXAxisTitle:setXAxisTitle,setXAxisRangeData:setXAxisRangeData,setXAxisBand:setXAxisBand,setYAxisTitle:setYAxisTitle,setYAxisRangeData:setYAxisRangeData,setLineData:setLineData,setBarData:setBarData,setTmpSVGG:setTmpSVGG,getChartThemeConfig:getChartThemeConfig,getChartConfig:getChartConfig,getXYChartData:getXYChartData},renderer:{draw:__name((txt,id,_version,diagObj)=>{const db=diagObj.db,themeConfig=db.getChartThemeConfig(),chartConfig=db.getChartConfig(),labelData=db.getXYChartData().plots[0].data.map(data=>data[1]);function getDominantBaseLine(horizontalPos){return"top"===horizontalPos?"text-before-edge":"middle"}function getTextAnchor(verticalPos){return"left"===verticalPos?"start":"right"===verticalPos?"end":"middle"}function getTextTransformation(data){return`translate(${data.x}, ${data.y}) rotate(${data.rotation||0})`}__name(getDominantBaseLine,"getDominantBaseLine"),__name(getTextAnchor,"getTextAnchor"),__name(getTextTransformation,"getTextTransformation"),log.debug("Rendering xychart chart\n"+txt);const svg=selectSvgElement(id),group=svg.append("g").attr("class","main"),background=group.append("rect").attr("width",chartConfig.width).attr("height",chartConfig.height).attr("class","background");configureSvgSize(svg,chartConfig.height,chartConfig.width,!0),svg.attr("viewBox",`0 0 ${chartConfig.width} ${chartConfig.height}`),background.attr("fill",themeConfig.backgroundColor),db.setTmpSVGG(svg.append("g").attr("class","mermaid-tmp-group"));const shapes=db.getDrawableElem(),groups={};function getGroup(gList){let elem=group,prefix="";for(const[i]of gList.entries()){let parent=group;i>0&&groups[prefix]&&(parent=groups[prefix]),prefix+=gList[i],elem=groups[prefix],elem||(elem=groups[prefix]=parent.append("g").attr("class",gList[i]))}return elem}__name(getGroup,"getGroup");for(const shape of shapes){if(0===shape.data.length)continue;const shapeGroup=getGroup(shape.groupTexts);switch(shape.type){case"rect":if(shapeGroup.selectAll("rect").data(shape.data).enter().append("rect").attr("x",data=>data.x).attr("y",data=>data.y).attr("width",data=>data.width).attr("height",data=>data.height).attr("fill",data=>data.fill).attr("stroke",data=>data.strokeFill).attr("stroke-width",data=>data.strokeWidth),chartConfig.showDataLabel){const showDataLabelOutsideBar=chartConfig.showDataLabelOutsideBar;if("horizontal"===chartConfig.chartOrientation){let fitsHorizontally2=function(item,fontSize){const{data:data,label:label}=item;return fontSize*label.length*charWidthFactor<=data.width-rightMargin};__name(fitsHorizontally2,"fitsHorizontally");const charWidthFactor=.7,rightMargin=10,validItems=shape.data.map((d,i)=>({data:d,label:labelData[i].toString()})).filter(item=>item.data.width>0&&item.data.height>0),candidateFontSizes=validItems.map(item=>{const{data:data}=item;let fontSize=.7*data.height;for(;!fitsHorizontally2(item,fontSize)&&fontSize>0;)fontSize-=1;return fontSize}),uniformFontSize=Math.floor(Math.min(...candidateFontSizes)),determineLabelXPosition=__name(item=>showDataLabelOutsideBar?item.data.x+item.data.width+rightMargin:item.data.x+item.data.width-rightMargin,"determineLabelXPosition");shapeGroup.selectAll("text").data(validItems).enter().append("text").attr("x",determineLabelXPosition).attr("y",item=>item.data.y+item.data.height/2).attr("text-anchor",showDataLabelOutsideBar?"start":"end").attr("dominant-baseline","middle").attr("fill",themeConfig.dataLabelColor).attr("font-size",`${uniformFontSize}px`).text(item=>item.label)}else{let fitsInBar2=function(item,fontSize,yOffset2){const{data:data,label:label}=item,textWidth=fontSize*label.length*.7,centerX=data.x+data.width/2,rightEdge=centerX+textWidth/2,horizontalFits=centerX-textWidth/2>=data.x&&rightEdge<=data.x+data.width,verticalFits=data.y+yOffset2+fontSize<=data.y+data.height;return horizontalFits&&verticalFits};__name(fitsInBar2,"fitsInBar");const yOffset=10,validItems=shape.data.map((d,i)=>({data:d,label:labelData[i].toString()})).filter(item=>item.data.width>0&&item.data.height>0),candidateFontSizes=validItems.map(item=>{const{data:data,label:label}=item;let fontSize=data.width/(.7*label.length);for(;!fitsInBar2(item,fontSize,yOffset)&&fontSize>0;)fontSize-=1;return fontSize}),uniformFontSize=Math.floor(Math.min(...candidateFontSizes)),determineLabelYPosition=__name(item=>showDataLabelOutsideBar?item.data.y-yOffset:item.data.y+yOffset,"determineLabelYPosition");shapeGroup.selectAll("text").data(validItems).enter().append("text").attr("x",item=>item.data.x+item.data.width/2).attr("y",determineLabelYPosition).attr("text-anchor","middle").attr("dominant-baseline",showDataLabelOutsideBar?"auto":"hanging").attr("fill",themeConfig.dataLabelColor).attr("font-size",`${uniformFontSize}px`).text(item=>item.label)}}break;case"text":shapeGroup.selectAll("text").data(shape.data).enter().append("text").attr("x",0).attr("y",0).attr("fill",data=>data.fill).attr("font-size",data=>data.fontSize).attr("dominant-baseline",data=>getDominantBaseLine(data.verticalPos)).attr("text-anchor",data=>getTextAnchor(data.horizontalPos)).attr("transform",data=>getTextTransformation(data)).text(data=>data.text);break;case"path":shapeGroup.selectAll("path").data(shape.data).enter().append("path").attr("d",data=>data.path).attr("fill",data=>data.fill?data.fill:"none").attr("stroke",data=>data.strokeFill).attr("stroke-width",data=>data.strokeWidth)}}},"draw")}};export{diagram};
package/dist/index.html CHANGED
@@ -21,12 +21,11 @@
21
21
  // 整体显示大小已弃用 CSS zoom:Electron 改用 webFrame.setZoomFactor(首屏抢占见
22
22
  // electron/tab-content-preload.js),纯浏览器交由用户用浏览器自带快捷键缩放,故此处不再设 zoom。
23
23
  </script>
24
- <script type="module" crossorigin src="./assets/index-C4Jei4gi.js"></script>
25
- <link rel="modulepreload" crossorigin href="./assets/vendor-antd-FhK5cQx7.js">
26
- <link rel="modulepreload" crossorigin href="./assets/vendor-virtuoso-B_7lc2Ot.js">
27
- <link rel="modulepreload" crossorigin href="./assets/vendor-codemirror-DL3yyKRQ.js">
28
- <link rel="modulepreload" crossorigin href="./assets/vendor-mdxeditor-DgyrvHzS.js">
29
- <link rel="stylesheet" crossorigin href="./assets/index-D3GEPgde.css">
24
+ <script type="module" crossorigin src="./assets/index-DbUpoAFu.js"></script>
25
+ <link rel="modulepreload" crossorigin href="./assets/vendor-antd-DKIytXho.js">
26
+ <link rel="modulepreload" crossorigin href="./assets/vendor-codemirror-4qgXq03k.js">
27
+ <link rel="modulepreload" crossorigin href="./assets/vendor-mdxeditor-D5Z5D9fq.js">
28
+ <link rel="stylesheet" crossorigin href="./assets/index-D1yGak8I.css">
30
29
  </head>
31
30
  <body>
32
31
  <!-- Pre-hydration splash: no SPA CSS yet — keep font-family in sync with --font-ui in src/global.css -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-viewer",
3
- "version": "1.8.10",
3
+ "version": "1.8.12",
4
4
  "description": "Claude Code logging, visualization, and management toolkit — launch a web viewer alongside Claude Code with full request/response tracing, proxy, and mobile support",
5
5
  "license": "MIT",
6
6
  "main": "server.js",
@@ -24,43 +24,65 @@ export function validateSkillName(name) {
24
24
  return true;
25
25
  }
26
26
 
27
- // 解析 SKILL.md frontmatter 的 description。支持 3 种 YAML 形式:
28
- // 1) description: plain text ← 单行
29
- // 2) description: "quoted text" ← 带引号
30
- // 3) description: | ← block scalar(保留换行)
31
- // multi\n line\n content
32
- // 4) description: > ← folded scalar(换行折成空格)
33
- // 失败返 null,UI 兜底"无描述"。
34
- function parseSkillMdFrontmatter(skillDir) {
35
- const mdPath = join(skillDir, 'SKILL.md');
36
- if (!existsSync(mdPath)) return null;
37
- try {
38
- const text = readFileSync(mdPath, 'utf8');
39
- const m = /^---\s*\n([\s\S]*?)\n---/.exec(text);
40
- if (!m) return null;
41
- const lines = m[1].split('\n');
42
- let descIdx = -1, firstVal = '';
43
- for (let i = 0; i < lines.length; i++) {
44
- const lm = /^description\s*:\s*(.*)$/.exec(lines[i]);
45
- if (lm) { descIdx = i; firstVal = lm[1].trim(); break; }
46
- }
47
- if (descIdx < 0) return null;
27
+ // Parse SKILL.md frontmatter text → { name, description } (each string|null),
28
+ // or null when no parseable `---` frontmatter block exists.
29
+ // name: single-line `name: value` (surrounding quotes stripped).
30
+ // description supports 4 YAML forms:
31
+ // 1) description: plain text ← single line
32
+ // 2) description: "quoted text" ← quoted
33
+ // 3) description: | ← block scalar (keeps newlines)
34
+ // 4) description: > ← folded scalar (newlines → spaces)
35
+ // Values that are empty after trimming are returned as null (treated as absent).
36
+ export function parseSkillFrontmatter(text) {
37
+ // Tolerate CRLF line endings (Windows-authored SKILL.md) — otherwise the whole
38
+ // frontmatter block fails to match and valid skills are rejected as INVALID_FRONTMATTER.
39
+ const m = /^---[ \t]*\r?\n([\s\S]*?)\r?\n---/.exec(text);
40
+ if (!m) return null;
41
+ const lines = m[1].split('\n').map((l) => l.replace(/\r$/, ''));
48
42
 
49
- // block scalar: | / |- / > / >-
43
+ let name = null;
44
+ const nm = /^name\s*:\s*(.*)$/m.exec(m[1]);
45
+ if (nm) {
46
+ const v = nm[1].trim().replace(/\r$/, '').replace(/^["']|["']$/g, '');
47
+ name = v || null;
48
+ }
49
+
50
+ let description = null;
51
+ let descIdx = -1, firstVal = '';
52
+ for (let i = 0; i < lines.length; i++) {
53
+ const lm = /^description\s*:\s*(.*)$/.exec(lines[i]);
54
+ if (lm) { descIdx = i; firstVal = lm[1].trim(); break; }
55
+ }
56
+ if (descIdx >= 0) {
50
57
  if (/^[|>][-+]?$/.test(firstVal)) {
58
+ // block scalar: | / |- / > / >-
51
59
  const fold = firstVal.startsWith('>');
52
60
  const collected = [];
53
61
  for (let i = descIdx + 1; i < lines.length; i++) {
54
62
  const line = lines[i];
55
- // 块结束:非空且不以空白字符开头(视为下一个顶级 key)
63
+ // Block ends at a non-empty line without leading whitespace (next top-level key).
56
64
  if (line !== '' && !/^\s/.test(line)) break;
57
65
  collected.push(line.replace(/^\s+/, ''));
58
66
  }
59
67
  while (collected.length && collected[collected.length - 1] === '') collected.pop();
60
- return fold ? collected.join(' ') : collected.join('\n');
68
+ description = fold ? collected.join(' ') : collected.join('\n');
69
+ } else {
70
+ description = firstVal.replace(/^["']|["']$/g, '');
61
71
  }
62
- // 单行 scalar(去首尾引号)
63
- return firstVal.replace(/^["']|["']$/g, '');
72
+ if (!description || !description.trim()) description = null;
73
+ }
74
+
75
+ return { name, description };
76
+ }
77
+
78
+ // Read <skillDir>/SKILL.md and return the frontmatter description (delegates to
79
+ // parseSkillFrontmatter). Returns null on any failure — the UI falls back to "no description".
80
+ function parseSkillMdFrontmatter(skillDir) {
81
+ const mdPath = join(skillDir, 'SKILL.md');
82
+ if (!existsSync(mdPath)) return null;
83
+ try {
84
+ const fm = parseSkillFrontmatter(readFileSync(mdPath, 'utf8'));
85
+ return fm ? fm.description : null;
64
86
  } catch { return null; }
65
87
  }
66
88
 
@@ -17,7 +17,8 @@ import { _projectName } from '../interceptor.js';
17
17
  const FILE_RAW_MIME = {
18
18
  '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg',
19
19
  '.gif': 'image/gif', '.svg': 'image/svg+xml', '.ico': 'image/x-icon',
20
- '.webp': 'image/webp', '.html': 'text/html', '.htm': 'text/html',
20
+ '.webp': 'image/webp', '.bmp': 'image/bmp', '.avif': 'image/avif',
21
+ '.html': 'text/html', '.htm': 'text/html',
21
22
  '.css': 'text/css', '.js': 'text/javascript', '.mjs': 'text/javascript',
22
23
  '.json': 'application/json', '.map': 'application/json', '.txt': 'text/plain',
23
24
  '.woff': 'font/woff', '.woff2': 'font/woff2', '.ttf': 'font/ttf',
@@ -6,7 +6,7 @@ import {
6
6
  import { join, dirname, basename, resolve, sep } from 'node:path';
7
7
  import { homedir, tmpdir } from 'node:os';
8
8
  import { execFile, spawn } from 'node:child_process';
9
- import { bumpWorkspacesVersion } from '../lib/file-access-policy.js';
9
+ import { bumpWorkspacesVersion, isReadAllowed } from '../lib/file-access-policy.js';
10
10
  import { validateImportDir } from '../lib/file-api.js';
11
11
  import { PROFILE_PATH, _projectName, _logDir } from '../interceptor.js';
12
12
  import { LOG_DIR, getClaudeConfigDir } from '../../findcc.js';
@@ -659,6 +659,80 @@ function resolvePath(req, res, parsedUrl, isLocal, deps) {
659
659
  });
660
660
  }
661
661
 
662
+ // Lightweight existence probe for the chat markdown code-span feature: the web
663
+ // client batches path-looking inline code spans here and only renders them
664
+ // clickable when the file provably exists. Uniform {exists:false} for every
665
+ // not-readable-as-regular-file outcome (missing / outside allowlist / denied /
666
+ // directory) — never echoes policy reasons, so this is a strictly weaker oracle
667
+ // than /api/file-content's 404/403 split.
668
+ const FILES_EXISTS_MAX_BATCH = 50;
669
+ const FILES_EXISTS_MAX_PATH = 1024;
670
+ const FILES_EXISTS_MAX_BODY = 256 * 1024; // 50 × 1024 + JSON overhead ≪ this
671
+
672
+ function filesExists(req, res, parsedUrl, isLocal, deps) {
673
+ let body = '';
674
+ let aborted = false;
675
+ req.on('data', chunk => {
676
+ body += chunk;
677
+ if (body.length > FILES_EXISTS_MAX_BODY && !aborted) {
678
+ aborted = true;
679
+ res.writeHead(413, { 'Content-Type': 'application/json' });
680
+ res.end(JSON.stringify({ error: 'Request too large' }));
681
+ req.destroy();
682
+ }
683
+ });
684
+ req.on('end', () => {
685
+ if (aborted) return;
686
+ let parsed;
687
+ try { parsed = JSON.parse(body); } catch {
688
+ res.writeHead(400, { 'Content-Type': 'application/json' });
689
+ res.end(JSON.stringify({ error: 'Invalid request body' }));
690
+ return;
691
+ }
692
+ const paths = parsed && parsed.paths;
693
+ if (!Array.isArray(paths)) {
694
+ res.writeHead(400, { 'Content-Type': 'application/json' });
695
+ res.end(JSON.stringify({ error: 'Invalid paths' }));
696
+ return;
697
+ }
698
+ if (paths.length > FILES_EXISTS_MAX_BATCH) {
699
+ res.writeHead(400, { 'Content-Type': 'application/json' });
700
+ res.end(JSON.stringify({ error: 'Too many paths' }));
701
+ return;
702
+ }
703
+ for (const p of paths) {
704
+ if (typeof p !== 'string' || p.length > FILES_EXISTS_MAX_PATH) {
705
+ res.writeHead(400, { 'Content-Type': 'application/json' });
706
+ res.end(JSON.stringify({ error: 'Invalid path' }));
707
+ return;
708
+ }
709
+ }
710
+ const cwd = process.env.CCV_PROJECT_DIR || process.cwd();
711
+ const results = paths.map(p => ({ path: p, exists: probeFileExists(p, cwd) }));
712
+ res.writeHead(200, { 'Content-Type': 'application/json' });
713
+ res.end(JSON.stringify({ results }));
714
+ });
715
+ }
716
+
717
+ function probeFileExists(p, cwd) {
718
+ try {
719
+ const isAbs = /^([a-zA-Z]:[\\/]|[\\/])/.test(p);
720
+ // Mirrors /api/file-content: a relative `..` segment can never be opened by
721
+ // the click path either, so report it as non-existent rather than 400.
722
+ // Segment-wise check — a legit filename like `foo..bar.md` must not match.
723
+ if (!isAbs && p.split(/[\\/]/).includes('..')) return false;
724
+ // Resolve BEFORE isReadAllowed: realpathSync inside the policy resolves
725
+ // relative input against process.cwd(), which is the app dir (not the
726
+ // project) in packaged Electron runs.
727
+ const absPath = isAbs ? p : resolve(cwd, p);
728
+ const policy = isReadAllowed(absPath);
729
+ if (!policy.ok) return false;
730
+ return statSync(policy.real).isFile();
731
+ } catch {
732
+ return false; // one bad path must not sink the whole batch
733
+ }
734
+ }
735
+
662
736
  function createFile(req, res, parsedUrl, isLocal, deps) {
663
737
  let body = '';
664
738
  req.on('data', chunk => { body += chunk; if (body.length > deps.MAX_POST_BODY) req.destroy(); });
@@ -964,6 +1038,7 @@ export const filesFsRoutes = [
964
1038
  { method: 'POST', match: 'exact', path: '/api/reveal-file', handler: revealFile },
965
1039
  { method: 'POST', match: 'exact', path: '/api/open-file', handler: openFile },
966
1040
  { method: 'POST', match: 'exact', path: '/api/resolve-path', handler: resolvePath },
1041
+ { method: 'POST', match: 'exact', path: '/api/files-exists', handler: filesExists },
967
1042
  { method: 'POST', match: 'exact', path: '/api/create-file', handler: createFile },
968
1043
  { method: 'POST', match: 'exact', path: '/api/open-terminal', handler: openTerminal },
969
1044
  { method: 'POST', match: 'exact', path: '/api/create-dir', handler: createDir },
@@ -2,7 +2,7 @@
2
2
  import { mkdirSync, writeFileSync, existsSync } from 'node:fs';
3
3
  import { join, resolve, sep, dirname } from 'node:path';
4
4
  import { getClaudeConfigDir } from '../../findcc.js';
5
- import { listSkills, moveSkill, deleteSkill, validateSkillName } from '../lib/skills-api.js';
5
+ import { listSkills, moveSkill, deleteSkill, validateSkillName, parseSkillFrontmatter } from '../lib/skills-api.js';
6
6
  import { isAdminReq } from '../lib/is-admin.js';
7
7
 
8
8
  async function skillsList(req, res) {
@@ -81,22 +81,35 @@ function skillsDelete(req, res, parsedUrl, isLocal) {
81
81
  // 设计要点(与原实现一致):
82
82
  // · 扩展名白名单只放 zip / md(忽略大小写);其他类型 415;
83
83
  // · zip 内必须含 SKILL.md(任意子目录、忽略大小写),取最浅的那个所在目录作为 skill 根;
84
- // · skill 名优先取 SKILL.md frontmatter 的 name,回落 zip 根目录名 / 文件名(去扩展名);
84
+ // · Strict spec check (unified across all three entries): SKILL.md frontmatter must contain
85
+ // a name (must pass validateSkillName) and a description; violations reject with
86
+ // INVALID_FRONTMATTER / MISSING_NAME / INVALID_NAME / MISSING_DESCRIPTION — no more
87
+ // filename / zip-root-dir fallback;
85
88
  // · zip bomb 防护:单文件 ≤50MB,总解压 ≤200MB;拒绝 symlink entry。
86
89
 
87
- const parseNameFromMd = (text) => {
88
- const m = /^---\s*\n([\s\S]*?)\n---/.exec(text);
89
- if (!m) return null;
90
- const nm = /^name\s*:\s*(.*)$/m.exec(m[1]);
91
- if (!nm) return null;
92
- return nm[1].trim().replace(/^["']|["']$/g, '');
93
- };
90
+ // Shared size caps for the zip path (declared-size pass + actual-size re-check).
91
+ const MAX_SKILL_FILE = 50 * 1024 * 1024;
92
+ const MAX_SKILL_TOTAL = 200 * 1024 * 1024;
94
93
 
95
- const fallbackBaseName = (filename, stripExt) => {
96
- let n = filename.replace(/^.*[\\/]/, '');
97
- if (stripExt) n = n.replace(/\.[^.]+$/, '');
98
- return n;
99
- };
94
+ // Strict skill-spec validation shared by all three import entries (folder / zip / SKILL.md).
95
+ // Check order is fixed (tests depend on it): no frontmatter block → INVALID_FRONTMATTER;
96
+ // missing name → MISSING_NAME; invalid name → INVALID_NAME; missing description → MISSING_DESCRIPTION.
97
+ function requireSkillSpec(text) {
98
+ const fm = parseSkillFrontmatter(text);
99
+ if (!fm) {
100
+ throw Object.assign(new Error('SKILL.md is missing valid frontmatter'), { status: 400, code: 'INVALID_FRONTMATTER' });
101
+ }
102
+ if (!fm.name) {
103
+ throw Object.assign(new Error('SKILL.md frontmatter is missing a name'), { status: 400, code: 'MISSING_NAME' });
104
+ }
105
+ if (!validateSkillName(fm.name)) {
106
+ throw Object.assign(new Error(`Invalid skill name: ${fm.name}`), { status: 400, code: 'INVALID_NAME' });
107
+ }
108
+ if (!fm.description) {
109
+ throw Object.assign(new Error('SKILL.md frontmatter is missing a description'), { status: 400, code: 'MISSING_DESCRIPTION' });
110
+ }
111
+ return fm;
112
+ }
100
113
 
101
114
  /**
102
115
  * 解析一段 multipart body(已组装好的 Buffer)→ { skillName, files: [{relPath, data}] }。
@@ -136,7 +149,7 @@ export async function parseSkillUpload(buf, boundary, windowsReservedRe) {
136
149
 
137
150
  if (isMd) {
138
151
  const text = fileData.toString('utf8');
139
- skillName = parseNameFromMd(text) || fallbackBaseName(originalName, true);
152
+ skillName = requireSkillSpec(text).name;
140
153
  skillFiles = [{ relPath: 'SKILL.md', data: fileData }];
141
154
  } else {
142
155
  const AdmZip = (await import('adm-zip')).default;
@@ -147,8 +160,6 @@ export async function parseSkillUpload(buf, boundary, windowsReservedRe) {
147
160
  throw Object.assign(new Error('Invalid zip archive'), { status: 400, code: 'INVALID_ZIP' });
148
161
  }
149
162
  const entries = zip.getEntries();
150
- const MAX_PER_FILE = 50 * 1024 * 1024;
151
- const MAX_TOTAL_UNCOMPRESSED = 200 * 1024 * 1024;
152
163
  let totalUncompressed = 0;
153
164
  for (const e of entries) {
154
165
  if (e.isDirectory) continue;
@@ -157,11 +168,11 @@ export async function parseSkillUpload(buf, boundary, windowsReservedRe) {
157
168
  throw Object.assign(new Error('Symlinks not allowed in zip'), { status: 400, code: 'INVALID_ZIP' });
158
169
  }
159
170
  const sizeRaw = e.header?.size || 0;
160
- if (sizeRaw > MAX_PER_FILE) {
171
+ if (sizeRaw > MAX_SKILL_FILE) {
161
172
  throw Object.assign(new Error('File too large in archive'), { status: 400, code: 'ZIP_BOMB' });
162
173
  }
163
174
  totalUncompressed += sizeRaw;
164
- if (totalUncompressed > MAX_TOTAL_UNCOMPRESSED) {
175
+ if (totalUncompressed > MAX_SKILL_TOTAL) {
165
176
  throw Object.assign(new Error('Archive expands too large'), { status: 400, code: 'ZIP_BOMB' });
166
177
  }
167
178
  }
@@ -179,12 +190,16 @@ export async function parseSkillUpload(buf, boundary, windowsReservedRe) {
179
190
  if (!bestSkillEntry) {
180
191
  throw Object.assign(new Error('SKILL.md not found in zip'), { status: 400, code: 'MISSING_SKILL_MD' });
181
192
  }
193
+ // Guard BEFORE inflating: header.size is attacker-controlled, but a declared oversize at
194
+ // least lets us reject before spending memory on getData() (actual-size re-check below
195
+ // still catches a lying small header).
196
+ if ((bestSkillEntry.header?.size || 0) > MAX_SKILL_FILE) {
197
+ throw Object.assign(new Error('File too large in archive'), { status: 400, code: 'ZIP_BOMB' });
198
+ }
182
199
  const lastSlash = bestSkillEntry.entryName.lastIndexOf('/');
183
200
  const skillRootPrefix = lastSlash >= 0 ? bestSkillEntry.entryName.slice(0, lastSlash + 1) : '';
184
201
  const skillMdText = bestSkillEntry.getData().toString('utf8');
185
- skillName = parseNameFromMd(skillMdText)
186
- || (skillRootPrefix ? skillRootPrefix.replace(/\/$/, '').split('/').pop() : null)
187
- || fallbackBaseName(originalName, true);
202
+ skillName = requireSkillSpec(skillMdText).name;
188
203
 
189
204
  // 二次校验:header.size 来自 zip 中央目录是攻击者可控的(可谎报 size=0),用真实 data.length 复核。
190
205
  let actualTotal = 0;
@@ -194,11 +209,11 @@ export async function parseSkillUpload(buf, boundary, windowsReservedRe) {
194
209
  const rel = skillRootPrefix ? e.entryName.slice(skillRootPrefix.length) : e.entryName;
195
210
  if (!rel || rel.includes('..')) continue;
196
211
  const data = e.getData();
197
- if (data.length > MAX_PER_FILE) {
212
+ if (data.length > MAX_SKILL_FILE) {
198
213
  throw Object.assign(new Error('File actual size too large'), { status: 400, code: 'ZIP_BOMB' });
199
214
  }
200
215
  actualTotal += data.length;
201
- if (actualTotal > MAX_TOTAL_UNCOMPRESSED) {
216
+ if (actualTotal > MAX_SKILL_TOTAL) {
202
217
  throw Object.assign(new Error('Archive actual size too large'), { status: 400, code: 'ZIP_BOMB' });
203
218
  }
204
219
  const finalRel = rel.split('/').pop().toLowerCase() === 'skill.md'
@@ -208,6 +223,8 @@ export async function parseSkillUpload(buf, boundary, windowsReservedRe) {
208
223
  }
209
224
  }
210
225
 
226
+ // defense-in-depth: requireSkillSpec already validated the name (and would have
227
+ // thrown first); keep this re-check so future refactors can't silently skip it.
211
228
  if (!validateSkillName(skillName)) {
212
229
  throw Object.assign(new Error(`Invalid skill name: ${skillName}`), { status: 400, code: 'INVALID_NAME' });
213
230
  }
@@ -264,7 +281,8 @@ export function importSkillTo(req, res, { skillsRoot, windowsReserved }) {
264
281
  const contentLength = parseInt(req.headers['content-length'] || '0', 10);
265
282
  if (contentLength > MAX_UPLOAD) {
266
283
  res.writeHead(413, { 'Content-Type': 'application/json' });
267
- res.end(JSON.stringify({ error: 'File too large (max 100MB)' }));
284
+ // code 字段供前端 skillImportErrorKey 映射成 i18n 文案,而不是裸英文
285
+ res.end(JSON.stringify({ error: 'File too large (max 100MB)', code: 'TOO_LARGE' }));
268
286
  return;
269
287
  }
270
288
  const boundary = boundaryMatch[1].trim().replace(/^["']|["']$/g, '');
@@ -276,7 +294,7 @@ export function importSkillTo(req, res, { skillsRoot, windowsReserved }) {
276
294
  if (totalSize > MAX_UPLOAD) {
277
295
  aborted = true;
278
296
  res.writeHead(413, { 'Content-Type': 'application/json' });
279
- res.end(JSON.stringify({ error: 'File too large (max 100MB)' }));
297
+ res.end(JSON.stringify({ error: 'File too large (max 100MB)', code: 'TOO_LARGE' }));
280
298
  req.destroy();
281
299
  return;
282
300
  }