vendor: 4,462 bytes, line 1
1import{aR as Pn,b7 as ti,aZ as tt,b3 as Je,b2 as ps,aY as ht,aO as Mt,b6 as si,b1 as Mn,E as ni,aL as fs,aK as ct,aV as fe,aM as ai,aN as ii,aS as Oe,b0 as qt,a$ as ri,aU as ot,aW as qe,aQ as oi,a_ as x,aT as e,aX as de,W as li,y as _n,z as ci,P as xs,e as di,x as At,av as _e,D as xe,aw as He,ar as Te,d as Fe,c as Nt,f as ke,aB as ui,J as hi,aI as gs,$ as mi,r as pi,aF as J,X as Qe,az as Ge,af as Us,ax as Hs,aE as Y,ah as fi,ab as Tn,Z as Pe,a0 as xi,a8 as gi,i as _t,G as ne,at as Me,aC as Tt,aG as St,K as Ct,a7 as ji,aA as yi,p as be,a as Et,a1 as bi,ag as vi,q as wi,ao as ki,S as Ni,ak as Si,j as Ci,A as Pi,b as Mi,a6 as _i,t as Ti,Y as js,ap as Ei,H as Ri,aa as Ai,aH as Ii,an as Di,ai as Li,n as $i,ae as En,R as zi,a3 as Oi,_ as Rn,aj as An,aP as Fi,h as Bi,b4 as mt,F as It,O as In,aq as st,w as Xe,aD as Dn,am as Wi,al as he,a5 as Ui,U as Hi,g as pe,a9 as qi,a2 as Ee,V as oe,k as We,l as Ze,Q as Ln,s as $n,aJ as Ki,ay as Gi,B as zn,ac as Ue,u as Vi,b5 as Qi,T as ge,N as On,m as me,I as pt,M as nt,L as qs,au as Fn,a4 as Ks,as as Yi,v as Ji,o as Xi,C as Zi,ad as er}from"./react-1BiklAXe.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))a(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&a(r)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function a(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();function Gs(t,s){const n=String(t);if(typeof s!="string")throw new TypeError("Expected character");let a=0,i=n.indexOf(s);for(;i!==-1;)a++,i=n.indexOf(s,i+s.length);return a}function tr(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function sr(t,s,n){const i=Pn((n||{}).ignore||[]),o=nr(s);let r=-1;for(;++r<o.length;)ti(t,"text",d);function d(c,u){let h=-1,p;for(;++h<u.length;){const g=u[h],j=p?p.children:void 0;if(i(g,j?j.indexOf(g):void 0,p))return;p=g}if(p)return l(c,u)}function l(c,u){const h=u[u.length-1],p=o[r][0],g=o[r][1];let j=0;const b=h.children.indexOf(c);let y=!1,w=[];p.lastIndex=0;let v=p.exec(c.value);for(;v;){const S=v.index,T={index:v.index,input:v.input,stack:[...u,c]};let k=g(...v,T);if(typeof k=="string"&&(k=k.length>0?{type:"text",value:k}:void 0),k===!1?p.lastIndex=S+1:(j!==S&&w.push({type:"text",value:c.value.slice(j,S)}),Array.isArray(k)?w.push(...k):k&&w.push(k),j=S+v[0].length,y=!0),!p.global)break;v=p.exec(c.value)}return y?(j<c.value.length&&w.push({type:"text",value:c.value.slice(j)}),h.children.splice(b,1,...w)):w=[c],b+w.length}}function nr(t){const s=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!t[0]||Array.isArray(t[0])?t:[t];let a=-1;for(;++a<n.length;){const i=n[a];s.push([ar(i[0]),ir(i[1])])}return s}function ar(t){return typeof t=="string"?new RegExp(tr(t),"g"):t}function ir(t){return typeof t=="function"?t:function(){return t}}const Kt="phrasing",Gt=["autolink","link","image","label"];function rr(){return{transforms:[mr],enter:{literalAutolink:lr,literalAutolinkEmail:Vt,literalAutolinkHttp:Vt,literalAutolinkWww:Vt},exit:{literalAutolink:hr,literalAutolinkEmail:ur,literalAutolinkHttp:cr,literalAutolinkWww:dr}}}function or(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Kt,notInConstruct:Gt},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Kt,notInConstruct:Gt},{character:":",before:"[ps]",after:"\\/",inConstruct:Kt,notInConstruct:Gt}]}}function lr(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function Vt(t){this.config.enter.autolinkProtocol.call(this,t)}function cr(t){this.config.exit.autolinkProtocol.call(this,t)}function dr(t){this.config.exit.data.call(this,t);const s=this.stack[this.stack.length-1];tt(s.type==="link"),s.url="http://"+this.sliceSerialize(t)}function ur(t){this.config.exit.autolinkEmail.call(this,t)}function hr(t){this.exit(t)}function mr(t){sr(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,pr],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S}
1)([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),fr]],{ignore:["link","linkReference"]})}function pr(t,s,n,a,i){let o="";if(!Bn(i)||(/^w/i.test(s)&&(n=s+n,s="",o="http://"),!xr(n)))return!1;const r=gr(n+a);if(!r[0])return!1;const d={type:"link",title:null,url:o+s+r[0],children:[{type:"text",value:s+r[0]}]};return r[1]?[d,{type:"text",value:r[1]}]:d}function fr(t,s,n,a){return!Bn(a,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+s+"@"+n,children:[{type:"text",value:s+"@"+n}]}}function xr(t){const s=t.split(".");return!(s.length<2||s[s.length-1]&&(/_/.test(s[s.length-1])||!/[a-zA-Z\d]/.test(s[s.length-1]))||s[s.length-2]&&(/_/.test(s[s.length-2])||!/[a-zA-Z\d]/.test(s[s.length-2])))}function gr(t){const s=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!s)return[t,void 0];t=t.slice(0,s.index);let n=s[0],a=n.indexOf(")");const i=Gs(t,"(");let o=Gs(t,")");for(;a!==-1&&i>o;)t+=n.slice(0,a+1),n=n.slice(a+1),a=n.indexOf(")"),o++;return[t,n]}function Bn(t,s){const n=t.input.charCodeAt(t.index-1);return(t.index===0||Je(n)||ps(n))&&(!s||n!==47)}Wn.peek=Cr;function jr(){this.buffer()}function yr(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function br(){this.buffer()}function vr(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function wr(t){const s=this.resume(),n=this.stack[this.stack.length-1];tt(n.type==="footnoteReference"),n.identifier=ht(this.sliceSerialize(t)).toLowerCase(),n.label=s}function kr(t){this.exit(t)}function Nr(t){const s=this.resume(),n=this.stack[this.stack.length-1];tt(n.type==="footnoteDefinition"),n.identifier=ht(this.sliceSerialize(t)).toLowerCase(),n.label=s}function Sr(t){this.exit(t)}function Cr(){return"["}function Wn(t,s,n,a){const i=n.createTracker(a);let o=i.move("[^");const r=n.enter("footnoteReference"),d=n.enter("reference");return o+=i.move(n.safe(n.associationId(t),{after:"]",before:o})),d(),r(),o+=i.move("]"),o}function Pr(){return{enter:{gfmFootnoteCallString:jr,gfmFootnoteCall:yr,gfmFootnoteDefinitionLabelString:br,gfmFootnoteDefinition:vr},exit:{gfmFootnoteCallString:wr,gfmFootnoteCall:kr,gfmFootnoteDefinitionLabelString:Nr,gfmFootnoteDefinition:Sr}}}function Mr(t){let s=!1;return t&&t.firstLineBlank&&(s=!0),{handlers:{footnoteDefinition:n,footnoteReference:Wn},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(a,i,o,r){const d=o.createTracker(r);let l=d.move("[^");const c=o.enter("footnoteDefinition"),u=o.enter("label");return l+=d.move(o.safe(o.associationId(a),{before:l,after:"]"})),u(),l+=d.move("]:"),a.children&&a.children.length>0&&(d.shift(4),l+=d.move((s?` 2`:" ")+o.indentLines(o.containerFlow(a,d.current()),s?Un:_r))),c(),l}}function _r(t,s,n){return s===0?t:Un(t,s,n)}function Un(t,s,n){return(n?"":" ")+t}const Tr=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Hn.peek=Dr;function Er(){return{canContainEols:["delete"],enter:{strikethrough:Ar},exit:{strikethrough:Ir}}}function Rr(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Tr}],handlers:{delete:Hn}}}function Ar(t){this.enter({type:"delete",children:[]},t)}function Ir(t){this.exit(t)}function Hn(t,s,n,a){const i=n.createTracker(a),o=n.enter("strikethrough");let r=i.move("~~");return r+=n.containerPhrasing(t,{...i.current(),before:r,after:"~"}),r+=i.move("~~"),o(),r}function Dr(){return"~"}function Lr(t){return t.length}function $r(t,s){const n=s||{},a=(n.align||[]).concat(),i=n.stringLength||Lr,o=[],r=[],d=[],l=[];let c=0,u=-1;for(;++u<t.length;){const f=[],b=[];let y=-1;for(t[u].length>c&&(c=t[u].length);++y<t[u].length;){const w=zr(t[u][y]);if(n.alignDelimiters!==!1){const v=i(w);b[y]=v,(l[y]===void 0||v>l[y])&&(l[y]=v)}f.push(w)}r[u]=f,d[u]=b}let h=-1;if(typeof a=="object"&&"length"in a)for(;++h<c;)o[h]=Vs(a[h]);else{const f=Vs(a);for(;++h<c;)o[h]=f}h=-1;const p=[],g=[];for(;++h<c;){const f=o[h];let b="",y="";f===99?(b=":",y=":"):f===108?b=":":f===114&&(y=":");let w=n.alignDelimiters===!1?1:Math.max(1,l[h]-b.length-y.length);const v=b+"-".repeat(w)+y;n.alignDelimiters!==!1&&(w=b.length+w+y.length,w>l[h]&&(l[h]=w),g[h]=w),p[h]=v}r.splice(1,0,p),d.splice(1,0,g),u=-1;const j=[];for(;++u<r.length;){const f=r[u],b=d[u];h=-1;const y=[];for(;++h<c;){const w=f[h]||"";
vendor: 15,747 bytes, lines 2-16
2let v="",S="";if(n.alignDelimiters!==!1){const T=l[h]-(b[h]||0),k=o[h];k===114?v=" ".repeat(T):k===99?T%2?(v=" ".repeat(T/2+.5),S=" ".repeat(T/2-.5)):(v=" ".repeat(T/2),S=v):S=" ".repeat(T)}n.delimiterStart!==!1&&!h&&y.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&w==="")&&(n.delimiterStart!==!1||h)&&y.push(" "),n.alignDelimiters!==!1&&y.push(v),y.push(w),n.alignDelimiters!==!1&&y.push(S),n.padding!==!1&&y.push(" "),(n.delimiterEnd!==!1||h!==c-1)&&y.push("|")}j.push(n.delimiterEnd===!1?y.join("").replace(/ +$/,""):y.join(""))}return j.join(` 3`)}function zr(t){return t==null?"":String(t)}function Vs(t){const s=typeof t=="string"?t.codePointAt(0):0;return s===67||s===99?99:s===76||s===108?108:s===82||s===114?114:0}function Or(t,s,n,a){const i=n.enter("blockquote"),o=n.createTracker(a);o.move("> "),o.shift(2);const r=n.indentLines(n.containerFlow(t,o.current()),Fr);return i(),r}function Fr(t,s,n){return">"+(n?"":" ")+t}function Br(t,s){return Qs(t,s.inConstruct,!0)&&!Qs(t,s.notInConstruct,!1)}function Qs(t,s,n){if(typeof s=="string"&&(s=[s]),!s||s.length===0)return n;let a=-1;for(;++a<s.length;)if(t.includes(s[a]))return!0;return!1}function Ys(t,s,n,a){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===` 4`&&Br(n.stack,n.unsafe[i]))return/[ \t]/.test(a.before)?"":" ";return`\\ 5`}function Wr(t,s){const n=String(t);let a=n.indexOf(s),i=a,o=0,r=0;if(typeof s!="string")throw new TypeError("Expected substring");for(;a!==-1;)a===i?++o>r&&(r=o):o=1,i=a+s.length,a=n.indexOf(s,i);return r}function Ur(t,s){return!!(s.options.fences===!1&&t.value&&!t.lang&&/[^ \r\n]/.test(t.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(t.value))}function Hr(t){const s=t.options.fence||"`";if(s!=="`"&&s!=="~")throw new Error("Cannot serialize code with `"+s+"` for `options.fence`, expected `` ` `` or `~`");return s}function qr(t,s,n,a){const i=Hr(n),o=t.value||"",r=i==="`"?"GraveAccent":"Tilde";if(Ur(t,n)){const h=n.enter("codeIndented"),p=n.indentLines(o,Kr);return h(),p}const d=n.createTracker(a),l=i.repeat(Math.max(Wr(o,i)+1,3)),c=n.enter("codeFenced");let u=d.move(l);if(t.lang){const h=n.enter(`codeFencedLang${r}`);u+=d.move(n.safe(t.lang,{before:u,after:" ",encode:["`"],...d.current()})),h()}if(t.lang&&t.meta){const h=n.enter(`codeFencedMeta${r}`);u+=d.move(" "),u+=d.move(n.safe(t.meta,{before:u,after:` 6`,encode:["`"],...d.current()})),h()}return u+=d.move(` 7`),o&&(u+=d.move(o+` 8`)),u+=d.move(l),c(),u}function Kr(t,s,n){return(n?"":" ")+t}function ys(t){const s=t.options.quote||'"';if(s!=='"'&&s!=="'")throw new Error("Cannot serialize title with `"+s+"` for `options.quote`, expected `\"`, or `'`");return s}function Gr(t,s,n,a){const i=ys(n),o=i==='"'?"Quote":"Apostrophe",r=n.enter("definition");let d=n.enter("label");const l=n.createTracker(a);let c=l.move("[");return c+=l.move(n.safe(n.associationId(t),{before:c,after:"]",...l.current()})),c+=l.move("]: "),d(),!t.url||/[\0- \u007F]/.test(t.url)?(d=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(t.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(d=n.enter("destinationRaw"),c+=l.move(n.safe(t.url,{before:c,after:t.title?" ":` 9`,...l.current()}))),d(),t.title&&(d=n.enter(`title${o}`),c+=l.move(" "+i),c+=l.move(n.safe(t.title,{before:c,after:i,...l.current()})),c+=l.move(i),d()),r(),c}function Vr(t){const s=t.options.emphasis||"*";if(s!=="*"&&s!=="_")throw new Error("Cannot serialize emphasis with `"+s+"` for `options.emphasis`, expected `*`, or `_`");return s}function dt(t){return"&#x"+t.toString(16).toUpperCase()+";"}function Rt(t,s,n){const a=Mt(t),i=Mt(s);return a===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:a===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}qn.peek=Qr;function qn(t,s,n,a){const i=Vr(n),o=n.enter("emphasis"),r=n.createTracker(a),d=r.move(i);let l=r.move(n.containerPhrasing(t,{after:i,before:d,...r.current()}));const c=l.charCodeAt(0),u=Rt(a.before.charCodeAt(a.before.length-1),c,i);u.inside&&(l=dt(c)+l.slice(1));const h=l.charCodeAt(l.length-1),p=Rt(a.after.charCodeAt(0),h,i);p.inside&&(l=l.slice(0,-1)+dt(h));const g=r.move(i);return o(),n.attentionEncodeSurroundingInfo={after:p.outside,before:u.outside},d+l+g}function Qr(t,s,n){return n.options.emphasis||"*"}function Yr(t,s){let n=!1;return si(t,function(a){if("value"in a&&/\r?\n|\r/.test(a.value)||a.type==="break")return n=!0,ni}),!!((!t.depth||t.depth<3)&&Mn(t)&&(s.options.setext||n))}function Jr(t,s,n,a){const i=Math.max(Math.min(6,t.depth||1),1),o=n.createTracker(a);if(Yr(t,n)){const u=n.enter("headingSetext"),h=n.enter("phrasing"),p=n.containerPhrasing(t,{...o.current(),before:` 10`,after:` 11`});return h(),u(),p+` 12`+(i===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(` 13`))+1))}const r="#".repeat(i),d=n.enter("headingAtx"),l=n.enter("phrasing");o.move(r+" ");let c=n.containerPhrasing(t,{before:"# ",after:` 14`,...o.current()});return/^[\t ]/.test(c)&&(c=dt(c.charCodeAt(0))+c.slice(1)),c=c?r+" "+c:r,n.options.closeAtx&&(c+=" "+r),l(),d(),c}Kn.peek=Xr;function Kn(t){return t.value||""}function Xr(){return"<"}Gn.peek=Zr;function Gn(t,s,n,a){const i=ys(n),o=i==='"'?"Quote":"Apostrophe",r=n.enter("image");let d=n.enter("label");const l=n.createTracker(a);let c=l.move("![");return c+=l.move(n.safe(t.alt,{before:c,after:"]",...l.current()})),c+=l.move("]("),d(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(d=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(t.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(d=n.enter("destinationRaw"),c+=l.move(n.safe(t.url,{before:c,after:t.title?" ":")",...l.current()}))),d(),t.title&&(d=n.enter(`title${o}`),c+=l.move(" "+i),c+=l.move(n.safe(t.title,{before:c,after:i,...l.current()})),c+=l.move(i),d()),c+=l.move(")"),r(),c}function Zr(){return"!"}Vn.peek=eo;function Vn(t,s,n,a){const i=t.referenceType,o=n.enter("imageReference");let r=n.enter("label");const d=n.createTracker(a);let l=d.move("![");const c=n.safe(t.alt,{before:l,after:"]",...d.current()});l+=d.move(c+"]["),r();const u=n.stack;n.stack=[],r=n.enter("reference");const h=n.safe(n.associationId(t),{before:l,after:"]",...d.current()});return r(),n.stack=u,o(),i==="full"||!c||c!==h?l+=d.move(h+"]"):i==="shortcut"?l=l.slice(0,-1):l+=d.move("]"),l}function eo(){return"!"}Qn.peek=to;function Qn(t,s,n){let a=t.value||"",i="`",o=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(a);)i+="`";for(/[^ \r\n]/.test(a)&&(/^[ \r\n]/.test(a)&&/[ \r\n]$/.test(a)||/^`|`$/.test(a))&&(a=" "+a+" ");++o<n.unsafe.length;){const r=n.unsafe[o],d=n.compilePattern(r);let l;if(r.atBreak)for(;l=d.exec(a);){let c=l.index;a.charCodeAt(c)===10&&a.charCodeAt(c-1)===13&&c--,a=a.slice(0,c)+" "+a.slice(l.index+1)}}return i+a+i}function to(){return"`"}function Yn(t,s){const n=Mn(t);return!!(!s.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(n===t.url||"mailto:"+n===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}Jn.peek=so;function Jn(t,s,n,a){const i=ys(n),o=i==='"'?"Quote":"Apostrophe",r=n.createTracker(a);let d,l;if(Yn(t,n)){const u=n.stack;n.stack=[],d=n.enter("autolink");let h=r.move("<");return h+=r.move(n.containerPhrasing(t,{before:h,after:">",...r.current()})),h+=r.move(">"),d(),n.stack=u,h}d=n.enter("link"),l=n.enter("label");let c=r.move("[");return c+=r.move(n.containerPhrasing(t,{before:c,after:"](",...r.current()})),c+=r.move("]("),l(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(l=n.enter("destinationLiteral"),c+=r.move("<"),c+=r.move(n.safe(t.url,{before:c,after:">",...r.current()})),c+=r.move(">")):(l=n.enter("destinationRaw"),c+=r.move(n.safe(t.url,{before:c,after:t.title?" ":")",...r.current()}))),l(),t.title&&(l=n.enter(`title${o}`),c+=r.move(" "+i),c+=r.move(n.safe(t.title,{before:c,after:i,...r.current()})),c+=r.move(i),l()),c+=r.move(")"),d(),c}function so(t,s,n){return Yn(t,n)?"<":"["}Xn.peek=no;function Xn(t,s,n,a){const i=t.referenceType,o=n.enter("linkReference");let r=n.enter("label");const d=n.createTracker(a);let l=d.move("[");const c=n.containerPhrasing(t,{before:l,after:"]",...d.current()});l+=d.move(c+"]["),r();const u=n.stack;n.stack=[],r=n.enter("reference");const h=n.safe(n.associationId(t),{before:l,after:"]",...d.current()});return r(),n.stack=u,o(),i==="full"||!c||c!==h?l+=d.move(h+"]"):i==="shortcut"?l=l.slice(0,-1):l+=d.move("]"),l}function no(){return"["}function bs(t){const s=t.options.bullet||"*";if(s!=="*"&&s!=="+"&&s!=="-")throw new Error("Cannot serialize items with `"+s+"` for `options.bullet`, expected `*`, `+`, or `-`");return s}function ao(t){const s=bs(t),n=t.options.bulletOther;if(!n)return s==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===s)throw new Error("Expected `bullet` (`"+s+"`) and `bulletOther` (`"+n+"`) to be different");return n}function io(t){const s=t.options.bulletOrdered||".";if(s!=="."&&s!==")")throw new Error("Cannot serialize items with `"+s+"` for `options.bulletOrdered`, expected `.` or `)`");return s}function Zn(t){const s=t.options.rule||"*";if(s!=="*"&&s!=="-"&&s!=="_")throw new Error("Cannot serialize rules with `"+s+"` for `options.rule`, expected `*`, `-`, or `_`");return s}function ro(t,s,n,a){const i=n.enter("list"),o=n.bulletCurrent;let r=t.ordered?io(n):bs(n);const d=t.ordered?r==="."?")":".":ao(n);let l=s&&n.bulletLastUsed?r===n.bulletLastUsed:!1;if(!t.ordered){const u=t.children?t.children[0]:void 0;if((r==="*"||r==="-")&&u&&(!u.children||!u.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),Zn(n)===r&&u){let h=-1;for(;++h<t.children.length;){const p=t.children[h];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(r=d),n.bulletCurrent=r;const c=n.containerFlow(t,a);return n.bulletLastUsed=r,n.bulletCurrent=o,i(),c}function oo(t){const s=t.options.listItemIndent||"one";if(s!=="tab"&&s!=="one"&&s!=="mixed")throw new Error("Cannot serialize items with `"+s+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return s}function lo(t,s,n,a){const i=oo(n);let o=n.bulletCurrent||bs(n);s&&s.type==="list"&&s.ordered&&(o=(typeof s.start=="number"&&s.start>-1?s.start:1)+(n.options.incrementListMarker===!1?0:s.children.indexOf(t))+o);let r=o.length+1;(i==="tab"||i==="mixed"&&(s&&s.type==="list"&&s.spread||t.spread))&&(r=Math.ceil(r/4)*4);const d=n.createTracker(a);d.move(o+" ".repeat(r-o.length)),d.shift(r);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(t,d.current()),u);return l(),c;function u(h,p,g){return p?(g?"":" ".repeat(r))+h:(g?o:o+" ".repeat(r-o.length))+h}}function co(t,s,n,a){const i=n.enter("paragraph"),o=n.enter("phrasing"),r=n.containerPhrasing(t,a);return o(),i(),r}const uo=Pn(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function ho(t,s,n,a){return(t.children.some(function(r){return uo(r)})?n.containerPhrasing:n.containerFlow).call(n,t,a)}function mo(t){const s=t.options.strong||"*";if(s!=="*"&&s!=="_")throw new Error("Cannot serialize strong with `"+s+"` for `options.strong`, expected `*`, or `_`");return s}ea.peek=po;function ea(t,s,n,a){const i=mo(n),o=n.enter("strong"),r=n.createTracker(a),d=r.move(i+i);let l=r.move(n.containerPhrasing(t,{after:i,before:d,...r.current()}));const c=l.charCodeAt(0),u=Rt(a.before.charCodeAt(a.before.length-1),c,i);u.inside&&(l=dt(c)+l.slice(1));const h=l.charCodeAt(l.length-1),p=Rt(a.after.charCodeAt(0),h,i);p.inside&&(l=l.slice(0,-1)+dt(h));const g=r.move(i+i);return o(),n.attentionEncodeSurroundingInfo={after:p.outside,before:u.outside},d+l+g}function po(t,s,n){return n.options.strong||"*"}function fo(t,s,n,a){return n.safe(t.value,a)}function xo(t){const s=t.options.ruleRepetition||3;if(s<3)throw new Error("Cannot serialize rules with repetition `"+s+"` for `options.ruleRepetition`, expected `3` or more");return s}function go(t,s,n){const a=(Zn(n)+(n.options.ruleSpaces?" ":"")).repeat(xo(n));return n.options.ruleSpaces?a.slice(0,-1):a}const ta={blockquote:Or,break:Ys,code:qr,definition:Gr,emphasis:qn,hardBreak:Ys,heading:Jr,html:Kn,image:Gn,imageReference:Vn,inlineCode:Qn,link:Jn,linkReference:Xn,list:ro,listItem:lo,paragraph:co,root:ho,strong:ea,text:fo,thematicBreak:go};function jo(){return{enter:{table:yo,tableData:Js,tableHeader:Js,tableRow:vo},exit:{codeText:wo,table:bo,tableData:Qt,tableHeader:Qt,tableRow:Qt}}}function yo(t){const s=t._align;this.enter({type:"table",align:s.map(function(n){return n==="none"?null:n}),children:[]},t),this.data.inTable=!0}function bo(t){this.exit(t),this.data.inTable=void 0}function vo(t){this.enter({type:"tableRow",children:[]},t)}function Qt(t){this.exit(t)}function Js(t){this.enter({type:"tableCell",children:[]},t)}function wo(t){let s=this.resume();this.data.inTable&&(s=s.replace(/\\([\\|])/g,ko));const n=this.stack[this.stack.length-1];tt(n.type==="inlineCode"),n.value=s,this.exit(t)}function ko(t,s){return s==="|"?s:t}function No(t){const s=t||{},n=s.tableCellPadding,a=s.tablePipeAlign,i=s.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` 15`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:r,tableCell:l,tableRow:d}};function r(g,j,f,b){return c(u(g,f,b),g.align)}function d(g,j,f,b){const y=h(g,f,b),w=c([y]);return w.slice(0,w.indexOf(` 16`))}function l(g,j,f,b){const y=f.enter("tableCell"),w=f.enter("phrasing"),v=f.containerPhrasing(g,{...b,before:o,after:o});return w(),y(),v}function c(g,j){return $r(g,{align:j,alignDelimiters:a,padding:n,stringLength:i})}function u(g,j,f){const b=g.children;let y=-1;const w=[],v=j.enter("table");for(;++y<b.length;)w[y]=h(b[y],j,f);return v(),w}function h(g,j,f){const b=g.children;let y=-1;const w=[],v=j.enter("tableRow");for(;++y<b.length;)w[y]=l(b[y],g,j,f);return v(),w}function p(g,j,f){let b=ta.inlineCode(g,j,f);return f.stack.includes("tableCell")&&(b=b.replace(/\|/g,"\\$&")),b}}function So(){return{exit:{taskListCheckValueChecked:Xs,taskListCheckValueUnchecked:Xs,paragraph:Po}}}function Co(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Mo}}}function Xs(t){const s=this.stack[this.stack.length-2];tt(s.type==="listItem"),s.checked=t.type==="taskListCheckValueChecked"}function Po(t){const s=this.stack[this.stack.length-2];if(s&&s.type==="listItem"&&typeof s.checked=="boolean"){const n=this.stack[this.stack.length-1];tt(n.type==="paragraph");const a=n.children[0];if(a&&a.type==="text"){const i=s.children;let o=-1,r;for(;++o<i.length;){const d=i[o];if(d.type==="paragraph"){r=d;break}}r===n&&(a.value=a.value.slice(1),a.value.length===0?n.children.shift():n.position&&a.position&&typeof a.position.start.offset=="number"&&(a.position.start.column++,a.position.start.offset++,n.position.start=Object.assign({},a.position.start)))}}this.exit(t)}function Mo(t,s,n,a){const i=t.children[0],o=typeof t.checked=="boolean"&&i&&i.type==="paragraph",r="["+(t.checked?"x":" ")+"] ",d=n.createTracker(a);o&&d.move(r);
vendor: 10,400 bytes, line 16
16let l=ta.listItem(t,s,n,{...a,...d.current()});return o&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+r}}function _o(){return[rr(),Pr(),Er(),jo(),So()]}function To(t){return{extensions:[or(),Mr(t),Rr(),No(t),Co()]}}const Eo={tokenize:$o,partial:!0},sa={tokenize:zo,partial:!0},na={tokenize:Oo,partial:!0},aa={tokenize:Fo,partial:!0},Ro={tokenize:Bo,partial:!0},ia={name:"wwwAutolink",tokenize:Do,previous:oa},ra={name:"protocolAutolink",tokenize:Lo,previous:la},Re={name:"emailAutolink",tokenize:Io,previous:ca},Ne={};function Ao(){return{text:Ne}}let Be=48;for(;Be<123;)Ne[Be]=Re,Be++,Be===58?Be=65:Be===91&&(Be=97);Ne[43]=Re;Ne[45]=Re;Ne[46]=Re;Ne[95]=Re;Ne[72]=[Re,ra];Ne[104]=[Re,ra];Ne[87]=[Re,ia];Ne[119]=[Re,ia];function Io(t,s,n){const a=this;let i,o;return r;function r(h){return!ls(h)||!ca.call(a,a.previous)||vs(a.events)?n(h):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),d(h))}function d(h){return ls(h)?(t.consume(h),d):h===64?(t.consume(h),l):n(h)}function l(h){return h===46?t.check(Ro,u,c)(h):h===45||h===95||fs(h)?(o=!0,t.consume(h),l):u(h)}function c(h){return t.consume(h),i=!0,l}function u(h){return o&&i&&ct(a.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),s(h)):n(h)}}function Do(t,s,n){const a=this;return i;function i(r){return r!==87&&r!==119||!oa.call(a,a.previous)||vs(a.events)?n(r):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(Eo,t.attempt(sa,t.attempt(na,o),n),n)(r))}function o(r){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),s(r)}}function Lo(t,s,n){const a=this;let i="",o=!1;return r;function r(h){return(h===72||h===104)&&la.call(a,a.previous)&&!vs(a.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),i+=String.fromCodePoint(h),t.consume(h),d):n(h)}function d(h){if(ct(h)&&i.length<5)return i+=String.fromCodePoint(h),t.consume(h),d;if(h===58){const p=i.toLowerCase();if(p==="http"||p==="https")return t.consume(h),l}return n(h)}function l(h){return h===47?(t.consume(h),o?c:(o=!0,l)):n(h)}function c(h){return h===null||ai(h)||fe(h)||Je(h)||ps(h)?n(h):t.attempt(sa,t.attempt(na,u),n)(h)}function u(h){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),s(h)}}function $o(t,s,n){let a=0;return i;function i(r){return(r===87||r===119)&&a<3?(a++,t.consume(r),i):r===46&&a===3?(t.consume(r),o):n(r)}function o(r){return r===null?n(r):s(r)}}function zo(t,s,n){let a,i,o;return r;function r(c){return c===46||c===95?t.check(aa,l,d)(c):c===null||fe(c)||Je(c)||c!==45&&ps(c)?l(c):(o=!0,t.consume(c),r)}function d(c){return c===95?a=!0:(i=a,a=void 0),t.consume(c),r}function l(c){return i||a||!o?n(c):s(c)}}function Oo(t,s){let n=0,a=0;return i;function i(r){return r===40?(n++,t.consume(r),i):r===41&&a<n?o(r):r===33||r===34||r===38||r===39||r===41||r===42||r===44||r===46||r===58||r===59||r===60||r===63||r===93||r===95||r===126?t.check(aa,s,o)(r):r===null||fe(r)||Je(r)?s(r):(t.consume(r),i)}function o(r){return r===41&&a++,t.consume(r),i}}function Fo(t,s,n){return a;function a(d){return d===33||d===34||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===63||d===95||d===126?(t.consume(d),a):d===38?(t.consume(d),o):d===93?(t.consume(d),i):d===60||d===null||fe(d)||Je(d)?s(d):n(d)}function i(d){return d===null||d===40||d===91||fe(d)||Je(d)?s(d):a(d)}function o(d){return ct(d)?r(d):n(d)}function r(d){return d===59?(t.consume(d),a):ct(d)?(t.consume(d),r):n(d)}}function Bo(t,s,n){return a;function a(o){return t.consume(o),i}function i(o){return fs(o)?n(o):s(o)}}function oa(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||fe(t)}function la(t){return!ct(t)}function ca(t){return!(t===47||ls(t))}function ls(t){return t===43||t===45||t===46||t===95||fs(t)}function vs(t){let s=t.length,n=!1;for(;s--;){const a=t[s][1];if((a.type==="labelLink"||a.type==="labelImage")&&!a._balanced){n=!0;break}if(a._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Wo={tokenize:Yo,partial:!0};function Uo(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Go,continuation:{tokenize:Vo},exit:Qo}},text:{91:{name:"gfmFootnoteCall",tokenize:Ko},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Ho,resolveTo:qo}}}}function Ho(t,s,n){const a=this;let i=a.events.length;const o=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let r;for(;i--;){const l=a.events[i][1];if(l.type==="labelImage"){r=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return d;function d(l){if(!r||!r._balanced)return n(l);const c=ht(a.sliceSerialize({start:r.end,end:a.now()}));return c.codePointAt(0)!==94||!o.includes(c.slice(1))?n(l):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(l),t.exit("gfmFootnoteCallLabelMarker"),s(l))}}function qo(t,s){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const a={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},t[t.length-1][1].start)},r={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},d=[t[n+1],t[n+2],["enter",a,s],t[n+3],t[n+4],["enter",i,s],["exit",i,s],["enter",o,s],["enter",r,s],["exit",r,s],["exit",o,s],t[t.length-2],t[t.length-1],["exit",a,s]];return t.splice(n,t.length-n+1,...d),t}function Ko(t,s,n){const a=this,i=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let o=0,r;return d;function d(h){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),l}function l(h){return h!==94?n(h):(t.enter("gfmFootnoteCallMarker"),t.consume(h),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",c)}function c(h){if(o>999||h===93&&!r||h===null||h===91||fe(h))return n(h);if(h===93){t.exit("chunkString");const p=t.exit("gfmFootnoteCallString");return i.includes(ht(a.sliceSerialize(p)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),s):n(h)}return fe(h)||(r=!0),o++,t.consume(h),h===92?u:c}function u(h){return h===91||h===92||h===93?(t.consume(h),o++,c):c(h)}}function Go(t,s,n){const a=this,i=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let o,r=0,d;return l;function l(j){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(j),t.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(j){return j===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(j),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",u):n(j)}function u(j){if(r>999||j===93&&!d||j===null||j===91||fe(j))return n(j);if(j===93){t.exit("chunkString");const f=t.exit("gfmFootnoteDefinitionLabelString");return o=ht(a.sliceSerialize(f)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(j),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),p}return fe(j)||(d=!0),r++,t.consume(j),j===92?h:u}function h(j){return j===91||j===92||j===93?(t.consume(j),r++,u):u(j)}function p(j){return j===58?(t.enter("definitionMarker"),t.consume(j),t.exit("definitionMarker"),i.includes(o)||i.push(o),Oe(t,g,"gfmFootnoteDefinitionWhitespace")):n(j)}function g(j){return s(j)}}function Vo(t,s,n){return t.check(ii,s,t.attempt(Wo,s,n))}function Qo(t){t.exit("gfmFootnoteDefinition")}function Yo(t,s,n){const a=this;return Oe(t,i,"gfmFootnoteDefinitionIndent",5);function i(o){const r=a.events[a.events.length-1];return r&&r[1].type==="gfmFootnoteDefinitionIndent"&&r[2].sliceSerialize(r[1],!0).length===4?s(o):n(o)}}function Jo(t){let n=(t||{}).singleTilde;const a={name:"strikethrough",tokenize:o,resolveAll:i};return n==null&&(n=!0),{text:{126:a},insideSpan:{null:[a]},attentionMarkers:{null:[126]}};function i(r,d){let l=-1;for(;++l<r.length;)if(r[l][0]==="enter"&&r[l][1].type==="strikethroughSequenceTemporary"&&r[l][1]._close){let c=l;for(;c--;)if(r[c][0]==="exit"&&r[c][1].type==="strikethroughSequenceTemporary"&&r[c][1]._open&&r[l][1].end.offset-r[l][1].start.offset===r[c][1].end.offset-r[c][1].start.offset){r[l][1].type="strikethroughSequence",r[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},r[c][1].start),end:Object.assign({},r[l][1].end)},h={type:"strikethroughText",start:Object.assign({},r[c][1].end),end:Object.assign({},r[l][1].start)},p=[["enter",u,d],["enter",r[c][1],d],["exit",r[c][1],d],["enter",h,d]],g=d.parser.constructs.insideSpan.null;g&&qt(p,p.length,0,ri(g,r.slice(c+1,l),d)),qt(p,p.length,0,[["exit",h,d],["enter",r[l][1],d],["exit",r[l][1],d],["exit",u,d]]),qt(r,c-1,l-c+3,p),l=c+p.length-2;break}}for(l=-1;++l<r.length;)r[l][1].type==="strikethroughSequenceTemporary"&&(r[l][1].type="data");return r}function o(r,d,l){const c=this.previous,u=this.events;let h=0;return p;function p(j){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(j):(r.enter("strikethroughSequenceTemporary"),g(j))}function g(j){const f=Mt(c);if(j===126)return h>1?l(j):(r.consume(j),h++,g);if(h<2&&!n)return l(j);const b=r.exit("strikethroughSequenceTemporary"),y=Mt(j);return b._open=!y||y===2&&!!f,b._close=!f||f===2&&!!y,d(j)}}}class Xo{constructor(){this.map=[]}add(s,n,a){Zo(this,s,n,a)}consume(s){if(this.map.sort(function(o,r){return o[0]-r[0]}),this.map.length===0)return;let n=this.map.length;const a=[];for(;n>0;)n-=1,a.push(s.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),s.length=this.map[n][0];a.push(s.slice()),s.length=0;let i=a.pop();for(;i;){for(const o of i)s.push(o);i=a.pop()}this.map.length=0}}function Zo(t,s,n,a){let i=0;if(!(n===0&&a.length===0)){for(;i<t.map.length;){if(t.map[i][0]===s){t.map[i][1]+=n,t.map[i][2].push(...a);return}i+=1}t.map.push([s,n,a])}}function el(t,s){let n=!1;const a=[];for(;s<t.length;){const i=t[s];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&a.push(t[s+1][1].type==="tableDelimiterMarker"?"left"
vendor: 6,969 bytes, line 16
16:"none");else if(i[1].type==="tableContent"){if(t[s-1][1].type==="tableDelimiterMarker"){const o=a.length-1;a[o]=a[o]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);s+=1}return a}function tl(){return{flow:{null:{name:"table",tokenize:sl,resolveAll:nl}}}}function sl(t,s,n){const a=this;let i=0,o=0,r;return d;function d(m){let M=a.events.length-1;for(;M>-1;){const _=a.events[M][1].type;if(_==="lineEnding"||_==="linePrefix")M--;else break}const P=M>-1?a.events[M][1].type:null,F=P==="tableHead"||P==="tableRow"?k:l;return F===k&&a.parser.lazy[a.now().line]?n(m):F(m)}function l(m){return t.enter("tableHead"),t.enter("tableRow"),c(m)}function c(m){return m===124||(r=!0,o+=1),u(m)}function u(m){return m===null?n(m):ot(m)?o>1?(o=0,a.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(m),t.exit("lineEnding"),g):n(m):qe(m)?Oe(t,u,"whitespace")(m):(o+=1,r&&(r=!1,i+=1),m===124?(t.enter("tableCellDivider"),t.consume(m),t.exit("tableCellDivider"),r=!0,u):(t.enter("data"),h(m)))}function h(m){return m===null||m===124||fe(m)?(t.exit("data"),u(m)):(t.consume(m),m===92?p:h)}function p(m){return m===92||m===124?(t.consume(m),h):h(m)}function g(m){return a.interrupt=!1,a.parser.lazy[a.now().line]?n(m):(t.enter("tableDelimiterRow"),r=!1,qe(m)?Oe(t,j,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(m):j(m))}function j(m){return m===45||m===58?b(m):m===124?(r=!0,t.enter("tableCellDivider"),t.consume(m),t.exit("tableCellDivider"),f):T(m)}function f(m){return qe(m)?Oe(t,b,"whitespace")(m):b(m)}function b(m){return m===58?(o+=1,r=!0,t.enter("tableDelimiterMarker"),t.consume(m),t.exit("tableDelimiterMarker"),y):m===45?(o+=1,y(m)):m===null||ot(m)?S(m):T(m)}function y(m){return m===45?(t.enter("tableDelimiterFiller"),w(m)):T(m)}function w(m){return m===45?(t.consume(m),w):m===58?(r=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(m),t.exit("tableDelimiterMarker"),v):(t.exit("tableDelimiterFiller"),v(m))}function v(m){return qe(m)?Oe(t,S,"whitespace")(m):S(m)}function S(m){return m===124?j(m):m===null||ot(m)?!r||i!==o?T(m):(t.exit("tableDelimiterRow"),t.exit("tableHead"),s(m)):T(m)}function T(m){return n(m)}function k(m){return t.enter("tableRow"),N(m)}function N(m){return m===124?(t.enter("tableCellDivider"),t.consume(m),t.exit("tableCellDivider"),N):m===null||ot(m)?(t.exit("tableRow"),s(m)):qe(m)?Oe(t,N,"whitespace")(m):(t.enter("data"),L(m))}function L(m){return m===null||m===124||fe(m)?(t.exit("data"),N(m)):(t.consume(m),m===92?z:L)}function z(m){return m===92||m===124?(t.consume(m),L):L(m)}}function nl(t,s){let n=-1,a=!0,i=0,o=[0,0,0,0],r=[0,0,0,0],d=!1,l=0,c,u,h;const p=new Xo;for(;++n<t.length;){const g=t[n],j=g[1];g[0]==="enter"?j.type==="tableHead"?(d=!1,l!==0&&(Zs(p,s,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},j.start),end:Object.assign({},j.end)},p.add(n,0,[["enter",c,s]])):j.type==="tableRow"||j.type==="tableDelimiterRow"?(a=!0,h=void 0,o=[0,0,0,0],r=[0,n+1,0,0],d&&(d=!1,u={type:"tableBody",start:Object.assign({},j.start),end:Object.assign({},j.end)},p.add(n,0,[["enter",u,s]])),i=j.type==="tableDelimiterRow"?2:u?3:1):i&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")?(a=!1,r[2]===0&&(o[1]!==0&&(r[0]=r[1],h=yt(p,s,o,i,void 0,h),o=[0,0,0,0]),r[2]=n)):j.type==="tableCellDivider"&&(a?a=!1:(o[1]!==0&&(r[0]=r[1],h=yt(p,s,o,i,void 0,h)),o=r,r=[o[1],n,0,0])):j.type==="tableHead"?(d=!0,l=n):j.type==="tableRow"||j.type==="tableDelimiterRow"?(l=n,o[1]!==0?(r[0]=r[1],h=yt(p,s,o,i,n,h)):r[1]!==0&&(h=yt(p,s,r,i,n,h)),i=0):i&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")&&(r[3]=n)}for(l!==0&&Zs(p,s,l,c,u),p.consume(s.events),n=-1;++n<s.events.length;){const g=s.events[n];g[0]==="enter"&&g[1].type==="table"&&(g[1]._align=el(s.events,n))}return t}function yt(t,s,n,a,i,o){const r=a===1?"tableHeader":a===2?"tableDelimiter":"tableData",d="tableContent";n[0]!==0&&(o.end=Object.assign({},Ke(s.events,n[0])),t.add(n[0],0,[["exit",o,s]]));const l=Ke(s.events,n[1]);if(o={type:r,start:Object.assign({},l),end:Object.assign({},l)},t.add(n[1],0,[["enter",o,s]]),n[2]!==0){const c=Ke(s.events,n[2]),u=Ke(s.events,n[3]),h={type:d,start:Object.assign({},c),end:Object.assign({},u)};if(t.add(n[2],0,[["enter",h,s]]),a!==2){const p=s.events[n[2]],g=s.events[n[3]];if(p[1].end=Object.assign({},g[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const j=n[2]+1,f=n[3]-n[2]-1;t.add(j,f,[])}}t.add(n[3]+1,0,[["exit",h,s]])}return i!==void 0&&(o.end=Object.assign({},Ke(s.events,i)),t.add(i,0,[["exit",o,s]]),o=void 0),o}function Zs(t,s,n,a,i){const o=[],r=Ke(s.events,n);i&&(i.end=Object.assign({},r),o.push(["exit",i,s])),a.end=Object.assign({},r),o.push(["exit",a,s]),t.add(n+1,0,o)}function Ke(t,s){const n=t[s],a=n[0]==="enter"?"start":"end";return n[1][a]}const al={name:"tasklistCheck",tokenize:rl};function il(){return{text:{91:al}}}function rl(t,s,n){const a=this;return i;function i(l){return a.previous!==null||!a._gfmTasklistFirstContentOfListItem?n(l):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),o)}function o(l){return fe(l)?(t.enter("taskListCheckValueUnchecked"),t.consume(l),t.exit("taskListCheckValueUnchecked"),r):l===88||l===120?(t.enter("taskListCheckValueChecked"),t.consume(l),t.exit("taskListCheckValueChecked"),r):n(l)}function r(l){return l===93?(t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),d):n(l)}function d(l){return ot(l)?s(l):qe(l)?t.check({tokenize:ol},s,n)(l):n(l)}}function ol(t,s,n){return Oe(t,a,"whitespace");function a(i){return i===null?n(i):s(i)}}function ll(t){return oi([Ao(),Uo(),Jo(t),tl(),il()])}const cl={};function ws(t){const s=this,n=t||cl,a=s.data(),i=a.micromarkExtensions||(a.micromarkExtensions=[]),o=a.fromMarkdownExtensions||(a.fromMarkdownExtensions=[]),r=a.toMarkdownExtensions||(a.toMarkdownExtensions=[]);i.push(ll(n)),o.push(_o()),r.push(To(n))}function da({authenticated:t,authBusy:s,delegateAccountId:n,delegateKey:a,setDelegateAccountId:i,setDelegateKey:o,onImport:r,dashboardUrl:d,noticeSlot:l,variant:c="panel",onBack:u,description:h,delegateStorage:p="server"}){const[g,j]=x.useState(!1),f=x.useId(),b=`${f}-memwal-account`,y=`${f}-delegate-key`,w=n.trim().length>0&&a.trim().length>0,v=c==="compact",S=[p==="browser"?{icon:_e,title:"Browser delegate",text:"The private key is stored in this browser and sent only as a request header for private hosted runs."}:{icon:_e,title:"Encrypted delegate",text:"The private key is sent once to the ContextMeM API and reused server-side."},{icon:xe,title:"Walrus Memory recall",text:"Unlock verified context recall, memory sync, and namespace history."},{icon:He,title:"Full console",text:"After import, all Walrus Site tabs, artifacts, and build actions become active."}
16,{icon:Te,title:"Mainnet only",text:"Built for current mainnet Walrus Sites resources and object IDs."}];function T(k){k.preventDefault(),!(!w||s)&&r()}return e.jsxs("section",{className:`rbAuth1 ${c}`,children:[e.jsx("div",{className:"rbAuth1FormCol",children:e.jsxs(de.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.42},className:"rbAuth1Stack",children:[e.jsx(de.div,{initial:{opacity:0,scale:.92},animate:{opacity:1,scale:1},transition:{duration:.32,delay:.08},className:"rbAuth1Logo","aria-hidden":"true",children:e.jsx(li,{size:v?17:20})}),e.jsxs(de.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.34,delay:.14},className:"rbAuth1Copy",children:[e.jsx("span",{children:t?"Delegate key required":"SDK credentials required"}),e.jsx("h2",{children:v?"Import SDK credentials":"Import Walrus Memory SDK credentials"}),e.jsx("p",{children:h??"Paste your Walrus Memory account ID and delegate private key. ContextMeM stores the delegate encrypted and unlocks verified Walrus context."})]}),e.jsxs(de.form,{initial:{opacity:0}
16,animate:{opacity:1},transition:{duration:.34,delay:.2},className:"rbAuth1Form",onSubmit:T,children:[e.jsx("label",{htmlFor:b,children:"Walrus Memory account ID"}),e.jsx("input",{id:b,name:"memwalAccountId",value:n,onChange:k=>i(k.target.value),placeholder:"0x...",disabled:s,autoComplete:"username",spellCheck:!1}),e.jsx("label",{htmlFor:y,children:"Delegate private key"}),e.jsxs("div",{className:"rbAuth1SecretField",children:[e.jsx("input",{id:y,name:"delegatePrivateKey",value:a,onChange:k=>o(k.target.value),placeholder:"Paste delegate private key",type:g?"text":"password",disabled:s,autoComplete:"current-password",spellCheck:!1}),e.jsx("button",{type:"button",onClick:()=>j(k=>!k),disabled:s,"aria-label":g?"Hide delegate private key":"Show delegate private key",children:g?e.jsx(_n,{size:18}):e.jsx(ci,{size:18})})]}),l,e.jsxs("button",{className:"rbAuth1Submit",type:"submit",disabled:s||!w,children:[e.jsx(xs,{size:16}),s?"Importing":t?"Import delegate key":"Import and start session"]})]}),e.jsxs(de.div,{initial:{opacity:0}
16,animate:{opacity:1},transition:{duration:.34,delay:.26},className:"rbAuth1Footer",children:[u?e.jsxs("button",{type:"button",onClick:u,children:[e.jsx(di,{size:15}),"Back to console"]}):null,e.jsxs("a",{href:d,target:"_blank",rel:"noreferrer",children:[e.jsx(At,{size:14}),"Open Walrus Memory dashboard"]})]})]})}),v?null:e.jsxs("div",{className:"rbAuth1VisualCol","aria-hidden":"true",children:[e.jsx("div",{className:"rbAuth1Flicker"}),e.jsx("div",{className:"rbAuth1Fade left"}),e.jsx("div",{className:"rbAuth1Fade right"}),e.jsx("div",{className:"rbAuth1Marquee",children:e.jsx("div",{className:"rbAuth1MarqueeTrack",children:[...S,...S].map((k,N)=>{const L=k.icon;return e.jsxs("article",{className:"rbAuth1ProofCard",children:[e.jsx(L,{size:20}),e.jsx("strong",{children:k.title}),e.jsx("p",{children:k.text})]},`${k.title}-${N}`)})})})]})]})}function dl({statusLabel:t,statusTone:s,sessionSlot:n,authHint:a,onOpenConsole:i,onInspectArtifacts:o,onOpenHistory:r}){const[d,l]=x.useState(!1),c=u=>{l(!1),u()};return e.jsxs("header",{className:"rbNav10",children:[e.jsxs(de.nav,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},transition:{duration:.5},className:"rbNav10Bar",children:[e.jsxs("button",{className:"rbNav10Brand",type:"button",onClick:i,children:[e.jsx("span",{className:"rbNav10Mark",children:e.jsx(Te,{size:15,strokeWidth:2.2})}),e.jsxs("span",{children:[e.jsx("strong",{children:"ContextMeM"}),e.jsx("small",{children:"Walrus Sites context engine"})]})]}),e.jsxs("button",{className:"rbNav10Live",type:"button",onClick:i,children:[e.jsxs("span",{className:"rbNav10LiveLabel",children:[e.jsx("span",{className:"rbNav10LiveDot"}),"Open ContextMeM"]}),e.jsx("span",{className:"rbNav10LiveArrow",children:e.jsx(Fe,{size:14})})]}),e.jsxs("div",{className:"rbNav10Actions",children:[e.jsx("span",{className:`rbNav10Status ${s}`,children:t}),n||null]})]}),a?e.jsx("div",{className:"rbNav10Hint",children:a}):null,e.jsx(Nt,{children:d?e.jsx(de.div,{initial:{opacity:0}
16,animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},onClick:()=>l(!1),className:"rbNav10Overlay"},"overlay"):null}),e.jsx(Nt,{children:d?e.jsx(de.aside,{initial:{clipPath:"circle(0% at calc(100% - 18px) 18px)"},animate:{clipPath:"circle(150% at calc(100% - 18px) 18px)"},exit:{clipPath:"circle(0% at calc(100% - 18px) 18px)"},transition:{duration:.5,ease:[.22,1,.36,1]},className:"rbNav10Panel",children:e.jsxs(de.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},transition:{duration:.25,delay:.2},className:"rbNav10PanelInner",children:[e.jsxs("nav",{className:"rbNav10MenuLinks",children:[e.jsx("button",{type:"button",onClick:()=>c(i),children:"App"}),e.jsx("button",{type:"button",onClick:()=>c(o),children:"Artifacts"}),e.jsx("button",{type:"button",onClick:()=>c(r),children:"History"})]}),e.jsxs("div",{className:"rbNav10MenuSection",children:[e.jsx("p",{children:"RESOURCES"}),e.jsxs("button",{type:"button",onClick:()=>c(o),children:[e.jsx(ke,{size:16}),"Inspect context package"]}),e.jsxs("button",{type:"button",onClick:()=>c(r),children:[e.jsx(xe,{size:16}),"Walrus update history"]})]}),e.jsxs("div",{className:"rbNav10Socials",children:[e.jsx("a",{href:"https://x.com/harry_phan06",target:"_blank",rel:"noreferrer","aria-label":"Harry Phan on X",children:e.jsx(ui,{size:16})}),e.jsx("a",{href:"https://github.com/MystenLabs/walrus-sites",target:"_blank",rel:"noreferrer","aria-label":"Walrus Sites on GitHub",children:e.jsx(hi,{size:16})})]}),e.jsxs("button",{className:"rbNav10PanelCta",type:"button",onClick:()=>c(i),children:["OPEN APP",e.jsx(Fe,{size:17})]})]})},"panel"):null}),e.jsxs("div",{className:"rbNav10ToggleWrap",children:[e.jsx(de.div,{initial:!1,animate:{opacity:d?0:1},transition:{duration:d?0:.2,delay:d?0:.35},className:"rbNav10ToggleBg"}),e.jsx(de.button,{type:"button",onClick:()=>l(u=>!u),initial:!1,animate:{x:d?-1:0},transition:{duration:.25},className:"rbNav10Toggle","aria-label":d?"Close menu":"Open menu","aria-expanded":d,children:e.jsx("span",{children:e.jsx(Nt,{mode:"wait",initial:!1,children:d?e.jsx(de.span,{initial:{opacity:0}
16,animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:e.jsx(gs,{size:17})},"x"):e.jsx(de.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:e.jsx(mi,{size:17})},"m")})})})]})]})}const D="https://contextmem-backend.petlofi.workers.dev",en={type:"change"},ks={type:"start"},ua={type:"end"},bt=new fi,tn=new Tn,ul=Math.cos(70*Pe.DEG2RAD),ee=new J,ce=2*Math.PI,V={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Yt=1e-6;class hl extends pi{constructor(s,n=null){super(s,n),this.state=V.NONE,this.target=new J,this.cursor=new J,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Qe.ROTATE,MIDDLE:Qe.DOLLY,RIGHT:Qe.PAN},this.touches={ONE:Ge.ROTATE,TWO:Ge.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new J,this._lastQuaternion=new Us,this._lastTargetPosition=new J,this._quat=new Us().setFromUnitVectors(s.up,new J(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Hs,this._sphericalDelta=new Hs,this._scale=1,this._panOffset=new J,this._rotateStart=new Y,this._rotateEnd=new Y,this._rotateDelta=new Y,this._panStart=new Y,this._panEnd=new Y,this._panDelta=new Y,this._dollyStart=new Y,this._dollyEnd=new Y,this._dollyDelta=new Y,this._dollyDirection=new J,this._mouse=new Y,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=pl.bind(this),this._onPointerDown=ml.bind(this),this._onPointerUp=fl.bind(this),this._onContextMenu=wl.bind(this),this._onMouseWheel=jl.bind(this),this._onKeyDown=yl.bind(this),this._onTouchStart=bl.bind(this),this._onTouchMove=vl.bind(this),this._onMouseDown=xl.bind(this),this._onMouseMove=gl.bind(this),this._interceptControlDown=kl.bind(this),this._interceptControlUp=Nl.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(s){this._cursorStyle=s,s==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(s){super.connect(s),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=""}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(s){s.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=s}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(en),this.update(),this.state=V.NONE}pan(s,n){this._pan(s,n),this.update()}dollyIn(s){this._dollyIn(s),this.update()}dollyOut(s){this._dollyOut(s),this.update()}rotateLeft(s){this._rotateLeft(s),this.update()}rotateUp(s){this._rotateUp(s),this.update()}update(s=null){const n=this.object.position;ee.copy(n).sub(this.target),ee.applyQuaternion(this._quat),this._spherical.setFromVector3(ee),this.autoRotate&&this.state===V.NONE&&this._rotateLeft(this._getAutoRotationAngle(s)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let a=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(a)&&isFinite(i)&&(a<-Math.PI?a+=ce:a>Math.PI&&(a-=ce),i<-Math.PI?i+=ce:i>Math.PI&&(i-=ce),a<=i?this._spherical.theta=Math.max(a,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(a+i)/2?Math.max(a,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let o=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radiu
vendor: 31,254 bytes, lines 16-224
16s=this._clampDistance(this._spherical.radius);else{const r=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),o=r!=this._spherical.radius}if(ee.setFromSpherical(this._spherical),ee.applyQuaternion(this._quatInverse),n.copy(this.target).add(ee),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let r=null;if(this.object.isPerspectiveCamera){const d=ee.length();r=this._clampDistance(d*this._scale);const l=d-r;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),o=!!l}else if(this.object.isOrthographicCamera){const d=new J(this._mouse.x,this._mouse.y,0);d.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),o=l!==this.object.zoom;const c=new J(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(d),this.object.updateMatrixWorld(),r=ee.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;r!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(r).add(this.object.position):(bt.origin.copy(this.object.position),bt.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(bt.direction))<ul?this.object.lookAt(this.target):(tn.setFromNormalAndCoplanarPoint(this.object.up,this.target),bt.intersectPlane(tn,this.target))))}else if(this.object.isOrthographicCamera){const r=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),r!==this.object.zoom&&(this.object.updateProjectionMatrix(),o=!0)}return this._scale=1,this._performCursorZoom=!1,o||this._lastPosition.distanceToSquared(this.object.position)>Yt||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Yt||this._lastTargetPosition.distanceToSquared(this.target)>Yt?(this.dispatchEvent(en),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(s){return s!==null?ce/60*this.autoRotateSpeed*s:ce/60/60*this.autoRotateSpeed}_getZoomScale(s){const n=Math.abs(s*.01);return Math.pow(.95,this.zoomSpeed*n)}_rotateLeft(s){this._sphericalDelta.theta-=s}_rotateUp(s){this._sphericalDelta.phi-=s}_panLeft(s,n){ee.setFromMatrixColumn(n,0),ee.multiplyScalar(-s),this._panOffset.add(ee)}_panUp(s,n){this.screenSpacePanning===!0?ee.setFromMatrixColumn(n,1):(ee.setFromMatrixColumn(n,0),ee.crossVectors(this.object.up,ee)),ee.multiplyScalar(s),this._panOffset.add(ee)}_pan(s,n){const a=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;ee.copy(i).sub(this.target);let o=ee.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*s*o/a.clientHeight,this.object.matrix),this._panUp(2*n*o/a.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(s*(this.object.right-this.object.left)/this.object.zoom/a.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/a.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(s){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=s:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(s){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=s:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(s,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const a=this.domElement.getBoundingClientRect(),i=s-a.left,o=n-a.top,r=a.width,d=a.height;this._mouse.x=i/r*2-1,this._mouse.y=-(o/d)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(s){return Math.max(this.minDistance,Math.min(this.maxDistance,s))}_handleMouseDownRotate(s){this._rotateStart.set(s.clientX,s.clientY)}_handleMouseDownDolly(s){this._updateZoomParameters(s.clientX,s.clientX),this._dollyStart.set(s.clientX,s.clientY)}_handleMouseDownPan(s){this._panStart.set(s.clientX,s.clientY)}_handleMouseMoveRotate(s){this._rotateEnd.set(s.clientX,s.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(ce*this._rotateDelta.x/n.clientHeight),this._rotateUp(ce*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(s){this._dollyEnd.set(s.clientX,s.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(s){this._panEnd.set(s.clientX,s.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(s){this._updateZoomParameters(s.clientX,s.clientY),s.deltaY<0?this._dollyIn(this._getZoomScale(s.deltaY)):s.deltaY>0&&this._dollyOut(this._getZoomScale(s.deltaY)),this.update()}_handleKeyDown(s){let n=!1;switch(s.code){case this.keys.UP:s.ctrlKey||s.metaKey||s.shiftKey?this.enableRotate&&this._rotateUp(ce*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),n=!0;break;case this.keys.BOTTOM:s.ctrlKey||s.metaKey||s.shiftKey?this.enableRotate&&this._rotateUp(-ce*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),n=!0;break;case this.keys.LEFT:s.ctrlKey||s.metaKey||s.shiftKey?this.enableRotate&&this._rotateLeft(ce*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),n=!0;break;case this.keys.RIGHT:s.ctrlKey||s.metaKey||s.shiftKey?this.enableRotate&&this._rotateLeft(-ce*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(s.preventDefault(),this.update())}_handleTouchStartRotate(s){if(this._pointers.length===1)this._rotateStart.set(s.pageX,s.pageY);else{const n=this._getSecondPointerPosition(s),a=.5*(s.pageX+n.x),i=.5*(s.pageY+n.y);this._rotateStart.set(a,i)}}_handleTouchStartPan(s){if(this._pointers.length===1)this._panStart.set(s.pageX,s.pageY);else{const n=this._getSecondPointerPosition(s),a=.5*(s.pageX+n.x),i=.5*(s.pageY+n.y);this._panStart.set(a,i)}}_handleTouchStartDolly(s){const n=this._getSecondPointerPosition(s),a=s.pageX-n.x,i=s.pageY-n.y,o=Math.sqrt(a*a+i*i);this._dollyStart.set(0,o)}_handleTouchStartDollyPan(s){this.enableZoom&&this._handleTouchStartDolly(s),this.enablePan&&this._handleTouchStartPan(s)}_handleTouchStartDollyRotate(s){this.enableZoom&&this._handleTouchStartDolly(s),this.enableRotate&&this._handleTouchStartRotate(s)}_handleTouchMoveRotate(s){if(this._pointers.length==1)this._rotateEnd.set(s.pageX,s.pageY);else{const a=this._getSecondPointerPosition(s),i=.5*(s.pageX+a.x),o=.5*(s.pageY+a.y);this._rotateEnd.set(i,o)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(ce*this._rotateDelta.x/n.clientHeight),this._rotateUp(ce*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(s){if(this._pointers.length===1)this._panEnd.set(s.pageX,s.pageY);else{const n=this._getSecondPointerPosition(s),a=.5*(s.pageX+n.x),i=.5*(s.pageY+n.y);this._panEnd.set(a,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(s){const n=this._getSecondPointerPosition(s),a=s.pageX-n.x,i=s.pageY-n.y,o=Math.sqrt(a*a+i*i);this._dollyEnd.set(0,o),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const r=(s.pageX+n.x)*.5,d=(s.pageY+n.y)*.5;this._updateZoomParameters(r,d)}_handleTouchMoveDollyPan(s){this.enableZoom&&this._handleTouchMoveDolly(s),this.enablePan&&this._handleTouchMovePan(s)}_handleTouchMoveDollyRotate(s){this.enableZoom&&this._handleTouchMoveDolly(s),this.enableRotate&&this._handleTouchMoveRotate(s)}_addPointer(s){this._pointers.push(s.pointerId)}_removePointer(s){delete this._pointerPositions[s.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==s.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(s){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==s.pointerId)return!0;return!1}_trackPointer(s){let n=this._pointerPositions[s.pointerId];n===void 0&&(n=new Y,this._pointerPositions[s.pointerId]=n),n.set(s.pageX,s.pageY)}_getSecondPointerPosition(s){const n=s.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[n]}_customWheelEvent(s){const n=s.deltaMode,a={clientX:s.clientX,clientY:s.clientY,deltaY:s.deltaY};switch(n){case 1:a.deltaY*=16;break;case 2:a.deltaY*=100;break}return s.ctrlKey&&!this._controlActive&&(a.deltaY*=10),a}}function ml(t){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(t.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(t)&&(this._addPointer(t),t.pointerType==="touch"?this._onTouchStart(t):this._onMouseDown(t),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function pl(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function fl(t){switch(this._removePointer(t),this._pointers.length){case 0:this.domElement.releasePointerCapture(t.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(ua),this.state=V.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const s=this._pointers[0],n=this._pointerPositions[s];this._onTouchStart({pointerId:s,pageX:n.x,pageY:n.y});break}}function xl(t){let s;switch(t.button){case 0:s=this.mouseButtons.LEFT;break;case 1:s=this.mouseButtons.MIDDLE;break;case 2:s=this.mouseButtons.RIGHT;break;default:s=-1}switch(s){case Qe.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=V.DOLLY;break;case Qe.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=V.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=V.ROTATE}break;case Qe.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=V.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=V.PAN}break;default:this.state=V.NONE}this.state!==V.NONE&&this.dispatchEvent(ks)}function gl(t){switch(this.state){case V.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case V.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case V.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function jl(t){this.enabled===!1||this.enableZoom===!1||this.state!==V.NONE||(t.preventDefault(),this.dispatchEvent(ks),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(ua))}function yl(t){this.enabled!==!1&&this._handleKeyDown(t)}function bl(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case Ge.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=V.TOUCH_ROTATE;break;case Ge.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=V.TOUCH_PAN;break;default:this.state=V.NONE}break;case 2:switch(this.touches.TWO){case Ge.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=V.TOUCH_DOLLY_PAN;break;case Ge.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=V.TOUCH_DOLLY_ROTATE;break;default:this.state=V.NONE}break;default:this.state=V.NONE}this.state!==V.NONE&&this.dispatchEvent(ks)}function vl(t){switch(this._trackPointer(t),this.state){case V.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case V.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case V.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case V.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=V.NONE}}function wl(t){this.enabled!==!1&&t.preventDefault()}function kl(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Nl(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const Pt={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` 17 18 varying vec2 vUv; 19 20 void main() { 21 22 vUv = uv; 23 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 24 25 }`,fragmentShader:` 26 27 uniform float opacity; 28 29 uniform sampler2D tDiffuse; 30 31 varying vec2 vUv; 32 33 void main() { 34 35 vec4 texel = texture2D( tDiffuse, vUv ); 36 gl_FragColor = opacity * texel; 37 38 39 }`};class at{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const Sl=new gi(-1,1,1,-1,0,1);class Cl extends _t{constructor(){super(),this.setAttribute("position",new ne([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new ne([0,2,0,0,2,0],2))}}const Pl=new Cl;class Ns{constructor(s){this._mesh=new xi(Pl,s)}dispose(){this._mesh.geometry.dispose()}render(s){s.render(this._mesh,Sl)}get material(){return this._mesh.material}set material(s){this._mesh.material=s}}class Ml extends at{constructor(s,n="tDiffuse"){super(),this.textureID=n,this.uniforms=null,this.material=null,s instanceof Me?(this.uniforms=s.uniforms,this.material=s):s&&(this.uniforms=Tt.clone(s.uniforms),this.material=new Me({name:s.name!==void 0?s.name:"unspecified",defines:Object.assign({},s.defines),uniforms:this.uniforms,vertexShader:s.vertexShader,fragmentShader:s.fragmentShader})),this._fsQuad=new Ns(this.material)}render(s,n,a){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=a.texture),this._fsQuad.material=this.material,this.renderToScreen?(s.setRenderTarget(null),this._fsQuad.render(s)):(s.setRenderTarget(n),this.clear&&s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil),this._fsQuad.render(s))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class sn extends at{constructor(s,n){super(),this.scene=s,this.camera=n,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(s,n,a){const i=s.getContext(),o=s.state;o.buffers.color.setMask(!1),o.buffers.depth.setMask(!1),o.buffers.color.setLocked(!0),o.buffers.depth.setLocked(!0);let r,d;this.inverse?(r=0,d=1):(r=1,d=0),o.buffers.stencil.setTest(!0),o.buffers.stencil.setOp(i.REPLACE,i.REPLACE,i.REPLACE),o.buffers.stencil.setFunc(i.ALWAYS,r,4294967295),o.buffers.stencil.setClear(d),o.buffers.stencil.setLocked(!0),s.setRenderTarget(a),this.clear&&s.clear(),s.render(this.scene,this.camera),s.setRenderTarget(n),this.clear&&s.clear(),s.render(this.scene,this.camera),o.buffers.color.setLocked(!1),o.buffers.depth.setLocked(!1),o.buffers.color.setMask(!0),o.buffers.depth.setMask(!0),o.buffers.stencil.setLocked(!1),o.buffers.stencil.setFunc(i.EQUAL,1,4294967295),o.buffers.stencil.setOp(i.KEEP,i.KEEP,i.KEEP),o.buffers.stencil.setLocked(!0)}}class _l extends at{constructor(){super(),this.needsSwap=!1}render(s){s.state.buffers.stencil.setLocked(!1),s.state.buffers.stencil.setTest(!1)}}class Tl{constructor(s,n){if(this.renderer=s,this._pixelRatio=s.getPixelRatio(),n===void 0){const a=s.getSize(new Y);this._width=a.width,this._height=a.height,n=new St(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Ct}),n.texture.name="EffectComposer.rt1"}else this._width=n.width,this._height=n.height;this.renderTarget1=n,this.renderTarget2=n.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new Ml(Pt),this.copyPass.material.blending=ji,this.timer=new yi}swapBuffers(){const s=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=s}addPass(s){this.passes.push(s),s.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(s,n){this.passes.splice(n,0,s),s.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(s){const n=this.passes.indexOf(s);n!==-1&&this.passes.splice(n,1)}isLastEnabledPass(s){for(let n=s+1;n<this.passes.length;n++)if(this.passes[n].enabled)return!1;return!0}render(s){this.timer.update(),s===void 0&&(s=this.timer.getDelta());const n=this.renderer.getRenderTarget();let a=!1;for(let i=0,o=this.passes.length;i<o;i++){const r=this.passes[i];if(r.enabled!==!1){if(r.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(i),r.render(this.renderer,this.writeBuffer,this.readBuffer,s,a),r.needsSwap){if(a){const d=this.renderer.getContext(),l=this.renderer.state.buffers.stencil;l.setFunc(d.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,s),l.setFunc(d.EQUAL,1,4294967295)}this.swapBuffers()}sn!==void 0&&(r instanceof sn?a=!0:r instanceof _l&&(a=!1))}}this.renderer.setRenderTarget(n)}reset(s){if(s===void 0){const n=this.renderer.getSize(new Y);this._pixelRatio=this.renderer.getPixelRatio(),this._width=n.width,this._height=n.height,s=this.renderTarget1.clone(),s.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=s,this.renderTarget2=s.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(s,n){this._width=s,this._height=n;const a=this._width*this._pixelRatio,i=this._height*this._pixelRatio;this.renderTarget1.setSize(a,i),this.renderTarget2.setSize(a,i);for(let o=0;o<this.passes.length;o++)this.passes[o].setSize(a,i)}setPixelRatio(s){this._pixelRatio=s,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class El extends at{constructor(s,n,a=null,i=null,o=null){super(),this.scene=s,this.camera=n,this.overrideMaterial=a,this.clearColor=i,this.clearAlpha=o,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.isRenderPass=!0,this._oldClearColor=new be}render(s,n,a){const i=s.autoClear;s.autoClear=!1;let o,r;this.overrideMaterial!==null&&(r=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(s.getClearColor(this._oldClearColor),s.setClearColor(this.clearColor,s.getClearAlpha())),this.clearAlpha!==null&&(o=s.getClearAlpha(),s.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&s.clearDepth(),s.setRenderTarget(this.renderToScreen?null:a),this.clear===!0&&s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil),s.render(this.scene,this.camera),this.clearColor!==null&&s.setClearColor(this._oldClearColor),this.clearAlpha!==null&&s.setClearAlpha(o),this.overrideMaterial!==null&&(this.scene.overrideMaterial=r),s.autoClear=i}}const Rl={uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new be(0)},defaultOpacity:{value:0}},vertexShader:` 40 41 varying vec2 vUv; 42 43 void main() { 44 45 vUv = uv; 46 47 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 48 49 }`,fragmentShader:` 50 51 uniform sampler2D tDiffuse; 52 uniform vec3 defaultColor; 53 uniform float defaultOpacity; 54 uniform float luminosityThreshold; 55 uniform float smoothWidth; 56 57 varying vec2 vUv; 58 59 void main() { 60 61 vec4 texel = texture2D( tDiffuse, vUv ); 62 63 float v = luminance( texel.xyz ); 64 65 vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity ); 66 67 float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v ); 68 69 gl_FragColor = mix( outputColor, texel, alpha ); 70 71 }`};class et extends at{constructor(s,n=1,a,i){super(),this.strength=n,this.radius=a,this.threshold=i,this.resolution=s!==void 0?new Y(s.x,s.y):new Y(256,256),this.clearColor=new be(0,0,0),this.needsSwap=!1,this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let o=Math.round(this.resolution.x/2),r=Math.round(this.resolution.y/2);this.renderTargetBright=new St(o,r,{type:Ct}),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let u=0;u<this.nMips;u++){const h=new St(o,r,{type:Ct});h.texture.name="UnrealBloomPass.h"+u,h.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(h);const p=new St(o,r,{type:Ct});p.texture.name="UnrealBloomPass.v"+u,p.texture.generateMipmaps=!1,this.renderTargetsVertical.push(p),o=Math.round(o/2),r=Math.round(r/2)}const d=Rl;this.highPassUniforms=Tt.clone(d.uniforms),this.highPassUniforms.luminosityThreshold.value=i,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new Me({uniforms:this.highPassUniforms,vertexShader:d.vertexShader,fragmentShader:d.fragmentShader}),this.separableBlurMaterials=[];const l=[6,10,14,18,22];o=Math.round(this.resolution.x/2),r=Math.round(this.resolution.y/2);for(let u=0;u<this.nMips;u++)this.separableBlurMaterials.push(this._getSeparableBlurMaterial(l[u])),this.separableBlurMaterials[u].uniforms.invSize.value=new Y(1/o,1/r),o=Math.round(o/2),r=Math.round(r/2);this.compositeMaterial=this._getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=n,this.compositeMaterial.uniforms.bloomRadius.value=.1;const c=[1,.8,.6,.4,.2];this.compositeMaterial.uniforms.bloomFactors.value=c,this.bloomTintColors=[new J(1,1,1),new J(1,1,1),new J(1,1,1),new J(1,1,1),new J(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,this.copyUniforms=Tt.clone(Pt.uniforms),this.blendMaterial=new Me({uniforms:this.copyUniforms,vertexShader:Pt.vertexShader,fragmentShader:Pt.fragmentShader,premultipliedAlpha:!0,blending:Et,depthTest:!1,depthWrite:!1,transparent:!0}),this._oldClearColor=new be,this._oldClearAlpha=1,this._basic=new bi,this._fsQuad=new Ns(null)}dispose(){for(let s=0;s<this.renderTargetsHorizontal.length;s++)this.renderTargetsHorizontal[s].dispose();for(let s=0;s<this.renderTargetsVertical.length;s++)this.renderTargetsVertical[s].dispose();this.renderTargetBright.dispose();for(let s=0;s<this.separableBlurMaterials.length;s++)this.separableBlurMaterials[s].dispose();this.compositeMaterial.dispose(),this.blendMaterial.dispose(),this._basic.dispose(),this._fsQuad.dispose()}setSize(s,n){let a=Math.round(s/2),i=Math.round(n/2);this.renderTargetBright.setSize(a,i);for(let o=0;o<this.nMips;o++)this.renderTargetsHorizontal[o].setSize(a,i),this.renderTargetsVertical[o].setSize(a,i),this.separableBlurMaterials[o].uniforms.invSize.value=new Y(1/a,1/i),a=Math.round(a/2),i=Math.round(i/2)}render(s,n,a,i,o){s.getClearColor(this._oldClearColor),this._oldClearAlpha=s.getClearAlpha();const r=s.autoClear;s.autoClear=!1,s.setClearColor(this.clearColor,0),o&&s.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this._fsQuad.material=this._basic,this._basic.map=a.texture,s.setRenderTarget(null),s.clear(),this._fsQuad.render(s)),this.highPassUniforms.tDiffuse.value=a.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this._fsQuad.material=this.materialHighPassFilter,s.setRenderTarget(this.renderTargetBright),s.clear(),this._fsQuad.render(s);let d=this.renderTargetBright;for(let l=0;l<this.nMips;l++)this._fsQuad.material=this.separableBlurMaterials[l],this.separableBlurMaterials[l].uniforms.colorTexture.value=d.texture,this.separableBlurMaterials[l].uniforms.direction.value=et.BlurDirectionX,s.setRenderTarget(this.renderTargetsHorizontal[l]),s.clear(),this._fsQuad.render(s),this.separableBlurMaterials[l].uniforms.colorTexture.value=this.renderTargetsHorizontal[l].texture,this.separableBlurMaterials[l].uniforms.direction.value=et.BlurDirectionY,s.setRenderTarget(this.renderTargetsVertical[l]),s.clear(),this._fsQuad.render(s),d=this.renderTargetsVertical[l];this._fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,s.setRenderTarget(this.renderTargetsHorizontal[0]),s.clear(),this._fsQuad.render(s),this._fsQuad.material=this.blendMaterial,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,o&&s.state.buffers.stencil.setTest(!0),this.renderToScreen?(s.setRenderTarget(null),this._fsQuad.render(s)):(s.setRenderTarget(a),this._fsQuad.render(s)),s.setClearColor(this._oldClearColor,this._oldClearAlpha),s.autoClear=r}_getSeparableBlurMaterial(s){const n=[],a=s/3;for(let i=0;i<s;i++)n.push(.39894*Math.exp(-.5*i*i/(a*a))/a);return new Me({defines:{KERNEL_RADIUS:s},uniforms:{colorTexture:{value:null},invSize:{value:new Y(.5,.5)},direction:{value:new Y(.5,.5)},gaussianCoefficients:{value:n}},vertexShader:` 72 73 varying vec2 vUv; 74 75 void main() { 76 77 vUv = uv; 78 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 79 80 }`,fragmentShader:` 81 82 #include <common> 83 84 varying vec2 vUv; 85 86 uniform sampler2D colorTexture; 87 uniform vec2 invSize; 88 uniform vec2 direction; 89 uniform float gaussianCoefficients[KERNEL_RADIUS]; 90 91 void main() { 92 93 float weightSum = gaussianCoefficients[0]; 94 vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum; 95 96 for ( int i = 1; i < KERNEL_RADIUS; i ++ ) { 97 98 float x = float( i ); 99 float w = gaussianCoefficients[i]; 100 vec2 uvOffset = direction * invSize * x; 101 vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb; 102 vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb; 103 diffuseSum += ( sample1 + sample2 ) * w; 104 105 } 106 107 gl_FragColor = vec4( diffuseSum, 1.0 ); 108 109 }`})}_getCompositeMaterial(s){return new Me({defines:{NUM_MIPS:s},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:` 110 111 varying vec2 vUv; 112 113 void main() { 114 115 vUv = uv; 116 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 117 118 }`,fragmentShader:` 119 120 varying vec2 vUv; 121 122 uniform sampler2D blurTexture1; 123 uniform sampler2D blurTexture2; 124 uniform sampler2D blurTexture3; 125 uniform sampler2D blurTexture4; 126 uniform sampler2D blurTexture5; 127 uniform float bloomStrength; 128 uniform float bloomRadius; 129 uniform float bloomFactors[NUM_MIPS]; 130 uniform vec3 bloomTintColors[NUM_MIPS]; 131 132 float lerpBloomFactor( const in float factor ) { 133 134 float mirrorFactor = 1.2 - factor; 135 return mix( factor, mirrorFactor, bloomRadius ); 136 137 } 138 139 void main() { 140 141 // 3.0 for backwards compatibility with previous alpha-based intensity 142 vec3 bloom = 3.0 * bloomStrength * ( 143 lerpBloomFactor( bloomFactors[ 0 ] ) * bloomTintColors[ 0 ] * texture2D( blurTexture1, vUv ).rgb + 144 lerpBloomFactor( bloomFactors[ 1 ] ) * bloomTintColors[ 1 ] * texture2D( blurTexture2, vUv ).rgb + 145 lerpBloomFactor( bloomFactors[ 2 ] ) * bloomTintColors[ 2 ] * texture2D( blurTexture3, vUv ).rgb + 146 lerpBloomFactor( bloomFactors[ 3 ] ) * bloomTintColors[ 3 ] * texture2D( blurTexture4, vUv ).rgb + 147 lerpBloomFactor( bloomFactors[ 4 ] ) * bloomTintColors[ 4 ] * texture2D( blurTexture5, vUv ).rgb 148 ); 149 150 float bloomAlpha = max( bloom.r, max( bloom.g, bloom.b ) ); 151 gl_FragColor = vec4( bloom, bloomAlpha ); 152 153 }`})}}et.BlurDirectionX=new Y(1,0);et.BlurDirectionY=new Y(0,1);const vt={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:` 154 precision highp float; 155 156 uniform mat4 modelViewMatrix; 157 uniform mat4 projectionMatrix; 158 159 attribute vec3 position; 160 attribute vec2 uv; 161 162 varying vec2 vUv; 163 164 void main() { 165 166 vUv = uv; 167 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 168 169 }`,fragmentShader:` 170 171 precision highp float; 172 173 uniform sampler2D tDiffuse; 174 175 #include <tonemapping_pars_fragment> 176 #include <colorspace_pars_fragment> 177 178 varying vec2 vUv; 179 180 void main() { 181 182 gl_FragColor = texture2D( tDiffuse, vUv ); 183 184 // tone mapping 185 186 #ifdef LINEAR_TONE_MAPPING 187 188 gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); 189 190 #elif defined( REINHARD_TONE_MAPPING ) 191 192 gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); 193 194 #elif defined( CINEON_TONE_MAPPING ) 195 196 gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); 197 198 #elif defined( ACES_FILMIC_TONE_MAPPING ) 199 200 gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); 201 202 #elif defined( AGX_TONE_MAPPING ) 203 204 gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); 205 206 #elif defined( NEUTRAL_TONE_MAPPING ) 207 208 gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); 209 210 #elif defined( CUSTOM_TONE_MAPPING ) 211 212 gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); 213 214 #endif 215 216 // color space 217 218 #ifdef SRGB_TRANSFER 219 220 gl_FragColor = sRGBTransferOETF( gl_FragColor ); 221 222 #endif 223 224 }`};class Al extends at{constructor(){super(),this.isOutputPass=!0,this.uniforms=Tt.clone(vt.uniforms),this.material=new vi({name:vt.name,uniforms:this.uniforms,vertexShader:vt.vertexShader,fragmentShader:vt.fragmentShader}
224),this._fsQuad=new Ns(this.material),this._outputColorSpace=null,this._toneMapping=null}render(s,n,a){this.uniforms.tDiffuse.value=a.texture,this.uniforms.toneMappingExposure.value=s.toneMappingExposure,(this._outputColorSpace!==s.outputColorSpace||this._toneMapping!==s.toneMapping)&&(this._outputColorSpace=s.outputColorSpace,this._toneMapping=s.toneMapping,this.material.defines={},wi.getTransfer(this._outputColorSpace)===ki&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===Ni?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===Si?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===Ci?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===Pi?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===Mi?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===_i?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===Ti&&(this.material.defines.CUSTOM_TONE_MAPPING=""),this.material.needsUpdate=!0),this.renderToScreen===!0?(s.setRenderTarget(null),this._fsQuad.render(s)):(s.setRenderTarget(n),this.clear&&s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil),this._fsQuad.render(s))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}const cs={organization:"#3e7bd6",product:"#46a758",platform:"#12a594",feature:"#8e4ec6",technology:"#3aa6c4",integration:"#e07b3c",pricing_plan:"#29a383",use_case:"#cf5b9b",person:"#dd6a52",customer:"#5b7fd6",competitor:"#d65b5f",metric:"#d6b150",location:"#6b6bcf",event:"#d65b8a",concept:"#8b97a8",other:"#6e7079"},ha={organization:"Organizations",product:"Products",feature:"Features",person:"People",technology:"Technologies",integration:"Integrations",platform:"Platforms",pricing_plan:"Pricing plans",use_case:"Use cases",metric:"Metrics",customer:"Customers",competitor:"Competitors",location:"Locations",event:"Events",concept:"Concepts",other:"Other"},Il=["organization","product","platform","feature","technology","integration","pricing_plan","use_case","person","customer","competitor","metric","location","event","concept","other"];function Dl(t){return cs[t]??cs.other}function Ll(t){return ha[t]??t}const nn={positive:"#46a758",negative:"#d65b5f",neutral:"#8b95a3"};function $l({node:t,detail:s,related:n,onClose:a,onSelectRelated:i}){const o=s?.aliases??[],r=s?.topics??[],d=s?.claims??[],l=s?.stats??[];return e.jsxs(de.aside,{className:"nmc-panel",initial:{x:40,opacity:0},animate:{x:0,opacity:1},exit:{x:40,opacity:0},transition:{duration:.2},children:[e.jsx("button",{className:"nmc-close",onClick:a,"aria-label":"Close",children:e.jsx(gs,{size:18})}),e.jsx("div",{className:"nmc-breadcrumb",style:{color:"var(--cm-accent)"},children:Ll(t.routePath)}),e.jsx("h3",{style:{margin:"2px 0 8px",fontSize:20,lineHeight:1.25},children:t.label}),e.jsxs("div",{style:{fontSize:12,color:"#8b95a3",marginBottom:12},children:[typeof t.mentions=="number"?e.jsxs(e.Fragment,{children:[t.mentions," mention",t.mentions===1?"":"s"]}):null,t.url?e.jsxs(e.Fragment,{children:[typeof t.mentions=="number"?" · ":"",e.jsx("a",{href:t.url,target:"_blank",rel:"noreferrer",style:{color:"var(--cm-accent)"},children:"source"})]}):null]}),o.length||r.length?e.jsxs("div",{className:"nmc-section nmc-chips",children:[o.map(c=>e.jsx("span",{className:"nmc-chip nmc-chip-alias",children:c},`a-${c}`)),r.map(c=>e.jsx("span",{className:"nmc-chip",children:c},`t-${c}`))]}):null,e.jsx("div",{className:"nmc-panel-text",children:e.jsx(js,{remarkPlugins:[ws],children:t.text})}),l.length?e.jsxs("div",{className:"nmc-section",children:[e.jsx("div",{className:"nmc-section-title",children:"Stats"}),l.map((c,u)=>e.jsxs("div",{className:"nmc-stat-row",children:[e.jsx("strong",{children:c.value}),e.jsx("span",{children:c.label})]},`${c.label}-${u}`))]}):null,d.length?e.jsxs("div",{className:"nmc-section",children:[e.jsx("div",{className:"nmc-section-title",children:"Claims"}),d.map((c,u)=>e.jsxs("div",{className:"nmc-claim",children:[e.jsx("span",{className:"nmc-claim-dot",style:{background:nn[c.sentiment]??nn.neutral}}),e.jsxs("span",{children:[c.text," ",e.jsx("em",{className:"nmc-claim-kind",children:c.kind.replace(/_/g," ")})]})]},u))]}):null,n.length?e.jsxs("div",{className:"nmc-section",children:[e.jsx("div",{className:"nmc-section-title",children:"Related"}),e.jsx("div",{className:"nmc-related-list",children:n.map(c=>{const u=c.relLabel||(c.relKind?c.relKind.replace(/_/g," "):"related"),h=c.direction==="out"?`${t.label} ${u} ${c.node.label}`:`${c.node.label} ${u} ${t.label}`;return e.jsxs("button",{className:"nmc-related",onClick:()=>i(c.node),title:h,children:[e.jsx("span",{className:"nmc-related-dot",style:{background:Dl(c.node.routePath)}}),e.jsx("span",{className:"nmc-related-name",children:c.node.label}),e.jsxs("span",{className:"nmc-related-rel",children:[c.direction==="in"?"â
224 ":"",u,c.direction==="out"?" â":"",typeof c.confidence=="number"?` · ${Math.round(c.confidence*100)}%`:""]})]},c.node.id)})})]}):null]})}function an(t){return typeof t=="object"&&t!==null?t.id:t}const zl=8;function Ol(t,s){const n=new Map(t.nodes.map(i=>[i.id,i])),a=new Map;for(const i of t.links){const o=an(i.source),r=an(i.target),d=o===s?r:r===s?o:null;if(!d)continue;const l=n.get(d);if(!l)continue;const c=a.get(d);(!c||(i.confidence??0)>(c.confidence??0))&&a.set(d,{node:l,relLabel:i.relLabel,relKind:i.relKind,confidence:i.confidence,direction:o===s?"out":"in"})}return[...a.values()].sort((i,o)=>(o.confidence??0)-(i.confidence??0)).slice(0,zl)}function Fl({nodes:t,onSelect:s}){const[n,a]=x.useState(""),i=x.useMemo(()=>t.map(r=>`${r.label} ${r.routePath} ${r.text}`.toLowerCase()),[t]),o=x.useMemo(()=>{const r=n.trim().toLowerCase();return r?t.filter((d,l)=>i[l].includes(r)).slice(0,20):[]},[n,t,i]);return e.jsxs("div",{className:"nmc-search",children:[e.jsx("input",{value:n,onChange:r=>a(r.target.value),placeholder:"Search memoryâ¦"}),o.length>0&&e.jsx("div",{className:"nmc-results",children:o.map(r=>e.jsxs("button",{onClick:()=>{s(r),a("")},children:[e.jsx("strong",{children:r.label}),e.jsxs("span",{style:{color:"#8b95a3"},children:[" â ",r.routePath]})]},r.id))})]})}function Bl({nodeCount:t,linkCount:s}){return e.jsx("div",{className:"nmc-legend",children:e.jsxs("span",{children:[t," entities · ",s," relationships"]})})}function Ve(t){return typeof t=="object"&&t!==null?t.id:t}const ma=` 225vec3 mod289(vec3 x){return x-floor(x*(1.0/289.0))*289.0;} 226vec4 mod289(vec4 x){return x-floor(x*(1.0/289.0))*289.0;} 227vec4 permute(vec4 x){return mod289(((x*34.0)+1.0)*x);} 228vec4 taylorInvSqrt(vec4 r){return 1.79284291400159-0.85373472095314*r;} 229float snoise(vec3 v){ 230 const vec2 C=vec2(1.0/6.0,1.0/3.0); const vec4 D=vec4(0.0,0.5,1.0,2.0); 231 vec3 i=floor(v+dot(v,C.yyy)); vec3 x0=v-i+dot(i,C.xxx); 232 vec3 g=step(x0.yzx,x0.xyz); vec3 l=1.0-g; 233 vec3 i1=min(g.xyz,l.zxy); vec3 i2=max(g.xyz,l.zxy); 234 vec3 x1=x0-i1+C.xxx; vec3 x2=x0-i2+C.yyy; vec3 x3=x0-D.yyy; 235 i=mod289(i); 236 vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0)); 237 float n_=0.142857142857; vec3 ns=n_*D.wyz-D.xzx; 238 vec4 j=p-49.0*floor(p*ns.z*ns.z); vec4 x_=floor(j*ns.z); vec4 y_=floor(j-7.0*x_); 239 vec4 x=x_*ns.x+ns.yyyy; vec4 y=y_*ns.x+ns.yyyy; vec4 h=1.0-abs(x)-abs(y); 240 vec4 b0=vec4(x.xy,y.xy); vec4 b1=vec4(x.zw,y.zw); 241 vec4 s0=floor(b0)*2.0+1.0; vec4 s1=floor(b1)*2.0+1.0; vec4 sh=-step(h,vec4(0.0)); 242 vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy; vec4 a1=b1.xzyw+s1.xzyw*sh.zzww; 243 vec3 p0=vec3(a0.xy,h.x); vec3 p1=vec3(a0.zw,h.y); vec3 p2=vec3(a1.xy,h.z); vec3 p3=vec3(a1.zw,h.w); 244 vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3))); 245 p0*=norm.x; p1*=norm.y; p2*=norm.z; p3*=norm.w; 246 vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0); m=m*m; 247 return 42.0*dot(m*m,vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3))); 248}`,rn={vertexShader:`${ma} 249 attribute float nodeSize; attribute float nodeType; attribute vec3 nodeColor; attribute float distanceFromRoot; 250 uniform float uTime; uniform vec3 uPulsePositions[3]; uniform float uPulseTimes[3]; uniform float uPulseSpeed; uniform float uBaseNodeSize; 251 varying vec3 vColor; varying float vNodeType; varying vec3 vPosition; varying float vPulseIntensity; varying float vDistanceFromRoot; varying float vGlow; 252 float getPulseIntensity(vec3 worldPos, vec3 pulsePos, float pulseTime){ 253 if(pulseTime<0.0)return 0.0; float t=uTime-pulseTime; if(t<0.0||t>4.0)return 0.0; 254 float pr=t*uPulseSpeed; float d=distance(worldPos,pulsePos); float wp=abs(d-pr); 255 return smoothstep(3.0,0.0,wp)*smoothstep(4.0,0.0,t); 256 } 257 void main(){ 258 vNodeType=nodeType; vColor=nodeColor; vDistanceFromRoot=distanceFromRoot; 259 vec3 worldPos=(modelMatrix*vec4(position,1.0)).xyz; vPosition=worldPos; 260 float tot=0.0; for(int i=0;i<3;i++){tot+=getPulseIntensity(worldPos,uPulsePositions[i],uPulseTimes[i]);} 261 vPulseIntensity=min(tot,1.0); 262 float breathe=sin(uTime*0.7+distanceFromRoot*0.15)*0.15+0.85; 263 float baseSize=nodeSize*breathe; float pulseSize=baseSize*(1.0+vPulseIntensity*2.5); 264 vGlow=0.5+0.5*sin(uTime*0.5+distanceFromRoot*0.2); 265 vec3 mp=position; 266 if(nodeType>0.5){ float n=snoise(position*0.08+uTime*0.08); mp+=normalize(position+0.001)*n*0.15; } 267 vec4 mvPosition=modelViewMatrix*vec4(mp,1.0); 268 gl_PointSize=pulseSize*uBaseNodeSize*(1000.0/-mvPosition.z); 269 gl_Position=projectionMatrix*mvPosition; 270 }`,fragmentShader:` 271 uniform float uTime; uniform vec3 uPulseColors[3]; 272 varying vec3 vColor; varying float vNodeType; varying vec3 vPosition; varying float vPulseIntensity; varying float vDistanceFromRoot; varying float vGlow; 273 void main(){ 274 vec2 c=2.0*gl_PointCoord-1.0; float dist=length(c); if(dist>1.0)discard; 275 float glow1=1.0-smoothstep(0.0,0.5,dist); float glow2=1.0-smoothstep(0.0,1.0,dist); 276 float gs=pow(glow1,1.2)+glow2*0.3; 277 float bc=0.9+0.1*sin(uTime*0.6+vDistanceFromRoot*0.25); 278 vec3 baseColor=vColor*bc; vec3 finalColor=baseColor; 279 if(vPulseIntensity>0.0){ vec3 pc=mix(vec3(1.0),uPulseColors[0],0.4); finalColor=mix(baseColor,pc,vPulseIntensity*0.8); finalColor*=(1.0+vPulseIntensity*1.2); gs*=(1.0+vPulseIntensity); } 280 float core=smoothstep(0.4,0.0,dist); finalColor+=vec3(1.0)*core*0.3; 281 float alpha=gs*(0.95-0.3*dist); 282 float cd=length(vPosition-cameraPosition); float df=smoothstep(120.0,15.0,cd); 283 if(vNodeType>0.5){ finalColor*=1.1; alpha*=0.9; } 284 finalColor*=(1.0+vGlow*0.1); 285 gl_FragColor=vec4(finalColor,alpha*df); 286 }`},on={vertexShader:`${ma} 287 attribute vec3 startPoint; attribute vec3 endPoint; attribute float connectionStrength; attribute float pathIndex; attribute vec3 connectionColor; 288 uniform float uTime; uniform vec3 uPulsePositions[3]; uniform float uPulseTimes[3]; uniform float uPulseSpeed; 289 varying vec3 vColor; varying float vConnectionStrength; varying float vPulseIntensity; varying float vPathPosition; varying float vDistanceFromCamera; 290 float getPulseIntensity(vec3 worldPos, vec3 pulsePos, float pulseTime){ 291 if(pulseTime<0.0)return 0.0; float t=uTime-pulseTime; if(t<0.0||t>4.0)return 0.0; 292 float pr=t*uPulseSpeed; float d=distance(worldPos,pulsePos); float wp=abs(d-pr); 293 return smoothstep(3.0,0.0,wp)*smoothstep(4.0,0.0,t); 294 } 295 void main(){ 296 float t=position.x; vPathPosition=t; 297 vec3 midPoint=mix(startPoint,endPoint,0.5); 298 float pathOffset=sin(t*3.14159)*0.15; 299 vec3 perpendicular=normalize(cross(normalize(endPoint-startPoint),vec3(0.0,1.0,0.0))); 300 if(length(perpendicular)<0.1)perpendicular=vec3(1.0,0.0,0.0); 301 midPoint+=perpendicular*pathOffset; 302 vec3 p0=mix(startPoint,midPoint,t); vec3 p1=mix(midPoint,endPoint,t); vec3 finalPos=mix(p0,p1,t); 303 float noise=snoise(vec3(pathIndex*0.08,t*0.6,uTime*0.15)); finalPos+=perpendicular*noise*0.12; 304 vec3 worldPos=(modelMatrix*vec4(finalPos,1.0)).xyz; 305 float tot=0.0; for(int i=0;i<3;i++){tot+=getPulseIntensity(worldPos,uPulsePositions[i],uPulseTimes[i]);} 306 vPulseIntensity=min(tot,1.0); 307 vColor=connectionColor; vConnectionStrength=connectionStrength; 308 vDistanceFromCamera=length(worldPos-cameraPosition); 309 gl_Position=projectionMatrix*modelViewMatrix*vec4(finalPos,1.0); 310 }`,fragmentShader:` 311 uniform float uTime; uniform vec3 uPulseColors[3]; 312 varying vec3 vColor; varying float vConnectionStrength; varying float vPulseIntensity; varying float vPathPosition; varying float vDistanceFromCamera; 313 void main(){ 314 float f1=sin(vPathPosition*25.0-uTime*4.0)*0.5+0.5; 315 float f2=sin(vPathPosition*15.0-uTime*2.5+1.57)*0.5+0.5; 316 float flow=(f1+f2*0.5)/1.5; 317 vec3 baseColor=vColor*(0.8+0.2*sin(uTime*0.6+vPathPosition*12.0)); 318 float fi=0.4*flow*vConnectionStrength; vec3 finalColor=baseColor; 319 if(vPulseIntensity>0.0){ vec3 pc=mix(vec3(1.0),uPulseColors[0],0.3); finalColor=mix(baseColor,pc*1.2,vPulseIntensity*0.7); fi+=vPulseIntensity*0.8; } 320 finalColor*=(0.7+fi+vConnectionStrength*0.5); 321 float alpha=0.7*vConnectionStrength+flow*0.3;
322 alpha=mix(alpha,min(1.0,alpha*2.5),vPulseIntensity); 323 float df=smoothstep(120.0,15.0,vDistanceFromCamera); 324 gl_FragColor=vec4(finalColor,alpha*df); 325 }`},Wl=[12513892,10741301,14285213];function ln(){const t={uTime:{value:0},uPulsePositions:{value:[new J(1e3,1e3,1e3),new J(1e3,1e3,1e3),new J(1e3,1e3,1e3)]},uPulseTimes:{value:[-1e3,-1e3,-1e3]},uPulseColors:{value:[new be(1,1,1),new be(1,1,1),new be(1,1,1)]},uPulseSpeed:{value:16},uBaseNodeSize:{value:.72}};return Wl.forEach((s,n)=>{n<3&&t.uPulseColors.value[n].set(s)}),t}function Ul(){const s=[],n=[],a=[];for(let r=0;r<5e3;r++){const d=Pe.randFloat(70,170),l=Math.acos(Pe.randFloatSpread(2)),c=Pe.randFloat(0,Math.PI*2);s.push(d*Math.sin(l)*Math.cos(c),d*Math.sin(l)*Math.sin(c),d*Math.cos(l)),Math.random()<.82?n.push(.85,.95,.7):n.push(1,1,1),a.push(Pe.randFloat(.1,.28))}const i=new _t;i.setAttribute("position",new ne(s,3)),i.setAttribute("color",new ne(n,3)),i.setAttribute("size",new ne(a,1));const o=new Me({uniforms:{uTime:{value:0}},vertexShader:`attribute float size; attribute vec3 color; varying vec3 vColor; uniform float uTime; 326 void main(){ vColor=color; vec4 mv=modelViewMatrix*vec4(position,1.0); 327 float tw=sin(uTime*2.0+position.x*100.0)*0.3+0.7; gl_PointSize=size*tw*(300.0/-mv.z); gl_Position=projectionMatrix*mv; }`,fragmentShader:`varying vec3 vColor; void main(){ vec2 c=gl_PointCoord-0.5; float d=length(c); if(d>0.5)discard; 328 float a=1.0-smoothstep(0.0,0.5,d); gl_FragColor=vec4(vColor,a*0.4); }`,transparent:!0,depthWrite:!1,blending:Et});return new En(i,o)}const Hl=new be(6660877),cn=new be(10741301),ql=new be(12513892);function dn(t){const s=new be;return t<.5?s.copy(Hl).lerp(cn,t/.5):s.copy(cn).lerp(ql,(t-.5)/.5),s.offsetHSL(Pe.randFloatSpread(.015),Pe.randFloatSpread(.05),Pe.randFloatSpread(.06))}const Kl=Math.PI*(3-Math.sqrt(5));function un(t,s){const n=s<=1?0:1-t/(s-1)*2,a=Math.sqrt(Math.max(0,1-n*n)),i=Kl*t;return[Math.cos(i)*a,n,Math.sin(i)*a]}function Gl(t){const n=new Map;for(const u of t.nodes)n.set(u.id,[]);for(const u of t.links){const h=Ve(u.source),p=Ve(u.target);n.has(h)&&n.has(p)&&(n.get(h).push(p),n.get(p).push(h))}const a=t.nodes.find(u=>u.primary)?.id,i=new Set,o=[];for(const u of t.nodes){if(i.has(u.id))continue;const h=[],p=[u.id];for(i.add(u.id);p.length;){const g=p.shift();h.push(g);for(const j of n.get(g))i.has(j)||(i.add(j),p.push(j))}o.push(h)}const r=new Map;o.sort((u,h)=>{const p=u.includes(a??"")?1:0;return(h.includes(a??"")?1:0)-p||h.length-u.length}),o.forEach((u,h)=>{const p=u.includes(a??"")?a:u.slice().sort((w,v)=>n.get(v).length-n.get(w).length)[0],g=un(h,o.length),j=h===0?[0,0,0]:[g[0]*60,g[1]*60,g[2]*60];r.set(p,j);const f=new Map([[p,0]]),b=[p];for(;b.length;){const w=b.shift();for(const v of n.get(w))f.has(v)||(f.set(v,f.get(w)+1),b.push(v))}const y=new Map;for(const w of u){if(w===p)continue;const v=f.get(w)??1;(y.get(v)??y.set(v,[]).get(v)).push(w)}for(const[w,v]of y){const S=7+(w-1)*7;v.forEach((T,k)=>{const N=un(k,v.length);r.set(T,[j[0]+N[0]*S,j[1]+N[1]*S,j[2]+N[2]*S])})}});const d=o[0]??[];let l=.001;for(const u of d){const h=r.get(u);h&&(l=Math.max(l,Math.hypot(h[0],h[1],h[2])))}const c=16/l;return t.nodes.map(u=>{const h=r.get(u.id)??[0,0,0];return{id:u.id,node:u,x:h[0]*c,y:h[1]*c,z:h[2]*c}})}function Vl({graph:t,entityDetail:s}){const n=x.useRef(null),a=x.useRef(null),i=x.useRef(null),[o,r]=x.useState(null),d=x.useRef(null);d.current=o;const l=x.useRef(null),[c,u]=x.useState(!1);x.useEffect(()=>{const f=()=>{const b=document.fullscreenElement??document.webkitFullscreenElement??null;u(b===l.current)};return document.addEventListener("fullscreenchange",f),document.addEventListener("webkitfullscreenchange",f),()=>{document.removeEventListener("fullscreenchange",f),document.removeEventListener("webkitfullscreenchange",f)}},[]);function h(){const f=l.current;if(!f)return;document.fullscreenElement??document.webkitFullscreenElement??null?(document.exitFullscreen??document.webkitExitFullscreen)?.call(document):(f.requestFullscreen??f.webkitRequestFullscreen)?.call(f)}const p=x.useMemo(()=>{const f=new Map;for(const v of t.nodes)f.set(v.id,[]);for(const v of t.links){const S=Ve(v.source),T=Ve(v.target);f.get(S)?.push(T),f.get(T)?.push(S)}const b=t.nodes.find(v=>v.primary)?.id??t.nodes[0]?.id,y=new Map;if(b){const v=[b];for(y.set(b,0);v.length;){const S=v.shift();for(const T of f.get(S)??[])y.has(T)||(y.set(T,y.get(S)+1),v.push(T))}}const w=new Map;for(const[v,S]of f)w.set(v,S.length);return{lvl:y,deg:w}},[t]),g=x.useMemo(()=>o?Ol(t,o.id):[],[o,t]);x.useEffect(()=>{const f=n.current;if(!f)return;const b=f.clientWidth||1,y=f.clientHeight||1,w=new Ei;w.fog=new Ri(0,.0019);const v=new Ai(62,b/y,.1,1e3);v.position.set(0,6,40);const S=new Ii({antialias:!0,powerPreference:"high-performance",alpha:!1});S.setSize(b,y),S.setPixelRatio(Math.min(window.devicePixelRatio,2)),S.setClearColor(329482),S.outputColorSpace
328=Di,S.domElement.style.display="block",f.appendChild(S.domElement);const T=Ul();w.add(T);const k=new hl(v,S.domElement);k.enableDamping=!0,k.dampingFactor=.05,k.rotateSpeed=.6,k.minDistance=12,k.maxDistance=110,k.autoRotate=!0,k.autoRotateSpeed=.28,k.enablePan=!1;const N=new Tl(S);N.addPass(new El(w,v));const L=new et(new Y(b,y),1.6,.6,.7);N.addPass(L),N.addPass(new Al);const z=new Li;z.params.Points={threshold:1.8};const m={renderer:S,scene:w,camera:v,controls:k,composer:N,bloom:L,raycaster:z,nodesMesh:null,connMesh:null,records:[],labels:[],raf:0,desired:null,lastPulse:0};i.current=m;const M=new J,P=new $i,F=()=>{m.raf=requestAnimationFrame(F);const B=P.getElapsedTime();m.clockT=B,m.nodesMesh&&(m.nodesMesh.material.uniforms.uTime.value=B,m.nodesMesh.rotation.y=Math.sin(B*.04)*.05),m.connMesh&&(m.connMesh.material.uniforms.uTime.value=B,m.connMesh.rotation.y=Math.sin(B*.04)*.05),T.rotation.y+=2e-4,T.material.uniforms.uTime.value=B,m.desired&&(m.controls.target.lerp(m.desired.target,.08),m.camera.position.lerp(m.desired.cam,.08),B>m.desired.until&&(m.desired=null,d.current||(m.controls.autoRotate=!0))),m.controls.update(),m.composer.render();const W=m.nodesMesh?m.nodesMesh.rotation.y:0,te=Math.cos(W),ae=Math.sin(W);for(let ie=0;ie<m.records.length;ie++){const X=m.records[ie],se=m.labels[ie];if(!se)continue;const A=X.x*te+X.z*ae,re=-X.x*ae+X.z*te;if(M.set(A,X.y,re).project(m.camera),M.z>1){se.style.opacity="0";continue}const Ae=(M.x*.5+.5)*f.clientWidth,$t=(-M.y*.5+.5)*f.clientHeight,jt=Pe.clamp(M.z,0,1);se.style.transform=`translate(-50%,0) translate(${Ae}px,${$t}px)`,se.style.opacity=String(.92-jt*.5)}};let _=0,O=0;const q=B=>{_=B.clientX,O=B.clientY},$=B=>{if(Math.hypot(B.clientX-_,B.clientY-O)>6)return;const W=S.domElement.getBoundingClientRect(),te=new Y((B.clientX-W.left)/W.width*2-1,-((B.clientY-W.top)/W.height)*2+1);if(m.raycaster.setFromCamera(te,m.camera),m.nodesMesh){const X=m.raycaster.intersectObject(m.nodesMesh);if(X.length&&X[0].index!=null){const se=m.records[X[0].index];if(se){K(se),r(se.node);return}}}const ae=new Tn(m.camera.position.clone().normalize(),0);ae.constant=-ae.normal.dot(m.camera.position)+m.camera.position.length()*.5;const ie=new J;if(m.raycaster.ray.intersectPlane(ae,ie)){m.lastPulse=(m.lastPulse+1)%3;for(const X of[m.nodesMesh,m.connMesh])X&&(X.material.uniforms.uPulsePositions.value[m.lastPulse].copy(ie),X.material.uniforms.uPulseTimes.value[m.lastPulse]=m.clockT??0)}};S.domElement.addEventListener("pointerdown",q),S.domElement.addEventListener("pointerup",$);function K(B){const W=new J(B.x,B.y,B.z),te=m.camera.position.clone().sub(m.controls.target).normalize();m.desired={target:W.clone(),cam:W.clone().add(te.multiplyScalar(20)),until:(m.clockT??0)+1.2},m.controls.autoRotate=!1}m.focusRec=K;const U=new ResizeObserver(()=>{f.clientWidth&&(m.camera.aspect=f.clientWidth/f.clientHeight,m.camera.updateProjectionMatrix(),m.renderer.setSize(f.clientWidth,f.clientHeight),m.composer.setSize(f.clientWidth,f.clientHeight),m.bloom.resolution.set(f.clientWidth,f.clientHeight))});return U.observe(f),F(),()=>{cancelAnimationFrame(m.raf),U.disconnect(),S.domElement.removeEventListener("pointerdown",q),S.domElement.removeEventListener("pointerup",$),m.nodesMesh&&(m.nodesMesh.geometry.dispose(),m.nodesMesh.material.dispose()),m.connMesh&&(m.connMesh.geometry.dispose(),m.connMesh.material.dispose()),T.geometry.dispose(),T.material.dispose(),k.dispose(),S.dispose(),S.domElement.remove(),i.current=null}},[]),x.useEffect(()=>{const f=i.current;f&&(f.controls.autoRotate=!o&&!f.desired)},[o]),x.useEffect(()=>{const f=i.current;if(!f)return;const b=Gl(t);f.records=b,f.nodesMesh&&(f.scene.remove(f.nodesMesh),f.nodesMesh.geometry.dispose(),f.nodesMesh.material.dispose(),f.nodesMesh=null),f.connMesh&&(f.scene.remove(f.connMesh),f.connMesh.geometry.dispose(),f.connMesh.material.dispose(),f.connMesh=null);const y=a.current;if(y.innerHTML="",f.labels=b.map($=>{const K=document.createElement("div");return K.className="nmc-label3d",K.textContent=$.node.label,y.appendChild(K),K}),!b.length)return;const w=[],v=[],S=[],T=[],k=[];for(const $ of b){const K=Math.max(0,Math.min(1,$.node.salience??.5));w.push($.x,$.y,$.z);const U=p.deg.get($.id)??0;v.push($.node.primary?0:U<=1?1:0),S.push(1+K*1.6+($.node.primary?.6:0)),k.push(p.lvl.get($.id)??3);const B=dn(K);T.push(B.r,B.g,B.b)}const N=new _t;N.setAttribute("position",new ne(w,3)),N.setAttribute("nodeType",new ne(v,1)),N.setAttribute("nodeSize",new ne(S,1)),N.setAttribute("nodeColor",new ne(T,3)),N.setAttribute("distanceFromRoot",new ne(k,1)),f.nodesMesh=new En(N,new Me({uniforms:ln(),vertexShader:rn.vertexShader,fragmentShader:rn.fragmentShader,transparent:!0,depthWrite:!1,blending:Et})),f.scene.add(f.nodesMesh);const L=new Map(b.map($=>[$.id,$])),z=[],m=[],M=[],P=[],F=[],_=[];let O=0;for(const $ of t.links){const K=L.get(Ve($.source)),U=L.get(Ve($.target));if(!K||!U)continue;const B=dn(Math.max(0,Math.min(1,K.node.salience??.5))),W=typeof $.confidence=="number"?$.confidence:.7;for(let te=0;te<20;te++)z.push(te/19,0,0),m.push(K.x,K.y,K.z),M.push(U.x,U.y,U.z),_.push(O),P.pu
328sh(W),F.push(B.r,B.g,B.b);O++}const q=new _t;q.setAttribute("position",new ne(z,3)),q.setAttribute("startPoint",new ne(m,3)),q.setAttribute("endPoint",new ne(M,3)),q.setAttribute("connectionStrength",new ne(P,1)),q.setAttribute("connectionColor",new ne(F,3)),q.setAttribute("pathIndex",new ne(_,1)),f.connMesh=new zi(q,new Me({uniforms:ln(),vertexShader:on.vertexShader,fragmentShader:on.fragmentShader,transparent:!0,depthWrite:!1,blending:Et})),f.scene.add(f.connMesh),!f.desired&&!d.current&&(f.camera.position.set(0,3,32),f.controls.target.set(0,0,0),f.controls.update())},[t,p]);function j(f){const b=i.current;r(f);const y=b?.records.find(w=>w.id===f.id);y&&b.focusRec(y)}return e.jsxs("div",{className:"nmc-root nmc-3d",ref:l,children:[e.jsx(Fl,{nodes:t.nodes,onSelect:j}),e.jsx("button",{className:"nmc-fullscreen",onClick:h,"aria-label":c?"Exit fullscreen":"Enter fullscreen",title:c?"Exit fullscreen":"Fullscreen",children:c?e.jsx(Oi,{size:16}):e.jsx(Rn,{size:16})}),e.jsx("div",{className:"nmc-canvas",ref:n}),e.jsx("div",{className:"nmc-labels",ref:a,"aria-hidden":"true"}),e.jsx(Bl,{nodeCount:t.nodes.length,linkCount:t.links.length}),e.jsx(Nt,{children:o&&e.jsx($l,{node:o,detail:s?.get(o.id),related:g,onClose:()=>r(null),onSelectRelated:j})})]})}const Ql=40;function Yl(t,s,n){const a=t.slice().sort((c,u)=>(u.salience||0)-(c.salience||0)||c.id.localeCompare(u.id)).slice(0,Ql),i=Math.max(...a.map(c=>c.salience||0),1e-4),o=new Set(a.map(c=>c.id)),r=n&&o.has(n)?n:a[0]?.id,d=a.map((c,u)=>({id:c.id,label:c.name,routePath:c.type,headingPath:[c.type],url:c.url,text:c.description??c.name,byteLength:(c.description??"").length,order:u,val:1+(c.salience||0)/i*4,salience:c.salience||0,primary:c.id===r,mentions:c.mentions})),l=s.filter(c=>o.has(c.sourceEntityId)&&o.has(c.targetEntityId)&&c.sourceEntityId!==c.targetEntityId).map(c=>({source:c.sourceEntityId,target:c.targetEntityId,kind:"spine",relKind:c.kind,relLabel:c.label,confidence:c.confidence}));return{nodes:d,links:l}}function Jt(t,s,n){const a=t.get(s);a?a.push(n):t.set(s,[n])}function Jl(t,s,n,a){const i=new Map;for(const l of s)l.subjectEntityId&&Jt(i,l.subjectEntityId,l);const o=new Map;for(const l of n)l.subjectEntityId&&Jt(o,l.subjectEntityId,l);const r=new Map;for(const l of a)for(const c of l.entityIds)Jt(r,c,l.label);const d=new Map;for(const l of t){const c=l.aliases??[],u=r.get(l.id)??[],h=(i.get(l.id)??[]).slice().sort((g,j)=>(j.confidence??0)-(g.confidence??0)).map(g=>({text:g.text,kind:g.kind,sentiment:g.sentiment})),p=(o.get(l.id)??[]).map(g=>({value:g.valueRaw,label:g.label}));(c.length||u.length||h.length||p.length)&&d.set(l.id,{aliases:c,topics:u,claims:h,stats:p})}return d}function pa(t){try{return window.localStorage.getItem(t)}catch{return null}}function Xt(t,s){try{window.localStorage.setItem(t,s)}catch{}}function wt(t){try{window.localStorage.removeItem(t)}catch{}}class fa extends An.Component{constructor(s){super(s),this.state={error:null}}static getDerivedStateFromError(s){return{error:s}}componentDidCatch(s){console.error("[ContextMeM] render error:",s)}render(){return this.state.error?e.jsx("div",{className:"appErrorBoundary",children:e.jsxs("div",{className:"appErrorCard",children:[e.jsx("strong",{children:"Something went wrong rendering this view."}),e.jsx("p",{children:this.state.error.message}),e.jsxs("div",{className:"appErrorActions",children:[e.jsx("button",{type:"button",onClick:()=>this.setState({error:null}),children:"Try again"}),e.jsx("a",{href:"/app",children:"Back to Build"})]})]})}):this.props.children}}const Xl=!1,xa={fast:["markdown","sitemap"],balanced:["markdown","images","brand","styleguide","sitemap"],full:["markdown","images","brand","styleguide","sitemap","screenshots"]},hn=[{id:"fast",label:"Fast",detail:"Context first"},{id:"balanced",label:"Balanced",detail:"No screenshots"},{id:"full",label:"Full",detail:"Rich visual pass"}],Zl=[{id:"markdown",label:"markdown"},{id:"images",label:"images"},{id:"brand",label:"brand"},{id:"styleguide",label:"styleguide"},{id:"sitemap",label:"sitemap"},{id:"screenshots",label:"screenshots",detail:"slower/full"}],Zt=Bd(),ec="ContextMeM turns Walrus Sites into portable agent context with verified resources, markdown, assets, visual systems, onchain provenance, and Walrus Memory recall.",es=ec.split(" "),tc=["Walrus Sites",".wal.app","Sui object IDs","Walrus resources","Markdown","Design tokens","Screenshots","Walrus Memory"],sc=[{title:"Resolve",detail:"Resolve .wal.app names, Walrus object IDs, and fallback web URLs into a target map.",icon:st}
328,{title:"Verify",detail:"Check Sui provenance, Walrus blob IDs, hashes, routes, and resource metadata.",icon:_e},{title:"Package",detail:"Bundle markdown, screenshots, assets, design tokens, and resource manifests for agents.",icon:ke},{title:"Remember",detail:"Sync verified context into Walrus Memory for future agent recall.",icon:pe}],nc=[{eyebrow:"Resolve & verify",heading:"Resolve .wal.app names and Sui object IDs, then verify every blob.",highlights:[".wal.app","Sui","verify"],body:"Paste a name, an object ID, or a web URL. ContextMeM reads the onchain resources and checks every hash, route, and content type before trusting a byte.",image:{src:"/illustrations/resolve-verify-walrus-blobs.png",alt:"A hand-drawn walrus blob turns a resolver crank while .wal.app names and Sui object IDs move through blob verification into trusted context."}},{eyebrow:"Agent context",heading:"Package markdown, llms.txt, and design tokens agents can actually read.",highlights:["markdown","llms.txt","design tokens"],body:"Every run emits static, agent-readable artifacts â markdown, a resource manifest, screenshots â that you can inspect, diff, and download.",image:{src:"/illustrations/package-agent-context-black-walrus.png",alt:"A solid-black walrus worker packages markdown, llms.txt, manifests, screenshots, and design token swatches into an agent-ready artifact bundle."}},{eyebrow:"Walrus Memory",heading:"Remember verified context so agents recall it later.",highlights:["Remember","recall"],body:"Sync the certified context into Walrus Memory. Agents recall the pointer and re-fetch the real artifact, keyed by blobId.",image:{src:"/illustrations/walrus-memory-recall-black-walrus.png",alt:"A solid-black walrus worker stores only a blobId pointer in Walrus Memory so agents can recall and re-fetch the real artifact."}},{eyebrow:"Onchain provenance",heading:"Artifacts can be sealed with onchain Walrus proof.",highlights:["onchain","certified","Walrus"],body:"Tar the bundle, store it on Walrus through Tatum, and keep a verifiable blobId and digest for every run.",image:{src:"/illustrations/onchain-proof-black-walrus.png",alt:"A solid-black walrus worker seals a tar bundle through Tatum and Walrus storage, producing a certified blobId and digest receipt."}}],ac=[{tag:"Walrus Storage",title:"Real artifacts, kept on-chain",detail:"The tarred context bundle â manifest, llms.txt, markdown, proofs, screenshots â is uploaded via Tatum POST /v4/data/storage/upload and polled to CERTIFIED. Storage holds the bytes, keyed by blobId.",icon:xe,accent:"blue"},{tag:"Walrus Memory",title:"A recall-able index, not the bytes",detail:"Walrus Memory remembers only the semantic pointer: target, namespace, artifactDigest, blobId, jobId, and what changed. Agents recall it, then re-fetch the real artifact from storage.",icon:pe,accent:"accent"},{tag:"Tatum",title:"One gateway for storage + chain",detail:"A single Tatum API key powers the Walrus storage REST and Sui chain reads â and the same key drives the @tatumio/blockchain-mcp server so agents read blockchain data directly.",icon:$n,accent:"teal"}],ic="Import Walrus Memory SDK credentials",rc="Paste your Walrus Memory account ID and delegate private key. ContextMeM stores the delegate encrypted and unlocks verified Walrus context.",ft="https://memwal.ai/dashboard",kt={authenticated:!1,account:null,quota:{limit:1,used:0,remaining:0},access:{canPreview:!0,canRun:!1,reason:"Import Walrus Memory SDK credentials for verified recall and memory."}};function oc(){return e.jsx(Bi,{children:e.jsx(lc,{})})}function lc(){const t=mt(),[s,n]=x.useState(Zt.target),[a,i]=x.useState(""),[o,r]=x.useState(""),[d,l]=x.useState(Zt.mode),[c,u]=x.useState("balanced"),[h,p]=x.useState(xa.balanced),[g,j]=x.useState(null),[f,b]=x.useState(null),[y,w]=x.useState([]),[v,S]=x.useState("Markdown"),[T,k]=x.useState(!1),[N,L]=x.useState(!1),[z,m]=x.useState(null),[M,P]=x.useState(""),[F,_]=x.useState(null),[O,q]=x.useState(null),[$,K]=x.useState(null),[U,B]=x.useState(kt),[W,te]=x.useState(()=>pa("contextmem.session")??""),[ae,ie]=x.useState(""),[X,se]=x.use
328State("");x.useEffect(()=>{if(typeof window>"u")return;const E=new URLSearchParams(window.location.search),C=E.get("memwalAccountId")??E.get("delegateAccountId"),R=E.get("memwalDelegateKey")??E.get("delegateKey");if(!C&&!R)return;C&&ie(C),R&&se(R);const I=window.location.pathname+window.location.hash;window.history.replaceState({},"",I),window.location.pathname.startsWith("/app/settings")||t("/app/settings")},[t]);const A=x.useRef(!1),re=x.useRef(null),Ae=x.useRef(null),[$t,jt]=x.useState({x:0,y:0}),[Oa,Fa]=x.useState(0),zt="mainnet",ue=!!(U.authenticated&&U.account?.hasDelegateKey),Rs=!!ue,As=!0,it=!le(D),Ot=U.authenticated?U.quota.unlimited?"full":`${U.quota.remaining}/${U.quota.limit}`:"import",Ba=T?"Running":ue?"Build context":"Import credentials",Wa=T?"Running":ue?"Build":"Import",Is=x.useMemo(()=>[{label:"Pages",value:f?.pages?.length??g?.pages??g?.walrus?.pages??0,icon:It},{label:"Images",value:f?.images?.length??0,icon:In},{label:"Resources",value:f?.walrus?.resources.length??g?.walrus?.resources??0,icon:ke},...f?.discovery?[{label:"Discovery",value:`${f.discovery.pagesEmitted}/${f.discovery.totalCandidates}`,icon:st}]:[],{label:"Namespace",value:g?.manifest.namespace??"not synced",icon:xe}],[f,g]),Ua=x.useMemo(()=>[{label:"mode",value:d,icon:He},{label:"network",value:zt,icon:Xe},{label:"quota",value:Ot,icon:_e}],[d,Ot,zt]);x.useEffect(()=>{const E=new URLSearchParams(window.location.search),C=E.get("contextmem_session"),R=E.get("memwal");if(C){Xt("contextmem.session",C),te(C),P("Walrus Memory connected. ContextMeM session restored."),q({tone:"success",message:"Walrus Memory connected. SDK delegate is ready for ContextMeM."}),E.delete("contextmem_session"),E.delete("memwal");const I=E.toString();window.history.replaceState({},"",`${window.location.pathname}${I?`?${I}`:""}${window.location.hash}`)}else R&&R!=="connected"&&q({tone:"warning",message:`Walrus Memory auth did not finish: ${R.replaceAll("_"," ")}.`})},[]),x.useEffect(()=>{!Zt.autorun||A.current||!s||!Rs||(A.current=!0,Ft())},[Rs]),x.useEffect(()=>{Ds(W)},[W]),x.useEffect(()=>{U.authenticated?rt():w([])},[U.authenticated,W]),x.useEffect(()=>{const E=Ae.current;if(!E)return;let C=0;const R=()=>{C=0;const H=E.getBoundingClientRect(),Z=window.innerHeight*.9,De=window.innerHeight*.52,Le=Math.min(1,Math.max(0,(Z-H.top)/(Z-De)));Fa(Le)},I=()=>{C||(C=requestAnimationFrame(R))};return window.addEventListener("scroll",I,{passive:!0}),window.addEventListener("resize",I),R(),()=>{window.removeEventListener("scroll",I),window.removeEventListener("resize",I),C&&cancelAnimationFrame(C)}},[]);function Ha(E){if(!re.current||window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const C=re.current.getBoundingClientRect(),R=((E.clientX-C.left)/C.width-.5)*34,I=((E.clientY-C.top)/C.height-.5)*34;jt({x:R,y:I})}function qa(){jt({x:0,y:0})}function Ie(E="/app"){t(E),window.requestAnimationFrame(()=>window.scrollTo({top:0,behavior:"smooth"}))}async function Ds(E=W){if(it){const C=Da();if(C){B(Cn(C));return}B(kt);return}try{const C=await fetch(`${D}/api/me`,{headers:G(E)});if(!C.ok)throw new Error(await Q(C));const R=await C.json();B(R),R.authenticated||(wt("contextmem.session"),te(""))}catch{B(kt),wt("contextmem.session"),E&&te("")}}function Ls(){wt("contextmem.session"),wt("contextmem.hostedDelegate"),te(""),B(kt),j(null),b(null),w([]),q(null)}async function Ka(){if(!U.authenticated){const E="Import Walrus Memory SDK credentials first, then local MCP credentials can be attached in dev mode.";P(E),q({tone:"info",message:E});return}L(!0),m(null),q(null);try{const E=await fetch(`${D}/api/memwal/connect`,{method:"POST",headers:G(W,{"content-type":"application/json"}),body:JSON.stringify({mode:"local"})});if(!E.ok)throw new Error(await Q(E));const C=await E.json();if(C.imported&&C.me){B(C.me),P("Local Walrus Memory MCP credentials attached for dev. Delegate key stays server-side."),q({tone:"success",message:"Local Walrus Memory MCP credentials attached for dev. Delegate key stays encrypted on the ContextMeM API."});return}const R=C.commands?.[0],I=C.status==="account-mismatch"||C.status==="credentials-invalid"?"warning":"info";q({tone:I,message:C.message,command:R}),P(R?`Local MCP dev attach needs Walrus Memory MCP login. Copy/run: ${R}`:C.message)}catch(E){const C=E instanceof Error?E.message:String(E);m(C),q({tone:"warning",message:C})}finally{L(!1)}}async function $s(){const E=Sn(ae),C=Sn(X).replace(/^0x/i,"");if(!E){const R="Paste your Walrus Memory account ID.";m(R),q({tone:"warning",message:R});return}if(!/^[0-9a-fA-F]{64}$/.test(C)){const I=`Delegate private key must be a 64-character hex Ed25519 seed â ${C.length===0?"the field is empty":C.length!==64?`after cleaning it's ${C.length} characters, not 64`:`it has a non-hex character (cleaned value starts "${C.slice(0,6)}â¦")`}. Re-copy the delegate SEED (not the account ID) from your Walrus Memory dashboard. 0x, space
328s, and line breaks are removed automatically.`;m(I),q({tone:"warning",message:I});return}if(it){try{Xt("contextmem.hostedDelegate",JSON.stringify({memwalAccountId:E,delegateKey:C}))}catch(R){const I=R instanceof Error?R.message:"Could not persist delegate to browser storage.";m(I),q({tone:"warning",message:I});return}B(Cn({memwalAccountId:E})),ie(""),se(""),P("Walrus Memory delegate stored for this browser session and sent to the hosted API only when you run private ContextMeM requests."),q({tone:"success",message:"Delegate ready on the hosted app. The Worker accepts it for prod testing and does not persist the private key server-side."});return}L(!0),m(null);try{const R=await fetch(`${D}/api/memwal/import-delegate`,{method:"POST",headers:W?G(W,{"content-type":"application/json"}):{"content-type":"application/json"},body:JSON.stringify({memwalAccountId:E,delegateKey:C})});if(!R.ok)throw new Error(await Q(R));const I=await R.json(),H="me"in I?I.me:I;"token"in I&&(Xt("contextmem.session",I.token),te(I.token)),B(H),ie(""),se(""),P("Walrus Memory delegate imported. ContextMeM will use it server-side."),q({tone:"success",message:"SDK credentials imported. The delegate key was sent once and is stored encrypted server-side."})}catch(R){const I=R instanceof Error?R.message:String(R);m(I),q({tone:"warning",message:I})}finally{se(""),L(!1)}}async function rt(){if(W)try{const E=await fetch(`${D}/api/runs?limit=25`,{headers:G(W)});E.ok&&w(await E.json())}catch{}}async function Ga(E){k(!0),m(null);try{const[C,R]=await Promise.all([fetch(`${D}/api/runs/${E}`,{headers:G(W)}),fetch(`${D}/api/runs/${E}/artifacts`,{headers:G(W)})]);if(!C.ok)throw new Error(await Q(C));if(!R.ok)throw new Error(await Q(R));const I=await C.json(),H=await R.json();j({manifest:I}),b(H),n(I.target),I.buildProfile&&u(I.buildProfile),I.outputs?.length&&p(I.outputs),S(H.designSystem?"Design System":"Markdown")}catch(C){m(C instanceof Error?C.message:String(C))}finally{k(!1)}}async function Ft(){if(!ue){m("Import Walrus Memory SDK credentials before building context.");return}if(it){await Va();return}k(!0),m(null),j(null),b(null);try{const E=await fetch(`${D}/api/runs`,{method:"POST",headers:G(W,{"content-type":"application/json"}),body:JSON.stringify({target:s,mode:d,network:zt,buildProfile:c,outputs:h,background:!0,crawlOptions:{maxPages:12,maxDepth:2,includeImages:h.includes("images"),includeLinks:!0,concurrency:6}})});if(!E.ok)throw new Error(await Q(E));const C=await E.json();j(C);const R=C.manifest.status==="completed"?C.manifest:await Qa(C.manifest.runId);j({manifest:R});const I=await fetch(`${D}/api/runs/${R.runId}/artifacts`,{headers:G(W)});if(I.ok){const H=await I.json();b(H),S(H.designSystem?"Design System":H.walrus?"Walrus Resources":"Markdown")}else C.walrus&&S("Walrus Resources");await Promise.allSettled([rt(),Ds(W)])}catch(E){m(E instanceof Error?E.message:String(E))}finally{k(!1)}}async function Va(){const E=s.trim();if(!E){m("Paste a Walrus Site URL, Walrus object ID, or public web URL.");return}k(!0),m(null),j(null),b(null);try{const C=await fetch(`${D}/api/demo/extractions`,{method:"POST",headers:{"content-type":"application/json",...ut()},body:JSON.stringify({target:E,...a.trim()?{namespace:a.trim()}:{},...o.trim()?{displayName:o.trim()}:{}})});if(!C.ok)throw new Error(await Q(C));let R=await C.json();const I=R.job.id;for(let Ws=0;Ws<200&&(R.job.status==="queued"||R.job.status==="running");Ws+=1){await rs(900);const Ut=await fetch(`${D}/api/demo/extractions/${encodeURIComponent(I)}`);if(!Ut.ok)throw new Error(await Q(Ut));const Ht=await Ut.json();R={job:"job"in Ht?Ht.job:Ht}}if(R.job.status==="failed")throw new Error(R.job.error??"Hosted context build failed.");if(R.job.status!=="completed"){m(null),P(`Still building ${R.job.namespace} â large multi-page sites can take a few minutes. It keeps building in the background and will appear under Runs and Memory when ready.`);return}const Z=(R.job.result??{}).share?.id;if(!Z)throw new Error("Hosted build completed without a share artifact.");const[De,Le]=await Promise.all([fetch(`${D}/api/share-links/${encodeURIComponent(Z)}`),fetch(`${D}/api/share-links/${encodeURIComponent(Z)}/artifacts`)]);if(!De.ok)throw new Error(await Q(De));const $e=(await De.json()).manifest;$e&&(b($e),S($e.designSystem?"Design System":$e.walrus?"Walrus Resources":"Markdown"),j({manifest:{runId:R.job.id,target:R.job.target,namespace:R.job.namespace,artifactDir:`share/${Z}`,mode:R.job.target.includes(".wal.app")?"walrus":"web",status:"completed",pages:$e.pages?.length??0,images:$e.images?.length??0,resources:$e.walrus?.resources?.length??0,errors:[],updatedAt:new Date().toISOString(),walrus:$e.walrus}}));const Za=`${window.location.origin}/share/${Z}`,ei=`${le(D)?window.location.origin:D}/mcp?namespace=${encodeURIComponent(R.job.namespace)}`;_({shareId:Z,namespace:R.job.namespace,shareUrl:Za,mcpUrl:ei}),P("Hosted build complete. Public share + MCP endpoint below."),Le.ok}catch(C){m(C instanceof Error?C.message:String(C))}finally{k(!1)}}async function Qa(E){try{const C=await Td(E,W,R=>{j(I=>!I||I.manifest.runId!==E?I:{manifest:{...I.manifest,status:R.status,progress:R.progress??I.manifest.progress,updatedAt:R.updatedAt??I.manifest.updatedAt}})});if(C.status==="completed")return C;if(C.status==="failed")throw new Error(C.errors?.[0]??"Context build failed.")}catch{}for(let C=0;C<360;C+=1){await rs(650);const R=await fetch(`${D}/api/runs/${E}`,{headers:G(W)});if(!R.ok)throw new Error(await Q(R));const I=await R.json();if(j({manifest:I}),I.status==="completed")return I;if(I.status==="failed")throw new Error(I.errors?.[0]??"Context build failed.")}throw new Error("Build is taking longer than expected â it may still finish; check Runs in a moment.")}async function zs(){if(g){if(it){q({tone:"info",message:"This run's verified context is already stored and answerable here â use Recall or Memory query above, or the MCP namespace shown in the result. Writing it into the Walrus Memory vector store runs on local ContextMeM (rolling out to the hosted site)."});return}if(!ue){m("Import Walrus Memory SDK credentials before remembering context.");return}k(!0),m(null);try{const E=await fetch(`${D}/api/runs/${g.manifest.runId}/memwal/remember`,{method:"POST",headers:G(W)});if(!E.ok)throw new Error(await Q(E));const C=await E.json();m(`Walrus Memory remembered namespace: ${C.namespace}`)}catch(E){const C=E instanceof Error?E.message:String(E);m(Ed(C)?`Walrus Memory unavailable: ${C}`:C)}finally{k(!1)}}}async function Bt(E){await Ga(E),Ie("/app/artifacts")}async function Ya(){if(!ue){if(le(D)){Ie("/app");return}await Wt();return}Ie("/app"),await Ft()}async function Wt(){const E=s.trim(),C=E||"curated Walrus Site sample";k(!0),m(null),P(""),K({phase:"starting",target:C,message:"Starting hosted preview",updatedAt:Date.now()});let R=null;try{const I=await fetch(`${D}/api/demo/extractions`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({target:E||void 0,sample:!E})});if(!I.ok)throw new Error(await Q(I));let H=await I.json();R=H.job,K(pn(H.job,C));for(let De=0;De<200&&(H.job.status==="queued"||H.job.status==="running");De+=1){await rs(900);const Le=await fetch(`${D}/api/demo/extractions/${encodeURIComponent(H.job.id)}`);if(!Le.ok)throw new Error(await Q(Le));H=await Le.json(),R=H.job,K(pn(H.job,C))}if(H.job.status==="failed")throw new Error(H.job.error??"Context build failed.");const Z=H.job.result?.share?.id;if(Z){K({phase:"completed",target:H.job.target||C,jobId:H.job.id,shareId:Z,message:"Preview ready. Opening share page",updatedAt:Date.now()}),t(`/share/${Z}`),window.requestAnimationFrame(()=>window.scrollTo({top:0,behavior:"smooth"}));return}if(H.job.status==="queued"||H.job.status==="running"){K({phase:"queued",target:H.job.target||C,jobId:H.job.id,message:"Still building â larger sites take a couple of minutes. Your share page will be ready shortly; reload or check Runs.",updatedAt:Date.now()}),P("Still building on the Worker â larger sites take a couple of minutes. The share page will appear shortly.");return}throw new Error(H.job.error??"Demo extraction finished without a share page.")}catch(I){const H=I instanceof Error?I.message:String(I),Z=H.includes("DEMO_PLACEHOLDER_HOST")?"That looks like a placeholder URL (example.com). Try a real Walrus Site â e.g. https://fmsprint.wal.app/ â or a public product URL.":H;K({phase:"failed",target:R?.target||C,jobId:R?.id,message:Z,updatedAt:Date.now()}),P(Z),m(Z)}finally{k(!1)}}const Os=ue?"Walrus Memory ready":"Walrus Memory import needed",Fs=ue?"ready":"needsMemWal",Bs=U.authenticated?e.jsxs("button",{className:"sessionButton",onClick:Ls,children:[e.jsx(Dn,{size:15}),ye(U.account?.memwalAccountId??U.account?.ownerAddress??"")]}):null,Ja=e.jsx(nd,{authenticated:U.authenticated,authBusy:N,notice:O,delegateAccountId:ae,delegateKey:X,setDelegateAccountId:ie,setDelegateKey:se,onImport:$s,canImportSdkCredentials:As,previewBusy:T,onPreviewDemo:Wt,target:s,setTarget:n}),Xa=e.jsx(Ac,{target:s,setTarget:n,mode:d,setMode:l,buildProfile:c,setBuildProfile:u,outputs:h,setOutputs:p,busy:T,error:z,run:g,artifact:f,stats:Is,activeTab:v,setActiveTab:S,setArtifact:b,history:y,refreshHistory:rt,authToken:W,accountLabel:U.account?.memwalAccountId??U.account?.ownerAddress??"",primaryActionLabel:Ba,onStartRun:Ft,onRemember:zs,onOpenRun:Bt,hasMemWalDelegate:ue,hostedBuildResult:F,customNamespace:a,setCustomNamespace:i,customDisplayName:o,setCustomDisplayName:r,isHostedApiBase:it,notice:O});function Se(E,C,R,I=!1){const H=e.jsxs(e.Fragment,{children:[$?e.jsx(Nc,{preview:$,onBackHome:()=>Ie("/")}):null,Ja]}),Z=I||ue;return e.jsx(bc,{pageTitle:E,pageDescription:C,statusLabel:Os,statusTone:Fs,authHint:M,sessionSlot:Bs,hasMemWalDelegate:ue,previewUnlocked:I,run:g,children:Z?e.jsx(fa,{children:R}):H})}return e.jsxs(e.Fragment,{children:[e.jsxs(Wi,{children:[e.jsx(he,{path:"/",element:e.jsx(Tc,{target:s,setTarget:n,busy:T,demoPreview:$,hasMemWalDelegate:ue,compactPrimaryActionLabel:Wa,statusLabel:Os,statusTone:Fs,sessionSlot:Bs,authHint:M,heroRef:re,heroOffset:$t,headlineRef:Ae,headlineProgress:Oa,heroMetrics:Ua,onHeroMouseMove:Ha,onHeroMouseLeave:qa,onHeroAction:Ya,onOpenApp:()=>Ie("/app/home"),onImportDelegate:()=>
328Ie("/app/settings"),onInspectArtifacts:()=>Ie("/app/artifacts"),onOpenHistory:()=>Ie("/app/runs")})}),e.jsx(he,{path:"/share/:shareId",element:e.jsx(dc,{})}),e.jsx(he,{path:"/showcase",element:e.jsx(jc,{})}),e.jsx(he,{path:"/app/home",element:Se("Overview","Everything you've resolved, verified and published across the mainnet.",e.jsx(xd,{history:y}),!0)}),e.jsx(he,{path:"/app",element:Se("Build console","Resolve a Walrus Site, verify resources, then generate a context package.",Xa)}),e.jsx(he,{path:"/app/artifacts",element:Se("Artifacts","Open a verified context package to browse its knowledge graph, facts, and Walrus proof.",e.jsx(Ic,{stats:Is,run:g,artifact:f,authToken:W,setArtifact:b,history:y,accountLabel:U.account?.memwalAccountId??U.account?.ownerAddress??"",onOpenRun:Bt,busy:T}))}),e.jsx(he,{path:"/app/runs",element:Se("Runs","Verified context packages â open one to browse its knowledge graph, facts, and Walrus proof.",e.jsx(Dc,{history:y,busy:T,currentRunId:g?.manifest.runId,onRefresh:rt,onOpenRun:Bt}))}),e.jsx(he,{path:"/app/memory",element:Se("Walrus Memory","Recall and remember verified context namespaces from the active package.",e.jsx(Bc,{artifact:f,run:g,history:y,refreshHistory:rt,authToken:W,onRemember:zs,busy:T,notice:O}),!0)}),e.jsx(he,{path:"/app/compare",element:Se("Compare","Pick two runs and review brand, design tokens, and key facts side-by-side.",e.jsx(pd,{history:y,authToken:W}))}),e.jsx(he,{path:"/app/publish",element:Se("Publish","Check readiness and copy the commands needed to publish the context package.",e.jsx(_a,{run:g,authToken:W}))}),e.jsx(he,{path:"/app/namespaces",element:Se("Namespaces","Verified context namespaces â open one to browse its knowledge graph.",e.jsx(gd,{}),!0)}),e.jsx(he,{path:"/app/settings",element:Se("Settings",le(D)?"Manage Walrus Memory delegate status and encrypted server-side credentials.":"Manage Walrus Memory delegate status for hosted prod testing.",e.jsx(Wc,{me:U,quotaLabel:Ot,hasMemWalDelegate:ue,authBusy:N,delegateAccountId:ae,delegateKey:X,setDelegateAccountId:ie,setDelegateKey:se,onImport:$s,notice:O,canImportSdkCredentials:As,previewBusy:T,onPreviewDemo:Wt,showDevMemWalAuth:Xl,onAttachLocalMemWal:Ka,onLogout:Ls}))}),e.jsx(he,{path:"*",element:e.jsx(Ui,{to:"/",replace:!0})})]}),e.jsx(yc,{ownerId:U.account?.id})]})}const cc=[{to:"/app",label:"Build",icon:Ue,end:!0},{to:"/app/artifacts",label:"Artifacts",icon:pt},{to:"/app/runs",label:"Runs",icon:nt},{to:"/app/memory",label:"Memory",icon:pe},{to:"/app/namespaces",label:"Namespaces",icon:xe},{to:"/app/settings",label:"Settings",icon:Yi}],mn=[["Markdown",It],["Structure",Hi],["Facts",pe],["Images",In],["Brand",Xe],["Design System",qi],["AI Query",Ee],["Walrus Resources",ke]];function dc(){const{shareId:t=""}=Qi(),[s,n]=x.useState(null),[a,i]=x.useState([]),[o,r]=x.useState(null);x.useEffect(()=>{t&&d()},[t]),x.useEffect(()=>{if(!t)return;const g=`${D}/api/share-links/${encodeURIComponent(t)}/og.svg`,j=[];function f(b,y,w,v){let S=document.head.querySelector(b);S||(S=document.createElement("meta"),S.setAttribute(y,w),document.head.appendChild(S),j.push(S)),S.content=v}return f('meta[property="og:image"]',"property","og:image",g),f('meta[property="og:type"]',"property","og:type","article"),f('meta[name="twitter:card"]',"name","twitter:card","summary_large_image"),f('meta[name="twitter:image"]',"name","twitter:image",g),()=>{j.forEach(b=>b.remove())}},[t]);async function d(){r(null);try{const[g,j]=await Promise.all([fetch(`${D}/api/share-links/${encodeURIComponent(t)}`),fetch(`${D}/api/share-links/${encodeURIComponent(t)}/artifacts`)]);if(!g.ok)throw new Error(await Q(g));if(!j.ok)throw new Error(await Q(j));n(await g.json()),i((await j.json()).artifacts??[])}catch(g){r(g instanceof Error?g.message:String(g))}}const l=s?.manifest,c=s?.share,u=l?.pages??[],h=l?.walrus?.resources??[],p=l?.screenshots?.filter(g=>g.status==="captured")??[];return e.jsxs("main",{className:"sharePage",children:[e.jsxs("header",{className:"shareTopbar",children:[e.jsxs(ge,{className:"appBrand",to:"/",children:[e.jsx("span",{className:"appBrandMark",children:e.jsx(Te,{size:18})}),e.jsxs("span",{children:[e.jsx("strong",{children:"ContextMeM"}),e.jsx("small",{children:"Public context share"})]})]}),e.jsxs(ge,{className:"heroGhost",to:"/",children:[e.jsx(On,{size:16}),"Home"]})]}),o?e.jsxs("section",{className:"shareHero panel errorState",children:[e.jsx(We,{size:24}),e.jsx("h1",{children:"Share not available"}),e.jsx("p",{children:o})]}):!s||!c?e.jsxs("section",{className:"shareHero panel",children:[e.jsx(oe,{size:24}),e.jsx("h1",{children:"Loading shared context"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"shareHero",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Shareable run"}),e.jsx("h1",{children:c.title??je(c.target)}),e.jsx("p",{children:c.description??"Redacted public ContextMeM package with artifacts, screenshots, and an MCP entrypoint for agents."}),e.jsxs("div",{className:"shareActions",children:[e.jsxs("a",{href:c.mcpUrl,target:"_blank",rel:"noreferrer",children:[e.jsx(Te,{size:16}),"MCP endpoint"]}),e.jsxs("button",{onClick:()=>navigator.clipboard.writeText(c.mcpUrl),children:[e.jsx(me,{size:15}),"Copy MCP URL"]})]})]}),e.jsxs("aside",{children:[e.jsxs("div",{children:[e.jsx("span",{children:"pages"}),e.jsx("strong",{children:u.length})]}),e.jsxs("div",{children:[e.jsx("span",{children:"artifacts"}),e.jsx("strong",{children:c.artifactCount})]}),e.jsxs("div",{children:[e.jsx("span",{children:"resources"}),e.jsx("strong",{children:h.length})]}),e.jsxs("div",{children:[e.jsx("span",{children:"screenshots"}),e.jsx("strong",{children:p.length})]})]})]}),l?e.jsx(uc,{manifest:l,artifacts:a,mcpUrl:c.mcpUrl,namespace:c.namespace,shareId:t}):null]})]})}function uc({manifest:t,artifacts:s,mcpUrl:n,namespace:a,shareId:i}){const o=x.useMemo(()=>{const l=[];return t.pages?.length&&l.push({key:"markdown",label:"Markdown",count:t.pages.length}),t.siteStructure?.nodes?.length&&l.push({key:"structure",label:"Structure"}),t.facts&&l.push({key:"facts",label:"Facts"}),t.images?.length&&l.push({key:"images",label:"Images",count:t.images.length}),t.brand&&l.push({key:"brand",label:"Brand"}),(t.designSystem||t.styleguide)&&l.push({key:"design",label:"Design System"}),t.codeBlocks?.length&&l.push({key:"code",label:"Code Blocks",count:t.codeBlocks.length}),t.aiQuery&&l.push({key:"ai",label:"AI Summary"}),t.walrus?.resources?.length&&l.push({key:"walrus",label:"Walrus Resources",count:t.walrus.resources.length}),l.push({key:"artifacts",label:"Artifacts",count:s.length}),l.push({key:"mcp",label:"MCP install"}),l},[t,s]),[r,d]=x.useState(o[0]?.key??"markdown");return e.jsxs("section",{className:"shareContent panel",children:[e.jsx("nav",{className:"shareTabs",role:"tablist","aria-label":"Share content sections",children:o.map(l
328=>e.jsxs("button",{role:"tab","aria-selected":r===l.key,className:r===l.key?"selected":"",onClick:()=>d(l.key),type:"button",children:[l.label,typeof l.count=="number"?e.jsx("span",{className:"shareTabBadge",children:l.count}):null]},l.key))}),e.jsxs("div",{className:"shareTabBody",children:[r==="markdown"?e.jsx(ba,{pages:t.pages,namespace:a}):null,r==="structure"?e.jsx(hc,{structure:t.siteStructure}):null,r==="facts"?e.jsx(_s,{facts:t.facts}):null,r==="images"?e.jsx(mc,{manifest:t}):null,r==="brand"?e.jsx(Ea,{data:t.brand}):null,r==="design"?e.jsx(pc,{manifest:t}):null,r==="code"?e.jsx(fc,{codeBlocks:t.codeBlocks??[]}):null,r==="ai"?e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"AI Summary"}),e.jsx("span",{children:t.aiQuery?.usedProvider??"stored"})]}),t.aiQuery?e.jsx(Ms,{data:t.aiQuery.data}):e.jsx("p",{className:"subEmpty",children:"No AI summary on this run."})]}):null,r==="walrus"?e.jsx(Ra,{data:t.walrus}):null,r==="artifacts"?e.jsx(xc,{artifacts:s,shareId:i}):null,r==="mcp"?e.jsx(gc,{mcpUrl:n,namespace:a}):null]})]})}function hc({structure:t}){return t?e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Site structure"}),e.jsxs("span",{children:[t.summary.pages," pages · ",t.summary.assets," assets · ",t.summary.walrusResources," Walrus resources"]})]}),e.jsx(ga,{nodes:t.nodes,depth:0})]}):e.jsx("div",{className:"panel subEmpty",children:"No site structure captured."})}function ga({nodes:t,depth:s}){return e.jsx("ul",{className:"shareStructureTree",style:{paddingLeft:s===0?0:16},children:t.map(n=>e.jsxs("li",{children:[e.jsx("strong",{children:n.label}),n.path?e.jsx("code",{children:n.path}):null,e.jsx("span",{className:"shareStructureKind",children:n.kind}),n.children?.length?e.jsx(ga,{nodes:n.children,depth:s+1}):null]},n.id))})}function mc({manifest:t}){return t.images?.length?e.jsx("div",{className:"grid",children:t.images.map((s,n)=>{const a=La(s,t),i=$a(s,t);return e.jsxs("article",{className:"imageCard",children:[e.jsx("div",{className:"imagePreview",children:a?e.jsx("img",{src:a,alt:s.alt??s.role??s.type??"Extracted image",loading:"lazy"}):e.jsx("span",{children:s.type??"asset"})}),e.jsxs("div",{className:"imageMeta",children:[e.jsx("strong",{children:s.role??s.contentType??s.type??"image"}),s.alt?e.jsx("span",{children:s.alt}):null,e.jsx("code",{children:i})]})]},`${s.absoluteUrl}-${n}`)})}):e.jsx("div",{className:"panel subEmpty",children:"No images extracted."})}function pc({manifest:t}){const s=t.designSystem,n=t.styleguide;if(!s&&!n)return e.jsx("div",{className:"panel subEmpty",children:"No design tokens captured."});const a=s?.tokens.colors??(n?.colors.palette??[]).map((u,h)=>({name:`color-${h}`,value:u,role:"raw"})),i=s?.tokens.typography.fontFamilies??n?.typography.fontFamilies??[],o=s?.tokens.spacing??[],r=s?.tokens.radii??[],d=s?Object.keys(s.tokens.cssVariables??{}).length:0,l=s?.identity.confidence,c=typeof l=="number"?l>=.66?"high":l>=.33?"partial":"framework-only":null;return e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Design tokens"}),e.jsxs("span",{children:[a.length," colors · ",i.length," font families",d?` · ${d} :root vars`:""]})]}),s?.framework?e.jsxs("small",{className:"frameworkBadge",title:`${s.framework.defaultsSubtracted} framework defaults filtered out`,children:["Built on ",s.framework.name," â ",s.framework.defaultsSubtracted," defaults filtered"]}):null,c?e.jsx("div",{style:{marginTop:8},children:e.jsxs("small",{style:{color:l>=.66?"#16a34a":l>=.33?"#d97706":"#94a3b8",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.04em"},children:["confidence: ",Math.round((l??0)*100),"% · ",c]})}):null,a.length===0?e.jsxs("div",{className:"tabEmptyState",style:{marginTop:12},children:[e.jsx("strong",{children:"No brand-distinct colors detected"}),e.jsx("p",{children:s?.framework?`This site uses ${s.framework.name}; its default tokens were filtered out and nothing brand-distinct remained.`:"Inline CSS contained only framework or system defaults."})]}):e.jsx("div",{className:"comparePalette",style:{marginTop:12},children:a.slice(0,24).map(u=>e.jsx("span",{style:{background:u.value},title:`${u.name} â ${u.value}`,children:e.jsx("small",{children:u.name})},`${u.name}-${u.value}`))}),i.length>0?e.jsx("div",{className:"compareFonts",style:{marginTop:12},children:i.slice(0,8).map(u=>e.jsx("code",{children:u},u))}):null,o.length>0?e.jsxs("div",{style:{marginTop:12},children:[e.jsx("strong",{style:{fontSize:12,textTransform:"uppercase",letterSpacing:"0.04em",color:"#64748b"},children:"Spacing (raw)"}),e.jsx("div",{className:"compareFonts",style:{marginTop:6},children:o.slice(0,12).map(u=>e.jsx("code",{children:u},u))})]}):null,r.length>0?e.jsxs("div",{style:{marginTop:8},children:[e.jsx("strong",{style:{fontSize:12,textTransform:"uppercase",letterSpacing:"0.04em",color:"#64748b"},children:"Radii (raw)"}),e.jsx("div",{className:"compareFonts",style:{marginTop:6},children:r.slice(0,8).map((u,h)=>e.jsx("code",{children:u},`${u}-${h}`))})]}):null]})}function fc({codeBlocks:t}){const[s,n]=x.useState("all"),a=x.useMemo(()=>{const o=new Set;for(const r of t)o.add(r.language||"text");return Array.from(o).sort()},[t]),i=s==="all"?t:t.filter(o=>(o.language||"text")===s);return t.length?e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Code Blocks"}),e.jsxs("span",{children:[t.length," snippets across ",a.length," language",a.length===1?"":"s"]})]}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:12},children:[e.jsxs("button",{type:"button",className:s==="all"?"primary":"secondary",onClick:()=>n("all"),children:["All (",t.length,")"]}),a.map(o=>{const r=t.filter(d=>(d.language||"text")===o).length;return e.jsxs("button",{type:"button",className:s===o?"primary":"secondary",onClick:()=>n(o),children:[o," (",r,")"]},o)})]}),e.jsxs("div",{style:{display:"grid",gap:12},children:[i.slice(0,60).map((o,r)=>
328e.jsxs("article",{className:"page",style:{padding:0},children:[e.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid #e5eaf1",display:"flex",justifyContent:"space-between",gap:12,alignItems:"baseline",flexWrap:"wrap"},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsx("strong",{style:{fontSize:12,textTransform:"uppercase",letterSpacing:"0.05em",color:"#0f1115"},children:o.language||"text"}),o.parentHeading?e.jsxs("span",{style:{marginLeft:8,color:"#64748b",fontSize:12},children:["· ",o.parentHeading]}):null]}),e.jsx("small",{style:{color:"#64748b",fontSize:11,overflowWrap:"anywhere"},children:o.routePath??o.pageUrl})]}),e.jsx("pre",{style:{margin:0,padding:12,background:"#0f1115",color:"#f1f5f9",overflowX:"auto",fontSize:12,lineHeight:1.5,maxHeight:320},children:e.jsx("code",{children:o.snippet})})]},`${o.pageUrl}-${r}`)),i.length>60?e.jsxs("small",{style:{color:"#64748b"},children:["(+",i.length-60," more snippets â install MCP and use list_context / read_context to access /context/code-blocks.json directly)"]}):null]})]}):e.jsx("div",{className:"panel subEmpty",children:"No code blocks detected in extracted pages."})}function xc({artifacts:t,shareId:s}){const[n,a]=x.useState(null),[i,o]=x.useState({}),[r,d]=x.useState(null);async function l(c){if(n===c.path){a(null);return}if(a(c.path),!i[c.path]&&c.previewable){d(c.path);try{const u=`${D}/api/share-links/${encodeURIComponent(s)}/file?path=${encodeURIComponent(c.path)}`,h=await fetch(u);if(!h.ok)throw new Error(await Q(h));const p=await h.text();o(g=>({...g,[c.path]:p.slice(0,3e4)}))}catch(u){o(h=>({...h,[c.path]:u instanceof Error?`(failed: ${u.message})`:"(failed to load)"}))}finally{d(null)}}}return e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Artifacts"}),e.jsxs("span",{children:[t.length," files · click to preview"]})]}),e.jsx("div",{className:"shareArtifactList",children:t.map(c=>e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>{l(c)},className:"shareArtifactRow",children:[e.jsx(It,{size:14}),e.jsx("code",{children:c.path}),e.jsx("span",{children:c.kind})]}),n===c.path?e.jsx("pre",{className:"shareArtifactPreview",children:r===c.path?"Loadingâ¦":i[c.path]??"(no preview)"}):null]},c.path))})]})}function gc({mcpUrl:t,namespace:s}){const n=s.replace(/[^a-zA-Z0-9_-]/g,"-"),a=JSON.stringify({mcpServers:{[`contextmem-${n}`]:{command:"npx",args:["-y","mcp-remote",t]}}},null,2),i=JSON.stringify({contextmem:{url:t}},null,2);return e.jsxs("div",{className:"panel",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Install in your MCP client"}),e.jsx("span",{children:"read-only"})]}),e.jsxs("p",{className:"subEmpty",style:{margin:"8px 0 16px"},children:["Endpoint: ",e.jsx("code",{children:t})]}),e.jsx("h3",{style:{margin:"8px 0 6px",fontSize:13},children:"Claude Desktop / Codex"}),e.jsx("pre",{children:a}),e.jsx("h3",{style:{margin:"16px 0 6px",fontSize:13},children:"Cursor (generic)"}),e.jsx("pre",{children:i})]})}function jc(){const[t,s]=x.useState([]),[n,a]=x.useState(null),[i,o]=x.useState(!0),[r,d]=x.useState("");x.useEffect(()=>{let c=!1;return(async()=>{try{const u=await fetch(`${D}/api/directory`);if(!u.ok)throw new Error(await Q(u));const h=await u.json();c||s(h.namespaces??[])}catch(u){c||a(u instanceof Error?u.message:String(u))}finally{c||o(!1)}})(),()=>{c=!0}},[]);const l=t.filter(c=>r.trim()?`${c.namespace} ${c.target} ${c.displayName??""} ${c.description??""} ${(c.tags??[]).join(" ")}`.toLowerCase().includes(r.trim().toLowerCase()):!0);return e.jsxs("main",{className:"showcasePage",children:[e.jsxs("header",{className:"showcaseHero",children:[e.jsxs(ge,{className:"appBrand",to:"/",children:[e.jsx("span",{className:"appBrandMark",children:e.jsx(Te,{size:18})}),e.jsxs("span",{children:[e.jsx("strong",{children:"ContextMeM"}),e.jsx("small",{children:"Showcase · public hosted namespaces"})]})]}),e.jsx("h1",{children:"Browse public ContextMeM namespaces"}),e.jsx("p",{children:"Every namespace below exposes a read-only MCP endpoint. Install one in Claude Desktop, Cursor, or any MCP client to ground an agent in verified site context."}),e.jsx("input",{className:"showcaseSearch",type:"search",placeholder:"Filter by domain, namespace, or tag",value:r,onChange:c=>d(c.target.value)})]}),i?e.jsx("section",{className:"panel",children:e.jsx("p",{children:"Loading directoryâ¦"})}
328):n?e.jsxs("section",{className:"panel errorState",children:[e.jsx("h2",{children:"Directory unavailable"}),e.jsx("p",{children:n}),e.jsx(Lt,{message:n})]}):l.length?e.jsx("section",{className:"showcaseGrid",children:l.map(c=>e.jsxs("article",{className:"showcaseCard",children:[e.jsxs("header",{children:[e.jsx("strong",{children:c.displayName??c.namespace}),e.jsx("code",{children:c.namespace})]}),e.jsx("p",{children:c.description??je(c.target)}),e.jsxs("dl",{children:[e.jsxs("div",{children:[e.jsx("span",{children:"target"}),e.jsx("strong",{children:je(c.target)})]}),e.jsxs("div",{children:[e.jsx("span",{children:"artifacts"}),e.jsx("strong",{children:c.artifactCount??"â"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"last snapshot"}),e.jsx("strong",{children:c.lastSnapshotAt?new Date(c.lastSnapshotAt).toLocaleDateString():"â"})]})]}),c.tags?.length?e.jsx("div",{className:"showcaseTags",children:c.tags.slice(0,6).map(u=>e.jsx("span",{children:u},u))}):null,e.jsxs("footer",{children:[e.jsx("a",{href:c.mcpUrl,target:"_blank",rel:"noreferrer",children:"Open MCP URL"}),e.jsx("button",{onClick:()=>{navigator.clipboard.writeText(c.mcpUrl)},children:"Copy"})]})]},c.namespace))}):e.jsx("section",{className:"panel",children:e.jsx("p",{children:"No public namespaces match that filter yet."})})]})}function yc({ownerId:t}){const[s,n]=x.useState(!1),[a,i]=x.useState(""),[o,r]=x.useState(!1),[d,l]=x.useState(!1);async function c(){if(a.trim()){l(!0);try{await fetch(`${D}/api/feedback`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ownerId:t,message:a.trim(),pageUrl:window.location.href,sentiment:"neutral"})}),r(!0),i("")}finally{l(!1)}}}return e.jsx("div",{className:`feedbackWidget ${s?"open":""}`,children:s?e.jsxs("form",{onSubmit:u=>{u.preventDefault(),c()},children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Feedback"}),e.jsx("button",{type:"button",onClick:()=>n(!1),children:"Close"})]}),o?e.jsx("p",{children:"Thanks, saved."}):e.jsx("textarea",{value:a,onChange:u=>i(u.target.value),placeholder:"What felt confusing or valuable?"}),o?null:e.jsx("button",{type:"submit",disabled:d||!a.trim(),children:d?"Sending":"Send feedback"})]}):e.jsxs("button",{type:"button",onClick:()=>n(!0),children:[e.jsx(Ee,{size:16}),"Feedback"]})})}function bc({pageTitle:t,pageDescription:s,statusLabel:n,statusTone:a,authHint:i,sessionSlot:o,hasMemWalDelegate:r,previewUnlocked:d=!1,run:l,children:c}){return e.jsxs("main",{className:`appShell ${r||d?"":"isLocked"}`,children:[e.jsxs("aside",{className:"appSidebar",children:[e.jsxs(ge,{className:"appBrand",to:"/",children:[e.jsx("span",{className:"appBrandMark",children:e.jsx(Te,{size:18})}),e.jsxs("span",{children:[e.jsx("strong",{children:"ContextMeM"}),e.jsx("small",{children:"Walrus Sites context engine"})]})]}),e.jsxs("nav",{className:"appSideNav","aria-label":"App pages",children:[e.jsxs(Ks,{className:({isActive:u})=>`appSideLink ${u?"selected":""}`,to:"/app/home",end:!0,children:[e.jsx(On,{size:17}),"Home"]}),cc.map(u=>{const h=u.icon;return e.jsxs(Ks,{className:({isActive:p})=>`appSideLink ${p?"selected":""}`,to:u.to,end:u.end,children:[e.jsx(h,{size:17}),u.label]},u.to)})]}),e.jsxs("div",{className:"appSidebarFoot",children:[e.jsx("span",{children:"Mainnet only"}),e.jsx("strong",{children:"Walrus Sites"})]})]}),e.jsxs("section",{className:"appMain",children:[null,e.jsxs("header",{className:"appTopbar",children:[e.jsxs("div",{className:"appTitleBlock",children:[e.jsx("span",{children:r?"Full app":d?"Public preview":"Locked preview"}),e.jsx("h1",{children:t}),e.jsx("p",{children:s})]}),e.jsx(Kc,{statusLabel:n,statusTone:a,run:l,hasMemWalDelegate:r,sessionSlot:o})]}),i?e.jsx("div",{className:"appHint",children:i}):null,e.jsx("div",{className:"appContent",children:c})]})]})}function pn(t,s){const n=t.status==="queued"||t.status==="running"||t.status==="completed"||t.status==="failed"?t.status:"starting",a=t.result?.share?.id;return{phase:n,target:t.target||s,jobId:t.id,shareId:a,message:vc(n,t.error),updatedAt:Date.now()}}
328function vc(t,s){switch(t){case"starting":return"Starting hosted preview";case"queued":return"Queued in Worker. Preparing extraction";case"running":return"Extracting public context and artifacts";case"completed":return"Preview ready. Opening share page";case"failed":return s||"Preview failed. Try another Walrus Site URL"}}function ts(t){if(!t)return"Preview";switch(t.phase){case"starting":return"Starting";case"queued":return"Queued";case"running":return"Extracting";case"completed":return"Opening";case"failed":return"Retry"}}function ja(t){switch(t){case"starting":return 18;case"queued":return 36;case"running":return 72;case"completed":case"failed":return 100}}function wc(t,s){return s?s.phase==="failed"?t===0?"isFailed":"":s.phase==="completed"?"isDone":s.phase==="running"?t===0?"isDone":t===1||t===2?"isActive":"":t===0?"isActive":"":""}function Ye(t,s){return s?s.phase==="failed"?t===0?"isFailed":"":s.phase==="completed"?"isDone":s.phase==="running"?t===0?"isDone":t===1||t===2?"isActive":"":s.phase==="queued"?t===0?"isDone":t===1?"isActive":"":t===0?"isActive":"":""}function kc(t){return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function Nc({preview:t,onBackHome:s}){const n=t.phase!=="failed"&&t.phase!=="completed",a=ja(t.phase),i=[["Create job",Ye(0,t)],["Resolve target",Ye(1,t)],["Package share page",Ye(2,t)]];return e.jsxs("section",{className:`demoRunPanel ${t.phase}`,"aria-live":"polite","aria-busy":n,children:[e.jsxs("div",{className:"demoRunPanelTop",children:[e.jsx("span",{className:"demoRunPanelIcon",children:t.phase==="failed"?e.jsx(We,{size:18}):n?e.jsx(oe,{className:"spinIcon",size:18}):e.jsx(Ze,{size:18})}),e.jsxs("div",{children:[e.jsx("span",{children:"Public demo preview"}),e.jsx("h2",{children:t.message}),e.jsx("p",{children:t.target})]}),t.shareId?e.jsxs(ge,{className:"demoRunPanelButton primary",to:`/share/${t.shareId}`,children:["Open share page",e.jsx(Fe,{size:15})]}):e.jsx("button",{className:"demoRunPanelButton",type:"button",onClick:s,children:"Back to homepage"})]}),e.jsx("div",{className:"demoRunPanelTrack",style:{"--preview-progress":`${a}%`},children:e.jsx("span",{})}),e.jsxs("div",{className:"demoRunPanelMeta",children:[t.jobId?e.jsx("code",{children:ye(t.jobId)}):e.jsx("span",{children:"waiting for job id"}),e.jsx("span",{children:n?"The Worker is still running. You can stay here or go back to the homepage.":t.phase==="failed"?"Try a different Walrus Site URL or run the curated sample.":"Share page is ready."})]}),e.jsx("div",{className:"demoRunPanelSteps","aria-label":"Demo preview progress",children:i.map(([o,r])=>e.jsxs("div",{className:r,children:[e.jsx("span",{}),e.jsx("p",{children:o})]},o))})]})}const Sc="https://contextmem-backend.petlofi.workers.dev",Cc=[{id:"recall",label:"recall",hint:"Read stored memory for a query",icon:st},{id:"ask",label:"ask",hint:"Grounded RAG answer over the namespace",icon:Ee},{id:"knowledge",label:"knowledge",hint:"The verified knowledge graph",icon:ke},{id:"remember",label:"remember",hint:"Write a memory (needs an account)",icon:pe}];function Pc(t,s,n,a){const i=n||"demo:anthropic",o=(a||"What is this and who is it for?").replace(/"/g,'\\"'),r=Sc;if(s==="knowledge"){const c=`/api/memwal/facts/${i}`;return t==="curl"?`curl ${r}${c}`:t==="ts"?`const res = await fetch("${r}${c}"); 329const { facts, proof } = await res.json();`:`import requests 330facts = requests.get("${r}${c}").json()`}if(s==="remember")return t==="curl"?`# remember (write) is NOT a keyless REST call. 331# Memory is written to Walrus during a build, or via the MCP server, 332# once you import a Walrus Memory delegate key in Settings. 333# recall · ask · knowledge above ARE keyless and live: 334curl -X POST ${r}/api/memwal/recall \\ 335 -H "content-type: application/json" \\ 336 -d '{"namespace":"${i}","query":"..."}'`:t==="ts"?`// remember (write) is NOT a keyless REST call. 337// Import a Walrus Memory delegate in Settings, then write memory by 338// running a build or wiring the ContextMEM MCP server into your agent. 339// recall · ask · knowledge above ARE keyless: 340const res = await fetch("${r}/api/memwal/recall", { 341 method: "POST", 342 headers: { "content-type": "application/json" }, 343 body: JSON.stringify({ namespace: "${i}", query: "..." }) 344});`:`# remember (write) is NOT a keyless REST call. 345# Import a Walrus Memory delegate in Settings, then write memory by
346# running a build or via the ContextMEM MCP server. 347# recall / ask / knowledge above ARE keyless: 348import requests 349data = requests.post("${r}/api/memwal/recall", 350 json={"namespace": "${i}", "query": "..."}).json()`;const d=s==="ask"?"/api/memwal/chat":"/api/memwal/recall",l=s==="ask"?`{"namespace":"${i}","messages":[{"role":"user","content":"${o}"}]}`:`{"namespace":"${i}","query":"${o}"}`;return t==="curl"?`curl -X POST ${r}${d} \\ 351 -H "content-type: application/json" \\ 352 -d '${l}'`:t==="ts"?`const res = await fetch("${r}${d}", { 353 method: "POST", 354 headers: { "content-type": "application/json" }, 355 body: JSON.stringify(${l}) 356}); 357const data = await res.json();`:`import requests 358data = requests.post("${r}${d}", 359 json=${l}).json()`}function Mc(t,s){if(!s)return"";const n=a=>"```json\n"+JSON.stringify(a,null,2)+"\n```";try{if(t==="ask"){const o=s?.data?.answer??s?.answer??"",r=s?.data?.key_points??s?.key_points??[];let l=`### Answer${typeof s?.confidence=="number"?` _(confidence ${Math.round(s.confidence*100)}%)_`:""} 360 361${o||"_(no answer)_"} 362`;return Array.isArray(r)&&r.length&&(l+=` 363**Key points** 364${r.map(c=>`- ${c}`).join(` 365`)} 366`),l}if(t==="knowledge"){const o=s?.facts??{},r=o?.identity??{};let d=`### ${r?.name??"Knowledge graph"} 367`;r?.oneLiner&&(d+=` 368${r.oneLiner} 369`);const l=(o?.topics??[]).map(u=>u?.label).filter(Boolean);l.length&&(d+=` 370**Topics:** ${l.slice(0,12).join(", ")} 371`);const c=Array.isArray(o?.entities)?o.entities:[];return c.length&&(d+=` 372**Entities (${c.length}):** ${c.slice(0,8).map(u=>u?.name).filter(Boolean).join(", ")} 373`),d||n(o)}const a=s?.result;if(a&&Array.isArray(a.results)&&a.results.length){const o=a.results.map(r=>`- ${typeof r?.text=="string"?r.text:JSON.stringify(r)}`).join(` 374`);return`### Recall â ${s?.namespace??""} 375 376${o} 377`}const i=typeof a=="string"?a:a?.context??a?.answer??"";return i?`### Recall â ${s?.namespace??""} 378 379${i} 380`:n(a??s)}catch{return n(s)}}function _c({onRequestAccess:t}){const[s,n]=x.useState([]),[a,i]=x.useState(""),[o,r]=x.useState("recall"),[d,l]=x.useState(""),[c,u]=x.useState(!1),[h,p]=x.useState(null),[g,j]=x.useState(null),[f,b]=x.useState(null),[y,w]=x.useState("markdown"),[v,S]=x.useState("curl"),[T,k]=x.useState(!1);x.useEffect(()=>{(async()=>{try{const M=await fetch(`${D}/api/memwal/namespaces`,{headers:G("")});if(!M.ok)return;const F=(await M.json()).namespaces??[];n(F),i(_=>_||F[0]?.namespace||"")}catch{}})()},[]);async function N(){if(o==="remember"){p("Writing memory needs a Walrus Memory delegate key â import one in Settings. recall · ask · knowledge are keyless and live.");return}const M=a.trim();if(!M){p("Pick a namespace first.");return}const P=d.trim()||"What is this and who is it for?";u(!0),p(null),j(null),b(null);try{let F;o==="knowledge"?F=await fetch(`${D}/api/memwal/facts/${encodeURIComponent(M)}`,{headers:G("")}):o==="ask"?F=await fetch(`${D}/api/memwal/chat`,{method:"POST",headers:G("",{"content-type":"application/json"}),body:JSON.stringify({namespace:M,messages:[{role:"user",content:P}]})}):F=await fetch(`${D}/api/memwal/recall`,{method:"POST",headers:G("",{"content-type":"application/json"}),body:JSON.stringify({namespace:M,query:P})});const _=await F.text();let O={};try{O=_?JSON.parse(_):{}}catch{O={raw:_}}if(!F.ok)throw new Error(O?.error||`Request failed (${F.status}).`);j(O),b(typeof O?.source=="string"?O.source:o==="knowledge"?"facts":null)}catch(F){const _=F instanceof Error?F.message:String(F);p(/Failed to fetch/i.test(_)?"Can't reach the API right now â try again in a moment.":_)}finally{u(!1)}}const L=Pc(v,o,a,d);async function z(){try{await navigator.clipboard.writeText(L),k(!0),window.setTimeout(()=>k(!1),1600)}catch{}}const m=f==="walrus-memory"?{label:"Walrus Memory · live recall",tone:"live"}:f==="facts"?{label:"Curated facts · keyword-ranked",tone:"facts"}:null;return e.jsxs("section",{className:"memPlay",id:"playground","aria-label":"Memory API playground",children:[e.jsxs("div",{className:"memPlayHead",children:[e.jsxs("span",{className:"memPlayKicker",children:[e.jsx(He,{size:15})," Memory API"]}),e.jsx("h2",{children:"Paste a question. Get agent-ready context."}),e.jsx("p",{children:"Zero-auth, runs live against curated public namespaces. When you like the result, copy the exact call."})]}),e.jsxs("div",{className:"memPlayBody",children:[e.jsxs("div",{className:"memPlayControls",children:[e.jsx("div",{className:"memPlayVerbs",role:"tablist",children:Cc.map(M=>{const P=M.icon;return e.jsxs("button",{type:"button",className:`memPlayVerb ${o===M.id?"selected":""}`,onClick:()=>r(M.id),title:M.hint,children:[e.jsx(P,{size:14})," ",M.label]},M.id)})}),s.length?e.jsx("div",{className:"memPlayNs",children:s.map(M=>e.jsxs("button",{type:"button",className:`memoryNsChip ${a===M.namespace?"selected":""}`,onClick:()=>i(M.namespace),children:[e.jsx(xe,{size:13})," ",e.jsx("span",{children:M.label})]},M.namespace))}):null,o==="remember"?e.jsxs("div",{className:"memPlayGate",children:[e.jsx(_e,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:"Writing memory needs a delegate key."}),e.jsx("span",{children:"recall · ask · knowledge above are keyless and live. Writing your own memory to Walrus â optionally Seal-encrypted â runs during a build or via the MCP server, once you import a Walrus Memory delegate. There is no keyless public write endpoint."})]}),e.jsxs("button",{type:"button",className:"memPlayGateCta",onClick:()=>t?.(),children:["Import a delegate ",e.jsx(Fe,{size:15})]})]}):e.jsxs("div",{className:"memPlayInput",children:[e.jsx(st,{size:16}),e.jsx("input",{value:d,onChange:M=>l(M.target.value),placeholder:o==="knowledge"?"knowledge needs no query â pick a namespace, then Run":"Ask anything about the selected namespace",disabled:o==="knowledge",onKeyDown:M=>{M.key==="Enter"&&N()}}),e.jsxs("button",{type:"button",onClick:()=>{N()}
380,disabled:c,children:[c?e.jsx(oe,{className:"spinIcon",size:15}):e.jsx(Ue,{size:15})," Run"]})]}),h?e.jsxs("div",{className:"memPlayError",children:[e.jsx(We,{size:15})," ",h]}):null,e.jsxs("div",{className:"memPlaySnippet",children:[e.jsxs("div",{className:"memPlaySnippetTabs",children:[["curl","ts","python"].map(M=>e.jsx("button",{type:"button",className:v===M?"selected":"",onClick:()=>S(M),children:M==="curl"?"cURL":M==="ts"?"TypeScript":"Python"},M)),e.jsxs("button",{type:"button",className:"memPlayCopy",onClick:()=>{z()},children:[e.jsx(me,{size:13})," ",T?"Copied":"Copy"]})]}),e.jsx("pre",{className:"memPlayCode",children:e.jsx("code",{children:L})})]})]}),e.jsxs("div",{className:"memPlayResponse",children:[e.jsxs("div",{className:"memPlayRespHead",children:[e.jsx("div",{className:"memPlayRespTabs",children:["markdown","json"].map(M=>e.jsx("button",{type:"button",className:y===M?"selected":"",onClick:()=>w(M),children:M==="json"?"JSON":"Markdown"},M))}),m?e.jsx("span",{className:`memPlaySource ${m.tone}`,children:m.label}):null]}),e.jsx("pre",{className:"memPlayRespBody",children:e.jsx("code",{children:c?"Runningâ¦":g?y==="json"?JSON.stringify(g,null,2):Mc(o,g)||"// (empty)":"// Run a verb to see the response here."})})]})]}),e.jsxs("p",{className:"memPlayFoot",children:[e.jsx(_e,{size:14})," Public namespaces answer from verified facts (keyword-ranked). Live semantic Walrus recall and writing your own memory need an account."]})]})}function Tc({target:t,setTarget:s,busy:n,demoPreview:a,hasMemWalDelegate:i,compactPrimaryActionLabel:o,statusLabel:r,statusTone:d,sessionSlot:l,authHint:c,heroRef:u,heroOffset:h,headlineRef:p,headlineProgress:g,heroMetrics:j,onHeroMouseMove:f,onHeroMouseLeave:b,onHeroAction:y,onOpenApp:w,onImportDelegate:v,onInspectArtifacts:S,onOpenHistory:T}){const k=!!(a&&a.phase!=="failed"&&a.phase!=="completed"),N=a?ja(a.phase):0,L=a?.target||(t?je(t):"waiting for target"),z=[{label:a?.phase==="starting"?"start hosted preview job":"resolve Walrus Site object",state:Ye(0,a)},{label:a?.phase==="queued"?"waiting for Worker slot":"verify blob/resource manifest",state:Ye(1,a)},{label:a?.phase==="running"?"exporting public share package":"export Walrus Memory context",state:Ye(2,a)}];return e.jsxs("main",{className:`shell landingShell ${i?"":"isLocked"}`,children:[e.jsx("div",{className:"lpFrame lpFrameTop","aria-hidden":"true"}),e.jsx("div",{className:"lpFrame lpFrameBottom","aria-hidden":"true"}),e.jsx("div",{className:"lpFrame lpFrameLeft","aria-hidden":"true"}),e.jsx("div",{className:"lpFrame lpFrameRight","aria-hidden":"true"}),e.jsx("svg",{className:"lpCorner lpCornerTL",width:"50",height:"50",viewBox:"0 0 50 50",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e.jsx("path",{d:"M5.50871e-06 0C-0.00788227 37.3001 8.99616 50.0116 50 50H5.50871e-06V0Z",fill:"currentColor"})}),e.jsx("svg",{className:"lpCorner lpCornerTR",width:"50",height:"50",viewBox:"0 0 50 50",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e.jsx("path",{d:"M5.50871e-06 0C-0.00788227 37.3001 8.99616 50.0116 50 50H5.50871e-06V0Z",fill:"currentColor"})}),e.jsx("svg",{className:"lpCorner lpCornerBL",width:"50",height:"50",viewBox:"0 0 50 50",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e.jsx("path",{d:"M5.50871e-06 0C-0.00788227 37.3001 8.99616 50.0116 50 50H5.50871e-06V0Z",fill:"currentColor"})}),e.jsx("svg",{className:"lpCorner lpCornerBR",width:"50",height:"50",viewBox:"0 0 50 50",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e.jsx("path",{d:"M5.50871e-06 0C-0.00788227 37.3001 8.99616 50.0116 50 50H5.50871e-06V0Z",fill:"currentColor"})}),e.jsx(dl,{statusLabel:r,statusTone:d,sessionSlot:l,authHint:c,onOpenConsole:w,onInspectArtifacts:S,onOpenHistory:T}),e.jsxs("section",{ref:u,className:"productHero landingHero",onMouseMove:f,onMouseLeave:b,style:{"--hero-x":`${h.x}px`,"--hero-y":`${h.y}px`},children:[e.jsx("div",{className:"heroBackdrop","aria-hidden":"true"}),e.jsxs("div",{className:"heroGrid",children:[e.jsxs("div",{className:"heroCopy",children:[e.jsxs("div",{className:"heroKicker",children:[e.jsx(He,{size:16}),"Walrus Sites context engine"]}),e.jsxs("h1",{className:"heroTitle",children:[e.jsxs("span",{children:["Decode ",e.jsx("em",{children:"Walrus Sites"}),"."]}),e.jsxs("span",{children:["Package ",e.jsx("em",{children:"onchain context"}),"."]})]}),e.jsx("p",{children:"Resolve .wal.app names and Walrus Site object IDs, verify resources from Sui and Walrus, then package markdown, assets, design tokens, screenshots, and Walrus Memoryâready memory for agents."}),e.jsxs("div",{className:"heroTarget",children:[e.jsx(st,{size:18}),e.jsx("input",{value:t,onChange:m=>s(m.target.value),disabled:k,placeholder:"Paste a .wal.app URL, Walrus object ID, or web URL"}),e.jsxs("button",{className:k?"isLoading":"",disabled:n||i&&!t,onClick:y,children:[!i&&k?e.jsx(oe,{className:"spinIcon",size:16}):null,i?o:ts(a)]})]}),!i&&a?e.jsxs("div",{className:`heroDemoStatus ${a.phase}`,"aria-live":"polite","aria-busy":k,children:[e.jsxs("div",{className:"heroDemoStatusMain",children:[e.jsx("span",{className:"heroDemoStatusIcon",children:a.phase==="failed"?e.jsx(We,{size:16}):k?e.jsx(oe,{className:"spinIcon",size:16}):e.jsx(Ze,{size:16})}),e.jsxs("div",{children:[e.jsx("small",{className:"heroDemoStatusLabel",children:"Public demo preview"}),e.jsx("strong",{children:a.message}),e.jsx("span",{children:L})]})]}),a.jobId?e.jsx("code",{children:ye(a.jobId)}):null,e.jsx("div",{className:"heroDemoStatusTrack",style:{"--preview-progress":`${N}%`},children:e.jsx("span",{})})]}):null,e.jsxs("div",{className:"heroActions",children:[e.jsxs("button",{className:"heroCta",onClick:i?w:y,disabled:!i&&k,children:[e.jsxs("span",{className:"heroCtaLabel",children:[!i&&k?e.jsx(oe,{className:"spinIcon",size:17}):null,i?"Open app":k?ts(a):"Run public preview"]}),e.jsx("span",{className:"heroCtaArrow",children:k?null:e.jsx(Fe,{size:18})})]}),e.jsxs("button",{className:"heroGhost",onClick:S,children:[e.jsx(Ln,{size:17}),"Inspect artifacts"]})]})]}),e.jsxs("div",{className:`heroPreview ${a?`isDemo${kc(a.phase)}`:""}`,"aria-label":"ContextMeM workflow preview",children:[e.jsxs("div",{className:"previewChrome",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsxs("div",{className:"previewHeader",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Live pipeline"}),e.jsx("strong",{children:L})]}),a?.phase==="failed"?e.jsx(We,{size:20}):k?e.jsx(oe,{className:"spinIcon",size:20}):e.jsx(Ze,{size:20})]}),e.jsx("div",{className:"previewPipeline",children:[["resolve",".wal.app or object ID",Xe],["verify","Sui + Walrus resources",$n],["package","agent context bundle",ke],["remember","Walrus Memory account",pe]].map(([m,M,P],F)=>{const _=P;return e.jsxs("div",{className:`pipelineStep ${wc(F,a)}`,children:[e.jsx(_,{size:17}),e.jsx("span",{children:m}),e.jsx("strong",{children:M})]},m)})}),e.jsx("div",{className:"previewLog",children:z.map(m=>e.jsxs("div",{className:m.state,children:[e.jsx("span",{}),e.jsx("p",{children:m.label})]},m.label))}),e.jsx("div",{className:"previewMetrics",children:j.map(m=>{const M=m.icon;return e.jsxs("div",{children:[e.jsx(M,{size:16}),e.jsx("span",{children:m.label}),e.jsx("strong",{children:String(m.value)})]},m.label)})})]})]}),e.jsx("div",{className:"logoLoop","aria-label":"ContextMeM output loop",children:e.jsx("div",{className:"logoTrack",children:[0,1].map(m=>e.jsx("div",{className:"logoSequence","aria-hidden":m>0,children:tc.map(M=>e.jsx("span",{children:M},`${m}-${M}`))},m))})})]}),e.jsx(_c,{onRequestAccess:v}),e.jsx("section",{ref:p,className:"headlineReveal",children:e.jsx("p",{children:es.map((m,M)=>{const P=M/es.length,F=P+1/es.length,_=Math.min(1,Math.max(0,(g-P)/(F-P)));return e.jsx("span",{style:{opacity:.58+_*.42,filter:`blur(${(1-_)*1.4}px)`},children:m},`${m}-${M}`)})})}),e.jsx("section",{className:"featureBento","aria-label":"ContextMeM capabilities",children:sc.map((m,M)=>{const P=m.icon;return e.jsxs("article",{className:"featureCard",style:{"--card-delay":`${M*90}ms`},children:[e.jsx(P,{size:20}),e.jsxs("div",{children:[e.jsx("h2",{children:m.title}),e.jsx("p",{children:m.detail})]}),e.jsx(Ki,{size:16,"aria-hidden":"true"})]},m.title)})}),e.jsxs("section",{className:"lpUse","aria-label":"Built so agents actually use it",children:[e.jsx(Gi,{as:"h2",className:"lpUseTitle",text:"Built so agents actually use it.",segmentBy:"words",blur:!0,direction:"bottom",delay:55,duration:.6}),e.jsx("div",{className:"lpUseGrid",children:nc.map(m=>e.jsxs("article",{className:"lpUseCard",children:[e.jsx("span",{className:"lpUseEyebrow",children:m.eyebrow}),e.jsx(zn,{className:"lpUseHeading",highlightedBits:m.highlights,highlightColor:"rgba(168, 217, 70, 0.5)",highlightClassName:"lpUseHi",blurAmount:6,blurDuration:.7,highlightDelay:.45,highlightDuration:.6,viewportOptions:{once:!0,amount:.4},children:m.heading}),e.jsx("div",{className:`lpUseGif ${m.image?"hasIllustration":""}`,role:m.image?void 0:"img","aria-label":m.image?void 0:"Demo placeholder â drop a GIF here",children:m.image?e.jsx("img",{className:"lpUseIllustration",src:m.image.src,alt:m.image.alt,loading:"lazy",decoding:"async"}):e.jsxs("span",{className:"lpUseGifHint",children:[e.jsx(Ue,{size:15})," Drop a GIF here"]})}),e.jsx("p",{className:"lpUseBody",children:m.body})]},m.eyebrow))})]}),e.jsxs("section",{className:"lpStore","aria-label":"Walrus storage and memory via Tatum",children:[e.jsxs("header",{className:"lpSectionHead",children:[e.jsxs("span",{className:"lpEyebrow",children:[e.jsx(xe,{size:14})," Storage + Memory"]}),e.jsxs("h2",{children:["Walrus storage keeps the proof.",e.jsx("br",{}),"Walrus Memory remembers where it is."]}),e.jsx("p",{children:"Three layers, cleanly split through Tatum â so the integration is real provenance, not a logo on a slide."})]}),e.jsxs("div",{className:"lpStoreVisual","aria-label":"Walrus blob handoff from certified storage proof to Walrus Memory recall pointer",children:[e.jsx("div",{className:"lpStoreVisualMedia",children:e.jsx("img",{src:"/illustrations/walrus-memory-handoff.png",alt:"A hand-drawn walrus blob pulls a pointer from a certified Walrus storage proof bundle to a Walrus Memory index board.",loading:"lazy",decoding:"async"})}),e.jsxs("div",{className:"lpStoreVisualNotes",children:[e.jsx("span",{children:"Proof bytes stay certified in storage"}),e.jsx("span",{children:"Memory keeps the recall pointer"}),e.jsx("span",{children:"Agents re-fetch the real artifact"})]})]}),e.jsx("div",{className:"lpStoreGrid",children:ac.map((m,M)=>{const P=m.icon;return e.jsxs("article",{className:`lpBento ${M===0?"isPrimary":""}`,children:[e.jsx("div",{className:"lpBentoIcon",children:e.jsx(P,{size:22})}),e.jsx("span",{className:"lpBentoTag",children:m.tag}),e.jsx("h3",{children:m.title}),e.jsx("p",{children:m.detail})]},m.tag)})}),e.jsx("div",{className:"lpFlowPill",children:e.jsxs("code",{children:["context/ â tar â Tatum upload â ",e.jsx("strong",{children:"CERTIFIED"})," â blobId â Walrus Memory"]})})]}),e.jsxs("section",{className:"lpCta","aria-label":"Get started with ContextMeM",children:[e.jsx("div",{className:"lpCtaBg","aria-hidden":"true",children:e.jsx(Vi,{color:"#a8d946",speed:.5,scale:.72,size:.62,blur:.4,className:"lpCtaDots"})}),e.jsxs("div",{className:"lpCtaInner",children:[e.jsxs("span",{className:"lpCtaBrand",children:[e.jsx("span",{className:"lpCtaBrandMark",children:e.jsx(Te,{size:20})}),"ContextMeM"]}),e.jsxs("h2",{className:"lpCtaTitle",children:["Decode any Walrus Site.",e.jsx("br",{}),"Remember it forever."]}),e.jsx("p",{className:"lpCtaSub",children:"Resolve, verify, package, and store verified onchain context your agents can actually recall."}),e.jsxs("button",{className:"lpCtaBtn",onClick:i?w:y,disabled:!i&&k,children:[i?"Open app":k?ts(a):"Run public preview",e.jsx(Fe,{size:18})]})]})]})]})}const Ec=[{order:1,route:"/app/artifacts",icon:pt,line:"Open Artifacts to read the markdown, manifests, and screenshots you just built.",highlight:"Artifacts"},{order:2,route:"/app/runs",icon:nt,line:"Open Runs to scan your history by namespace and reopen any package in one click.",highlight:"Runs"},{order:3,route:"/app/memory",icon:pe,line:"Open Memory to browse the knowledge graph and recall stored context.",highlight:"Memory"},{order:4,route:"/app/namespaces",icon:xe,line:"Open Namespaces to browse every verified context namespace.",highlight:"Namespaces"}];function Rc({intro:t}){return e.jsxs("section",{className:"nextSteps","aria-label":"Next steps",children:[e.jsxs("header",{className:"nextStepsHead",children:[e.jsx("span",{className:"nextStepsEyebrow",children:"Next steps"}),e.jsx("h3",{children:t??"Your context package is built â here's how to explore it, share it, and keep it fresh."})]}),e.jsx("ol",{className:"nextStepsList",children:Ec.map((s,n)=>{const a=s.icon;return e.jsx("li",{className:"nextStepsItem",children:e.jsxs(ge,{className:"nextStepsLink",to:s.route,children:[e.jsx("span",{className:"nextStepsNum",children:s.order}),e.jsx("span",{className:"nextStepsIcon",children:e.jsx(a,{size:20})}),e.jsx("span",{className:"nextStepsBody",children:e.jsx(zn,{highlightedBits:[s.highlight],highlightColor:"rgba(168, 217, 70, 0.5)",highlightClassName:"nextStepsHi",blurAmount:6,blurDelay:n*.08,blurDuration:.6,highlightDelay:.3+n*.08,highlightDuration:.5,viewportOptions:{once:!0,amount:.3},children:s.line})}),e.jsx("span",{className:"nextStepsGo","aria-hidden":"true",children:"â"})]})},s.route)})})]})}function Ac({target:t,setTarget:s,mode:n,setMode:a,buildProfile:i,setBuildProfile:o,outputs:r,setOutputs:d,busy:l,error:c,run:u,artifact:h,stats:p,activeTab:g,setActiveTab:j,setArtifact:f,history:b,refreshHistory:y,authToken:w,accountLabel:v,primaryActionLabel:S,onStartRun:T,onRemember:k,onOpenRun:N,hasMemWalDelegate:L,hostedBuildResult:z,customNamespace:m,setCustomNamespace:M,customDisplayName:P,setCustomDisplayName:F,isHostedApiBase:_,notice:O}){const q=mn.some(([A])=>A===g)?g:"Markdown",[$,K]=x.useState(!1),U=A=>{o(A),d(xa[A])};x.useEffect(()=>{if(!$)return;function A(Ae){Ae.key==="Escape"&&K(!1)}window.addEventListener("keydown",A);const re=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",A),document.body.style.overflow=re}},[$]);const B=u?.manifest.runId??null,W=z?.shareId??null,te=z?.shareUrl??null,ae=!!(u||h),ie=!ae&&!l&&b.length>0,X=!ae&&!l&&!$,se=e.jsxs(e.Fragment,{children:[e.jsx(Gc,{runId:B,busy:l,shareId:W,shareUrl:te,expanded:$,onToggleExpand:()=>K(A=>!A)}),ae?e.jsx("div",{className:"stats",children:p.map(A=>{const re=A.icon;return e.jsxs("div",{className:"stat",children:[e.jsx(re,{size:18}),e.jsx("span",{children:A.label}),e.jsx("strong",{children:String(A.value)})]},A.label)})}):ie?e.jsx(Vc,{history:b,onOpenRun:N,busy:l}):null,ae&&!$?e.jsx(Rc,{}):null,e.jsx("div",{className:"tabs",children:mn.map(([A,re])=>e.jsxs("button",{className:q===A?"selected":"",onClick:()=>j(A),children:[e.jsx(re,{size:15}),A]},A))}),e.jsx("div",{className:"resultsTabBody",children:e.jsx(qc,{tab:q,artifact:h,run:u,busy:l,error:c?.startsWith("Walrus Memory")?null:c,setArtifact:f,history:b,refreshHistory:y,authToken:w,accountLabel:v,target:t,setTarget:s,onStartRun:T,canStart:!!t.trim()&&!l})})]});return e.jsxs("section",{className:`workspace appWorkspace ${X?"appWorkspaceFirstRun":""}`,children:[e.jsxs("aside",{className:"control buildControl",children:[e.jsxs("div",{className:"heroInput",children:[e.jsxs("div",{className:"heroInputMain",children:[e.jsx(st,{size:18,className:"heroInputIcon"}),e.jsx("input",{value:t,onChange:A=>s(A.target.value),placeholder:"Paste a .wal.app URL, Walrus object ID, or web URLâ¦",onKeyDown:A=>{A.key==="Enter"&&t&&!l&&T()}})]}),e.jsxs("div",{className:"heroInputRow",children:[e.jsx("div",{className:"segmented heroModes","aria-label":"Build mode",children:["auto","web","walrus"].map(A=>e.jsxs("button",{className:n===A?"selected":"",onClick:()=>a(A),type:"button",children:[A==="web"?e.jsx(Xe,{size:14}):A==="walrus"?e.jsx(ke,{size:14}):e.jsx(He,{size:14}),A]},A))}),e.jsxs("div",{className:"heroSend",children:[l||S!=="Build context"?e.jsx("span",{className:"heroSendLabel",children:S}):null,e.jsx("button",{className:"heroSendBtn",disabled:!t||l,onClick:T,type:"but
380ton",title:S,"aria-label":S,children:l?e.jsx(oe,{size:18,className:"spin"}):e.jsx(Fe,{size:18})})]})]})]}),e.jsxs("details",{className:"advancedSettings",children:[e.jsx("summary",{children:e.jsxs("span",{className:"advancedSummary",children:[e.jsx("span",{className:"advancedSummaryLabel",children:"More options"}),e.jsxs("span",{className:"advancedSummaryHint",children:[hn.find(A=>A.id===i)?.label??"Balanced"," · ",r.length," outputs"]})]})}),e.jsxs("div",{className:"buildSettings",children:[e.jsxs("div",{className:"field",children:[e.jsx("span",{children:"Network"}),e.jsx("div",{className:"segmented networkOnly","aria-label":"Walrus network",children:e.jsxs("button",{className:"selected",type:"button","aria-pressed":"true",children:[e.jsx(Xe,{size:15}),"mainnet"]})})]}),e.jsxs("div",{className:"field",children:[e.jsx("span",{children:"Build profile"}),e.jsx("div",{className:"profileGrid",children:hn.map(A=>e.jsxs("button",{className:i===A.id?"selected":"",type:"button",onClick:()=>U(A.id),children:[e.jsx("strong",{children:A.label}),e.jsx("small",{children:A.detail})]},A.id))})]}),_?e.jsxs("details",{className:"field customNamespaceField",open:!0,children:[e.jsxs("summary",{children:["Name this context ",e.jsx("span",{className:"customNamespaceHint",children:"â set a namespace, or auto-generate"})]}),e.jsxs("div",{className:"namespaceFields",children:[e.jsxs("label",{children:[e.jsx("span",{children:"Namespace slug"}),e.jsx("input",{type:"text",value:m,onChange:A=>M(A.target.value.replace(/[^a-zA-Z0-9_:.-]/g,"")),placeholder:"seal-docs (becomes demo:seal-docs)",spellCheck:!1})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Display name"}),e.jsx("input",{type:"text",value:P,onChange:A=>F(A.target.value),placeholder:"Seal Docs (shown on share page)"})]}),e.jsxs("small",{children:["Leave blank to auto-generate ",e.jsx("code",{children:"demo:<hostname>:<random>"}),". Manage all your namespaces in ",e.jsx("strong",{children:"Runs"}),"."]})]})]}):null,e.jsxs("div",{className:"field",children:[e.jsx("span",{children:"Outputs"}),e.jsx("div",{className:"checks",children:Zl.map(A=>e.jsxs("label",{className:A.id==="screenshots"?"slowOutput":"",children:[e.jsx("input",{type:"checkbox",checked:r.includes(A.id),onChange:()=>d(re=>re.includes(A.id)?re.filter(Ae=>Ae!==A.id):[...re,A.id])}),e.jsxs("span",{children:[A.label,A.detail?e.jsx("small",{children:A.detail}):null]})]},A.id))})]})]})]}),(L||_)&&u?e.jsxs("button",{className:"secondary",disabled:!u||l||!L&&!_,onClick:k,children:[e.jsx(pe,{size:17}),"Remember in Walrus Memory"]}):null,O?e.jsx(xt,{notice:O}):null,z?e.jsx(Yc,{result:z}):null,c?e.jsx("div",{className:h||c.startsWith("Walrus Memory")?"notice":"error",children:h&&!c.startsWith("Walrus Memory")?`Partial context kept: ${c}`:c}):null]}),X?e.jsxs("div",{className:"firstRunSamples",children:[e.jsx("span",{className:"firstRunSamplesLabel",children:"Try one of these"}),e.jsx("div",{className:"firstRunSampleChips",children:va.map(A=>e.jsx("button",{type:"button",className:`firstRunChip ${t===A.url?"selected":""}`,onClick:()=>s(A.url),disabled:l,title:A.detail,children:A.label},A.url))})]}):e.jsx("section",{className:"results appResults","aria-hidden":$,children:$?e.jsx("div",{className:"resultsExpandPlaceholder",children:"Output expanded â close the overlay to return."}):se}),$?e.jsx("div",{className:"resultsExpandModal",role:"dialog","aria-modal":"true","aria-label":"Build output (expanded)",onClick:()=>K(!1),children:e.jsx("div",{className:"resultsExpandModalInner resultsExpandModalInnerWide",onClick:A=>A.stopPropagation(),children:se})}):null]})}function Ic({stats:t,run:s,artifact:n,authToken:a,setArtifact:i,history:o,accountLabel:r,onOpenRun:d,busy:l}){const{items:c}=ya(),u=mt();return n?e.jsxs("section",{className:"appPanelStack",children:[e.jsx("div",{className:"stats",children:t.map(h=>{const p=h.icon;return e.jsxs("div",{className:"stat",children:[e.jsx(p,{size:18}),e.jsx("span",{children:h.label}),e.jsx("strong",{children:String(h.value)})]},h.label)})}),s?e.jsx(Ca,{artifact:n,run:s,setArtifact:i,authToken:a,history:o,accountLabel:r}):null,e.jsx(Ma,{run:s,authToken:a})]}):e.jsx("section",{className:"appPanelStack artifactsEmptyStack",children:e.jsxs("div",{className:"artifactsEmpty",children:[e.jsx("div",{className:"artifactsEmptyIcon",children:e.jsx(pt,{size:26})}),e.jsx("h2",{children:"Browse context packages"}),e.jsx("p",{children:"Open a verified context package to explore its knowledge graph, facts, and Walrus storage proof â or build a new one."}),e.jsxs(ge,{to:"/app",className:"artifactsEmptyCta",children:[e.jsx(Ue,{size:16}),"Open Build"]}),c.length?e.jsxs("div",{className:"artifactsRecent",children:[e.jsx("span",{className:"artifactsRecentLabel",children:"Verified packages"}),e.jsx("div",{className:"artifactsRecentGrid",children:c.map(h=>e.jsxs("button",{type:"button",className:"artifactsRecentCard",onClick:()=>u(`/app/memory?ns=${encodeURIComponent(h.namespace)}`),children:[e.jsx("strong",{children:h.displayName}),e.jsxs("small",{children:[h.entities," entities · ",h.relationships," links",h.proof?.certified?" · â Walrus":""]}),e.jsx("time",{children:je(h.target)})]},h.namespace))})]}):null]})})}function ya(){const[t,s]=x.useState([]),[n,a]=x.useState(!0);return x.useEffect(()=>{let i=!1;return(async()=>{try{const r=await(await fetch(`${D}/api/memwal/facts`)).json();i||s(r.namespaces??[])}catch{}finally{i||a(!1)}})(),()=>{i=!0}},[]),{items:t,busy:n}}function Dc({busy:t,onRefresh:s}){const{items:n,busy:a}=ya(),i=mt();return e.jsxs("section",{className:"appPanelStack",children:[e.jsxs("div",{className:"pageToolbar",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[n.length," context package",n.length===1?"":"s"]}),e.jsx("span",{children:"Verified Walrus context packages â open one to browse its knowledge graph."})]}),e.jsxs("button",{onClick:()=>{s()},disabled:t,children:[e.jsx(nt,{size:16}),"Refresh"]})]}),n.length?e.jsx("div",{className:"runListPage",children:n.map(o=>e.jsxs("button",{className:"runRow",onClick:()=>i(`/app/memory?ns=${encodeURIComponent(o.namespace)}`),children:[e.jsxs("span",{children:[e.jsx("strong",{children:o.displayName}),e.jsx("small",{children:o.namespace})]}),e.jsx("span",{children:je(o.target)}),e.jsxs("span",{children:[o.entities," entities"]}),e.jsxs("span",{children:[o.relationships," links"]}),e.jsx("span",{className:"runRowEnd",children:o.proof?.certified?e.jsx("span",{className:"runProofBadge",children:"â Walrus"}):null})]},o.namespace))}):a?e.jsx("div",{className:"panel subEmpty",children:"Loading context packagesâ¦"}):e.jsx("div",{className:"panel subEmpty",children:"No context packages yet. Build your first from the Build page."})]})}function Lc({proof:t}){return e.jsxs("section",{className:"proofPanel",children:[e.jsxs("div",{className:"proofHead",children:[e.jsxs("span",{className:"proofKicker",children:[e.jsx(_e,{size:14})," Walrus storage proof"]}),e.jsx("span",{className:`proofBadge ${t.certified?"isCertified":""}`,children:t.certified?"CERTIFIED":t.status})]}),e.jsxs("p",{className:"proofSub",children:["This context bundle is stored on Walrus ",e.jsx("strong",{children:t.network})," and its availability is certified onchain via ",t.provider,"."]}),e.jsxs("dl",{className:"proofGrid",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Walrus blob ID"}),e.jsx("dd",{children:e.jsx("code",{children:t.blobId})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Tatum job"}),e.jsx("dd",{children:e.jsx("code",{children:t.jobId})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Artifact digest"}),e.jsx("dd",{children:e.jsx("code",{children:t.artifactDigest})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Bundle size"}),e.jsxs("dd",{children:[(t.byteLength/1024).toFixed(1)," KB"]}
380)]}),t.certifiedAt?e.jsxs("div",{children:[e.jsx("dt",{children:"Certified"}),e.jsx("dd",{children:Ts(t.certifiedAt)})]}):null]})]})}const $c=["What is this project and who is it for?","How does it work technically?","What are the key facts, numbers, and costs?"];function zc({authToken:t}){const[s,n]=x.useState([]),[a,i]=x.useState(!0),[o,r]=x.useState(""),[d,l]=x.useState(null),[c,u]=x.useState(null),[h,p]=x.useState(!1);return x.useEffect(()=>{(async()=>{try{const g=await fetch(`${D}/api/memwal/namespaces`,{headers:G(t)});if(!g.ok){i(!1);return}const j=await g.json();n(j.namespaces??[]),i(j.configured!==!1);const f=new URLSearchParams(window.location.search).get("ns")||"",b=j.namespaces?.some(y=>y.namespace===f)?f:"";r(y=>y||b||j.namespaces?.[0]?.namespace||"")}catch{i(!1)}})()},[t]),x.useEffect(()=>{if(l(null),u(null),!o)return;let g=!1;return p(!0),(async()=>{try{const j=await fetch(`${D}/api/memwal/facts/${encodeURIComponent(o)}`,{headers:G(t)});if(!j.ok){g||l(null);return}const f=await j.json();g||(l(f.facts??null),u(f.proof??null))}catch{g||l(null)}finally{g||p(!1)}})(),()=>{g=!0}},[o,t]),e.jsxs("section",{className:"panel memoryExplorer",children:[e.jsxs("div",{className:"memoryExplorerHead",children:[e.jsxs("span",{className:"factsKicker",children:[e.jsx(pe,{size:14})," Walrus Memory"]}),e.jsx("h2",{children:"Browse Knowledge + Memory"}),e.jsx("p",{children:"Explore a namespace's verified knowledge graph and recall its stored context â no run required. Pick a namespace."})]}),a?null:e.jsxs("div",{className:"notice",children:["Recall uses your Walrus Memory delegate â import it in ",e.jsx("strong",{children:"Settings"})," (sent securely as a request header), or set ",e.jsx("code",{children:"MEMWAL_*"})," on the Worker for anonymous recall."]}),s.length?e.jsx("div",{className:"memoryExplorerNamespaces",children:s.map(g=>e.jsxs("button",{type:"button",className:`memoryNsChip ${o===g.namespace?"selected":""}`,onClick:()=>r(g.namespace),children:[e.jsx(xe,{size:14}),e.jsx("span",{children:g.label}),e.jsx("small",{children:g.namespace})]},g.namespace))}):null,e.jsx(Fc,{namespace:o,authToken:t},o),h&&!d?e.jsx("div",{className:"memoryKnowledgeLoading",children:"Loading knowledge graphâ¦"}):d?e.jsxs("div",{className:"memoryKnowledge",children:[e.jsx("div",{className:"memoryKnowledgeHead",children:e.jsxs("span",{className:"factsKicker",children:[e.jsx(ke,{size:14})," Knowledge"]})}),c?e.jsx(Lc,{proof:c}):null,e.jsx(_s,{facts:d})]}):null]})}function Oc(t){return t==="walrus-memory"?"Walrus Memory":t==="mixed"?"Memory + facts":"Verified facts"}function Fc({namespace:t,authToken:s}){const[n,a]=x.useState([]),[i,o]=x.useState(""),[r,d]=x.useState(!1),[l,c]=x.useState(null),u=x.useRef(null);x.useEffect(()=>{u.current?.scrollTo({top:u.current.scrollHeight,behavior:"smooth"})},[n,r]);async function h(p){const g=(p??i).trim();if(!g||!t||r)return;d(!0),c(null),o("");const j=[];for(const f of n){j.push({role:"user",content:f.question});const b=typeof f.result.data?.answer=="string"?f.result.data.answer:"";b&&j.push({role:"assistant",content:b})}j.push({role:"user",content:g});try{const f=await fetch(`${D}/api/memwal/chat`,{method:"POST",headers:G(s,{"content-type":"application/json"}),body:JSON.stringify({namespace:t,messages:j})}),b=await f.text();let y;try{y=b?JSON.parse(b):{}}catch{y={}}if(!f.ok)throw new Error(y?.error??`Chat failed (${f.status}).`);a(w=>[...w,{id:`${Date.now()}`,question:g,result:y}])}catch(f){const b=f instanceof Error?f.message:String(f),y=/hexToBytes|non-hex|invalid.*key|Ed25519/i.test(b)?"Your Walrus Memory delegate key looks malformed (not a 64-char hex seed). Re-import it in Settings, or set MEMWAL_PRIVATE_KEY on the Worker.":/Failed to fetch/i.test(b)?"Can't reach the API. On a local preview, start the dev server (bun run dev) or point the app at the hosted backend.":b;c(y)}finally{d(!1)}}return e.jsxs("div",{className:"memoryChat",children:[e.jsxs("div",{className:"memoryChatStream","aria-live":"polite",ref:u,children:[n.length===0?e.jsxs("div",{className:"memoryChatEmpty",children:[e.jsx(Ee,{size:18}),e.jsx("strong",{children:"Chat with this namespace"}),e.jsxs("span",{children:["Ask anything â answers are grounded in Walrus Memory recall and the verified knowledge graph for"," ",e.jsx("code",{children:t||"a namespace"}),"."]})]}):n.map(p=>e.jsxs("article",{className:"aiChatTurn",children:[e.jsxs("div",{className:"aiChatUser",children:[e.jsx("span",{children:"You"}),e.jsx("p",{children:p.question})]}),e.jsxs("div",{className:"aiChatAssistant",children:[e.jsxs("div",{className:"aiChatAssistantHead",children:[e.jsx("span",{children:"ContextMeM"}),e.jsxs("small",{children:[Oc(p.result.source)," · ",p.result.usedProvider," · ",Math.round((p.result.confidence??0)*100),"%"]})]}),e.jsx(Ms,{data:p.result.data}),p.result.sources?.length?e.jsxs("details",{className:"aiChatSources",children:[e.jsxs("summary",{children:[p.result.sources.length," source",p.result.sources.length===1?"":"s"]}),e.jsx("div",{className:"sourceGrid",children:p.result.sources.map((g,j)=>e.jsxs("article",{children:[e.jsx("strong",{children:g.routePath??g.url}),g.quote?e.jsx("p",{children:g.quote}):null,g.blobId?e.jsx("code",{children:g.blobId}):null]},`${g.routePath??g.url}-${j}`))})]}):null]})]}
380,p.id)),r?e.jsxs("div",{className:"aiChatTyping",children:[e.jsx(oe,{size:14,className:"spin"})," ContextMeM is thinkingâ¦"]}):null]}),e.jsx("div",{className:"memoryExplorerPrompts",children:$c.map(p=>e.jsx("button",{type:"button",onClick:()=>{h(p)},disabled:r||!t,children:p},p))}),e.jsxs("form",{className:"memoryChatForm",onSubmit:p=>{p.preventDefault(),h()},children:[e.jsx("textarea",{value:i,onChange:p=>o(p.target.value),onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),h())},placeholder:t?`Message ${t}⦠(Enter to send, Shift+Enter = newline)`:"Pick a namespace firstâ¦",rows:2,disabled:!t||r}),e.jsxs("button",{className:"primary",type:"submit",disabled:!t||r||!i.trim(),children:[r?e.jsx(oe,{size:16,className:"spin"}):e.jsx(Ee,{size:16}),"Send"]})]}),l?e.jsx("div",{className:"error",children:l}):null]})}function Bc({artifact:t,run:s,history:n,refreshHistory:a,authToken:i,onRemember:o,busy:r,notice:d}){return e.jsx("section",{className:"appPanelStack",children:t&&s?e.jsx(Ta,{artifact:t,run:s,history:n,refreshHistory:a,authToken:i,onRemember:o,rememberBusy:r,notice:d}):e.jsx(zc,{authToken:i})})}function Wc({me:t,quotaLabel:s,hasMemWalDelegate:n,authBusy:a,delegateAccountId:i,delegateKey:o,setDelegateAccountId:r,setDelegateKey:d,onImport:l,notice:c,canImportSdkCredentials:u,previewBusy:h,onPreviewDemo:p,showDevMemWalAuth:g,onAttachLocalMemWal:j,onLogout:f}){return e.jsxs("section",{className:"settingsGrid",children:[e.jsxs("section",{className:"accountCard settingsCard",children:[e.jsxs("div",{className:"accountCardHead",children:[e.jsx(xe,{size:17}),e.jsxs("div",{children:[e.jsx("strong",{children:"Walrus Memory account"}),e.jsx("span",{children:t.authenticated?t.account?.memwalAccountId??"Walrus Memory not connected":"login required"})]})]}),e.jsxs("div",{className:"accountGrid",children:[e.jsxs("div",{children:[e.jsx("span",{children:"quota"}),e.jsx("strong",{children:t.authenticated?s:"locked"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Walrus Memory"}),e.jsx("strong",{children:n?"ready":"import"})]})]}),n?e.jsx(td,{accountId:t.account?.memwalAccountId}):null,e.jsxs("div",{className:"settingsActionRow",children:[e.jsxs("button",{className:"secondary danger",type:"button",disabled:!t.authenticated,onClick:f,children:[e.jsx(xs,{size:15}),"Log out account"]}),e.jsxs(ge,{className:"settingsLinkButton",to:"/app/namespaces",children:[e.jsx(xe,{size:15}),"Manage namespaces"]})]}),e.jsx(xt,{notice:c})]}),e.jsxs("section",{className:"settingsCard",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:n?"Rotate SDK credentials":ic}),e.jsx("span",{children:le(D)?"encrypted server-side":"stored in this browser only"})]}),e.jsx("p",{className:"settingsCopy",children:n?"Import again only if you rotate the delegate key in Walrus Memory.":le(D)?rc:"Paste your Walrus Memory account ID and delegate private key. On the public site the delegate is stored in this browser only, sent as a request header for private hosted runs, and never persisted by the Worker."}),e.jsxs("a",{className:"sdkSetupLink",href:ft,target:"_blank",rel:"noreferrer",children:[e.jsx(At,{size:13}),"Open Walrus Memory dashboard to create or copy credentials"]}),e.jsx(ed,{authenticated:t.authenticated,authBusy:a,delegateAccountId:i,delegateKey:o,setDelegateAccountId:r,setDelegateKey:d,onImport:l})]}),e.jsx(Uc,{authenticated:t.authenticated,onLogout:f}),le(D)?e.jsx(Hc,{}):null,g?e.jsxs("section",{className:"settingsCard",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Developer auth fallback"}),e.jsx("span",{children:"local MCP"})]}),e.jsx("div",{className:"devOnlyBanner",children:"Dev only. This panel is hidden in production builds and delegate keys stay server-side."}),e.jsx("button",{className:"secondary",onClick:j,disabled:a||!t.authenticated,children:"Use local MCP credentials"})]}):null]})}function Uc({authenticated:t,onLogout:s}){return e.jsxs("section",{className:"settingsCard settingsUsageGuide",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"How to use this account"}),e.jsx("span",{children:"logout · MCP · namespace name"})]}),e.jsxs("div",{className:"usageGuideGrid",children:[e.jsxs("article",{children:[e.jsx("strong",{children:"Log out"}),e.jsx("p",{children:"Use this when you want to remove the Walrus Memory delegate from this browser and clear the active run state."}),e.jsxs("button",{className:"secondary danger",type:"button",disabled:!t,onClick:s,children:[e.jsx(xs,{size:14}
380),"Log out now"]})]}),e.jsxs("article",{children:[e.jsx("strong",{children:"Use MCP"}),e.jsx("p",{children:"Build or publish a namespace, open Namespaces, copy the MCP URL, then add it to Codex, Claude Desktop, Cursor, or any MCP client."}),e.jsxs(ge,{className:"settingsLinkButton",to:"/app/namespaces",children:[e.jsx(Te,{size:14}),"Open Namespaces"]})]}),e.jsxs("article",{children:[e.jsx("strong",{children:"Set namespace name"}),e.jsx("p",{children:"Namespace is the stable ID agents connect to. Display name is the friendly label shown in this UI and share pages."}),e.jsxs(ge,{className:"settingsLinkButton",to:"/app/publish",children:[e.jsx(Ln,{size:14}),"Publish / name namespace"]})]})]})]})}function Hc(){const[t,s]=x.useState(""),[n,a]=x.useState(!1);function i(){const r=new Uint8Array(32);crypto.getRandomValues(r);const d=Array.from(r,l=>l.toString(16).padStart(2,"0")).join("");s(d),a(!1)}async function o(){if(t)try{await navigator.clipboard.writeText(`CONTEXTMEM_ACCOUNT_SECRET=${t}`),a(!0),setTimeout(()=>a(!1),1800)}catch{a(!1)}}return e.jsxs("section",{className:"settingsCard",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Account secret"}),e.jsx("span",{children:"32-byte hex"})]}),e.jsxs("p",{className:"settingsCopy",children:["Generate a fresh ",e.jsx("code",{children:"CONTEXTMEM_ACCOUNT_SECRET"})," for your local ",e.jsx("code",{children:".env.local"}),". Used to derive session tokens; never sent to the server."]}),e.jsxs("div",{className:"accountSecretRow",children:[e.jsx("button",{className:"secondary",onClick:i,children:t?"Generate again":"Generate secret"}),t?e.jsx("button",{className:"ghost",onClick:()=>{o()},children:n?"Copied":"Copy env line"}):null]}),t?e.jsx("pre",{className:"accountSecretReadout",children:e.jsxs("code",{children:["CONTEXTMEM_ACCOUNT_SECRET=",t]})}):null]})}function qc({tab:t,artifact:s,run:n,busy:a,error:i,setArtifact:o,history:r,refreshHistory:d,authToken:l,accountLabel:c,target:u,setTarget:h,onStartRun:p,canStart:g}){const[,j]=x.useState(0),f=n?.manifest.createdAt;x.useEffect(()=>{if(!a||!f)return;const v=setInterval(()=>j(S=>S+1),1e3);return()=>clearInterval(v)},[a,f]);const b=n?.manifest.errors.filter(Boolean)??[],w=(n?.manifest.status==="failed"?b[0]??"Context build failed.":null)??(s?null:i);if(w)return e.jsxs("div",{className:"empty resultState errorState",role:"alert",children:[e.jsx(We,{size:26}),e.jsx("strong",{children:"Context build failed"}),e.jsx("span",{children:w}),e.jsx(Lt,{message:w})]});if(!s){if(a){const v=n?.manifest.progress,S=n?.manifest.cacheStats,T=typeof v?.itemsDone=="number"&&typeof v?.itemsTotal=="number"?`${v.itemsDone}/${v.itemsTotal}`:v?.phase?v.phase.replaceAll("_"," "):"starting",k=n?.manifest.createdAt?Math.max(0,Date.now()-Date.parse(n.manifest.createdAt)):0;return e.jsxs("div",{className:"empty resultState loadingState","aria-live":"polite","aria-busy":"true",children:[e.jsx(oe,{size:28}),e.jsx("strong",{children:v?.label??"Building context package"}),e.jsx("span",{children:_d(v?.phase)}),e.jsxs("div",{className:"progressMeta",children:[e.jsx("code",{children:T}),e.jsx("code",{children:Md(k)}),S&&S.hits+S.misses>0?e.jsxs("code",{children:[S.hits," cache hits"]}):null]}),e.jsx("div",{className:"loadingTrack","aria-hidden":"true",children:e.jsx("span",{})})]})}return h&&p?e.jsx(Qc,{target:u??"",setTarget:h,onStartRun:p,canStart:!!g,busy:a}):e.jsxs("div",{className:"empty",children:[e.jsx(He,{size:24}),e.jsx("span",{children:"Build a Walrus Site context package to inspect verified resources, markdown, visual assets, Walrus Memory, and publish artifacts."})]})}if(t==="Markdown"){const v=n?.manifest.namespace;return e.jsx(ba,{pages:s.pages,namespace:v,onPageEdited:(S,T)=>{o(k=>k&&{...k,pages:k.pages.map(N=>N.artifactPath===S?{...N,markdown:T}:N)})}})}return t==="Structure"?e.jsx(ad,{data:s.siteStructure,run:n,authToken:l}):t==="Facts"?e.jsx(_s,{facts:s.facts}):t==="Images"?e.jsx("div",{className:"grid",children:s.images.map((v,S)=>{const T=La(v,s),k=$a(v,s);return e.jsxs("article",{className:"imageCard",children:[e.jsx("div",{className:"imagePreview",children:T?e.jsx("img",{src:T,alt:v.alt??v.role??v.type??"Extracted image",loading:"lazy"}):e.jsx("span",{children:v.type??"asset"})}),e.jsxs("div",{className:"imageMeta",children:[e.jsx("strong",{children:v.role??v.contentType??v.type??"image"}),v.alt?e.jsx("span",{children:v.alt}):null,e.jsx("code",{children:k})]})]},`${v.absoluteUrl}-${S}`)})}):t==="Brand"?e.jsx(Ea,{data:s.brand}):t==="Design System"||t==="Styleguide"?e.jsx(vd,{data:s.designSystem,fallback:s.styleguide,run:n,authToken:l}):t==="AI Query"?e.jsx(Ca,{artifact:s,run:n,setArtifact:o,authToken:l,history:r,accountLabel:c}):t==="Artifacts"?e.jsx(Ma,{run:n,authToken:l}):t==="Walrus Resources"?e.jsx(Ra,{data:s.walrus}):t==="Walrus History"?e.jsx(Pd,{run:n,walrus:s.walrus,authToken:l}):t==="MemWal Memory"?e.jsx(Ta,{artifact:s,run:n,history:r,refreshHistory:d,authToken:l}):e.jsx(_a,{run:n,authToken:l})}function ba({pages:t,namespace:s,onPageEdited:n}
380){const[a,i]=x.useState("preview"),[o,r]=x.useState({}),[d,l]=x.useState(null),[c,u]=x.useState(null),[h,p]=x.useState(()=>t[0]?ze(t[0]):""),g=x.useMemo(()=>t.reduce((k,N)=>k+N.markdown.length,0),[t]),j=!!s;if(!t.length)return e.jsx("div",{className:"panel subEmpty",children:"No markdown pages were extracted for this run."});function f(k){const N=ze(k);return o[N]??k.markdown}function b(k,N){const L=ze(k);r(z=>({...z,[L]:N}))}function y(k){const N=ze(k);r(L=>{const z={...L};return delete z[N],z})}async function w(k){if(!k.artifactPath||!s){u({tone:"warning",message:"This page has no artifact path. Re-run the build so it's tracked."});return}l(k.artifactPath),u(null);try{const N=await fetch(`${D}/api/namespaces/${encodeURIComponent(s)}/artifact-edit`,{method:"POST",headers:G("",{"content-type":"application/json"}),body:JSON.stringify({path:k.artifactPath,content:f(k)})});if(!N.ok)throw new Error(await Q(N));const L=f(k);n?.(k.artifactPath,L),y(k),u({tone:"success",message:`Saved ${k.artifactPath}. MCP clients reading this namespace will get the new content on next query.`})}catch(N){u({tone:"warning",message:N instanceof Error?N.message:String(N)})}finally{l(null)}}const v=t.find(k=>ze(k)===h)??t[0],S=f(v),T=o[ze(v)]!==void 0&&o[ze(v)]!==v.markdown;return e.jsxs("div",{className:"panel markdownPanel markdownDocs",children:[e.jsxs("div",{className:"markdownToolbar",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Markdown"}),e.jsxs("span",{children:[t.length," pages · ",ve(g),j?" · raw is editable":""]})]}),e.jsxs("div",{className:"markdownMode",role:"group","aria-label":"Markdown view mode",children:[e.jsxs("button",{type:"button",className:a==="preview"?"selected":"",onClick:()=>i("preview"),"aria-pressed":a==="preview",children:[e.jsx(_n,{size:14}),"Preview"]}),e.jsxs("button",{type:"button",className:a==="raw"?"selected":"",onClick:()=>i("raw"),"aria-pressed":a==="raw",children:[e.jsx(Xi,{size:14}),"Raw"]})]})]}),c?e.jsx("div",{className:`markdownSaveNotice ${c.tone}`,children:c.message}):null,e.jsxs("div",{className:"markdownDocsLayout",children:[e.jsxs("aside",{className:"markdownPageNav","aria-label":"Markdown pages",children:[e.jsxs("div",{className:"markdownPageNavHead",children:[e.jsx("span",{children:"Pages"}),e.jsx("small",{children:t.length})]}),e.jsx("ul",{children:t.map(k=>{const N=ze(k),L=f(k),z=o[N]!==void 0&&o[N]!==k.markdown;return e.jsx("li",{children:e.jsxs("button",{type:"button",className:N===h?"selected":"",onClick:()=>p(N),title:k.routePath??k.url,children:[e.jsx("span",{className:"markdownPageNavTitle",children:k.title??k.routePath??k.url}),e.jsxs("span",{className:"markdownPageNavMeta",children:[e.jsx("small",{children:ve(L.length)}),z?e.jsx("em",{children:"edited"}):null]})]})},N)})})]}),e.jsxs("article",{className:"page markdownPage markdownDocsBody",children:[e.jsxs("div",{className:"pageHead markdownPageHead",children:[e.jsxs("div",{children:[e.jsx("strong",{children:v.title??v.routePath??v.url}),e.jsx("span",{children:v.routePath??v.url})]}),e.jsxs("span",{children:[v.source?.blobId??ve(S.length),v.artifactPath?` · ${v.artifactPath}`:""]})]}),a==="preview"?e.jsx("div",{className:"markdownBody",children:e.jsx(js,{remarkPlugins:[ws],components:{a:Ss},children:S})}):j?e.jsxs(e.Fragment,{children:[e.jsx("textarea",{className:"markdownRawEditor",value:S,onChange:k=>b(v,k.target.value),spellCheck:!1,rows:Math.min(36,Math.max(12,S.split(` 381`).length))}),e.jsxs("div",{className:"markdownEditActions",children:[e.jsx("button",{type:"button",className:"primary",disabled:!T||d===v.artifactPath,onClick:()=>{w(v)},children:d===v.artifactPath?"Savingâ¦":T?"Save to namespace":"Saved"}),T?e.jsx("button",{type:"button",className:"ghost",onClick:()=>y(v),children:"Discard changes"}):null]})]}):e.jsx("pre",{className:"markdownRaw",children:S})]},h)]})]})}function ze(t){return t.artifactPath??t.url}function Kc({statusLabel:t,statusTone:s,run:n,hasMemWalDelegate:a,sessionSlot:i}){const o=a?"ready":s==="needsMemWal"?"warn":"info",r=a?n?"Building":"Ready":"Walrus Memory import needed";return e.jsxs("details",{className:"statusPill",children:[e.jsxs("summary",{"aria-label":`${r}: ${t}`,children:[e.jsx("span",{className:`statusDot statusDot-${o}`,"aria-hidden":"true"}),e.jsx("span",{className:"statusPillLabel",children:r}),e.jsx(Zi,{className:"statusPillCaret",size:14,"aria-hidden":"true"})]}),e.jsxs("div",{className:"statusPanel",role:"dialog",children:[e.jsxs("div",{className:"statusRow",children:[e.jsx("span",{children:"Network"}),e.jsx("strong",{children:"Walrus mainnet"})]}),e.jsxs("div",{className:"statusRow",children:[e.jsx("span",{children:"Walrus Memory"}),e.jsx("strong",{className:`statusValue statusValue-${s}`,children:t})]}),e.jsxs("div",{className:"statusRow",children:[e.jsx("span",{children:"Run"}),e.jsx("strong",{children:n?ye(n.manifest.runId):"no active run"})]}),i?e.jsx("div",{className:"statusSession",children:i}):null]})]})}function Gc({runId:t,busy:s,shareId:n,shareUrl:a,expanded:i,onToggleExpand:o}){const[r,d]=x.useState(!1);async function l(){if(t)try{await navigator.clipboard.writeText(t),d(!0),setTimeout(()=>d(!1),1600)}catch{d(!1)}}return e.jsxs("div",{className:"resultsMetaBar",children:[e.jsxs("div",{className:"resultsMetaBarFacts",children:[t?e.jsxs("button",{type:"button",className:"resultsMetaChip",onClick:()=>{l()},title:t,"aria-label":`Job ID ${t}, click to copy`,children:[e.jsx(qs,{size:13}),e.jsx("span",{children:"job"}),e.jsx("code",{children:ye(t)}),r?e.jsx("small",{children:"copied"}):null]}):s?e.jsxs("span",{className:"resultsMetaChip resultsMetaChipActive",children:[e.jsx(oe,{size:13,className:"spin"}),e.jsx("span",{children:"starting buildâ¦"})]}):e.jsxs("span",{className:"resultsMetaChip resultsMetaChipMuted",children:[e.jsx(qs,{size:13}),e.jsx("span",{children:"no active run"})]}),n&&a?e.jsxs(ge,{className:"resultsMetaShareLink",to:`/share/${n}`,title:a,children:[e.jsx(Fn,{size:13}),"Open share page",e.jsx(Fe,{size:13})]}):null]}),e.jsxs("button",{type:"button",className:"resultsMetaExpandButton",onClick:o,"aria-label":i?"Close expanded view":"Expand output to fullscreen",children:[i?e.jsx(gs,{size:15}):e.jsx(Rn,{size:15}),i?"Close":"Expand"]})]})}function Vc({history:t,onOpenRun:s,busy:n}){const a=t.slice(0,5);return e.jsxs("div",{className:"recentRunsRow","aria-label":"Recent runs",children:[e.jsxs("div",{className:"recentRunsLabel",children:[e.jsx(nt,{size:14}),e.jsx("span",{children:"Recent runs"})]}),e.jsx("div",{className:"recentRunsList",children:a.map(i=>{const o=(()=>{try{return new URL(i.target).hostname}catch{return i.target}})(),r=i.updatedAt?new Date(i.updatedAt).toLocaleDateString(void 0,{month:"short",day:"numeric"}):"",d=i.mode==="walrus"?ke:Xe;return e.jsxs("button",{type:"button",className:"recentRunChip",onClick:()=>{s(i.runId)},disabled:n,title:`${i.target} · ${i.pages??0} pages`,children:[e.jsx(d,{size:13}),e.jsx("span",{className:"recentRunChipHost",children:o}),e.jsxs("span",{className:"recentRunChipMeta",children:[i.pages??0,"p · ",r]})]},i.runId)})})]})}const va=[{label:"seal-docs",url:"https://seal-docs.wal.app/",detail
381:"Walrus Site · Seal docs"},{label:"walrus.site",url:"https://walrus.site/",detail:"Walrus Foundation site"},{label:"rememe",url:"https://rememe.wal.app/",detail:".wal.app product example"}];function Qc({target:t,setTarget:s,onStartRun:n,canStart:a,busy:i}){return e.jsxs("div",{className:"quickStartCard",children:[e.jsxs("div",{className:"quickStartHead",children:[e.jsx("span",{className:"quickStartBadge",children:"Quick start"}),e.jsx("h2",{children:"Build verified context from a website or Walrus Site."}),e.jsx("p",{children:"Paste a URL, click Build, and ContextMeM packages markdown, brand, design system, and a hosted MCP namespace your agents can query."})]}),e.jsxs("ol",{className:"quickStartSteps",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"1. Paste a URL"}),e.jsx("span",{children:"A `.wal.app` Walrus Site, a Sui object ID, or any public web URL."})]}),e.jsxs("li",{children:[e.jsx("strong",{children:"2. Click Build"}),e.jsx("span",{children:"Hosted Firecrawl extraction with JS rendering, sitemap discovery, and per-page chunk hashing."})]}),e.jsxs("li",{children:[e.jsx("strong",{children:"3. Use the share link or MCP URL"}),e.jsx("span",{children:"Open it in Claude Desktop / Cursor / Codex, or share the read-only `/share/:id` page with your team."})]})]}),e.jsxs("div",{className:"quickStartSamples",children:[e.jsx("span",{children:"Try one of these:"}),e.jsx("div",{className:"quickStartSampleList",children:va.map(o=>e.jsxs("button",{type:"button",className:`quickStartSample ${t===o.url?"selected":""}`,onClick:()=>s(o.url),disabled:i,title:o.detail,children:[e.jsx("span",{className:"quickStartSampleLabel",children:o.label}),e.jsx("small",{children:o.detail})]},o.url))})]}),e.jsxs("button",{type:"button",className:"run quickStartBuild",disabled:!a,onClick:n,children:[e.jsx(Ue,{size:16}),i?"Building":a?"Build context":"Paste or pick a URL above"]})]})}function Yc({result:t}){const[s,n]=x.useState(null);async function a(i,o){try{await navigator.clipboard.writeText(o),n(i),setTimeout(()=>n(null),1800)}catch{n(null)}}return e.jsxs("div",{className:"hostedBuildBanner",children:[e.jsxs("div",{className:"hostedBuildBannerHead",children:[e.jsx(Ze,{size:16}),e.jsx("strong",{children:"Hosted build complete"}),e.jsx("code",{children:t.namespace})]}),e.jsxs("div",{className:"hostedBuildBannerRow",children:[e.jsx("span",{children:"Share page"}),e.jsx(ge,{to:`/share/${t.shareId}`,children:t.shareUrl}),e.jsxs("button",{type:"button",onClick:()=>{a("share",t.shareUrl)},children:[e.jsx(me,{size:13}),s==="share"?"Copied":"Copy"]})]}),e.jsxs("div",{className:"hostedBuildBannerRow",children:[e.jsx("span",{children:"MCP endpoint"}),e.jsx("a",{href:t.mcpUrl,target:"_blank",rel:"noreferrer",children:t.mcpUrl}),e.jsxs("button",{type:"button",onClick:()=>{a("mcp",t.mcpUrl)},children:[e.jsx(me,{size:13}),s==="mcp"?"Copied":"Copy"]})]}),e.jsx(Jc,{mcpUrl:t.mcpUrl,namespace:t.namespace})]})}function Jc({mcpUrl:t,namespace:s}){const[n,a]=x.useState(null),[i,o]=x.useState(""),[r,d]=x.useState("/site/index.md");async function l(h,p){return(await fetch(t,{method:"POST",headers:{"content-type":"application/json",accept:"application/json, text/event-stream",...ut()},body:JSON.stringify({jsonrpc:"2.0",id:Date.now(),method:h,params:p})})).text()}async function c(){a("tools"),o("");try{await l("initialize",{protocolVersion:"2025-03-26",capabilities:{},clientInfo:{name:"contextmem-playground",version:"0.1.0"}});const h=await l("tools/list",{});o(fn(h))}catch(h){o(h instanceof Error?h.message:String(h))}finally{a(null)}}async function u(){if(r.trim()){a("read"),o("");try{await l("initialize",{protocolVersion:"2025-03-26",capabilities:{},clientInfo:{name:"contextmem-playground",version:"0.1.0"}});const h=await l("tools/call",{name:"contextmem_read_artifact",arguments:{path:r.trim(),namespace:s}});o(fn(h))}catch(h){o(h instanceof Error?h.message:String(h))}finally{a(null)}}}return e.jsxs("div",{className:"mcpPlayground",children:[e.jsx("strong",{children:"Try this MCP endpoint"}),e.jsxs("div",{className:"mcpPlaygroundActions",children:[e.jsx("button",{type:"button",onClick:()=>{c()},disabled:n!==null,children:n==="tools"?"Listingâ¦":"tools/list"}),e.jsx("input",{type:"text",value:r,onChange:h=>d(h.target.value),placeholder:"/site/index.md",spellCheck:!1}),e.jsx("button",{type:"button",onClick:()=>{u()},disabled:n!==null||!r.trim(),children:n==="read"?"Readingâ¦":"read_artifact"})]}),i?e.jsx("pre",{className:"mcpPlaygroundOutput",children:i}):e.jsx("small",{children:"Run `tools/list` to see what your namespace exposes, or `read_artifact` to fetch a file like `/site/index.md` or `/llms.txt`."})]})}function fn(t){try{const s=t.split(` 382`).map(a=>a.startsWith("data: ")?a.slice(6):a).filter(a=>a.trim().length>0).join(` 383`),n=JSON.parse(s);return n.error?JSON.stringify(n.error,null,2):n.result?JSON.stringify(n.result,null,2).slice(0,6e3):JSON.stringify(n,null,2).slice(0,6e3)}catch{return t.slice(0,6e3)}}function Ss(t){const{href:s,children:n,node:a,...i}=t,o=typeof s=="string"&&/^https?:\/\//i.test(s);return e.jsx("a",{href:s,target:o?"_blank":void 0,rel:o?"noreferrer":void 0,...i,children:n})}const Xc={a:Ss,p:({children:t})=>e.jsx(e.Fragment,{children:t})},Zc={a:Ss};function xn({children:t,inline:s=!1}){const n=t.replace(/\\r\\n|\\r|\\n/g,` 384`);return e.jsx(js,{remarkPlugins:[ws],components:s?Xc:Zc,children:n})}function ed({authenticated:t,authBusy:s,delegateAccountId:n,delegateKey:a,setDelegateAccountId:i,setDelegateKey:o,onImport:r}){return e.jsx(da,{variant:"compact",authenticated:t,authBusy:s,delegateAccountId:n,delegateKey:a,setDelegateAccountId:i,setDelegateKey:o,onImport:r,dashboardUrl:ft,delegateStorage:le(D)?"server"
384:"browser",description:le(D)?"Paste your Walrus Memory account ID and delegate private key. ContextMeM stores the delegate encrypted server-side and unlocks verified Walrus context.":"Paste your Walrus Memory account ID and delegate private key. On the public site they are stored in this browser only, sent as request headers for private hosted runs, and never persisted by the Worker."})}function td({accountId:t}){const[s,n]=x.useState({tone:"idle",message:""}),[a,i]=x.useState(!1);async function o(){i(!0),n({tone:"idle",message:"Initializing MCP sessionâ¦"});try{const r=await fetch(`${D}/mcp`,{method:"POST",headers:{"content-type":"application/json",accept:"application/json, text/event-stream",...ut()},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize",params:{protocolVersion:"2025-03-26",capabilities:{},clientInfo:{name:"contextmem-test-connection",version:"0.1.0"}}})});if(!r.ok)throw new Error(`initialize ${r.status}: ${(await r.text()).slice(0,160)}`);const c=((await(await fetch(`${D}/mcp`,{method:"POST",headers:{"content-type":"application/json",accept:"application/json, text/event-stream",...ut()},body:JSON.stringify({jsonrpc:"2.0",id:2,method:"tools/list",params:{}})})).text()).match(/"name"\s*:\s*"/g)||[]).length;n({tone:"ok",message:`Connection healthy. ${c} tools available on the gateway.`})}catch(r){n({tone:"fail",message:r instanceof Error?r.message:String(r)})}finally{i(!1)}}return e.jsxs("div",{className:"sdkSavedState",children:[e.jsx(_e,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:"SDK credentials saved"}),e.jsx("p",{children:le(D)?"ContextMeM will reuse the encrypted server-side delegate. Import again only if you rotate this key in Walrus Memory.":"ContextMeM will reuse the delegate from this browser for hosted prod testing. Import again only if you rotate this key in Walrus Memory."}),t?e.jsx("code",{children:ye(t)}):null,e.jsxs("div",{className:"sdkTestRow",children:[e.jsx("button",{type:"button",className:"sdkTestButton",onClick:()=>{o()},disabled:a,children:a?"Testingâ¦":"Test connection"}),s.tone==="ok"?e.jsx("span",{className:"sdkTestOk",children:s.message}):null,s.tone==="fail"?e.jsx("span",{className:"sdkTestFail",children:s.message}):null,s.tone==="idle"&&s.message?e.jsx("span",{className:"sdkTestIdle",children:s.message}):null]})]}),e.jsxs("a",{className:"sdkSetupLink",href:ft,target:"_blank",rel:"noreferrer",children:[e.jsx(At,{size:13}),"Open Walrus Memory dashboard"]})]})}function sd({notice:t,previewBusy:s,onPreviewDemo:n,panel:a=!1,target:i,setTarget:o}){const r=typeof i=="string"&&typeof o=="function";return e.jsxs("div",{className:`hostedCredentialGate ${a?"panelMode":""}`,children:[e.jsx("div",{className:"hostedCredentialIcon",children:e.jsx(_e,{size:22})}),e.jsx("span",{children:"Hosted prod test"}
384),e.jsx("h2",{children:"Run a public preview or import credentials."}),e.jsx("p",{children:"Public preview works without credentials. Private hosted runs accept your Walrus Memory delegate from Settings and do not require a local API."}),r?e.jsxs("form",{className:"hostedCredentialInput",onSubmit:d=>{d.preventDefault(),s||n()},children:[e.jsx("input",{type:"url",value:i??"",onChange:d=>o?.(d.target.value),placeholder:"Paste a .wal.app URL or public web URL (leave blank for the curated sample)",disabled:s,spellCheck:!1,inputMode:"url",autoComplete:"off"}),e.jsxs("button",{type:"submit",disabled:s,children:[s?e.jsx(oe,{className:"spinIcon",size:16}):e.jsx(Ue,{size:16}),s?"Running":i?.trim()?"Run this URL":"Run public preview"]})]}):e.jsx("div",{className:"hostedCredentialActions",children:e.jsxs("button",{type:"button",onClick:n,disabled:s,children:[s?e.jsx(oe,{className:"spinIcon",size:16}):e.jsx(Ue,{size:16}),s?"Preview running":"Run public preview"]})}),e.jsx("div",{className:"hostedCredentialActions secondary",children:e.jsxs("a",{href:ft,target:"_blank",rel:"noreferrer",children:[e.jsx(At,{size:14}),"Open Walrus Memory dashboard"]})}),e.jsx(xt,{notice:t,centered:a})]})}function nd({authenticated:t,authBusy:s,notice:n,delegateAccountId:a,delegateKey:i,setDelegateAccountId:o,setDelegateKey:r,onImport:d,canImportSdkCredentials:l,previewBusy:c,onPreviewDemo:u,target:h,setTarget:p}){return e.jsxs("div",{className:"lockedPreview",children:[e.jsxs("div",{className:"blurredDemo","aria-hidden":"true",children:[e.jsx("div",{className:"stats",children:["Pages","Resources","Design tokens","Walrus Memory"].map((g,j)=>e.jsxs("div",{className:"stat",children:[e.jsx(He,{size:16}),e.jsx("span",{children:g}),e.jsx("strong",{children:j===3?"locked":`${(j+1)*8}`})]},g))}),e.jsx("div",{className:"panel",children:e.jsx("pre",{children:`Walrus Site package 385- verified Sui object provenance 386- resource manifest and blob IDs 387- markdown and visual system export 388- Walrus Memory recall namespace`})})]}),l?e.jsx(da,{variant:"panel",authenticated:t,authBusy:s,delegateAccountId:a,delegateKey:i,setDelegateAccountId:o,setDelegateKey:r,onImport:d,dashboardUrl:ft,noticeSlot:e.jsx(xt,{notice:n,centered:!0}),delegateStorage:le(D)?"server":"browser",description:le(D)?"Paste your Walrus Memory account ID and delegate private key. ContextMeM stores the delegate encrypted server-side and unlocks verified Walrus context.":"Paste your Walrus Memory account ID and delegate private key. On the public site they are stored in this browser only, sent as request headers for private hosted runs, and never persisted by the Worker."}):e.jsx(sd,{notice:n,previewBusy:c,onPreviewDemo:u,panel:!0,target:h,setTarget:p})]})}function xt({notice:t,centered:s=!1}){return t?e.jsxs("div",{className:`memwalNotice ${t.tone} ${s?"centered":""}`,children:[e.jsx("p",{children:t.message}),t.command?e.jsxs("div",{className:"memwalCommand",children:[e.jsx("code",{children:t.command}),e.jsx("button",{onClick:()=>{navigator.clipboard.writeText(t.command)},children:"Copy command"})]}):null]}):null}function ad({data:t,run:s,authToken:n}){const a=x.useMemo(()=>t?lt(t.nodes).filter(u=>u.kind!=="group"):[],[t]),[i,o]=x.useState(""),r=a.find(u=>u.id===i)??a[0],d=x.useMemo(()=>Aa(r),[r]),[l,c]=x.useState("");return x.useEffect(()=>{o(a[0]?.id??"")},[t?.generatedAt]),x.useEffect(()=>{if(!s||!d?.artifactPath||hs(d)){c("");return}if(!Ia(d)){c("Preview unavailable for this node.");return}fetch(we(s.manifest.runId,d.artifactPath,n),{headers:G(n)}).then(u=>u.ok?u.text():u.text().then(h=>Promise.reject(new Error(h)))).then(c).catch(u=>c(u instanceof Error?u.message:String(u)))},[n,s?.manifest.runId,d?.id,d?.artifactPath]),t?e.jsxs("div",{className:"panel structurePanel",children:[e.jsxs("section",{className:"structureSummary",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Pages"}),e.jsx("strong",{children:t.summary.pages})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Docs"}),e.jsx("strong",{children:t.summary.docs})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Assets"}),e.jsx("strong",{children:t.summary.assets})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Brand"}),e.jsx("strong",{children:t.summary.brandAssets})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Walrus"}),e.jsx("strong",{children:t.summary.walrusResources})]})]}),e.jsxs("section",{className:"structureLayout",children:[e.jsx("div",{className:"structureTree",children:t.nodes.map(u=>e.jsx(wa,{node:u,selectedId:r?.id,onSelect:o,depth:0,runId:s?.manifest.runId,authToken:n},u.id))}),e.jsx("aside",{className:"structureInspector",children:r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:r.label}),e.jsx("span",{children:r.kind})]}
388),e.jsxs("dl",{children:[r.path?e.jsxs("div",{children:[e.jsx("dt",{children:"path"}),e.jsx("dd",{children:r.path})]}):null,r.route?e.jsxs("div",{children:[e.jsx("dt",{children:"route"}),e.jsx("dd",{children:r.route})]}):null,r.contentType?e.jsxs("div",{children:[e.jsx("dt",{children:"type"}),e.jsx("dd",{children:r.contentType})]}):null,r.byteLength?e.jsxs("div",{children:[e.jsx("dt",{children:"size"}),e.jsx("dd",{children:ve(r.byteLength)})]}):null,r.blobId?e.jsxs("div",{children:[e.jsx("dt",{children:"blob"}),e.jsx("dd",{children:r.blobId})]}):null,r.blobHash?e.jsxs("div",{children:[e.jsx("dt",{children:"hash"}),e.jsx("dd",{children:r.blobHash})]}):null,r.artifactPath?e.jsxs("div",{children:[e.jsx("dt",{children:"artifact"}),e.jsx("dd",{children:r.artifactPath})]}):null,!r.artifactPath&&d?.artifactPath?e.jsxs("div",{children:[e.jsx("dt",{children:"preview"}),e.jsx("dd",{children:d.artifactPath})]}):null]}),e.jsxs("div",{className:"structureActions",children:[e.jsxs("button",{onClick:()=>navigator.clipboard.writeText(r.path??r.artifactPath??r.label),children:[e.jsx(me,{size:14}),"Copy path"]}),d?.artifactPath?e.jsxs("a",{href:we(s?.manifest.runId,d.artifactPath,n),target:"_blank",rel:"noreferrer",children:[e.jsx(pt,{size:14}),"Open"]}):null]}),d?.artifactPath?e.jsx("div",{className:"structurePreview",children:hs(d)?e.jsx("img",{src:we(s?.manifest.runId,d.artifactPath,n),alt:d.label}):e.jsx("pre",{children:l})}):e.jsx("div",{className:"subEmpty",children:"No local preview artifact for this node."})]}):e.jsx("div",{className:"subEmpty",children:"No structure nodes found."})})]})]}):e.jsx("div",{className:"panel structurePanel",children:e.jsxs("div",{className:"tabEmptyState",children:[e.jsx("strong",{children:"Site structure not in this run"}),e.jsxs("p",{children:["This run was built before site-structure extraction shipped. Re-run the Build to get a tree of pages, resources, and Walrus assets â saved as ",e.jsx("code",{children:"/context/site-structure.json"}),"."]})]})})}function wa({node:t,selectedId:s,onSelect:n,depth:a,runId:i,authToken:o}){const r=!!t.children?.length,d=Aa(t),l=e.jsxs("div",{className:`structureLine ${s===t.id?"selected":""}`,style:{paddingLeft:`${a*14+8}px`},children:[e.jsxs("button",{onClick:()=>n(t.id),children:[e.jsx("span",{children:t.kind}),e.jsx("strong",{children:t.label}),t.contentType?e.jsx("small",{children:t.contentType.split(";")[0]}):null,t.blobId?e.jsx("code",{children:ye(t.blobId)}):null]}),e.jsxs("div",{children:[e.jsx("button",{title:"Copy path",onClick:()=>navigator.clipboard.writeText(t.path??t.artifactPath??t.label),children:e.jsx(me,{size:13})}),d?.artifactPath?e.jsx("a",{title:"Open artifact",href:we(i,d.artifactPath,o),target:"_blank",rel:"noreferrer",children:e.jsx(pt,{size:13})}):null]})]});
388return r?e.jsxs("details",{open:a<1,className:"structureBranch",children:[e.jsx("summary",{children:l}),t.children?.map(c=>e.jsx(wa,{node:c,selectedId:s,onSelect:n,depth:a+1,runId:i,authToken:o},c.id))]}):l}const id=[{label:"Namespace summary",question:"Summarize this namespace for a developer agent. Include the best pages and confidence level."},{label:"What to remember?",question:"What should this account remember about this namespace for future agent recall?"},{label:"API endpoints",question:"List any developer API endpoints, SDKs, auth model, and example payloads found in this context."},{label:"Install steps",question:"How does a new developer install or integrate this product in under 5 minutes?"},{label:"Risks / gaps",question:"What important information is missing or low-confidence in this extracted context?"}];function rd(t,s,n,a){const i=Dt(t,s),o=Cs(t),r=n?ye(n):"this account",d=!!t.walrus?.resources.length,l=a.filter(p=>p.namespace===s?.manifest.namespace&&p.runId!==s?.manifest.runId),c=cd(t),u=[{label:"For this account",question:`What should account ${r} do next with namespace ${i}? Include MCP usage, memory recommendations, and the most relevant extracted pages.`},{label:"What to remember?",question:`Create a concise memory note for account ${r} about ${o} from namespace ${i}. Include stable facts and open gaps.`},{label:"Best pages",question:`Which extracted pages in namespace ${i} are most useful for a developer agent, and why?`},d?{label:"Walrus proof",question:`Explain the Walrus resources and verification signals for ${i}. Which resources should an agent trust first?`}:{label:"Context quality",question:`How complete is this namespace for ${o}? Identify missing pages or weak evidence.`},l.length?{label:"Recent changes",question:"Compare this namespace against previous runs for the same account. What likely changed and what should be rechecked?"}:{label:"First snapshot",question:`This appears to be the first snapshot for ${i}. What baseline should the account keep for later comparisons?`}];c.includes("developerDocs")&&u.push({label:"SDK / APIs",question:`Extract SDK setup, API endpoints, auth requirements, and integration steps from ${i}.`}),c.includes("pricing")&&u.push({label:"Pricing",question:`Find pricing, plans, limits, free tier, and commercial terms for ${o}.`}),(t.designSystem||t.brand)&&u.push({label:"Brand voice",question:`Summarize the brand voice, design tokens, and visual system for ${o} using this namespace.`});const h=(t.facts?.questions??[]).filter(p=>p.question&&!p.unanswerable).slice(0,5).map(p=>({label:ld(p),question:p.question}));return od(h.concat(u,id)).slice(0,7)}function ka(t,s,n,a){const i=Dt(t,s),o=Cs(t),r=n?`account ${ye(n)}`:"this account",d=t.pages.length,l=t.walrus?.resources.length??0,c=t.images.length,u=a.filter(p=>p.namespace===s?.manifest.namespace&&p.runId!==s?.manifest.runId),h=Sa(i);return[{title:"Use as agent context",detail:`${i} has ${d} pages${l?` and ${l} Walrus resources`:""}. Query the MCP namespace before asking agents to reason about ${o}.`},{title:`Recommended for ${r}`,detail:"Save the namespace, target, top pages, MCP URL, and known gaps as recall context so future chats do not restart from a blank crawl."},{title:"MCP endpoint",detail:h},{title:"Ask evidence-first questions",detail:c?`Start with best pages, SDK/API details, and visual/brand assets. This run also has ${c} extracted images.`:"Start with best pages, SDK/API details, target users, and missing evidence."},{title:u.length?"Compare with earlier run":"Create a baseline",detail:u.length?`${u.length} related run${u.length===1?"":"s"} found for this namespace. Ask what changed before publishing or remembering.`:"No earlier run for this namespace is loaded. Treat this as the baseline for later alerts and diffs."}]}function od(t){const s=new Set;return t.filter(n=>{const a=`${n.label}:${n.question}`;return s.has(a)?!1:(s.add(a),!0)})}const Na={what_is_it:"What is it",who_is_it_for:"Who it's for",how_it_works:"How it works",pricing:"Pricing",differentiators:"Differentiators",integrations:"Integrations",getting_started:"Get started",limitations:"Limitations",trust_security:"Trust & security"};function ld(t){return Na[t.category]??"Context Q"}function Dt(t,s){return s?.manifest.namespace||t.runId||Ps(t.target)||"current namespace"}function Cs(t){return t.designSystem?.identity.name||t.brand?.name||Ps(t.target)||t.target}function Ps(t){try{return new URL(t).hostname.replace(/^www\./,"")}catch{return t.replace(/^https?:\/\//,"").replace(/\/.*$/,"")}}function Sa(t){return typeof window>"u"?`/mcp?namespace=${encodeURIComponent(t)}`:`${window.location.origin}/mcp?namespace=${encodeURIComponent(t)}`}function cd(t){const s=[t.target,t.brand?.description,t.designSystem?.identity.description,...t.pages.slice(0,8).flatMap(a=>
388[a.title,a.url,a.markdown.slice(0,1400)])].filter(Boolean).join(` 389`).toLowerCase(),n=[];return/\b(api|sdk|developer|docs|quickstart|install|cli|endpoint|auth)\b/.test(s)&&n.push("developerDocs"),/\b(pricing|plan|billing|free tier|subscription|paid|quota|limit)\b/.test(s)&&n.push("pricing"),/\b(seal|encrypt|decrypt|access control|secret|private|policy)\b/.test(s)&&n.push("security"),/\b(walrus|sui|blob|object id|resource|quilt)\b/.test(s)&&n.push("walrus"),/\b(brand|design|token|color|font|component|style)\b/.test(s)&&n.push("brand"),n}function gn(t,s,n,a,i){const o=Dt(t,s),r=Cs(t),d=a?ye(a):"this account",l=dd(t,n,5),c=ka(t,s,a,i),u=t.pages.length,h=t.walrus?.resources.length??0,p=n.toLowerCase(),g=Sa(o),j=p.includes("pricing")?"Pricing terms were not assumed. If no pricing page appears in the sources below, treat pricing as unknown and ask the site owner to add it to the namespace.":p.includes("api")||p.includes("sdk")||p.includes("install")?"Focus on docs, SDK setup, auth, endpoints, and integration steps from the strongest extracted pages.":p.includes("remember")||p.includes("account")?`For ${d}, remember the namespace, target, MCP URL, strongest pages, and any gaps that should be refreshed later.`:"Use the namespace summary, strongest pages, and extracted Walrus proof before making product claims.";return{target:t.target,data:{answer:`From namespace ${o}, ${r} currently has ${u} extracted page${u===1?"":"s"}${h?` and ${h} verified Walrus resource${h===1?"":"s"}`:""}. ${j}`,recommendedForThisAccount:c.slice(0,4).map(f=>`${f.title}: ${f.detail}`),bestPagesToRead:l.length?l.map(f=>`${f.routePath??Ps(f.url)} â ${f.title??jn(f.markdown)??f.url}`):["No page-level markdown was available in this artifact."],agentNextSteps:[`Query MCP namespace: ${g}`,`Ask: "What should account ${d} remember about ${o}?"`,h?"Verify Walrus resource paths before citing object/blob proof.":"Re-run with Walrus mode if object/resource proof is required."],confidenceNote:"Client-side namespace answer. It uses the extracted manifest and page markdown because the hosted AI Query route is not available for public demo jobs yet."},confidence:l.length?.62:.42,usedProvider:"namespace heuristic",sources:l.map(f=>({url:f.url,routePath:f.routePath,resourcePath:f.source?.resourcePath??f.artifactPath,blobId:f.source?.blobId,quote:jn(f.markdown)}))}}function dd(t,s,n){const a=s.toLowerCase().split(/[^a-z0-9]+/g).filter(i=>i.length>2&&!["the","and","for","this","that","with","from","what","how"].includes(i));return t.pages.map((i,o)=>{const r=[i.title,i.routePath,i.url,i.markdown.slice(0,4e3)].filter(Boolean).join(" ").toLowerCase(),d=a.reduce((l,c)=>l+(r.includes(c)?2:0),0)+(i.title?1:0)+Math.max(0,4-o)*.1;return{page:i,score:d}}).sort((i,o)=>o.score-i.score).slice(0,n).map(i=>i.page)}function jn(t){if(!t)return;const s=t.replace(/```[\s\S]*?```/g," ").replace(/!\[[^\]]*]\([^)]*\)/g," ").replace(/\[[^\]]+]\([^)]*\)/g,a=>a.replace(/^\[|\]\([^)]*\)$/g,"")).replace(/[#*_>`~|-]/g," ").replace(/\s+/g," ").trim(),n=s.split(new RegExp("(?<=[.!?])\\s+")).find(a=>a.length>=48)??s.slice(0,180);return n?`${n.slice(0,220)}${n.length>220?"...":""}`:void 0}function yn(t,s,n){return n.pages.length?t===404||t===501?!0:le(D)&&/not found|ai query|openai/i.test(s):!1}function Ca({artifact:t,run:s,setArtifact:n,authToken:a,history:i,accountLabel:o}){const[r,d]=x.useState(""),[l,c]=x.useState(!1),[u,h]=x.useState(`{ 390 "answer": { "type": "text", "description": "Direct answer to the question" }, 391 "keyFacts": { "type": "list", "description": "Important facts with source support" } 392}`),[p,g]=x.useState(!1),[j,f]=x.useState(null),[b,y]=x.useState(()=>t.aiQuery?[{id:"initial",question:"(previous query)",result:t.aiQuery,at:""}]:[]),w=x.useMemo(()=>rd(t,s,o,i),[t,s?.manifest.namespace,s?.manifest.runId,o,i]),v=x.useMemo(()=>ka(t,s,o,i),[t,s?.manifest.namespace,s?.manifest.runId,o,i]),S=Dt(t,s);x.useEffect(()=>{y(t.aiQuery?[{id:"initial",question:"(previous query)",result:t.aiQuery,at:""}]:[]),f(null),d("")},[t.runId,t.target,s?.manifest.runId]);function T(N,L){n(z=>z&&{...z,aiQuery:L}),y(z=>[...z,{id:`${Date.now()}`,question:N,result:L,at:new Date().toISOString()}]),d("")}async function k(N){if(!s)return;const L=(N??r).trim();if(!L)return;g(!0),f(null);let z;try{z=l&&u.trim()?JSON.parse(u):void 0}
392catch{f("Structured schema is not valid JSON."),g(!1);return}try{const m=await fetch(`${D}/api/runs/${s.manifest.runId}/ai-query`,{method:"POST",headers:G(a,{"content-type":"application/json"}),body:JSON.stringify({question:L,schema:z})});if(!m.ok){const P=await Q(m);if(yn(m.status,P,t)){T(L,gn(t,s,L,o,i));return}throw new Error(P)}const M=await m.json();T(L,M)}catch(m){const M=m instanceof Error?m.message:String(m);yn(null,M,t)?T(L,gn(t,s,L,o,i)):f(M)}finally{g(!1)}}return e.jsxs("div",{className:"panel queryPanel aiChatPanel",children:[e.jsxs("section",{className:"aiNamespaceBrief",children:[e.jsxs("div",{className:"aiNamespaceBriefHead",children:[e.jsxs("span",{children:[e.jsx(pe,{size:15}),"Recommended for this namespace"]}),e.jsx("code",{children:S}),o?e.jsx("small",{children:ye(o)}):null]}),e.jsx("div",{className:"aiRecommendationGrid",children:v.slice(0,4).map(N=>e.jsxs("article",{children:[e.jsx("strong",{children:N.title}),e.jsx("p",{children:N.detail})]},N.title))})]}),e.jsx("section",{className:"aiChatStream","aria-live":"polite",children:b.length===0?e.jsxs("div",{className:"aiChatEmpty",children:[e.jsx(Ee,{size:20}),e.jsx("strong",{children:"Ask anything about this context"}),e.jsx("span",{children:"Suggested prompts are tuned to this namespace and account. Hosted runs query Workers AI server-side over the extracted pages; client-side fallback only kicks in if the worker endpoint is unreachable."})]}):b.map(N=>e.jsxs("article",{className:"aiChatTurn",children:[e.jsxs("div",{className:"aiChatUser",children:[e.jsx("span",{children:"You"}),e.jsx("p",{children:N.question})]}),e.jsxs("div",{className:"aiChatAssistant",children:[e.jsxs("div",{className:"aiChatAssistantHead",children:[e.jsx("span",{children:"ContextMeM"}),e.jsxs("small",{children:[N.result.usedProvider," · ",Math.round(N.result.confidence*100),"%"]})]}),e.jsx(Ms,{data:N.result.data}),N.result.sources.length?e.jsxs("details",{className:"aiChatSources",children:[e.jsxs("summary",{children:[N.result.sources.length," source",N.result.sources.length===1?"":"s"]}),e.jsx("div",{className:"sourceGrid",children:N.result.sources.map((L,z)=>e.jsxs("article",{children:[e.jsx("strong",{children:L.routePath??L.url}),L.quote?e.jsx("p",{children:L.quote}):null,e.jsx("code",{children:L.resourcePath??L.blobId??L.url})]},`${L.url}-${z}`))})]}):null]})]},N.id))}),e.jsxs("section",{className:"aiChatComposer",children:[e.jsx("div",{className:"memoryQuickPrompts aiPrompts",children:w.map(N=>e.jsx("button",{type:"button",onClick:()=>{k(N.question)},disabled:!s||p,children:N.label},N.label))}),e.jsxs("form",{className:"aiChatForm",onSubmit:N=>{N.preventDefault(),k()},children:[e.jsx("textarea",{value:r,onChange:N=>d(N.target.value),placeholder:"Ask about this site⦠pricing, APIs, tone, target users, recent changes",rows:2,onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),k())}}),e.jsxs("button",{className:"run inline",type:"submit",disabled:!s||p||!r.trim(),children:[e.jsx(Ee,{size:16}),p?"Asking":"Ask"]})]}),e.jsxs("button",{type:"button",className:"aiChatAdvancedToggle",onClick:()=>c(N=>!N),children:[l?"Hide":"Show"," structured schema (advanced)"]}),l?e.jsxs("label",{className:"aiChatSchema",children:[e.jsx("span",{children:"Structured schema (JSON)"}),e.jsx("textarea",{value:u,onChange:N=>h(N.target.value),spellCheck:!1,rows:5})]}):null,j?e.jsxs("div",{className:"error",children:[j,e.jsx(Lt,{message:j})]}):null]})]})}function Ms({data:t}){const s=Object.entries(t??{}).filter(([,n])=>!hd(n));return s.length?e.jsx("div",{className:"aiResultData",children:s.map(([n,a])=>e.jsxs("article",{className:"aiResultCard",children:[e.jsx("span",{children:Pa(n)}),e.jsx(ud,{value:a})]},n))}):e.jsx("div",{className:"subEmpty aiResultEmpty",children:"No structured data returned."})}function ud({value:t}){if(Array.isArray(t)){const n=t.map(a=>ds(a)).filter(Boolean);return n.length?e.jsx("ul",{className:"aiAnswerList",children:n.map((a,i)=>e.jsx("li",{children:e.jsx(xn,{inline:!0,children:a})},`${a}-${i}`))}):null}if(t&&typeof t=="object")return e.jsx("pre",{className:"compactJson",children:JSON.stringify(t,null,2)});const s=ds(t);return s?e.jsx("div",{className:"aiTextAnswer",children:e.jsx(xn,{children:s})}):null}function ds(t){return typeof t=="string"?t.trim():typeof t=="number"||typeof t=="boolean"?String(t):t==null?"":JSON.stringify(t)}function hd(t){return t==null?!0:typeof t=="string"?t.trim().length===0:Array.isArray(t)?t.map(s=>
392ds(s)).filter(Boolean).length===0:typeof t=="object"?Object.keys(t).length===0:!1}function Pa(t){return t.replaceAll(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,s=>s.toUpperCase())}function md(t){return{claudeDesktop:"Claude Desktop",contextMcpGateway:"Gateway",mcpRemote:"mcp-remote",generic:"Generic MCP",cursor:"Cursor",codex:"Codex"}[t]??Pa(t)}function Ma({run:t,authToken:s}){const[n,a]=x.useState([]),[i,o]=x.useState(null),[r,d]=x.useState(""),[l,c]=x.useState(null);x.useEffect(()=>{t&&u()},[t?.manifest.runId]);async function u(){if(t){c(null);try{const p=await fetch(`${D}/api/runs/${t.manifest.runId}/artifact-files`,{headers:G(s)});if(!p.ok)throw new Error(await Q(p));const g=await p.json();a(g),o(g.find(j=>j.path==="/context/design-system.json")??g.find(j=>j.previewable)??g[0]??null)}catch(p){c(p instanceof Error?p.message:String(p))}}}x.useEffect(()=>{if(!t||!i||i.kind==="image"){d("");return}if(!i.previewable){d("Preview unavailable for this file.");return}fetch(we(t.manifest.runId,i.path,s),{headers:G(s)}).then(p=>p.ok?p.text():p.text().then(g=>Promise.reject(new Error(g)))).then(d).catch(p=>d(p instanceof Error?p.message:String(p)))},[s,t?.manifest.runId,i?.path]);const h=n.reduce((p,g)=>(p[g.group]=[...p[g.group]??[],g],p),{});return e.jsxs("div",{className:"panel artifactPanel",children:[e.jsxs("aside",{className:"artifactList",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Artifacts"}),e.jsxs("span",{children:[n.length," files"]})]}),l?e.jsx("div",{className:"error",children:l}):null,Object.entries(h).map(([p,g])=>e.jsxs("section",{children:[e.jsx("h3",{children:p}),g.map(j=>e.jsxs("button",{className:i?.path===j.path?"selected":"",onClick:()=>o(j),children:[e.jsx(It,{size:14}),e.jsx("span",{children:j.path}),e.jsx("small",{children:ve(j.size)})]},j.path))]},p))]}),e.jsx("section",{className:"artifactPreview",children:i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"artifactPreviewHead",children:[e.jsxs("div",{children:[e.jsx("strong",{children:i.path}),e.jsxs("span",{children:[i.contentType," · ",ve(i.size)]})]}),e.jsxs("a",{className:"downloadLink",href:`${we(t?.manifest.runId,i.path,s)}&download=1`,children:[e.jsx(Ji,{size:15}),"Download"]})]}),i.kind==="image"?e.jsx("div",{className:"artifactImage",children:e.jsx("img",{src:we(t?.manifest.runId,i.path,s),alt:i.path})}):e.jsx("pre",{children:r})]}):e.jsx("div",{className:"subEmpty",children:"No artifacts found for this run."})})]})}function pd({history:t,authToken:s}){const[n,a]=x.useState(""),[i,o]=x.useState(""),[r,d]=x.useState(null),[l,c]=x.useState(null),[u,h]=x.useState(null),[p,g]=x.useState(null);x.useEffect(()=>{if(t.length>=2&&!n&&!i){const f=t[0],b=t[1];f&&a(f.runId),b&&o(b.runId)}},[t,n,i]);async function j(f,b){if(!f){b==="left"?d(null):c(null);return}g(b),h(null);try{const y=await fetch(`${D}/api/runs/${encodeURIComponent(f)}/artifact-file?path=context/manifest.json`,{headers:G(s)});if(!y.ok)throw new Error(await Q(y));const w=await y.json();b==="left"?d(w):c(w)}catch(y){h(y instanceof Error?y.message:String(y))}finally{g(null)}}return x.useEffect(()=>{j(n,"left")},[n]),x.useEffect(()=>{j(i,"right")},[i]),e.jsxs("section",{className:"comparePage",children:[e.jsxs("header",{className:"compareHead",children:[e.jsxs("label",{children:[e.jsx("span",{children:"Left run"}),e.jsxs("select",{value:n,onChange:f=>a(f.target.value),children:[e.jsx("option",{value:"",children:"â pick a run â"}),t.map(f=>e.jsxs("option",{value:f.runId,children:[je(f.target)," · ",f.mode," · ",new Date(f.updatedAt).toLocaleDateString()]},f.runId))]})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Right run"}),e.jsxs("select",{value:i,onChange:f=>o(f.target.value),children:[e.jsx("option",{value:"",children:"â pick a run â"}),t.map(f=>e.jsxs("option",{value:f.runId,children:[je(f.target)," · ",f.mode," · ",new Date(f.updatedAt).toLocaleDateString()]},f.runId))]})]})]}),u?e.jsxs("div",{className:"errorState panel",children:[e.jsx("p",{children:u}),e.jsx(Lt,{message:u})]}):null,p?e.jsx("div",{className:"subEmpty",children:"Loading manifestâ¦"}):null,e.jsxs("div",{className:"compareGrid",children:[e.jsx(bn,{label:"Left",manifest:r}),e.jsx(bn,{label:"Right",manifest:l})]})]})}function bn({label:t,manifest:s}){if(!s)return e.jsxs("div",{className:"compareColumn panel subEmpty",children:["No run selected for ",t.toLowerCase(),"."]});const n=s.brand?.colors?.slice(0,8)??s.styleguide?.colors?.palette?.slice(0,8)??[],a=s.brand?.fonts??s.styleguide?.typography.fontFamilies??[],i=(s.pages??[]).slice(0,6),o=s.designSystem?.tokens.colors.slice(0,8)??[];return e.jsxs("article",{className:"compareColumn panel",children:[e.jsxs("header",{children:[e.jsx("span",{children:t}),e.jsx("strong",{children:s.brand?.name??s.brand?.domain??je(s.target)}),e.jsx("code",{children:je(s.target)})]}),e.jsxs("section",{className:"compareSection",children:[e.jsx("h3",{children:"Brand"}),s.brand?.description?e.jsx("p",{children:s.brand.description}):e.jsx("p",{className:"subEmpty",children:"No brand description extracted."}),e.jsx("div",{className:"comparePalette",children:n.length?n.map(r=>e.jsx("span",{style:{background:r},title:r,children:e.jsx("small",{children:r})},r)):e.jsx("span",{className:"subEmpty",children:"No palette"})}),e.jsx("div",{className:"compareFonts",children:a.slice(0,4).map(r=>e.jsx("code",{children:r},r))})]}),e.jsxs("section",{className:"compareSection",children:[e.jsx("h3",{children:"Design tokens"}),o.length?e.jsx("div",{className:"comparePalette",children:o.map(r=>e.jsx("span",{style:{background:r.value},title:`${r.name} â ${r.value}`,children:e.jsx("small",{children:r.name})},`${r.name}-${r.value}`))}):e.jsx("p",{className:"subEmpty",children:"No design system extracted."})]}),e.jsxs("section",{className:"compareSection",children:[e.jsxs("h3",{children:["Pages (",s.pages?.length??0,")"]}),e.jsx("ul",{className:"compareList",children:i.map(r=>e.jsxs("li",{children:[e.jsx("strong",{children:r.title??r.routePath??r.url}),e.jsx("span",{children:r.routePath??r.url})]},r.url))})]}),s.walrus?e.jsxs("section",{className:"compareSection",children:[e.jsx("h3",{children:"Walrus"}),e.jsxs("p",{children:[e.jsxs("code",{children:[s.walrus.site.siteObjectId.slice(0,18),"â¦"]}),s.walrus.site.suinsName?e.jsxs(e.Fragment,{children:[" · ",s.walrus.site.suinsName]}):null]}),e.jsxs("small",{children:[s.walrus.resources.length," resources verified"]})]}):null]})}function _a({run:t,authToken:s}){const[n,a]=x.useState(null),[i,o]=x.useState(null),[r,d]=x.useState("private"),[l,c]=x.useState(!1),[u,h]=x.useState(""),[p,g]=x.use
392State(""),[j,f]=x.useState(""),[b,y]=x.useState(""),[w,v]=x.useState(!1),[S,T]=x.useState(null),[k,N]=x.useState(null),[L,z]=x.useState(!1),[m,M]=x.useState(null);x.useEffect(()=>{t&&(o(null),a(null),T(null),N(null),h(t.manifest.namespace),g(os(t.manifest.target)),f(""),y(t.manifest.mode==="walrus"?"walrus,context":"web,context"),fetch(`${D}/api/runs/${t.manifest.runId}/publish-readiness`,{headers:G(s)}).then(_=>_.ok?_.json():_.text().then(O=>Promise.reject(new Error(O)))).then(_=>{const O=_??{};a({ready:!!O.ready,routeCount:O.routeCount??0,artifactCount:O.artifactCount??0,totalBytes:O.totalBytes??0,required:O.required??[],optional:O.optional??[],warnings:O.warnings??(O.missing??[]).map(q=>`Missing required package file: ${q}`),commands:O.commands??{publish:""},files:O.files??[]})}).catch(_=>o(_ instanceof Error?_.message:String(_))))},[s,t?.manifest.runId]);async function P(){if(t){v(!0),T(null);try{const _=await fetch(`${D}/api/runs/${t.manifest.runId}/hosted/import`,{method:"POST",headers:G(s,{"content-type":"application/json"}),body:JSON.stringify({visibility:r,namespace:u||t.manifest.namespace,displayName:p||os(t.manifest.target),description:j||void 0,tags:b.split(",").map(O=>O.trim()).filter(Boolean),directoryEnabled:r==="public"&&l})});if(!_.ok)throw new Error(await Q(_));N(await _.json())}catch(_){T(_ instanceof Error?_.message:String(_))}finally{v(!1)}}}async function F(){if(t){z(!0),T(null);try{const _=await fetch(`${D}/api/runs/${t.manifest.runId}/share`,{method:"POST",headers:G(s,{"content-type":"application/json"}),body:JSON.stringify({title:p||os(t.manifest.target),description:j||void 0})});if(!_.ok)throw new Error(await Q(_));M(await _.json())}catch(_){T(_ instanceof Error?_.message:String(_))}finally{z(!1)}}}return t?i?e.jsx("div",{className:"panel",children:e.jsx("div",{className:"error",children:i})}):n?e.jsxs("div",{className:"panel publishPanel",children:[e.jsxs("section",{className:"publishHero",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Walrus package readiness"}),e.jsx("h2",{children:n.ready?"Ready to publish":"Needs files"})]}),e.jsxs("div",{className:"publishStats",children:[e.jsx("strong",{children:n.routeCount}),e.jsx("span",{children:"routes"}),e.jsx("strong",{children:n.artifactCount}),e.jsx("span",{children:"artifacts"}),e.jsx("strong",{children:ve(n.totalBytes)}),e.jsx("span",{children:"package"})]})]}),e.jsxs("section",{className:"designSection split",children:[e.jsxs("article",{children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Required Files"}),e.jsx("span",{children:"static package"})]}),e.jsx(kn,{files:n.required})]}),e.jsxs("article",{children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Optional Exports"}),e.jsx("span",{children:"agent/design extras"})]}),e.jsx(kn,{files:n.optional})]})]}),n.warnings.length?e.jsx("section",{className:"warningList",children:n.warnings.map(_=>e.jsx("div",{children:_},_))}):null,n.commands.publish?e.jsxs("section",{className:"commandBox",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Publish Commands"}),e.jsx("span",{children:"run locally with site-builder"})]}),e.jsx("code",{children:n.commands.publish}),e.jsxs("button",{onClick:()=>navigator.clipboard.writeText(n.commands.publish),children:[e.jsx(me,{size:15}),"Copy publish command"]}),n.commands.update?e.jsx("code",{children:n.commands.update}):null]}):null,e.jsxs("section",{className:"namespacePanel",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Hosted MCP Namespace"}),e.jsx("span",{children:t.manifest.namespace})]}),e.jsxs("div",{className:"namespaceForm",children:[e.jsxs("label",{children:[e.jsx("span",{children:"Namespace"}),e.jsx("input",{value:u,onChange:_=>h(_.target.value),placeholder:"team.project or walrus:mainnet:0x..."})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Display name"}),e.jsx("input",{value:p,onChange:_=>g(_.target.value),placeholder:"Docs, product, client, or project name"})]}),e.jsxs("label",{className:"wide",children:[e.jsx("span",{children:"Description"}),e.jsx("input",{value:j,onChange:_=>f(_.target.value),placeholder:"Short note shown in your namespace dashboard and public directory"})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Tags"}),e.jsx("input",{value:b,onChange:_=>y(_.target.value),placeholder:"walrus, docs, design"})]})]}),e.jsxs("div",{className:"namespaceControls",children:[e.jsxs("div",{className:"segmented compact",children:[e.jsx("button",{className:r==="private"?"selected":"",onClick:()=>d("private"),children:"Private"}),e.jsx("button",{className:r==="public"?"selected":"",onClick:()=>d("public"),children:"Public"})]}),e.jsxs("label",{className:"inlineCheck",children:[e.jsx("input",{type:"checkbox",checked:l,disabled:r!=="public",onChange:_=>c(_.target.checked)}),"Directory"]}),e.jsxs("button",{className:"secondary",onClick:P,disabled:w,children:[e.jsx(Te,{size:15}),w?"Publishing":"Publish MCP namespace"]}),e.jsxs("button",{className:"secondary",onClick:F,disabled:L,children:[e.jsx(Fn,{size:15}),L?"Creating":"Create share page"]})]}),S?e.jsx("div",{className:"error",children:S}):null,m?e.jsxs("label",{className:"shareResultLink",children:[e.jsx("span",{children:"Share URL"}),e.jsx("code",{children:m.url}),e.jsxs("button",{onClick:()=>navigator.clipboard.writeText(m.url),children:[e.jsx(me,{size:14}),"Copy"]})]}):null,k?e.jsxs("div",{className:"namespaceResult",children:[e.jsxs("div",{className:"namespaceMeta",children:[e.jsxs("div",{children:[e.jsx("span",{children:"version"}),e.jsx("strong",{children:k.versionId})]}),e.jsxs("div",{children:[e.jsx("span",{children:"artifacts"}),e.jsx("strong",{children:k.artifactCount})]}),e.jsxs("div",{children:[e.jsx("span",{children:"size"}),e.jsx("strong",{children:ve(k.byteLength)})]})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Gateway"}),e.jsx("code",{children:k.gatewayMcpUrl??""}),e.jsxs("button",{onClick:()=>navigator.clipboard.writeText(k.gatewayMcpUrl??""),children:[e.jsx(me,{size:14}),"Copy"]})]}),e.jsxs("label",{children:[e.jsx("span",{children:"MCP URL"}),e.jsx("code",{children:k.mcpUrl}),e.jsxs("button",{onClick:()=>navigator.clipboard.writeText(k.mcpUrl),children:[e.jsx(me,{size:14}),"Copy"]})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Read token"}),e.jsx("code",{className:"secretToken",children:k.readToken}),e.jsxs("button",{onClick:()=>navigator.clipboard.writeText(k.readToken),children:[e.jsx(me,{size:14}),"Copy"]})]}),e.jsx("div",{className:"snippetGrid",children:Object.entries(k.snippets).filter(([,_])=>!!_).map(([_,O])=>e.jsxs("article",{children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:md(_)}),e.jsxs("button",{onClick:()=>navigator.clipboard.writeText(JSON.stringify(O,null,2)),children:[e.jsx(me,{size:14}),"Copy"]})]}),e.jsx("pre",{children:JSON.stringify(O,null,2)})]},_))})]}):null]})]}):e.jsx("div",{className:"empty",children:"Loading publish package..."}):e.jsxs("div",{className:"panel subEmpty",children:["No run selected. Build or open a run to check publish readiness. ",e.jsx(ge,{to:"/app",children:"Open Build"})]})}function ss(t){const s=new Date(t).getTime();if(Number.isNaN(s))return"â";const n=Math.max(1,Math.floor((Date.now()-s)/6e4));if(n<60)return`${n}m`;const a=Math.floor(n/60);if(a<24)return`${a}h`;const i=Math.floor(a/24);if(i<7)return`${i}d`;const o=Math.floor(i/7);return o<5?`${o}w`:`${Math.floor(i/30)}mo`}function fd(t){const s=(t.status??"").toLowerCase();return(t.errors?.length??0)>0||s==="failed"||s==="error"?{label:"failed",tone:"failed"}:s==="running"||s==="queued"||s==="processing"||s==="pending"?{label:"running",tone:"running"}
392:{label:"done",tone:"done"}}function xd({history:t}){const s=mt(),[n,a]=x.useState([]),[i,o]=x.useState(!0),[r,d]=x.useState(null);x.useEffect(()=>{let b=!1;return(async()=>{try{const w=await(await fetch(`${D}/api/memwal/facts`)).json();b||a(w.namespaces??[])}catch{}finally{b||o(!1)}})(),()=>{b=!0}},[]);const l=n.reduce((b,y)=>b+(y.entities??0),0),c=n.filter(b=>b.proof?.certified).length,u=n.length>0&&c===n.length,h=t.slice(0,4),p=t.length?t.reduce((b,y)=>new Date(y.updatedAt).getTime()>new Date(b.updatedAt).getTime()?y:b):null,g=t.filter(b=>(b.errors?.length??0)>0||(b.status??"").toLowerCase()==="failed"),j=g.length;function f(b){const w=`${le(D)?window.location.origin:D}/mcp?namespace=${encodeURIComponent(b)}`;navigator.clipboard.writeText(w),d(b),window.setTimeout(()=>d(v=>v===b?null:v),1600)}return e.jsxs("div",{className:"ovPage",children:[e.jsx("div",{className:"ovHead",children:e.jsxs("button",{type:"button",className:"ovBuildBtn",onClick:()=>s("/app"),children:[e.jsx(er,{size:15}),"Build context"]})}),e.jsxs("div",{className:"ovStatGrid",children:[e.jsxs("div",{className:"ovStatCard",children:[e.jsxs("div",{className:"ovStatTop",children:[e.jsx("span",{className:"ovStatLabel",children:"Namespaces"}),e.jsx("span",{className:"ovStatIcon",children:e.jsx(xe,{size:15})})]}),e.jsx("div",{className:"ovStatNum",children:n.length}),e.jsx("div",{className:"ovStatSub",children:"live on mainnet"})]}),e.jsxs("div",{className:"ovStatCard",children:[e.jsxs("div",{className:"ovStatTop",children:[e.jsx("span",{className:"ovStatLabel",children:"Artifacts"}),e.jsx("span",{className:"ovStatIcon",children:e.jsx(ke,{size:15})})]}),e.jsx("div",{className:"ovStatNum",children:l.toLocaleString()}),e.jsx("div",{className:`ovStatSub ${u?"isGood":""}`,children:u?"100% verified":`${c} verified`})]}),e.jsxs("div",{className:"ovStatCard",children:[e.jsxs("div",{className:"ovStatTop",children:[e.jsx("span",{className:"ovStatLabel",children:"Snapshots"}),e.jsx("span",{className:"ovStatIcon",children:e.jsx(nt,{size:15})})]}),e.jsx("div",{className:"ovStatNum",children:t.length}),e.jsx("div",{className:"ovStatSub",children:p?`last ${ss(p.updatedAt)} ago`:"â"})]}),e.jsxs("div",{className:"ovStatCard",children:[e.jsxs("div",{className:"ovStatTop",children:[e.jsx("span",{className:"ovStatLabel",children:"Open alerts"}),e.jsx("span",{className:"ovStatIcon isAlert",children:e.jsx(We,{size:15})})]}),e.jsx("div",{className:"ovStatNum isAlert",children:j}),e.jsx("div",{className:"ovStatSub",children:j?`${j} run${j>1?"s":""} need attention`:"All clear"})]})]}),e.jsxs("div",{className:"ovPanelGrid",children:[e.jsxs("div",{className:"ovPanel",children:[e.jsxs("div",{className:"ovPanelHead",children:[e.jsx("span",{children:"Recent runs"}),e.jsx("button",{type:"button",className:"ovLink",onClick:()=>s("/app/runs"),children:"View all â"})]}),e.jsx("div",{className:"ovRunList",children:h.length?h.map(b=>{const y=fd(b),w=(b.pages??0)+(b.images??0)+(b.resources??0);return e.jsxs("div",{className:"ovRunRow",children:[e.jsxs("div",{className:"ovRunMeta",children:[e.jsx("span",{className:"ovRunTitle",children:b.namespace||je(b.target)}),e.jsxs("span",{className:"ovRunSub",children:[w," artifacts · ",b.mode]})]}),e.jsx("span",{className:"ovRunTime",children:ss(b.updatedAt)}),e.jsxs("span",{className:`ovStatusPill ${y.tone}`,children:[e.jsx("span",{className:"ovDot"}),y.label]})]},b.runId)}):e.jsx("div",{className:"ovRunEmpty",children:"No runs yet. Build a context package to get started."})})]}),e.jsxs("div",{className:"ovPanel",children:[e.jsx("div",{className:"ovPanelHead",children:e.jsx("span",{children:"Alerts"})}),e.jsx("div",{className:"ovAlertList",children:g.length?g.slice(0,6).map(b=>e.jsxs("div",{className:"ovAlert",children:[e.jsx("span",{className:"ovAlertDot"}),e.jsxs("div",{children:[e.jsx("div",{className:"ovAlertTitle",children:"Run failed"}),e.jsx("div",{className:"ovAlertSub",children:(b.namespace||je(b.target))+" · "+(b.errors?.[0]??"build did not complete")})]})]},b.runId)):e.jsxs("div",{className:"ovAlertEmpty",children:[e.jsx(Ze,{size:18}),e.jsxs("div",{children:[e.jsx("div",{className:"ovAlertTitle",children:"No open alerts"}),e.jsx("div",{className:"ovAlertSub",children:"Every run finished cleanly. Drift and webhook checks surface here."})]})]})})]})]}),e.jsxs("div",{className:"ovPanel ovTableCard",children:[e.jsxs("div",{className:"ovPanelHead",children:[e.jsx("span",{children:"Namespaces"}),e.jsx("button",{type:"button",className:"ovLink",onClick:()=>s("/app/namespaces"),children:"Manage â"})]}),e.jsx("div",{className:"ovTableWrap",children:e.jsxs("table",{className:"ovTable",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"NAMESPACE"}),e.jsx("th",{children:"VISIBILITY"}),e.jsx("th",{children:"ARTIFACTS"}),e.jsx("th",{children:"SNAPSHOT"}),e.jsx("th",{children:"MCP"})]})}),e.jsx("tbody",{children:n.map(b=>{const y=t.find(v=>
392v.namespace===b.namespace),w=y?`${ss(y.updatedAt)} ago`:"â";return e.jsxs("tr",{children:[e.jsx("td",{className:"ovNsName",children:b.namespace}),e.jsx("td",{children:e.jsx("span",{className:"ovVisPill",children:"public"})}),e.jsx("td",{className:"ovMono",children:b.entities}),e.jsx("td",{className:"ovSnap",children:w}),e.jsx("td",{children:e.jsx("button",{type:"button",className:"ovCopy",onClick:()=>f(b.namespace),children:r===b.namespace?e.jsxs(e.Fragment,{children:[e.jsx(Ze,{size:12})," copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(me,{size:12})," copy"]})})})]},b.namespace)})})]})}),i?e.jsx("div",{className:"ovTableEmpty",children:"Loading namespacesâ¦"}):n.length?null:e.jsx("div",{className:"ovTableEmpty",children:"No namespaces yet. Build a context package to create one."})]})]})}function gd(){const t=mt(),[s,n]=x.useState([]),[a,i]=x.useState(!0);return x.useEffect(()=>{let o=!1;return(async()=>{try{const d=await(await fetch(`${D}/api/memwal/facts`)).json();o||n(d.namespaces??[])}catch{}finally{o||i(!1)}})(),()=>{o=!0}},[]),e.jsxs("section",{className:"appPanelStack",children:[e.jsx("div",{className:"nsSimpleGrid",children:s.map(o=>e.jsxs("button",{type:"button",className:"nsSimpleCard",onClick:()=>t(`/app/memory?ns=${encodeURIComponent(o.namespace)}`),children:[e.jsxs("div",{className:"nsSimpleHead",children:[e.jsx(xe,{size:16}),e.jsx("strong",{children:o.displayName}),o.proof?.certified?e.jsx("span",{className:"nsSimpleProof",title:`Walrus blob ${o.proof.blobId}`,children:"â Walrus"}):null]}),e.jsx("code",{children:o.namespace}),e.jsx("span",{className:"nsSimpleTarget",children:o.target}),e.jsxs("div",{className:"nsSimpleCounts",children:[e.jsxs("span",{children:[o.entities," entities"]}),e.jsxs("span",{children:[o.relationships," links"]}),e.jsxs("span",{children:[o.topics," topics"]}),e.jsxs("span",{children:[o.questions," Q&A"]})]}),e.jsx("span",{className:"nsSimpleBrowse",children:"Browse knowledge â"})]},o.namespace))}),a?e.jsx("div",{className:"panel subEmpty",children:"Loading namespacesâ¦"}):s.length?null:e.jsx("div",{className:"panel subEmpty",children:"No namespaces yet. Build a context package to create one."})]})}function Ta({artifact:t,run:s,history:n,refreshHistory:a,authToken:i,onRemember:o,rememberBusy:r=!1,notice:d}){const[l,c]=x.useState("What changed or should the agent remember about this site?"),[u,h]=x.useState(null),[p,g]=x.useState(null),[j,f]=x.useState(null),[b,y]=x.useState(null),[w,v]=x.useState(null),[S,T]=x.useState(null),[k,N]=x.useState(()=>[wn(t,s)]),L=x.useRef(null),z=n.filter(P=>P.runId!==s?.manifest.runId&&P.namespace===s?.manifest.namespace).slice(0,5);x.useEffect(()=>{s&&M()},[s?.manifest.runId]),x.useEffect(()=>{N([wn(t,s)]),h(null),g(null),T(null)},[t.runId,s?.manifest.runId]),x.useEffect(()=>{L.current?.scrollTo({top:L.current.scrollHeight,behavior:"smooth"})},[k,w]);async function m(P){if(!s)return;const F=l.trim();if(!F)return;const _=P==="recall"?"memwal/recall":"memwal/query",O=P==="recall"?h:g,q={id:ns("user"),role:"user",content:F,mode:P};N($=>[...$,q]),v(_),T(null);try{const $=await fetch(`${D}/api/runs/${s.manifest.runId}/${_}`,{method:"POST",headers:G(i,{"content-type":"application/json"}),body:JSON.stringify({query:F})});if(!$.ok)throw new Error(await Q($));const K=await $.json();O(K),N(U=>[...U,{id:ns("assistant"),role:"assistant",mode:P,content:us(K,P),data:K}]),await a()}catch($){const K=jd($ instanceof Error?$.message:String($),P);T(null),N(U=>[...U,{id:ns("error"),role:"assistant",mode:P,content:K}])}finally{v(null)}}async function M(P){if(s)try{const F=await fetch(`${D}/api/runs/${s.manifest.runId}/diff`,{method:"POST",headers:G(i,{"content-type":"application/json"}),body:JSON.stringify({compareToRunId:P})});F.ok&&f(await F.json());const _=await fetch(`${D}/api/runs/${s.manifest.runId}/visual-diff`,{method:"POST",headers:G(i,{"content-type":"application/json"}),body:JSON.stringify({compareToRunId:P})});_.ok&&y(await _.json())}catch{f(null),y(null)}}return e.jsxs("div",{className:"panel memwalPanel memoryChatPanel",children:[e.jsxs("section",{className:"memoryChatShell","aria-label":"Walrus Memory chat",children:[e.jsxs("header",{className:"memoryChatHeader",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Namespace"}),e.jsx("strong",{children:s?.manifest.namespace??"not synced"}),e.jsxs("p",{children:[t.pages.length," pages · ",t.walrus?.resources.length??0," resources · ",t.designSystem?.tokens.colors.length??0," color tokens"]})]}),e.jsxs("div",{className:"memoryHeaderActions",children:[e.jsxs("div",{className:"memoryStatusDots","aria-label":"Memory package status",children:[e.jsx("span",{children:"verified"}),e.jsx("span",{children:"mainnet"})]}),e.jsxs("button",{type:"button",onClick:o,disabled:!s||!o||r,children:[e.jsx(pe,{size:15}),r?"Remembering":"Remember run"]})]})]}),d?e.jsx(xt,{notice:d}):null,e.jsx("div",{className:"memoryQuickPrompts","aria-label":"Prompt shortcuts",children:["What changed since the last snapshot?","What should an agent remember?","Summarize important docs pages"].map(P=>e.jsx("button",{type:"button",onClick:()=>c(P),children:P},P))}),e.jsx("div",{className:"memoryChatLog",ref:L,role:"log","aria-live":"polite","aria-relevant":"additions text",children:e.jsxs("div",{className:"memoryChatLogInner",children:[k.map(P=>e.jsxs("article",{className:`memoryBubble ${P.role} ${P.mode??""}`,children:[e.jsx("div",{className:"memoryBubbleIcon",children:P.role==="user"?e.jsx(Dn,{size:16}):P.mode==="recall"?e.jsx(pe,{size:16}):e.jsx(Ee,{size:16})}),e.jsxs("div",{children:[e.jsx("span",{children:P.role==="user"?P.mode==="recall"?"Recall prompt":"Memory question":P.mode==="recall"?"Walrus Memory recall":"ContextMeM memory"}),e.jsx("p",{children:P.content}),P.data?e.jsxs("details",{children:[e.jsx("summary",{children:"Raw response"}),e.jsx(gt,{data:P.data})]}):null]})]},P.id)),w?e.jsxs("article",{className:"memoryBubble assistant loading",children:[e.jsx("div",{className:"memoryBubbleIcon",children:e.jsx(oe,{size:16})}),e.jsxs("div",{children:[e.jsx("span",{children:w==="memwal/recall"?"Walrus Memory recall":"ContextMeM memory"}),e.jsx("p",{children:w==="memwal/recall"?"Searching previous namespace memory...":"Querying remembered context..."})]})]}):null]})}),e.jsxs("form",{className:"memoryChatComposer",onSubmit:P=>{P.preventDefault(),m("query")}
392,children:[e.jsx("textarea",{value:l,onChange:P=>c(P.target.value),placeholder:"Ask Walrus Memory what changed, what matters, or what the next agent should remember..."}),e.jsxs("div",{className:"memoryComposerActions",children:[e.jsxs("button",{type:"button",onClick:()=>{m("recall")},disabled:!s||w!==null||!l.trim(),children:[e.jsx(pe,{size:15}),w==="memwal/recall"?"Recalling":"Recall"]}),e.jsxs("button",{type:"submit",className:"primary",disabled:!s||w!==null||!l.trim(),children:[e.jsx(Ee,{size:15}),w==="memwal/query"?"Querying":"Send"]})]})]}),S?e.jsx("div",{className:"error memoryChatError",children:S}):null]}),e.jsxs("aside",{className:"memoryContextRail",children:[e.jsxs("section",{children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Local Diff"}),e.jsx("span",{children:j?.compareRunId??"no previous run"})]}),j?e.jsx(yd,{diff:j}):e.jsx("div",{className:"subEmpty",children:"No comparable run found."})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Previous Runs"}),e.jsxs("span",{children:[z.length," matches"]})]}),e.jsxs("div",{className:"previousRuns",children:[z.map(P=>e.jsxs("button",{onClick:()=>M(P.runId),children:[e.jsx("strong",{children:P.runId}),e.jsxs("span",{children:[Ts(P.updatedAt)," · ",P.pages,"p/",P.resources,"r"]})]},P.runId)),z.length?null:e.jsx("p",{children:"No prior local snapshot for this namespace."})]})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Visual Diff"}),e.jsxs("span",{children:[b?.pages.length??0," pages"]})]}),b&&s?e.jsx(bd,{diff:b,run:s,authToken:i}):e.jsx("div",{className:"subEmpty",children:"No visual diff generated yet."})]}),e.jsxs("section",{children:[e.jsx("div",{className:"sectionHead",children:e.jsx("h2",{children:"Last Recall"})}),e.jsx(vn,{data:u,empty:"No recall run yet."})]}),e.jsxs("section",{children:[e.jsx("div",{className:"sectionHead",children:e.jsx("h2",{children:"Last Query"})}),e.jsx(vn,{data:p,empty:"No memory query run yet."})]})]})]})}function vn({data:t,empty:s}){return t?e.jsxs("details",{className:"memoryRawResult",children:[e.jsx("summary",{children:"View raw response"}),e.jsx(gt,{data:t})]}):e.jsx("div",{className:"memoryEmptyResult",children:s})}function ns(t){return`${t}-${Date.now()}-${Math.random().toString(36).slice(2)}`}function wn(t,s){const n=s?.manifest.namespace??"not synced";return{id:`system-${s?.manifest.runId??"empty"}`,role:"assistant",content:`Active package loaded for ${ye(n)}. Ask what changed, what should be remembered, or query existing Walrus Memory context for this namespace.`,mode:"query"}}function us(t,s){if(typeof t=="string")return t;if(!t||typeof t!="object")return s==="recall"?"Recall completed.":"Memory query completed.";const n=t;for(const i of["answer","response","message","summary","text","content"]){const o=n[i];if(typeof o=="string"&&o.trim())return o}if(Array.isArray(n.content)){const i=n.content.map(o=>o&&typeof o=="object"&&typeof o.text=="string"?o.text:"").filter(
392Boolean).join(` 393`);if(i.trim())return i}if(n.result&&n.result!==t){const i=us(n.result,s);if(i.trim())return i}if(n.data&&typeof n.data=="object"&&n.data!==t){const i=us(n.data,s);if(i.trim())return i}for(const i of["results","matches","memories"]){const o=n[i];if(Array.isArray(o)){const r=o.map(d=>d&&typeof d=="object"&&typeof d.text=="string"?d.text:"").filter(Boolean);if(r.length)return r.map((d,l)=>`${l+1}. ${d}`).join(` 394 395`)}}if(Array.isArray(n.matches)&&n.matches.length)return`Found ${n.matches.length} matching memory item${n.matches.length===1?"":"s"}. Open Raw response for details.`;if(Array.isArray(n.memories)&&n.memories.length)return`Found ${n.memories.length} remembered item${n.memories.length===1?"":"s"} for this namespace.`;if(Array.isArray(n.results)&&n.results.length)return`Found ${n.results.length} result${n.results.length===1?"":"s"} from Walrus Memory.`;if(["results","matches","memories"].some(i=>Array.isArray(n[i])))return s==="recall"?"No memories matched this query.":"No results.";const a=JSON.stringify(t,null,2);return a.length>1200?`${a.slice(0,1200)} 396...`:a}function jd(t,s){return/unable to connect|failed to fetch|network|ECONNREFUSED|ENOTFOUND/i.test(t)?s==="recall"?"Walrus Memory could not be reached from the ContextMeM server. The active package is still available here; remember this run once the Walrus Memory service is reachable, then retry recall.":"Walrus Memory could not answer right now. The active package is loaded locally, but the server-side Walrus Memory connection failed. Try Remember run first, then send the question again.":t}function kn({files:t}){return e.jsx("div",{className:"fileChecklist",children:t.map(s=>e.jsxs("div",{className:s.exists?"ok":"missing",children:[e.jsx("span",{children:s.exists?"ok":"missing"}),e.jsx("code",{children:s.path}),typeof s.size=="number"?e.jsx("small",{children:ve(s.size)}):null]},s.path))})}function yd({diff:t}){return e.jsx("div",{className:"diffSummary",children:Object.entries(t.summary).map(([s,n])=>e.jsxs("article",{children:[e.jsx("strong",{children:s}),e.jsxs("span",{children:["+",n.added]}),e.jsxs("span",{children:["-",n.removed]}),e.jsxs("span",{children:["~",n.changed]}),e.jsxs("span",{children:[n.unchanged," same"]})]},s))})}function bd({diff:t,run:s,authToken:n}){const[a,i]=x.useState(!1),o=t.pages.filter(l=>l.status!=="unchanged"),r=a?o:o.slice(0,6);if(!o.length)return e.jsx("div",{className:"memoryEmptyResult",children:"No changed page screenshots."});const d=o.reduce((l,c)=>(l[c.status]=(l[c.status]??0)+1,l),{added:0,removed:0,changed:0,unchanged:0});return e.jsxs("div",{className:"visualDiffList",children:[e.jsxs("header",{className:"visualDiffSummary",children:[e.jsxs("span",{className:"visualBadge added",children:["+",d.added," new"]}),e.jsxs("span",{className:"visualBadge removed",children:["-",d.removed," removed"]}),e.jsxs("span",{className:"visualBadge changed",children:["~",d.changed," changed"]}),e.jsxs("small",{children:["Generated ",new Date(t.generatedAt).toLocaleString()]})]}),r.map(l=>e.jsxs("article",{className:`visualDiffCard ${l.status}`,children:[e.jsxs("div",{className:"visualDiffHead",children:[e.jsx("strong",{children:l.routePath}),e.jsx("span",{className:`visualBadge ${l.status}`,children:l.status==="added"?"new page":l.status})]}),e.jsxs("div",{className:"visualPair",children:[e.jsxs("figure",{children:[e.jsx("figcaption",{children:"before"}),l.beforeScreenshot?e.jsx("img",{src:we(t.compareRunId,l.beforeScreenshot,n),alt:`${l.routePath} before`}):e.jsx("div",{className:"visualPlaceholder",children:"This page did n
396ot exist in the prior run."})]}),e.jsxs("figure",{className:"visualAfter",children:[e.jsx("figcaption",{children:"after"}),l.afterScreenshot?e.jsxs("div",{className:"visualAfterCanvas",children:[e.jsx("img",{src:we(s.manifest.runId,l.afterScreenshot,n),alt:`${l.routePath} after`}),l.boxes?.length?(()=>{const c=Math.max(...l.boxes.map(h=>h.x+h.width),1),u=Math.max(...l.boxes.map(h=>h.y+h.height),1);return e.jsx("svg",{className:"visualBoxes",viewBox:`0 0 ${c} ${u}`,preserveAspectRatio:"none","aria-hidden":"true",children:l.boxes.map((h,p)=>e.jsx("rect",{x:h.x,y:h.y,width:h.width,height:h.height,className:`visualBox ${h.tone}`,vectorEffect:"non-scaling-stroke"},`${h.label}-${p}`))})})():null]}):e.jsx("div",{className:"visualPlaceholder",children:"This page was removed in the latest run."})]})]}),l.markdownDiff&&(l.markdownDiff.added.length||l.markdownDiff.removed.length)?e.jsxs("div",{className:"markdownMiniDiff",children:[l.markdownDiff.added.slice(0,8).map((c,u)=>e.jsxs("p",{children:["+ ",c]},`add-${u}`)),l.markdownDiff.removed.slice(0,8).map((c,u)=>e.jsxs("p",{className:"removed",children:["- ",c]},`remove-${u}`)),l.markdownDiff.added.length+l.markdownDiff.removed.length>16?e.jsxs("small",{children:["⦠",l.markdownDiff.added.length-8+(l.markdownDiff.removed.length-8)," more lines"]}):null]}):null]},l.routePath)),o.length>6?e.jsx("button",{type:"button",className:"visualDiffMore",onClick:()=>i(l=>!l),children:a?"Show fewer pages":`Show ${o.length-6} more page${o.length-6===1?"":"s"}`}):null]})}function vd({data:t,fallback:s,run:n,authToken:a}){if(!t)return e.jsx(wd,{data:s});const i=t.tokens.colors.reduce((l,c)=>(l[c.role]=[...l[c.role]??[],c],l),{}),o=[["Figma Tokens",t.exports.figmaTokens,Ad(t)],["Style Dictionary",t.exports.styleDictionary,Id(t)],["Tailwind Theme",t.exports.tailwindTheme,Dd(t)],["Tokens CSS",t.exports.tokensCss,Ld(t)],["Web Brand Kit",t.exports.webBrandKit,$d(t)],["Video Brand Kit",t.exports.videoBrandKit,zd(t)],["Raw JSON",t.exports.rawJson,t]],r=t.tokens.colors.length+t.tokens.spacing.length+t.tokens.radii.length+t.tokens.shadows.length,d=t.identity.confidence>=.66?"high":t.identity.confidence>=.33?"partial":"framework-only";return e.jsxs("div",{className:"panel designPanel",children:[e.jsxs("section",{className:"designHero",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Design System"}),e.jsx("h2",{children:t.identity.name??t.identity.domain??"Extracted identity"}),t.identity.description?e.jsx("p",{children:t.identity.description}):null,t.framework?e.jsxs("small",{className:"frameworkBadge",title:`${t.framework.defaultsSubtracted} framework defaults filtered out`,children:["Built on ",t.framework.name," â ",t.framework.defaultsSubtracted," defaults filtered"]}):null]}),e.jsxs("div",{className:"designScore",children:[e.jsxs("strong",{children:[Math.round(t.identity.confidence*100),"%"]}),e.jsx("span",{children:d})]})]}),r===0?e.jsxs("div",{className:"tabEmptyState",children:[e.jsx("strong",{children:"No brand-distinct tokens detected"}),e.jsxs("p",{children:[t.framework?`This site uses ${t.framework.name}; its default tokens were filtered out and nothing brand-distinct remained.`:"Inline CSS contained only framework or system defaults."," Try a fresh Build, or render-then-sample is required to surface real brand tokens (Tier 2 â not shipped yet)."]})]}):null,e.jsxs("section",{className:"designStats designStatsAuto",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Tokens"}),e.jsx("strong",{children:r})]}),t.assets.length>0?e.jsxs("div",{children:[e.jsx("span",{children:"Assets"}),e.jsx("strong",{children:t.assets.length})]}):null,t.components.length>0?e.jsxs("div",{children:[e.jsx("span",{children:"Components"}),e.jsx("strong",{children:t.components.length})]}):null,t.motion.length>0?e.jsxs("div",{children:[e.jsx("span",{children:"Motion"}),e.jsx("strong",{children:t.motion.length})]}):null]}),e.jsxs("section",{className:"designSection",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Semantic Color Tokens"}),e.jsxs("span",{children:[t.tokens.rawPalette.length," raw colors"]})]}),e.jsx("div",{className:"colorRoles",children:Object.entries(i).map(([l,c])=>e.jsxs("article",{className:"roleGroup",children:[e.jsx("h3",{children:l}),e.jsx("div",{className:"swatches compact",children:c.slice(0,12).map(u=>e.jsx("span",{style:{background:u.value},title:u.name,children:u.value},`${u.name}-${u.value}`))})]},l))})]}),e.jsxs("section",{className:"designSection split designSplitType",children:[e.jsxs("article",{className:"designTypography",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Typography"}),e.jsxs("span",{children:[t.tokens.typography.scale.length," styles"]})]}),e.jsx("div",{className:"fontList fontSpecimens",children:t.tokens.typography.fontFamilies.slice(0,6).map(l=>e.jsxs("span",{style:{fontFamily:l},children:[e.jsx("strong",{children:"Ag"}),l]},l))}),e.jsx("div",{className:"tokenRows typeScaleRows",children:[t.tokens.typography.body,...t.tokens.typography.headings].filter(
396Boolean).map(l=>e.jsxs("div",{children:[e.jsx("strong",{children:l.name}),e.jsx("code",{children:[l.fontSize,l.fontWeight,l.lineHeight].filter(Boolean).join(" / ")||l.fontFamily})]},l.name))})]}),e.jsxs("article",{children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Layout Primitives"}),e.jsx("span",{children:"raw values observed"})]}),e.jsx(as,{label:"Spacing (raw)",values:t.tokens.spacing}),e.jsx(as,{label:"Radii (raw)",values:t.tokens.radii}),e.jsx(as,{label:"Shadows (raw)",values:t.tokens.shadows})]})]}),e.jsxs("section",{className:"designSection",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Components"}),e.jsxs("span",{children:[t.components.length," detected"]})]}),e.jsx("div",{className:"componentGrid",children:t.components.map(l=>e.jsxs("article",{className:"componentCard",children:[l.previews?.find(c=>c.path&&c.status==="captured")?e.jsx("img",{className:"componentPreview",src:we(n?.manifest.runId,l.previews.find(c=>c.path&&c.status==="captured").path,a),alt:`${l.name} preview`}):null,e.jsxs("div",{children:[e.jsx("strong",{children:l.name}),e.jsx("span",{children:l.selectors.slice(0,3).join(", ")||l.type})]}),e.jsx("dl",{children:l.tokens.slice(0,6).map(c=>e.jsxs(An.Fragment,{children:[e.jsx("dt",{children:c.property}),e.jsx("dd",{children:c.value})]},`${l.type}-${c.property}-${c.value}`))}),l.states.length?e.jsx("code",{children:l.states.map(c=>c.name).join(" · ")}):null]},l.type))})]}),e.jsxs("section",{className:"designSection split",children:[e.jsxs("article",{children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Assets"}),e.jsxs("span",{children:[t.assets.length," files"]})]}),e.jsx("div",{className:"assetList",children:t.assets.slice(0,18).map((l,c)=>e.jsxs("div",{children:[e.jsx("strong",{children:l.kind}),e.jsx("code",{children:l.url??l.resourcePath??l.label})]},`${l.kind}-${l.url??l.resourcePath}-${c}`))})]}),e.jsxs("article",{children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Motion"}),e.jsxs("span",{children:[t.motion.length," tokens"]})]}),e.jsx("div",{className:"tokenRows",children:t.motion.slice(0,12).map(l=>e.jsxs("div",{children:[e.jsx("strong",{children:l.property}),e.jsx("code",{children:l.value})]},`${l.name}-${l.value}`))})]})]}),e.jsxs("section",{className:"designSection",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Exports"}),e.jsx("span",{children:"Figma, web, video, agent JSON"})]}),e.jsx("div",{className:"exportGrid",children:o.map(([l,c,u])=>e.jsxs("article",{className:"exportCard",children:[e.jsxs("div",{children:[e.jsx("strong",{children:l}),e.jsx("code",{children:c})]}),e.jsxs("div",{className:"exportActions",children:[e.jsx("button",{onClick:()=>Od(u),children:"Copy"}),e.jsx("button",{onClick:()=>Fd(l,u,c.endsWith(".css")?"text/css":"application/json"),children:"Download"})]})]},c))})]})]})}function wd({data:t}){return t?e.jsxs("div",{className:"panel",children:[e.jsx("div",{className:"swatches",children:t.colors.palette.slice(0,24).map(s=>e.jsx("span",{style:{background:s},children:s},s))}),e.jsx(gt,{data:t})]}):e.jsx("div",{className:"panel",children:e.jsxs("div",{className:"tabEmptyState",children:[e.jsx("strong",{children:"Design system tokens not in this run"}),e.jsxs("p",{children:["Re-run the Build to extract a token snapshot â palette, font scale, spacing, radii, shadows â from the home page's inline CSS, saved as ",e.jsx("code",{children:"/context/design-system.json"}),"."]})]})})}function as({label:t,values:s}){return s.length?e.jsxs("div",{className:"tokenChipGroup",children:[e.jsx("span",{children:t}),e.jsx("div",{children:s.slice(0,16).map(n=>e.jsx("code",{children:n},`${t}-${n}`))})]}):null}const kd={value_prop:"Value props",capability:"Capabilities",differentiator:"Differentiators",limitation:"Limitations",guarantee:"Guarantees",positioning:"Positioning",fact:"Facts"},Nd=["value_prop","differentiator","capability","guarantee","positioning","fact","limitation"];function Nn(t,s){const n=new Map;for(const a of t){const i=s(a),o=n.get(i);o?o.push(a):n.set(i,[a])}return n}function is({sources:t,label:s="why"}){const n=t.filter(a=>a.quote);return n.length?e.jsxs("details",{className:"factsWhy",children:[e.jsx("summary",{children:s}),e.jsx("div",{className:"factsWhyBody",children:n.map((a,i)=>e.jsxs("article",{className:"factsSource",children:[e.jsx("code",{children:a.routePath??a.resourcePath??a.url??"s
396ource"}),e.jsxs("p",{children:["â",a.quote,"â"]})]},`${a.chunkId??a.routePath??a.url}-${i}`))})]}):null}function Sd({topics:t,colorForEntity:s}){const n=t.slice().sort((i,o)=>o.weight-i.weight),a=n.reduce((i,o)=>i+(o.weight||0),0)||1;return e.jsxs("section",{className:"factsSection",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Topics"}),e.jsxs("span",{children:[t.length," cluster",t.length===1?"":"s"]})]}),e.jsx("div",{className:"factsTopicBand",children:n.map(i=>{const o=Math.round(i.weight/a*100);return e.jsxs("div",{className:"factsTopicTile",style:{flexGrow:Math.max(.5,i.weight*10),borderTopColor:s(i.entityIds?.[0])},title:`${o}% of content`,children:[e.jsxs("div",{className:"factsTopicTop",children:[e.jsx("strong",{children:i.label}),e.jsxs("span",{className:"factsTopicPct",children:[o,"%"]})]}),i.keywords?.length?e.jsx("div",{className:"factsTopicKeywords",children:i.keywords.slice(0,4).map(r=>e.jsx("span",{children:r},r))}):null,i.routePaths?.length?e.jsxs("small",{children:[i.routePaths.length," page",i.routePaths.length===1?"":"s"]}):null]},i.id)})})]})}function _s({facts:t}){const[s,n]=x.useState(null);x.useEffect(()=>{n(null)},[t]);const a=x.useMemo(()=>Yl((t?.entities??[]).filter(y=>(y.sources?.length??0)>0),t?.relationships??[],t?.identity?.primaryEntityId),[t]),i=x.useMemo(()=>Jl((t?.entities??[]).filter(y=>(y.sources?.length??0)>0),t?.claims??[],t?.stats??[],t?.topics??[]),[t]);if(!t)return e.jsx("div",{className:"panel factsPanel",children:e.jsxs("div",{className:"tabEmptyState",children:[e.jsx("strong",{children:"No grounded facts in this run"}),e.jsxs("p",{children:["Re-run the Build to extract a grounded ",e.jsx("code",{children:"SiteFacts"})," layer â identity, entities, claims, stats, topics, and an auto-generated FAQ â saved as ",e.jsx("code",{children:"/context/facts.json"}),". Every fact carries a verbatim source quote, so nothing is hallucinated."]})]})});const o=t.identity??{name:"",oneLiner:"",category:"",audience:[]},r=t.stats??[],d=(t.entities??[]).filter(y=>(y.sources?.length??0)>0),l=t.claims??[],c=(t.questions??[]).slice().sort((y,w)=>w.importance-y.importance),u=t.topics??[],h=new Map(d.map(y=>[y.id,y.type])),p=y=>cs[(y?h.get(y):void 0)??"concept"],g=Nn(d,y=>y.type),j=Il.filter(y=>g.has(y)),f=Nn(l.filter(y=>y.text),y=>y.kind),b=Nd.filter(y=>f.has(y));return e.jsxs("div",{className:"panel factsPanel",children:[e.jsxs("section",{className:"factsHero",children:[e.jsxs("div",{className:"factsHeroMain",children:[e.jsx("span",{className:"factsKicker",children:"What this site is"}),e.jsx("h2",{children:o.name||Cd(t.target)}),o.oneLiner?e.jsx("p",{className:"factsOneLiner",children:o.oneLiner}):null,e.jsxs("div",{className:"factsChips",children:[o.category?e.jsx("span",{className:"factsChip factsChipAccent",children:o.category}):null,(o.audience??[]).map(y=>e.jsx("span",{className:"factsChip",children:y},y))]})]}),e.jsxs("div",{className:"factsHeroMeta",children:[e.jsxs("div",{className:"factsMetric",children:[e.jsxs("strong",{children:[Math.round((t.confidence??0)*100),"%"]}),e.jsx("span",{children:"confidence"})]}),e.jsxs("div",{className:"factsMetric",children:[e.jsx("strong",{children:t.usedProvider==="heuristic"?"heuristic":"model"}),e.jsx("span",{children:"source"})]}),t.coverage?e.jsxs("div",{className:"factsMetric",children:[e.jsxs("strong",{children:[t.coverage.pagesAnalyzed,"/",t.coverage.chunksAnalyzed]}),e.jsx("span",{children:"pages / chunks"})]}):null]})]}),d.length?e.jsxs("section",{className:"factsSection factsGraphSection",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Knowledge graph"}),e.jsxs("span",{children:[d.length," entit",d.length===1?"y":"ies"," · ",t.relationships?.length??0," relationship",t.relationships?.length===1?"":"s"]})]}),e.jsx("div",{className:"nmc-host",children:e.jsx(Vl,{graph:a,entityDetail:i})})]}):null,r.length?e.jsxs("section",{className:"factsSection",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Facts at a glance"}),e.jsxs("span",{children:[r.length," stat",r.length===1?"":"s"]})]}),e.jsx("div",{className:"factsStatGrid",children:r.map(y=>{const w=y.sources.find(v=>v.quote);return e.jsxs("article",{className:"factsStatCard",title:w?.routePath??w?.url??void 0,children:[e.jsx("strong",{children:y.valueRaw}),e.jsx("span",{children:y.label}),y.sources.length?e.jsx(is,{sources:y.sources,label:"source"}):null]},y.id)})})]}):null,u.length?e.jsx(Sd,{topics:u,colorForEntity:p}):null,j.length?e.jsxs("section",{className:"factsSection",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Entities & relationships"}),e.jsxs("span",{children:[d.length," entit",d.length===1?"y":"ies"," · ",t.relationships?.length??0," edge",t.relationships?.length===1?"":"s"]})]}),e.jsx("div",{className:"factsEntityGroups",children:j.map(y=>{const w=(g.get(y)??[]).slice().sort((v,S)=>S.salience-v.salience);return e.jsxs("div",{className:"factsEntityGroup",children:[e.jsxs("h3",{children:[e.jsx("span",{className:`factsTypeDot factsType-${y}`,"aria-hidden":"true"}),ha[y],e.jsx("small",{children:w.length})]}),e.jsx("ul",{className:"factsEntityList",children:w.map(v=>e.jsxs("li",{className:`factsEntityRow${s===v.id?" isActive":""}`,onClick:()=>n(s===v.id?null:v.id),children:[e.jsxs("div",{className:"factsEntityHead",children:[e.jsx("strong",{children:v.url?e.jsx("a",{href:v.url,target:"_blank",rel:"noreferrer noopener",children:v.name}):v.name}),e.jsxs("span",{className:"factsEntityMentions",children:[v.mentions," mention",v.mentions===1?"":"s"]}),e.jsx(is,{sources:v.sources})]}),v.description?e.jsx("p",{className:"factsEntityDesc",children:v.description}):null,e.jsx("div",{className:"factsSalienceTrack","aria-hidden":"true",children:e.jsx("span",{className:`factsSalienceFill factsType-${y}`,style:{width:`${Math.max(6,Math.round(v.salience*100))}%`}})})]},v.id))})]},y)})})]}):null,b.length?e.jsxs("section",{className:"factsSection",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Claims"}),e.jsxs("span",{children:[l.length," extracted"]})]}),e.jsx("div",{className:"factsClaimGroups",children:b.map(y=>e.jsxs("div",{className:"factsClaimGroup",children:[e.jsx("h3",{children:kd[y]}),e.jsx("ul",{className:"factsClaimList",children:(f.get(y)??[]).map(w=>e.jsxs("li",{className:`factsClaimRow${w.isMarketing?" factsClaimMarketing":""}`,children:[e.jsx("p",{children:w.text}),e.jsxs("div",{className:"factsClaimMeta",children:[w.isMarketing?e.jsx("span",{className:"factsTag factsTagMarketing",children:"marketing"}):null,e.jsxs("span",{className:"factsTag",children:[Math.round(w.confidence*100),"%"]}),e.jsx(is,{sources:w.sources})]})]},w.id))})]},y))})]}):null,c.length?e.jsxs("section",{className:"factsSection",children:[e.jsxs("div",{className:"sectionHead",children:[e.jsx("h2",{children:"Context questions"}),e.jsxs("span",{children:[c.length," answered & gaps"]})]}),e.jsx("div",{className:"factsFaq",children:c.map(y=>e.jsxs("details",{className:`factsFaqItem${y.unanswerable?" factsFaqGap":""}`,children:[e.jsxs("summary",{children:[e.jsx("span",{className:"factsFaqQ",children:y.question}),e.jsx("span",{className:"factsFaqCat",children:Na[y.category]??y.category})]}),e.jsxs("div",{className:"factsFaqBody",children:[y.unanswerable?e.jsx("p",{className:"factsGapNote",children:"Gap: not covered on this site."}):e.jsx("p",{className:"factsFaqAnswer",children:y.answer||"No answer extracted."}),y.sources.some(w=>w.quote)?e.jsx("div",{className:"factsFaqChips",children:y.sources.filter(w=>w.quote).map((w,v)=>
396e.jsx("span",{className:"factsSourceChip",title:w.quote,children:w.routePath??w.resourcePath??w.url??"source"},`${w.chunkId??w.routePath??w.url}-${v}`))}):null]})]},y.id))})]}):null,t.coverage&&t.coverage.ungroundedDropped>0?e.jsxs("p",{className:"factsCoverageNote",children:[t.coverage.ungroundedDropped," ungrounded fact",t.coverage.ungroundedDropped===1?"":"s"," dropped (quote not found in cited source)."]}):null]})}function Cd(t){try{return new URL(t).hostname.replace(/^www\./,"")}catch{return t||"This site"}}function Ea({data:t}){return t?e.jsxs("div",{className:"panel brandPanel",children:[e.jsxs("div",{className:"brandSummary",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Name"}),e.jsx("strong",{children:t.name??"Unknown"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Domain"}),e.jsx("strong",{children:t.domain??"Unknown"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Confidence"}),e.jsxs("strong",{children:[Math.round(t.confidence*100),"%"]})]})]}),t.description?e.jsx("p",{className:"brandDescription",children:t.description}):null,t.colors.length?e.jsxs("div",{className:"brandSection",children:[e.jsx("h2",{children:"Colors"}),e.jsx("div",{className:"swatches",children:t.colors.slice(0,24).map(s=>e.jsx("span",{style:{background:s},children:s},s))})]}):null,t.fonts.length?e.jsxs("div",{className:"brandSection",children:[e.jsx("h2",{children:"Fonts"}),e.jsx("div",{className:"fontList",children:t.fonts.slice(0,12).map(s=>e.jsx("span",{children:s},s))})]}):null,t.logos.length?e.jsxs("div",{className:"brandSection",children:[e.jsx("h2",{children:"Logo Assets"}),e.jsx("div",{className:"brandAssets",children:t.logos.map((s,n)=>e.jsxs("article",{className:"brandAsset",children:[e.jsx("strong",{children:s.role??s.type??"logo-candidate"}),s.alt?e.jsx("span",{children:s.alt}):null,e.jsx("code",{children:s.absoluteUrl??s.src})]},`${s.absoluteUrl??s.src}-${n}`))})]}):null]}):e.jsx("div",{className:"panel brandPanel",children:e.jsxs("div",{className:"tabEmptyState",children:[e.jsx("strong",{children:"Brand profile not in this run"}),e.jsxs("p",{children:["Re-run the Build to extract a brand profile â favicon, OG image, palette from inline CSS, font families, and social links â saved as ",e.jsx("code",{children:"/context/brand.json"}),"."]})]})})}function Ra({data:t}){if(!t)return e.jsx(gt,{data:{status:"No Walrus resource artifact"}});const s=t.resources.filter(a=>a.verified).length,n=t.resources.filter(a=>a.error).length;return e.jsxs("div",{className:"panel walrusPanel",children:[e.jsxs("div",{className:"walrusSummary",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Network"}),e.jsx("strong",{children:t.site.network})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Object"}),e.jsx("strong",{children:t.site.siteObjectId})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Resources"}),e.jsx("strong",{children:t.resources.length})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Verified"}),e.jsx("strong",{children:s})]}),n?e.jsxs("div",{children:[e.jsx("span",{children:"Fetch errors"}),e.jsx("strong",{children:n})]}):null]}),e.jsx("div",{className:"resourceGrid",children:t.resources.map(a=>{const i=a.error?"error":a.verified?"verified":"unverified";return e.jsxs("article",{className:`resourceCard ${i}`,children:[e.jsxs("div",{className:"resourceTop",children:[e.jsx("strong",{children:a.path}),e.jsx("span",{children:i})]}),e.jsx("code",{children:a.contentType??"application/octet-stream"}),e.jsxs("dl",{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"blob"}),e.jsx("dd",{children:a.blobId})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"hash"}),e.jsx("dd",{children:a.blobHash})]}),a.quiltPatchId?e.jsxs("div",{children:[e.jsx("dt",{children:"patch"}),e.jsx("dd",{children:a.quiltPatchId})]}):null,typeof a.byteLength=="number"?e.jsxs("div",{children:[e.jsx("dt",{children:"bytes"}),e.jsx("dd",{children:ve(a.byteLength)})]}):null]}),a.error?e.jsx("p",{children:a.error}):null]},`${a.path}-${a.blobId}-${a.quiltPatchId??""}`)})})]})}function Pd({run:t,walrus:s,authToken:n}
396){const[a,i]=x.useState(null),[o,r]=x.useState(!1),[d,l]=x.useState(null);x.useEffect(()=>{!t||!s||c()},[n,t?.manifest.runId,!!s]);async function c(){if(t){r(!0),l(null);try{const u=await fetch(`${D}/api/runs/${t.manifest.runId}/walrus/history?limit=40&maxTransactions=800`,{headers:G(n)});if(!u.ok)throw new Error(await Q(u));i(await u.json())}catch(u){l(u instanceof Error?u.message:String(u))}finally{r(!1)}}}return s?e.jsxs("div",{className:"panel historyTimelinePanel",children:[e.jsxs("section",{className:"historyOverview",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Site object"}),e.jsx("strong",{children:s.site.siteObjectId})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Owner"}),e.jsx("strong",{children:a?.owner??"loading"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Current version"}),e.jsx("strong",{children:a?.currentVersion??"loading"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Scanned"}),e.jsxs("strong",{children:[a?.scannedTransactions??0," tx"]})]}),e.jsxs("button",{onClick:c,disabled:o,children:[e.jsx(nt,{size:15}),o?"Loading":"Refresh history"]})]}),d?e.jsx("div",{className:"error",children:d}):null,a?.warnings.length?e.jsx("div",{className:"warningList",children:a.warnings.map(u=>e.jsx("div",{children:u},u))}):null,e.jsxs("section",{className:"timeline",children:[a?.entries.map(u=>e.jsxs("article",{className:u.action,children:[e.jsx("div",{className:"timelineDot"}),e.jsxs("div",{className:"timelineBody",children:[e.jsxs("div",{className:"timelineHead",children:[e.jsxs("div",{children:[e.jsx("strong",{children:u.action}),e.jsxs("span",{children:[u.timestampIso?Ts(u.timestampIso):"unknown time"," · ",u.status??"unknown"]})]}),e.jsx("code",{children:u.digest})]}),e.jsxs("dl",{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"version"}),e.jsxs("dd",{children:[u.previousVersion??"new"," â ",u.siteVersion??"unknown"]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"sender"}),e.jsx("dd",{children:u.sender??"unknown"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"functions"}),e.jsx("dd",{children:u.functions.join(", ")||"unknown"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"paths"}),e.jsx("dd",{children:u.resourcePaths.join(", ")||`${u.resourceChanges.length} resource object changes`})]})]})]})]},u.digest)),a&&!a.entries.length?e.jsx("div",{className:"subEmpty",children:"No site update transactions found in the scanned owner history."}):null,!a&&!d?e.jsx("div",{className:"subEmpty",children:"Loading onchain Walrus update history..."}):null]})]}):e.jsx(gt,{data:{status:"No Walrus site selected"}})}function gt({data:t}){return e.jsx("div",{className:"panel",children:e.jsx("pre",{children:JSON.stringify(t,null,2)})})}function ve(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Md(t){const s=Math.max(0,Math.floor(t/1e3));return s<60?`${s}s`:`${Math.floor(s/60)}m ${String(s%60).padStart(2,"0")}s`}function _d(t){switch(t){case"queued":return"The API accepted the build and is preparing the first phase.";case"resolving":return"Resolving the target to a website or Walrus Site object.";case"listing_resources":return"Reading Walrus resource metadata from Sui before downloading blobs.";case"downloading_resources":return"Fetching verified resources with bounded parallel downloads and cache reuse.";case"crawling_pages":return"Collecting pages once so downstream context steps can reuse the same crawl.";case"extracting_pages":return"Converting materialized pages into markdown and structured context.";case"extracting_metadata":return"Building brand, styleguide, and design metadata from the cached page set.";case"capturing_screenshots":return"Running the slower visual pass for screenshots and component previews.";case"building_artifacts":return"Writing the agent-readable package files.";default:return"Resolving target, fetching resources, and preparing the agent-readable artifacts."}}function rs(t){return new Promise(s=>window.setTimeout(s,t))}async function Td(t,s,n){const a=await fetch(`${D}/api/runs/${t}/events`,{headers:G(s)});if(!a.ok||!a.body)throw new Error(a.ok?"Run event stream unavailable.":await Q(a));const i=a.body.getReader(),o=new TextDecoder;let r="",d="message",l="";for(;;){const{value:c,done:u}=await i.read();c&&(r+=o.decode(c,{stream:!u}));let h=r.indexOf(` 397 398`);for(;h>=0;){const p=r.slice(0,h);r=r.slice(h+2),d="message",l="";for(const g of p.split(/\n/))g.startsWith("event:")&&(d=g.slice(6).trim()),g.startsWith("data:")&&(l+=g.slice(5).trim());if(l){const g=JSON.parse(l);if(d==="progress"&&n(g),d==="done")return g}h=r.indexOf(` 399 400`)}if(u)break}throw new Error("Run event stream closed before completion.")}function lt(t){return t.flatMap(s=>[s,...lt(s.children??[])])}function Aa(t){if(t){if(t.kind==="page"){const s=lt(t.children??[]),n=s.find(i=>i.artifactPath&&i.kind==="markdown"&&/extracted/i.test(i.label));if(n)return n;const a=s.find(i=>i.artifactPath&&i.kind==="markdown");
400if(a)return a}return t.artifactPath?t:lt(t.children??[]).find(s=>s.artifactPath&&(Ia(s)||hs(s)))??lt(t.children??[]).find(s=>s.artifactPath)}}function hs(t){return/^image\//i.test(t.contentType??"")||/\.(?:svg|png|jpe?g|webp|gif|ico)$/i.test(t.artifactPath??t.path??"")}function Ia(t){return/(?:json|markdown|html|text|css|javascript|xml)/i.test(t.contentType??"")||/\.(?:json|md|html?|txt|css|js|xml)$/i.test(t.artifactPath??t.path??"")}function ye(t){return t.length>18?`${t.slice(0,8)}...${t.slice(-6)}`:t}function je(t){try{return new URL(t).hostname.replace(/^www\./,"")}catch{return t.length>34?`${t.slice(0,18)}...${t.slice(-10)}`:t}}function Ts(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function os(t){try{return new URL(t).hostname.replace(/^www\./,"")}catch{return t.slice(0,80)}}function we(t,s,n=""){if(!t)return"";const a=new URLSearchParams({path:s});return n&&a.set("accessToken",n),`${D}/api/runs/${t}/artifact-file?${a.toString()}`}function G(t,s={}){const n={...s,...le(D)?{}:ut()};return t?{...n,authorization:`Bearer ${t}`}:n}function Sn(t){return(t??"").normalize("NFKC").replace(/[â-ââ  ]/g,"").replace(/\s+/g,"").replace(/^bearer/i,"").trim()}function le(t){try{const s=new URL(t);return s.hostname==="localhost"||s.hostname==="127.0.0.1"||s.hostname==="::1"}catch{return!1}}function Da(){if(typeof window>"u")return null;try{const t=pa("contextmem.hostedDelegate");if(!t)return null;const s=JSON.parse(t),n=typeof s.memwalAccountId=="string"?s.memwalAccountId:"",a=typeof s.delegateKey=="string"?s.delegateKey:"";return!n||a.length<12?null:{memwalAccountId:n,delegateKey:a}}catch{return null}}function Cn(t){const s=new Date().toISOString();return{authenticated:!0,account:{id:`hosted:${t.memwalAccountId.toLowerCase().replace(/[^a-z0-9:._-]+/g,"-").slice(0,180)}`,ownerAddress:t.memwalAccountId,provider:"unknown",memwalAccountId:t.memwalAccountId,hasDelegateKey:!0,createdAt:s,updatedAt:s},quota:{limit:0,used:0,remaining:0,unlimited:!0},access:{canPreview:!0,canRun:!0,reason:"Hosted Walrus Memory delegate is available for this browser session."}}}function ut(){const t=Da();return t?{"x-memwal-authorization":t.delegateKey.startsWith("Bearer ")?t.delegateKey:`Bearer ${t.delegateKey}`,"x-memwal-account-id":t.memwalAccountId}:{}}function Ed(t){return/unable to connect|fetch failed|network|ECONNREFUSED|ECONNRESET|ENOTFOUND|ETIMEDOUT|terminated|MCP HTTP (502|503|504)/i.test(t)}async function Q(t){const s=await t.text();if(!s)return t.statusText;try{const n=JSON.parse(s);if(typeof n.error=="object"&&n.error&&n.error.message){const a=n.error.code?`[${n.error.code}] `:"",i=n.error.hint?` â ${n.error.hint}`:"";return`${a}${n.error.message}${i}`}return typeof n.error=="string"?n.error:n.message??s}catch{return s}}function Rd(t){if(!t)return null;const s=t.toLowerCase();return s.includes("[demo_limit_exceeded]")||s.includes("demo limit reached")?{code:"DEMO_LIMIT_EXCEEDED",hint:"Open /app/settings, generate an account secret and import Walrus Memory credentials to unlock unlimited extractions."}:s.includes("walrus")&&(s.includes("aggregator")||s.includes("timeout")||s.includes("unreachable"))?{code:"WALRUS_UNREACHABLE",hint:"Walrus aggregator is unreachable. Try again in a minute or set WALRUS_AGGREGATOR_URL to an alternate mirror."}:s.includes("memwal")&&(s.includes("401")||s.includes("unauthorized")||s.includes("delegate"))?{code:"MEMWAL_AUTH",hint:"Walrus Memory rejected the delegate key. Re-import SDK credentials in /app/settings or rotate the key in the Walrus Memory dashboard."}:s.includes("openai")&&(s.includes("rate")||s.includes("429"))?{code:"OPENAI_RATE_LIMIT",hint:"OpenAI rate-limited the request. Wait ~30 seconds, then retry â or set a higher-tier OPENAI_API_KEY."}:s.includes("openai")&&s.includes("api key")?{code:"OPENAI_MISSING",hint:"OPENAI_API_KEY is not configured. AI Query is disabled until it's set in the API worker env."}:s.includes("namespace")&&s.includes("not found")?{code:"NAMESPACE_MISSING",hint:"The hosted namespace doesn't exist or was deleted. Re-publish from /app/publish or check the URL."}:s.includes("read token")||s.includes("namespace")&&s.includes("token")?{code:"NAMESPACE_TOKEN",hint:"The hosted namespace requires a read token. Generate one in /app/namespaces and pass it as `Authorization: Bearer <token>`."}:null}function Lt({message:t}
400){if(!t)return null;const s=Rd(t);return s?e.jsxs("div",{className:"failurePanel",role:"note",children:[e.jsx("strong",{children:"Why did this fail?"}),e.jsx("span",{children:s.hint}),s.code?e.jsx("code",{className:"failureCode",children:s.code}):null]}):null}function La(t,s){const n=t.previewUrl??t.absoluteUrl;if(!(!n||n.startsWith("inline-svg:")))return za(n,s)}function $a(t,s){return t.absoluteUrl.startsWith("inline-svg:")?t.absoluteUrl:za(t.absoluteUrl,s)}function za(t,s){if(!s.walrus?.site.portalUrl)return t;try{const n=new URL(t);if(n.hostname==="localhost"||n.hostname==="127.0.0.1")return new URL(`${n.pathname}${n.search}`,s.walrus.site.portalUrl).toString()}catch{return t}return t}function Ad(t){const s={};for(const n of t.tokens.colors)Ce(s,n.name,{value:n.value,type:"color"});for(const[n,a]of t.tokens.typography.fontFamilies.entries())Ce(s,`fontFamilies.${n===0?"body":Es(a)}`,{value:a,type:"fontFamilies"});for(const[n,a]of t.tokens.spacing.entries())Ce(s,`spacing.${n+1}`,{value:a,type:"spacing"});for(const[n,a]of t.tokens.radii.entries())Ce(s,`radii.${n+1}`,{value:a,type:"borderRadius"});for(const[n,a]of t.tokens.shadows.entries())Ce(s,`shadows.${n+1}`,{value:a,type:"boxShadow"});return{$metadata:{tokenSetOrder:["global"]},global:s}}function Id(t){const s={};for(const n of t.tokens.colors)Ce(s,n.name,{value:n.value,type:"color"});for(const[n,a]of t.tokens.spacing.entries())Ce(s,`size.spacing.${n+1}`,{value:a,type:"dimension"});for(const[n,a]of t.tokens.radii.entries())Ce(s,`size.radius.${n+1}`,{value:a,type:"dimension"});for(const[n,a]of t.tokens.shadows.entries())Ce(s,`shadow.${n+1}`,{value:a,type:"shadow"});return s}function Dd(t){return{theme:{extend:{colors:Object.fromEntries(t.tokens.colors.map(s=>[Es(s.name.replace(/^color\./,"")),s.value])),fontFamily:{sans:t.tokens.typography.fontFamilies[0]?.split(",").map(s=>s.trim())??["ui-sans-serif","system-ui"],mono:t.tokens.typography.fontFamilies.find(s=>/mono|code/i.test(s))?.split(",").map(s=>s.trim())??["ui-monospace","monospace"]},spacing:Object.fromEntries(t.tokens.spacing.map((s,n)=>[String(n+1),s])),borderRadius:Object.fromEntries(t.tokens.radii.map((s,n)=>[String(n+1),s])),boxShadow:Object.fromEntries(t.tokens.shadows.map((s,n)=>[String(n+1),s]))}}}}function Ld(t){const s=[":root {"];for(const n of t.tokens.colors)s.push(` --cm-${Es(n.name)}: ${n.value};`);for(const[n,a]of t.tokens.spacing.entries())s.push(` --cm-spacing-${n+1}: ${a};`);for(const[n,a]of t.tokens.radii.entries())s.push(` --cm-radius-${n+1}: ${a};`);for(const[n,a]of t.tokens.shadows.entries())s.push(` --cm-shadow-${n+1}: ${a};`);return s.push("}"),`${s.join(` 401`)} 402`}function $d(t){return{identity:t.identity,tokens:t.tokens,components:t.components,exports:{css:t.exports.tokensCss,tailwind:t.exports.tailwindTheme,styleDictionary:t.exports.styleDictionary}}}function zd(t){const s=t.tokens.colors.find(i=>i.role==="brand")??t.tokens.colors[0],n=t.tokens.colors.find(i=>i.role==="text"),a=t.tokens.colors.find(i=>i.role==="background"||i.role==="surface");return{identity:t.identity,titleCard:{background:a?.value??"#ffffff",foreground:n?.value??"#111827",accent:s?.value??"#2563eb",fontFamily:t.tokens.typography.fontFamilies[0]??"Inter, system-ui, sans-serif"},lowerThird:{background:s?.value??"#2563eb",foreground:n?.value??"#ffffff",radius:t.tokens.radii[0]??"8px",shadow:t.tokens.shadows[0]??"none"},motion:{defaultDuration:t.motion.find(i=>i.property==="duration")?.value??"180ms",easing:t.motion.find(i=>i.property==="easing")?.value??"ease"}}}function Ce(t,s,n){const a=s.split(".").filter(Boolean);let i=t;for(const r of a.slice(0,-1)){const d=i[r];(!d||typeof d!="object"||Array.isArray(d))&&(i[r]={}),i=i[r]}const o=a.at(-1);o&&(i[o]=n)}function Es(t){return t.replaceAll(".","-").replaceAll(/[^a-z0-9-_]+/gi,"-").replaceAll(/^-|-$/g,"").toLowerCase()}async function Od(t){const s=typeof t=="string"?t:JSON.stringify(t,null,2);await navigator.clipboard.writeText(s)}function Fd(t,s,n){const a=typeof s=="string"?s:JSON.stringify(s,null,2),i=new Blob([a],{type:n}),o=URL.createObjectURL(i),r=document.createElement("a");r.href=o,r.download=`${t.toLowerCase().replaceAll(/[^a-z0-9]+/g,"-").replaceAll(/^-|-$/g,"")}.${n==="text/css"?"css":"json"}`,r.click(),URL.revokeObjectURL(o)}function Bd(){if(typeof window>"u")return{target:"",mode:"auto",autorun:!1};const t=new URLSearchParams(window.location.search),s=t.get("mode");return{target:t.get("target")??"",mode:s==="web"||s==="walrus"||s==="auto"?s:"auto",autorun:t.get("autorun")==="1"||t.get("autorun")==="true"}}const ms=document.getElementById("root");ms.__contextMemRoot??=Fi.createRoot(ms);ms.__contextMemRoot.render(e.jsx(fa,{children:e.jsx(oc,{})}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.