cc-viewer 1.8.4 → 1.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +39 -1
- package/dist/assets/{App-CUz2vao6.js → App-QfR6J-2-.js} +2 -2
- package/dist/assets/MdxEditorPanel-BEab9H3Q.js +1 -0
- package/dist/assets/{Mobile-CEXns9fY.js → Mobile-XUIomH49.js} +1 -1
- package/dist/assets/{ProxyStatsModal-COBPefXw.js → ProxyStatsModal-Bawmf1xu.js} +1 -1
- package/dist/assets/{_baseUniq-BvoL7sea.js → _baseUniq-D2aO8mv4.js} +1 -1
- package/dist/assets/{arc-CWSgghLO.js → arc-DOjcnBTh.js} +1 -1
- package/dist/assets/architectureDiagram-Q4EWVU46-Drea2H7X.js +1 -0
- package/dist/assets/blockDiagram-DXYQGD6D-Bc9eijBD.js +1 -0
- package/dist/assets/c4Diagram-AHTNJAMY-D-umzFnM.js +1 -0
- package/dist/assets/{channel-NrrRrxlA.js → channel-DUff3FBt.js} +1 -1
- package/dist/assets/{chunk-4BX2VUAB-DJvzFKwQ.js → chunk-4BX2VUAB-CFnsROfz.js} +1 -1
- package/dist/assets/{chunk-4TB4RGXK-BtkeuMYF.js → chunk-4TB4RGXK-C95jMPjB.js} +1 -1
- package/dist/assets/{chunk-55IACEB6-B9KZe48-.js → chunk-55IACEB6-CeWf2Y2b.js} +1 -1
- package/dist/assets/{chunk-EDXVE4YY-CrC8aHms.js → chunk-EDXVE4YY-ClUoTJxv.js} +1 -1
- package/dist/assets/{chunk-FMBD7UC4-CsMZhbHS.js → chunk-FMBD7UC4-Dk62kqb8.js} +1 -1
- package/dist/assets/{chunk-OYMX7WX6-DzMU24Av.js → chunk-OYMX7WX6-CZuykSsu.js} +1 -1
- package/dist/assets/{chunk-QZHKN3VN-DQg8aTq0.js → chunk-QZHKN3VN-DYtx68Um.js} +1 -1
- package/dist/assets/{chunk-YZCP3GAM-DiH0m9X5.js → chunk-YZCP3GAM-rLSq0tSC.js} +1 -1
- package/dist/assets/classDiagram-6PBFFD2Q-DT8RQXlO.js +1 -0
- package/dist/assets/classDiagram-v2-HSJHXN6E-DT8RQXlO.js +1 -0
- package/dist/assets/clone-_dhVVwEt.js +1 -0
- package/dist/assets/cose-bilkent-S5V4N54A-B5H6ewon.js +1 -0
- package/dist/assets/dagre-KV5264BT-BO2R2WP7.js +1 -0
- package/dist/assets/diagram-5BDNPKRD-Y3GNif-g.js +1 -0
- package/dist/assets/diagram-G4DWMVQ6-Du3_TylQ.js +1 -0
- package/dist/assets/diagram-MMDJMWI5-DB_Ynyjc.js +1 -0
- package/dist/assets/diagram-TYMM5635-_Rfjm82W.js +1 -0
- package/dist/assets/erDiagram-SMLLAGMA-D5XhBiiV.js +1 -0
- package/dist/assets/flowDiagram-DWJPFMVM-CxWJ7sAQ.js +1 -0
- package/dist/assets/ganttDiagram-T4ZO3ILL-D-a8fh00.js +1 -0
- package/dist/assets/gitGraphDiagram-UUTBAWPF-q5WMk0Ce.js +1 -0
- package/dist/assets/{graph-BHosumIo.js → graph-Bi8xMAuo.js} +1 -1
- package/dist/assets/index-3Z3ucdlB.js +1 -0
- package/dist/assets/index-BB66PLo6.js +1 -0
- package/dist/assets/index-BBEH6Ppx.js +1 -0
- package/dist/assets/index-BRtbpMRz.js +1 -0
- package/dist/assets/index-BWPHHS6P.js +1 -0
- package/dist/assets/index-C3wsDB-y.js +1 -0
- package/dist/assets/index-O2Mx9uLd.js +1 -0
- package/dist/assets/index-gBheYuc_.js +2 -0
- package/dist/assets/infoDiagram-42DDH7IO-CE2mUuLF.js +1 -0
- package/dist/assets/ishikawaDiagram-UXIWVN3A-C5sNQIVL.js +1 -0
- package/dist/assets/journeyDiagram-VCZTEJTY-g7HXOeyX.js +1 -0
- package/dist/assets/{jszip.min-B7ufzfHi.js → jszip.min-x3xOZxY_.js} +1 -1
- package/dist/assets/kanban-definition-6JOO6SKY-D3Mus6hc.js +1 -0
- package/dist/assets/{layout-D5zEy4mK.js → layout-05qDuweB.js} +1 -1
- package/dist/assets/{linear-BAPnyqP4.js → linear-DQEG_N-F.js} +1 -1
- package/dist/assets/{mermaid.core-C8GuIPOP.js → mermaid.core-DcaXqkk5.js} +2 -2
- package/dist/assets/{min-DP92r0cl.js → min-DSpvw5zG.js} +1 -1
- package/dist/assets/mindmap-definition-QFDTVHPH-DomUIop7.js +1 -0
- package/dist/assets/pieDiagram-DEJITSTG-COTLcC5G.js +1 -0
- package/dist/assets/quadrantDiagram-34T5L4WZ-DMg8C3Up.js +1 -0
- package/dist/assets/requirementDiagram-MS252O5E-DF9beYd7.js +1 -0
- package/dist/assets/sankeyDiagram-XADWPNL6-MvERK2UP.js +1 -0
- package/dist/assets/seqResourceLoaders-KWixB6L_.js +2 -0
- package/dist/assets/{seqResourceLoaders-DI0G5nu1.css → seqResourceLoaders-vliPauH9.css} +2 -2
- package/dist/assets/sequenceDiagram-FGHM5R23-B8k_nyzc.js +1 -0
- package/dist/assets/stateDiagram-FHFEXIEX-D-9fTYas.js +1 -0
- package/dist/assets/stateDiagram-v2-QKLJ7IA2-CO0tv8rD.js +1 -0
- package/dist/assets/timeline-definition-GMOUNBTQ-CbK1g9CO.js +1 -0
- package/dist/assets/{vendor-antd-CSjy2pdD.js → vendor-antd-FhK5cQx7.js} +1 -1
- package/dist/assets/vendor-codemirror-DL3yyKRQ.js +1 -0
- package/dist/assets/vendor-mdxeditor-DgyrvHzS.js +2 -0
- package/dist/assets/{vendor-qrcode-Bs-eoLpy.js → vendor-qrcode-BAwwP1Nd.js} +1 -1
- package/dist/assets/vendor-virtuoso-B_7lc2Ot.js +1 -0
- package/dist/assets/vennDiagram-DHZGUBPP-DYjGtMA5.js +1 -0
- package/dist/assets/{wardley-RL74JXVD-CvCX-J_r.js → wardley-RL74JXVD-Djh5alV9.js} +1 -1
- package/dist/assets/wardleyDiagram-NUSXRM2D-al50Jlxp.js +1 -0
- package/dist/assets/xychartDiagram-5P7HB3ND-Bl969-3U.js +1 -0
- package/dist/index.html +5 -4
- package/package.json +1 -1
- package/server/lib/code-search.js +82 -139
- package/server/lib/ensure-hooks.js +62 -5
- package/server/lib/launch-config.js +31 -0
- package/server/lib/search-worker.js +214 -0
- package/server/lib/session-start-bridge.js +5 -1
- package/server/lib/task-bridge.js +136 -0
- package/server/lib/task-state.js +150 -0
- package/server/pty-manager.js +8 -2
- package/server/routes/events.js +56 -0
- package/server/server.js +61 -0
- package/dist/assets/MdxEditorPanel-6tJrZws0.js +0 -1
- package/dist/assets/architectureDiagram-Q4EWVU46-hxmrC4g0.js +0 -1
- package/dist/assets/blockDiagram-DXYQGD6D-D3Ie-HJv.js +0 -1
- package/dist/assets/c4Diagram-AHTNJAMY-Bqi7HUr9.js +0 -1
- package/dist/assets/classDiagram-6PBFFD2Q-DiDwaKTt.js +0 -1
- package/dist/assets/classDiagram-v2-HSJHXN6E-DiDwaKTt.js +0 -1
- package/dist/assets/clone-N9s0k-Pj.js +0 -1
- package/dist/assets/cose-bilkent-S5V4N54A-Cuw7G_qy.js +0 -1
- package/dist/assets/dagre-KV5264BT-qqKh51pl.js +0 -1
- package/dist/assets/diagram-5BDNPKRD-B-pBCkaj.js +0 -1
- package/dist/assets/diagram-G4DWMVQ6-sdTDQV0t.js +0 -1
- package/dist/assets/diagram-MMDJMWI5-CelfzJxz.js +0 -1
- package/dist/assets/diagram-TYMM5635-z0RlpFuK.js +0 -1
- package/dist/assets/erDiagram-SMLLAGMA-BHI2bnGz.js +0 -1
- package/dist/assets/flowDiagram-DWJPFMVM-I1SWP3XA.js +0 -1
- package/dist/assets/ganttDiagram-T4ZO3ILL-DZh82zoq.js +0 -1
- package/dist/assets/gitGraphDiagram-UUTBAWPF-DsMWEHvH.js +0 -1
- package/dist/assets/index-CGG82Lfj.js +0 -1
- package/dist/assets/index-CPC2RsfO.js +0 -2
- package/dist/assets/index-CiJgRlSn.js +0 -1
- package/dist/assets/index-Dn7Vc5py.js +0 -1
- package/dist/assets/index-DnekML0c.js +0 -1
- package/dist/assets/index-VFaPBr79.js +0 -1
- package/dist/assets/index-_nQUY-oI.js +0 -1
- package/dist/assets/index-s7YuKwmu.js +0 -1
- package/dist/assets/infoDiagram-42DDH7IO-DBi-2oXp.js +0 -1
- package/dist/assets/ishikawaDiagram-UXIWVN3A-fIVocwqv.js +0 -1
- package/dist/assets/journeyDiagram-VCZTEJTY-CTSi1qOI.js +0 -1
- package/dist/assets/kanban-definition-6JOO6SKY-U8kfIi3w.js +0 -1
- package/dist/assets/mindmap-definition-QFDTVHPH-CCrRqC11.js +0 -1
- package/dist/assets/pieDiagram-DEJITSTG-BrMSbuT1.js +0 -1
- package/dist/assets/quadrantDiagram-34T5L4WZ-3K-JFsjs.js +0 -1
- package/dist/assets/requirementDiagram-MS252O5E-CiqMG6uM.js +0 -1
- package/dist/assets/sankeyDiagram-XADWPNL6-CM98y9LX.js +0 -1
- package/dist/assets/seqResourceLoaders-CjHZJGi0.js +0 -2
- package/dist/assets/sequenceDiagram-FGHM5R23-C4x_1BvX.js +0 -1
- package/dist/assets/stateDiagram-FHFEXIEX-DyPisIEy.js +0 -1
- package/dist/assets/stateDiagram-v2-QKLJ7IA2-1n69gYPg.js +0 -1
- package/dist/assets/timeline-definition-GMOUNBTQ-CRnoneDr.js +0 -1
- package/dist/assets/vendor-codemirror-Clv6kvI5.js +0 -1
- package/dist/assets/vendor-mdxeditor-CtujsSUV.js +0 -2
- package/dist/assets/vendor-virtuoso-DsaYo4Fi.js +0 -1
- package/dist/assets/vennDiagram-DHZGUBPP-JQY_eM5i.js +0 -1
- package/dist/assets/wardleyDiagram-NUSXRM2D-C1ZrJXnG.js +0 -1
- package/dist/assets/xychartDiagram-5P7HB3ND-hR1VN6u6.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-DcaXqkk5.js";import{p as populateCommonDb}from"./chunk-4BX2VUAB-CFnsROfz.js";import{p as parse}from"./wardley-RL74JXVD-Djh5alV9.js";import"./vendor-mdxeditor-DgyrvHzS.js";import"./vendor-antd-FhK5cQx7.js";import"./vendor-virtuoso-B_7lc2Ot.js";import"./vendor-codemirror-DL3yyKRQ.js";import"./vendor-markdown-DOJHsAxX.js";import"./min-DSpvw5zG.js";import"./_baseUniq-D2aO8mv4.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-DcaXqkk5.js";import{i as initRange}from"./init-DMZMl1PR.js";import{o as ordinal}from"./ordinal-DA-_8pMy.js";import{l as linear}from"./linear-DQEG_N-F.js";import"./vendor-mdxeditor-DgyrvHzS.js";import"./vendor-antd-FhK5cQx7.js";import"./vendor-virtuoso-B_7lc2Ot.js";import"./vendor-codemirror-DL3yyKRQ.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,10 +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-
|
|
25
|
-
<link rel="modulepreload" crossorigin href="./assets/vendor-antd-
|
|
26
|
-
<link rel="modulepreload" crossorigin href="./assets/vendor-
|
|
27
|
-
<link rel="modulepreload" crossorigin href="./assets/vendor-
|
|
24
|
+
<script type="module" crossorigin src="./assets/index-gBheYuc_.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">
|
|
28
29
|
<link rel="stylesheet" crossorigin href="./assets/index-D3GEPgde.css">
|
|
29
30
|
</head>
|
|
30
31
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-viewer",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.7",
|
|
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",
|
|
@@ -4,16 +4,17 @@
|
|
|
4
4
|
// - ripgrep (`rg --json`): fast, respects .gitignore, skips hidden + binary natively.
|
|
5
5
|
// - node (pure walker): fallback when rg is absent; deliberately mirrors rg's file
|
|
6
6
|
// selection (gitignore-aware via `git ls-files`, hidden skipped) so both
|
|
7
|
-
// engines return the SAME results.
|
|
7
|
+
// engines return the SAME results. The scan itself runs in a worker thread
|
|
8
|
+
// (search-worker.js) — its per-file sync fs + per-line regex would otherwise
|
|
9
|
+
// pin the server event loop on large trees (in Electron each tab's server is a
|
|
10
|
+
// forked process, so a scan would freeze that tab's SSE/WS/PTY traffic).
|
|
8
11
|
//
|
|
9
12
|
// Security: the node engine reads arbitrary project files, so every candidate is gated
|
|
10
13
|
// through isReadAllowed(realpath) and symlinks are skipped — a symlinked file must not be
|
|
11
14
|
// able to exfiltrate secrets (e.g. notes.txt -> ~/.ssh/id_rsa). rg does not follow symlinks.
|
|
12
15
|
import { spawn } from 'node:child_process';
|
|
13
|
-
import {
|
|
14
|
-
import { join } from 'node:path';
|
|
16
|
+
import { Worker } from 'node:worker_threads';
|
|
15
17
|
import { StringDecoder } from 'node:string_decoder';
|
|
16
|
-
import { isReadAllowed } from './file-access-policy.js';
|
|
17
18
|
|
|
18
19
|
// Directory/entry names never searched (superset of server IGNORED_PATTERNS + node_modules).
|
|
19
20
|
export const IGNORED_NAMES = new Set(['.git', '.svn', '.hg', '.DS_Store', '.idea', '.vscode', 'node_modules']);
|
|
@@ -50,9 +51,10 @@ export function buildQueryRegExp({ query, regex, wholeWord, caseSensitive }) {
|
|
|
50
51
|
/**
|
|
51
52
|
* Conservative guard against classic exponential-backtracking patterns — a quantified group
|
|
52
53
|
* whose body already contains a quantifier, e.g. (a+)+, (.*)*, (a+){2,}. The node engine scans
|
|
53
|
-
* with JS RegExp (backtracking)
|
|
54
|
-
*
|
|
55
|
-
* exhaustive — defense-in-depth for the fallback path; matched
|
|
54
|
+
* with JS RegExp (backtracking), so one such pattern on a modest line can pin the scan (today
|
|
55
|
+
* that's the search worker's own loop; previously the server's). ripgrep uses a linear engine
|
|
56
|
+
* and needs no guard. Not exhaustive — defense-in-depth for the fallback path; matched
|
|
57
|
+
* patterns are rejected as invalid.
|
|
56
58
|
*/
|
|
57
59
|
export function looksCatastrophic(pattern) {
|
|
58
60
|
return /\([^()]*[+*}][^()]*\)\s*[+*]/.test(pattern)
|
|
@@ -104,20 +106,6 @@ export function globToRegExp(glob) {
|
|
|
104
106
|
return new RegExp('^' + re + '$');
|
|
105
107
|
}
|
|
106
108
|
|
|
107
|
-
function makeGlobFilter(includeGlobs, excludeGlobs) {
|
|
108
|
-
// Parity with rg: a '!'-prefixed entry in the include field is a negation (exclude),
|
|
109
|
-
// mirroring rg's `-g !glob`. globToRegExp strips the leading '!'.
|
|
110
|
-
const inc = [];
|
|
111
|
-
const exc = [];
|
|
112
|
-
for (const g of includeGlobs || []) { if (!g) continue; (g.startsWith('!') ? exc : inc).push(globToRegExp(g)); }
|
|
113
|
-
for (const g of excludeGlobs || []) { if (!g) continue; exc.push(globToRegExp(g)); }
|
|
114
|
-
return (relPath) => {
|
|
115
|
-
if (inc.length && !inc.some((r) => r.test(relPath))) return false;
|
|
116
|
-
if (exc.some((r) => r.test(relPath))) return false;
|
|
117
|
-
return true;
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
109
|
export function normRel(p) {
|
|
122
110
|
let s = String(p).replace(/\\/g, '/');
|
|
123
111
|
if (s.startsWith('./')) s = s.slice(2);
|
|
@@ -287,50 +275,6 @@ function rgSearch(opts) {
|
|
|
287
275
|
});
|
|
288
276
|
}
|
|
289
277
|
|
|
290
|
-
// ─── node engine ────────────────────────────────────────────────────
|
|
291
|
-
|
|
292
|
-
function gitListFiles(root, signal) {
|
|
293
|
-
return new Promise((resolve) => {
|
|
294
|
-
let child;
|
|
295
|
-
try {
|
|
296
|
-
child = spawn('git', ['ls-files', '--cached', '--others', '--exclude-standard', '-z'],
|
|
297
|
-
{ cwd: root, windowsHide: true, signal });
|
|
298
|
-
} catch { resolve(null); return; }
|
|
299
|
-
let out = '';
|
|
300
|
-
const decoder = new StringDecoder('utf8');
|
|
301
|
-
// Bound a hung git (index.lock contention, slow/NFS mount) so nodeSearch always resolves.
|
|
302
|
-
const timer = setTimeout(() => { try { child.kill(); } catch { /* gone */ } }, GIT_LS_FILES_TIMEOUT_MS);
|
|
303
|
-
child.stdout.on('data', (d) => { out += decoder.write(d); });
|
|
304
|
-
child.stdout.on('error', () => {});
|
|
305
|
-
child.on('error', () => { clearTimeout(timer); resolve(null); });
|
|
306
|
-
child.on('close', (code) => {
|
|
307
|
-
clearTimeout(timer);
|
|
308
|
-
out += decoder.end();
|
|
309
|
-
if (code !== 0) { resolve(null); return; }
|
|
310
|
-
resolve(out.split('\0').filter(Boolean));
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
function walkDir(root) {
|
|
316
|
-
const out = [];
|
|
317
|
-
const stack = [''];
|
|
318
|
-
while (stack.length) {
|
|
319
|
-
const rel = stack.pop();
|
|
320
|
-
let entries;
|
|
321
|
-
try { entries = readdirSync(rel ? join(root, rel) : root, { withFileTypes: true }); }
|
|
322
|
-
catch { continue; }
|
|
323
|
-
for (const e of entries) {
|
|
324
|
-
if (e.name.startsWith('.') || IGNORED_NAMES.has(e.name)) continue;
|
|
325
|
-
const childRel = rel ? `${rel}/${e.name}` : e.name;
|
|
326
|
-
if (e.isSymbolicLink()) continue; // don't follow symlinks (parity + safety)
|
|
327
|
-
if (e.isDirectory()) stack.push(childRel);
|
|
328
|
-
else if (e.isFile()) out.push(childRel);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
return out;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
278
|
export function isHidden(relPath) {
|
|
335
279
|
return relPath.split('/').some((seg) => seg.startsWith('.'));
|
|
336
280
|
}
|
|
@@ -345,78 +289,67 @@ export function isBinary(buf, n = DEFAULTS.binarySniffBytes) {
|
|
|
345
289
|
return false;
|
|
346
290
|
}
|
|
347
291
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
const maxResults = opts.maxResults ?? DEFAULTS.maxResults;
|
|
355
|
-
const maxPerFile = opts.maxMatchesPerFile ?? DEFAULTS.maxMatchesPerFile;
|
|
356
|
-
const maxFileSize = opts.maxFileSize ?? DEFAULTS.maxFileSize;
|
|
357
|
-
const timeBudget = opts.nodeTimeBudgetMs ?? DEFAULTS.nodeTimeBudgetMs;
|
|
358
|
-
const started = Date.now();
|
|
292
|
+
// ─── node engine (worker thread) ────────────────────────────────────
|
|
293
|
+
//
|
|
294
|
+
// The scan body lives in ./search-worker.js and runs on a worker thread; here we only spawn
|
|
295
|
+
// one worker per query, bridge abort → terminate, and adapt the message protocol back to the
|
|
296
|
+
// {results, truncated, filesScanned} shape. A worker failure rejects → searchCode()'s auto
|
|
297
|
+
// path surfaces it as a 500 (an in-process retry would reintroduce the freeze we're fixing).
|
|
359
298
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
if (
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
try { raw = readFileSync(real); } catch { continue; }
|
|
394
|
-
if (isBinary(raw)) continue;
|
|
395
|
-
|
|
396
|
-
scanned.add(rel);
|
|
397
|
-
const lines = raw.toString('utf8').split(/\r?\n/);
|
|
398
|
-
let stop = false;
|
|
399
|
-
for (let i = 0; i < lines.length && !stop; i++) {
|
|
400
|
-
const text = lines[i];
|
|
401
|
-
if (!text || text.length > DEFAULTS.maxLineLength) continue; // skip empty / pathological long lines
|
|
402
|
-
opts.queryRe.lastIndex = 0;
|
|
403
|
-
const submatches = [];
|
|
404
|
-
let m;
|
|
405
|
-
while ((m = opts.queryRe.exec(text)) !== null) {
|
|
406
|
-
const start = m.index;
|
|
407
|
-
const end = m.index + m[0].length;
|
|
408
|
-
if (end > start) submatches.push({ start, end });
|
|
409
|
-
if (m.index === opts.queryRe.lastIndex) opts.queryRe.lastIndex++; // zero-width guard
|
|
410
|
-
if (submatches.length >= 1000) break; // pathological single-line match count
|
|
411
|
-
}
|
|
412
|
-
if (submatches.length) {
|
|
413
|
-
const ok = grouper.add(rel, { line: i + 1, text: text.slice(0, DEFAULTS.maxLineLength), submatches });
|
|
414
|
-
if (!ok) { truncated = true; stop = true; }
|
|
415
|
-
}
|
|
299
|
+
function nodeSearch(opts) {
|
|
300
|
+
return new Promise((resolve, reject) => {
|
|
301
|
+
let worker;
|
|
302
|
+
try {
|
|
303
|
+
worker = new Worker(new URL('./search-worker.js', import.meta.url), {
|
|
304
|
+
workerData: {
|
|
305
|
+
root: opts.root,
|
|
306
|
+
query: opts.query,
|
|
307
|
+
caseSensitive: !!opts.caseSensitive,
|
|
308
|
+
wholeWord: !!opts.wholeWord,
|
|
309
|
+
regex: !!opts.regex,
|
|
310
|
+
includeGlobs: opts.includeGlobs || [],
|
|
311
|
+
excludeGlobs: opts.excludeGlobs || [],
|
|
312
|
+
maxResults: opts.maxResults,
|
|
313
|
+
maxMatchesPerFile: opts.maxMatchesPerFile,
|
|
314
|
+
maxFileSize: opts.maxFileSize,
|
|
315
|
+
nodeTimeBudgetMs: opts.nodeTimeBudgetMs,
|
|
316
|
+
},
|
|
317
|
+
});
|
|
318
|
+
} catch (err) { reject(err); return; }
|
|
319
|
+
|
|
320
|
+
let settled = false;
|
|
321
|
+
const settle = (fn, val) => {
|
|
322
|
+
if (settled) return;
|
|
323
|
+
settled = true;
|
|
324
|
+
worker.terminate().catch(() => {});
|
|
325
|
+
fn(val);
|
|
326
|
+
};
|
|
327
|
+
const onAbort = () => settle(resolve, { results: [], truncated: true, filesScanned: 0 });
|
|
328
|
+
|
|
329
|
+
if (opts.signal) {
|
|
330
|
+
if (opts.signal.aborted) { onAbort(); return; }
|
|
331
|
+
opts.signal.addEventListener('abort', onAbort, { once: true });
|
|
416
332
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
333
|
+
|
|
334
|
+
worker.on('message', (msg) => {
|
|
335
|
+
if (!msg || typeof msg !== 'object') return;
|
|
336
|
+
if (msg.type === 'done') {
|
|
337
|
+
settle(resolve, { results: msg.results, truncated: msg.truncated, filesScanned: msg.filesScanned });
|
|
338
|
+
} else if (msg.type === 'error') {
|
|
339
|
+
const e = new Error(msg.error || 'search_failed');
|
|
340
|
+
e.code = msg.error === 'invalid_regex' ? 'INVALID_REGEX' : 'SEARCH_FAILED';
|
|
341
|
+
settle(reject, e);
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
worker.on('error', (err) => settle(reject, err));
|
|
345
|
+
worker.on('exit', (code) => {
|
|
346
|
+
// A non-zero exit before a 'done' message means the scan died mid-flight.
|
|
347
|
+
if (!settled && code !== 0) {
|
|
348
|
+
const e = new Error('search worker exited'); e.code = 'SEARCH_FAILED';
|
|
349
|
+
settle(reject, e);
|
|
350
|
+
} else settle(resolve, { results: [], truncated: true, filesScanned: 0 });
|
|
351
|
+
});
|
|
352
|
+
});
|
|
420
353
|
}
|
|
421
354
|
|
|
422
355
|
// ─── Public entry ───────────────────────────────────────────────────
|
|
@@ -468,13 +401,23 @@ export async function searchCode(opts) {
|
|
|
468
401
|
// rather than 500-ing a query the fallback would have handled. Explicit engine:'ripgrep'
|
|
469
402
|
// surfaces the error.
|
|
470
403
|
if (engine === 'auto') {
|
|
471
|
-
|
|
472
|
-
|
|
404
|
+
try {
|
|
405
|
+
const r = await nodeSearch(runOpts);
|
|
406
|
+
return { ...r, engine: 'node', elapsedMs: Date.now() - started };
|
|
407
|
+
} catch (nodeErr) {
|
|
408
|
+
if (nodeErr.code === 'INVALID_REGEX') return empty({ engine: 'node', error: 'invalid_regex' });
|
|
409
|
+
throw nodeErr;
|
|
410
|
+
}
|
|
473
411
|
}
|
|
474
412
|
throw err;
|
|
475
413
|
}
|
|
476
414
|
}
|
|
477
415
|
|
|
478
|
-
|
|
479
|
-
|
|
416
|
+
try {
|
|
417
|
+
const r = await nodeSearch(runOpts);
|
|
418
|
+
return { ...r, engine: 'node', elapsedMs: Date.now() - started };
|
|
419
|
+
} catch (nodeErr) {
|
|
420
|
+
if (nodeErr.code === 'INVALID_REGEX') return empty({ engine: 'node', error: 'invalid_regex' });
|
|
421
|
+
throw nodeErr;
|
|
422
|
+
}
|
|
480
423
|
}
|
|
@@ -76,9 +76,14 @@ function _looksStaleManagedCommand(cmd) {
|
|
|
76
76
|
return !existsSync(target);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
// All hook sections cc-viewer manages. _purgeStaleManagedHooks and
|
|
80
|
+
// removeAllManagedHooks must iterate this exact set or uninstall/cleanup
|
|
81
|
+
// leaves zombie entries behind (cli.js cleanup-hooks path).
|
|
82
|
+
const MANAGED_SECTIONS = ['PreToolUse', 'Stop', 'SessionStart', 'TaskCreated', 'TaskCompleted', 'PostToolUse'];
|
|
83
|
+
|
|
79
84
|
function _purgeStaleManagedHooks(settings) {
|
|
80
85
|
let removed = 0;
|
|
81
|
-
for (const sectionKey of
|
|
86
|
+
for (const sectionKey of MANAGED_SECTIONS) {
|
|
82
87
|
const arr = settings.hooks?.[sectionKey];
|
|
83
88
|
if (!Array.isArray(arr)) continue;
|
|
84
89
|
for (let i = arr.length - 1; i >= 0; i--) {
|
|
@@ -99,7 +104,7 @@ function _purgeStaleManagedHooks(settings) {
|
|
|
99
104
|
// 调用方负责 atomic write-back。返回 removed 数量。
|
|
100
105
|
export function removeAllManagedHooks(settings) {
|
|
101
106
|
let removed = 0;
|
|
102
|
-
for (const sectionKey of
|
|
107
|
+
for (const sectionKey of MANAGED_SECTIONS) {
|
|
103
108
|
const arr = settings.hooks?.[sectionKey];
|
|
104
109
|
if (!Array.isArray(arr)) continue;
|
|
105
110
|
for (let i = arr.length - 1; i >= 0; i--) {
|
|
@@ -127,9 +132,11 @@ export function ensureHooks() {
|
|
|
127
132
|
}
|
|
128
133
|
|
|
129
134
|
if (!settings.hooks) settings.hooks = {};
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
135
|
+
// Init every managed section from the single source of truth — adding a
|
|
136
|
+
// section to MANAGED_SECTIONS without an init here would crash the push.
|
|
137
|
+
for (const k of MANAGED_SECTIONS) {
|
|
138
|
+
if (!Array.isArray(settings.hooks[k])) settings.hooks[k] = [];
|
|
139
|
+
}
|
|
133
140
|
|
|
134
141
|
let changed = false;
|
|
135
142
|
// 先一次性清掉「path 已 stale 但还带 cc-viewer-managed marker」的老条目,
|
|
@@ -240,6 +247,56 @@ export function ensureHooks() {
|
|
|
240
247
|
changed = true;
|
|
241
248
|
}
|
|
242
249
|
|
|
250
|
+
// Task checklist hooks → task-bridge.js. Feed the GUI task-progress HUD:
|
|
251
|
+
// TaskCreated/TaskCompleted are matcher-less lifecycle events (a matcher
|
|
252
|
+
// would be silently ignored by Claude Code); in_progress/deleted/owner
|
|
253
|
+
// transitions have no dedicated hook event, so they ride PostToolUse with
|
|
254
|
+
// matcher 'TaskUpdate'. Find-by-command (NOT find-by-matcher): a user may
|
|
255
|
+
// legitimately have their own PostToolUse/'TaskUpdate' entry, and
|
|
256
|
+
// in-place overwriting would clobber it — multiple entries per matcher
|
|
257
|
+
// are valid config, so we always append our own.
|
|
258
|
+
const taskBridgePath = resolve(SERVER_LIB, 'task-bridge.js');
|
|
259
|
+
const taskCmd = `[ -n "$CCVIEWER_PORT" ] && node "${taskBridgePath}" || true ${CCV_HOOK_MARKER}`;
|
|
260
|
+
const taskDesired = _buildHookObj(taskCmd);
|
|
261
|
+
for (const sectionKey of ['TaskCreated', 'TaskCompleted']) {
|
|
262
|
+
const existing = settings.hooks[sectionKey].find(h => {
|
|
263
|
+
const cmd = h.hooks?.[0]?.command || '';
|
|
264
|
+
return cmd.includes('task-bridge.js');
|
|
265
|
+
});
|
|
266
|
+
if (existing) {
|
|
267
|
+
if (!_hookObjEqual(existing.hooks?.[0], taskDesired)) {
|
|
268
|
+
existing.hooks = [_mergeHookObj(existing.hooks?.[0], taskDesired)];
|
|
269
|
+
changed = true;
|
|
270
|
+
}
|
|
271
|
+
} else {
|
|
272
|
+
settings.hooks[sectionKey].push({
|
|
273
|
+
hooks: [taskDesired],
|
|
274
|
+
});
|
|
275
|
+
changed = true;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
const taskUpdateExisting = settings.hooks.PostToolUse.find(h => {
|
|
279
|
+
const cmd = h.hooks?.[0]?.command || '';
|
|
280
|
+
return cmd.includes('task-bridge.js');
|
|
281
|
+
});
|
|
282
|
+
if (taskUpdateExisting) {
|
|
283
|
+
// Ours already exists: normalize the matcher and merge field-level.
|
|
284
|
+
if (taskUpdateExisting.matcher !== 'TaskUpdate') {
|
|
285
|
+
taskUpdateExisting.matcher = 'TaskUpdate';
|
|
286
|
+
changed = true;
|
|
287
|
+
}
|
|
288
|
+
if (!_hookObjEqual(taskUpdateExisting.hooks?.[0], taskDesired)) {
|
|
289
|
+
taskUpdateExisting.hooks = [_mergeHookObj(taskUpdateExisting.hooks?.[0], taskDesired)];
|
|
290
|
+
changed = true;
|
|
291
|
+
}
|
|
292
|
+
} else {
|
|
293
|
+
settings.hooks.PostToolUse.push({
|
|
294
|
+
matcher: 'TaskUpdate',
|
|
295
|
+
hooks: [taskDesired],
|
|
296
|
+
});
|
|
297
|
+
changed = true;
|
|
298
|
+
}
|
|
299
|
+
|
|
243
300
|
if (changed) {
|
|
244
301
|
mkdirSync(claudeDir, { recursive: true });
|
|
245
302
|
// Atomic write(): write to a sibling temp file then rename. Concurrent
|