[ { "title": "$:/plugins/Gk0Wk/echarts/addons/TheBrain.js", "text": "\"use strict\";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(e,t)=>{for(var i in t)__defProp(e,i,{get:t[i],enumerable:!0})},__copyProps=(t,i,o,r)=>{if(i&&\"object\"==typeof i||\"function\"==typeof i)for(let e of __getOwnPropNames(i))__hasOwnProp.call(t,e)||e===o||__defProp(t,e,{get:()=>i[e],enumerable:!(r=__getOwnPropDesc(i,e))||r.enumerable});return t},__toCommonJS=e=>__copyProps(__defProp({},\"__esModule\",{value:!0}),e),TheBrain_exports={},colors=(__export(TheBrain_exports,{\"default\":()=>TheBrain_default}),module.exports=__toCommonJS(TheBrain_exports),[\"#5470c6\",\"#91cc75\",\"#fac858\",\"#ee6666\",\"#73c0de\",\"#3ba272\",\"#fc8452\",\"#9a60b4\",\"#ea7ccc\"]),CategoriesEn=[\"Focusing\",\"History\",\"Link To\",\"Backlink From\",\"Tag To\",\"Tag By\",\"Transclude\"].map((e,t)=>({name:e,itemStyle:{color:colors[t%colors.length]}})),CategoriesZh=[\"聚焦\",\"历史\",\"链接\",\"反链\",\"标签\",\"作为标签\",\"嵌套\"].map((e,t)=>({name:e,itemStyle:{color:colors[t%colors.length]}})),attributes=new Set([\"focussedTiddler\",\"levels\",\"graphTitle\",\"aliasField\",\"excludeFilter\",\"previewDelay\"]),getPlatteColor=e=>$tw.wiki.renderText(\"text/plain\",\"text/vnd.tiddlywiki\",`<$transclude tiddler={{$:/palette}} index=\"${e}\"><$transclude tiddler=\"$:/palettes/Vanilla\" index=\"${e}\"><$transclude tiddler=\"$:/config/DefaultColourMappings/${e}\"/>`,{}),findIcon=e=>{var t,i=null==(i=$tw.wiki.getTiddler(e))?void 0:i.fields;if(null!=i&&i.icon)return(t=null==(t=$tw.wiki.getTiddler(i.icon))?void 0:t.fields)?t._canonical_uri?\"image://\"+t._canonical_uri:t.title.startsWith(\"$:/core/images/\")?void 0:`image://data:${t.type};base64,`+t.text:/^https?:\\/\\//.test(i.icon)?\"image://\"+i.icon:void 0},getAliasOrTitle=(e,t)=>{var i;return void 0===t||\"title\"===t?[e,Boolean($tw.wiki.getTiddler(e))]:(i=$tw.wiki.getTiddler(e))?[\"string\"==typeof(i=i.fields[t])?$tw.wiki.renderText(\"text/plain\",\"text/vnd.tiddlywiki\",i,{variables:{currentTiddler:e}}):e,!0]:[e,!1]},TheBrainAddon={onMount:(e,t)=>(e.on(\"click\",{dataType:\"node\"},e=>{(new $tw.Story).navigateTiddler(e.data.name)}),{historyTiddlers:[],viewingTiddlers:new Set,focusing:t.focussedTiddler}),shouldUpdate:({viewingTiddlers:t,focusing:e,currentlyFocused:i},o,r)=>Object.keys(o).some(e=>t.has(e))||Object.keys(r).some(e=>attributes.has(e))||void 0===e&&$tw.wiki.getTiddlerText(\"$:/temp/focussedTiddler\")!==i,onUpdate:(r,l,d)=>{let s=d.focussedTiddler||$tw.wiki.getTiddlerText(\"$:/temp/focussedTiddler\");if(l.viewingTiddlers.clear(),l.focusing=d.focussedTiddler,l.currentlyFocused=s){l.viewingTiddlers.add(s),null!=(n=$tw.wiki.getTiddler(s))&&n.fields[\"draft.of\"]&&(s=$tw.wiki.getTiddler(s).fields[\"draft.of\"]);const T=[],b=[];var n=!0===(null==(n=$tw.wiki.getTiddlerText(\"$:/language\"))?void 0:n.includes(\"zh\"));let e=Number(d.levels);Number.isNaN(e)&&(e=1),e=Math.max(e,0);var g=d.graphTitle||(n?\"聚焦\":\"Focusing Map\");const v=\"\"===d.aliasField?void 0:d.aliasField,k=\"\"===d.excludeFilter?void 0:$tw.wiki.compileFilter(null!=(h=d.excludeFilter)?h:\"[prefix[$:/]]\"),$=new Map;T.push({name:s,category:0,label:{formatter:getAliasOrTitle(s,v)[0],fontWeight:\"bold\",fontSize:\"15px\"},symbol:findIcon(s),symbolSize:15,select:{disabled:!0},itemStyle:{opacity:1,borderColor:colors[0]+\"66\",borderWidth:15},isTag:!1,tooltip:{show:!1}});let a=[s];if(k){var u=new Set(a);for(const _ of k.call($tw.wiki,a))u[\"delete\"](_);a=Array.from(u)}$.set(s,!0),$.set(\"\",!1);for(var y=(e,t,i)=>{var o,r,l;return!(k&&0({name:x,label:{formatter:e},itemStyle:{opacity:t?1:.65},symbol:findIcon(x),category:2,isTag:!1}),e=>({source:S,target:x,lineStyle:{color:colors[2],type:e?\"solid\":\"dashed\"}}));for(const O of $tw.wiki.getTiddlerBacklinks(S))y(O,(e,t)=>({name:O,label:{formatter:e},itemStyle:{opacity:t?1:.65},symbol:findIcon(O),category:3,isTag:!1}),e=>({source:O,target:S,lineStyle:{color:colors[3],type:e?\"solid\":\"dashed\"}}));for(const P of null!=(m=null==(m=null==(m=$tw.wiki.getTiddler(s))?void 0:m.fields)?void 0:m.tags)?m:[])y(P,(e,t)=>({name:P,label:{formatter:e},itemStyle:{opacity:t?1:.65},symbol:findIcon(P),category:4,isTag:!0}),e=>({source:S,target:P,lineStyle:{color:colors[4],type:e?\"solid\":\"dashed\"}}));for(const C of $tw.wiki.getTiddlersWithTag(S))y(C,(e,t)=>({name:C,label:{formatter:e},itemStyle:{opacity:t?1:.65},symbol:findIcon(C),category:5,isTag:!1}),e=>({source:C,target:S,lineStyle:{color:colors[5],type:e?\"solid\":\"dashed\"}}));var m=$tw.wiki.getTiddler(S);if(m){m=m.fields.type||\"text/vnd.tiddlywiki\";if(\"text/vnd.tiddlywiki\"===m||\"text/x-markdown\"===m){const B=new Set,F=e=>{var t=e[\"length\"];for(let r=0;r({name:M,label:{formatter:e},itemStyle:{opacity:t?1:.65},symbol:findIcon(M),category:6,isTag:!1}),e=>({source:S,target:M,lineStyle:{color:colors[6],type:e?\"solid\":\"dashed\"}}))}}}}let t=s;var w=new Set;for(let o=l.historyTiddlers.length-2;0<=o;o--){const I=l.historyTiddlers[o];w.has(I)||I===t||I.startsWith(\"$:/\")||(y(I,(e,t)=>({name:I,label:{formatter:e,fontSize:\"10px\"},category:1,symbol:findIcon(I),symbolSize:3,itemStyle:{opacity:t?.65:.4},isTag:!1}),e=>({source:I,target:t,lineStyle:{color:colors[1],type:e?\"dashed\":\"dotted\",opacity:.5}})),t=I)}var h=l.historyTiddlers.indexOf(s);-1e.name),icon:\"circle\"}],title:{text:g,show:!0,top:\"bottom\",left:\"right\"},toolbox:{show:!0,left:0,bottom:0,feature:{restore:{},saveAsImage:{}}},tooltip:{position:\"top\",formatter:({data:{name:t,isTag:e},dataType:i})=>{if(\"node\"!==i)return[];if(t!==c||!p){var o=$tw.utils.domMaker(\"div\",{style:{maxWidth:\"40vw\",maxHeight:\"50vh\",overflowY:\"auto\",whiteSpace:\"normal\"},\"class\":\"gk0wk-echarts-thebrain-popuptiddler-container\"});if(e){var r=$tw.utils.domMaker(\"ul\",{}),l=$tw.wiki.getTiddlersWithTag(t),a=l.length;for(let e=0;e(new $tw.Story).navigateTiddler(n)),d.appendChild(s),r.appendChild(d)}p=[r]}else $tw.wiki.makeWidget($tw.wiki.parseTiddler(\"$:/plugins/Gk0Wk/echarts/addons/TheBrainPopup\"),{document:document,parseAsInline:!0,variables:{currentTiddler:t}}).render(o,null),p=[o,$tw.utils.domMaker(\"style\",{innerHTML:\".gk0wk-echarts-thebrain-popuptiddler-container::-webkit-scrollbar {display: none;} .gk0wk-echarts-thebrain-popuptiddler-container .tc-tiddler-controls { display: none; }\"})];c=t}return p},triggerOn:0<=i?\"mousemove\":\"none\",enterable:!0,showDelay:Math.max(0,i),hideDelay:800,confine:!0,textStyle:{color:\"inherit\",fontFamily:\"inherit\",fontSize:\"inherit\"},appendToBody:!0,backgroundColor:getPlatteColor(\"page-background\"),borderColor:getPlatteColor(\"very-muted-foreground\")},series:[{name:g,type:\"graph\",layout:\"force\",top:0,bottom:0,left:0,right:0,height:\"100%\",width:\"100%\",nodes:T,edges:b,categories:n?CategoriesZh:CategoriesEn,roam:!0,draggable:!0,zoom:4,label:{position:\"right\",show:!0,backgroundColor:\"transparent\"},labelLayout:{moveOverlap:!0},force:{repulsion:50},cursor:\"pointer\",symbolSize:6,edgeSymbol:[\"none\",\"arrow\"],edgeSymbolSize:[0,5],lineStyle:{width:1,opacity:.75,curveness:.15},itemStyle:{opacity:.9}}]})}}},TheBrain_default=TheBrainAddon;", "Modern.TiddlyDev#IncludeSource": "true", "Modern.TiddlyDev#Origin": "addons/Gk0Wk/TheBrain.ts", "module-type": "echarts-component", "type": "application/javascript" } ]