@origintrail-official/dkg-node-ui 0.0.1-dev.1773506972.23bf9c0 → 0.0.1-dev.1773614346.8bc4e9c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-ui/assets/{3d-force-graph-nMUNmvtB.js → 3d-force-graph-1PNn0-xZ.js} +1 -1
- package/dist-ui/assets/AgentHub-CGWLJjy7.js +65 -0
- package/dist-ui/assets/{AppHost-DoLIi89g.js → AppHost-CV_UngOC.js} +1 -1
- package/dist-ui/assets/{Apps-Cc8HfqfD.js → Apps-I5gxUd6p.js} +1 -1
- package/dist-ui/assets/{Dashboard-D5q6MK78.js → Dashboard-TzI8O8tL.js} +1 -1
- package/dist-ui/assets/{Explorer-B80RVksc.js → Explorer-DX5DlGnt.js} +1 -1
- package/dist-ui/assets/{Settings-CG7-7GM-.js → Settings-DhFWxz-F.js} +1 -1
- package/dist-ui/assets/{hooks-BLTFNmyP.js → hooks-CL5p8QP2.js} +1 -1
- package/dist-ui/assets/{index-DH-l6lM0.js → index-BKmDUHkm.js} +22 -22
- package/dist-ui/assets/{index-8_35CUX2.js → index-CjNfRG2Z.js} +3 -3
- package/dist-ui/assets/{jsonld-32FQRO67-DhbO8O6B.js → jsonld-32FQRO67-CzvixUyM.js} +2 -2
- package/dist-ui/assets/{jsonld-BFI4wECl.js → jsonld-BOMJ7P6E.js} +1 -1
- package/dist-ui/assets/{renderer-3d-2EVDZII7-DsxBsJvs.js → renderer-3d-2EVDZII7-CXOG3Zet.js} +2 -2
- package/dist-ui/index.html +1 -1
- package/package.json +5 -5
- package/dist-ui/assets/AgentHub-XKCM9uYQ.js +0 -65
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{C as To,R as yh,M as Ze,T as dn,V as ce,P as vo,a as I,b as Et,B as Zs,c as Ut,S as Zu,d as Ct,e as bh,f as Gi,L as jg,G as _h,g as xh,h as Th,i as qg,Q as Hg,j as vh,k as Xg,l as Kg,w as z,H as it,m as Ju,N as tr,n as Yg,o as So,p as Ge,q as G,r as Ve,s as Yr,t as Ot,u as Ft,v as Oe,F as Qg,x as Zg,y as ht,z as Cs,D as rr,W as Ji,A as Kt,E as Jg,I as Sh,J as em,K as el,O as Nh,U as tm,X as nm,Y as rm,Z as sm,_ as im,$ as om,a0 as am,a1 as um,a2 as tl,a3 as Rh,a4 as Qt,a5 as nl,a6 as Hl,a7 as Ws,a8 as lm,a9 as cm,aa as bt,ab as Bn,ac as je,ad as Dn,ae as Fn,af as An,ag as Ms,ah as an,ai as wn,aj as kr,ak as dm,al as rl,am as sl,an as Ya,ao as Mr,ap as re,aq as hm,ar as Js,as as No,at as Gr,au as fm,av as eo,aw as st,ax as Ro,ay as js,az as wo,aA as sr,aB as Qa,aC as qs,aD as wh,aE as Bt,aF as Ah,aG as Eh,aH as Ch,aI as Mh,aJ as Ph,aK as Ao,aL as Bh,aM as Dh,aN as Xl,aO as Vr,aP as vt,aQ as pm,aR as Fh,aS as Lh,aT as Uh,aU as Oh,aV as Ih,aW as kh,aX as Gh,aY as Vh,aZ as $h,a_ as zh,a$ as Wh,b0 as jh,b1 as gm,b2 as mm,b3 as ym,b4 as $r,b5 as to,b6 as no,b7 as ro,b8 as ir,b9 as qh,ba as Hh,bb as Xh,bc as Kh,bd as Yh,be as Qh,bf as Zh,bg as Jh,bh as bm,bi as _m,bj as ef,bk as tf,bl as Ps,bm as Bs,bn as Pr,bo as xm,bp as il,bq as ol,br as al,bs as hn,bt as ul,bu as ll,bv as Vi,bw as $i,bx as zi,by as Wi,bz as Kl,bA as Yl,bB as Ql,bC as Zl,bD as Za,bE as Ja,bF as eu,bG as tu,bH as nu,bI as so,bJ as ru,bK as su,bL as iu,bM as ou,bN as au,bO as uu,bP as lu,bQ as cu,bR as du,bS as hu,bT as fu,bU as pu,bV as gu,bW as mu,bX as yu,bY as bu,bZ as _u,b_ as xu,b$ as io,c0 as Tu,c1 as nf,c2 as Tm,c3 as vm,c4 as Sm,c5 as Nm,c6 as Rm,c7 as wm,c8 as Am,c9 as Em,ca as Cm,cb as Mm,cc as oo,cd as Pm,ce as cl,cf as dl,cg as Bm,ch as Dm,ci as Fm,cj as Lm,ck as Um,cl as Om,cm as Im,cn as km,co as Gm,cp as Vm,cq as $m,cr as zm,cs as Wm,ct as jm,cu as qm,cv as Hm,cw as Xm,cx as Km,cy as Ym,cz as Qm,cA as Zm,cB as rf,cC as Jm,cD as ey,cE as ty,cF as ny,cG as ao,cH as sf,cI as ry,cJ as of,cK as af,cL as sy,cM as uf,cN as iy,cO as oy,cP as ay,cQ as uy,cR as ji,cS as uo,cT as lo,cU as Wo,cV as jo,cW as ly,cX as cy,cY as dy,cZ as hy,c_ as fy,c$ as hl,d0 as py,d1 as gy,d2 as my,d3 as yy,d4 as Jl,d5 as by,d6 as ec,d7 as _y,d8 as xy,d9 as lf,da as Ty,db as vy}from"./three.module-uCjFke6H.js";import{J as Sy}from"./index-
|
|
1
|
+
import{C as To,R as yh,M as Ze,T as dn,V as ce,P as vo,a as I,b as Et,B as Zs,c as Ut,S as Zu,d as Ct,e as bh,f as Gi,L as jg,G as _h,g as xh,h as Th,i as qg,Q as Hg,j as vh,k as Xg,l as Kg,w as z,H as it,m as Ju,N as tr,n as Yg,o as So,p as Ge,q as G,r as Ve,s as Yr,t as Ot,u as Ft,v as Oe,F as Qg,x as Zg,y as ht,z as Cs,D as rr,W as Ji,A as Kt,E as Jg,I as Sh,J as em,K as el,O as Nh,U as tm,X as nm,Y as rm,Z as sm,_ as im,$ as om,a0 as am,a1 as um,a2 as tl,a3 as Rh,a4 as Qt,a5 as nl,a6 as Hl,a7 as Ws,a8 as lm,a9 as cm,aa as bt,ab as Bn,ac as je,ad as Dn,ae as Fn,af as An,ag as Ms,ah as an,ai as wn,aj as kr,ak as dm,al as rl,am as sl,an as Ya,ao as Mr,ap as re,aq as hm,ar as Js,as as No,at as Gr,au as fm,av as eo,aw as st,ax as Ro,ay as js,az as wo,aA as sr,aB as Qa,aC as qs,aD as wh,aE as Bt,aF as Ah,aG as Eh,aH as Ch,aI as Mh,aJ as Ph,aK as Ao,aL as Bh,aM as Dh,aN as Xl,aO as Vr,aP as vt,aQ as pm,aR as Fh,aS as Lh,aT as Uh,aU as Oh,aV as Ih,aW as kh,aX as Gh,aY as Vh,aZ as $h,a_ as zh,a$ as Wh,b0 as jh,b1 as gm,b2 as mm,b3 as ym,b4 as $r,b5 as to,b6 as no,b7 as ro,b8 as ir,b9 as qh,ba as Hh,bb as Xh,bc as Kh,bd as Yh,be as Qh,bf as Zh,bg as Jh,bh as bm,bi as _m,bj as ef,bk as tf,bl as Ps,bm as Bs,bn as Pr,bo as xm,bp as il,bq as ol,br as al,bs as hn,bt as ul,bu as ll,bv as Vi,bw as $i,bx as zi,by as Wi,bz as Kl,bA as Yl,bB as Ql,bC as Zl,bD as Za,bE as Ja,bF as eu,bG as tu,bH as nu,bI as so,bJ as ru,bK as su,bL as iu,bM as ou,bN as au,bO as uu,bP as lu,bQ as cu,bR as du,bS as hu,bT as fu,bU as pu,bV as gu,bW as mu,bX as yu,bY as bu,bZ as _u,b_ as xu,b$ as io,c0 as Tu,c1 as nf,c2 as Tm,c3 as vm,c4 as Sm,c5 as Nm,c6 as Rm,c7 as wm,c8 as Am,c9 as Em,ca as Cm,cb as Mm,cc as oo,cd as Pm,ce as cl,cf as dl,cg as Bm,ch as Dm,ci as Fm,cj as Lm,ck as Um,cl as Om,cm as Im,cn as km,co as Gm,cp as Vm,cq as $m,cr as zm,cs as Wm,ct as jm,cu as qm,cv as Hm,cw as Xm,cx as Km,cy as Ym,cz as Qm,cA as Zm,cB as rf,cC as Jm,cD as ey,cE as ty,cF as ny,cG as ao,cH as sf,cI as ry,cJ as of,cK as af,cL as sy,cM as uf,cN as iy,cO as oy,cP as ay,cQ as uy,cR as ji,cS as uo,cT as lo,cU as Wo,cV as jo,cW as ly,cX as cy,cY as dy,cZ as hy,c_ as fy,c$ as hl,d0 as py,d1 as gy,d2 as my,d3 as yy,d4 as Jl,d5 as by,d6 as ec,d7 as _y,d8 as xy,d9 as lf,da as Ty,db as vy}from"./three.module-uCjFke6H.js";import{J as Sy}from"./index-BKmDUHkm.js";import{i as fe,s as Ny,a as fl,f as Ry,b as wy,c as Ay,d as Ey,e as Cy,t as cf,g as My,G as Py,T as tc,E as nc}from"./index-CjNfRG2Z.js";import{o as By,m as Dy,d as Fy}from"./ordinal-DIohFSkg.js";function ft(){return ft=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},ft.apply(null,arguments)}function Hs(i,e){return Hs=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},Hs(i,e)}function Ly(i,e){i.prototype=Object.create(e.prototype),i.prototype.constructor=i,Hs(i,e)}function Uy(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}const Lr=new vo,un=new ce,df=new I,qo=new ce,qi=new ce,co=new I,vu=new I,hf=new Et,ff=new I,pf=new I;let tt=null,jt=null;const ln=[],Ln={NONE:-1,PAN:0,ROTATE:1};class Oy extends To{constructor(e,t,n=null){super(t,n),this.objects=e,this.recursive=!0,this.transformGroup=!1,this.rotateSpeed=1,this.raycaster=new yh,this.mouseButtons={LEFT:Ze.PAN,MIDDLE:Ze.PAN,RIGHT:Ze.ROTATE},this.touches={ONE:dn.PAN},this._onPointerMove=Iy.bind(this),this._onPointerDown=ky.bind(this),this._onPointerCancel=Gy.bind(this),this._onContextMenu=Vy.bind(this),n!==null&&this.connect(n)}connect(e){super.connect(e),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointerup",this._onPointerCancel),this.domElement.addEventListener("pointerleave",this._onPointerCancel),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointerup",this._onPointerCancel),this.domElement.removeEventListener("pointerleave",this._onPointerCancel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="auto",this.domElement.style.cursor=""}dispose(){this.disconnect()}_updatePointer(e){const t=this.domElement.getBoundingClientRect();un.x=(e.clientX-t.left)/t.width*2-1,un.y=-(e.clientY-t.top)/t.height*2+1}_updateState(e){let t;if(e.pointerType==="touch")t=this.touches.ONE;else switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=null}switch(t){case Ze.PAN:case dn.PAN:this.state=Ln.PAN;break;case Ze.ROTATE:case dn.ROTATE:this.state=Ln.ROTATE;break;default:this.state=Ln.NONE}}}function Iy(i){const e=this.object,t=this.domElement,n=this.raycaster;if(this.enabled!==!1){if(this._updatePointer(i),n.setFromCamera(un,e),tt)this.state===Ln.PAN?n.ray.intersectPlane(Lr,co)&&(tt.position.copy(co.sub(df).applyMatrix4(hf)),this.dispatchEvent({type:"drag",object:tt})):this.state===Ln.ROTATE&&(qo.subVectors(un,qi).multiplyScalar(this.rotateSpeed),tt.rotateOnWorldAxis(ff,qo.x),tt.rotateOnWorldAxis(pf.normalize(),-qo.y),this.dispatchEvent({type:"drag",object:tt})),qi.copy(un);else if(i.pointerType==="mouse"||i.pointerType==="pen")if(ln.length=0,n.setFromCamera(un,e),n.intersectObjects(this.objects,this.recursive,ln),ln.length>0){const r=ln[0].object;Lr.setFromNormalAndCoplanarPoint(e.getWorldDirection(Lr.normal),vu.setFromMatrixPosition(r.matrixWorld)),jt!==r&&jt!==null&&(this.dispatchEvent({type:"hoveroff",object:jt}),t.style.cursor="auto",jt=null),jt!==r&&(this.dispatchEvent({type:"hoveron",object:r}),t.style.cursor="pointer",jt=r)}else jt!==null&&(this.dispatchEvent({type:"hoveroff",object:jt}),t.style.cursor="auto",jt=null);qi.copy(un)}}function ky(i){const e=this.object,t=this.domElement,n=this.raycaster;this.enabled!==!1&&(this._updatePointer(i),this._updateState(i),ln.length=0,n.setFromCamera(un,e),n.intersectObjects(this.objects,this.recursive,ln),ln.length>0&&(this.transformGroup===!0?tt=gf(ln[0].object):tt=ln[0].object,Lr.setFromNormalAndCoplanarPoint(e.getWorldDirection(Lr.normal),vu.setFromMatrixPosition(tt.matrixWorld)),n.ray.intersectPlane(Lr,co)&&(this.state===Ln.PAN?(hf.copy(tt.parent.matrixWorld).invert(),df.copy(co).sub(vu.setFromMatrixPosition(tt.matrixWorld)),t.style.cursor="move",this.dispatchEvent({type:"dragstart",object:tt})):this.state===Ln.ROTATE&&(ff.set(0,1,0).applyQuaternion(e.quaternion).normalize(),pf.set(1,0,0).applyQuaternion(e.quaternion).normalize(),t.style.cursor="move",this.dispatchEvent({type:"dragstart",object:tt})))),qi.copy(un))}function Gy(){this.enabled!==!1&&(tt&&(this.dispatchEvent({type:"dragend",object:tt}),tt=null),this.domElement.style.cursor=jt?"pointer":"auto",this.state=Ln.NONE)}function Vy(i){this.enabled!==!1&&i.preventDefault()}function gf(i,e=null){return i.isGroup&&(e=i),i.parent===null?e:gf(i.parent,e)}function $y(i){Wy(i);const e=zy(i);return i.on=e.on,i.off=e.off,i.fire=e.fire,i}function zy(i){let e=Object.create(null);return{on:function(t,n,r){if(typeof n!="function")throw new Error("callback is expected to be a function");let s=e[t];return s||(s=e[t]=[]),s.push({callback:n,ctx:r}),i},off:function(t,n){if(typeof t>"u")return e=Object.create(null),i;if(e[t])if(typeof n!="function")delete e[t];else{const o=e[t];for(let a=0;a<o.length;++a)o[a].callback===n&&o.splice(a,1)}return i},fire:function(t){const n=e[t];if(!n)return i;let r;arguments.length>1&&(r=Array.prototype.slice.call(arguments,1));for(let s=0;s<n.length;++s){const o=n[s];o.callback.apply(o.ctx,r)}return i}}}function Wy(i){if(!i)throw new Error("Eventify cannot use falsy object as events subject");const e=["on","fire","off"];for(let t=0;t<e.length;++t)if(i.hasOwnProperty(e[t]))throw new Error("Subject cannot be eventified, since it already has property '"+e[t]+"'")}function jy(i){if(i=i||{},"uniqueLinkId"in i&&(console.warn("ngraph.graph: Starting from version 0.14 `uniqueLinkId` is deprecated.\nUse `multigraph` option instead\n",`
|
|
2
2
|
`,`Note: there is also change in default behavior: From now on each graph
|
|
3
3
|
is considered to be not a multigraph by default (each edge is unique).`),i.multigraph=i.uniqueLinkId),i.multigraph===void 0&&(i.multigraph=!1),typeof Map!="function")throw new Error("ngraph.graph requires `Map` to be defined. Please polyfill it before using ngraph");var e=new Map,t=new Map,n={},r=0,s=i.multigraph?A:T,o=[],a=F,u=F,l=F,c=F,d={version:20,addNode:g,addLink:_,removeLink:E,removeNode:y,getNode:m,getNodeCount:B,getLinkCount:S,getEdgeCount:S,getLinksCount:S,getNodesCount:B,getLinks:v,forEachNode:ye,forEachLinkedNode:ne,forEachLink:te,beginUpdate:l,endUpdate:c,clear:ee,hasLink:O,hasNode:m,getLink:O,getLinkById:Y};return $y(d),h(),d;function h(){var k=d.on;d.on=q;function q(){return d.beginUpdate=l=V,d.endUpdate=c=K,a=p,u=f,d.on=k,k.apply(d,arguments)}}function p(k,q){o.push({link:k,changeType:q})}function f(k,q){o.push({node:k,changeType:q})}function g(k,q){if(k===void 0)throw new Error("Invalid node identifier");l();var ie=m(k);return ie?(ie.data=q,u(ie,"update")):(ie=new qy(k,q),u(ie,"add")),e.set(k,ie),c(),ie}function m(k){return e.get(k)}function y(k){var q=m(k);if(!q)return!1;l();var ie=q.links;return ie&&(ie.forEach(D),q.links=null),e.delete(k),u(q,"remove"),c(),!0}function _(k,q,ie){l();var Be=m(k)||g(k),M=m(q)||g(q),L=s(k,q,ie),X=t.has(L.id);return t.set(L.id,L),rc(Be,L),k!==q&&rc(M,L),a(L,X?"update":"add"),c(),L}function T(k,q,ie){var Be=oi(k,q),M=t.get(Be);return M?(M.data=ie,M):new sc(k,q,ie,Be)}function A(k,q,ie){var Be=oi(k,q),M=n.hasOwnProperty(Be);if(M||O(k,q)){M||(n[Be]=0);var L="@"+ ++n[Be];Be=oi(k+L,q+L)}return new sc(k,q,ie,Be)}function B(){return e.size}function S(){return t.size}function v(k){var q=m(k);return q?q.links:null}function E(k,q){return q!==void 0&&(k=O(k,q)),D(k)}function D(k){if(!k||!t.get(k.id))return!1;l(),t.delete(k.id);var q=m(k.fromId),ie=m(k.toId);return q&&q.links.delete(k),ie&&ie.links.delete(k),a(k,"remove"),c(),!0}function O(k,q){if(!(k===void 0||q===void 0))return t.get(oi(k,q))}function Y(k){if(k!==void 0)return t.get(k)}function ee(){l(),ye(function(k){y(k.id)}),c()}function te(k){if(typeof k=="function")for(var q=t.values(),ie=q.next();!ie.done;){if(k(ie.value))return!0;ie=q.next()}}function ne(k,q,ie){var Be=m(k);if(Be&&Be.links&&typeof q=="function")return ie?le(Be.links,k,q):ue(Be.links,k,q)}function ue(k,q,ie){for(var Be,M=k.values(),L=M.next();!L.done;){var X=L.value,be=X.fromId===q?X.toId:X.fromId;if(Be=ie(e.get(be),X),Be)return!0;L=M.next()}}function le(k,q,ie){for(var Be,M=k.values(),L=M.next();!L.done;){var X=L.value;if(X.fromId===q&&(Be=ie(e.get(X.toId),X),Be))return!0;L=M.next()}}function F(){}function V(){r+=1}function K(){r-=1,r===0&&o.length>0&&(d.fire("changed",o),o.length=0)}function ye(k){if(typeof k!="function")throw new Error("Function is expected to iterate over graph nodes. You passed "+k);for(var q=e.values(),ie=q.next();!ie.done;){if(k(ie.value))return!0;ie=q.next()}}}function qy(i,e){this.id=i,this.links=null,this.data=e}function rc(i,e){i.links?i.links.add(e):i.links=new Set([e])}function sc(i,e,t,n){this.fromId=i,this.toId=e,this.data=t,this.id=n}function oi(i,e){return i.toString()+"👉 "+e.toString()}var ai={exports:{}},br={exports:{}},Ho,ic;function mf(){return ic||(ic=1,Ho=function(e){return e===0?"x":e===1?"y":e===2?"z":"c"+(e+1)}),Ho}var Xo,oc;function Qr(){if(oc)return Xo;oc=1;const i=mf();return Xo=function(t){return n;function n(r,s){let o=s&&s.indent||0,a=s&&s.join!==void 0?s.join:`
|
|
4
4
|
`,u=Array(o+1).join(" "),l=[];for(let c=0;c<t;++c){let d=i(c),h=c===0?"":u;l.push(h+r.replace(/{var}/g,d))}return l.join(a)}},Xo}var ac;function Hy(){if(ac)return br.exports;ac=1;const i=Qr();br.exports=e,br.exports.generateCreateBodyFunctionBody=t,br.exports.getVectorCode=r,br.exports.getBodyCode=n;function e(s,o){let a=t(s,o),{Body:u}=new Function(a)();return u}function t(s,o){return`
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import{s as hs,r as s,a as gs,t as fs,v as Vt,q as qt,w as xs,x as ms,y as ys,z as Yt,j as e,A as bs,B as vs,c as Ss,C as ws,D as js,E as At,F as ks,G as Cs}from"./index-BKmDUHkm.js";import{R as Jt,u as Is}from"./index-CjNfRG2Z.js";import"./ordinal-DIohFSkg.js";function Le(n){if(!n)return n;const i=n.match(/^"([\s\S]*)"(?:\^\^<[^>]+>)?(?:@[a-z-]+)?$/);return i?i[1]:n}function Wt(n){return n.replace(/\s+/g," ").trim()}function Ns(n){if(n&&(n==="pending"||n==="in_progress"||n==="stored"||n==="enshrined"||n==="failed"||n==="skipped"))return n}const Qt="http://schema.org/dateCreated",Ms="http://schema.org/text",Ts="http://schema.org/name",Ze="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",Rs="http://dkg.io/ontology/ChatTurn",Es="http://dkg.io/ontology/turnId",Xt="http://dkg.io/ontology/GraphCluster",zs="http://dkg.io/ontology/clusterLinksTo",Ds="http://dkg.io/ontology/literalCount";function Ge(n){return n.startsWith("urn:")||n.startsWith("http://")||n.startsWith("https://")||n.startsWith("did:")||n.startsWith("_:")}function ft(n){return`${n.subject}\0${n.predicate}\0${n.object}`}function et(n){const i=new Set;for(const l of n)i.add(l.subject),Ge(l.object)&&i.add(l.object);return i}function Ot(n){const i=new Set;for(const l of n)Ge(l.object)&&i.add(ft(l));return i}function Ls(n,i){const l=et(n),a=[...et(i)].filter(g=>!l.has(g)),h=Ot(n),w=[...Ot(i)].filter(g=>!h.has(g));return{addedNodeCount:a.length,addedEdgeCount:w.length,sampleNodes:a.slice(0,4),sampleEdges:w.slice(0,3)}}function gt(n){let i=!1;const l=n.map(c=>c.role!=="assistant"||c.persistStatus!=="stored"?c:(i=!0,{...c,persistStatus:"enshrined"}));return i?l:n}function Ps(n,i){if(i.length===0)return n;const l=new Set(n.map(ft)),c=[...n];for(const a of i){const h=ft(a);l.has(h)||(l.add(h),c.push(a))}return c}function $s(n){if(n.length===0)return null;const i=new Set,l=new Map,c=new Map;for(const h of n){if(h.predicate===Ze&&h.object===Rs){i.add(h.subject);continue}if(h.predicate===Es){l.set(h.subject,Le(h.object));continue}if(h.predicate===Qt){const b=Date.parse(Le(h.object));Number.isNaN(b)||c.set(h.subject,b)}}const a=[...i].map(h=>({subject:h,turnId:l.get(h),ts:c.get(h)??0})).filter(h=>!!h.turnId).sort((h,b)=>h.ts-b.ts||String(h.turnId).localeCompare(String(b.turnId)));return a.length===0?null:a[a.length-1].turnId??null}function Bt(n,i){if(n.length===0)return null;const l=[...n].sort((a,h)=>a-h),c=Math.max(0,Math.min(l.length-1,Math.ceil(l.length*i)-1));return l[c]??null}function As(n,i){return i!=null&&i.includes("Conversation")?"Conversation":i!=null&&i.includes("Message")?"Message":i!=null&&i.includes("ToolInvocation")?"ToolInvocation":i!=null&&i.includes("ChatTurn")?"ChatTurn":n.includes(":session:")?"Conversation":n.includes(":msg:")?"Message":n.includes(":tool:")?"ToolInvocation":n.includes(":turn:")?"ChatTurn":n.startsWith("urn:dkg:entity:")?"Entity":n.startsWith("did:dkg:")?"Paranet":n.startsWith("http://schema.org/")?"SchemaNode":n.startsWith("urn:")?"URN":n.startsWith("http://")||n.startsWith("https://")?"IRI":"Other"}function Ws(n){if(n.length===0)return[];const i=new Map;for(const g of n)g.predicate===Ze&&Ge(g.object)&&i.set(g.subject,g.object);const l=new Map,c=new Map,a=new Map,h=new Map,b=g=>{const D=l.get(g);if(D)return D;const x=As(g,i.get(g));return l.set(g,x),c.has(x)||c.set(x,new Set),c.get(x).add(g),x};for(const g of n){const D=b(g.subject);if(Ge(g.object)){const x=b(g.object),T=`${D}\0${x}`;h.set(T,(h.get(T)??0)+1)}else a.set(D,(a.get(D)??0)+1)}const w=[];for(const[g,D]of c){const x=`urn:dkg:cluster:${g.toLowerCase()}`;w.push({subject:x,predicate:Ze,object:Xt},{subject:x,predicate:Ts,object:JSON.stringify(`${g} (${D.size})`)});const T=a.get(g)??0;T>0&&w.push({subject:x,predicate:Ds,object:JSON.stringify(String(T))})}for(const[g,D]of h){const[x,T]=g.split("\0"),F=`urn:dkg:cluster:${x.toLowerCase()}`,se=`urn:dkg:cluster:${T.toLowerCase()}`;w.push({subject:F,predicate:zs,object:se}),w.push({subject:F,predicate:`http://dkg.io/ontology/clusterEdgeCount:${T}`,object:JSON.stringify(String(D))})}return w}function Gt(n){if(!n)return n;const i=n.replace(/[<>]/g,"");return i.length<=42?i:`${i.slice(0,24)}...${i.slice(-14)}`}function Os({nodeIds:n,focusRequest:i}){const{viz:l}=Is(),c=s.useMemo(()=>[...n].sort().join("\0"),[n]);return s.useEffect(()=>{if(l)return n.length>0?l.highlightNodes(n):l.clearHighlight(),()=>{l.clearHighlight()}},[l,c,n]),s.useEffect(()=>{!l||!(i!=null&&i.nodeId)||l.centerOnNode(i.nodeId,{durationMs:300,zoomLevel:i.zoomLevel??2.1})},[l,i==null?void 0:i.requestId,i==null?void 0:i.nodeId,i==null?void 0:i.zoomLevel]),null}function Bs(n){const i=new Map;for(const c of n)if(c.predicate===Qt){const a=new Date(c.object);isNaN(a.getTime())||i.set(c.subject,a.getTime())}const l=[...new Set(i.values())].sort((c,a)=>c-a);return{subjectDates:i,timestamps:l}}function Gs(n,i,l){const c=new Set;for(const[a,h]of i)h<=l&&c.add(a);return n.filter(a=>!!(c.has(a.subject)||!i.has(a.subject)))}let Xe=10;function _t(n,i){if(!n||typeof n!="string")return"";const l=n.replace(/\^\^<[^>]+>$/,"").trim().replace(/^"|"$/g,""),c=new Date(l);return Number.isNaN(c.getTime())?l||"":c.toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Ht(){return{id:Xe++,role:"assistant",content:"Agent online. Connected to DKG v9 testnet with access to your Knowledge Assets. How can I help?",ts:new Date().toLocaleTimeString()}}function _s(n){var l;const i=new Map;for(const c of n){if(!(c!=null&&c.session))continue;const a=c.messages.find(F=>F.author==="user"),h=((l=a==null?void 0:a.text)==null?void 0:l.slice(0,60))||"New conversation",b=c.messages[c.messages.length-1],w={id:c.session,preview:h,messageCount:c.messages.length,lastTs:(b==null?void 0:b.ts)??""},g=i.get(w.id);if(!g){i.set(w.id,w);continue}const D=Date.parse(g.lastTs),x=Date.parse(w.lastTs);(Number.isFinite(x)&&Number.isFinite(D)?x>=D:w.lastTs>=g.lastTs)&&i.set(w.id,w)}return[...i.values()].sort((c,a)=>{const h=Date.parse(c.lastTs),b=Date.parse(a.lastTs);return Number.isFinite(h)&&Number.isFinite(b)?b-h:a.lastTs.localeCompare(c.lastTs)})}function Ft(){return{sampleCount:0,deltaApplied:0,fallbackCount:0,medianMs:null,p95Ms:null,lastMode:null,lastReason:null}}function Hs({initialPeerId:n,onPeerSelected:i}){const[l,c]=s.useState([]),[a,h]=s.useState(null),[b,w]=s.useState([]),[g,D]=s.useState(""),[x,T]=s.useState(!1),[F,se]=s.useState(!0),[j,Ne]=s.useState(""),M=s.useRef(null),ue=s.useRef(null);s.useEffect(()=>{var o;(o=M.current)==null||o.scrollIntoView({behavior:"smooth"})},[b]);const K=s.useCallback(async()=>{try{const N=((await Ss()).agents??[]).filter(S=>S.connectionStatus!=="self").map(S=>{var P;return{name:S.name??((P=S.peerId)==null?void 0:P.slice(0,12)),peerId:S.peerId,connectionStatus:S.connectionStatus,latencyMs:S.latencyMs,lastSeen:S.lastSeen}});N.sort((S,P)=>S.connectionStatus==="connected"&&P.connectionStatus!=="connected"?-1:P.connectionStatus==="connected"&&S.connectionStatus!=="connected"?1:S.name.localeCompare(P.name)),c(N)}catch{}se(!1)},[]);s.useEffect(()=>{K()},[K]);const re=s.useCallback(async o=>{try{const N=await ws({peer:o,limit:100});w(N.messages??[])}catch{}},[]),ne=s.useCallback(o=>{h(o),w([]),re(o.peerId)},[re]);s.useEffect(()=>{if(!n||l.length===0)return;const o=l.find(N=>N.peerId===n);o&&(ne(o),i==null||i())},[l,n,ne,i]),s.useEffect(()=>{if(a)return ue.current=setInterval(()=>re(a.peerId),4e3),()=>{ue.current&&clearInterval(ue.current)}},[a,re]);const ie=s.useCallback(async()=>{if(!a||!g.trim()||x)return;const o=g.trim();D(""),T(!0),w(N=>[...N,{ts:Date.now(),direction:"out",peer:a.peerId,text:o}]);try{await js(a.peerId,o)}catch(N){w(S=>[...S,{ts:Date.now(),direction:"in",peer:"system",text:`Failed to deliver: ${N.message}`}])}finally{T(!1)}},[a,g,x]),L=l.filter(o=>o.connectionStatus==="connected").length,xe=300*1e3,v=j.trim().toLowerCase(),oe=v?l.reduce((o,N)=>o+(N.name.toLowerCase().includes(v)||N.peerId.toLowerCase().includes(v)?1:0),0):l.length;return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"260px 1fr",height:"100%",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",borderRight:"1px solid var(--border)",background:"var(--bg)",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"16px 14px 12px",borderBottom:"1px solid var(--border)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",marginBottom:4},children:[e.jsx("div",{style:{fontSize:12,fontWeight:700},children:"Network Peers"}),v&&e.jsxs("div",{style:{fontSize:10,color:"var(--green)"},children:[oe," found"]})]}),e.jsxs("div",{style:{fontSize:10,color:"var(--text-dim)",marginBottom:10},children:[L," connected · ",l.length," discovered"]}),e.jsx("input",{type:"text",value:j,onChange:o=>Ne(o.target.value),placeholder:"Search peers…",style:{width:"100%",padding:"7px 10px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg-elevated)",color:"var(--text)",fontSize:11,outline:"none",boxSizing:"border-box"},onFocus:o=>{o.target.style.borderColor="var(--green)"},onBlur:o=>{o.target.style.borderColor="var(--border)"}})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"8px 10px"},children:[F&&e.jsx("div",{style:{fontSize:11,color:"var(--text-dim)",padding:"12px 6px"},children:"Loading peers…"}),!F&&l.length===0&&e.jsxs("div",{className:"empty-state empty-state--sidebar",children:[e.jsx("div",{className:"empty-state-icon",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),e.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}),e.jsx("div",{className:"empty-state-title",children:"No peers discovered"}),e.jsx("div",{className:"empty-state-desc",children:"Peers will appear here as your node discovers other agents on the network."})]}),!F&&l.length>0&&oe===0&&e.jsxs("div",{style:{fontSize:11,color:"var(--text-dim)",padding:"12px 6px"},children:['No peers match "',j,'"']}),l.map(o=>{const N=!v||o.name.toLowerCase().includes(v)||o.peerId.toLowerCase().includes(v),S=(a==null?void 0:a.peerId)===o.peerId,P=o.connectionStatus==="connected"||o.lastSeen!=null&&Date.now()-o.lastSeen<xe;return e.jsxs("div",{onClick:()=>ne(o),style:{padding:"10px 12px",borderRadius:8,marginBottom:4,cursor:"pointer",background:S?"var(--surface)":"transparent",border:S?"1px solid var(--border)":"1px solid transparent",transition:"all .15s ease",display:N?void 0:"none"},onMouseEnter:B=>{S||(B.currentTarget.style.background="var(--surface)")},onMouseLeave:B=>{S||(B.currentTarget.style.background="transparent")},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:7,height:7,borderRadius:"50%",flexShrink:0,background:P?"#10b981":"#6b7280",boxShadow:P?"0 0 6px rgba(16,185,129,.5)":"none"}}),e.jsx("span",{style:{fontSize:12,fontWeight:S?700:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:S?"var(--text)":"var(--text-muted)"},children:o.name})]}),o.latencyMs!=null&&e.jsxs("div",{className:"mono",style:{fontSize:9,color:"var(--text-dim)",marginTop:2,marginLeft:15},children:[o.latencyMs,"ms"]})]},o.peerId)})]}),e.jsx("div",{style:{padding:"10px 14px",borderTop:"1px solid var(--border)",fontSize:10,color:"var(--text-dim)"},children:e.jsx("button",{onClick:K,style:{fontSize:10,color:"var(--text-dim)",background:"none",border:"none",cursor:"pointer",padding:0,textDecoration:"underline",textUnderlineOffset:2},children:"Refresh peers"})})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden"},children:a?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"16px 24px",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:34,height:34,borderRadius:"50%",background:a.connectionStatus==="connected"?"rgba(16,185,129,.12)":"var(--surface)",border:`1px solid ${a.connectionStatus==="connected"?"rgba(16,185,129,.3)":"var(--border)"}`,display:"flex",alignItems:"center",justifyContent:"center",fontSize:14},children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:a.connectionStatus==="connected"?"#10b981":"#6b7280",strokeWidth:"2",children:[e.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"12",cy:"7",r:"4"})]})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:700},children:a.name}),e.jsxs("div",{style:{fontSize:11,color:a.connectionStatus==="connected"?"var(--green)":"var(--text-dim)",display:"flex",alignItems:"center",gap:5},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",display:"inline-block",background:a.connectionStatus==="connected"?"var(--green)":"#6b7280"}}),a.connectionStatus==="connected"?"Connected":"Disconnected",a.latencyMs!=null&&e.jsxs("span",{className:"mono",style:{fontSize:10,color:"var(--text-dim)"},children:["· ",a.latencyMs,"ms"]})]})]}),e.jsxs("div",{className:"mono",style:{marginLeft:"auto",fontSize:9,color:"var(--text-dim)",maxWidth:120,overflow:"hidden",textOverflow:"ellipsis"},children:[a.peerId.slice(0,16),"…"]})]}),e.jsxs("div",{className:"chat-area",style:{flex:1,overflowY:"auto",padding:"20px 24px"},children:[b.length===0&&e.jsxs("div",{className:"empty-state",style:{marginTop:24},children:[e.jsx("div",{className:"empty-state-icon",children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"}),e.jsx("polyline",{points:"22,6 12,13 2,6"})]})}),e.jsx("div",{className:"empty-state-title",children:"No messages yet"}),e.jsx("div",{className:"empty-state-desc",children:"Send a message to start a peer-to-peer conversation."})]}),b.map((o,N)=>e.jsxs("div",{className:`chat-msg ${o.direction==="out"?"user":"assistant"}`,children:[e.jsx("div",{className:`chat-bubble ${o.direction==="out"?"user":"assistant"}`,children:o.text}),e.jsx("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:4,fontFamily:"JetBrains Mono, monospace"},children:new Date(o.ts).toLocaleTimeString()})]},N)),x&&e.jsx("div",{className:"chat-msg user",children:e.jsx("div",{className:"chat-bubble user",style:{display:"flex",gap:4,alignItems:"center",padding:"12px 16px",opacity:.5},children:"Sending…"})}),e.jsx("div",{ref:M})]}),e.jsxs("div",{className:"chat-input-row",children:[e.jsx("input",{className:"chat-input",value:g,onChange:o=>D(o.target.value),onKeyDown:o=>o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),ie()),placeholder:`Message ${a.name}…`}),e.jsx("button",{className:"chat-send",onClick:ie,disabled:x||!g.trim(),children:"Send"})]})]}):e.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",gap:12,color:"var(--text-dim)"},children:[e.jsx("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",opacity:.4,children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),e.jsx("div",{style:{fontSize:13},children:"Select a peer to start chatting"}),e.jsx("div",{style:{fontSize:11},children:"Messages are sent directly over the DKG P2P network"})]})})]})}let Qe=1e3;const Ie="urn:dkg:chat:session:openclaw:dkg-ui",Ut="openclaw:dkg-ui";function Kt(n,i){const l=new Set,c=[];for(const a of[...i,...n]){const h=String(a.id),w=h&&!h.startsWith("oc-")&&!/^\d+$/.test(h)?h:`${a.role}\0${a.ts}\0${a.content}`;l.has(w)||(l.add(w),c.push(a))}return c}function Fs(){const[n,i]=s.useState([]),[l,c]=s.useState(""),[a,h]=s.useState(!1),[b,w]=s.useState(null),[g,D]=s.useState(0),[x,T]=s.useState(null),[F,se]=s.useState(null),[j,Ne]=s.useState(!1),[M,ue]=s.useState(!1),[K,re]=s.useState(null),[ne,ie]=s.useState(!1),[L,xe]=s.useState(!1),[v,oe]=s.useState(null),[o,N]=s.useState(null),S=s.useRef(null),P=s.useRef(null),B=s.useRef(null),ae=s.useRef(null),le=s.useRef(null),pe=s.useRef(null),V=u=>{u.current&&(clearTimeout(u.current),u.current=null)};s.useEffect(()=>{var u;(u=S.current)==null||u.scrollIntoView({behavior:"smooth"})},[n]),s.useEffect(()=>{if(b==null){D(0);return}D(Math.floor((Date.now()-b)/1e3));const u=setInterval(()=>{D(Math.floor((Date.now()-b)/1e3))},1e3);return()=>clearInterval(u)},[b]),s.useEffect(()=>()=>{var u;(u=P.current)==null||u.abort(),V(ae),V(le),V(pe)},[]),s.useEffect(()=>{let u=!1;const J=async()=>{try{const R=await Cs();if(u)return;const U=R.ok;U&&B.current===!1&&(se(Date.now()),V(ae),ae.current=setTimeout(()=>{ae.current=null,se(W=>W&&Date.now()-W>=2900?null:W)},3e3),At(100).then(W=>{if(u)return;const _=W.map(C=>({id:C.uri||`oc-history:${Qe++}`,role:C.author.includes("agent")?"assistant":"user",content:C.text,ts:C.ts?new Date(C.ts).toLocaleTimeString():""}));_.length>0&&i(C=>Kt(C,_))}).catch(()=>{})),B.current=U,T(U)}catch{u||(B.current=!1,T(!1))}};J();const $=setInterval(J,15e3);return()=>{u=!0,clearInterval($)}},[]),s.useEffect(()=>{let u=!1;return(async()=>{try{const J=await At(100);if(u)return;const $=J.map(R=>({id:R.uri||`oc-history:${Qe++}`,role:R.author.includes("agent")?"assistant":"user",content:R.text,ts:R.ts?new Date(R.ts).toLocaleTimeString():""}));$.length>0&&i(R=>Kt(R,$))}catch{}u||Ne(!0)})(),()=>{u=!0}},[]);const Y=s.useCallback(async()=>{var u;ie(!0);try{const J=`CONSTRUCT { ?s ?p ?o } WHERE {
|
|
2
|
+
{
|
|
3
|
+
SELECT ?s ?p ?o WHERE {
|
|
4
|
+
{ <${Ie}> ?p ?o . BIND(<${Ie}> AS ?s) }
|
|
5
|
+
UNION
|
|
6
|
+
{ ?s <http://schema.org/isPartOf> <${Ie}> . ?s ?p ?o }
|
|
7
|
+
UNION
|
|
8
|
+
{ ?msg <http://schema.org/isPartOf> <${Ie}> .
|
|
9
|
+
?msg <http://dkg.io/ontology/usedTool> ?tool .
|
|
10
|
+
?tool ?p ?o . BIND(?tool AS ?s) }
|
|
11
|
+
UNION
|
|
12
|
+
{ ?msg <http://schema.org/isPartOf> <${Ie}> .
|
|
13
|
+
?entity <http://dkg.io/ontology/mentionedIn> ?msg .
|
|
14
|
+
?entity ?p ?o . BIND(?entity AS ?s) }
|
|
15
|
+
UNION
|
|
16
|
+
{ ?msg <http://schema.org/isPartOf> <${Ie}> .
|
|
17
|
+
?srcEntity <http://dkg.io/ontology/mentionedIn> ?msg .
|
|
18
|
+
?srcEntity ?rel ?targetEntity .
|
|
19
|
+
FILTER(STRSTARTS(STR(?targetEntity), "urn:dkg:entity:"))
|
|
20
|
+
?targetEntity ?p ?o . BIND(?targetEntity AS ?s) }
|
|
21
|
+
UNION
|
|
22
|
+
{ ?memory <http://dkg.io/ontology/extractedFrom> <${Ie}> .
|
|
23
|
+
?memory ?p ?o . BIND(?memory AS ?s) }
|
|
24
|
+
UNION
|
|
25
|
+
{ ?memory a <http://dkg.io/ontology/ImportedMemory> .
|
|
26
|
+
?memory ?p ?o . BIND(?memory AS ?s) }
|
|
27
|
+
UNION
|
|
28
|
+
{ ?batch a <http://dkg.io/ontology/MemoryImport> .
|
|
29
|
+
?batch ?p ?o . BIND(?batch AS ?s) }
|
|
30
|
+
UNION
|
|
31
|
+
{ ?sessionEntity <http://dkg.io/ontology/extractedFrom> ?batch .
|
|
32
|
+
?batch a <http://dkg.io/ontology/MemoryImport> .
|
|
33
|
+
?sessionEntity ?p ?o . BIND(?sessionEntity AS ?s) }
|
|
34
|
+
}
|
|
35
|
+
ORDER BY ?s ?p ?o
|
|
36
|
+
LIMIT 5000
|
|
37
|
+
}
|
|
38
|
+
}`,$=await qt(J,"agent-memory",!0),R=Array.isArray((u=$==null?void 0:$.result)==null?void 0:u.quads)?$.result.quads:[];re(R.map(U=>({subject:U.subject,predicate:U.predicate,object:Le(U.object)})))}catch{re(null)}ie(!1)},[]);s.useEffect(()=>{M&&Y()},[M,Y]);const G=s.useCallback(()=>{Vt(Ut).then(u=>{N(u.scope)}).catch(()=>{N(u=>u??"empty")})},[]);s.useEffect(()=>{M&&G()},[M,G]);const Se=s.useCallback(async()=>{if(!L){xe(!0),oe(null);try{const u=await Promise.race([Yt(Ut,{clearAfter:!1}),new Promise((J,$)=>{setTimeout(()=>$(new Error("Publishing timed out. Please retry.")),45e3)})]);N(u.publication.scope),oe(`Published ${u.rootEntityCount} root entities (${u.status})`),await Y()}catch(u){oe(`Publish failed: ${(u==null?void 0:u.message)??"Unknown error"}`)}finally{xe(!1)}}},[L,Y]),Me=s.useCallback(async()=>{var U,W;if(!l.trim()||a)return;const u=l.trim();c(""),i(_=>[..._,{id:Qe++,role:"user",content:u,ts:new Date().toLocaleTimeString()}]),h(!0),w(Date.now());const J=new AbortController;P.current=J;const $=setTimeout(()=>J.abort(),9e4),R=Qe++;i(_=>[..._,{id:R,role:"assistant",content:"",ts:new Date().toLocaleTimeString()}]);try{await ks(u,{signal:J.signal,onEvent:_=>{_.type==="text_delta"?i(C=>C.map(O=>O.id===R?{...O,content:O.content+_.delta}:O)):_.type==="final"&&i(C=>C.map(O=>O.id===R?{...O,content:_.text}:O))}}),M&&(V(le),V(pe),le.current=setTimeout(()=>{le.current=null,Y()},1500),pe.current=setTimeout(()=>{pe.current=null,G()},2e3))}catch(_){let C;_.name==="AbortError"?C="Request timed out after 90 seconds. The agent may be overloaded — try again later.":x===!1?C="Agent is offline. Check that the OpenClaw gateway is running.":(U=_.message)!=null&&U.includes("Failed to fetch")||(W=_.message)!=null&&W.includes("NetworkError")?C="Network error — unable to reach the agent. Check your connection.":C=`Error: ${_.message}`,i(O=>O.map(H=>H.id===R?{...H,role:"system",content:C}:H))}finally{clearTimeout($),P.current=null,h(!1),w(null)}},[l,a,x,M,Y,G]),Pe=x===!0?"#4ade80":x===!1?"#ef4444":"#888",me=x===!0?"Online":x===!1?"Offline":"Checking…";return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:M?"1fr 1fr":"1fr",height:"100%",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"14px 20px",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:10,height:10,borderRadius:"50%",background:Pe,boxShadow:x===!0?`0 0 6px ${Pe}66`:"none"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:700},children:"OpenClaw Agent"}),e.jsxs("div",{style:{fontSize:10,color:"var(--text-dim)"},children:[F?"Reconnected":me,e.jsx("span",{style:{marginLeft:8,padding:"1px 6px",borderRadius:4,fontSize:9,background:F?"rgba(34,211,238,.12)":"rgba(74,222,128,.12)",color:F?"#22d3ee":"var(--green)"},children:F?"synced":"DKG UI"})]})]})]}),e.jsxs("button",{onClick:()=>ue(u=>!u),title:M?"Hide graph":"Show knowledge graph",style:{padding:"5px 12px",borderRadius:6,border:M?"1px solid rgba(34,211,238,.5)":"1px solid var(--border)",background:M?"rgba(34,211,238,.1)":"var(--surface)",color:M?"#22d3ee":"var(--text-muted)",fontSize:11,cursor:"pointer",fontWeight:600,display:"flex",alignItems:"center",gap:5,transition:"all .15s ease"},children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[e.jsx("circle",{cx:"6",cy:"6",r:"3"}),e.jsx("circle",{cx:"18",cy:"6",r:"3"}),e.jsx("circle",{cx:"12",cy:"18",r:"3"}),e.jsx("line",{x1:"8.5",y1:"7.5",x2:"10.5",y2:"16"}),e.jsx("line",{x1:"15.5",y1:"7.5",x2:"13.5",y2:"16"})]}),M?"Hide Graph":"Show Graph"]})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 20px 8px"},children:[!j&&e.jsx("div",{style:{textAlign:"center",color:"var(--text-dim)",fontSize:12,padding:20},children:"Loading history…"}),j&&n.length===0&&e.jsxs("div",{style:{textAlign:"center",color:"var(--text-dim)",padding:"40px 20px"},children:[e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{opacity:.3,marginBottom:12},children:[e.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),e.jsx("path",{d:"M2 17l10 5 10-5"}),e.jsx("path",{d:"M2 12l10 5 10-5"})]}),e.jsx("div",{style:{fontSize:13},children:"Send a message to start chatting with your OpenClaw agent."}),e.jsx("div",{style:{fontSize:11,marginTop:8},children:"Messages and imported memories are persisted to the DKG knowledge graph."})]}),n.map(u=>e.jsx("div",{style:{marginBottom:16,display:"flex",justifyContent:u.role==="user"?"flex-end":"flex-start"},children:e.jsxs("div",{style:{maxWidth:"75%",padding:"10px 14px",borderRadius:12,background:u.role==="user"?"rgba(74,222,128,.15)":u.role==="system"?"rgba(255,255,255,.04)":"rgba(255,255,255,.06)",border:u.role==="system"?"1px solid rgba(255,255,255,.08)":"none",fontSize:13,lineHeight:"1.5",whiteSpace:"pre-wrap",color:u.role==="system"?"var(--text-dim)":"var(--text)",fontStyle:u.role==="system"?"italic":"normal"},children:[u.content,e.jsx("div",{style:{fontSize:9,color:"var(--text-dim)",marginTop:4},children:u.ts})]})},u.id)),a&&e.jsx("div",{style:{display:"flex",justifyContent:"flex-start",marginBottom:16},children:e.jsxs("div",{style:{padding:"10px 14px",borderRadius:12,background:"rgba(255,255,255,.06)",fontSize:13,color:"var(--text-dim)"},children:["Thinking",g>0?`… ${g}s`:"…"]})}),e.jsx("div",{ref:S})]}),e.jsxs("div",{style:{padding:"12px 16px",borderTop:"1px solid var(--border)",display:"flex",gap:8},children:[e.jsx("input",{value:l,onChange:u=>c(u.target.value),onKeyDown:u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),Me())},placeholder:"Message your OpenClaw agent…",disabled:a||x===!1,style:{flex:1,padding:"10px 14px",borderRadius:10,border:"1px solid var(--border)",background:"var(--bg-elevated)",color:"var(--text)",fontSize:13,outline:"none"}}),e.jsx("button",{onClick:Me,disabled:a||!l.trim()||x===!1,style:{padding:"10px 20px",borderRadius:10,border:"none",background:a||!l.trim()||x===!1?"rgba(74,222,128,.2)":"var(--green)",color:a||!l.trim()||x===!1?"var(--text-dim)":"#000",fontWeight:700,fontSize:12,cursor:a?"wait":"pointer"},children:"Send"})]})]}),M&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",borderLeft:"1px solid var(--border)",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"10px 16px",borderBottom:"1px solid var(--border)",display:"grid",gap:8},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:12,fontWeight:700},children:"Knowledge Graph"}),K&&e.jsxs("span",{style:{fontSize:10,color:"var(--text-dim)"},children:[K.length," triples"]}),e.jsx("span",{className:"mono",style:{borderRadius:999,border:o==="enshrined"?"1px solid rgba(74,222,128,.3)":o==="enshrined_with_pending"?"1px solid rgba(245,158,11,.35)":"1px solid var(--border)",background:o==="enshrined"?"rgba(74,222,128,.1)":o==="enshrined_with_pending"?"rgba(245,158,11,.12)":"var(--surface)",color:o==="enshrined"?"var(--green)":o==="enshrined_with_pending"?"#f59e0b":"var(--text-dim)",padding:"2px 8px",fontSize:10},children:o==="enshrined"?"enshrined":o==="enshrined_with_pending"?"enshrined + pending":o==="workspace_only"?"workspace only":o?"empty":"checking..."})]}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsx("button",{onClick:Y,disabled:ne,style:{padding:"4px 10px",borderRadius:6,border:"1px solid var(--border)",background:"transparent",color:"var(--text-muted)",fontSize:10,cursor:"pointer"},children:ne?"Loading…":"Refresh"}),e.jsx("button",{onClick:()=>{Se()},disabled:L,style:{padding:"4px 10px",borderRadius:6,border:"1px solid rgba(74,222,128,.35)",background:"rgba(74,222,128,.1)",color:"var(--green)",fontSize:10,cursor:L?"not-allowed":"pointer",opacity:L?.65:1},children:L?"Publishing…":"Publish session"})]})]}),v&&e.jsx("div",{className:"mono",style:{fontSize:10,color:v.toLowerCase().includes("failed")?"var(--red)":"var(--green)"},children:v}),e.jsx("div",{className:"mono",style:{fontSize:10,color:"var(--text-dim)",lineHeight:1.5},children:"Publish session enshrines the OpenClaw conversation currently in view on the DKG privately. New writes remain in workspace until you publish again."})]}),e.jsxs("div",{style:{flex:1,minHeight:0,position:"relative"},children:[ne&&!K&&e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)",fontSize:12},children:"Loading graph…"}),K&&K.length===0&&e.jsxs("div",{className:"empty-state",style:{position:"absolute",inset:0},children:[e.jsx("div",{className:"empty-state-icon",children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("circle",{cx:"19",cy:"5",r:"2"}),e.jsx("circle",{cx:"5",cy:"19",r:"2"}),e.jsx("line",{x1:"14.5",y1:"9.5",x2:"17.5",y2:"6.5"}),e.jsx("line",{x1:"9.5",y1:"14.5",x2:"6.5",y2:"17.5"})]})}),e.jsx("div",{className:"empty-state-title",children:"No graph data yet"}),e.jsx("div",{className:"empty-state-desc",children:"Send some messages first. The knowledge graph builds as you converse."})]}),K&&K.length>0&&e.jsx(Jt,{data:K,format:"triples",options:{labelMode:"humanized",renderer:"2d",labels:{predicates:["http://schema.org/text","http://schema.org/name","http://www.w3.org/2000/01/rdf-schema#label","http://dkg.io/ontology/sessionId","http://dkg.io/ontology/toolName"]},style:{classColors:{"http://schema.org/Conversation":"#4ade80","http://schema.org/Message":"#22d3ee","http://dkg.io/ontology/ChatTurn":"#38bdf8","http://dkg.io/ontology/ToolInvocation":"#f59e0b","http://dkg.io/ontology/ImportedMemory":"#a78bfa","http://dkg.io/ontology/MemoryImport":"#818cf8","http://schema.org/Person":"#f472b6","http://schema.org/Organization":"#fb923c","http://schema.org/Place":"#34d399","http://schema.org/Product":"#c084fc","http://schema.org/Event":"#facc15","http://schema.org/CreativeWork":"#7dd3fc"},defaultNodeColor:"#94a3b8",defaultEdgeColor:"#5f8598",edgeWidth:.9},hexagon:{baseSize:4,minSize:3,maxSize:6,scaleWithDegree:!0,circleTypes:["http://schema.org/Message"]},focus:{maxNodes:5e3,hops:999}},style:{width:"100%",height:"100%"}})]})]})]})}function qs(){const[n,i]=hs(),l=n.get("tab"),c=n.get("peer"),[a,h]=s.useState(c?{peerId:c,nonce:Date.now()}:null),[b,w]=s.useState(l==="peers"?"peers":"agent"),[g,D]=s.useState(null);s.useEffect(()=>{let t=!1;return gs().then(r=>{t||D(r)}).catch(()=>{}),()=>{t=!0}},[]),s.useEffect(()=>{g!=null&&g.hasOpenClawChannel&&b==="agent"&&l!=="peers"&&w("openclaw")},[g,l,b]),s.useEffect(()=>{l==="peers"&&w("peers"),c&&h({peerId:c,nonce:Date.now()})},[l,c]),s.useEffect(()=>{if(l||c){const t=new URLSearchParams(n);t.delete("tab"),t.delete("peer"),i(t,{replace:!0})}},[l,c,n,i]);const[x,T]=s.useState([Ht()]),[F,se]=s.useState(""),[j,Ne]=s.useState(!1),[M,ue]=s.useState(null),[K,re]=s.useState([]),[ne,ie]=s.useState(!0),[L,xe]=s.useState(null),[v,oe]=s.useState(!1),[o,N]=s.useState(null),[S,P]=s.useState(!1),[B,ae]=s.useState(null),[le,pe]=s.useState(1500),[V,Y]=s.useState(!1),[G,Se]=s.useState("raw"),[Me,Pe]=s.useState({}),[me,u]=s.useState(null),[J,$]=s.useState(null),[R,U]=s.useState(!1),[W,_]=s.useState(!1),[C,O]=s.useState(null),[H,xt]=s.useState("timestamp"),[Te,ye]=s.useState(!1),[_e,He]=s.useState(""),[be,$e]=s.useState(null),[Z,we]=s.useState(null),[Zt,Ae]=s.useState(null),[We,es]=s.useState(typeof window<"u"?window.innerWidth<1180:!1),[q,tt]=s.useState(null),[,mt]=s.useState(()=>Ft()),st=s.useRef(null),Re=s.useRef(!0),rt=s.useRef(null),nt=s.useRef(new Map),it=s.useRef(null),he=s.useRef(0),Fe=s.useRef(0),Ue=s.useRef(v),je=s.useRef(B),Ee=s.useRef(L),ze=s.useRef(M),yt=s.useRef(j),bt=s.useRef(V),vt=s.useRef(0),St=s.useRef(new Map),ot=s.useRef(new Map),ge=s.useRef(new Map),Oe=s.useRef(new Map),wt=s.useRef([]),jt=s.useRef(async()=>{});s.useEffect(()=>{Ue.current=v},[v]),s.useEffect(()=>{je.current=B},[B]),s.useEffect(()=>{Ee.current=L},[L]),s.useEffect(()=>{ze.current=M},[M]),s.useEffect(()=>{yt.current=j},[j]),s.useEffect(()=>{bt.current=V},[V]),s.useEffect(()=>{it.current=o},[o]),s.useEffect(()=>{const t=()=>es(window.innerWidth<1180);return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),s.useEffect(()=>{const t=st.current;t&&Re.current&&(t.scrollTop=t.scrollHeight)},[x,j]);const ts=s.useCallback(()=>{const t=st.current;if(!t)return;const r=t.scrollHeight-t.scrollTop-t.clientHeight;Re.current=r<80},[]);s.useEffect(()=>{const t=new Map;for(const r of x)r.turnId&&t.set(r.turnId,r.id);ot.current=t},[x]),s.useEffect(()=>{const t=L??M;t&&St.current.set(t,x.map(r=>({...r})))},[x,L,M]);const ve=s.useCallback(()=>{wt.current=[],mt(Ft())},[]),kt=s.useCallback((t,r,d)=>{const p=Math.max(0,Number.isFinite(r)?r:0),m=wt.current;m.push(p),m.length>128&&m.splice(0,m.length-128);const f=Bt(m,.5),k=Bt(m,.95);mt(E=>({sampleCount:m.length,deltaApplied:E.deltaApplied+(t==="delta"?1:0),fallbackCount:E.fallbackCount+(t==="fallback"?1:0),medianMs:f,p95Ms:k,lastMode:t,lastReason:t==="fallback"?d??null:null}))},[]),De=s.useCallback(async()=>{ie(!0);try{const r=((await fs(50)).sessions??[]).filter(d=>{var p;return!((p=d.session)!=null&&p.startsWith("openclaw:"))});re(_s(r))}catch{re([])}finally{ie(!1)}},[]);s.useEffect(()=>{De()},[De]);const Ke=s.useCallback(async t=>{try{const r=await Vt(t);Pe(p=>({...p,[t]:r})),(Ee.current??ze.current)===t&&r.scope==="enshrined"&&T(p=>gt(p))}catch{}},[]),Ve=s.useCallback(t=>{const r=ot.current.get(t.turnId),d=Ee.current??ze.current;T(p=>{let m=!1;const f=p.map(k=>{var X,z;if(k.turnId!==t.turnId)return k;m=!0;const E=t.storeMs??((X=k.timings)==null?void 0:X.store_ms)??0,ke=(((z=k.timings)==null?void 0:z.llm_ms)??0)+E;return{...k,persistStatus:k.persistStatus==="enshrined"&&t.status==="stored"?"enshrined":t.status,persistError:t.error,persistAttempts:t.attempts,persistMaxAttempts:t.maxAttempts,timings:k.timings?{...k.timings,store_ms:E,total_ms:ke}:k.timings}});if(!m){if((yt.current||!!d&&t.sessionId===d)&&(ge.current.set(t.turnId,t),ge.current.size>128)){const E=ge.current.keys().next().value;E&&ge.current.delete(E)}return p}return ge.current.delete(t.turnId),f}),t.status==="stored"&&Ue.current&&t.sessionId&&jt.current(t.sessionId,t.turnId,{linkedMessageId:r,linkedTurnId:r==null?t.turnId:void 0})},[]);s.useEffect(()=>{let t=!1,r=null;const d=async()=>{try{const f=await bs();t||tt(f)}catch{t||tt(null)}},p=async()=>{for(;!t;){r=new AbortController;try{await vs({signal:r.signal,onEvent:f=>{if(!t){if(f.type==="persist_health"){tt({pending:f.pending,inProgress:f.inProgress,stored:f.stored,failed:f.failed,overduePending:f.overduePending,oldestPendingAgeMs:f.oldestPendingAgeMs});return}Ve(f)}}})}catch{if(t||r.signal.aborted)break}if(t)break;await new Promise(f=>setTimeout(f,1500))}};d(),p();const m=setInterval(()=>{d()},2e4);return()=>{t=!0,r&&r.abort(),clearInterval(m)}},[Ve]);const Ct=s.useCallback((t,r)=>{T(d=>d.map(p=>p.id===t?{...p,graphDiff:r}:p))},[]),ee=s.useCallback(async(t,r)=>{var p;const d=++he.current;P(!0),ae(t);try{const m=`urn:dkg:chat:session:${t}`,f=Math.max(500,Math.min((r==null?void 0:r.limitOverride)??le,15e3)),k=f+1,E=`CONSTRUCT { ?s ?p ?o } WHERE {
|
|
39
|
+
{
|
|
40
|
+
SELECT ?s ?p ?o WHERE {
|
|
41
|
+
{ <${m}> ?p ?o . BIND(<${m}> AS ?s) }
|
|
42
|
+
UNION
|
|
43
|
+
{ ?s <http://schema.org/isPartOf> <${m}> . ?s ?p ?o }
|
|
44
|
+
UNION
|
|
45
|
+
{ ?msg <http://schema.org/isPartOf> <${m}> .
|
|
46
|
+
?msg <http://dkg.io/ontology/usedTool> ?tool .
|
|
47
|
+
?tool ?p ?o . BIND(?tool AS ?s) }
|
|
48
|
+
UNION
|
|
49
|
+
{ ?msg <http://schema.org/isPartOf> <${m}> .
|
|
50
|
+
?entity <http://dkg.io/ontology/mentionedIn> ?msg .
|
|
51
|
+
?entity ?p ?o . BIND(?entity AS ?s) }
|
|
52
|
+
UNION
|
|
53
|
+
{ ?msg <http://schema.org/isPartOf> <${m}> .
|
|
54
|
+
?srcEntity <http://dkg.io/ontology/mentionedIn> ?msg .
|
|
55
|
+
?srcEntity ?rel ?targetEntity .
|
|
56
|
+
FILTER(STRSTARTS(STR(?targetEntity), "urn:dkg:entity:"))
|
|
57
|
+
?targetEntity ?p ?o . BIND(?targetEntity AS ?s) }
|
|
58
|
+
UNION
|
|
59
|
+
{ ?memory <http://dkg.io/ontology/extractedFrom> <${m}> .
|
|
60
|
+
?memory ?p ?o . BIND(?memory AS ?s) }
|
|
61
|
+
}
|
|
62
|
+
ORDER BY ?s ?p ?o
|
|
63
|
+
LIMIT ${k}
|
|
64
|
+
}
|
|
65
|
+
}`,A=await qt(E,"agent-memory",!0),X=(Array.isArray((p=A==null?void 0:A.result)==null?void 0:p.quads)?A.result.quads:[]).map(ce=>({subject:ce.subject,predicate:ce.predicate,object:Le(ce.object)})),z=X.length>f,te=z?X.slice(0,f):X;if(he.current!==d)return;pe(f),Y(z);const Ce=et(te);we(ce=>ce&&Ce.has(ce)?ce:null),Oe.current.set(t,$s(te)),N(te)}catch{if(he.current!==d)return;Oe.current.set(t,null),Y(!1),N([])}finally{he.current===d&&P(!1)}},[le]),at=s.useCallback(async(t,r,d)=>{const p=performance.now(),m=(z,te)=>{kt(z,performance.now()-p,te)},f=je.current,k=Ee.current??ze.current;if((f??k)!==t)return;const A=it.current;if(!A||bt.current){await ee(t),m("fallback",A?"partial_graph_snapshot":"missing_graph_snapshot");return}const ke=he.current,X=Oe.current.get(t)??null;try{const z=await xs(t,r,{baseTurnId:X});if(he.current!==ke||je.current&&je.current!==t)return;if(z.mode!=="delta"){await ee(t),m("fallback",z.reason??"full_refresh_required");return}const te=(z.triples??[]).map(ht=>({subject:ht.subject,predicate:ht.predicate,object:Le(ht.object)})),Ce=it.current??[],ce=Ps(Ce,te);let Je=d==null?void 0:d.linkedMessageId;Je==null&&(d!=null&&d.linkedTurnId)&&(Je=ot.current.get(d.linkedTurnId)),Je!=null&&Ct(Je,Ls(Ce,ce)),Oe.current.set(t,z.watermark.appliedTurnId??z.watermark.latestTurnId??r),ae(t),Y(!1),N(ce),m("delta")}catch{await ee(t),m("fallback","delta_request_error")}},[Ct,ee,kt]);jt.current=at;const lt=s.useCallback(async t=>{oe(!0),U(!1),O(null),ye(!1),Se("raw"),pe(1500),$(null),ve(),await Promise.all([ee(t,{limitOverride:1500}),Ke(t)])},[ee,Ke,ve]),It=s.useCallback(()=>{if(v){he.current+=1,oe(!1),U(!1),P(!1),ye(!1),$(null),Y(!1),Ae(null);return}const t=L??M;if(!t){ve(),oe(!0),U(!1),N([]),ae(null),P(!1),Y(!1),Ae(null);return}lt(t)},[v,L,M,lt,ve]),Nt=s.useCallback(async()=>{const t=F.trim();if(!t||j)return;se("");const r={id:Xe++,role:"user",content:t,ts:new Date().toLocaleTimeString()},d=Xe++,p=new Date().toLocaleTimeString();T(m=>[...m,r,{id:d,role:"assistant",content:"",ts:p,responseMode:"streaming"}]),Ne(!0),Re.current=!0;try{const m=await ms(t,{sessionId:M??void 0,onEvent:f=>{if(f.type==="text_delta"){T(k=>k.map(E=>E.id===d?{...E,content:`${E.content}${f.delta}`}:E));return}if(f.type==="final"){if(T(k=>k.map(E=>E.id===d?{...E,content:f.reply||E.content,data:f.data,sparql:f.sparql,turnId:f.turnId,persistStatus:f.persistStatus,persistError:f.persistError,timings:f.timings,responseMode:f.responseMode,llmDiagnostics:f.llmDiagnostics}:E)),f.turnId){const k=ge.current.get(f.turnId);k&&(ge.current.delete(f.turnId),Ve(k))}Ue.current&&f.sessionId&&f.persistStatus==="stored"&&f.turnId&&at(f.sessionId,f.turnId,{linkedMessageId:d})}}});m.sessionId&&(ue(m.sessionId),xe(m.sessionId)),De()}catch(m){T(f=>f.map(k=>k.id===d?{...k,content:`Error: ${m.message}`,responseMode:"blocking"}:k))}finally{Ne(!1)}},[F,j,M,De,Ve,at]),ss=s.useCallback(()=>{j||(Fe.current+=1,he.current+=1,ge.current.clear(),Oe.current.clear(),ve(),ue(null),xe(null),T([Ht()]),se(""),N(null),ae(null),P(!1),pe(1500),Y(!1),Se("raw"),U(!1),$(null),$e(null),we(null),Ae(null),He(""),O(null),ye(!1),U(!1),Re.current=!0)},[j,ve]),rs=s.useCallback(async t=>{var d;if(j||t===L)return;const r=++Fe.current;ge.current.clear(),ve(),ie(!0),O(null),ye(!1),Re.current=!0,$e(null),we(null),Ae(null),He("");try{const p=await ys(t);if(Fe.current!==r||!((d=p==null?void 0:p.messages)!=null&&d.length))return;const m=St.current.get(t)??[],f=new Map;for(const A of m)A.turnId&&f.set(A.turnId,A);const k=p.messages.map(A=>{var Ce;const ke=A.author==="user"?"user":"assistant",X=((Ce=A.turnId)==null?void 0:Ce.trim())||void 0,z=X?f.get(X):void 0;let te=Ns(A.persistStatus);return(z==null?void 0:z.persistStatus)==="enshrined"&&(te="enshrined"),!te&&ke==="assistant"&&X&&(te="stored"),{id:Xe++,role:ke,content:A.text,ts:A.ts?_t(A.ts)||new Date(A.ts).toLocaleTimeString():"",turnId:X,persistStatus:te,graphDiff:z==null?void 0:z.graphDiff,llmDiagnostics:z==null?void 0:z.llmDiagnostics}}),E=Me[t];T((E==null?void 0:E.scope)==="enshrined"?gt(k):k),ue(t),xe(t),v?(Se("raw"),pe(1500),await Promise.all([ee(t,{limitOverride:1500}),Ke(t)])):(he.current+=1,N(null),ae(null),P(!1),Y(!1))}catch{}finally{Fe.current===r&&ie(!1)}},[j,L,v,ee,Ke,ve,Me]),y=s.useMemo(()=>!o||o.length===0?null:Bs(o),[o]),Mt=s.useMemo(()=>{if(!y||y.timestamps.length===0)return 0;const t=C??y.timestamps[y.timestamps.length-1];let r=0;for(let d=0;d<y.timestamps.length&&y.timestamps[d]<=t;d+=1)r=d;return r},[y,C]),Tt=s.useMemo(()=>!o||!y||C===null?o:Gs(o,y.subjectDates,C),[o,y,C]);s.useEffect(()=>{y&&y.timestamps.length>0&&C===null&&O(y.timestamps[y.timestamps.length-1])},[y,C]),s.useEffect(()=>{if(!Te||!y||y.timestamps.length<2)return;const t=y.timestamps;return rt.current=setInterval(()=>{O(r=>{const d=t.findIndex(p=>p>(r??0));return d===-1||d>=t.length?(ye(!1),t[t.length-1]):t[d]})},600),()=>{rt.current&&clearInterval(rt.current)}},[Te,y]);const dt=s.useMemo(()=>{const t=new Map;if(!o||o.length===0)return t;for(const r of o){if(r.predicate!==Ms)continue;const d=Wt(Le(r.object));d&&(t.has(d)||t.set(d,new Set),t.get(d).add(r.subject))}return t},[o]),Be=s.useMemo(()=>{const t=new Map;if(dt.size===0)return t;for(const r of x){const d=Wt(r.content);if(!d)continue;const p=dt.get(d);p&&p.size>0&&t.set(r.id,[...p])}return t},[x,dt]),qe=s.useMemo(()=>{const t=new Map;for(const[r,d]of Be)for(const p of d)t.set(p,r);return t},[Be]),fe=s.useMemo(()=>{const t=Tt??o;return t&&(G==="clustered"?Ws(t):t)},[Tt,o,G]),ns=s.useMemo(()=>{if(G!=="clustered"||!fe)return 0;const t=new Set;for(const r of fe)r.predicate===Ze&&r.object===Xt&&t.add(r.subject);return t.size},[G,fe]),Ye=s.useMemo(()=>{const t=_e.trim().toLowerCase(),r=fe;if(!t||!r)return[];const d=new Set;for(const p of r)(p.subject.toLowerCase().includes(t)||p.predicate.toLowerCase().includes(t)||p.object.toLowerCase().includes(t))&&(d.add(p.subject),Ge(p.object)&&d.add(p.object));return[...d]},[fe,_e]),is=s.useMemo(()=>{const t=new Set;if(be!=null)for(const r of Be.get(be)??[])t.add(r);for(const r of Ye)t.add(r);return Z&&t.add(Z),[...t]},[be,Be,Ye,Z]),Rt=s.useMemo(()=>[...x].reverse().find(t=>t.role==="assistant"&&t.graphDiff),[x]),Q=s.useMemo(()=>{if(be!=null){const t=x.find(r=>r.id===be&&r.role==="assistant"&&r.graphDiff);if(t!=null&&t.graphDiff)return t}return Rt??null},[x,be,Rt]),Et=s.useCallback(t=>{const r=nt.current.get(t);r&&(Re.current=!1,r.scrollIntoView({behavior:"smooth",block:"center"}))},[]),zt=s.useCallback((t,r=2.1)=>{vt.current+=1,Ae({nodeId:t,requestId:vt.current,zoomLevel:r})},[]),os=s.useCallback(t=>{we(t.id);const r=qe.get(t.id);r!=null&&$e(r)},[qe]),as=s.useMemo(()=>({name:"Conversation",palette:"dark",paletteOverrides:{edgeColor:"#5f8598",particleColor:"rgba(34, 211, 238, 0.5)"}}),[]),Dt=s.useMemo(()=>!o||o.length===0?new Set:et(o),[o]),de=L??M??B,I=de?Me[de]??null:null,ls=s.useMemo(()=>I?I.scope==="enshrined"?"enshrined":I.scope==="enshrined_with_pending"?"enshrined + pending":I.scope==="workspace_only"?"workspace only":"empty":de?"checking...":"no session",[de,I]),Lt=!!me&&!!de&&me===de,Pt=!!me&&!!de&&me!==de,ct=!B||Lt||Pt,ut=J&&de&&J.sessionId===de?J.text:null;s.useEffect(()=>{G==="raw"&&Z&&(Dt.has(Z)||we(null))},[G,Dt,Z]);const ds=s.useCallback(()=>{const t=je.current;if(!t||S)return;const r=Math.min(le+1500,15e3);ee(t,{limitOverride:r})},[ee,le,S]),cs=s.useCallback(async()=>{const t=je.current??Ee.current??ze.current;if(!(!t||me!=null)){u(t),$(null);try{const r=await Promise.race([Yt(t,{clearAfter:!1}),new Promise((p,m)=>{setTimeout(()=>m(new Error("Publishing timed out. Please retry.")),45e3)})]);Pe(p=>({...p,[t]:r.publication})),(Ee.current??ze.current)===t&&r.publication.scope==="enshrined"&&T(p=>gt(p)),$({sessionId:t,text:`Published ${r.rootEntityCount} root entities (${r.status})`}),Ue.current&&je.current===t&&await ee(t),await De()}catch(r){$({sessionId:t,text:`Publish failed: ${(r==null?void 0:r.message)??"Unknown error"}`})}finally{u(r=>r===t?null:r)}}},[ee,me,De]),$t=e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,background:"var(--bg)"},children:[e.jsxs("div",{style:{padding:"10px 12px",borderBottom:"1px solid var(--border)",display:"grid",gap:8},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",fontSize:11,color:"var(--text-muted)"},children:[e.jsx("span",{children:G==="clustered"?`${ns} clusters`:`${(fe==null?void 0:fe.length)??0} triples`}),Ye.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--text-dim)"},children:"."}),e.jsxs("span",{children:[Ye.length," highlighted nodes"]})]}),e.jsx("span",{style:{color:"var(--text-dim)"},children:"."}),e.jsx("span",{className:"mono",style:{borderRadius:999,border:(I==null?void 0:I.scope)==="enshrined"?"1px solid rgba(74,222,128,.3)":(I==null?void 0:I.scope)==="enshrined_with_pending"?"1px solid rgba(245,158,11,.35)":"1px solid var(--border)",background:(I==null?void 0:I.scope)==="enshrined"?"rgba(74,222,128,.1)":(I==null?void 0:I.scope)==="enshrined_with_pending"?"rgba(245,158,11,.12)":"var(--surface)",color:(I==null?void 0:I.scope)==="enshrined"?"var(--green)":(I==null?void 0:I.scope)==="enshrined_with_pending"?"#f59e0b":"var(--text-dim)",padding:"2px 8px",fontSize:10},title:`workspace triples: ${(I==null?void 0:I.workspaceTripleCount)??0}, data triples: ${(I==null?void 0:I.dataTripleCount)??0}`,children:ls}),B&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--text-dim)"},children:"."}),e.jsxs("span",{className:"mono",title:B,children:["session ",B.slice(0,10)]})]})]}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsx("input",{value:_e,onChange:t=>He(t.target.value),placeholder:"Search graph nodes, predicates, values",style:{flex:1,minWidth:0,borderRadius:8,border:"1px solid var(--border)",background:"var(--surface)",color:"var(--text)",padding:"7px 10px",fontSize:11}}),_e&&e.jsx("button",{onClick:()=>He(""),style:{borderRadius:7,border:"1px solid var(--border)",background:"var(--surface)",color:"var(--text-muted)",padding:"6px 8px",fontSize:10,cursor:"pointer"},children:"Clear"})]}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[e.jsx("button",{onClick:()=>Se("raw"),style:{borderRadius:7,border:G==="raw"?"1px solid rgba(34,211,238,.35)":"1px solid var(--border)",background:G==="raw"?"rgba(34,211,238,.1)":"var(--surface)",color:G==="raw"?"#22d3ee":"var(--text-muted)",padding:"5px 9px",fontSize:10,cursor:"pointer"},children:"Raw"}),e.jsx("button",{onClick:()=>Se("clustered"),style:{borderRadius:7,border:G==="clustered"?"1px solid rgba(34,211,238,.35)":"1px solid var(--border)",background:G==="clustered"?"rgba(34,211,238,.1)":"var(--surface)",color:G==="clustered"?"#22d3ee":"var(--text-muted)",padding:"5px 9px",fontSize:10,cursor:"pointer"},children:"Clustered"}),e.jsx("button",{onClick:ds,disabled:!V||S,style:{borderRadius:7,border:"1px solid var(--border)",background:"var(--surface)",color:V?"var(--text-muted)":"var(--text-dim)",padding:"5px 9px",fontSize:10,cursor:V?"pointer":"not-allowed",opacity:V?1:.65},title:V?`Load more triples (current limit ${le})`:"All currently loaded triples are shown",children:V?"Load more":"Fully loaded"}),e.jsx("button",{onClick:()=>{cs()},disabled:ct,title:Pt?"Another session is currently publishing":void 0,style:{marginLeft:"auto",borderRadius:7,border:"1px solid rgba(74,222,128,.35)",background:"rgba(74,222,128,.1)",color:"var(--green)",padding:"5px 9px",fontSize:10,cursor:ct?"not-allowed":"pointer",opacity:ct?.65:1},children:Lt?"Publishing...":"Publish session"})]}),ut&&e.jsx("div",{className:"mono",style:{fontSize:10,color:ut.toLowerCase().includes("failed")?"var(--red)":"var(--green)"},children:ut}),e.jsx("div",{className:"mono",style:{fontSize:10,color:"var(--text-dim)",lineHeight:1.5},children:"Publish session enshrines the agent conversation currently in view on the DKG privately. New writes remain in workspace until you publish again."})]}),e.jsxs("div",{style:{flex:1,minHeight:0,position:"relative"},children:[S&&e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)"},children:"Loading graph..."}),!S&&o==null&&e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-dim)",fontSize:12,textAlign:"center",padding:20},children:"Open a conversation graph to see node growth while you chat."}),!S&&o&&o.length===0&&e.jsxs("div",{className:"empty-state",style:{position:"absolute",inset:0},children:[e.jsx("div",{className:"empty-state-icon",children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("circle",{cx:"19",cy:"5",r:"2"}),e.jsx("circle",{cx:"5",cy:"19",r:"2"}),e.jsx("line",{x1:"14.5",y1:"9.5",x2:"17.5",y2:"6.5"}),e.jsx("line",{x1:"9.5",y1:"14.5",x2:"6.5",y2:"17.5"})]})}),e.jsx("div",{className:"empty-state-title",children:"No triples yet"}),e.jsx("div",{className:"empty-state-desc",children:"Memory graph triples will appear here as data is stored."})]}),!S&&o&&o.length>0&&e.jsx(Jt,{data:fe??o,format:"triples",options:{labelMode:"humanized",renderer:"2d",labels:{predicates:["http://schema.org/text","http://schema.org/name","http://www.w3.org/2000/01/rdf-schema#label","http://dkg.io/ontology/sessionId","http://dkg.io/ontology/toolName"]},style:{classColors:{"http://schema.org/Conversation":"#4ade80","http://schema.org/Message":"#22d3ee","http://dkg.io/ontology/ToolInvocation":"#f59e0b","http://dkg.io/ontology/GraphCluster":"#a78bfa","http://schema.org/Person":"#f472b6","http://schema.org/Organization":"#fb923c","http://schema.org/Place":"#34d399","http://schema.org/Product":"#c084fc","http://schema.org/Event":"#facc15","http://schema.org/CreativeWork":"#7dd3fc"},defaultNodeColor:"#94a3b8",defaultEdgeColor:"#5f8598",edgeWidth:.9},hexagon:{baseSize:4,minSize:3,maxSize:6,scaleWithDegree:!0,circleTypes:["http://schema.org/Message"]},focus:{maxNodes:5e3,hops:999}},viewConfig:as,style:{width:"100%",height:"100%"},onNodeClick:os,children:e.jsx(Os,{nodeIds:is,focusRequest:Zt})})]}),y&&y.timestamps.length>1&&e.jsxs("div",{style:{padding:"10px 12px",borderTop:"1px solid var(--border)",display:"grid",gap:8,background:"var(--bg)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("button",{onClick:()=>{Te?ye(!1):(C!==null&&C>=y.timestamps[y.timestamps.length-1]&&O(y.timestamps[0]),ye(!0))},style:{width:28,height:28,borderRadius:"50%",border:"1px solid rgba(34,211,238,.3)",background:Te?"rgba(34,211,238,.15)":"var(--surface)",color:"#22d3ee",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,flexShrink:0},title:Te?"Pause timeline":"Play timeline",children:Te?"||":">"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("button",{onClick:()=>xt("timestamp"),style:{borderRadius:6,border:H==="timestamp"?"1px solid rgba(34,211,238,.35)":"1px solid var(--border)",background:H==="timestamp"?"rgba(34,211,238,.12)":"var(--surface)",color:H==="timestamp"?"#22d3ee":"var(--text-muted)",padding:"5px 8px",fontSize:10,cursor:"pointer"},children:"Timestamp"}),e.jsx("button",{onClick:()=>xt("turn"),style:{borderRadius:6,border:H==="turn"?"1px solid rgba(34,211,238,.35)":"1px solid var(--border)",background:H==="turn"?"rgba(34,211,238,.12)":"var(--surface)",color:H==="turn"?"#22d3ee":"var(--text-muted)",padding:"5px 8px",fontSize:10,cursor:"pointer"},children:"Turn"})]}),e.jsx("div",{className:"mono",style:{marginLeft:"auto",fontSize:10,color:"var(--text-dim)"},children:H==="turn"?`Turn ${Mt+1}/${y.timestamps.length}`:`At ${new Date(C??y.timestamps[y.timestamps.length-1]).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}`})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("div",{className:"mono",style:{fontSize:10,color:"var(--text-dim)",minWidth:56},children:H==="turn"?"Turn 1":new Date(y.timestamps[0]).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),e.jsx("input",{type:"range",min:H==="turn"?0:y.timestamps[0],max:H==="turn"?y.timestamps.length-1:y.timestamps[y.timestamps.length-1],step:H==="turn"?1:void 0,value:H==="turn"?Mt:C??y.timestamps[y.timestamps.length-1],onChange:t=>{const r=Number(t.target.value);if(ye(!1),H==="turn"){const d=Math.max(0,Math.min(y.timestamps.length-1,r));O(y.timestamps[d]);return}O(r)},style:{flex:1,accentColor:"#22d3ee",cursor:"pointer"}}),e.jsx("div",{className:"mono",style:{fontSize:10,color:"var(--text-dim)",minWidth:66,textAlign:"right"},children:H==="turn"?`Turn ${y.timestamps.length}`:new Date(y.timestamps[y.timestamps.length-1]).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})})]})]}),(Z||(Q==null?void 0:Q.graphDiff))&&e.jsxs("div",{style:{padding:"10px 12px",borderTop:"1px solid var(--border)",background:"var(--surface)",display:"grid",gap:8},children:[Z&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[e.jsx("span",{style:{fontSize:10,color:"var(--text-dim)",flexShrink:0},children:"Selected node"}),e.jsx("code",{style:{fontSize:10,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:Z,children:Gt(Z)}),qe.has(Z)&&e.jsx("button",{onClick:()=>Et(qe.get(Z)),style:{marginLeft:"auto",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",padding:"4px 8px",fontSize:10,cursor:"pointer"},children:"Jump to message"})]}),(Q==null?void 0:Q.graphDiff)&&e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:11,fontWeight:700,color:"var(--text)"},children:"What changed"}),e.jsx("span",{style:{fontSize:10,color:"var(--text-dim)"},children:be===Q.id?"selected turn":"latest persisted turn"}),e.jsx("button",{onClick:()=>{$e(Q.id),Et(Q.id)},style:{marginLeft:"auto",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-muted)",padding:"4px 8px",fontSize:10,cursor:"pointer"},children:"Go to turn"})]}),e.jsxs("div",{className:"mono",style:{fontSize:10,color:"var(--cyan)"},children:["+",Q.graphDiff.addedNodeCount," nodes . +",Q.graphDiff.addedEdgeCount," edges"]}),Q.graphDiff.sampleNodes.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:Q.graphDiff.sampleNodes.map(t=>e.jsx("button",{onClick:()=>{we(t),zt(t)},title:t,style:{borderRadius:999,border:"1px solid rgba(34,211,238,.25)",background:"rgba(34,211,238,.08)",color:"#22d3ee",padding:"3px 8px",fontSize:10,cursor:"pointer",maxWidth:220,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:Gt(t)},t))})]})]})]}),pt=v&&!R,us=!(v&&R),ps=pt?We?{gridTemplateColumns:"1fr",gridTemplateRows:"minmax(260px, .95fr) minmax(260px, 1.05fr)"}:{gridTemplateColumns:"minmax(340px, 1fr) minmax(360px, .95fr)",gridTemplateRows:"1fr"}:{gridTemplateColumns:"1fr",gridTemplateRows:"1fr"};return e.jsxs("div",{className:"page-section",style:{display:"flex",flexDirection:"column",height:"100%",padding:0},children:[e.jsx("div",{style:{display:"flex",borderBottom:"1px solid var(--border)",background:"var(--bg)",padding:"0 16px",gap:0,flexShrink:0},children:(g!=null&&g.hasOpenClawChannel?["openclaw","peers"]:["agent","peers"]).map(t=>e.jsxs("button",{onClick:()=>w(t),style:{padding:"12px 20px",fontSize:12,fontWeight:b===t?700:500,background:"none",border:"none",borderBottom:b===t?"2px solid var(--green)":"2px solid transparent",color:b===t?"var(--text)":"var(--text-muted)",cursor:"pointer",display:"flex",alignItems:"center",gap:6,transition:"all .15s ease"},children:[t==="agent"?e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),e.jsx("circle",{cx:"12",cy:"5",r:"3"})]}):t==="openclaw"?e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),e.jsx("path",{d:"M2 17l10 5 10-5"}),e.jsx("path",{d:"M2 12l10 5 10-5"})]}):e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),t==="agent"?"My Agent":t==="openclaw"?`OpenClaw${g!=null&&g.name?` (${g.name})`:""}`:"Peer Chat"]},t))}),b==="peers"?e.jsx("div",{style:{flex:1,overflow:"hidden"},children:e.jsx(Hs,{initialPeerId:a==null?void 0:a.peerId,onPeerSelected:()=>h(null)})}):b==="openclaw"?e.jsx("div",{style:{flex:1,overflow:"hidden"},children:e.jsx(Fs,{})}):e.jsxs("div",{style:{display:"grid",gridTemplateColumns:W?"44px 1fr":"260px 1fr",flex:1,overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",borderRight:"1px solid var(--border)",background:"var(--bg)",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:W?"10px 8px":"16px 14px 12px",borderBottom:"1px solid var(--border)",display:"grid",gap:8},children:[e.jsx("button",{onClick:()=>_(t=>!t),title:W?"Expand sidebar":"Collapse sidebar",style:{width:"100%",padding:W?"8px 6px":"8px 10px",borderRadius:8,border:"1px solid var(--border)",background:"var(--surface)",color:"var(--text-muted)",fontSize:11,fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:W?e.jsx("path",{d:"M9 18l6-6-6-6"}):e.jsx("path",{d:"M15 18l-6-6 6-6"})})}),e.jsxs("button",{onClick:ss,disabled:j,title:"Start a new chat session",style:{width:"100%",padding:W?"8px 6px":"10px 14px",borderRadius:10,border:"1px solid rgba(74,222,128,.3)",background:"var(--green-dim)",color:"var(--green)",fontSize:12,fontWeight:700,cursor:j?"not-allowed":"pointer",opacity:j?.6:1,display:"flex",alignItems:"center",justifyContent:"center",gap:W?0:8},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),!W&&"New Chat"]})]}),!W&&e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"8px 10px"},children:[ne&&K.length===0&&e.jsx("div",{style:{fontSize:11,color:"var(--text-dim)",padding:"12px 6px"},children:"Loading conversations…"}),!ne&&K.length===0&&e.jsxs("div",{className:"empty-state empty-state--sidebar",children:[e.jsx("div",{className:"empty-state-icon",children:e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),e.jsx("div",{className:"empty-state-title",children:"No conversations yet"}),e.jsx("div",{className:"empty-state-desc",children:"Start chatting with your agent. Each conversation is stored in your private knowledge graph."})]}),K.map(t=>{const r=t.id===L,d=_t(t.lastTs);return e.jsxs("div",{onClick:()=>{j||rs(t.id)},style:{padding:"10px 12px",borderRadius:8,marginBottom:4,cursor:j?"not-allowed":"pointer",opacity:j?.75:1,background:r?"var(--surface)":"transparent",border:r?"1px solid var(--border)":"1px solid transparent",transition:"all .15s ease"},onMouseEnter:p=>{!r&&!j&&(p.currentTarget.style.background="var(--surface)")},onMouseLeave:p=>{!r&&!j&&(p.currentTarget.style.background="transparent")},children:[e.jsxs("div",{style:{fontSize:12,fontWeight:r?700:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r?"var(--text)":"var(--text-muted)",marginBottom:3},children:[t.preview,t.preview.length>=60?"…":""]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsxs("span",{className:"mono",style:{fontSize:10,color:"var(--text-dim)"},children:[t.messageCount," msg",d?` · ${d}`:""]}),r&&e.jsx("button",{onClick:p=>{p.stopPropagation(),!j&&(v&&B===t.id?It():lt(t.id))},disabled:j,title:"Visualize conversation graph",style:{marginLeft:"auto",padding:"2px 6px",fontSize:9,fontWeight:600,borderRadius:4,border:"1px solid rgba(34,211,238,.3)",background:"rgba(34,211,238,.08)",color:"#22d3ee",cursor:j?"not-allowed":"pointer",opacity:j?.7:1},children:v&&B===t.id?"Hide":"Graph"})]})]},t.id)})]}),!W&&e.jsx("div",{style:{padding:"10px 14px",borderTop:"1px solid var(--border)",fontSize:10,color:"var(--text-dim)"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z"}),e.jsx("path",{d:"M12 6v6l4 2"})]}),"Conversations stored in your private DKG"]})})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden",minWidth:0},children:[e.jsxs("div",{style:{padding:"14px 20px",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:34,height:34,borderRadius:"50%",background:"var(--green-dim)",border:"1px solid rgba(74,222,128,.25)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:16},children:"AI"}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:700},children:"DKG Agent"}),e.jsxs("div",{style:{fontSize:11,color:"var(--green)",display:"flex",alignItems:"center",gap:5},children:[e.jsx("span",{className:"pulse-dot",style:{width:6,height:6,borderRadius:"50%",background:"var(--green)",display:"inline-block"}}),"Connected"]})]}),v&&e.jsx("span",{style:{marginLeft:8,fontSize:10,color:"#22d3ee",background:"rgba(34,211,238,.1)",border:"1px solid rgba(34,211,238,.28)",borderRadius:999,padding:"3px 8px"},children:R?"Graph-only view":"Split graph view"}),q&&e.jsxs("span",{className:"mono",title:`Pending: ${q.pending}, In progress: ${q.inProgress}, Failed: ${q.failed}, Overdue: ${q.overduePending}`,style:{marginLeft:8,fontSize:10,color:q.failed>0||q.overduePending>0?"var(--red)":"var(--text-dim)",background:q.failed>0||q.overduePending>0?"rgba(248,113,113,.08)":"var(--surface)",border:q.failed>0||q.overduePending>0?"1px solid rgba(248,113,113,.3)":"1px solid var(--border)",borderRadius:999,padding:"3px 8px"},children:["Queue ",q.pending,q.failed>0?` . fail ${q.failed}`:"",q.overduePending>0?` . overdue ${q.overduePending}`:""]}),v&&e.jsx("button",{onClick:()=>U(t=>!t),style:{marginLeft:8,padding:"5px 10px",fontSize:10,fontWeight:600,borderRadius:6,border:R?"1px solid rgba(34,211,238,.5)":"1px solid var(--border)",background:R?"rgba(34,211,238,.1)":"var(--surface)",color:R?"#22d3ee":"var(--text-muted)",cursor:"pointer"},title:R?"Exit graph-only mode":"Focus on graph only",children:R?"Exit graph-only":"Graph only"}),e.jsxs("button",{onClick:It,style:{marginLeft:"auto",padding:"5px 12px",fontSize:11,fontWeight:600,borderRadius:6,border:v?"1px solid rgba(34,211,238,.5)":"1px solid var(--border)",background:v?"rgba(34,211,238,.1)":"var(--surface)",color:v?"#22d3ee":"var(--text-muted)",cursor:"pointer",display:"flex",alignItems:"center",gap:5,transition:"all .15s ease"},children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"6",cy:"6",r:"3"}),e.jsx("circle",{cx:"18",cy:"6",r:"3"}),e.jsx("circle",{cx:"12",cy:"18",r:"3"}),e.jsx("line",{x1:"8.5",y1:"7.5",x2:"10.5",y2:"16"}),e.jsx("line",{x1:"15.5",y1:"7.5",x2:"13.5",y2:"16"})]}),v?"Hide Graph":"Show Graph"]})]}),e.jsxs("div",{style:{flex:1,minHeight:0,display:"grid",...ps},children:[us&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0,minHeight:0,borderRight:pt&&!We?"1px solid var(--border)":"none",borderBottom:pt&&We?"1px solid var(--border)":"none"},children:[e.jsxs("div",{ref:st,onScroll:ts,className:"chat-area",style:{flex:1,overflowY:"scroll",padding:"20px 24px"},children:[x.map(t=>{const r=be===t.id,d=Be.get(t.id)??[],p=t.persistStatus!=="stored"&&t.persistStatus!=="enshrined"&&t.persistStatus!=="skipped"&&t.persistAttempts!=null&&t.persistMaxAttempts!=null;return e.jsxs("div",{ref:m=>{m?nt.current.set(t.id,m):nt.current.delete(t.id)},className:`chat-msg ${t.role}`,onClick:()=>{if($e(t.id),!v)return;const m=d[0]??null;we(m),m&&zt(m)},style:{cursor:v?"pointer":"default"},children:[e.jsx("div",{className:`chat-bubble ${t.role}`,style:r?{boxShadow:"0 0 0 1px rgba(34,211,238,.55)"}:void 0,children:t.content}),t.role==="assistant"&&(t.persistStatus||t.llmDiagnostics||t.graphDiff)&&e.jsxs("div",{style:{marginTop:5,display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[t.persistStatus&&e.jsxs("span",{className:"mono",title:t.persistStatus==="enshrined"?"Published to the paranet and anchored on-chain":t.persistStatus==="stored"?"Saved to your local knowledge graph":t.persistStatus==="failed"?"Failed to persist this memory":t.persistStatus==="skipped"?"Memory persistence was skipped for this message":t.persistStatus==="in_progress"?"Currently being saved to the knowledge graph":"Waiting to be persisted",style:{fontSize:10,cursor:"help",color:t.persistStatus==="enshrined"?"#22d3ee":t.persistStatus==="stored"?"var(--green)":t.persistStatus==="failed"?"var(--red)":t.persistStatus==="skipped"?"var(--text-dim)":"#f59e0b",background:t.persistStatus==="enshrined"?"rgba(34,211,238,.1)":t.persistStatus==="stored"?"rgba(74,222,128,.1)":t.persistStatus==="failed"?"rgba(248,113,113,.08)":t.persistStatus==="skipped"?"var(--surface)":"rgba(245,158,11,.1)",border:t.persistStatus==="enshrined"?"1px solid rgba(34,211,238,.3)":t.persistStatus==="stored"?"1px solid rgba(74,222,128,.3)":t.persistStatus==="failed"?"1px solid rgba(248,113,113,.3)":t.persistStatus==="skipped"?"1px solid var(--border)":"1px solid rgba(245,158,11,.35)",borderRadius:5,padding:"2px 6px"},children:["Memory: ",t.persistStatus==="in_progress"?"pending":t.persistStatus,p?` (${t.persistAttempts}/${t.persistMaxAttempts})`:""]}),t.graphDiff&&e.jsxs("span",{style:{fontSize:10,color:"#22d3ee",background:"rgba(34,211,238,.1)",border:"1px solid rgba(34,211,238,.28)",borderRadius:5,padding:"2px 6px"},children:["Added to graph: +",t.graphDiff.addedNodeCount," nodes, +",t.graphDiff.addedEdgeCount," edges"]}),t.persistStatus==="failed"&&e.jsxs("span",{style:{fontSize:10,color:"var(--red)",background:"rgba(248,113,113,.08)",border:"1px solid rgba(248,113,113,.3)",borderRadius:5,padding:"2px 6px"},children:["Memory save failed: ",t.persistError??"Unknown error"]}),t.llmDiagnostics&&e.jsxs("span",{style:{fontSize:10,color:"#f59e0b",background:"rgba(245,158,11,.1)",border:"1px solid rgba(245,158,11,.35)",borderRadius:5,padding:"2px 6px"},title:t.llmDiagnostics.message,children:["LLM compatibility issue",t.llmDiagnostics.compatibilityHint?`: ${t.llmDiagnostics.compatibilityHint}`:""]})]}),t.sparql&&e.jsxs("details",{style:{marginTop:4},children:[e.jsx("summary",{style:{fontSize:10,color:"var(--text-dim)",cursor:"pointer"},children:"SPARQL used"}),e.jsx("pre",{className:"mono",style:{fontSize:10,color:"var(--text-muted)",padding:"6px 8px",background:"var(--surface)",borderRadius:4,marginTop:4,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:t.sparql})]}),e.jsx("div",{style:{fontSize:10,color:"var(--text-dim)",marginTop:4,fontFamily:"JetBrains Mono, monospace"},children:t.ts})]},t.id)}),j&&e.jsx("div",{className:"chat-msg assistant",children:e.jsx("div",{className:"chat-bubble assistant",style:{display:"flex",gap:4,alignItems:"center",padding:"12px 16px"},children:[0,.2,.4].map((t,r)=>e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--text-muted)",display:"inline-block",animation:`pulse 1.2s ease ${t}s infinite`}},r))})})]}),e.jsxs("div",{className:"chat-input-row",children:[e.jsx("input",{className:"chat-input",value:F,onChange:t=>se(t.target.value),onKeyDown:t=>t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),Nt()),placeholder:"Query the graph, recall memories, publish knowledge..."}),e.jsx("button",{className:"chat-send",onClick:Nt,disabled:j,children:"Send"})]})]}),v&&!We&&e.jsx("div",{style:{display:"flex",minWidth:0,overflow:"hidden"},children:$t})]}),v&&We&&e.jsx("div",{style:{borderTop:"1px solid var(--border)",height:"43%",minHeight:260,maxHeight:"70%",display:"flex",overflow:"hidden"},children:$t})]})]})]})}export{qs as AgentHubPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a1 as p,r as n,j as c}from"./index-
|
|
1
|
+
import{a1 as p,r as n,j as c}from"./index-BKmDUHkm.js";function m({apps:h}){const{appId:l}=p(),o=n.useRef(null),[d,s]=n.useState(null),i=n.useRef(!1),t=h.find(e=>e.id===l);n.useEffect(()=>{if(!t)return;let e=!1;return i.current=!1,s(null),t.staticUrl?fetch(t.staticUrl,{method:"HEAD"}).then(r=>{e||s(r.ok?t.staticUrl:`${t.path}/`)}).catch(()=>{e||s(`${t.path}/`)}):s(`${t.path}/`),()=>{e=!0}},[t==null?void 0:t.id,t==null?void 0:t.staticUrl,t==null?void 0:t.path]);const a=n.useCallback(()=>{var r;const e=window.__DKG_TOKEN__;e&&((r=o.current)!=null&&r.contentWindow)&&o.current.contentWindow.postMessage({type:"dkg-token",token:e,apiOrigin:window.location.origin},"*")},[]),w=n.useCallback(()=>{t&&t.staticUrl&&!i.current&&(i.current=!0,s(`${t.path}/`))},[t]);return n.useEffect(()=>{const e=r=>{var u,f;((u=r.data)==null?void 0:u.type)==="dkg-token-request"&&((f=o.current)==null?void 0:f.contentWindow)===r.source&&a()};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[a]),t?d?c.jsx("iframe",{ref:o,src:d,onLoad:a,onError:w,sandbox:"allow-scripts allow-forms allow-popups",style:{width:"100%",height:"100%",border:"none",borderRadius:8,background:"var(--surface)"},title:t.label}):null:c.jsxs("div",{style:{padding:32,color:"var(--text-muted)"},children:["App ",c.jsx("strong",{children:l})," is not installed."]})}export{m as AppHostPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,j as k}from"./index-
|
|
1
|
+
import{r as n,j as k}from"./index-BKmDUHkm.js";const E="origin-trail-game",a="/apps/origin-trail-game/";function R(o,t){return typeof t=="string"&&o!==null&&t===o}function b({apps:o}){const t=n.useRef(null),i=n.useRef(null),e=o==null?void 0:o.find(r=>r.id===E),[g,l]=n.useState((e==null?void 0:e.staticUrl)||a),c=n.useRef(!1);n.useEffect(()=>{c.current=!1,l((e==null?void 0:e.staticUrl)||a)},[e==null?void 0:e.staticUrl]);const w=n.useCallback(()=>{e!=null&&e.staticUrl&&!c.current&&(c.current=!0,l(a))},[e==null?void 0:e.staticUrl]),m=n.useCallback(()=>{var s;if(!((s=t.current)!=null&&s.contentWindow))return;const r=crypto.randomUUID();i.current=r,t.current.contentWindow.postMessage({type:"dkg-nonce",nonce:r},"*")},[]);return n.useEffect(()=>{const r=s=>{var u,d;if(((u=s.data)==null?void 0:u.type)==="dkg-token-request"&&((d=t.current)==null?void 0:d.contentWindow)===s.source&&R(i.current,s.data.nonce)){i.current=null;const f=window.__DKG_TOKEN__;f&&t.current.contentWindow.postMessage({type:"dkg-token",token:f,apiOrigin:window.location.origin},"*")}};return window.addEventListener("message",r),()=>window.removeEventListener("message",r)},[]),k.jsx("iframe",{ref:t,src:g,onLoad:m,onError:w,sandbox:"allow-scripts allow-forms allow-popups",allow:"clipboard-write",style:{width:"100%",height:"100%",border:"none",borderRadius:8,background:"#111"},title:"OriginTrail Game"})}export{b as AppsPage,R as validateTokenRequest};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as u,j as e,u as J,f as Z,a as ee,b as te,c as ne,i as re,d as se,e as oe,R as ie,g as ae,h as le,I as de,k as ce,l as he}from"./index-
|
|
1
|
+
import{r as u,j as e,u as J,f as Z,a as ee,b as te,c as ne,i as re,d as se,e as oe,R as ie,g as ae,h as le,I as de,k as ce,l as he}from"./index-BKmDUHkm.js";import{u as T,f as $}from"./hooks-CL5p8QP2.js";import{R as pe}from"./index-CjNfRG2Z.js";import"./ordinal-DIohFSkg.js";function E({text:t,children:l,maxWidth:r=280}){const[s,n]=u.useState(!1),[o,i]=u.useState(null),a=u.useRef(null),h=u.useRef(null),S=u.useCallback(()=>{if(!a.current)return;const m=a.current.getBoundingClientRect();i({x:m.left+m.width/2,y:m.top}),n(!0)},[]),f=u.useCallback(()=>n(!1),[]);return u.useEffect(()=>{if(!s||!h.current||!o)return;const m=h.current,k=m.getBoundingClientRect();let v=o.x,N=o.y;k.right>window.innerWidth-12&&(v-=k.right-window.innerWidth+12),k.left<12&&(v+=12-k.left),k.top<12?(N=a.current.getBoundingClientRect().bottom,m.classList.add("tt-below")):m.classList.remove("tt-below"),(v!==o.x||N!==o.y)&&i({x:v,y:N})},[s,o]),e.jsxs("span",{ref:a,onMouseEnter:S,onMouseLeave:f,style:{display:"inline-flex",alignItems:"center"},children:[l,s&&o&&e.jsx("div",{ref:h,className:"tt",style:{left:o.x,top:o.y,maxWidth:r},children:t})]})}function H({text:t,maxWidth:l}){return e.jsx(E,{text:t,maxWidth:l,children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-dim)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{marginLeft:4,verticalAlign:"middle",opacity:.7},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})})}const ue={claude:{label:"Claude",icon:"🟣"},chatgpt:{label:"ChatGPT",icon:"🟢"},gemini:{label:"Gemini",icon:"🔵"},other:{label:"Other",icon:"⚪"}},ge=de.map(t=>({value:t,...ue[t]})),fe={name:"ImportPreview",palette:"dark",paletteOverrides:{edgeColor:"#5f8598"},animation:{fadeIn:!0,linkParticles:!1,drift:!1,hoverTrace:!1}};function U(t){const l=t.replace(/^"|".*$/g,""),r=l.lastIndexOf("#"),s=l.lastIndexOf("/"),n=l.lastIndexOf(":"),o=Math.max(r,s,n);return o>=0?l.slice(o+1):l}function me(t){return t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t.startsWith('"')&&t.includes('"^^<')?t.slice(1,t.indexOf('"^^<')):t}function xe({result:t,onReset:l,onClose:r}){const[s,n]=u.useState("graph"),o=u.useMemo(()=>{var i;return(i=t.quads)!=null&&i.length?t.quads.filter(a=>!a.object.startsWith('"')).map(a=>({subject:a.subject,predicate:a.predicate,object:a.object})):[]},[t.quads]);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("div",{style:{textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:16,fontWeight:700,color:"var(--green)",marginBottom:4},children:[t.memoryCount," memories imported"]}),e.jsxs("p",{children:[t.tripleCount," triples created",t.entityCount>0&&e.jsxs(e.Fragment,{children:[" · ",t.entityCount," entities extracted"]})]}),e.jsxs("div",{className:"mono",style:{fontSize:10,color:"var(--text-dim)",marginTop:6},children:["Batch: ",t.batchId," · Source: ",t.source]})]}),t.warnings&&t.warnings.length>0&&e.jsx("div",{style:{padding:"8px 12px",borderRadius:8,background:"rgba(250,204,21,.08)",border:"1px solid rgba(250,204,21,.25)"},children:t.warnings.map((i,a)=>e.jsxs("div",{style:{fontSize:11,color:"rgb(250,204,21)",lineHeight:1.5},children:["⚠ ",i]},a))}),e.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"center"},children:[e.jsx("button",{className:`dkg-btn ${s==="graph"?"":"dkg-btn-secondary"}`,onClick:()=>n("graph"),style:{padding:"6px 16px",fontSize:11},children:"Graph"}),e.jsx("button",{className:`dkg-btn ${s==="triples"?"":"dkg-btn-secondary"}`,onClick:()=>n("triples"),style:{padding:"6px 16px",fontSize:11},children:"Triples"})]}),s==="graph"&&e.jsx("div",{style:{height:320,borderRadius:10,overflow:"hidden",border:"1px solid var(--border)",background:"var(--bg)"},children:o.length>0?e.jsx(pe,{data:o,format:"triples",options:{labelMode:"humanized",renderer:"2d",style:{classColors:{"http://dkg.io/ontology/MemoryImport":"#f59e0b","http://dkg.io/ontology/ImportedMemory":"#4ade80"},defaultNodeColor:"#22d3ee",defaultEdgeColor:"#5f8598",edgeWidth:.9},hexagon:{baseSize:4,minSize:3,maxSize:6,scaleWithDegree:!0},focus:{maxNodes:500,hops:999}},viewConfig:fe,style:{width:"100%",height:"100%"}}):e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--text-dim)",fontSize:12},children:"No graph edges to display"})}),s==="triples"&&e.jsx("div",{style:{maxHeight:320,overflowY:"auto",borderRadius:10,border:"1px solid var(--border)",background:"var(--bg)",padding:0},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:11,fontFamily:"'JetBrains Mono', monospace"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{position:"sticky",top:0,background:"var(--surface)",borderBottom:"1px solid var(--border)"},children:[e.jsx("th",{style:{textAlign:"left",padding:"8px 10px",color:"var(--text-dim)",fontWeight:600,fontSize:10,textTransform:"uppercase",letterSpacing:".05em"},children:"Subject"}),e.jsx("th",{style:{textAlign:"left",padding:"8px 10px",color:"var(--text-dim)",fontWeight:600,fontSize:10,textTransform:"uppercase",letterSpacing:".05em"},children:"Predicate"}),e.jsx("th",{style:{textAlign:"left",padding:"8px 10px",color:"var(--text-dim)",fontWeight:600,fontSize:10,textTransform:"uppercase",letterSpacing:".05em"},children:"Object"})]})}),e.jsx("tbody",{children:(t.quads??[]).map((i,a)=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--border)"},children:[e.jsx("td",{style:{padding:"6px 10px",color:"var(--cyan)",wordBreak:"break-all"},children:U(i.subject)}),e.jsx("td",{style:{padding:"6px 10px",color:"var(--text-muted)",wordBreak:"break-all"},children:U(i.predicate)}),e.jsx("td",{style:{padding:"6px 10px",color:i.object.startsWith('"')?"var(--text)":"var(--green)",wordBreak:"break-all"},children:me(i.object)})]},a))})]})}),e.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.6,textAlign:"center"},children:["Stored as private Knowledge Assets in ",e.jsx("code",{className:"mono",style:{fontSize:10,background:"var(--surface)",padding:"1px 4px",borderRadius:3},children:"agent-memory"}),". Never shared with other nodes."]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"center"},children:[e.jsx("button",{className:"dkg-btn dkg-btn-secondary",onClick:l,children:"Import More"}),e.jsx("button",{className:"dkg-btn dkg-btn-solid",onClick:r,children:"Done"})]})]})}function be({open:t,onClose:l}){const[r,s]=u.useState(""),[n,o]=u.useState("claude"),[i,a]=u.useState(!1),[h,S]=u.useState(!1),[f,m]=u.useState(null),[k,v]=u.useState(null),N=u.useCallback(()=>{s(""),o("claude"),a(!1),S(!1),m(null),v(null)},[]),c=u.useCallback(()=>{h||(N(),l())},[l,N,h]),w=u.useCallback(async()=>{if(!(!r.trim()||h)){S(!0),v(null),m(null);try{const d=await re(r.trim(),n,i);m(d)}catch(d){v(d.message??"Import failed")}finally{S(!1)}}},[r,n,i,h]);return t?e.jsx("div",{className:"import-modal-overlay open",onClick:c,children:e.jsxs("div",{className:"import-modal",style:f?{maxWidth:680}:void 0,onClick:d=>d.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:20},children:[e.jsx("h3",{style:{fontSize:18,fontWeight:700},children:f?"Import Complete":"Import Memories"}),e.jsx("button",{onClick:c,disabled:h,style:{background:"none",border:"none",color:"var(--text-muted)",fontSize:18,opacity:h?.3:1},children:"×"})]}),f?e.jsx(xe,{result:f,onReset:N,onClose:c}):e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{marginBottom:12},children:"Paste exported memories from Claude, ChatGPT, Gemini, or any other AI assistant. They'll be stored as private Knowledge Assets on your DKG node — owned by you, queryable by your agent."}),e.jsx("div",{style:{display:"flex",gap:6,marginBottom:14},children:ge.map(d=>e.jsxs("button",{className:`dkg-btn ${n===d.value?"":"dkg-btn-secondary"}`,onClick:()=>o(d.value),style:{padding:"6px 12px",fontSize:11},children:[e.jsx("span",{style:{fontSize:12},children:d.icon}),d.label]},d.value))}),e.jsxs("div",{style:{padding:"10px 14px",borderRadius:8,background:"var(--blue-dim)",border:"1px solid rgba(96,165,250,.2)",marginBottom:16},children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,color:"var(--blue)",marginBottom:4},children:"HOW TO EXPORT"}),e.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.6},children:["Paste this into ",n==="claude"?"Claude":n==="chatgpt"?"ChatGPT":n==="gemini"?"Gemini":"your AI assistant"," to export your memories:",e.jsx("br",{}),e.jsx("code",{className:"mono",style:{fontSize:10,color:"var(--text)",background:"rgba(255,255,255,.05)",padding:"2px 6px",borderRadius:4,display:"inline-block",marginTop:4},children:'"List every memory you have stored about me in a single code block."'})]})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:11,color:"var(--text-muted)",marginBottom:10,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:i,onChange:d=>a(d.target.checked),disabled:h}),e.jsxs("span",{children:["Use LLM-assisted parsing ",e.jsx("span",{style:{fontSize:10,opacity:.7},children:"(sends memories to configured LLM for better categorisation & entity extraction)"})]})]}),e.jsx("textarea",{value:r,onChange:d=>s(d.target.value),placeholder:"Paste your exported memories here...",disabled:h}),r.trim()&&e.jsxs("div",{className:"mono",style:{fontSize:10,color:"var(--text-dim)",marginTop:6},children:[r.trim().split(`
|
|
2
2
|
`).filter(d=>d.trim().length>3).length," lines detected"]}),k&&e.jsx("div",{style:{marginTop:10,padding:"8px 12px",borderRadius:6,background:"var(--red-dim)",border:"1px solid rgba(248,113,113,.2)",color:"var(--red)",fontSize:12},children:k}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:16,justifyContent:"flex-end"},children:[e.jsx("button",{className:"dkg-btn dkg-btn-secondary",onClick:c,disabled:h,children:"Cancel"}),e.jsx("button",{className:"dkg-btn dkg-btn-solid",onClick:w,disabled:h||!r.trim(),children:h?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{width:12,height:12,border:"2px solid rgba(10,15,26,.3)",borderTopColor:"var(--bg)",borderRadius:"50%",animation:"spin .6s linear infinite",display:"inline-block"}}),"Importing…"]}):e.jsxs(e.Fragment,{children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Import as Private Knowledge"]})})]})]})]})}):null}const Q={publish:"#10b981",query:"#3b82f6",update:"#f97316",chat:"#06b6d4",access:"#f59e0b",stake:"#8b5cf6"},Y=["#4f46e5","#6366f1","#818cf8","#3b82f6","#60a5fa","#22d3ee","#a78bfa","#8b5cf6","#f472b6","#94a3b8","#fbbf24","#f97316"],F=4,V=8,ye=2,X=6;function ve(t,l,r,s){const n=[];for(let o=0;o<t;o++){const i=o/t*Math.PI*2-Math.PI/2;n.push({x:l+Math.cos(i)*s,y:r+Math.sin(i)*s})}return n}function je(t,l,r){t.save(),t.strokeStyle="rgba(74, 222, 128, 0.03)",t.lineWidth=1;const s=40;for(let n=0;n<l;n+=s)t.beginPath(),t.moveTo(n,0),t.lineTo(n,r),t.stroke();for(let n=0;n<r;n+=s)t.beginPath(),t.moveTo(0,n),t.lineTo(l,n),t.stroke();t.restore()}function Se(t,l,r,s,n,o){t.save(),t.strokeStyle=o?"rgba(74, 222, 128, 0.18)":"rgba(74, 222, 128, 0.05)",t.lineWidth=o?1.5:1,t.setLineDash(o?[]:[4,4]),t.beginPath(),t.moveTo(l,r),t.lineTo(s,n),t.stroke(),t.restore()}function ke(t,l,r,s,n){if(t.save(),n){const a=t.createRadialGradient(l,r,F,l,r,V);a.addColorStop(0,"rgba(74, 222, 128, 0.30)"),a.addColorStop(1,"transparent"),t.fillStyle=a,t.beginPath(),t.arc(l,r,V,0,Math.PI*2),t.fill()}const o=s.status==="offline"&&!n;t.globalAlpha=o?.3:s.status==="recent"&&!n?.6:1,t.beginPath(),t.arc(l,r,F,0,Math.PI*2),t.fillStyle=n?"#0a1a0a":"#0f0f23",t.fill(),t.strokeStyle=n?"#4ade80":s.color,t.lineWidth=n?1.5:1,s.status==="recent"&&!n&&t.setLineDash([2,2]),t.stroke(),t.setLineDash([]);const i=s.status==="online"?"#10b981":s.status==="recent"?"#f59e0b":"#ef4444";if(t.beginPath(),t.arc(l+4,r-4,1.5,0,Math.PI*2),t.fillStyle=i,t.fill(),t.strokeStyle="#0a0f1a",t.lineWidth=.8,t.stroke(),s.status==="online"){const a=t.createRadialGradient(l+4,r-4,1.5,l+4,r-4,4);a.addColorStop(0,"rgba(16,185,129,0.3)"),a.addColorStop(1,"transparent"),t.fillStyle=a,t.beginPath(),t.arc(l+4,r-4,4,0,Math.PI*2),t.fill()}t.font="500 7px Inter, system-ui, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillStyle="#94a3b8",t.fillText(s.sublabel,l,r+F+7),n&&(t.font="600 6px JetBrains Mono, monospace",t.fillStyle="#4ade80",t.fillText("YOUR NODE",l,r+F+15)),t.globalAlpha=1,t.restore()}function we(t,l,r,s){const n=Q[s];t.save();const o=t.createRadialGradient(l,r,0,l,r,X);o.addColorStop(0,n+"aa"),o.addColorStop(.4,n+"44"),o.addColorStop(1,"transparent"),t.fillStyle=o,t.beginPath(),t.arc(l,r,X,0,Math.PI*2),t.fill(),t.fillStyle=n,t.beginPath(),t.arc(l,r,ye,0,Math.PI*2),t.fill(),t.fillStyle="#ffffff",t.beginPath(),t.arc(l,r,1.5,0,Math.PI*2),t.fill(),t.restore()}function Ce(t,l,r){const s=Object.entries(Q).map(([f,m])=>[f.charAt(0).toUpperCase()+f.slice(1),m]),n=10,o=16,i=90,a=n*2+s.length*o,h=l-i-12,S=r-a-12;t.save(),t.fillStyle="rgba(10, 15, 26, 0.85)",t.strokeStyle="rgba(74, 222, 128, 0.15)",t.lineWidth=1,t.beginPath(),t.roundRect(h,S,i,a,6),t.fill(),t.stroke(),t.font="500 9px Inter, system-ui, sans-serif",t.textAlign="left",t.textBaseline="middle",s.forEach(([f,m],k)=>{const v=S+n+k*o+o/2;t.fillStyle=m,t.beginPath(),t.arc(h+n+3,v,3.5,0,Math.PI*2),t.fill(),t.fillStyle="#94a3b8",t.fillText(f,h+n+12,v)}),t.restore()}const Re={publish:"publish",query:"query",workspace:"update",chat:"chat",connect:"access",enshrine:"publish",sync:"stake",access:"access"};function Pe({agents:t,nodeName:l}){const r=u.useRef(null),s=u.useRef(null),n=u.useRef([]),o=u.useRef(0),i=u.useRef(new Set),a=u.useRef(0),h=u.useRef(1),S=u.useRef({x:0,y:0}),f=u.useRef(!1),m=u.useRef({x:0,y:0,panX:0,panY:0}),k=300*1e3,v=1440*60*1e3;function N(d){if(d.connectionStatus==="self"||d.connectionStatus==="connected")return"online";if(d.lastSeen==null)return"offline";const p=Date.now()-d.lastSeen;return p<k?"online":p<v?"recent":"offline"}const c=t.length>0?t.map((d,p)=>{var j,x;const y=d.connectionStatus==="self",b=N(d);return{id:p,isYou:y,online:b!=="offline",status:b,label:y?"YOU":((j=d.name)==null?void 0:j.replace(/^devnet-/,""))||`P${p}`,sublabel:y?l||d.name||"my-node":d.name||((x=d.peerId)==null?void 0:x.slice(0,10))||`peer-${p}`,color:y?"#4ade80":Y[p%Y.length]}}):[{id:0,isYou:!0,online:!0,status:"online",label:"YOU",sublabel:l||"my-node",color:"#4ade80"}],w=u.useCallback(()=>{var q,K;const d=r.current;if(!d)return;const p=d.getContext("2d"),y=window.devicePixelRatio||1,b=d.width/y,j=d.height/y,x=b/2,C=j/2,z=c.length<=6?.52:c.length<=10?.58:.64,W=Math.min(x,C)*z;p.save(),p.scale(y,y),p.clearRect(0,0,b,j),p.fillStyle="#0a0f1a",p.fillRect(0,0,b,j),je(p,b,j),p.save();const B=h.current,M=S.current;p.translate(b/2+M.x,j/2+M.y),p.scale(B,B),p.translate(-b/2,-j/2);const R=ve(c.length,x,C,W),D=new Set;for(const g of n.current){const P=[Math.min(g.from,g.to),Math.max(g.from,g.to)].join("-");D.add(P)}const L=c.findIndex(g=>g.isYou),G=new Set;for(let g=0;g<c.length;g++){if(g===L)continue;const P=[Math.min(g,L),Math.max(g,L)].join("-");G.add(P);const I=(g+1)%c.length;if(I!==L){const O=[Math.min(g,I),Math.max(g,I)].join("-");G.add(O)}}for(const g of G){const[P,I]=g.split("-").map(Number);if(R[P]&&R[I]){const O=((q=c[P])==null?void 0:q.online)!==!1&&((K=c[I])==null?void 0:K.online)!==!1;p.globalAlpha=O?1:.15,Se(p,R[P].x,R[P].y,R[I].x,R[I].y,D.has(g))}}p.globalAlpha=1;for(const g of n.current){const P=R[g.from],I=R[g.to];if(!P||!I)continue;const O=g.progress<.5?2*g.progress*g.progress:1-Math.pow(-2*g.progress+2,2)/2;we(p,P.x+(I.x-P.x)*O,P.y+(I.y-P.y)*O,g.type)}for(let g=0;g<c.length;g++)ke(p,R[g].x,R[g].y,c[g],c[g].isYou);p.restore(),Ce(p,b,j),p.restore()},[t,l]);return u.useEffect(()=>{let d,p=!1;const y=c.findIndex(C=>C.isYou),b=c.map((C,z)=>z).filter(C=>C!==y),j=async()=>{if(p||c.length<2)return;const C=Date.now();if(!(C-a.current<3e3)){a.current=C;try{const z=C-1e4,W=await he({from:String(z),limit:"20"}),B=(W==null?void 0:W.operations)??[];for(const M of B){const R=M.operation_id??M.id;if(!R||i.current.has(R))continue;i.current.add(R);const D=Re[M.operation_name]??"query",L=b.length>0?b[Math.floor(Math.random()*b.length)]:0;n.current.push({id:o.current++,from:y>=0?y:0,to:L,progress:0,speed:.006+Math.random()*.004,type:D})}if(i.current.size>200){const M=Array.from(i.current);i.current=new Set(M.slice(-100))}}catch{}}},x=C=>{j(),n.current=n.current.map(z=>({...z,progress:z.progress+z.speed})).filter(z=>z.progress<=1),w(),d=requestAnimationFrame(x)};return d=requestAnimationFrame(x),()=>{p=!0,cancelAnimationFrame(d)}},[w]),u.useEffect(()=>{const d=r.current,p=s.current;if(!d||!p)return;const y=()=>{const j=window.devicePixelRatio||1,x=p.getBoundingClientRect();d.width=x.width*j,d.height=x.height*j,d.style.width=`${x.width}px`,d.style.height=`${x.height}px`};y();const b=new ResizeObserver(y);return b.observe(p),()=>b.disconnect()},[]),u.useEffect(()=>{const d=s.current;if(!d)return;const p=x=>{x.preventDefault();const C=x.deltaY>0?.9:1.1;h.current=Math.max(.3,Math.min(5,h.current*C))},y=x=>{f.current=!0,m.current={x:x.clientX,y:x.clientY,panX:S.current.x,panY:S.current.y},d.style.cursor="grabbing"},b=x=>{f.current&&(S.current={x:m.current.panX+(x.clientX-m.current.x),y:m.current.panY+(x.clientY-m.current.y)})},j=()=>{f.current=!1,d.style.cursor="grab"};return d.style.cursor="grab",d.addEventListener("wheel",p,{passive:!1}),d.addEventListener("mousedown",y),window.addEventListener("mousemove",b),window.addEventListener("mouseup",j),()=>{d.removeEventListener("wheel",p),d.removeEventListener("mousedown",y),window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",j)}},[]),e.jsx("div",{ref:s,style:{width:"100%",height:"100%"},children:e.jsx("canvas",{ref:r,style:{display:"block"}})})}const Ne=[{name:"OriginTrail Game",assets:847,agents:12,color:"var(--green)"},{name:"DeSci Research",assets:1203,agents:8,color:"var(--blue)"},{name:"Supply Chain EU",assets:797,agents:4,color:"var(--amber)"}],Ie={prepare:"Partitioning triples, computing Merkle hashes, validating & signing.",store:"Inserting triples into the local triple store and data graph.",chain:"Submitting on-chain tx and waiting for confirmation.",broadcast:"Broadcasting to network peers via GossipSub.",parse:"Validating and parsing the SPARQL query syntax.",execute:"Running the SPARQL query against the local triple store.",transfer:"Fetching triple pages from the remote peer.",verify:"Verifying Merkle proofs and inserting synced triples."},A={prepare:"#3b82f6","prepare:ensureParanet":"#60a5fa","prepare:partition":"#2563eb","prepare:manifest":"#93c5fd","prepare:validate":"#1d4ed8","prepare:merkle":"#7dd3fc",store:"#8b5cf6",chain:"#f59e0b","chain:sign":"#fbbf24","chain:submit":"#d97706","chain:metadata":"#f97316",broadcast:"#22c55e",decode:"#14b8a6",validate:"#2dd4bf","read-workspace":"#06b6d4",parse:"#3b82f6",execute:"#8b5cf6",transfer:"#60a5fa",verify:"#22c55e"},_="#a78bfa";function ze({phases:t,totalMs:l}){const[r,s]=u.useState(null);if(!(t!=null&&t.length)||l<=0)return e.jsx("div",{style:{flex:1,height:8,borderRadius:2,background:"rgba(255,255,255,.04)"}});const n=t.reduce((o,i)=>o+(i.duration_ms??0),0)||l;return e.jsxs("div",{style:{flex:1,position:"relative"},children:[e.jsx("div",{style:{display:"flex",height:8,borderRadius:2,overflow:"hidden",background:"rgba(255,255,255,.04)"},children:t.map((o,i)=>{const a=Math.max((o.duration_ms??0)/n*100,2),h=o.status==="error"?"#ef4444":A[o.phase]??_;return e.jsx("div",{onMouseEnter:()=>s(i),onMouseLeave:()=>s(null),style:{width:`${a}%`,background:h,minWidth:2,opacity:r===i?1:.7,transition:"opacity .15s",cursor:"default"}},`${o.phase}-${i}`)})}),r!==null&&t[r]&&(()=>{const o=t[r].phase,i=o.includes(":")?o.split(":")[0]:o,a=Ie[i];return e.jsxs("div",{style:{position:"absolute",bottom:"100%",left:"50%",transform:"translateX(-50%)",marginBottom:6,padding:"4px 8px",borderRadius:6,background:"var(--surface)",border:"1px solid var(--border)",boxShadow:"0 4px 12px rgba(0,0,0,.4)",fontSize:10,zIndex:10,pointerEvents:"none",maxWidth:240},children:[e.jsxs("div",{style:{whiteSpace:"nowrap"},children:[e.jsx("span",{style:{fontWeight:700,color:A[o]??_},children:o}),e.jsx("span",{style:{color:"var(--text-muted)",margin:"0 4px"},children:"·"}),e.jsx("span",{style:{fontFamily:"'JetBrains Mono', monospace",color:"var(--text)"},children:$(t[r].duration_ms)}),t[r].status==="error"&&e.jsx("span",{style:{color:"var(--red)",marginLeft:4,fontWeight:600},children:"FAIL"})]}),a&&e.jsx("div",{style:{fontSize:9,color:"var(--text-muted)",marginTop:2,whiteSpace:"normal",lineHeight:1.3},children:a})]})})()]})}function Me({operationId:t}){const{data:l,loading:r}=T(()=>ce(t),[t]);if(r)return e.jsx("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"},children:"Loading..."});if(!l)return null;const{operation:s,phases:n,logs:o}=l;if(!s)return null;const i=(o??[]).slice(-5);return e.jsxs("div",{style:{padding:"10px 12px",background:"rgba(255,255,255,.02)",borderTop:"1px solid var(--border)"},children:[e.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",marginBottom:8,fontSize:11},children:[e.jsxs("span",{style:{color:"var(--text-muted)"},children:["Status: ",e.jsx("strong",{style:{color:s.status==="error"?"var(--red)":"var(--green-mid)"},children:s.status})]}),e.jsxs("span",{style:{color:"var(--text-muted)"},children:["Duration: ",e.jsx("strong",{style:{fontFamily:"'JetBrains Mono', monospace"},children:$(s.duration_ms)})]}),s.error_message&&e.jsx("span",{style:{color:"var(--red)",fontSize:10},children:s.error_message})]}),(n==null?void 0:n.length)>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3,marginBottom:i.length?8:0},children:n.map((a,h)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:10},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:a.status==="error"?"var(--red)":A[a.phase]??_,flexShrink:0}}),e.jsx("span",{style:{color:A[a.phase]??_,fontWeight:600,minWidth:100},children:a.phase}),e.jsx("span",{className:"mono",style:{color:"var(--text-dim)"},children:$(a.duration_ms)}),a.status==="error"&&e.jsx("span",{style:{color:"var(--red)",fontWeight:600},children:"FAILED"})]},`${a.phase}-${h}`))}),i.length>0&&e.jsxs("div",{style:{borderTop:"1px solid var(--border)",paddingTop:6},children:[e.jsx("div",{style:{fontSize:9,color:"var(--text-dim)",marginBottom:4,fontWeight:600},children:"Recent logs"}),i.map((a,h)=>e.jsxs("div",{style:{fontSize:10,color:a.level==="error"?"var(--red)":a.level==="warn"?"var(--amber)":"var(--text-muted)",lineHeight:1.5,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["[",a.module,"] ",a.message]},h))]})]})}function Te(){const{data:t}=T(()=>se({limit:"8"}),[],1e4),l=J(),[r,s]=u.useState(null),n=(t==null?void 0:t.operations)??[],o=oe();return n.length===0?null:e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("div",{className:"section-title",style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{children:"Recent Operations"}),o&&e.jsx("button",{className:"dkg-btn dkg-btn-secondary",style:{fontSize:10,padding:"4px 10px"},onClick:()=>l("/settings?tab=observability"),children:"View All"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:n.map(i=>{const a=i.duration_ms??0,h=i.status==="error",S=i.phases??[],f=r===i.operation_id;return e.jsxs(ie.Fragment,{children:[e.jsxs("div",{onClick:()=>s(f?null:i.operation_id),style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",borderRadius:f?"8px 8px 0 0":8,background:f?"rgba(59,130,246,.06)":"var(--surface)",border:"1px solid var(--border)",borderBottom:f?"1px solid var(--border)":void 0,cursor:"pointer",transition:"border-color .15s, background .15s"},onMouseEnter:m=>{f||(m.currentTarget.style.borderColor="rgba(74,222,128,.3)")},onMouseLeave:m=>{f||(m.currentTarget.style.borderColor="var(--border)")},children:[e.jsx("span",{className:"mono",style:{fontSize:10,color:"var(--text-dim)",width:50,flexShrink:0},children:new Date(i.started_at).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}),e.jsx("span",{style:{fontSize:10,fontWeight:700,width:60,flexShrink:0,color:h?"var(--red)":"var(--green-mid)"},children:i.operation_name}),e.jsx(ze,{phases:S,totalMs:a}),e.jsx("span",{className:"mono",style:{fontSize:10,color:"var(--text-muted)",width:50,textAlign:"right",flexShrink:0},children:$(a)}),e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:h?"var(--red)":i.status==="in_progress"?"var(--amber)":"var(--green-mid)",flexShrink:0}})]}),f&&e.jsx("div",{style:{border:"1px solid var(--border)",borderTop:"none",borderRadius:"0 0 8px 8px",overflow:"hidden",marginTop:-4},children:e.jsx(Me,{operationId:i.operation_id})})]},i.operation_id)})})]})}function Ee(){const{data:t}=T(()=>ae(6048e5),[],3e4),l=((t==null?void 0:t.hotspots)??[]).slice(0,5);return l.length===0?e.jsx("div",{className:"paranet-card",style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:60},children:e.jsx("span",{style:{fontSize:11,color:"var(--green)",fontWeight:600},children:"No errors in 7 days"})}):e.jsxs("div",{className:"paranet-card",style:{padding:12},children:[e.jsx("div",{style:{fontSize:11,fontWeight:700,color:"var(--red)",marginBottom:6},children:"Error Hotspots (7d)"}),l.map((r,s)=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:11,padding:"3px 0",color:"var(--text-muted)"},children:[e.jsxs("span",{children:[e.jsx("span",{style:{color:"var(--text-dim)",fontSize:10},children:r.operation_name}),e.jsx("span",{style:{color:"var(--text-dim)",margin:"0 4px"},children:"›"}),e.jsx("span",{style:{color:A[r.phase]??_,fontWeight:500},children:r.phase})]}),e.jsx("span",{style:{color:"var(--red)",fontWeight:700},children:r.error_count})]},`${r.operation_name}-${r.phase}-${s}`))]})}function Le(){var s,n;const{data:t}=T(le,[],6e4),r=((t==null?void 0:t.periods)??[])[0];return r?e.jsxs("div",{className:"paranet-card",style:{padding:12},children:[e.jsxs("div",{style:{fontSize:11,fontWeight:700,color:"var(--amber)",marginBottom:6},children:["Spending (",r.label,")"]}),e.jsxs("div",{style:{display:"flex",gap:16,fontSize:11,color:"var(--text-muted)"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"mono",style:{fontSize:14,fontWeight:700,color:"var(--text)"},children:((s=r.totalGasEth)==null?void 0:s.toFixed(6))??"0"}),e.jsx(E,{text:"Ethereum gas fees for on-chain transactions",children:e.jsx("div",{children:"ETH gas"})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mono",style:{fontSize:14,fontWeight:700,color:"var(--text)"},children:((n=r.totalTrac)==null?void 0:n.toFixed(2))??"0"}),e.jsx(E,{text:"TRAC — the OriginTrail network token used for publishing and storing knowledge",children:e.jsx("div",{children:"TRAC"})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mono",style:{fontSize:14,fontWeight:700,color:"var(--text)"},children:r.publishCount??0}),e.jsx(E,{text:"Number of Knowledge Assets published on-chain",children:e.jsx("div",{children:"publishes"})})]})]})]}):null}function Be(){const t=J(),[l,r]=u.useState(!1),{data:s}=T(ee,[],1e4),{data:n}=T(te,[],1e4),{data:o}=T(Z,[],3e4),{data:i}=T(ne,[],15e3),a=u.useMemo(()=>{const c=["var(--green)","var(--blue)","var(--amber)","var(--purple)","#f472b6","#22d3ee"];return((o==null?void 0:o.paranets)??[]).map((w,d)=>({id:w.id??`paranet-${d}`,name:w.name??w.id??`Paranet ${d+1}`,assets:w.assetCount??w.assets??"—",agents:w.agentCount??w.agents??"—",color:c[d%c.length]}))},[o]),h=a.length>0?a:Ne,S=a.length>0,f=(s==null?void 0:s.connectedPeers)??(s==null?void 0:s.peerCount)??null,m=(n==null?void 0:n.total_kcs)??null,k=(n==null?void 0:n.confirmed_kcs)??null,v=(n==null?void 0:n.tentative_kcs)??null,N=(i==null?void 0:i.agents)!=null?i.agents.length:null;return e.jsxs("div",{className:"page-section",children:[e.jsx(be,{open:l,onClose:()=>r(!1)}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:24},children:[e.jsxs("div",{children:[e.jsx("h1",{className:"page-title",style:{marginBottom:0},children:"Dashboard"}),e.jsx("p",{style:{marginTop:4},children:s?`Your node is live${a.length?` and participating in ${a.length} paranet${a.length!==1?"s":""}`:""}`:"Loading node status…"})]}),e.jsxs("button",{className:"dkg-btn",onClick:()=>r(!0),children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Import Memories"]})]}),e.jsx("div",{style:{display:"flex",gap:12,marginBottom:24,flexWrap:"wrap"},children:[{label:e.jsxs(e.Fragment,{children:["Knowledge Collections ",e.jsx(H,{text:"Groups of knowledge triples stored on your node. Confirmed = finalized on-chain. Tentative = stored locally, pending blockchain finalization."})]}),value:k!=null&&v!=null?String(Number(k)+Number(v)):m!=null?Number(m).toLocaleString():"—",sub:k!=null&&v!=null?e.jsxs(e.Fragment,{children:[e.jsx(E,{text:"Finalized on-chain with a confirmed transaction",children:e.jsxs("span",{style:{color:"var(--green)"},children:[Number(k).toLocaleString()," confirmed"]})})," · ",e.jsx(E,{text:"Stored locally, pending blockchain finalization",children:e.jsxs("span",{style:{color:"var(--amber)"},children:[Number(v).toLocaleString()," tentative"]})})]}):m!=null?"from node metrics":"loading…",color:"var(--green)"},{label:e.jsxs(e.Fragment,{children:["Connected Peers ",e.jsx(H,{text:"Other DKG nodes your node has an active network connection with"})]}),value:f!=null?String(f):"—",sub:f!=null?"live":"loading…",color:"var(--blue)"},{label:e.jsxs(e.Fragment,{children:["Agents Discovered ",e.jsx(H,{text:"AI agents discovered across the paranets your node participates in"})]}),value:N!=null?String(N):"—",sub:`Across ${h.length} paranet${h.length!==1?"s":""}`,color:"var(--amber)"}].map((c,w)=>e.jsxs("div",{className:"stat-card",children:[e.jsx("div",{className:"accent",style:{background:`linear-gradient(90deg,${c.color}44,transparent)`}}),e.jsx("div",{className:"stat-label",children:c.label}),e.jsx("div",{className:"stat-value mono",children:c.value}),e.jsx("div",{className:"stat-sub",children:c.sub})]},w))}),e.jsxs("div",{style:{position:"relative",height:340,borderRadius:12,overflow:"hidden",background:"var(--bg)",border:"1px solid var(--border)",marginBottom:16},children:[e.jsxs("div",{style:{position:"absolute",top:14,left:18,zIndex:2,display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{className:"pulse-dot",style:{width:6,height:6,borderRadius:"50%",background:"var(--green)",boxShadow:"0 0 6px rgba(74,222,128,.53)",display:"inline-block"}}),e.jsx("span",{className:"mono",style:{fontSize:12,fontWeight:700},children:(s==null?void 0:s.networkName)??"DKG Network"}),e.jsx("span",{className:"mono",style:{fontSize:10,color:"var(--text-muted)"},children:f!=null?`${f} PEERS`:"… PEERS"}),e.jsx("span",{className:"mono",style:{fontSize:9,color:"var(--text-dim)",marginLeft:4},children:"scroll to zoom · drag to pan"})]}),e.jsx(Pe,{agents:(i==null?void 0:i.agents)??[],nodeName:(s==null?void 0:s.name)??""})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("div",{className:"section-title",children:["Paranets",!S&&e.jsx("span",{className:"mono",style:{fontSize:9,color:"var(--text-dim)",fontWeight:400},children:"DEMO"})]}),e.jsx("div",{className:"paranet-list",children:h.map((c,w)=>e.jsxs("div",{className:"paranet-card",onClick:()=>c.id&&t(`/explorer?paranet=${encodeURIComponent(c.id)}`),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[e.jsx("span",{style:{width:7,height:7,borderRadius:3,background:c.color,display:"inline-block"}}),e.jsx("h3",{style:{fontSize:13,fontWeight:600,margin:0},children:c.name}),e.jsx("span",{className:"pulse-dot",style:{width:5,height:5,borderRadius:"50%",background:"var(--green)",display:"inline-block",marginLeft:"auto"}})]}),e.jsxs("div",{className:"mono",style:{display:"flex",gap:14,fontSize:10,color:"var(--text-muted)"},children:[e.jsx(E,{text:"Knowledge Assets published to this paranet",children:e.jsxs("span",{children:[c.assets.toLocaleString()," assets"]})}),e.jsxs("span",{children:[c.agents," agents"]})]})]},c.id??`fallback-${w}`))})]}),e.jsx(Te,{}),e.jsxs("div",{className:"dashboard-grid-2",children:[e.jsx(Ee,{}),e.jsx(Le,{})]}),e.jsx("div",{className:"quick-actions",style:{marginBottom:16},children:[{label:"Query the Graph",desc:"SPARQL queries",icon:"⌘",onClick:()=>t("/explorer/sparql")},{label:"Import Memories",desc:"From Claude / ChatGPT",icon:"📥",onClick:()=>r(!0)},{label:"Play OriginTrail",desc:"Test your node",icon:"🎮",onClick:()=>t("/apps")}].map(c=>e.jsxs("button",{className:"quick-action",onClick:c.onClick,children:[e.jsx("span",{style:{fontSize:16},children:c.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"qa-label",children:c.label}),e.jsx("div",{className:"qa-desc",children:c.desc})]})]},c.label))})]})}export{Be as DashboardPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as g,N as Cs,m as pa,n as Nt,o as As,f as So,r as P,p as ga,q as Bt,s as ma,u as xa}from"./index-
|
|
1
|
+
import{j as g,N as Cs,m as pa,n as Nt,o as As,f as So,r as P,p as ga,q as Bt,s as ma,u as xa}from"./index-BKmDUHkm.js";import{u as vo,s as ya}from"./hooks-CL5p8QP2.js";import{R as Co,u as ba}from"./index-CjNfRG2Z.js";import"./ordinal-DIohFSkg.js";let Ys=[],Ao=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<n.length;e++)(e%2?Ao:Ys).push(t=t+n[e])})();function ka(n){if(n<768)return!1;for(let e=0,t=Ys.length;;){let i=e+t>>1;if(n<Ys[i])t=i;else if(n>=Ao[i])e=i+1;else return!0;if(e==t)return!1}}function or(n){return n>=127462&&n<=127487}const lr=8205;function wa(n,e,t=!0,i=!0){return(t?Oo:Sa)(n,e,i)}function Oo(n,e,t){if(e==n.length)return e;e&&To(n.charCodeAt(e))&&Mo(n.charCodeAt(e-1))&&e--;let i=Os(n,e);for(e+=ar(i);e<n.length;){let s=Os(n,e);if(i==lr||s==lr||t&&ka(s))e+=ar(s),i=s;else if(or(s)){let r=0,o=e-2;for(;o>=0&&or(Os(n,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function Sa(n,e,t){for(;e>0;){let i=Oo(n,e-2,t);if(i<e)return i;e--}return 0}function Os(n,e){let t=n.charCodeAt(e);if(!Mo(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return To(i)?(t-55296<<10)+(i-56320)+65536:t}function To(n){return n>=56320&&n<57344}function Mo(n){return n>=55296&&n<56320}function ar(n){return n<65536?1:2}class Q{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=zt(this,e,t);let s=[];return this.decompose(0,e,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(t,this.length,s,1),qe.from(s,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=zt(this,e,t);let i=[];return this.decompose(e,t,i,0),qe.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),s=new si(this),r=new si(e);for(let o=t,l=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(l+=s.value.length,s.done||l>=i)return!0}}iter(e=1){return new si(this,e)}iterRange(e,t=this.length){return new Ro(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;i=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Po(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Q.empty:e.length<=32?new re(e):qe.from(re.split(e,[]))}}class re extends Q{constructor(e,t=va(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.text[r],l=s+o.length;if((t?i:l)>=e)return new Ca(s,l,i,o);s=l+1,i++}}decompose(e,t,i,s){let r=e<=0&&t>=this.length?this:new re(hr(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=i.pop(),l=zi(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new re(l,o.length+r.length));else{let a=l.length>>1;i.push(new re(l.slice(0,a)),new re(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof re))return super.replace(e,t,i);[e,t]=zt(this,e,t);let s=zi(this.text,zi(i.text,hr(this.text,0,e)),t),r=this.length+i.length-(t-e);return s.length<=32?new re(s,r):qe.from(re.split(s,[]),r)}sliceString(e,t=this.length,i=`
|
|
2
2
|
`){[e,t]=zt(this,e,t);let s="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let l=this.text[o],a=r+l.length;r>e&&o&&(s+=i),e<a&&t>r&&(s+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],s=-1;for(let r of e)i.push(r),s+=r.length+1,i.length==32&&(t.push(new re(i,s)),i=[],s=-1);return s>-1&&t.push(new re(i,s)),t}}class qe extends Q{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.children[r],l=s+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,s);s=l+1,i=a+1}}decompose(e,t,i,s){for(let r=0,o=0;o<=t&&r<this.children.length;r++){let l=this.children[r],a=o+l.length;if(e<=a&&t>=o){let h=s&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if([e,t]=zt(this,e,t),i.lines<this.lines)for(let s=0,r=0;s<this.children.length;s++){let o=this.children[s],l=r+o.length;if(e>=r&&t<=l){let a=o.replace(e-r,t-r,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[s]=a,new qe(c,this.length-(t-e)+i.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
|
|
3
3
|
`){[e,t]=zt(this,e,t);let s="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let l=this.children[r],a=o+l.length;o>e&&r&&(s+=i),e<a&&t>o&&(s+=l.sliceString(e-o,t-o,i)),o=a+1}return s}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof qe))return 0;let i=0,[s,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=t,r+=t){if(s==o||r==l)return i;let a=this.children[s],h=e.children[r];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,s)=>i+s.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new re(d,t)}let s=Math.max(32,i>>5),r=s<<1,o=s>>1,l=[],a=0,h=-1,c=[];function f(d){let p;if(d.lines>r&&d instanceof qe)for(let m of d.children)f(m);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof re&&a&&(p=c[c.length-1])instanceof re&&d.lines+p.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new re(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>s&&u(),a+=d.lines,h+=d.length+1,c.push(d))}function u(){a!=0&&(l.push(c.length==1?c[0]:qe.from(c,h)),h=-1,a=c.length=0)}for(let d of e)f(d);return u(),l.length==1?l[0]:new qe(l,t)}}Q.empty=new re([""],0);function va(n){let e=-1;for(let t of n)e+=t.length+1;return e}function zi(n,e,t=0,i=1e9){for(let s=0,r=0,o=!0;r<n.length&&s<=i;r++){let l=n[r],a=s+l.length;a>=t&&(a>i&&(l=l.slice(0,i-s)),s<t&&(l=l.slice(t-s)),o?(e[e.length-1]+=l,o=!1):e.push(l)),s=a+1}return e}function hr(n,e,t){return zi(n,[""],e,t)}class si{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof re?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,s=this.nodes[i],r=this.offsets[i],o=r>>1,l=s instanceof re?s.text.length:s.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
4
4
|
`,this;e--}else if(s instanceof re){let a=s.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=s.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof re?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Ro{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new si(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=i?s:t<0?s.slice(s.length-i):s.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Po{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:s}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Q.prototype[Symbol.iterator]=function(){return this.iter()},si.prototype[Symbol.iterator]=Ro.prototype[Symbol.iterator]=Po.prototype[Symbol.iterator]=function(){return this});class Ca{constructor(e,t,i,s){this.from=e,this.to=t,this.number=i,this.text=s}get length(){return this.to-this.from}}function zt(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function Ue(n,e,t=!0,i=!0){return wa(n,e,t,i)}function Aa(n){return n>=56320&&n<57344}function Oa(n){return n>=55296&&n<56320}function Ta(n,e){let t=n.charCodeAt(e);if(!Oa(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return Aa(i)?(t-55296<<10)+(i-56320)+65536:t}function Ma(n){return n<65536?1:2}const Zs=/\r\n?|\n/;var Pe=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(Pe||(Pe={}));class Je{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,s=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(i,s,r),s+=r):s+=o,i+=r}}iterChangedRanges(e,t=!1){Js(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];s<0?e.push(i,s):e.push(s,i)}return new Je(e)}composeDesc(e){return this.empty?e:e.empty?this:No(this,e)}mapDesc(e,t=!1){return e.empty?this:en(this,e,t)}mapPos(e,t=-1,i=Pe.Simple){let s=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=s+l;if(a<0){if(h>e)return r+(e-s);r+=l}else{if(i!=Pe.Simple&&h>=e&&(i==Pe.TrackDel&&s<e&&h>e||i==Pe.TrackBefore&&s<e||i==Pe.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==s||t<0?r:r+a;r+=a}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let i=0,s=0;i<this.sections.length&&s<=t;){let r=this.sections[i++],o=this.sections[i++],l=s+r;if(o>=0&&s<=t&&l>=e)return s<e&&l>t?"cover":!0;s=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];e+=(e?" ":"")+i+(s>=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Je(e)}static create(e){return new Je(e)}}class de extends Je{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Js(this,(t,i,s,r,o)=>e=e.replace(s,s+(i-t),o),!1),e}mapDesc(e,t=!1){return en(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let s=0,r=0;s<t.length;s+=2){let o=t[s],l=t[s+1];if(l>=0){t[s]=l,t[s+1]=o;let a=s>>1;for(;i.length<a;)i.push(Q.empty);i.push(o?e.slice(r,r+o):Q.empty)}r+=o}return new de(t,i)}compose(e){return this.empty?e:e.empty?this:No(this,e,!0)}map(e,t=!1){return e.empty?this:en(this,e,t,!0)}iterChanges(e,t=!1){Js(this,e,t)}get desc(){return Je.create(this.sections)}filter(e){let t=[],i=[],s=[],r=new hi(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break e;let c=Math.min(r.len,a-l);ye(s,c,-1);let f=r.ins==-1?-1:r.off==0?r.ins:0;ye(t,c,f),f>0&&at(i,t,r.text),r.forward(c),l+=c}let h=e[o++];for(;l<h;){if(r.done)break e;let c=Math.min(r.len,h-l);ye(t,c,-1),ye(s,c,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(c),l+=c}}return{changes:new de(t,i),filtered:Je.create(s)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],s=this.sections[t+1];s<0?e.push(i):s==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let s=[],r=[],o=0,l=null;function a(c=!1){if(!c&&!s.length)return;o<t&&ye(s,t-o,-1);let f=new de(s,r);l=l?l.compose(f.map(l)):f,s=[],r=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof de){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:d}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let p=d?typeof d=="string"?Q.of(d.split(i||Zs)):d:Q.empty,m=p.length;if(f==u&&m==0)return;f<o&&a(),f>o&&ye(s,f-o,-1),ye(s,u-f,m),at(r,s,p),o=u}}return h(e),a(!l),l}static empty(e){return new de(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let s=0;s<e.length;s++){let r=e[s];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length<s;)i.push(Q.empty);i[s]=Q.of(r.slice(1)),t.push(r[0],i[s].length)}}}return new de(t,i)}static createSet(e,t){return new de(e,t)}}function ye(n,e,t,i=!1){if(e==0&&t<=0)return;let s=n.length-2;s>=0&&t<=0&&t==n[s+1]?n[s]+=e:s>=0&&e==0&&n[s]==0?n[s+1]+=t:i?(n[s]+=e,n[s+1]+=t):n.push(e,t)}function at(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(Q.empty);n.push(t)}}function Js(n,e,t){let i=n.inserted;for(let s=0,r=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)s+=l,r+=l;else{let h=s,c=r,f=Q.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(s,h,r,c,f),s=h,r=c}}}function en(n,e,t,i=!1){let s=[],r=i?[]:null,o=new hi(n),l=new hi(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);ye(s,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(ye(s,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(ye(s,0,o.ins),r&&at(r,s,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;ye(s,h,a<o.i?o.ins:0),r&&a<o.i&&at(r,s,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return r?de.createSet(s,r):Je.create(s);throw new Error("Mismatched change set lengths")}}}function No(n,e,t=!1){let i=[],s=t?[]:null,r=new hi(n),o=new hi(e);for(let l=!1;;){if(r.done&&o.done)return s?de.createSet(i,s):Je.create(i);if(r.ins==0)ye(i,r.len,0,l),r.next();else if(o.len==0&&!o.done)ye(i,0,o.ins,l),s&&at(s,i,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),h=i.length;if(r.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;ye(i,a,c,l),s&&c&&at(s,i,o.text)}else o.ins==-1?(ye(i,r.off?0:r.len,a,l),s&&at(s,i,r.textBit(a))):(ye(i,r.off?0:r.len,o.off?0:o.ins,l),s&&!o.off&&at(s,i,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),r.forward2(a),o.forward(a)}}}}class hi{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Q.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?Q.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class St{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,s;return this.empty?i=s=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new St(i,s,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return M.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return M.range(this.anchor,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return M.range(e.anchor,e.head)}static create(e,t,i){return new St(e,t,i)}}class M{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:M.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new M([this.main],0)}addRange(e,t=!0){return M.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,M.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new M(e.ranges.map(t=>St.fromJSON(t)),e.main)}static single(e,t=e){return new M([M.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,s=0;s<e.length;s++){let r=e[s];if(r.empty?r.from<=i:r.from<i)return M.normalized(e.slice(),t);i=r.to}return new M(e,t)}static cursor(e,t=0,i,s){return St.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(s??16777215)<<6)}static range(e,t,i,s){let r=(i??16777215)<<6|(s==null?7:Math.min(6,s));return t<e?St.create(t,e,48|r):St.create(e,t,(t>e?8:0)|r)}static normalized(e,t=0){let i=e[t];e.sort((s,r)=>s.from-r.from),t=e.indexOf(i);for(let s=1;s<e.length;s++){let r=e[s],o=e[s-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);s<=t&&t--,e.splice(--s,2,r.anchor>r.head?M.range(a,l):M.range(l,a))}}return new M(e,t)}}function Eo(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let Fn=0;class L{constructor(e,t,i,s,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=s,this.id=Fn++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new L(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Hn),!!e.static,e.enables)}of(e){return new Vi([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Vi(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Vi(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function Hn(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class Vi{constructor(e,t,i,s){this.dependencies=e,this.facet=t,this.type=i,this.value=s,this.id=Fn++}dynamicSlot(e){var t;let i=this.value,s=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:(((t=e[f.id])!==null&&t!==void 0?t:1)&1)==0&&c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||tn(f,c)){let d=i(f);if(l?!cr(d,f.values[o],s):!s(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,p=u.config.address[r];if(p!=null){let m=_i(u,p);if(this.dependencies.every(x=>x instanceof L?u.facet(x)===f.facet(x):x instanceof Rt?u.field(x,!1)==f.field(x,!1):!0)||(l?cr(d=i(f),m,s):s(d=i(f),m)))return f.values[o]=m,0}else d=i(f);return f.values[o]=d,1}}}}function cr(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function tn(n,e){let t=!1;for(let i of e)ni(n,i)&1&&(t=!0);return t}function Ra(n,e,t){let i=t.map(a=>n[a.id]),s=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=_i(a,i[c]);if(s[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)ni(a,h);return a.values[o]=l(a),1},update(a,h){if(!tn(a,r))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=tn(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&Hn(t,f))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}const Ai=L.define({static:!0});class Rt{constructor(e,t,i,s,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=s,this.spec=r,this.provides=void 0}static define(e){let t=new Rt(Fn++,e.create,e.update,e.compare||((i,s)=>i===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Ai).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,s)=>{let r=i.values[t],o=this.updateF(r,s);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,s)=>{let r=i.facet(Ai),o=s.facet(Ai),l;return(l=r.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):s.config.address[this.id]!=null?(i.values[t]=s.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,Ai.of({field:this,create:e})]}get extension(){return this}}const kt={lowest:4,low:3,default:2,high:1,highest:0};function _t(n){return e=>new Do(e,n)}const gs={highest:_t(kt.highest),high:_t(kt.high),default:_t(kt.default),low:_t(kt.low),lowest:_t(kt.lowest)};class Do{constructor(e,t){this.inner=e,this.prec=t}}class ms{of(e){return new sn(this,e)}reconfigure(e){return ms.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class sn{constructor(e,t){this.compartment=e,this.inner=t}}class Gi{constructor(e,t,i,s,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=s,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let s=[],r=Object.create(null),o=new Map;for(let u of Pa(e,t,o))u instanceof Rt?s.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of s)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=i==null?void 0:i.config.facets;for(let u in r){let d=r[u],p=d[0].facet,m=c&&c[u]||[];if(d.every(x=>x.type==0))if(l[p.id]=a.length<<1|1,Hn(m,d))a.push(i.facet(p));else{let x=p.combine(d.map(y=>y.value));a.push(i&&p.compare(x,i.facet(p))?i.facet(p):x)}else{for(let x of d)x.type==0?(l[x.id]=a.length<<1|1,a.push(x.value)):(l[x.id]=h.length<<1,h.push(y=>x.dynamicSlot(y)));l[p.id]=h.length<<1,h.push(x=>Ra(x,p,d))}}let f=h.map(u=>u(l));return new Gi(e,o,f,l,a,r)}}function Pa(n,e,t){let i=[[],[],[],[],[]],s=new Map;function r(o,l){let a=s.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof sn&&t.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let h of o)r(h,l);else if(o instanceof sn){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),r(h,l)}else if(o instanceof Do)r(o.inner,o.prec);else if(o instanceof Rt)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof Vi)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,kt.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(h,l)}}return r(n,kt.default),i.reduce((o,l)=>o.concat(l))}function ni(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let s=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|s}function _i(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const Lo=L.define(),nn=L.define({combine:n=>n.some(e=>e),static:!0}),Bo=L.define({combine:n=>n.length?n[0]:void 0,static:!0}),Io=L.define(),jo=L.define(),Wo=L.define(),Fo=L.define({combine:n=>n.length?n[0]:!1});class Gt{constructor(e,t){this.type=e,this.value=t}static define(){return new Na}}class Na{of(e){return new Gt(this,e)}}class Ea{constructor(e){this.map=e}of(e){return new ue(this,e)}}class ue{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new ue(this.type,t)}is(e){return this.type==e}static define(e={}){return new Ea(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let s of e){let r=s.map(t);r&&i.push(r)}return i}}ue.reconfigure=ue.define();ue.appendConfig=ue.define();class be{constructor(e,t,i,s,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=s,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Eo(i,t.newLength),r.some(l=>l.type==be.time)||(this.annotations=r.concat(be.time.of(Date.now())))}static create(e,t,i,s,r,o){return new be(e,t,i,s,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(be.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}be.time=Gt.define();be.userEvent=Gt.define();be.addToHistory=Gt.define();be.remote=Gt.define();function Da(n,e){let t=[];for(let i=0,s=0;;){let r,o;if(i<n.length&&(s==e.length||e[s]>=n[i]))r=n[i++],o=n[i++];else if(s<e.length)r=e[s++],o=e[s++];else return t;!t.length||t[t.length-1]<r?t.push(r,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function Ho(n,e,t){var i;let s,r,o;return t?(s=e.changes,r=de.empty(e.changes.length),o=n.changes.compose(e.changes)):(s=e.changes.map(n.changes),r=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):(i=n.selection)===null||i===void 0?void 0:i.map(s),effects:ue.mapEffects(n.effects,s).concat(ue.mapEffects(e.effects,r)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function rn(n,e,t){let i=e.selection,s=It(e.annotations);return e.userEvent&&(s=s.concat(be.userEvent.of(e.userEvent))),{changes:e.changes instanceof de?e.changes:de.of(e.changes||[],t,n.facet(Bo)),selection:i&&(i instanceof M?i:M.single(i.anchor,i.head)),effects:It(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function zo(n,e,t){let i=rn(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(t=!1);let o=!!e[r].sequential;i=Ho(i,rn(n,e[r],o?i.changes.newLength:n.doc.length),o)}let s=be.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return Ba(t?La(s):s)}function La(n){let e=n.startState,t=!0;for(let s of e.facet(Io)){let r=s(n);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:Da(t,r))}if(t!==!0){let s,r;if(t===!1)r=n.changes.invertedDesc,s=de.empty(e.doc.length);else{let o=n.changes.filter(t);s=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}n=be.create(e,s,n.selection&&n.selection.map(r),ue.mapEffects(n.effects,r),n.annotations,n.scrollIntoView)}let i=e.facet(jo);for(let s=i.length-1;s>=0;s--){let r=i[s](n);r instanceof be?n=r:Array.isArray(r)&&r.length==1&&r[0]instanceof be?n=r[0]:n=zo(e,It(r),!1)}return n}function Ba(n){let e=n.startState,t=e.facet(Wo),i=n;for(let s=t.length-1;s>=0;s--){let r=t[s](n);r&&Object.keys(r).length&&(i=Ho(i,rn(e,r,n.changes.newLength),!0))}return i==n?n:be.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const Ia=[];function It(n){return n==null?Ia:Array.isArray(n)?n:[n]}var Ze=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(Ze||(Ze={}));const ja=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let on;try{on=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Wa(n){if(on)return on.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||ja.test(t)))return!0}return!1}function Fa(n){return e=>{if(!/\S/.test(e))return Ze.Space;if(Wa(e))return Ze.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return Ze.Word;return Ze.Other}}class U{constructor(e,t,i,s,r,o){this.config=e,this.doc=t,this.selection=i,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)ni(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return ni(this,i),_i(this,i)}update(...e){return zo(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:s}=t;for(let l of e.effects)l.is(ms.reconfigure)?(t&&(s=new Map,t.compartments.forEach((a,h)=>s.set(h,a)),t=null),s.set(l.value.compartment,l.value.extension)):l.is(ue.reconfigure)?(t=null,i=l.value):l.is(ue.appendConfig)&&(t=null,i=It(i).concat(l.value));let r;t?r=e.startState.values.slice():(t=Gi.resolve(i,s,this),r=new U(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(nn)?e.newSelection:e.newSelection.asSingle();new U(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:M.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),s=this.changes(i.changes),r=[i.range],o=It(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(s);for(let u=0;u<l;u++)r[u]=r[u].map(c);let f=s.mapDesc(h,!0);r.push(a.range.map(f)),s=s.compose(c),o=ue.mapEffects(o,c).concat(ue.mapEffects(It(a.effects),f))}return{changes:s,selection:M.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof de?e:de.of(e,this.doc.length,this.facet(U.lineSeparator))}toText(e){return Q.of(e.split(this.facet(U.lineSeparator)||Zs))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(ni(this,t),_i(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let s=e[i];s instanceof Rt&&this.config.address[s.id]!=null&&(t[i]=s.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let s=[];if(i){for(let r in i)if(Object.prototype.hasOwnProperty.call(e,r)){let o=i[r],l=e[r];s.push(o.init(a=>o.spec.fromJSON(l,a)))}}return U.create({doc:e.doc,selection:M.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=Gi.resolve(e.extensions||[],new Map),i=e.doc instanceof Q?e.doc:Q.of((e.doc||"").split(t.staticFacet(U.lineSeparator)||Zs)),s=e.selection?e.selection instanceof M?e.selection:M.single(e.selection.anchor,e.selection.head):M.single(0);return Eo(s,i.length),t.staticFacet(nn)||(s=s.asSingle()),new U(t,i,s,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(U.tabSize)}get lineBreak(){return this.facet(U.lineSeparator)||`
|