summaryrefslogtreecommitdiff
path: root/build/static/chunks/pages/index-b7e9a3c26de1eb7c41cc.js
blob: 2f8160954d485872ced53f72a0d5743cfc4d85f4 (about) (plain)
1
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[405],{9053:function(e,n,t){"use strict";t.r(n),t.d(n,{EnableSection:function(){return Z},Graph:function(){return X},GraphPage:function(){return L},InfoTooltip:function(){return _},SliderWithInfo:function(){return M},Tweaks:function(){return W},default:function(){return H}});var i=t(7757),r=t.n(i),l=t(2137),a=t(7375),s=t(5893),o=t(7329),c=t(6156),u=t(4699),d=t(7294);function h(e,n){return{get:function(){var t=n.getItem(e);if(t&&"undefined"!==t)return JSON.parse(t)},update:function(t){n.setItem(e,JSON.stringify(t))},remove:function(){n.removeItem(e)}}}var f=t(4309),g=t(8017),x=t(8420),j=t(5684),b=t(4115),p=t(3014),v=t(8134),y=t(1033),m=t(6327),C=t(2026),k=t(4096),S=t(8235),w=t(155),O=t(3924),I=t(4189),E=t(3986),N=t(6569);function D(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function F(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?D(Object(t),!0).forEach((function(n){(0,c.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):D(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var T=t.e(4).then(t.bind(t,7004)),P=t.g.window?t(6923).f$:null,B=t.g.window?t(6923).s6:null,R={enabled:!0,charge:-350,collision:!0,collisionStrength:0,linkStrength:.1,linkIts:1,particles:!1,particlesNumber:0,particlesWidth:4,linkOpacity:.4,linkWidth:1,nodeRel:4,labels:!0,labelScale:1.5,alphaDecay:.02,alphaTarget:0,alphaMin:0,velocityDecay:.25,gravity:.5,gravityOn:!0,colorful:!0,galaxy:!0,ticks:1,hover:"highlight",click:"select",doubleClick:"local",iterations:0,highlight:!0,highlightNodeSize:2,highlightLinkSize:2},z={base1:"#1c1f24",base2:"#21272d",base3:"#23272e",base4:"#484854",base5:"#62686E",base6:"#757B80",base7:"#9ca0a4",base8:"#DFDFDF",bg:"#242730","bg-alt":"#2a2e38",blue:"#51afef",cyan:"#5cEfFF","dark-blue":"#1f5582","dark-cyan":"#6A8FBF",fg:"#bbc2cf","fg-alt":"#5D656B",green:"#7bc275",grey:"#484854",magenta:"#C57BDB",orange:"#e69055",red:"#ff665c",teal:"#4db5bd",violet:"#a991f1",yellow:"#FCCE7B"};function H(){var e=(0,d.useState)(!1),n=e[0],t=e[1];return(0,d.useEffect)((function(){t(!0)}),[]),n?(0,s.jsx)(L,{}):null}function L(){var e=function(e,n){var t,i=h(e,null!==(t=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).storage)&&void 0!==t?t:localStorage),r=i.get(),l=void 0!==r?r:n;l!==r&&i.update(l);var a=(0,d.useState)(l),s=a[0],o=a[1];return(0,d.useEffect)((function(){s!==l&&o(l)}),[e]),[s,function(e){e instanceof Function?o((function(n){var t=e(n);return i.update(t),t})):(o(e),i.update(e))}]}("physics",R),n=(0,u.Z)(e,2),t=n[0],i=n[1],r=(0,d.useState)(z),l=(r[0],r[1]),a=(0,d.useState)(null),f=a[0],j=a[1],b=(0,d.useState)(null),p=b[0],v=b[1],y=(0,d.useRef)({}),m=(0,d.useRef)({}),C=function(){return fetch("http://localhost:35901/graph").then((function(e){return e.json()})).then((function(e){y.current=Object.fromEntries(e.nodes.map((function(e){return[e.id,e]}))),m.current=e.links.reduce((function(e,n){var t,i,r;return F(F({},e),{},(r={},(0,c.Z)(r,n.source,[].concat((0,o.Z)(null!==(t=e[n.source])&&void 0!==t?t:[]),[n])),(0,c.Z)(r,n.target,[].concat((0,o.Z)(null!==(i=e[n.target])&&void 0!==i?i:[]),[n])),r))}),{});var n=JSON.parse(JSON.stringify(e));j(n)}))};(0,d.useEffect)((function(){new EventSource("http://127.0.0.1:35901/current-node-id").addEventListener("message",(function(e){var n=e.data;v(n)})),fetch("http://localhost:35901/theme").then((function(e){return e.json()})).then((function(e){l(e)})),C()}),[]),(0,d.useEffect)((function(){p&&C()}),[p]);var k=(0,d.useState)(!1),S=k[0],w=(k[1],(0,d.useState)(!0)),I=w[0],E=w[1];return f?(0,s.jsxs)("div",{children:[I?(0,s.jsx)(W,F(F({},{physics:t,setPhysics:i,threeDim:S}),{},{onClose:function(){E(!1)}})):(0,s.jsx)(g.xu,{position:"absolute",zIndex:"overlay",marginTop:"2%",marginLeft:"2%",children:(0,s.jsx)(x.h,{"aria-label":"Settings",icon:(0,s.jsx)(O.e,{}),onClick:function(){return E(!0)}})}),(0,s.jsx)(X,F({nodeById:y.current,linksByNodeId:m.current},{physics:t,graphData:f,threeDim:S,emacsNodeId:p}))]}):null}var _=function(e){var n=e.infoText;return(0,s.jsx)(g.xu,{paddingLeft:"1",children:(0,s.jsx)(j.u,{label:n,placement:"top",color:"gray.100",bg:"gray.800",hasArrow:!0,children:(0,s.jsx)(I.h,{})})})},M=function(e){var n=e.min,t=void 0===n?0:n,i=e.max,r=void 0===i?10:i,l=e.step,o=void 0===l?.1:l,c=e.value,u=void 0===c?1:c,d=(0,a.Z)(e,["min","max","step","value"]),h=d.onChange,f=d.label,x=d.infoText;return(0,s.jsxs)(g.xu,{children:[(0,s.jsxs)(g.xu,{display:"flex",alignItems:"flex-end",children:[(0,s.jsx)(b.x,{children:f}),x&&(0,s.jsx)(_,{infoText:x})]}),(0,s.jsxs)(p.iR,{value:u,onChange:h,min:t,max:r,step:o,children:[(0,s.jsx)(p.Uj,{children:(0,s.jsx)(p.Ms,{})}),(0,s.jsx)(j.u,{label:u.toFixed(1),children:(0,s.jsx)(p.gs,{})})]})]})},Z=function(e){var n=e.value,t=e.onChange,i=e.label,r=e.infoText,l=e.children;return(0,s.jsxs)(g.xu,{children:[(0,s.jsxs)(g.xu,{display:"flex",justifyContent:"space-between",children:[(0,s.jsxs)(g.xu,{display:"flex",alignItems:"center",children:[(0,s.jsx)(b.x,{children:i}),r&&(0,s.jsx)(_,{infoText:r})]}),(0,s.jsx)(v.r,{isChecked:!!n,onChange:t})]}),n&&l]})},W=function(e){var n=e.physics,t=e.setPhysics,i=(e.threeDim,e.onClose);return(0,s.jsxs)(g.xu,{zIndex:"overlay",position:"absolute",bg:"white",w:"xs",marginTop:"2%",marginLeft:"2%",borderRadius:"md",maxH:"80%",overflowY:"scroll",children:[(0,s.jsxs)(g.xu,{display:"flex",justifyContent:"flex-end",children:[(0,s.jsx)(j.u,{label:"Reset settings to defaults",children:(0,s.jsx)(x.h,{"aria-label":"Reset Defaults",icon:(0,s.jsx)(E.A,{}),onClick:function(){return t(R)}})}),(0,s.jsx)(y.P,{onClick:i})]}),(0,s.jsxs)(m.UQ,{allowMultiple:!0,allowToggle:!0,children:[(0,s.jsxs)(m.Qd,{children:[(0,s.jsxs)(m.KF,{display:"flex",justifyContent:"space-between",children:[(0,s.jsxs)(g.xu,{display:"flex",children:[(0,s.jsx)(m.XE,{}),(0,s.jsx)(b.x,{children:"Physics"})]}),(0,s.jsx)(v.r,{id:"physicsOn",onChange:function(){return t(F(F({},n),{},{enabled:!n.enabled}))},isChecked:n.enabled})]}),(0,s.jsxs)(m.Hk,{children:[(0,s.jsxs)(C.gC,{spacing:2,justifyContent:"flex-start",divider:(0,s.jsx)(C.cX,{borderColor:"gray.200"}),align:"stretch",children:[(0,s.jsx)(Z,{label:"Gravity",value:n.gravityOn,onChange:function(){return t(F(F({},n),{},{gravityOn:!n.gravityOn}))},children:(0,s.jsx)(M,{label:"Strength",value:10*n.gravity,onChange:function(e){return t(F(F({},n),{},{gravity:e/10}))}})}),(0,s.jsx)(M,{value:-n.charge/100,onChange:function(e){return t(F(F({},n),{},{charge:-100*e}))},label:"Repulsive Force"}),(0,s.jsx)(Z,{label:"Collision",infoText:"Perfomance sap, disable if slow",value:n.collision,onChange:function(){return t(F(F({},n),{},{collision:!n.collision}))},children:(0,s.jsx)(M,{value:10*n.collisionStrength,onChange:function(e){return t(F(F({},n),{},{collisionStrength:e/10}))},label:"Strength"})}),(0,s.jsx)(M,{value:5*n.linkStrength,onChange:function(e){return t(F(F({},n),{},{linkStrength:e/5}))},label:"Link Force"}),(0,s.jsx)(M,{label:"Link Iterations",value:n.linkIts,onChange:function(e){return t(F(F({},n),{},{linkIts:e}))},min:0,max:6,step:1,infoText:"How many links down the line the physics of a single node affects (Slow)"}),(0,s.jsx)(M,{label:"Viscosity",value:10*n.velocityDecay,onChange:function(e){return t(F(F({},n),{},{velocityDecay:e/10}))}})]}),(0,s.jsx)(g.xu,{children:(0,s.jsx)(m.UQ,{allowToggle:!0,children:(0,s.jsxs)(m.Qd,{children:[(0,s.jsxs)(m.KF,{children:[(0,s.jsx)(b.x,{children:"Advanced"}),(0,s.jsx)(m.XE,{})]}),(0,s.jsx)(m.Hk,{children:(0,s.jsxs)(C.gC,{spacing:2,justifyContent:"flex-start",divider:(0,s.jsx)(C.cX,{borderColor:"gray.200"}),align:"stretch",children:[(0,s.jsx)(M,{label:"Iterations per tick",min:1,max:10,step:1,value:n.iterations,onChange:function(e){return t(F(F({},n),{},{iterations:e}))},infoText:"Number of times the physics simulation iterates per simulation step"}),(0,s.jsx)(M,{label:"Stabilization rate",value:50*n.alphaDecay,onChange:function(e){return t(F(F({},n),{},{alphaDecay:e/50}))}})]})})]})})})]})]}),(0,s.jsxs)(m.Qd,{children:[(0,s.jsxs)(m.KF,{children:[(0,s.jsx)(m.XE,{}),"Visual"]}),(0,s.jsx)(m.Hk,{children:(0,s.jsxs)(C.gC,{spacing:2,justifyContent:"flex-start",divider:(0,s.jsx)(C.cX,{borderColor:"gray.200"}),align:"stretch",children:[(0,s.jsx)(M,{label:"Node size",value:n.nodeRel,onChange:function(e){return t(F(F({},n),{},{nodeRel:e}))}}),(0,s.jsx)(M,{label:"Link width",value:n.linkWidth,onChange:function(e){return t(F(F({},n),{},{linkWidth:e}))}}),(0,s.jsx)(Z,{label:"Labels",value:n.labels,onChange:function(){return t(F(F({},n),{},{labels:!n.labels}))},children:(0,s.jsx)(M,{label:"Label Appearance Scale",value:5*n.labelScale,onChange:function(e){return t(F(F({},n),{},{labelScale:e/5}))}})}),(0,s.jsxs)(Z,{label:"Directional Particles",value:n.particles,onChange:function(){return t(F(F({},n),{},{particles:!n.particles}))},children:[(0,s.jsx)(M,{label:"Particle Number",value:n.particlesNumber,max:5,step:1,onChange:function(e){return t(F(F({},n),{},{particlesNumber:e}))}}),(0,s.jsx)(M,{label:"Particle Size",value:n.particlesWidth,onChange:function(e){return t(F(F({},n),{},{particleWidth:e}))}})]}),(0,s.jsxs)(Z,{label:"Highlight",onChange:function(){return t(F(F({},n),{},{highlight:!n.highlight}))},value:n.highlight,children:[(0,s.jsx)(M,{label:"Highlight Link Thickness Multiplier",value:n.highlightLinkSize,onChange:function(e){return t(F(F({},n),{},{highlightLinkSize:e}))}}),(0,s.jsx)(M,{label:"Highlight Node Size Multiplier",value:n.highlightNodeSize,onChange:function(e){return t(F(F({},n),{},{highlightNodeSize:e}))}}),(0,s.jsx)(k.k,{justifyContent:"space-between",children:(0,s.jsx)(b.x,{children:" Highlight node color "})}),(0,s.jsx)(k.k,{justifyContent:"space-between",children:(0,s.jsx)(b.x,{children:" Highlight link color "})})]})]})})]}),(0,s.jsxs)(m.Qd,{children:[(0,s.jsxs)(m.KF,{children:[(0,s.jsx)(m.XE,{}),"Behavior"]}),(0,s.jsx)(m.Hk,{children:(0,s.jsxs)(C.gC,{spacing:2,justifyContent:"flex-start",divider:(0,s.jsx)(C.cX,{borderColor:"gray.200"}),align:"stretch",children:[(0,s.jsxs)(g.xu,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[(0,s.jsx)(b.x,{children:"Hover Higlight"}),(0,s.jsxs)(S.v2,{children:[(0,s.jsx)(S.j2,{as:w.z,rightIcon:(0,s.jsx)(N.v,{}),children:n.hover}),(0,s.jsxs)(S.qy,{children:[(0,s.jsx)(S.sN,{children:"Off"}),(0,s.jsx)(S.sN,{children:"On"})]})]})]}),(0,s.jsx)(g.xu,{display:"flex",justifyContent:"space-between",children:(0,s.jsx)(b.x,{children:"Click"})}),(0,s.jsx)(g.xu,{display:"flex",justifyContent:"space-between",children:(0,s.jsx)(b.x,{children:"Double-click"})})]})})]})]})]})},X=function(e){var n=e.physics,t=e.graphData,i=e.threeDim,a=e.linksByNodeId,c=e.emacsNodeId,h=e.nodeById,g=(0,d.useRef)(null),x=(0,d.useRef)(null),j=(0,f.iP)(),b=(0,u.Z)(j,2),p=b[0],v=b[1],y=(0,d.useState)(null),m=y[0],C=y[1],k=(0,d.useState)({nodeIds:[]}),S=k[0],w=k[1];(0,d.useEffect)((function(){c&&w({nodeIds:[c]})}),[c]);var O=m,I=function(){if(!O)return{};var e=a[O.id];return e?Object.fromEntries([O.id].concat((0,o.Z)(e.flatMap((function(e){return[e.source,e.target]})))).map((function(e){return[e,{}]}))):{}}(),E=t.nodes.filter((function(e){var n,t=null!==(n=a[e.id])&&void 0!==n?n:[];return S.nodeIds.includes(e.id)||t.some((function(e){return S.nodeIds.includes(e.source)||S.nodeIds.includes(e.target)}))})),N=E.map((function(e){return e.id})),D=t.links.filter((function(e){var n="object"===typeof e.source?e.source.id:e.source,t="object"===typeof e.target?e.target.id:e.target;return N.includes(n)&&N.includes(t)})),R=(0,d.useMemo)((function(){return 0===S.nodeIds.length?t:{nodes:E,links:D}}),[S,JSON.stringify(Object.keys(h))]);(0,d.useEffect)((function(){setTimeout((function(){var e=i?x.current:g.current;null===e||void 0===e||e.zoomToFit(0,200)}),1)}),[JSON.stringify(N)]),(0,d.useEffect)((function(){(0,l.Z)(r().mark((function e(){var n,t;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=i?x.current:g.current,e.next=3,T;case 3:t=e.sent,n.d3Force("collide",t.forceCollide().radius(10));case 5:case"end":return e.stop()}}),e)})))()})),(0,d.useEffect)((function(){var e;null===(e=g.current)||void 0===e||e.d3ReheatSimulation()}),[n]);var z=(0,d.useRef)(0),H={graphData:R,width:p,height:v,backgroundColor:"#242730",nodeLabel:function(e){return e.title},nodeColor:function(e){var t,i;if(!n.colorful)return 0===Object.keys(I).length?"rgb(100, 100, 100)":I[e.id]?"#a991f1":"rgb(50, 50, 50)";var r,l,s,o=["#ff665c","#e69055","#7bc275","#4db5bd","#FCCE7B","#51afef","#1f5582","#C57BDB","#a991f1","#5cEfFF","#6A8FBF"];return o[(r=null!==(t=null===(i=a[e.id])||void 0===i?void 0:i.length)&&void 0!==t?t:0,l=0,s=o.length-1,Math.min(Math.max(r,l),s))]},nodeRelSize:n.nodeRel,nodeVal:function(e){var n;return(null!==(n=a[e.id])&&void 0!==n?n:[]).length},nodeCanvasObject:function(e,t,i){if(n.labels&&(!(i<=n.labelScale)||I[e.id])){var r=e.title,l=r.substring(0,Math.min(r.length,30)),a=12/i,s=[1.1*t.measureText(l).width,a].map((function(e){return e+.5*a})),c=Math.min(3*(i-n.labelScale)/n.labelScale,1),u=0===Object.keys(I).length?.5*c:I[e.id]?.5:.15*c;t.fillStyle="rgba(20, 20, 20, ".concat(u,")"),t.fillRect.apply(t,[e.x-s[0]/2,e.y-s[1]/2].concat((0,o.Z)(s)));var d=0===Object.keys(I).length?c:I[e.id]?1:.3*c;t.textAlign="center",t.textBaseline="middle",t.fillStyle="rgb(255, 255, 255, ".concat(d,")"),t.font="".concat(a,"px Sans-Serif"),t.fillText(l,e.x,e.y)}},nodeCanvasObjectMode:function(){return"after"},linkDirectionalParticles:n.particles?n.particlesNumber:void 0,linkColor:function(e){return e.source.id===(null===O||void 0===O?void 0:O.id)||e.target.id===(null===O||void 0===O?void 0:O.id)?"#a991f1":"#666666"},linkWidth:n.linkWidth,linkDirectionalParticleWidth:n.particlesWidth,onNodeClick:function(e,n){var t=n.timeStamp-z.current<400;z.current=n.timeStamp,t?window.open("org-protocol://roam-node?node="+e.id,"_self"):w((function(n){return F(F({},n),{},{nodeIds:[].concat((0,o.Z)(n.nodeIds),[e.id])})}))},onBackgroundClick:function(){w((function(e){return F(F({},e),{},{nodeIds:[]})}))},onNodeHover:function(e){n.hover&&C(e)}};return(0,s.jsx)("div",{children:i?(0,s.jsx)(B,F(F({ref:x},H),{},{nodeThreeObjectExtend:!0})):(0,s.jsx)(P,F({ref:g},H))})}},5301:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/",function(){return t(9053)}])}},function(e){e.O(0,[774,737,446,283,888,179],(function(){return n=5301,e(e.s=n);var n}));var n=e.O();_N_E=n}]);