graview 0.1.40 → 0.1.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/preview/{chunk.6PSWHBL2.js → chunk.2GQPLTV3.js} +1 -1
  2. package/dist/preview/{chunk.R5WY567U.js → chunk.2NB7U4EW.js} +1 -1
  3. package/dist/preview/{chunk.CNFL5IN5.js → chunk.33KXSD6F.js} +1 -1
  4. package/dist/preview/{chunk.H6XKMLDQ.js → chunk.3ZILIZZ6.js} +1 -1
  5. package/dist/preview/{chunk.QCWZSSNC.js → chunk.4EEWBCT2.js} +1 -1
  6. package/dist/preview/{chunk.DPZTW24D.js → chunk.4Q7XJJZY.js} +1 -1
  7. package/dist/preview/{chunk.VZYCILPJ.js → chunk.53CDFJNM.js} +1 -1
  8. package/dist/preview/{chunk.XQHDP5C3.js → chunk.57R2GXXN.js} +1 -1
  9. package/dist/preview/{chunk.ETOGQE2V.js → chunk.5P556A7W.js} +1 -1
  10. package/dist/preview/{chunk.G6VZNRQ5.js → chunk.5QXWMC6C.js} +1 -1
  11. package/dist/preview/{chunk.TD2LNFUB.js → chunk.6RID3OWK.js} +1 -1
  12. package/dist/preview/{chunk.LPBM5AES.js → chunk.6YPLZNVT.js} +1 -1
  13. package/dist/preview/{chunk.JQEYZB5I.js → chunk.7YIFF6BF.js} +1 -1
  14. package/dist/preview/chunk.A4UIM35E.js +1 -0
  15. package/dist/preview/{chunk.ZJMDLRC5.js → chunk.AIZQBPGU.js} +1 -1
  16. package/dist/preview/{chunk.ZK3X23EU.js → chunk.B5724ULM.js} +1 -1
  17. package/dist/preview/{chunk.YYIKSH2F.js → chunk.BELCPW66.js} +1 -1
  18. package/dist/preview/{chunk.STI447YW.js → chunk.BK6RWVRE.js} +1 -1
  19. package/dist/preview/{chunk.47KHZCNG.js → chunk.BQRAIU5R.js} +1 -1
  20. package/dist/preview/{chunk.LPE4FLC6.js → chunk.C4TSM4W5.js} +1 -1
  21. package/dist/preview/{chunk.6JEU3ZNE.js → chunk.C7JKMOFC.js} +1 -1
  22. package/dist/preview/{chunk.ZGCRMNER.js → chunk.DGCMEDQA.js} +1 -1
  23. package/dist/preview/{chunk.XRYTJNA7.js → chunk.DMF35E7D.js} +1 -1
  24. package/dist/preview/{chunk.UOPKRN55.js → chunk.EAH47SCN.js} +1 -1
  25. package/dist/preview/{chunk.6J37UQKG.js → chunk.EQ4UAWRB.js} +1 -1
  26. package/dist/preview/{chunk.T3TYD7QI.js → chunk.F2MQJH6Y.js} +1 -1
  27. package/dist/preview/{chunk.IDUPJMJO.js → chunk.HEVC6HHP.js} +1 -1
  28. package/dist/preview/{chunk.GTV2VZAS.js → chunk.HI7X6PLZ.js} +1 -1
  29. package/dist/preview/{chunk.GY6RYJHM.js → chunk.HKCK3JI4.js} +1 -1
  30. package/dist/preview/{chunk.GZIVMOY4.js → chunk.HPUN5DKZ.js} +3 -3
  31. package/dist/preview/{chunk.IFTWVUJO.js → chunk.I4JBWTZM.js} +1 -1
  32. package/dist/preview/{chunk.LLEFYJPJ.js → chunk.JHEVGLKB.js} +13 -12
  33. package/dist/preview/{chunk.74NOI7QN.js → chunk.JLBGJSCZ.js} +1 -1
  34. package/dist/preview/{chunk.CN5WAKHJ.js → chunk.JYJ4LZJJ.js} +2 -2
  35. package/dist/preview/{chunk.AWX7GP72.js → chunk.L4STJLUV.js} +1 -1
  36. package/dist/preview/{chunk.ACBUAIDF.js → chunk.LOCSF3BR.js} +1 -1
  37. package/dist/preview/{chunk.FDE3TSTK.js → chunk.LOSMUESM.js} +1 -1
  38. package/dist/preview/{chunk.MIM2QLF5.js → chunk.LPNIEPYI.js} +2 -2
  39. package/dist/preview/{chunk.CL2ZS5EQ.js → chunk.LPYVOBWB.js} +1 -1
  40. package/dist/preview/{chunk.7WPCP2LZ.js → chunk.M4T377LG.js} +1 -1
  41. package/dist/preview/{chunk.AVKDWISO.js → chunk.MSP73H5Z.js} +1 -1
  42. package/dist/preview/{chunk.35PHXNOC.js → chunk.MUKDKVVC.js} +1 -1
  43. package/dist/preview/{chunk.W7R2GFBW.js → chunk.MUPO5S2A.js} +1 -1
  44. package/dist/preview/{chunk.ESSSNLEO.js → chunk.O75JKQPF.js} +1 -1
  45. package/dist/preview/{chunk.KSXB4LDF.js → chunk.OF34OZ4V.js} +1 -1
  46. package/dist/preview/{chunk.2OSNYF5C.js → chunk.OVTCW3AI.js} +1 -1
  47. package/dist/preview/{chunk.VF7P3ZVZ.js → chunk.PMDNFN7Z.js} +1 -1
  48. package/dist/preview/{chunk.P5ODICND.js → chunk.PMGXASFI.js} +1 -1
  49. package/dist/preview/{chunk.O5JKDFDH.js → chunk.QHYXXZRD.js} +1 -1
  50. package/dist/preview/{chunk.4VG2KN7G.js → chunk.RQGTHRRJ.js} +1 -1
  51. package/dist/preview/{chunk.JLDBFX6O.js → chunk.SADG5RMV.js} +1 -1
  52. package/dist/preview/{chunk.WBLHCH5M.js → chunk.SCYQSXW4.js} +1 -1
  53. package/dist/preview/{chunk.2CF2XKOS.js → chunk.T3BWINOF.js} +1 -1
  54. package/dist/preview/{chunk.BSAXZQSY.js → chunk.TN5PYGU7.js} +1 -1
  55. package/dist/preview/{chunk.6AVZWLRF.js → chunk.UEXIKCLF.js} +1 -1
  56. package/dist/preview/{chunk.PYNYHNDS.js → chunk.USZPOOLZ.js} +1 -1
  57. package/dist/preview/{chunk.2NXH7VAI.js → chunk.UTWPZULC.js} +1 -1
  58. package/dist/preview/{chunk.2GDXNTY5.js → chunk.V3V47QRE.js} +1 -1
  59. package/dist/preview/{chunk.T73RB7LC.js → chunk.V4KLBSC4.js} +1 -1
  60. package/dist/preview/{chunk.2JB4Y2ET.js → chunk.VCX3HEIE.js} +1 -1
  61. package/dist/preview/{chunk.PPG2SEIY.js → chunk.W3FTEJH5.js} +1 -1
  62. package/dist/preview/{chunk.2WACBAUN.js → chunk.WUKHYLQT.js} +2 -2
  63. package/dist/preview/{chunk.S356ACK2.js → chunk.XOYJ26YB.js} +1 -1
  64. package/dist/preview/{chunk.YO24NALN.js → chunk.Z7BCIYDW.js} +1 -1
  65. package/dist/preview/{chunk.UTCB3CE7.js → chunk.ZRYSVOLA.js} +1 -1
  66. package/dist/preview/{chunk.AUBGUDO5.js → chunk.ZTMEESII.js} +1 -1
  67. package/dist/preview/index.html +21 -21
  68. package/dist/preview/page.js +2 -2
  69. package/package.json +6 -6
  70. package/dist/preview/chunk.BNVMMOOY.js +0 -1
@@ -1 +1 @@
1
- import"./chunk.5A4AOFOA.js";import"./chunk.KSXB4LDF.js";import"./chunk.SIGC3G7S.js";import{a as L,b as R,c as E}from"./chunk.GY6RYJHM.js";import{b as T}from"./chunk.P5ODICND.js";import"./chunk.LPE4FLC6.js";import"./chunk.XEKLEHC3.js";import"./chunk.JACGQ2PR.js";import"./chunk.VZYCILPJ.js";import"./chunk.4QPVS2ZM.js";import"./chunk.RCM7NOPF.js";import"./chunk.Z7LDT55A.js";import"./chunk.HJCQ6I3S.js";import"./chunk.VNUHESMZ.js";import"./chunk.N2K25KH3.js";import"./chunk.C2PECN4C.js";import"./chunk.XFZKP4IF.js";import"./chunk.AKQXF7GW.js";import"./chunk.6JEU3ZNE.js";import"./chunk.BFNVG5JE.js";import"./chunk.ZJMDLRC5.js";import"./chunk.2GDXNTY5.js";import"./chunk.ETOGQE2V.js";import"./chunk.O5JKDFDH.js";import"./chunk.YYIKSH2F.js";import"./chunk.LPBM5AES.js";import"./chunk.5RABSIF7.js";import"./chunk.NGDXH66B.js";import"./chunk.67WWRC6Y.js";import"./chunk.VJXXCUKS.js";import"./chunk.Z5AB2DBF.js";import"./chunk.QIV65FWE.js";import"./chunk.UT6642FC.js";import"./chunk.HPAGOEZG.js";import"./chunk.ISXFH3CK.js";import"./chunk.TI4OSTQV.js";import"./chunk.BXT6FDT4.js";import"./chunk.WVUJXDXZ.js";import"./chunk.N6MVK3KD.js";import"./chunk.I7XSDXQ3.js";import"./chunk.UHI3D7JC.js";import"./chunk.WVDKYUF3.js";import"./chunk.ZHLQWMV5.js";import"./chunk.TNESS3LQ.js";import"./chunk.GZHZLJBF.js";import{r as A}from"./chunk.42XSBKPO.js";import"./chunk.OJGHDWI6.js";import"./chunk.6FNMDAX5.js";import"./chunk.2FLPDPEL.js";import"./chunk.UUBYFBPN.js";import"./chunk.2RVUDRRY.js";import"./chunk.LLEFYJPJ.js";import{G as S,I as $,R as p,_ as x,aa as C}from"./chunk.FOQZADMA.js";import"./chunk.SDO3U72B.js";import{aa as h,uc as k}from"./chunk.V5MYKNL7.js";import{b as i}from"./chunk.AJZBJBMO.js";var r=i(S(),1);var l=i(S(),1);var g=i(p(),1);var m={font:"inherit",fontSize:"0.875rem",minHeight:24,padding:0,border:0,borderRadius:2,background:"transparent",boxShadow:"none",color:"var(--graview-accent)",textDecoration:"underline",textUnderlineOffset:3,textAlign:"start",cursor:"pointer"};var e=i(p(),1);function Y({page:n=!1,go:D,onPick:y,onDiscard:M}){let{store:d,seatTalk:c}=x(),u=$(c),N=E(),b=D??N,{keep:P}=L(b),[H,f]=(0,r.useState)(!1);C();let t=u.draft;(0,r.useEffect)(()=>f(!1),[t]),(0,r.useEffect)(()=>{n||R(!1)},[n]);let v=(0,r.useRef)(null),w=t!==null&&!n;if((0,r.useLayoutEffect)(()=>{let s=v.current;if(!w||!s?.parentElement)return;let o=[];for(let a=s.previousElementSibling;a;a=a.previousElementSibling)a instanceof HTMLElement&&!a.inert&&a.tagName!=="STYLE"&&(a.inert=!0,o.push(a));return()=>{for(let a of o)a.inert=!1}},[w]),!t)return null;let G=T(t.drawn),F=d.schema.tryDefinition(t.kind),q=d.graph.nodesOfKind(t.kind).filter(s=>h(F,s)),z=()=>{c.setDraft(null),M?.()};return(0,e.jsxs)("section",{ref:v,"data-testid":"draft-frame","data-graview-draft-frame":n?"page":"scene","aria-label":`Draft: ${t.title}`,style:n?{display:"grid",gap:12,minWidth:0}:{position:"absolute",inset:12,zIndex:k("rail"),display:"grid",gridTemplateRows:"auto auto minmax(0, 1fr)",background:"var(--graview-panel)",border:"1px solid var(--graview-edge)",borderRadius:12,boxShadow:"var(--graview-lift-high)",overflow:"hidden",minHeight:0},children:[(0,e.jsxs)("p",{"data-testid":"draft-line",style:{...K,...n?{}:{padding:"10px 16px"}},children:[n?(0,e.jsx)("span",{children:"Draft"}):(0,e.jsxs)("span",{children:["Draft \u2014 ",(0,e.jsx)("span",{"data-testid":"draft-title",style:{color:"var(--graview-ink)",fontWeight:600},children:t.title})]}),(0,e.jsx)("span",{"aria-hidden":"true",children:"\xB7"}),(0,e.jsx)("button",{type:"button","data-testid":"draft-keep",disabled:H,title:`Keep \u201C${t.title}\u201D as a lens: a place of its own`,onClick:()=>{f(!0),P(t).finally(()=>f(!1))},style:m,children:"Keep as a lens"}),(0,e.jsx)("span",{"aria-hidden":"true",children:"\xB7"}),(0,e.jsx)("button",{type:"button","data-testid":"draft-discard",onClick:z,style:m,children:"Discard"})]}),u.draftNote?(0,e.jsx)("p",{"data-testid":"draft-note",role:"status",style:{margin:0,padding:n?0:"0 16px 8px",fontSize:"0.8125rem",color:"var(--graview-warn)"},children:u.draftNote}):(0,e.jsx)("span",{}),(0,e.jsx)("div",{"data-testid":"draft-lens","data-graview-draft":t.lens.name,style:n?{height:"min(72vh, 760px)",display:"grid",gridTemplateRows:"minmax(0, 1fr)",overflow:"auto",scrollbarGutter:"stable",border:"1px solid var(--graview-edge)",borderRadius:12,background:"var(--graview-panel)"}:{minHeight:0,overflow:"auto",scrollbarGutter:"stable",display:"grid",gridTemplateRows:"minmax(0, 1fr)"},onClick:s=>{let o=s.target?.closest("[data-graview-pick]")?.getAttribute("data-graview-pick");if(!o||!d.graph.getNode(o))return;s.preventDefault();let a=d.graph.getNode(o);y?(c.setDraft(null),y(o)):b({to:"record",id:o,kind:a.kind,label:o,address:"",said:""})},children:(0,e.jsx)(A,{kind:t.kind,view:t.title,children:(0,e.jsx)(G,{nodes:q,label:t.title,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1})})})]})}var K={margin:0,display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"4px 8px",fontSize:"0.875rem",color:"var(--graview-ink-muted)",borderBottom:"1px solid var(--graview-edge)",paddingBottom:8};export{Y as DraftFrame};
1
+ import"./chunk.5A4AOFOA.js";import"./chunk.OF34OZ4V.js";import"./chunk.SIGC3G7S.js";import{a as L,b as R,c as E}from"./chunk.HKCK3JI4.js";import{b as T}from"./chunk.PMGXASFI.js";import"./chunk.C4TSM4W5.js";import"./chunk.XEKLEHC3.js";import"./chunk.JACGQ2PR.js";import"./chunk.53CDFJNM.js";import"./chunk.4QPVS2ZM.js";import"./chunk.RCM7NOPF.js";import"./chunk.Z7LDT55A.js";import"./chunk.HJCQ6I3S.js";import"./chunk.VNUHESMZ.js";import"./chunk.N2K25KH3.js";import"./chunk.C2PECN4C.js";import"./chunk.XFZKP4IF.js";import"./chunk.AKQXF7GW.js";import"./chunk.C7JKMOFC.js";import"./chunk.BFNVG5JE.js";import"./chunk.AIZQBPGU.js";import"./chunk.V3V47QRE.js";import"./chunk.5P556A7W.js";import"./chunk.QHYXXZRD.js";import"./chunk.BELCPW66.js";import"./chunk.6YPLZNVT.js";import"./chunk.5RABSIF7.js";import"./chunk.NGDXH66B.js";import"./chunk.67WWRC6Y.js";import"./chunk.VJXXCUKS.js";import"./chunk.Z5AB2DBF.js";import"./chunk.QIV65FWE.js";import"./chunk.UT6642FC.js";import"./chunk.HPAGOEZG.js";import"./chunk.ISXFH3CK.js";import"./chunk.TI4OSTQV.js";import"./chunk.BXT6FDT4.js";import"./chunk.WVUJXDXZ.js";import"./chunk.N6MVK3KD.js";import"./chunk.I7XSDXQ3.js";import"./chunk.UHI3D7JC.js";import"./chunk.WVDKYUF3.js";import"./chunk.ZHLQWMV5.js";import"./chunk.TNESS3LQ.js";import"./chunk.GZHZLJBF.js";import{r as A}from"./chunk.42XSBKPO.js";import"./chunk.OJGHDWI6.js";import"./chunk.6FNMDAX5.js";import"./chunk.2FLPDPEL.js";import"./chunk.UUBYFBPN.js";import"./chunk.2RVUDRRY.js";import"./chunk.JHEVGLKB.js";import{G as S,I as $,R as p,_ as x,aa as C}from"./chunk.FOQZADMA.js";import"./chunk.SDO3U72B.js";import{aa as h,uc as k}from"./chunk.V5MYKNL7.js";import{b as i}from"./chunk.AJZBJBMO.js";var r=i(S(),1);var l=i(S(),1);var g=i(p(),1);var m={font:"inherit",fontSize:"0.875rem",minHeight:24,padding:0,border:0,borderRadius:2,background:"transparent",boxShadow:"none",color:"var(--graview-accent)",textDecoration:"underline",textUnderlineOffset:3,textAlign:"start",cursor:"pointer"};var e=i(p(),1);function Y({page:n=!1,go:D,onPick:y,onDiscard:M}){let{store:d,seatTalk:c}=x(),u=$(c),N=E(),b=D??N,{keep:P}=L(b),[H,f]=(0,r.useState)(!1);C();let t=u.draft;(0,r.useEffect)(()=>f(!1),[t]),(0,r.useEffect)(()=>{n||R(!1)},[n]);let v=(0,r.useRef)(null),w=t!==null&&!n;if((0,r.useLayoutEffect)(()=>{let s=v.current;if(!w||!s?.parentElement)return;let o=[];for(let a=s.previousElementSibling;a;a=a.previousElementSibling)a instanceof HTMLElement&&!a.inert&&a.tagName!=="STYLE"&&(a.inert=!0,o.push(a));return()=>{for(let a of o)a.inert=!1}},[w]),!t)return null;let G=T(t.drawn),F=d.schema.tryDefinition(t.kind),q=d.graph.nodesOfKind(t.kind).filter(s=>h(F,s)),z=()=>{c.setDraft(null),M?.()};return(0,e.jsxs)("section",{ref:v,"data-testid":"draft-frame","data-graview-draft-frame":n?"page":"scene","aria-label":`Draft: ${t.title}`,style:n?{display:"grid",gap:12,minWidth:0}:{position:"absolute",inset:12,zIndex:k("rail"),display:"grid",gridTemplateRows:"auto auto minmax(0, 1fr)",background:"var(--graview-panel)",border:"1px solid var(--graview-edge)",borderRadius:12,boxShadow:"var(--graview-lift-high)",overflow:"hidden",minHeight:0},children:[(0,e.jsxs)("p",{"data-testid":"draft-line",style:{...K,...n?{}:{padding:"10px 16px"}},children:[n?(0,e.jsx)("span",{children:"Draft"}):(0,e.jsxs)("span",{children:["Draft \u2014 ",(0,e.jsx)("span",{"data-testid":"draft-title",style:{color:"var(--graview-ink)",fontWeight:600},children:t.title})]}),(0,e.jsx)("span",{"aria-hidden":"true",children:"\xB7"}),(0,e.jsx)("button",{type:"button","data-testid":"draft-keep",disabled:H,title:`Keep \u201C${t.title}\u201D as a lens: a place of its own`,onClick:()=>{f(!0),P(t).finally(()=>f(!1))},style:m,children:"Keep as a lens"}),(0,e.jsx)("span",{"aria-hidden":"true",children:"\xB7"}),(0,e.jsx)("button",{type:"button","data-testid":"draft-discard",onClick:z,style:m,children:"Discard"})]}),u.draftNote?(0,e.jsx)("p",{"data-testid":"draft-note",role:"status",style:{margin:0,padding:n?0:"0 16px 8px",fontSize:"0.8125rem",color:"var(--graview-warn)"},children:u.draftNote}):(0,e.jsx)("span",{}),(0,e.jsx)("div",{"data-testid":"draft-lens","data-graview-draft":t.lens.name,style:n?{height:"min(72vh, 760px)",display:"grid",gridTemplateRows:"minmax(0, 1fr)",overflow:"auto",scrollbarGutter:"stable",border:"1px solid var(--graview-edge)",borderRadius:12,background:"var(--graview-panel)"}:{minHeight:0,overflow:"auto",scrollbarGutter:"stable",display:"grid",gridTemplateRows:"minmax(0, 1fr)"},onClick:s=>{let o=s.target?.closest("[data-graview-pick]")?.getAttribute("data-graview-pick");if(!o||!d.graph.getNode(o))return;s.preventDefault();let a=d.graph.getNode(o);y?(c.setDraft(null),y(o)):b({to:"record",id:o,kind:a.kind,label:o,address:"",said:""})},children:(0,e.jsx)(A,{kind:t.kind,view:t.title,children:(0,e.jsx)(G,{nodes:q,label:t.title,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1})})})]})}var K={margin:0,display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"4px 8px",fontSize:"0.875rem",color:"var(--graview-ink-muted)",borderBottom:"1px solid var(--graview-edge)",paddingBottom:8};export{Y as DraftFrame};
@@ -1 +1 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{$ as S,F as g,G as T,R as v,ua as C}from"./chunk.FOQZADMA.js";import{a as m}from"./chunk.SDO3U72B.js";import"./chunk.V5MYKNL7.js";import{b as c}from"./chunk.AJZBJBMO.js";var n=c(T(),1),r=c(v(),1),s=null,u=null,f=new Set,a=()=>{for(let e of f)e()},y=e=>(f.add(e),()=>void f.delete(e)),E=300,d=()=>{u!==null&&clearTimeout(u),u=null};function q(e,t){d(),x.prefetch(),!(s?.element===t&&s.target.on===e.on)&&(s={target:e,element:t},a())}function M(e=!1){if(d(),s!==null){if(e){s=null,a();return}u=setTimeout(()=>{u=null,s=null,a()},E)}}var R=()=>d(),P=()=>s,b="graview:hover-chips",h;function A(e){if(h!==void 0)return h;try{return(e??localStorage).getItem(b)!=="off"}catch{return!0}}function I(e,t){h=e;try{(t??localStorage).setItem(b,e?"on":"off")}catch{}e||(s=null),a()}function w(){let e=S(),t=g(e?.ai),o=e?.memory,l=(0,n.useSyncExternalStore)(y,()=>A(o),()=>!1),i=(0,n.useCallback)(H=>I(H,o),[o]);return{offered:t,on:t&&l,set:i}}function z({legend:e,style:t,choice:o}){let l=w();return l.offered?(0,r.jsxs)("fieldset",{"data-testid":"setting-hover-chips",style:{border:0,margin:0,padding:0,display:"grid",gap:5,...t},children:[(0,r.jsx)("legend",{style:{...e,padding:0},children:"AI suggestions on hover"}),(0,r.jsx)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:"A quiet suggestion beside a record the pointer rests on, when the AI is sure of one."}),(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[!0,!1].map(i=>(0,r.jsx)("button",{type:"button","aria-pressed":l.on===i,"data-testid":`setting-hover-chips-${i?"on":"off"}`,onClick:()=>l.set(i),style:o(l.on===i),children:i?"On":"Off"},String(i)))})]}):null}var x=C(m(()=>(__graviewPreload(import.meta.url,["./chunk.UTCB3CE7.js","./chunk.QIV65FWE.js","./chunk.UT6642FC.js","./chunk.HPAGOEZG.js","./chunk.ISXFH3CK.js","./chunk.H5ADMSE7.js","./chunk.TI4OSTQV.js","./chunk.I7XSDXQ3.js","./chunk.2FLPDPEL.js","./chunk.UUBYFBPN.js","./chunk.2RVUDRRY.js","./chunk.LLEFYJPJ.js","./chunk.FOQZADMA.js","./chunk.SDO3U72B.js","./chunk.V5MYKNL7.js","./chunk.AJZBJBMO.js"]),import("./chunk.6PSWHBL2.js")))),k=x.part((e,t)=>{let o=e.HoverChip;return(0,r.jsx)(o,{...t})},{quiet:!0}),p=null,O=()=>p;function L(){let{on:e}=w(),t=(0,n.useSyncExternalStore)(y,P,()=>null),[o]=(0,n.useState)(()=>Symbol("hover-chip")),l=(0,n.useSyncExternalStore)(y,O,()=>null);return(0,n.useEffect)(()=>{if(e)return p===null&&(p=o,a()),()=>{p===o&&(p=null,s=null,d(),a())}},[e,o,l]),!e||t===null||l!==o||!t.element.isConnected?null:(0,r.jsx)(n.Suspense,{fallback:null,children:(0,r.jsx)(k,{rest:t,hold:R,leave:M})})}export{L as HoverChipDoor,z as HoverChipsSwitch,R as holdRest,A as hoverChipsWanted,M as leaveRest,q as restOn,I as setHoverChipsWanted,w as useHoverChipsSetting};
1
+ var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{$ as S,F as g,G as T,R as v,ua as C}from"./chunk.FOQZADMA.js";import{a as m}from"./chunk.SDO3U72B.js";import"./chunk.V5MYKNL7.js";import{b as c}from"./chunk.AJZBJBMO.js";var n=c(T(),1),r=c(v(),1),s=null,u=null,f=new Set,a=()=>{for(let e of f)e()},y=e=>(f.add(e),()=>void f.delete(e)),E=300,d=()=>{u!==null&&clearTimeout(u),u=null};function q(e,t){d(),x.prefetch(),!(s?.element===t&&s.target.on===e.on)&&(s={target:e,element:t},a())}function M(e=!1){if(d(),s!==null){if(e){s=null,a();return}u=setTimeout(()=>{u=null,s=null,a()},E)}}var R=()=>d(),P=()=>s,b="graview:hover-chips",h;function A(e){if(h!==void 0)return h;try{return(e??localStorage).getItem(b)!=="off"}catch{return!0}}function I(e,t){h=e;try{(t??localStorage).setItem(b,e?"on":"off")}catch{}e||(s=null),a()}function w(){let e=S(),t=g(e?.ai),o=e?.memory,l=(0,n.useSyncExternalStore)(y,()=>A(o),()=>!1),i=(0,n.useCallback)(H=>I(H,o),[o]);return{offered:t,on:t&&l,set:i}}function z({legend:e,style:t,choice:o}){let l=w();return l.offered?(0,r.jsxs)("fieldset",{"data-testid":"setting-hover-chips",style:{border:0,margin:0,padding:0,display:"grid",gap:5,...t},children:[(0,r.jsx)("legend",{style:{...e,padding:0},children:"AI suggestions on hover"}),(0,r.jsx)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:"A quiet suggestion beside a record the pointer rests on, when the AI is sure of one."}),(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[!0,!1].map(i=>(0,r.jsx)("button",{type:"button","aria-pressed":l.on===i,"data-testid":`setting-hover-chips-${i?"on":"off"}`,onClick:()=>l.set(i),style:o(l.on===i),children:i?"On":"Off"},String(i)))})]}):null}var x=C(m(()=>(__graviewPreload(import.meta.url,["./chunk.ZRYSVOLA.js","./chunk.QIV65FWE.js","./chunk.UT6642FC.js","./chunk.HPAGOEZG.js","./chunk.ISXFH3CK.js","./chunk.H5ADMSE7.js","./chunk.TI4OSTQV.js","./chunk.I7XSDXQ3.js","./chunk.2FLPDPEL.js","./chunk.UUBYFBPN.js","./chunk.2RVUDRRY.js","./chunk.JHEVGLKB.js","./chunk.FOQZADMA.js","./chunk.SDO3U72B.js","./chunk.V5MYKNL7.js","./chunk.AJZBJBMO.js"]),import("./chunk.2GQPLTV3.js")))),k=x.part((e,t)=>{let o=e.HoverChip;return(0,r.jsx)(o,{...t})},{quiet:!0}),p=null,O=()=>p;function L(){let{on:e}=w(),t=(0,n.useSyncExternalStore)(y,P,()=>null),[o]=(0,n.useState)(()=>Symbol("hover-chip")),l=(0,n.useSyncExternalStore)(y,O,()=>null);return(0,n.useEffect)(()=>{if(e)return p===null&&(p=o,a()),()=>{p===o&&(p=null,s=null,d(),a())}},[e,o,l]),!e||t===null||l!==o||!t.element.isConnected?null:(0,r.jsx)(n.Suspense,{fallback:null,children:(0,r.jsx)(k,{rest:t,hold:R,leave:M})})}export{L as HoverChipDoor,z as HoverChipsSwitch,R as holdRest,A as hoverChipsWanted,M as leaveRest,q as restOn,I as setHoverChipsWanted,w as useHoverChipsSetting};
@@ -15,6 +15,6 @@ Keep it, correct it, or split it into several \u2014 one proposal per distinct c
15
15
  ${o}`:"Nothing is broken.",u?`Selected right now (what "this" means): ${u}`:"Nothing is selected.",N.length>0?`Places in the app: ${N.join(", ")}.`:"",!$&&y?`Conversation so far:
16
16
  ${y}`:"",$?"":`Person: ${f}`,`To take the person somewhere, put a place's title or a thing's exact name in "go".`,`Answer ONLY JSON${$?" (your last message, after any reading)":""}: {"say": string, "proposals": [{"mutation": string, "args": object, "why": string}], "go"?: [string]}.`].filter(Boolean).join(`
17
17
 
18
- `),C=r.turn?await r.turn(Z(d,m,Y,f,a)):await r.complete(Y),v=_(C),c=Array.isArray(v)?{proposals:v}:v;if(!c||typeof c!="object"){let e=C.trim(),n=e.startsWith("{")||e.startsWith("["),h=e.length===0||n;return{say:[h?"The answer came back in a shape I could not read. Ask again in other words.":e,g?K:""].filter(Boolean).join(" "),proposals:[],...h?{unsure:!0}:{}}}let b=(c.proposals??[]).map(e=>H(t,e)),M=q(t,b,r.may),T=W(t,b,r.may),D=T.filter(e=>e.why==="unknown").map(e=>e.proposal.mutation),O=T.filter(e=>e.why==="not-allowed").map(e=>e.proposal.mutation),I=[g?K:"",D.length>0?`It also suggested ${D.map(e=>`"${e}"`).join(", ")}, which this app has no act for.`:"",O.length>0?`${O.map(e=>`"${e}"`).join(", ")} is not something this seat may run.`:"",M.length===0&&b.length>0?"Nothing it suggested can be applied here.":""].filter(Boolean).join(" "),L=typeof c.say=="string"&&c.say.length>0?c.say:"",P=[c.go,c.moves].flatMap(e=>Array.isArray(e)?e:typeof e=="string"?[e]:[]),A=P.length>0?(await (__graviewPreload(import.meta.url,["./chunk.KSXB4LDF.js","./chunk.NGDXH66B.js","./chunk.67WWRC6Y.js","./chunk.G4JJXA63.js","./chunk.VJXXCUKS.js","./chunk.Z5AB2DBF.js","./chunk.HPAGOEZG.js","./chunk.ISXFH3CK.js","./chunk.BXT6FDT4.js","./chunk.2FLPDPEL.js","./chunk.UUBYFBPN.js","./chunk.2RVUDRRY.js","./chunk.V5MYKNL7.js","./chunk.AJZBJBMO.js"]),import("./chunk.JQEYZB5I.js"))).movesFromNames(t,P,a):[],R=[L||A.map(e=>e.said).join(" "),I].filter(Boolean).join(" ");return{say:R||"\u2026",proposals:M,...A.length>0?{moves:A}:{},...!R&&b.length===0?{unsure:!0}:{}}}function Z(r,d,f,a,m){let t=B(r,{author:d,readOnly:!0,...m.app?{app:m.app}:{}}),g=t.definitions,k=0,w=new Map,l=[];for(let s of[...(m.history??[]).slice(-8),{role:"person",text:a}]){let i=s.role==="person"?"user":"assistant",p=l[l.length-1];p?.role===i?l[l.length-1]={role:i,content:`${p.content}
18
+ `),C=r.turn?await r.turn(Z(d,m,Y,f,a)):await r.complete(Y),v=_(C),c=Array.isArray(v)?{proposals:v}:v;if(!c||typeof c!="object"){let e=C.trim(),n=e.startsWith("{")||e.startsWith("["),h=e.length===0||n;return{say:[h?"The answer came back in a shape I could not read. Ask again in other words.":e,g?K:""].filter(Boolean).join(" "),proposals:[],...h?{unsure:!0}:{}}}let b=(c.proposals??[]).map(e=>H(t,e)),M=q(t,b,r.may),T=W(t,b,r.may),D=T.filter(e=>e.why==="unknown").map(e=>e.proposal.mutation),O=T.filter(e=>e.why==="not-allowed").map(e=>e.proposal.mutation),I=[g?K:"",D.length>0?`It also suggested ${D.map(e=>`"${e}"`).join(", ")}, which this app has no act for.`:"",O.length>0?`${O.map(e=>`"${e}"`).join(", ")} is not something this seat may run.`:"",M.length===0&&b.length>0?"Nothing it suggested can be applied here.":""].filter(Boolean).join(" "),L=typeof c.say=="string"&&c.say.length>0?c.say:"",P=[c.go,c.moves].flatMap(e=>Array.isArray(e)?e:typeof e=="string"?[e]:[]),A=P.length>0?(await (__graviewPreload(import.meta.url,["./chunk.OF34OZ4V.js","./chunk.NGDXH66B.js","./chunk.67WWRC6Y.js","./chunk.G4JJXA63.js","./chunk.VJXXCUKS.js","./chunk.Z5AB2DBF.js","./chunk.HPAGOEZG.js","./chunk.ISXFH3CK.js","./chunk.BXT6FDT4.js","./chunk.2FLPDPEL.js","./chunk.UUBYFBPN.js","./chunk.2RVUDRRY.js","./chunk.V5MYKNL7.js","./chunk.AJZBJBMO.js"]),import("./chunk.7YIFF6BF.js"))).movesFromNames(t,P,a):[],R=[L||A.map(e=>e.said).join(" "),I].filter(Boolean).join(" ");return{say:R||"\u2026",proposals:M,...A.length>0?{moves:A}:{},...!R&&b.length===0?{unsure:!0}:{}}}function Z(r,d,f,a,m){let t=B(r,{author:d,readOnly:!0,...m.app?{app:m.app}:{}}),g=t.definitions,k=0,w=new Map,l=[];for(let s of[...(m.history??[]).slice(-8),{role:"person",text:a}]){let i=s.role==="person"?"user":"assistant",p=l[l.length-1];p?.role===i?l[l.length-1]={role:i,content:`${p.content}
19
19
 
20
20
  ${s.text}`}:(p||i==="user")&&l.push({role:i,content:s.text})}return{system:f,messages:l,tools:g,call:async(s,i)=>{if(!g.some(o=>o.name===s))return{error:`"${s}" is not one of this turn's tools, which only read: ${g.map(o=>o.name).join(", ")}.`};let p=++k;if(p>J)return{error:`This turn has read ${J} times; answer from what you have read.`};let u=`${s}\0${E(i??{})}`,y=w.get(u);if(y!==void 0)return{already:Q(y)};w.set(u,p);try{let o=await t.call(s,i??{});return o.ok?o.data:{error:o.error}}catch(o){return{error:o instanceof Error?o.message:String(o)}}}}}export{K as READ_AS_ANY_AGENT,J as TURN_CALLS,Q as alreadyRead,se as answerWithModel};
@@ -1 +1 @@
1
- import{B as v,C,D as S,J as G,o as O}from"./chunk.LLEFYJPJ.js";import{G as I,_ as m,c as V,j as y,l as p,m as g,n as u,o as D,v as B,z as E}from"./chunk.FOQZADMA.js";import{Uc as P,Vc as k,Xc as R,Yc as T,ga as M}from"./chunk.V5MYKNL7.js";import{b as A}from"./chunk.AJZBJBMO.js";var W=A(I(),1);function j(e,t){try{t.length===0?localStorage.removeItem(v(e)):localStorage.setItem(v(e),JSON.stringify(t))}catch{}}function F(e,t){j(e,[...S(e).filter(n=>n.title!==t.title),t])}function H(e,t){j(e,S(e).filter(n=>n.title!==t))}function J(e,t){for(let n of e.places().filter(o=>o.title===t))e.forget?.(n.kind,n.as)}var U=e=>e===!0?{written:!0}:typeof e=="object"&&e!==null?{written:e.kept===!0,...e.said?{said:e.said}:{}}:{written:!1},N=e=>({title:e.title,lens:e.lens,on:e.on,...e.bindings?{bindings:e.bindings}:{},...e.options?{options:e.options}:{}});function Z(e,t){let n=o=>t.some(r=>r.title===o||r.as===P(o));if(!n(e))return e;for(let o=2;;o++)if(!n(`${e} ${o}`))return`${e} ${o}`}function ie(e){let{store:t,views:n,brand:o,seatTalk:r,onKeepLens:d}=m(),h=(0,W.useContext)(O),L=C(o,t.schema),b=async f=>{let{edit:i}=f;if(f.written&&d)try{await d({op:"remove-lens",title:i.title,on:i.on})}catch{}H(L,i.title),J(n,i.title),h?.dismiss(`kept:${i.title}`),r.setTurns(l=>[...l.map(s=>s.kept&&s.kept.edit.title===i.title&&!s.kept.taken?{...s,kept:{...s.kept,taken:!0}}:s),{role:"seat",text:`Took \u201C${i.title}\u201D back out of the places.`}]);let a=M(t.schema,i.on);e({to:"kind",kind:i.on,title:a,address:k(t.schema,i.on),said:`Went to ${a}.`})};return{keep:async f=>{let i=Z(f.edit.title,n.places()),a={...f.edit,title:i},l=!1,s;if(d)try{({written:l,said:s}=U(await d(a)))}catch{l=!1}l||F(L,N(a)),G(n,t.schema,[N(a)]);let K=n.places(),c=K.find(w=>w.title===i),x=s??(l?`Kept \u201C${i}\u201D as a lens: it is in the places now.`:d?`Kept \u201C${i}\u201D as your own lens. Ask the owner to keep it for everyone.`:`Kept \u201C${i}\u201D as your own lens.`),$={edit:a,written:l};r.setDraft(null),r.setTurns(w=>[...w,{role:"seat",text:x,kept:$}]),h?.notify({kind:"toast",id:`kept:${i}`,sentence:x,timeout:1e4,action:{label:"Take back",onSelect:()=>void b($)}}),c&&e({to:"picture",kind:c.kind,as:c.as,title:i,address:R(c.as,T(c,K)?k(t.schema,c.kind).slice(1):void 0),said:`Went to ${i}.`})},takeBack:b}}var q=A(I(),1);function _(e,t){switch(t.to){case"place":return{view:V("#")};case"picture":return{view:u(E(p(e,"filter",null),t.kind,t.as),[])};case"kind":{let n=D(g({...y(e,B(t.kind)),relation:null},!1),!0);return{view:u(p(p(n,"view",null),"filter",t.filter??null),[])}}case"record":return{view:u(y(g(p(p(e,"view",null),"filter",null),!1),t.id),[t.id])};case"problems":return{pane:"problems"}}}function z(e){let t=typeof document>"u"?null:document.querySelector('[data-testid="standing"]');t&&t.getAttribute("aria-expanded")==="true"!==e&&t.click()}function ae(){let{setView:e,seatTalk:t}=m();return(0,q.useCallback)(n=>{t.get().draft&&t.setDraft(null),z(n.to==="problems"),n.to!=="problems"&&e(o=>{let r=_(o,n);return"view"in r?r.view:o})},[e,t])}export{ie as a,z as b,ae as c};
1
+ import{B as v,C,D as S,J as G,o as O}from"./chunk.JHEVGLKB.js";import{G as I,_ as m,c as V,j as y,l as p,m as g,n as u,o as D,v as B,z as E}from"./chunk.FOQZADMA.js";import{Uc as P,Vc as k,Xc as R,Yc as T,ga as M}from"./chunk.V5MYKNL7.js";import{b as A}from"./chunk.AJZBJBMO.js";var W=A(I(),1);function j(e,t){try{t.length===0?localStorage.removeItem(v(e)):localStorage.setItem(v(e),JSON.stringify(t))}catch{}}function F(e,t){j(e,[...S(e).filter(n=>n.title!==t.title),t])}function H(e,t){j(e,S(e).filter(n=>n.title!==t))}function J(e,t){for(let n of e.places().filter(o=>o.title===t))e.forget?.(n.kind,n.as)}var U=e=>e===!0?{written:!0}:typeof e=="object"&&e!==null?{written:e.kept===!0,...e.said?{said:e.said}:{}}:{written:!1},N=e=>({title:e.title,lens:e.lens,on:e.on,...e.bindings?{bindings:e.bindings}:{},...e.options?{options:e.options}:{}});function Z(e,t){let n=o=>t.some(r=>r.title===o||r.as===P(o));if(!n(e))return e;for(let o=2;;o++)if(!n(`${e} ${o}`))return`${e} ${o}`}function ie(e){let{store:t,views:n,brand:o,seatTalk:r,onKeepLens:d}=m(),h=(0,W.useContext)(O),L=C(o,t.schema),b=async f=>{let{edit:i}=f;if(f.written&&d)try{await d({op:"remove-lens",title:i.title,on:i.on})}catch{}H(L,i.title),J(n,i.title),h?.dismiss(`kept:${i.title}`),r.setTurns(l=>[...l.map(s=>s.kept&&s.kept.edit.title===i.title&&!s.kept.taken?{...s,kept:{...s.kept,taken:!0}}:s),{role:"seat",text:`Took \u201C${i.title}\u201D back out of the places.`}]);let a=M(t.schema,i.on);e({to:"kind",kind:i.on,title:a,address:k(t.schema,i.on),said:`Went to ${a}.`})};return{keep:async f=>{let i=Z(f.edit.title,n.places()),a={...f.edit,title:i},l=!1,s;if(d)try{({written:l,said:s}=U(await d(a)))}catch{l=!1}l||F(L,N(a)),G(n,t.schema,[N(a)]);let K=n.places(),c=K.find(w=>w.title===i),x=s??(l?`Kept \u201C${i}\u201D as a lens: it is in the places now.`:d?`Kept \u201C${i}\u201D as your own lens. Ask the owner to keep it for everyone.`:`Kept \u201C${i}\u201D as your own lens.`),$={edit:a,written:l};r.setDraft(null),r.setTurns(w=>[...w,{role:"seat",text:x,kept:$}]),h?.notify({kind:"toast",id:`kept:${i}`,sentence:x,timeout:1e4,action:{label:"Take back",onSelect:()=>void b($)}}),c&&e({to:"picture",kind:c.kind,as:c.as,title:i,address:R(c.as,T(c,K)?k(t.schema,c.kind).slice(1):void 0),said:`Went to ${i}.`})},takeBack:b}}var q=A(I(),1);function _(e,t){switch(t.to){case"place":return{view:V("#")};case"picture":return{view:u(E(p(e,"filter",null),t.kind,t.as),[])};case"kind":{let n=D(g({...y(e,B(t.kind)),relation:null},!1),!0);return{view:u(p(p(n,"view",null),"filter",t.filter??null),[])}}case"record":return{view:u(y(g(p(p(e,"view",null),"filter",null),!1),t.id),[t.id])};case"problems":return{pane:"problems"}}}function z(e){let t=typeof document>"u"?null:document.querySelector('[data-testid="standing"]');t&&t.getAttribute("aria-expanded")==="true"!==e&&t.click()}function ae(){let{setView:e,seatTalk:t}=m();return(0,q.useCallback)(n=>{t.get().draft&&t.setDraft(null),z(n.to==="problems"),n.to!=="problems"&&e(o=>{let r=_(o,n);return"view"in r?r.view:o})},[e,t])}export{ie as a,z as b,ae as c};
@@ -1,4 +1,4 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{A as Vt,B as Pe,C as Nn,D as Ke,E as Ue,F as ni,G as $n,H as Le,I as ai,J as ri,K as F,L as ct,M as On,N as ii,O as Fn,P as Ut,Q as oi,R as ae,S as ie,T as In,a as Y,b as $e,c as Z,d as Qr,e as Mn,f as En,g as dt,h as J,i as ke,j as re,k as C,l as te,m as K,n as Se,o as Kt,p as xe,q as fe,r as Jr,s as ft,t as qt,u as Q,v as Ve,w as ei,x as Bt,y as Re,z as ti}from"./chunk.W7R2GFBW.js";import{b as Tn,c as Zr,d as Xr,e as Gt,g as ne}from"./chunk.CN5WAKHJ.js";import{a as zr,d as _r,e as Yr}from"./chunk.UGFDSE37.js";import{a as qr,c as Br,f as Gr,g as Vr,i as Ur,j as jr}from"./chunk.PYNYHNDS.js";import{a as Nr,b as $r,c as Or,d as Ln}from"./chunk.LPE4FLC6.js";import{b as Er}from"./chunk.XEKLEHC3.js";import{a as Fr,b as Ir,d as It,e as Wr,f as Dr,i as Wt}from"./chunk.VZYCILPJ.js";import{a as Dt,b as Ht}from"./chunk.PXQVXBNG.js";import{a as Lt,b as qa,c as Ba,d as Tt,e as Ga}from"./chunk.47KHZCNG.js";import{b as er,c as dr,e as cr,f as Pn}from"./chunk.XQHDP5C3.js";import{a as Ot,b as Ft,c as Lr,e as Tr}from"./chunk.ETOGQE2V.js";import{a as Ge,b as rr,c as ir,d as or,e as sr,f as lr}from"./chunk.O5JKDFDH.js";import{m as Mr}from"./chunk.LPBM5AES.js";import{a as fr,b as yr,c as hr,e as Rr,f as Rn,h as $t}from"./chunk.NGDXH66B.js";import{d as br,e as kr,f as Sr,g as xr,n as Pr,o as Ar,q as Cr,s as Nt}from"./chunk.67WWRC6Y.js";import{a as An}from"./chunk.QIV65FWE.js";import{a as Sn,b as Xa,c as Ja}from"./chunk.UT6642FC.js";import{a as Et,b as pr,c as ur,d as gr,e as mr}from"./chunk.ISXFH3CK.js";import{c as tr,d as nr,j as mt}from"./chunk.N6MVK3KD.js";import{r as xn,s as ar}from"./chunk.42XSBKPO.js";import{f as za,g as lt,i as _a,j as Ya,k as kn,q as Qa,r as Za}from"./chunk.2FLPDPEL.js";import{b as Mt,c as Va,d as Ua,e as ja}from"./chunk.UUBYFBPN.js";import{C as Cn,K as Hr,N as Kr,e as Ha,f as Ka,j as ji,u as vr,v as wr}from"./chunk.LLEFYJPJ.js";import{$ as ce,Ca as Da,G as Ie,L as La,N as Ta,Q as Ma,R as j,S as bn,V as Ea,W as Na,_ as $a,ca as Oa,da as Fa,fa as Ia,ja as st,la as Wa,oa as Rt,r as Ra,v as Fe}from"./chunk.FOQZADMA.js";import{a as Ca}from"./chunk.SDO3U72B.js";import{$c as Ct,I as ca,T as gt,Tc as vn,Vb as va,Wa as fa,Ya as ya,Yb as wa,Yc as Sa,Zb as ba,Zc as xa,aa as it,ba as me,da as be,ea as Pt,ga as ot,gb as hn,hb as ha,ia as pa,id as wn,ja as ua,jd as Pa,ka as He,nd as Aa,pb as At,tc as ka,va as ga,wa as ma}from"./chunk.V5MYKNL7.js";import{b as W}from"./chunk.AJZBJBMO.js";function si(t,e,n={}){let a=t.graph.getNode(e);if(!a)return;let r=t.schema.tryDefinition(a.kind),i=l=>me(t.schema.tryDefinition(l.kind),l),o=new Map;for(let l of t.graph.allEdges()){let d=l.from===e?"out":l.to===e?"in":null;if(!d)continue;let c=d==="out"?l.to:l.from,p=t.graph.getNode(c);if(!p)continue;let f=(d==="out"?r:t.schema.tryDefinition(p.kind))?.edges?.[l.kind],u=d==="in"?f?.inverse??f?.description:f?.description,k=`${l.kind}|${d}|${u??""}`;(o.get(k)??(()=>{let h={edgeKind:l.kind,direction:d,...u?{description:u}:{},targets:[]};return o.set(k,h),h})()).targets.push({id:p.id,kind:p.kind,label:i(p)})}return{id:e,kind:a.kind,label:i(a),fields:Ua(mt(t.schema,t.graph,a),r),violations:hn(t.violations(n.context),[e]),actions:An(t,[e],{focus:e,...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}}),links:[...o.values()].map(l=>{let d=Mt(l.targets.flatMap(c=>{let p=t.graph.getNode(c.id);return p?[p]:[]}),c=>t.schema.tryDefinition(c));return{...l,targets:[...l.targets].map(c=>d.has(c.id)?{...c,apart:d.get(c.id)}:c).sort((c,p)=>c.label.localeCompare(p.label))}})}}function Ye(t,e,n={}){return{kind:e,members:t.graph.nodesOfKind(e),actions:An(t,[],{kindSelection:[e],...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}})}}function li(t,e){let n=(i,o)=>`${i}|${JSON.stringify(o)}`,a=new Map;for(let i of[...t.affordances,...t.withheld]){if(i.provider!=="invariant")continue;let o=n(i.mutation,i.args);a.has(o)||a.set(o,i.rank??Number.MAX_SAFE_INTEGER)}let r=Number.MAX_SAFE_INTEGER;return[...e].map((i,o)=>({repair:i,declared:o})).sort((i,o)=>(a.get(n(i.repair.mutation,i.repair.args??{}))??r)-(a.get(n(o.repair.mutation,o.repair.args??{}))??r)||i.declared-o.declared).map(i=>i.repair)}function Qe(t){let e=t.schema.kinds.map(r=>({kind:r,plural:ot(t.schema,r),count:t.graph.nodesOfKind(r).length})),n=new Map;for(let r of t.graph.allEdges()){let i=t.graph.getNode(r.from),o=t.graph.getNode(r.to);if(!i||!o)continue;let l=`${r.kind}|${i.kind}|${o.kind}`;n.set(l,(n.get(l)??0)+1)}let a=[];for(let{kind:r}of e){let i=t.schema.tryDefinition(r)?.edges??{};for(let[o,l]of Object.entries(i)){let d=l.to==="*"||l.to===void 0?(()=>{let c=[...n.keys()].filter(p=>p.startsWith(`${o}|${r}|`)).map(p=>p.split("|")[2]);return c.length>0?c:["*"]})():l.to;for(let c of d)a.push({edgeKind:o,from:r,to:c,...l.description?{description:l.description}:{},...l.inverse?{inverse:l.inverse}:{},count:n.get(`${o}|${r}|${c}`)??0})}}return{kinds:e,relations:a}}var qe=W(Ie(),1);var Ze=W(Ie(),1),x=W(j(),1),zi=`
1
+ var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{A as Vt,B as Pe,C as Nn,D as Ke,E as Ue,F as ni,G as $n,H as Le,I as ai,J as ri,K as F,L as ct,M as On,N as ii,O as Fn,P as Ut,Q as oi,R as ae,S as ie,T as In,a as Y,b as $e,c as Z,d as Qr,e as Mn,f as En,g as dt,h as J,i as ke,j as re,k as C,l as te,m as K,n as Se,o as Kt,p as xe,q as fe,r as Jr,s as ft,t as qt,u as Q,v as Ve,w as ei,x as Bt,y as Re,z as ti}from"./chunk.MUPO5S2A.js";import{b as Tn,c as Zr,d as Xr,e as Gt,g as ne}from"./chunk.JYJ4LZJJ.js";import{a as zr,d as _r,e as Yr}from"./chunk.UGFDSE37.js";import{a as qr,c as Br,f as Gr,g as Vr,i as Ur,j as jr}from"./chunk.USZPOOLZ.js";import{a as Nr,b as $r,c as Or,d as Ln}from"./chunk.C4TSM4W5.js";import{b as Er}from"./chunk.XEKLEHC3.js";import{a as Fr,b as Ir,d as It,e as Wr,f as Dr,i as Wt}from"./chunk.53CDFJNM.js";import{a as Dt,b as Ht}from"./chunk.PXQVXBNG.js";import{a as Lt,b as qa,c as Ba,d as Tt,e as Ga}from"./chunk.BQRAIU5R.js";import{b as er,c as dr,e as cr,f as Pn}from"./chunk.57R2GXXN.js";import{a as Ot,b as Ft,c as Lr,e as Tr}from"./chunk.5P556A7W.js";import{a as Ge,b as rr,c as ir,d as or,e as sr,f as lr}from"./chunk.QHYXXZRD.js";import{m as Mr}from"./chunk.6YPLZNVT.js";import{a as fr,b as yr,c as hr,e as Rr,f as Rn,h as $t}from"./chunk.NGDXH66B.js";import{d as br,e as kr,f as Sr,g as xr,n as Pr,o as Ar,q as Cr,s as Nt}from"./chunk.67WWRC6Y.js";import{a as An}from"./chunk.QIV65FWE.js";import{a as Sn,b as Xa,c as Ja}from"./chunk.UT6642FC.js";import{a as Et,b as pr,c as ur,d as gr,e as mr}from"./chunk.ISXFH3CK.js";import{c as tr,d as nr,j as mt}from"./chunk.N6MVK3KD.js";import{r as xn,s as ar}from"./chunk.42XSBKPO.js";import{f as za,g as lt,i as _a,j as Ya,k as kn,q as Qa,r as Za}from"./chunk.2FLPDPEL.js";import{b as Mt,c as Va,d as Ua,e as ja}from"./chunk.UUBYFBPN.js";import{C as Cn,K as Hr,N as Kr,e as Ha,f as Ka,j as ji,u as vr,v as wr}from"./chunk.JHEVGLKB.js";import{$ as ce,Ca as Da,G as Ie,L as La,N as Ta,Q as Ma,R as j,S as bn,V as Ea,W as Na,_ as $a,ca as Oa,da as Fa,fa as Ia,ja as st,la as Wa,oa as Rt,r as Ra,v as Fe}from"./chunk.FOQZADMA.js";import{a as Ca}from"./chunk.SDO3U72B.js";import{$c as Ct,I as ca,T as gt,Tc as vn,Vb as va,Wa as fa,Ya as ya,Yb as wa,Yc as Sa,Zb as ba,Zc as xa,aa as it,ba as me,da as be,ea as Pt,ga as ot,gb as hn,hb as ha,ia as pa,id as wn,ja as ua,jd as Pa,ka as He,nd as Aa,pb as At,tc as ka,va as ga,wa as ma}from"./chunk.V5MYKNL7.js";import{b as W}from"./chunk.AJZBJBMO.js";function si(t,e,n={}){let a=t.graph.getNode(e);if(!a)return;let r=t.schema.tryDefinition(a.kind),i=l=>me(t.schema.tryDefinition(l.kind),l),o=new Map;for(let l of t.graph.allEdges()){let d=l.from===e?"out":l.to===e?"in":null;if(!d)continue;let c=d==="out"?l.to:l.from,p=t.graph.getNode(c);if(!p)continue;let f=(d==="out"?r:t.schema.tryDefinition(p.kind))?.edges?.[l.kind],u=d==="in"?f?.inverse??f?.description:f?.description,k=`${l.kind}|${d}|${u??""}`;(o.get(k)??(()=>{let h={edgeKind:l.kind,direction:d,...u?{description:u}:{},targets:[]};return o.set(k,h),h})()).targets.push({id:p.id,kind:p.kind,label:i(p)})}return{id:e,kind:a.kind,label:i(a),fields:Ua(mt(t.schema,t.graph,a),r),violations:hn(t.violations(n.context),[e]),actions:An(t,[e],{focus:e,...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}}),links:[...o.values()].map(l=>{let d=Mt(l.targets.flatMap(c=>{let p=t.graph.getNode(c.id);return p?[p]:[]}),c=>t.schema.tryDefinition(c));return{...l,targets:[...l.targets].map(c=>d.has(c.id)?{...c,apart:d.get(c.id)}:c).sort((c,p)=>c.label.localeCompare(p.label))}})}}function Ye(t,e,n={}){return{kind:e,members:t.graph.nodesOfKind(e),actions:An(t,[],{kindSelection:[e],...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}})}}function li(t,e){let n=(i,o)=>`${i}|${JSON.stringify(o)}`,a=new Map;for(let i of[...t.affordances,...t.withheld]){if(i.provider!=="invariant")continue;let o=n(i.mutation,i.args);a.has(o)||a.set(o,i.rank??Number.MAX_SAFE_INTEGER)}let r=Number.MAX_SAFE_INTEGER;return[...e].map((i,o)=>({repair:i,declared:o})).sort((i,o)=>(a.get(n(i.repair.mutation,i.repair.args??{}))??r)-(a.get(n(o.repair.mutation,o.repair.args??{}))??r)||i.declared-o.declared).map(i=>i.repair)}function Qe(t){let e=t.schema.kinds.map(r=>({kind:r,plural:ot(t.schema,r),count:t.graph.nodesOfKind(r).length})),n=new Map;for(let r of t.graph.allEdges()){let i=t.graph.getNode(r.from),o=t.graph.getNode(r.to);if(!i||!o)continue;let l=`${r.kind}|${i.kind}|${o.kind}`;n.set(l,(n.get(l)??0)+1)}let a=[];for(let{kind:r}of e){let i=t.schema.tryDefinition(r)?.edges??{};for(let[o,l]of Object.entries(i)){let d=l.to==="*"||l.to===void 0?(()=>{let c=[...n.keys()].filter(p=>p.startsWith(`${o}|${r}|`)).map(p=>p.split("|")[2]);return c.length>0?c:["*"]})():l.to;for(let c of d)a.push({edgeKind:o,from:r,to:c,...l.description?{description:l.description}:{},...l.inverse?{inverse:l.inverse}:{},count:n.get(`${o}|${r}|${c}`)??0})}}return{kinds:e,relations:a}}var qe=W(Ie(),1);var Ze=W(Ie(),1),x=W(j(),1),zi=`
2
2
  form:where([data-graview-part="form"]) {
3
3
  /* A grid item of the section above it and a grid container for the
4
4
  fields below: both halves are allowed to be narrower than what is in
@@ -105,7 +105,7 @@ p:where([data-graview-part="refused"]) {
105
105
  .graview-gallery-card > span:first-child { transition: border-color 160ms ease, box-shadow 160ms ease; }
106
106
  .graview-gallery-card:hover > span:first-child,
107
107
  .graview-gallery-card:focus-visible > span:first-child { border-color: var(--graview-edge-bright); box-shadow: 0 1px 0 var(--graview-edge), 0 10px 30px -18px var(--graview-ink); }
108
- `;function qn({context:t}){ne(t.store);let e=Hn(t);return e.length===0?null:(0,T.jsxs)("section",{style:ui,"data-testid":"gallery",children:[(0,T.jsx)("style",{children:ro}),e.map(n=>(0,T.jsx)(Kn,{context:t,entry:n},n.key))]})}function Bn({context:t}){let{store:e}=t;ne(e);let n=vn(Te(t)).filter(r=>!r.hidden),a=Hn(t);return(0,T.jsxs)(ae,{context:t,style:dt,children:[(0,T.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,T.jsx)("p",{style:ke,children:n.length===0?"None of its own yet":`${n.length} ${n.length===1?"picture":"pictures"}`}),(0,T.jsx)(ie,{context:t,children:"Pictures"}),(0,T.jsx)("p",{style:re,children:n.length===0?"Nothing here has a picture of its own yet, so each kind is drawn as the scene draws it. Title a group view and it appears here by name.":"The ways this installation looks at what it holds \u2014 each one the same picture the scene shows, here as a page."})]}),a.length>0?(0,T.jsx)("div",{style:ui,"data-testid":"places",children:a.map(r=>(0,T.jsx)(Kn,{context:t,entry:r},r.key))}):null]})}function Gn({context:t}){let{store:e,principal:n}=t;ne(e);let a=Ue(),r=Ke(),[i]=ct(),o=decodeURIComponent(a.as??""),[l,d]=(0,qe.useState)(null),c=i.get("of"),p=i.get("filter"),f=Te(t).find(M=>M.as===o&&(!c||Y(e.schema,M.kind)===c));if(!f)return(0,T.jsxs)(ae,{context:t,children:[(0,T.jsx)(ie,{context:t,children:"No picture is called that."}),(0,T.jsx)("p",{style:re,children:(0,T.jsxs)(F,{to:"/places",style:K,children:["The pictures there are ",(0,T.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]})})]});let u=Q(e,f.kind),k=t.views?.resolve(f.kind,{cardinality:"many",fidelity:"full"},f.as)?.view,B=k?.flows===!0,h=k?.creates!==!1,R=Ye(e,f.kind,{...n?{principal:n}:{},...t.invariantContext?{context:t.invariantContext}:{}}),G=h?R.actions.affordances.map(M=>({affordance:M,mutation:e.allMutations().find(V=>V.name===M.mutation)})).filter(M=>M.mutation!==void 0):[];return(0,T.jsxs)(ae,{context:t,style:dt,children:[(0,T.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,T.jsx)(ie,{context:t,children:f.title}),(0,T.jsxs)("p",{style:re,"data-testid":"place-lede",children:[Wn(e,zt(t,f),f.across),"."]}),p&&!B?(0,T.jsxs)("p",{style:{...C,margin:0},"data-testid":"place-narrowed",children:[`Only those where ${p.split(",").map(M=>M.replace(":"," is ")).join(" and ")}. `,(0,T.jsx)(F,{to:`?${(()=>{let M=new URLSearchParams(i);return M.delete("filter"),M.toString()})()}`,style:{...K,...C},children:"Show all"})]}):null,(0,T.jsx)("p",{style:{...C,margin:0,display:"flex",flexWrap:"wrap",gap:"4px 16px"},children:zt(t,f).map((M,V)=>(0,T.jsxs)(F,{to:`/${Y(e.schema,M)}`,style:{...K,...C},...V===0?{"data-testid":"place-as-list"}:{},children:["All ",(M===f.kind?u:Q(e,M)).toLowerCase()," as a list ",(0,T.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]},M))})]}),(0,T.jsx)("div",{"data-testid":"place-lens","data-flows":B?"":void 0,style:B?{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",maxWidth:"100%"}:{height:"min(72vh, 760px)",display:"grid",gridTemplateRows:"minmax(0, 1fr)",overflow:"auto",maxWidth:"100%",borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)"},onClick:M=>{let V=M.target?.closest("[data-graview-pick]"),z=V?.getAttribute("data-graview-pick"),se=V?.getAttribute("data-graview-joins");if(se)try{let I=JSON.parse(se);if(Array.isArray(I)&&I.every(_=>typeof _=="string")){M.preventDefault(),d({at:Xe(f),ids:I});return}}catch{}if(!z)return;let ue=e.graph.getNode(z);ue&&(M.preventDefault(),r(Z(e.schema,ue.kind,z)))},children:(0,T.jsx)(Dn,{context:t,place:f,filter:p,...l?.at===Xe(f)?{chosen:l.ids}:{}})}),G.length>0?(0,T.jsx)("div",{style:{maxWidth:760,display:"grid",gap:40},"data-testid":"place-creators",children:G.map(({affordance:M,mutation:V})=>(0,T.jsxs)("section",{style:{...te,display:"grid",gap:14},children:[(0,T.jsx)("h2",{style:J,children:V.title??V.name}),V.description?(0,T.jsx)("p",{style:{...C,margin:0,maxWidth:"58ch"},children:V.description}):null,(0,T.jsx)(We,{store:e,mutation:V,prefilled:M.args,open:M.open,label:M.label,...n?{principal:n}:{}})]},M.id))}):null]})}function io(t,e=document){let n=Dt(t);if(!n)return null;let a=[e,...[...e.querySelectorAll("[data-worker-view]")].flatMap(r=>r.shadowRoot?[r.shadowRoot]:[])];for(let r of a)for(let i of r.querySelectorAll("[id], [data-section]")){let o=i.getAttribute("data-section")??i.id;if(o===t||Dt(o)===n)return i}for(let r of a)for(let i of r.querySelectorAll("h1, h2, h3, h4, h5, h6, [role=heading]"))if(Dt(i.textContent??"")===n)return i;return null}function gi(t,e={}){if(typeof document>"u"||typeof requestAnimationFrame>"u")return()=>{};let n=e.frames??120,a=0,r=()=>{let i=io(t,e.root??document);if(i){i.hasAttribute("tabindex")||i.setAttribute("tabindex","-1"),i.scrollIntoView?.({block:"start"}),i.focus({preventScroll:!0});return}n-=1,n>0&&(a=requestAnimationFrame(r))};return a=requestAnimationFrame(()=>{a=requestAnimationFrame(r)}),()=>cancelAnimationFrame(a)}var U=W(Ie(),1);var _t=W(Ie(),1);var Je=W(j(),1);function mi({context:t}){return ce()?(0,Je.jsxs)(Je.Fragment,{children:[(0,Je.jsx)(oo,{context:t}),(0,Je.jsx)(Br,{face:"pages",on:t.quickAsk??!0})]}):null}function oo({context:t}){let{store:e}=t,n=ce(),{pathname:a}=Pe(),r=(0,_t.useRef)(n?.setSelection);return r.current=n?.setSelection,(0,_t.useEffect)(()=>{let i=r.current;if(!i)return;let[,o,l]=a.split("/"),d=(()=>{if(o==="places"){let p=t.views?.places().find(m=>m.as===decodeURIComponent(l??""));return p?[Fe(p.kind)]:[]}let c=o?$e(e.schema,o):void 0;return c&&l?[decodeURIComponent(l)]:c?[Ra(c)]:[]})();i(c=>c.length===d.length&&c.every((p,m)=>p===d[m])?c:d)},[a]),null}var he=W(Ie(),1);var yi=W(ji(),1);var pe=W(j(),1);var so=(0,he.lazy)(Rt(Ca(()=>(__graviewPreload(import.meta.url,["./chunk.CN5WAKHJ.js","./chunk.UGFDSE37.js","./chunk.PYNYHNDS.js","./chunk.LPE4FLC6.js","./chunk.XEKLEHC3.js","./chunk.VZYCILPJ.js","./chunk.4QPVS2ZM.js","./chunk.RCM7NOPF.js","./chunk.Z7LDT55A.js","./chunk.47KHZCNG.js","./chunk.XQHDP5C3.js","./chunk.BFNVG5JE.js","./chunk.ZJMDLRC5.js","./chunk.2GDXNTY5.js","./chunk.ETOGQE2V.js","./chunk.O5JKDFDH.js","./chunk.YYIKSH2F.js","./chunk.LPBM5AES.js","./chunk.5RABSIF7.js","./chunk.NGDXH66B.js","./chunk.67WWRC6Y.js","./chunk.MB7LKKUD.js","./chunk.WVUJXDXZ.js","./chunk.N6MVK3KD.js","./chunk.I7XSDXQ3.js","./chunk.UHI3D7JC.js","./chunk.WVDKYUF3.js","./chunk.ZHLQWMV5.js","./chunk.TNESS3LQ.js","./chunk.GZHZLJBF.js","./chunk.42XSBKPO.js","./chunk.OJGHDWI6.js","./chunk.6FNMDAX5.js","./chunk.2FLPDPEL.js","./chunk.UUBYFBPN.js","./chunk.2RVUDRRY.js","./chunk.LLEFYJPJ.js","./chunk.FOQZADMA.js","./chunk.SDO3U72B.js","./chunk.V5MYKNL7.js","./chunk.AJZBJBMO.js"]),import("./chunk.YO24NALN.js")).then(t=>({default:t.TakeBack})))));function lo({context:t,docked:e,at:n}){let{store:a}=t,r=ne(a),[i]=(0,he.useState)(()=>a.batches().length),o=(0,he.useRef)(!1);return o.current||=r>0||!e&&i>0,o.current?(0,pe.jsx)(he.Suspense,{fallback:null,children:(0,pe.jsx)(so,{context:t,docked:e,at:n,since:i})}):null}function co(t,e,n){let{store:a,principal:r,embedded:i}=t;(0,he.useEffect)(()=>{if(!n)return;let o=l=>{if(!Yr(l))return;let d=l.target,c=d instanceof Node&&e.current?.contains(d),p=d===document.body||d===document.documentElement||d===document;if(!(!c&&!(p&&!i))&&zr(a,r)){l.preventDefault();try{_r(a,r)}catch{}}};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[a,r,i,e,n])}function hi({context:t,registry:e,root:n,children:a}){let r=(0,he.useMemo)(ii,[]),i=e?.without()??new Set;return co(t,n,!i.has("undo")),(0,pe.jsxs)(On.Provider,{value:r,children:[(0,pe.jsx)(po,{context:t,placed:r,without:i}),a]})}function po({context:t,placed:e,without:n}){let[a,r]=(0,he.useState)(!1);(0,he.useLayoutEffect)(()=>r(!0),[]);let i=Fn(e,"find"),o=Fn(e,"undo"),l=Pe(),d=wr();if(!a)return null;let c=l.pathname.split("/").filter(Boolean),m=(c.length===1?$e(t.store.schema,c[0]):void 0)!==void 0;return(0,pe.jsxs)(pe.Fragment,{children:[!i&&!n.has("find")&&d?(0,yi.createPortal)((0,pe.jsx)(fi,{context:t,narrowsLists:m}),d.slot):null,!i&&!n.has("find")&&!d?(0,pe.jsx)("div",{"data-testid":"face-find-bar",style:{display:"flex",alignItems:"center",padding:"8px 16px",borderBottom:"1px solid var(--graview-edge)",background:"var(--graview-bar)",minWidth:0},children:(0,pe.jsx)(fi,{context:t,narrowsLists:m})}):null,!o&&!n.has("undo")?(0,pe.jsx)(lo,{context:t,docked:!0,at:l.pathname+l.search}):null,d?.own&&!n.has("undo")?(0,pe.jsx)(ti,{context:t,own:d.own}):null]})}function fi({context:t,narrowsLists:e}){return(0,pe.jsx)(On.Provider,{value:null,children:(0,pe.jsx)(In,{context:t,narrowsLists:e})})}var X=W(Ie(),1);var Ae=W(j(),1),uo=500,go=10;function Yt(t){return t instanceof HTMLElement?t.isContentEditable||t.tagName==="TEXTAREA"||t.tagName==="SELECT"?!0:t.tagName==="INPUT"&&!["button","submit","reset","checkbox","radio","image","file","color","range"].includes(t.type):!1}function mo(t){let e=typeof getSelection=="function"?getSelection():null;return e!==null&&!e.isCollapsed&&e.containsNode(t,!0)}function vi(t){let e=t.closest('a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])');if(e)return e;let n=document.activeElement;return n instanceof HTMLElement&&n!==document.body?n:null}function wi({context:t,root:e,children:n}){return ce()===null?(0,Ae.jsx)(Ae.Fragment,{children:n}):(0,Ae.jsx)(fo,{context:t,root:e,children:n})}function fo({context:t,root:e,children:n}){let{setMenuAt:a}=$a(),{store:r}=t,i=r.schema,o=Ke(),{pathname:l,search:d}=Pe(),c=Vt("/").replace(/\/$/,""),p=(0,X.useCallback)((w,y)=>t.views?.places().find(L=>L.as===w&&(y===null||L.kind===y)),[t.views]),m=(0,X.useCallback)((w,y)=>{let[L="",$,g]=w.split("/").filter(Boolean).map(O=>{try{return decodeURIComponent(O)}catch{return O}});if(g!==void 0)return null;if(L==="places"&&$!==void 0){let O=p($,new URLSearchParams(y).get("of"));return O?{face:"pages",place:O.as,about:[Fe(O.kind)],title:O.title}:null}let A=$e(i,L);return A?$===void 0?{face:"pages",about:[Fe(A)],title:ot(i,A)}:r.graph.getNode($)?{face:"pages",on:$,about:[$]}:null:null},[i,r,p]),f=(0,X.useCallback)(w=>{let y=w.href;try{let L=new URL(y,location.href);if(L.origin===location.origin&&(c===""||L.pathname===c||L.pathname.startsWith(`${c}/`))){let $=m(L.pathname.slice(c.length),L.search);if($)return{...$,href:y}}}catch{}return{face:"pages",about:[],href:y}},[c,m]),u=(0,X.useCallback)(()=>m(l,d)??{face:"pages",about:[]},[m,l,d]),k=(0,X.useCallback)(w=>{let y=u(),L=w.closest("[data-graview-field]")?.getAttribute("data-graview-field");if(L&&y.on!==void 0&&w.closest("[data-graview-pick], a[href]")===null)return{...y,field:L};let $=w.closest("[data-graview-act]")?.getAttribute("data-graview-act");if($)return{...y,act:$};let g=w.closest("a[href]"),A=w.closest("[data-graview-listed]"),O=[w.closest("[data-graview-pick]")?.getAttribute("data-graview-pick"),A&&(!g||A.contains(g)&&g.classList.contains("graview-spec-item-link"))?A.getAttribute("data-graview-listed"):null].map(De=>De?r.graph.getNode(De):void 0).find(Boolean);if(O)return{face:"pages",on:O.id,about:[O.id],href:`${c}${Z(i,O.kind,O.id)}`};if(g)return f(g);let ee=w.closest("[data-graview-record]")?.getAttribute("data-graview-record");return ee&&r.graph.getNode(ee)?{face:"pages",on:ee,about:[ee]}:y},[u,f,r,i,c]),B=(0,X.useCallback)(w=>{let y=e.current;if(y===null||!y.contains(w)||Yt(w)||w.closest("[data-graview-popover]"))return null;let L=k(w);return{face:"pages",on:L.on,about:L.about??[],field:L.field,place:L.place,href:L.href,act:L.act,element:vi(w)}},[k,e]),h=(0,X.useCallback)((w,y,L)=>{let $=k(w);a({...$,x:Math.round(y),y:Math.round(L),returnTo:vi(w)})},[k,a]),R=(0,X.useCallback)(w=>{let y=w.getBoundingClientRect();h(w,y.left+Math.min(16,y.width/2),Math.min(y.bottom,y.top+36))},[h]),G=(0,X.useRef)(0),M=(0,X.useRef)(null),V=(0,X.useRef)(!1),z=()=>{M.current&&clearTimeout(M.current.timer),M.current=null};(0,X.useEffect)(()=>z,[]),(0,X.useEffect)(()=>{let w=y=>{if(y.defaultPrevented||!(y.key==="ContextMenu"||y.key==="F10"&&y.shiftKey))return;let L=e.current,$=y.target instanceof Element?y.target:null,g=$===null||$===document.body||$===document.documentElement,A=L!==null&&$!==null&&L.contains($);if(!A&&!(g&&document.querySelector("[data-graview-face='pages']")===L)||Yt($)||$?.closest("[data-graview-popover]"))return;y.preventDefault(),G.current=Date.now();let O=A&&$ instanceof HTMLElement?$:L?.querySelector("[data-graview-page-title], main h1, main")??null;O&&R(O)};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[e,R]),(0,X.useEffect)(()=>{let w=e.current;if(!w)return;let y=L=>{let $=L.detail;$&&a({...$,face:"pages"})};return w.addEventListener(bn,y),()=>w.removeEventListener(bn,y)},[e,a]);let se=(0,X.useMemo)(()=>w=>{if(w.face!=="pages")return null;let y=[],L=w.on===void 0?void 0:r.graph.getNode(w.on),$=w.place===void 0?void 0:t.views?.places().find(Ee=>Ee.as===w.place),g=L?void 0:w.about.length===1&&w.about[0].startsWith("aggregate:")&&!$?yo(w.about[0]):void 0,A=L?Z(i,L.kind,L.id):$?ye(t,$):g?`/${Y(i,g)}`:void 0,O=A!==void 0&&l===A.split("?")[0];A!==void 0&&!O&&y.push({id:"open",label:"Open",run:()=>o(A)});let ee=A!==void 0?`${c}${A}`:w.href;ee!==void 0&&y.push({id:"open-in-a-new-tab",label:"Open in a new tab",run:()=>void window.open(ee,"_blank","noopener")});let De=L?`#focus=${encodeURIComponent(L.id)}`:$?`#focus=${encodeURIComponent(Fe($.kind))}&view=${encodeURIComponent($.as)}`:g?`#focus=${encodeURIComponent(Fe(g))}`:void 0;if(De!==void 0&&(t.overview||!t.embedded)){let Ee=t.overview;y.push({id:"in-the-scene",label:"Show in the scene",run:()=>Ee?Ee(De):location.assign(`${t.sceneHref??"/"}${De}`)})}return L===void 0&&w.href===void 0&&y.push({id:"find",label:"Find\u2026",run:()=>{let Ee=e.current?.querySelector('[data-testid="nav-find"]')??document.querySelector('[data-testid="nav-find"]');Ee&&Ee.offsetParent!==null?Ee.focus():o("/search")}}),y.length>0?{id:"pages",items:y}:null},[r,i,t,l,c,o,e]),ue=(0,X.useMemo)(()=>w=>{if(w.face!=="pages"||w.field===void 0||w.on===void 0)return null;let y=r.graph.getNode(w.on),L=w.element?.closest("[data-graview-field]")??e.current?.querySelector(`[data-graview-field="${CSS.escape(w.field)}"]`);return!y||!(L instanceof HTMLElement)||!L.hasAttribute("data-graview-editable")?null:{id:"field",at:"start",items:[{id:"change-field",label:`Change \u201C${pa(i.tryDefinition(y.kind),w.field)}\u201D`,run:()=>L.click()}]}},[r,i,e]),I=Vr(),_=dr(),oe=Er(),we=(0,X.useCallback)((w,y)=>{l===ye(t,w).split("?")[0]&&o(y?ye(t,y):"/")},[l,t,o]),le=jr(we),ge=(0,X.useMemo)(()=>[ue,oe,se,...le?[le]:[],..._?[_]:[],...I?[I]:[]],[ue,oe,se,le,_,I]);return(0,Ae.jsxs)(ar,{sections:ge,children:[(0,Ae.jsx)("div",{"data-graview-menu-ground":"",style:{display:"contents"},onContextMenu:w=>{let y=w.target;w.shiftKey||Yt(y)||mo(y)||(w.preventDefault(),!y.closest("[data-graview-popover]")&&(Date.now()-G.current<700||(w.clientX===0&&w.clientY===0&&y instanceof HTMLElement?R(y):h(y,w.clientX,w.clientY))))},onPointerDown:w=>{if(V.current=!1,w.pointerType==="mouse"||!w.isPrimary)return;let y=w.target;if(Yt(y)||y.closest("[data-graview-choose], [data-graview-popover]"))return;z();let{clientX:L,clientY:$}=w;M.current={x:L,y:$,timer:setTimeout(()=>{M.current=null,V.current=!0,G.current=Date.now(),h(y,L,$)},uo)}},onPointerMove:w=>{let y=M.current;y&&Math.hypot(w.clientX-y.x,w.clientY-y.y)>go&&z()},onPointerUp:z,onPointerCancel:z,onClickCapture:w=>{V.current&&(V.current=!1,w.preventDefault(),w.stopPropagation())},children:n}),(0,Ae.jsx)(ho,{openAt:R,readyAt:B}),(0,Ae.jsx)(Ur,{placement:"page"}),(0,Ae.jsx)(cr,{})]})}function yo(t){let e=t.slice(10).split("+");return e.length===1&&e[0]?e[0]:void 0}function ho({openAt:t,readyAt:e}){return(0,Ae.jsx)("span",{"data-graview-menu-home":"",tabIndex:-1,onFocus:n=>{if(n.target!==n.currentTarget)return;let a=n.currentTarget.closest("[data-graview-face]"),r=a?.querySelector("[data-graview-page-title]")??a?.querySelector("main h1, main")??null;r&&(r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),r.focus({preventScroll:!0}))},style:{position:"absolute",width:0,height:0,overflow:"hidden"},children:(0,Ae.jsx)(qr,{placement:"menu",openActs:t,aimAt:e})})}var H=W(j(),1);function bi(t,e){return e==="*"?{label:"anything",path:null}:{label:Q(t,e),path:`/${Y(t.schema,e)}`}}function vo({context:t,relation:e}){let{store:n}=t,a=bi(n,e.from),r=bi(n,e.to),i=o=>o.path?(0,H.jsx)(F,{to:o.path,style:{...Se,fontWeight:550},children:o.label}):(0,H.jsx)("span",{children:o.label});return(0,H.jsxs)("li",{"data-testid":"relation","data-relation":e.edgeKind,style:{display:"grid",gridTemplateColumns:"30px minmax(0, 1fr) auto",gap:12,alignItems:"baseline"},children:[(0,H.jsx)(Gr,{edgeKind:e.edgeKind,...t.brand?.kit?{kit:t.brand.kit}:{}}),(0,H.jsxs)("span",{style:{display:"grid",gap:1},children:[(0,H.jsxs)("span",{children:[i(a)," ",(0,H.jsxs)("span",{style:C,"data-graview-speaks-ids":"",children:[be(e.edgeKind)," \u2192"]})," ",i(r)]}),e.description||e.inverse?(0,H.jsxs)("span",{style:C,children:[e.description?Re(e.description):null,e.description&&e.inverse?" \xB7 ":null,e.inverse?`from the other end, ${e.inverse}`:null]}):null]}),r.path?(0,H.jsx)(F,{to:`${r.path}?with=${encodeURIComponent(e.edgeKind)}`,style:{...K,...C,fontVariantNumeric:"tabular-nums",display:"inline-block",minWidth:24,minHeight:24,textAlign:"center"},title:`The ${r.label.toLowerCase()} that have this`,children:e.count}):(0,H.jsx)("span",{style:{...C,fontVariantNumeric:"tabular-nums"},children:e.count})]})}function ki({context:t,heading:e=!0}){let{store:n}=t,a=new Set(Ve(n,t.principal)),r=Qe(n).relations.filter(i=>a.has(i.from)&&(i.to==="*"||a.has(i.to)));return r.length===0?null:(0,H.jsxs)("section",{style:{...te,display:"grid",gap:12},"data-testid":"kind-map",children:[e?(0,H.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,H.jsx)("h2",{style:J,children:(0,H.jsx)(F,{to:"/map",style:Se,children:"Connections"})}),(0,H.jsx)("span",{style:C,children:r.length===1?"1 relation":`${r.length} relations`})]}):null,(0,H.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:r.map(i=>(0,H.jsx)(vo,{context:t,relation:i},`${i.edgeKind}|${i.from}|${i.to}`))})]})}function Vn({context:t}){let{store:e}=t;ne(e);let n=new Set(Ve(e,t.principal)),a=Qe(e),r=a.relations.filter(i=>n.has(i.from));return(0,H.jsxs)(ae,{context:t,children:[(0,H.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,H.jsx)("p",{style:ke,children:r.length===0?"No relations":`${r.length} ${r.length===1?"relation":"relations"}`}),(0,H.jsx)(ie,{context:t,children:"Connections"}),(0,H.jsx)("p",{style:re,children:r.length===0?"Nothing here is declared to relate to anything else yet.":"The kinds this installation holds, and the relations declared between them \u2014 each in the declaration's own words, with how many of it there are."})]}),(0,H.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"6px 18px"},"data-testid":"map-kinds",children:a.kinds.filter(i=>n.has(i.kind)).map(i=>(0,H.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,H.jsx)(fe,{kind:i.kind,brand:t.brand,schema:e.schema,size:7}),(0,H.jsx)(F,{to:`/${Y(e.schema,i.kind)}`,style:K,children:i.plural}),(0,H.jsx)("span",{style:C,children:i.count})]},i.kind))}),(0,H.jsx)(ki,{context:t,heading:!1})]})}function Si({context:t}){let n=[...ce()?.robots.values()??[]].filter(r=>r.mode==="asking"&&r.say);if(n.length===0)return null;let{store:a}=t;return(0,H.jsxs)("section",{style:{...te,display:"grid",gap:10},"data-testid":"seat-questions",children:[(0,H.jsx)("h2",{style:J,children:n.length===1?"The seat asked something":`The seat asked ${n.length} things`}),(0,H.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8},children:n.map(r=>{let i=r.at?a.graph.getNode(r.at):void 0;return(0,H.jsxs)("li",{style:{display:"grid",gap:2},children:[(0,H.jsx)("span",{children:r.say}),i?(0,H.jsxs)(F,{to:Z(a.schema,i.kind,i.id),style:{...K,...C},children:[me(a.schema.tryDefinition(i.kind),i)," \u2192"]}):null]},r.participant)})})]})}var q=W(j(),1);function Un({context:t}){let{principal:e}=t,{store:n,brand:a,invariantContext:r}=t;ne(n);let i=n.violations(r),o=`${i.length===1?"A rule is broken":"Rules are broken"} \u2014 see what, and what would fix it`,l=[...n.log.all()].slice(-5).reverse(),c=Bt(t).map(R=>({kind:R,members:n.graph.nodesOfKind(R).filter(G=>it(n.schema.tryDefinition(R),G))})),p=c.filter(R=>R.members.length>0),m=c.map(R=>({entry:R,creator:n.allMutations().find(G=>(G.creates??[]).includes(R.kind)&&n.permits({name:G.name,args:{}},t.principal).ok)})).find(R=>R.creator!==void 0),f=p.length===0?"Nothing here yet.":`${p.map(R=>Pt(n.schema,R.kind,R.members.length)).join(", ").replace(/, ([^,]*)$/," and $1")}.`,u=t.views?.homeView?.(),k=n.schema.kinds.some(R=>n.graph.nodesOfKind(R).length>0);if(u&&k){let R=a?.subtitle?(0,q.jsx)("p",{style:{...C,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,G=u[Symbol.for("graview.home-blocks")]===!0;return(0,q.jsx)(ae,{context:t,style:dt,children:(0,q.jsxs)("div",{style:{display:"grid",gap:12},"data-testid":"home-view",children:[G?null:R,i.length>0?(0,q.jsx)(F,{to:"/problems",style:{...K,color:"var(--graview-warn)"},children:o}):null,(0,q.jsx)(Dr.Provider,{value:G?R:null,children:(0,q.jsx)(u,{cardinality:"many",fidelity:"full",mode:"fullscreen",selected:!1})})]})})}let B=new Set(Ve(n,t.principal)),h=Qe(n).relations.filter(R=>B.has(R.from)&&(R.to==="*"||B.has(R.to)));return(0,q.jsxs)(ae,{context:t,style:dt,children:[(0,q.jsxs)("header",{style:{display:"grid",gap:12},children:[a?.subtitle?(0,q.jsx)("p",{style:{...C,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,(0,q.jsx)(ie,{context:t,"data-testid":"standing",children:f}),(0,q.jsxs)("p",{style:{...re,display:"grid",gap:4},"data-testid":"standing-card",children:[p.length===0&&m?(0,q.jsxs)("span",{children:["Begin with \u201C",m.creator?.title??m.creator?.name,"\u201D, under"," ",(0,q.jsx)(F,{to:`/${Y(n.schema,m.entry.kind)}`,style:K,children:Q(n,m.entry.kind)}),"."]}):null,i.length===0?(0,q.jsx)("span",{children:"All rules hold."}):(0,q.jsx)(F,{to:"/problems",style:{...K,color:"var(--graview-warn)"},children:o})]})]}),(0,q.jsx)(qn,{context:t}),(0,q.jsxs)("section",{style:{...te,display:"grid",gap:14},"data-testid":"kinds",children:[(0,q.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,q.jsx)("h2",{style:J,children:"What is here"}),h.length>0?(0,q.jsxs)(F,{to:"/map",style:{...K,...C,marginLeft:"auto"},"data-testid":"map-link",children:["Connections \xB7 ",h.length===1?"1 relation":`${h.length} relations`," ",(0,q.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]}):null]}),(0,q.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"8px 10px"},children:c.map(({kind:R,members:G})=>(0,q.jsx)("li",{style:{maxWidth:"100%"},children:(0,q.jsxs)(F,{to:`/${Y(n.schema,R)}`,style:{...Se,flexWrap:"wrap",gap:8,padding:"6px 14px 6px 10px",borderRadius:8,border:"1px solid var(--graview-edge-bright)",background:"var(--graview-panel)"},children:[(0,q.jsx)(fe,{kind:R,brand:a,schema:n.schema,size:7}),(0,q.jsx)("span",{style:{fontWeight:550,overflowWrap:"anywhere"},children:Q(n,R)}),(0,q.jsx)("span",{style:{...C,fontVariantNumeric:"tabular-nums"},children:G.length===0?"none yet":gt(G.length)})]})},R))})]}),l.length>0?(0,q.jsxs)("section",{style:{...te,display:"grid",gap:10},children:[(0,q.jsx)("h2",{style:J,children:"Recently"}),(0,q.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:l.map(R=>(0,q.jsxs)("li",{style:C,children:[(0,q.jsx)("span",{style:{color:"var(--graview-ink)"},children:R.intent})," \u2014 ",ft(R,e,{graph:n.graph,schema:n.schema,...t.seats?{seats:t.seats}:{},...t.people?{people:t.people}:{}})]},R.id))})]}):null]})}var Me=W(Ie(),1);var et=W(j(),1);function Qt({context:t,withheld:e,style:n,testId:a}){let r=ce(),i=ba(e,t.signIn??r?.signIn);return i?(0,et.jsx)("p",{style:{...n,margin:0},children:(0,et.jsx)("button",{type:"button","data-testid":"sign-in",onClick:()=>i.run(),style:xe,children:i.label})}):e.length===0?null:(0,et.jsx)("ul",{style:{...n,margin:0,padding:0,listStyle:"none",display:"grid",gap:4},...a?{"data-testid":a}:{},children:e.map(o=>(0,et.jsxs)("li",{style:C,children:[(0,et.jsx)("s",{children:o.label})," \u2014 ",o.refusal.message]},o.id))})}var E=W(j(),1);function jn({context:t}){let{store:e,brand:n,principal:a,invariantContext:r}=t;ne(e);let[i]=ct(),o=i.get("q")??"",l=typeof r?.today=="string"?r.today:void 0,d=Cr(e,o,{...a?{principal:a}:{},places:Te(t),flagged:new Set(e.violations(r).flatMap(u=>u.nodeIds)),...l?{today:l}:{},limit:200}),c=d.hits.filter(u=>u.about==="node"),p=d.hits.filter(u=>u.about==="kind"||u.about==="place"||u.about==="rule"),m=[...new Set(c.map(u=>u.kind))],f=o.trim();return(0,E.jsxs)(ae,{context:t,children:[(0,E.jsx)("style",{children:Kt}),(0,E.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,E.jsx)("p",{style:ke,children:"Search"}),(0,E.jsx)(ie,{context:t,"data-testid":"search-heading",children:f.length===0?"Find anything by its name":d.hits.length===0?(0,E.jsxs)(E.Fragment,{children:["Nothing here is called \u201C",f,"\u201D."]}):(0,E.jsxs)(E.Fragment,{children:[wo(e,d.byKind)," for \u201C",f,"\u201D"]})}),f.length>0?(0,E.jsxs)("p",{style:{...C,margin:0},"data-testid":"search-searched",children:[Nt(e.schema,d.searched),d.conditions.filter(u=>u.key!=="is"&&u.admittedBy.length<d.searched.kinds.length).map(u=>(0,E.jsxs)("span",{children:[" ",u.key,":",u.value," narrows"," ",u.admittedBy.length===0?"nothing here":u.admittedBy.map(k=>Q(e,k).toLowerCase()).join(" and "),"."]},`${u.key}:${u.value}`))]}):(0,E.jsxs)("p",{style:re,children:["Type in the box above. Words find the start of words in names and in what each record says;"," ",(0,E.jsx)("code",{children:"done:false"})," and the like narrow as a list does, and ",(0,E.jsx)("code",{children:"is:any"})," includes what is past."]})]}),p.length>0?(0,E.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},"data-testid":"search-named",children:p.map(u=>(0,E.jsx)("li",{"data-testid":"search-hit","data-about":u.about,children:u.about==="kind"?(0,E.jsxs)(F,{to:`/${Y(e.schema,u.kind)}`,style:K,children:[u.label,u.count>0?(0,E.jsxs)("span",{style:C,children:[" \xB7 ",u.count," match"]}):null]}):u.about==="place"?(0,E.jsxs)(F,{to:ye(t,u),style:K,children:["Go to ",u.title]}):u.about==="rule"?(0,E.jsxs)(F,{to:"/problems",style:K,children:["The rule \u201C",u.label,"\u201D"]}):null},`${u.about}:${u.about==="rule"?u.name:u.about==="place"?u.as:u.kind}`))}):null,m.map(u=>(0,E.jsxs)("section",{className:"graview-list",style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",minWidth:0},"data-testid":"search-group","data-kind":u,children:[(0,E.jsxs)("h2",{className:"graview-group-head",style:{alignItems:"center"},children:[(0,E.jsx)(fe,{kind:u,brand:n,schema:e.schema,size:8}),(0,E.jsx)(F,{to:`/${Y(e.schema,u)}?${new URLSearchParams({q:f}).toString()}`,style:K,"data-testid":"search-kind-link",children:Q(e,u)}),(0,E.jsx)("span",{children:d.byKind[u]})]}),(0,E.jsx)("ul",{className:"graview-rows",children:c.filter(k=>k.kind===u).map(k=>(0,E.jsxs)("li",{"data-testid":"search-hit","data-about":"node",className:"graview-row",children:[(0,E.jsxs)(F,{to:Z(e.schema,u,k.id),className:"graview-row-title",...k.label.length>60?{title:k.label}:{},children:[k.flagged?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("span",{role:"img","aria-label":"Breaks a rule:",style:{color:"var(--graview-warn)"},children:"\u26A0"})," "]}):null,k.label]}),k.apart||!k.current?(0,E.jsx)("span",{className:"graview-row-glance",children:[k.apart,k.current?"":"past"].filter(Boolean).join(" \xB7 ")}):null,(0,E.jsx)(Zt,{why:k.why})]},k.id))})]},u)),f.length>0?(0,E.jsx)(bo,{asked:f}):null,f.length>0&&d.hits.length===0?(0,E.jsx)(Pi,{store:e,kinds:d.searched.kinds,words:d.words,...a?{principal:a}:{},...r?{invariantContext:r}:{}}):null]})}function Zt({why:t}){return t.strength==="near"?(0,E.jsxs)("span",{style:C,"data-testid":"search-why","data-near":"",children:["Near \u201C",t.asked,"\u201D",t.field==="label"?"":` \u2014 ${t.reading}: ${t.fragment}`]}):t.field==="label"?null:(0,E.jsxs)("span",{style:C,"data-testid":"search-why",children:[t.reading,": ",t.fragment]})}function wo(t,e){let n=Object.entries(e).map(([a,r])=>`${r} ${r===1?He(t.schema.tryDefinition(a),a):Q(t,a).toLowerCase()}`);return n.length===0?"Found":n.length===1?Re(n[0]):Re(`${n.slice(0,-1).join(", ")} and ${n[n.length-1]}`)}function xi(t,e,n={}){let a=[];for(let r of e){let i=Ye(t,r,{...n.principal?{principal:n.principal}:{},...n.invariantContext?{context:n.invariantContext}:{}});for(let o of Xt(t,r,i.actions.affordances))a.some(l=>l.mutation.name===o.mutation.name)||a.push(o)}return a}function Xt(t,e,n){let a=t.schema.tryDefinition(e)?.fieldRoles?.label,r=[];for(let i of n){let o=t.allMutations().find(c=>c.name===i.mutation);if(!o||!o.creates?.includes(e)||r.some(c=>c.mutation.name===o.name))continue;let l=Et(o.input).map(c=>c.name),d=l.includes("label")?"label":a&&l.includes(a)?a:void 0;!d||i.args[d]!==void 0||r.push({kind:e,affordance:i,mutation:o,arg:d})}return r}function Pi({store:t,kinds:e,words:n,principal:a,invariantContext:r}){let i=xi(t,e,{...a?{principal:a}:{},...r?{invariantContext:r}:{}});return i.length===0||n.trim().length===0?null:(0,E.jsx)("div",{style:{display:"grid",gap:24},"data-testid":"search-to-create",children:i.map(({kind:o,affordance:l,mutation:d,arg:c})=>(0,E.jsxs)("section",{style:{...te,display:"grid",gap:14},children:[(0,E.jsxs)("h2",{style:J,children:[Re(ua(He(t.schema.tryDefinition(o),o)))," called \u201C",n,"\u201D"]}),(0,E.jsx)(We,{store:t,mutation:d,prefilled:l.args,open:l.open,initial:{[c]:n},...a?{principal:a}:{}})]},`${l.id}|${n}`))})}function bo({asked:t}){let e=ce();return e?(0,E.jsx)(ko,{asked:t,desk:e.aiDesk}):null}function ko({asked:t,desk:e}){return Ka(e)?(0,E.jsx)("p",{style:{margin:0},children:(0,E.jsxs)("button",{type:"button","data-testid":"search-ask",onClick:a=>Ha(e,{pointed:{about:[]},asked:t,returnTo:a.currentTarget}),style:{...K,font:"inherit",padding:0,border:0,background:"transparent",cursor:"pointer",textAlign:"start"},children:["Ask: \u2018",t,"\u2019"]})}):null}var b=W(j(),1),Ci=8,Ri=40;function So(t,e){let n=e?.fields?.shape??{},a=Object.keys(n).find(r=>ma(n[r])&&ga(t[r]));return a===void 0?void 0:t[a]}function zn({context:t}){let e=Ue(),n=$e(t.store.schema,e.slug??"");return n?(0,b.jsx)(Li,{context:t,kind:n}):(0,b.jsx)(ae,{context:t,children:(0,b.jsx)(ie,{context:t,children:"No such kind of thing here."})})}function Li({context:t,kind:e,opening:n,row:a,layout:r="list",description:i,bare:o}){let{store:l,brand:d,invariantContext:c}=t;ne(l);let[p,m]=ct(),f=`list-${(0,Me.useId)().replace(/:/g,"")}`,u=l.schema.tryDefinition(e),k=ya(p.get("archived")),B=l.graph.nodesOfKind(e,{archived:k}),h=Qe(l).relations.filter(s=>s.from===e||s.to===e),R=new Set(l.violations(c).flatMap(s=>s.nodeIds)),G=xr(l.schema,Sr(l.schema,kr(l.schema,e))),M=h.map(s=>s.edgeKind),V=Lo(p,G,M),z=["sort","filter","group","q","by","with","past","archived",...M].some(s=>p.has(s)),se=B.length>=Ri,ue=u?.fieldRoles?.when,I=t.views?.arrangement?.()?.lists?.[e],_=yr(I),oe=fr(I?.group),we=Ro(se,ue),le=n??(_?{...we,..._}:we),ge=z?V.arrangement:Rn(le,G).arrangement,w=_?.sort,y=ge.sort&&w?.then&&ge.sort.by===w.by&&ge.sort.direction===w.direction?{...ge,sort:w}:ge,L=Pr(y.query??""),$=[...y.filter??[],...L.conditions].some(s=>s.key==="is"&&(s.value==="past"||s.value==="any"))||br(u,[...y.filter??[],...L.conditions]),g=$||!u?.lifecycle?y:{...y,filter:[...y.filter??[],{key:"is",value:"current"}]},A=new Map,O=$t(B,g,{schema:l.schema,graph:l.graph,flagged:R,...typeof c?.today=="string"?{today:c.today}:{},read:(s,v)=>{let N=A.get(s.id);return N||A.set(s.id,N=mt(l.schema,l.graph,s)),N[v]}}),ee=oe&&y.group?.by===oe.by&&!y.group.bucket?G.groups.find(s=>s.key===oe.by):void 0,De=oe&&ee&&(ee.type==="choice"||ee.type==="boolean")?hr(O.groups,oe,{type:ee.type,...ee.options?{options:ee.options}:{}}):O.groups.map(s=>({...s,closed:!1})),Ee=new Set((p.get("open")??"").split(",").filter(Boolean)),Oi=!!y.query||(y.filter??[]).some(s=>s.key===oe?.by),Zn=s=>ee?.type==="boolean"?s==="1"?"true":"false":s,Xn=s=>s.closed&&!Oi&&!Ee.has(Zn(s.key)),Fi=s=>{let v=new URLSearchParams(p),N=new Set(Ee);N.has(s)?N.delete(s):N.add(s),N.size>0?v.set("open",[...N].join(",")):v.delete("open"),m(v,{replace:!0})},Ce=O.nodes,nt=u?.lifecycle&&!$?B.filter(s=>it(u,s)):B,Jn=B.length-nt.length,tn=y.group?.by??null,Ii=s=>{let v=new URLSearchParams(p);for(let de of["sort","filter","group","q","by","with","past","archived",...h.map(St=>St.edgeKind)])v.delete(de);let N=Rr(s);for(let de of["sort","filter","group","q","archived"])N[de]&&v.set(de,N[de]);![...v.keys()].some(de=>["sort","filter","group","q"].includes(de))&&(n||_||se||ue)&&v.set("sort",""),m(v)},{principal:at}=t,nn=Ye(l,e,{...at?{principal:at}:{},...t.invariantContext?{context:t.invariantContext}:{}}),Be=nn.actions.affordances.map(s=>({affordance:s,mutation:l.allMutations().find(v=>v.name===s.mutation)})).filter(s=>s.mutation!==void 0),Wi=nn.actions.withheld,an=()=>new Set(Ce.length===0?Be.map(({mutation:s})=>s.name):[]),[rn,ea]=(0,Me.useState)(()=>({kind:e,open:an()}));rn.kind!==e&&ea({kind:e,open:an()});let ta=s=>(rn.kind===e?rn.open:an()).has(s),na=(s,v)=>ea(N=>{let de=new Set(N.open);return v?de.add(s):de.delete(s),{kind:N.kind,open:de}}),aa=`begin-${(0,Me.useId)().replace(/:/g,"")}`,ra=L.words&&Ce.length===0?Object.fromEntries(Xt(l,e,nn.actions.affordances).map(s=>[s.mutation.name,s.arg])):{},ze=Q(l,e),vt=t.views?.lookup(e,{cardinality:"one",fidelity:"glyph"}),on=vt!==void 0&&!st(vt)?vt:void 0,sn=(y.group?.bucket??"day")==="day"?y.group?.by:void 0,ln=(y.filter??[]).map(s=>s.key),Di=ln.filter(s=>ln.indexOf(s)===ln.lastIndexOf(s)&&/choice|boolean/.test(G.filters.find(v=>v.key===s)?.type??"")),dn=s=>{let v={...u?.computed?mt(l.schema,l.graph,s):s};sn&&!String(v[sn]).includes("T")&&delete v[sn];for(let N of Di)delete v[N];return v},wt=s=>{let v=me(u,s);if(a)return(0,b.jsxs)("li",{"data-testid":"record-row","data-graview-record":s.id,style:{minWidth:0},...fn(s.id),children:[mn(s,v),a(s,{label:v,href:Z(l.schema,e,s.id),flagged:R.has(s.id),glance:qt(dn(s),u,v)})]},s.id);if(on){let yn=Wt(vt,s,l.graph),Vi=Object.fromEntries(Object.entries(dn(s)).filter(([Ui])=>!yn?.fields.has(Ui))),da=yn?qt(Vi,u,yn.title??v):"";return(0,b.jsxs)("li",{"data-testid":"record-row","data-graview-record":s.id,style:{position:"relative",display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:16,rowGap:2,paddingBlock:10,borderTop:"1px solid var(--graview-edge)"},...fn(s.id),children:[mn(s,v),(0,b.jsx)("div",{style:{flex:"1 1 14rem",minWidth:0},children:(0,b.jsx)(on,{node:s,cardinality:"one",fidelity:"glyph",mode:"fullscreen",selected:!1,...R.has(s.id)?{flagged:[s.id]}:{}})}),da?(0,b.jsx)("span",{style:{...C,flex:"0 1 auto",minWidth:0,overflowWrap:"anywhere"},"data-testid":"record-glance",children:da}):null,(0,b.jsx)(Eo,{to:Z(l.schema,e,s.id),label:R.has(s.id)?`${v} \u2014 implicated in a problem`:v})]},s.id)}let N=qt(dn(s),u,v),de=L.words?Ar(u,s,L.words):void 0,St=se?void 0:nr(s,u),xt=So(s,u),la=(0,b.jsxs)(F,{to:Z(l.schema,e,s.id),className:"graview-row-title",...v.length>60?{title:v}:{},children:[R.has(s.id)?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{role:"img","aria-label":"Breaks a rule:",style:{color:"var(--graview-warn)"},children:"\u26A0"})," "]}):null,v]});return(0,b.jsxs)("li",{className:"graview-row","data-graview-record":s.id,...fn(s.id),children:[mn(s,v),St?(0,b.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:14,minWidth:0},children:[(0,b.jsx)(Ge,{as:"thumb",file:St}),la]}):la,N||xt?(0,b.jsxs)("span",{className:"graview-row-glance",children:[N,N&&xt?" \xB7 ":null,xt?(0,b.jsx)(Ot,{address:xt}):null]}):null,de?(0,b.jsx)(Zt,{why:de}):null]},s.id)},cn=Te(t).filter(s=>s.kind===e),ia=I?.filters,Hi=(y.filter??[]).some(s=>s.key!=="is"||s.value!=="any"),Ki=!!(y.sort||y.group||y.query||Hi),qi=nt.length>=Ci||z&&Ki,Oe=y.sort?G.sorts.find(s=>s.key===y.sort.by):void 0,pn=Oe?.type==="date"||Oe!==void 0&&Oe.key===ue,oa=se&&!O.grouped&&Oe&&(Oe.about==="label"||Oe.type==="text"||pn)?s=>{let v=Oe.about==="label"?me(u,s):s[Oe.key];if(typeof v!="string"||v.length===0)return pn?"No date":"#";if(pn)return v.slice(0,4);let N=v.trim().charAt(0).toLocaleUpperCase();return/\p{L}/u.test(N)?N:"#"}:void 0,_e=oa?Ce.reduce((s,v)=>{let N=oa(v);return s.at(-1)?.key===N?s.at(-1).nodes.push(v):s.push({key:N,nodes:[v]}),s},[]):void 0,sa=O.grouped&&tn?De.flatMap(s=>Xn(s)?[]:s.nodes):_e&&_e.length>1?_e.flatMap(s=>s.nodes):Ce,un=(0,Me.useMemo)(()=>sa.map(s=>s.id),[sa.map(s=>s.id).join(`
108
+ `;function qn({context:t}){ne(t.store);let e=Hn(t);return e.length===0?null:(0,T.jsxs)("section",{style:ui,"data-testid":"gallery",children:[(0,T.jsx)("style",{children:ro}),e.map(n=>(0,T.jsx)(Kn,{context:t,entry:n},n.key))]})}function Bn({context:t}){let{store:e}=t;ne(e);let n=vn(Te(t)).filter(r=>!r.hidden),a=Hn(t);return(0,T.jsxs)(ae,{context:t,style:dt,children:[(0,T.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,T.jsx)("p",{style:ke,children:n.length===0?"None of its own yet":`${n.length} ${n.length===1?"picture":"pictures"}`}),(0,T.jsx)(ie,{context:t,children:"Pictures"}),(0,T.jsx)("p",{style:re,children:n.length===0?"Nothing here has a picture of its own yet, so each kind is drawn as the scene draws it. Title a group view and it appears here by name.":"The ways this installation looks at what it holds \u2014 each one the same picture the scene shows, here as a page."})]}),a.length>0?(0,T.jsx)("div",{style:ui,"data-testid":"places",children:a.map(r=>(0,T.jsx)(Kn,{context:t,entry:r},r.key))}):null]})}function Gn({context:t}){let{store:e,principal:n}=t;ne(e);let a=Ue(),r=Ke(),[i]=ct(),o=decodeURIComponent(a.as??""),[l,d]=(0,qe.useState)(null),c=i.get("of"),p=i.get("filter"),f=Te(t).find(M=>M.as===o&&(!c||Y(e.schema,M.kind)===c));if(!f)return(0,T.jsxs)(ae,{context:t,children:[(0,T.jsx)(ie,{context:t,children:"No picture is called that."}),(0,T.jsx)("p",{style:re,children:(0,T.jsxs)(F,{to:"/places",style:K,children:["The pictures there are ",(0,T.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]})})]});let u=Q(e,f.kind),k=t.views?.resolve(f.kind,{cardinality:"many",fidelity:"full"},f.as)?.view,B=k?.flows===!0,h=k?.creates!==!1,R=Ye(e,f.kind,{...n?{principal:n}:{},...t.invariantContext?{context:t.invariantContext}:{}}),G=h?R.actions.affordances.map(M=>({affordance:M,mutation:e.allMutations().find(V=>V.name===M.mutation)})).filter(M=>M.mutation!==void 0):[];return(0,T.jsxs)(ae,{context:t,style:dt,children:[(0,T.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,T.jsx)(ie,{context:t,children:f.title}),(0,T.jsxs)("p",{style:re,"data-testid":"place-lede",children:[Wn(e,zt(t,f),f.across),"."]}),p&&!B?(0,T.jsxs)("p",{style:{...C,margin:0},"data-testid":"place-narrowed",children:[`Only those where ${p.split(",").map(M=>M.replace(":"," is ")).join(" and ")}. `,(0,T.jsx)(F,{to:`?${(()=>{let M=new URLSearchParams(i);return M.delete("filter"),M.toString()})()}`,style:{...K,...C},children:"Show all"})]}):null,(0,T.jsx)("p",{style:{...C,margin:0,display:"flex",flexWrap:"wrap",gap:"4px 16px"},children:zt(t,f).map((M,V)=>(0,T.jsxs)(F,{to:`/${Y(e.schema,M)}`,style:{...K,...C},...V===0?{"data-testid":"place-as-list"}:{},children:["All ",(M===f.kind?u:Q(e,M)).toLowerCase()," as a list ",(0,T.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]},M))})]}),(0,T.jsx)("div",{"data-testid":"place-lens","data-flows":B?"":void 0,style:B?{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",maxWidth:"100%"}:{height:"min(72vh, 760px)",display:"grid",gridTemplateRows:"minmax(0, 1fr)",overflow:"auto",maxWidth:"100%",borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)"},onClick:M=>{let V=M.target?.closest("[data-graview-pick]"),z=V?.getAttribute("data-graview-pick"),se=V?.getAttribute("data-graview-joins");if(se)try{let I=JSON.parse(se);if(Array.isArray(I)&&I.every(_=>typeof _=="string")){M.preventDefault(),d({at:Xe(f),ids:I});return}}catch{}if(!z)return;let ue=e.graph.getNode(z);ue&&(M.preventDefault(),r(Z(e.schema,ue.kind,z)))},children:(0,T.jsx)(Dn,{context:t,place:f,filter:p,...l?.at===Xe(f)?{chosen:l.ids}:{}})}),G.length>0?(0,T.jsx)("div",{style:{maxWidth:760,display:"grid",gap:40},"data-testid":"place-creators",children:G.map(({affordance:M,mutation:V})=>(0,T.jsxs)("section",{style:{...te,display:"grid",gap:14},children:[(0,T.jsx)("h2",{style:J,children:V.title??V.name}),V.description?(0,T.jsx)("p",{style:{...C,margin:0,maxWidth:"58ch"},children:V.description}):null,(0,T.jsx)(We,{store:e,mutation:V,prefilled:M.args,open:M.open,label:M.label,...n?{principal:n}:{}})]},M.id))}):null]})}function io(t,e=document){let n=Dt(t);if(!n)return null;let a=[e,...[...e.querySelectorAll("[data-worker-view]")].flatMap(r=>r.shadowRoot?[r.shadowRoot]:[])];for(let r of a)for(let i of r.querySelectorAll("[id], [data-section]")){let o=i.getAttribute("data-section")??i.id;if(o===t||Dt(o)===n)return i}for(let r of a)for(let i of r.querySelectorAll("h1, h2, h3, h4, h5, h6, [role=heading]"))if(Dt(i.textContent??"")===n)return i;return null}function gi(t,e={}){if(typeof document>"u"||typeof requestAnimationFrame>"u")return()=>{};let n=e.frames??120,a=0,r=()=>{let i=io(t,e.root??document);if(i){i.hasAttribute("tabindex")||i.setAttribute("tabindex","-1"),i.scrollIntoView?.({block:"start"}),i.focus({preventScroll:!0});return}n-=1,n>0&&(a=requestAnimationFrame(r))};return a=requestAnimationFrame(()=>{a=requestAnimationFrame(r)}),()=>cancelAnimationFrame(a)}var U=W(Ie(),1);var _t=W(Ie(),1);var Je=W(j(),1);function mi({context:t}){return ce()?(0,Je.jsxs)(Je.Fragment,{children:[(0,Je.jsx)(oo,{context:t}),(0,Je.jsx)(Br,{face:"pages",on:t.quickAsk??!0})]}):null}function oo({context:t}){let{store:e}=t,n=ce(),{pathname:a}=Pe(),r=(0,_t.useRef)(n?.setSelection);return r.current=n?.setSelection,(0,_t.useEffect)(()=>{let i=r.current;if(!i)return;let[,o,l]=a.split("/"),d=(()=>{if(o==="places"){let p=t.views?.places().find(m=>m.as===decodeURIComponent(l??""));return p?[Fe(p.kind)]:[]}let c=o?$e(e.schema,o):void 0;return c&&l?[decodeURIComponent(l)]:c?[Ra(c)]:[]})();i(c=>c.length===d.length&&c.every((p,m)=>p===d[m])?c:d)},[a]),null}var he=W(Ie(),1);var yi=W(ji(),1);var pe=W(j(),1);var so=(0,he.lazy)(Rt(Ca(()=>(__graviewPreload(import.meta.url,["./chunk.JYJ4LZJJ.js","./chunk.UGFDSE37.js","./chunk.USZPOOLZ.js","./chunk.C4TSM4W5.js","./chunk.XEKLEHC3.js","./chunk.53CDFJNM.js","./chunk.4QPVS2ZM.js","./chunk.RCM7NOPF.js","./chunk.Z7LDT55A.js","./chunk.BQRAIU5R.js","./chunk.57R2GXXN.js","./chunk.BFNVG5JE.js","./chunk.AIZQBPGU.js","./chunk.V3V47QRE.js","./chunk.5P556A7W.js","./chunk.QHYXXZRD.js","./chunk.BELCPW66.js","./chunk.6YPLZNVT.js","./chunk.5RABSIF7.js","./chunk.NGDXH66B.js","./chunk.67WWRC6Y.js","./chunk.MB7LKKUD.js","./chunk.WVUJXDXZ.js","./chunk.N6MVK3KD.js","./chunk.I7XSDXQ3.js","./chunk.UHI3D7JC.js","./chunk.WVDKYUF3.js","./chunk.ZHLQWMV5.js","./chunk.TNESS3LQ.js","./chunk.GZHZLJBF.js","./chunk.42XSBKPO.js","./chunk.OJGHDWI6.js","./chunk.6FNMDAX5.js","./chunk.2FLPDPEL.js","./chunk.UUBYFBPN.js","./chunk.2RVUDRRY.js","./chunk.JHEVGLKB.js","./chunk.FOQZADMA.js","./chunk.SDO3U72B.js","./chunk.V5MYKNL7.js","./chunk.AJZBJBMO.js"]),import("./chunk.Z7BCIYDW.js")).then(t=>({default:t.TakeBack})))));function lo({context:t,docked:e,at:n}){let{store:a}=t,r=ne(a),[i]=(0,he.useState)(()=>a.batches().length),o=(0,he.useRef)(!1);return o.current||=r>0||!e&&i>0,o.current?(0,pe.jsx)(he.Suspense,{fallback:null,children:(0,pe.jsx)(so,{context:t,docked:e,at:n,since:i})}):null}function co(t,e,n){let{store:a,principal:r,embedded:i}=t;(0,he.useEffect)(()=>{if(!n)return;let o=l=>{if(!Yr(l))return;let d=l.target,c=d instanceof Node&&e.current?.contains(d),p=d===document.body||d===document.documentElement||d===document;if(!(!c&&!(p&&!i))&&zr(a,r)){l.preventDefault();try{_r(a,r)}catch{}}};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[a,r,i,e,n])}function hi({context:t,registry:e,root:n,children:a}){let r=(0,he.useMemo)(ii,[]),i=e?.without()??new Set;return co(t,n,!i.has("undo")),(0,pe.jsxs)(On.Provider,{value:r,children:[(0,pe.jsx)(po,{context:t,placed:r,without:i}),a]})}function po({context:t,placed:e,without:n}){let[a,r]=(0,he.useState)(!1);(0,he.useLayoutEffect)(()=>r(!0),[]);let i=Fn(e,"find"),o=Fn(e,"undo"),l=Pe(),d=wr();if(!a)return null;let c=l.pathname.split("/").filter(Boolean),m=(c.length===1?$e(t.store.schema,c[0]):void 0)!==void 0;return(0,pe.jsxs)(pe.Fragment,{children:[!i&&!n.has("find")&&d?(0,yi.createPortal)((0,pe.jsx)(fi,{context:t,narrowsLists:m}),d.slot):null,!i&&!n.has("find")&&!d?(0,pe.jsx)("div",{"data-testid":"face-find-bar",style:{display:"flex",alignItems:"center",padding:"8px 16px",borderBottom:"1px solid var(--graview-edge)",background:"var(--graview-bar)",minWidth:0},children:(0,pe.jsx)(fi,{context:t,narrowsLists:m})}):null,!o&&!n.has("undo")?(0,pe.jsx)(lo,{context:t,docked:!0,at:l.pathname+l.search}):null,d?.own&&!n.has("undo")?(0,pe.jsx)(ti,{context:t,own:d.own}):null]})}function fi({context:t,narrowsLists:e}){return(0,pe.jsx)(On.Provider,{value:null,children:(0,pe.jsx)(In,{context:t,narrowsLists:e})})}var X=W(Ie(),1);var Ae=W(j(),1),uo=500,go=10;function Yt(t){return t instanceof HTMLElement?t.isContentEditable||t.tagName==="TEXTAREA"||t.tagName==="SELECT"?!0:t.tagName==="INPUT"&&!["button","submit","reset","checkbox","radio","image","file","color","range"].includes(t.type):!1}function mo(t){let e=typeof getSelection=="function"?getSelection():null;return e!==null&&!e.isCollapsed&&e.containsNode(t,!0)}function vi(t){let e=t.closest('a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])');if(e)return e;let n=document.activeElement;return n instanceof HTMLElement&&n!==document.body?n:null}function wi({context:t,root:e,children:n}){return ce()===null?(0,Ae.jsx)(Ae.Fragment,{children:n}):(0,Ae.jsx)(fo,{context:t,root:e,children:n})}function fo({context:t,root:e,children:n}){let{setMenuAt:a}=$a(),{store:r}=t,i=r.schema,o=Ke(),{pathname:l,search:d}=Pe(),c=Vt("/").replace(/\/$/,""),p=(0,X.useCallback)((w,y)=>t.views?.places().find(L=>L.as===w&&(y===null||L.kind===y)),[t.views]),m=(0,X.useCallback)((w,y)=>{let[L="",$,g]=w.split("/").filter(Boolean).map(O=>{try{return decodeURIComponent(O)}catch{return O}});if(g!==void 0)return null;if(L==="places"&&$!==void 0){let O=p($,new URLSearchParams(y).get("of"));return O?{face:"pages",place:O.as,about:[Fe(O.kind)],title:O.title}:null}let A=$e(i,L);return A?$===void 0?{face:"pages",about:[Fe(A)],title:ot(i,A)}:r.graph.getNode($)?{face:"pages",on:$,about:[$]}:null:null},[i,r,p]),f=(0,X.useCallback)(w=>{let y=w.href;try{let L=new URL(y,location.href);if(L.origin===location.origin&&(c===""||L.pathname===c||L.pathname.startsWith(`${c}/`))){let $=m(L.pathname.slice(c.length),L.search);if($)return{...$,href:y}}}catch{}return{face:"pages",about:[],href:y}},[c,m]),u=(0,X.useCallback)(()=>m(l,d)??{face:"pages",about:[]},[m,l,d]),k=(0,X.useCallback)(w=>{let y=u(),L=w.closest("[data-graview-field]")?.getAttribute("data-graview-field");if(L&&y.on!==void 0&&w.closest("[data-graview-pick], a[href]")===null)return{...y,field:L};let $=w.closest("[data-graview-act]")?.getAttribute("data-graview-act");if($)return{...y,act:$};let g=w.closest("a[href]"),A=w.closest("[data-graview-listed]"),O=[w.closest("[data-graview-pick]")?.getAttribute("data-graview-pick"),A&&(!g||A.contains(g)&&g.classList.contains("graview-spec-item-link"))?A.getAttribute("data-graview-listed"):null].map(De=>De?r.graph.getNode(De):void 0).find(Boolean);if(O)return{face:"pages",on:O.id,about:[O.id],href:`${c}${Z(i,O.kind,O.id)}`};if(g)return f(g);let ee=w.closest("[data-graview-record]")?.getAttribute("data-graview-record");return ee&&r.graph.getNode(ee)?{face:"pages",on:ee,about:[ee]}:y},[u,f,r,i,c]),B=(0,X.useCallback)(w=>{let y=e.current;if(y===null||!y.contains(w)||Yt(w)||w.closest("[data-graview-popover]"))return null;let L=k(w);return{face:"pages",on:L.on,about:L.about??[],field:L.field,place:L.place,href:L.href,act:L.act,element:vi(w)}},[k,e]),h=(0,X.useCallback)((w,y,L)=>{let $=k(w);a({...$,x:Math.round(y),y:Math.round(L),returnTo:vi(w)})},[k,a]),R=(0,X.useCallback)(w=>{let y=w.getBoundingClientRect();h(w,y.left+Math.min(16,y.width/2),Math.min(y.bottom,y.top+36))},[h]),G=(0,X.useRef)(0),M=(0,X.useRef)(null),V=(0,X.useRef)(!1),z=()=>{M.current&&clearTimeout(M.current.timer),M.current=null};(0,X.useEffect)(()=>z,[]),(0,X.useEffect)(()=>{let w=y=>{if(y.defaultPrevented||!(y.key==="ContextMenu"||y.key==="F10"&&y.shiftKey))return;let L=e.current,$=y.target instanceof Element?y.target:null,g=$===null||$===document.body||$===document.documentElement,A=L!==null&&$!==null&&L.contains($);if(!A&&!(g&&document.querySelector("[data-graview-face='pages']")===L)||Yt($)||$?.closest("[data-graview-popover]"))return;y.preventDefault(),G.current=Date.now();let O=A&&$ instanceof HTMLElement?$:L?.querySelector("[data-graview-page-title], main h1, main")??null;O&&R(O)};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[e,R]),(0,X.useEffect)(()=>{let w=e.current;if(!w)return;let y=L=>{let $=L.detail;$&&a({...$,face:"pages"})};return w.addEventListener(bn,y),()=>w.removeEventListener(bn,y)},[e,a]);let se=(0,X.useMemo)(()=>w=>{if(w.face!=="pages")return null;let y=[],L=w.on===void 0?void 0:r.graph.getNode(w.on),$=w.place===void 0?void 0:t.views?.places().find(Ee=>Ee.as===w.place),g=L?void 0:w.about.length===1&&w.about[0].startsWith("aggregate:")&&!$?yo(w.about[0]):void 0,A=L?Z(i,L.kind,L.id):$?ye(t,$):g?`/${Y(i,g)}`:void 0,O=A!==void 0&&l===A.split("?")[0];A!==void 0&&!O&&y.push({id:"open",label:"Open",run:()=>o(A)});let ee=A!==void 0?`${c}${A}`:w.href;ee!==void 0&&y.push({id:"open-in-a-new-tab",label:"Open in a new tab",run:()=>void window.open(ee,"_blank","noopener")});let De=L?`#focus=${encodeURIComponent(L.id)}`:$?`#focus=${encodeURIComponent(Fe($.kind))}&view=${encodeURIComponent($.as)}`:g?`#focus=${encodeURIComponent(Fe(g))}`:void 0;if(De!==void 0&&(t.overview||!t.embedded)){let Ee=t.overview;y.push({id:"in-the-scene",label:"Show in the scene",run:()=>Ee?Ee(De):location.assign(`${t.sceneHref??"/"}${De}`)})}return L===void 0&&w.href===void 0&&y.push({id:"find",label:"Find\u2026",run:()=>{let Ee=e.current?.querySelector('[data-testid="nav-find"]')??document.querySelector('[data-testid="nav-find"]');Ee&&Ee.offsetParent!==null?Ee.focus():o("/search")}}),y.length>0?{id:"pages",items:y}:null},[r,i,t,l,c,o,e]),ue=(0,X.useMemo)(()=>w=>{if(w.face!=="pages"||w.field===void 0||w.on===void 0)return null;let y=r.graph.getNode(w.on),L=w.element?.closest("[data-graview-field]")??e.current?.querySelector(`[data-graview-field="${CSS.escape(w.field)}"]`);return!y||!(L instanceof HTMLElement)||!L.hasAttribute("data-graview-editable")?null:{id:"field",at:"start",items:[{id:"change-field",label:`Change \u201C${pa(i.tryDefinition(y.kind),w.field)}\u201D`,run:()=>L.click()}]}},[r,i,e]),I=Vr(),_=dr(),oe=Er(),we=(0,X.useCallback)((w,y)=>{l===ye(t,w).split("?")[0]&&o(y?ye(t,y):"/")},[l,t,o]),le=jr(we),ge=(0,X.useMemo)(()=>[ue,oe,se,...le?[le]:[],..._?[_]:[],...I?[I]:[]],[ue,oe,se,le,_,I]);return(0,Ae.jsxs)(ar,{sections:ge,children:[(0,Ae.jsx)("div",{"data-graview-menu-ground":"",style:{display:"contents"},onContextMenu:w=>{let y=w.target;w.shiftKey||Yt(y)||mo(y)||(w.preventDefault(),!y.closest("[data-graview-popover]")&&(Date.now()-G.current<700||(w.clientX===0&&w.clientY===0&&y instanceof HTMLElement?R(y):h(y,w.clientX,w.clientY))))},onPointerDown:w=>{if(V.current=!1,w.pointerType==="mouse"||!w.isPrimary)return;let y=w.target;if(Yt(y)||y.closest("[data-graview-choose], [data-graview-popover]"))return;z();let{clientX:L,clientY:$}=w;M.current={x:L,y:$,timer:setTimeout(()=>{M.current=null,V.current=!0,G.current=Date.now(),h(y,L,$)},uo)}},onPointerMove:w=>{let y=M.current;y&&Math.hypot(w.clientX-y.x,w.clientY-y.y)>go&&z()},onPointerUp:z,onPointerCancel:z,onClickCapture:w=>{V.current&&(V.current=!1,w.preventDefault(),w.stopPropagation())},children:n}),(0,Ae.jsx)(ho,{openAt:R,readyAt:B}),(0,Ae.jsx)(Ur,{placement:"page"}),(0,Ae.jsx)(cr,{})]})}function yo(t){let e=t.slice(10).split("+");return e.length===1&&e[0]?e[0]:void 0}function ho({openAt:t,readyAt:e}){return(0,Ae.jsx)("span",{"data-graview-menu-home":"",tabIndex:-1,onFocus:n=>{if(n.target!==n.currentTarget)return;let a=n.currentTarget.closest("[data-graview-face]"),r=a?.querySelector("[data-graview-page-title]")??a?.querySelector("main h1, main")??null;r&&(r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),r.focus({preventScroll:!0}))},style:{position:"absolute",width:0,height:0,overflow:"hidden"},children:(0,Ae.jsx)(qr,{placement:"menu",openActs:t,aimAt:e})})}var H=W(j(),1);function bi(t,e){return e==="*"?{label:"anything",path:null}:{label:Q(t,e),path:`/${Y(t.schema,e)}`}}function vo({context:t,relation:e}){let{store:n}=t,a=bi(n,e.from),r=bi(n,e.to),i=o=>o.path?(0,H.jsx)(F,{to:o.path,style:{...Se,fontWeight:550},children:o.label}):(0,H.jsx)("span",{children:o.label});return(0,H.jsxs)("li",{"data-testid":"relation","data-relation":e.edgeKind,style:{display:"grid",gridTemplateColumns:"30px minmax(0, 1fr) auto",gap:12,alignItems:"baseline"},children:[(0,H.jsx)(Gr,{edgeKind:e.edgeKind,...t.brand?.kit?{kit:t.brand.kit}:{}}),(0,H.jsxs)("span",{style:{display:"grid",gap:1},children:[(0,H.jsxs)("span",{children:[i(a)," ",(0,H.jsxs)("span",{style:C,"data-graview-speaks-ids":"",children:[be(e.edgeKind)," \u2192"]})," ",i(r)]}),e.description||e.inverse?(0,H.jsxs)("span",{style:C,children:[e.description?Re(e.description):null,e.description&&e.inverse?" \xB7 ":null,e.inverse?`from the other end, ${e.inverse}`:null]}):null]}),r.path?(0,H.jsx)(F,{to:`${r.path}?with=${encodeURIComponent(e.edgeKind)}`,style:{...K,...C,fontVariantNumeric:"tabular-nums",display:"inline-block",minWidth:24,minHeight:24,textAlign:"center"},title:`The ${r.label.toLowerCase()} that have this`,children:e.count}):(0,H.jsx)("span",{style:{...C,fontVariantNumeric:"tabular-nums"},children:e.count})]})}function ki({context:t,heading:e=!0}){let{store:n}=t,a=new Set(Ve(n,t.principal)),r=Qe(n).relations.filter(i=>a.has(i.from)&&(i.to==="*"||a.has(i.to)));return r.length===0?null:(0,H.jsxs)("section",{style:{...te,display:"grid",gap:12},"data-testid":"kind-map",children:[e?(0,H.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,H.jsx)("h2",{style:J,children:(0,H.jsx)(F,{to:"/map",style:Se,children:"Connections"})}),(0,H.jsx)("span",{style:C,children:r.length===1?"1 relation":`${r.length} relations`})]}):null,(0,H.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:r.map(i=>(0,H.jsx)(vo,{context:t,relation:i},`${i.edgeKind}|${i.from}|${i.to}`))})]})}function Vn({context:t}){let{store:e}=t;ne(e);let n=new Set(Ve(e,t.principal)),a=Qe(e),r=a.relations.filter(i=>n.has(i.from));return(0,H.jsxs)(ae,{context:t,children:[(0,H.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,H.jsx)("p",{style:ke,children:r.length===0?"No relations":`${r.length} ${r.length===1?"relation":"relations"}`}),(0,H.jsx)(ie,{context:t,children:"Connections"}),(0,H.jsx)("p",{style:re,children:r.length===0?"Nothing here is declared to relate to anything else yet.":"The kinds this installation holds, and the relations declared between them \u2014 each in the declaration's own words, with how many of it there are."})]}),(0,H.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"6px 18px"},"data-testid":"map-kinds",children:a.kinds.filter(i=>n.has(i.kind)).map(i=>(0,H.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,H.jsx)(fe,{kind:i.kind,brand:t.brand,schema:e.schema,size:7}),(0,H.jsx)(F,{to:`/${Y(e.schema,i.kind)}`,style:K,children:i.plural}),(0,H.jsx)("span",{style:C,children:i.count})]},i.kind))}),(0,H.jsx)(ki,{context:t,heading:!1})]})}function Si({context:t}){let n=[...ce()?.robots.values()??[]].filter(r=>r.mode==="asking"&&r.say);if(n.length===0)return null;let{store:a}=t;return(0,H.jsxs)("section",{style:{...te,display:"grid",gap:10},"data-testid":"seat-questions",children:[(0,H.jsx)("h2",{style:J,children:n.length===1?"The seat asked something":`The seat asked ${n.length} things`}),(0,H.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8},children:n.map(r=>{let i=r.at?a.graph.getNode(r.at):void 0;return(0,H.jsxs)("li",{style:{display:"grid",gap:2},children:[(0,H.jsx)("span",{children:r.say}),i?(0,H.jsxs)(F,{to:Z(a.schema,i.kind,i.id),style:{...K,...C},children:[me(a.schema.tryDefinition(i.kind),i)," \u2192"]}):null]},r.participant)})})]})}var q=W(j(),1);function Un({context:t}){let{principal:e}=t,{store:n,brand:a,invariantContext:r}=t;ne(n);let i=n.violations(r),o=`${i.length===1?"A rule is broken":"Rules are broken"} \u2014 see what, and what would fix it`,l=[...n.log.all()].slice(-5).reverse(),c=Bt(t).map(R=>({kind:R,members:n.graph.nodesOfKind(R).filter(G=>it(n.schema.tryDefinition(R),G))})),p=c.filter(R=>R.members.length>0),m=c.map(R=>({entry:R,creator:n.allMutations().find(G=>(G.creates??[]).includes(R.kind)&&n.permits({name:G.name,args:{}},t.principal).ok)})).find(R=>R.creator!==void 0),f=p.length===0?"Nothing here yet.":`${p.map(R=>Pt(n.schema,R.kind,R.members.length)).join(", ").replace(/, ([^,]*)$/," and $1")}.`,u=t.views?.homeView?.(),k=n.schema.kinds.some(R=>n.graph.nodesOfKind(R).length>0);if(u&&k){let R=a?.subtitle?(0,q.jsx)("p",{style:{...C,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,G=u[Symbol.for("graview.home-blocks")]===!0;return(0,q.jsx)(ae,{context:t,style:dt,children:(0,q.jsxs)("div",{style:{display:"grid",gap:12},"data-testid":"home-view",children:[G?null:R,i.length>0?(0,q.jsx)(F,{to:"/problems",style:{...K,color:"var(--graview-warn)"},children:o}):null,(0,q.jsx)(Dr.Provider,{value:G?R:null,children:(0,q.jsx)(u,{cardinality:"many",fidelity:"full",mode:"fullscreen",selected:!1})})]})})}let B=new Set(Ve(n,t.principal)),h=Qe(n).relations.filter(R=>B.has(R.from)&&(R.to==="*"||B.has(R.to)));return(0,q.jsxs)(ae,{context:t,style:dt,children:[(0,q.jsxs)("header",{style:{display:"grid",gap:12},children:[a?.subtitle?(0,q.jsx)("p",{style:{...C,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,(0,q.jsx)(ie,{context:t,"data-testid":"standing",children:f}),(0,q.jsxs)("p",{style:{...re,display:"grid",gap:4},"data-testid":"standing-card",children:[p.length===0&&m?(0,q.jsxs)("span",{children:["Begin with \u201C",m.creator?.title??m.creator?.name,"\u201D, under"," ",(0,q.jsx)(F,{to:`/${Y(n.schema,m.entry.kind)}`,style:K,children:Q(n,m.entry.kind)}),"."]}):null,i.length===0?(0,q.jsx)("span",{children:"All rules hold."}):(0,q.jsx)(F,{to:"/problems",style:{...K,color:"var(--graview-warn)"},children:o})]})]}),(0,q.jsx)(qn,{context:t}),(0,q.jsxs)("section",{style:{...te,display:"grid",gap:14},"data-testid":"kinds",children:[(0,q.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,q.jsx)("h2",{style:J,children:"What is here"}),h.length>0?(0,q.jsxs)(F,{to:"/map",style:{...K,...C,marginLeft:"auto"},"data-testid":"map-link",children:["Connections \xB7 ",h.length===1?"1 relation":`${h.length} relations`," ",(0,q.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]}):null]}),(0,q.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"8px 10px"},children:c.map(({kind:R,members:G})=>(0,q.jsx)("li",{style:{maxWidth:"100%"},children:(0,q.jsxs)(F,{to:`/${Y(n.schema,R)}`,style:{...Se,flexWrap:"wrap",gap:8,padding:"6px 14px 6px 10px",borderRadius:8,border:"1px solid var(--graview-edge-bright)",background:"var(--graview-panel)"},children:[(0,q.jsx)(fe,{kind:R,brand:a,schema:n.schema,size:7}),(0,q.jsx)("span",{style:{fontWeight:550,overflowWrap:"anywhere"},children:Q(n,R)}),(0,q.jsx)("span",{style:{...C,fontVariantNumeric:"tabular-nums"},children:G.length===0?"none yet":gt(G.length)})]})},R))})]}),l.length>0?(0,q.jsxs)("section",{style:{...te,display:"grid",gap:10},children:[(0,q.jsx)("h2",{style:J,children:"Recently"}),(0,q.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:l.map(R=>(0,q.jsxs)("li",{style:C,children:[(0,q.jsx)("span",{style:{color:"var(--graview-ink)"},children:R.intent})," \u2014 ",ft(R,e,{graph:n.graph,schema:n.schema,...t.seats?{seats:t.seats}:{},...t.people?{people:t.people}:{}})]},R.id))})]}):null]})}var Me=W(Ie(),1);var et=W(j(),1);function Qt({context:t,withheld:e,style:n,testId:a}){let r=ce(),i=ba(e,t.signIn??r?.signIn);return i?(0,et.jsx)("p",{style:{...n,margin:0},children:(0,et.jsx)("button",{type:"button","data-testid":"sign-in",onClick:()=>i.run(),style:xe,children:i.label})}):e.length===0?null:(0,et.jsx)("ul",{style:{...n,margin:0,padding:0,listStyle:"none",display:"grid",gap:4},...a?{"data-testid":a}:{},children:e.map(o=>(0,et.jsxs)("li",{style:C,children:[(0,et.jsx)("s",{children:o.label})," \u2014 ",o.refusal.message]},o.id))})}var E=W(j(),1);function jn({context:t}){let{store:e,brand:n,principal:a,invariantContext:r}=t;ne(e);let[i]=ct(),o=i.get("q")??"",l=typeof r?.today=="string"?r.today:void 0,d=Cr(e,o,{...a?{principal:a}:{},places:Te(t),flagged:new Set(e.violations(r).flatMap(u=>u.nodeIds)),...l?{today:l}:{},limit:200}),c=d.hits.filter(u=>u.about==="node"),p=d.hits.filter(u=>u.about==="kind"||u.about==="place"||u.about==="rule"),m=[...new Set(c.map(u=>u.kind))],f=o.trim();return(0,E.jsxs)(ae,{context:t,children:[(0,E.jsx)("style",{children:Kt}),(0,E.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,E.jsx)("p",{style:ke,children:"Search"}),(0,E.jsx)(ie,{context:t,"data-testid":"search-heading",children:f.length===0?"Find anything by its name":d.hits.length===0?(0,E.jsxs)(E.Fragment,{children:["Nothing here is called \u201C",f,"\u201D."]}):(0,E.jsxs)(E.Fragment,{children:[wo(e,d.byKind)," for \u201C",f,"\u201D"]})}),f.length>0?(0,E.jsxs)("p",{style:{...C,margin:0},"data-testid":"search-searched",children:[Nt(e.schema,d.searched),d.conditions.filter(u=>u.key!=="is"&&u.admittedBy.length<d.searched.kinds.length).map(u=>(0,E.jsxs)("span",{children:[" ",u.key,":",u.value," narrows"," ",u.admittedBy.length===0?"nothing here":u.admittedBy.map(k=>Q(e,k).toLowerCase()).join(" and "),"."]},`${u.key}:${u.value}`))]}):(0,E.jsxs)("p",{style:re,children:["Type in the box above. Words find the start of words in names and in what each record says;"," ",(0,E.jsx)("code",{children:"done:false"})," and the like narrow as a list does, and ",(0,E.jsx)("code",{children:"is:any"})," includes what is past."]})]}),p.length>0?(0,E.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},"data-testid":"search-named",children:p.map(u=>(0,E.jsx)("li",{"data-testid":"search-hit","data-about":u.about,children:u.about==="kind"?(0,E.jsxs)(F,{to:`/${Y(e.schema,u.kind)}`,style:K,children:[u.label,u.count>0?(0,E.jsxs)("span",{style:C,children:[" \xB7 ",u.count," match"]}):null]}):u.about==="place"?(0,E.jsxs)(F,{to:ye(t,u),style:K,children:["Go to ",u.title]}):u.about==="rule"?(0,E.jsxs)(F,{to:"/problems",style:K,children:["The rule \u201C",u.label,"\u201D"]}):null},`${u.about}:${u.about==="rule"?u.name:u.about==="place"?u.as:u.kind}`))}):null,m.map(u=>(0,E.jsxs)("section",{className:"graview-list",style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",minWidth:0},"data-testid":"search-group","data-kind":u,children:[(0,E.jsxs)("h2",{className:"graview-group-head",style:{alignItems:"center"},children:[(0,E.jsx)(fe,{kind:u,brand:n,schema:e.schema,size:8}),(0,E.jsx)(F,{to:`/${Y(e.schema,u)}?${new URLSearchParams({q:f}).toString()}`,style:K,"data-testid":"search-kind-link",children:Q(e,u)}),(0,E.jsx)("span",{children:d.byKind[u]})]}),(0,E.jsx)("ul",{className:"graview-rows",children:c.filter(k=>k.kind===u).map(k=>(0,E.jsxs)("li",{"data-testid":"search-hit","data-about":"node",className:"graview-row",children:[(0,E.jsxs)(F,{to:Z(e.schema,u,k.id),className:"graview-row-title",...k.label.length>60?{title:k.label}:{},children:[k.flagged?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("span",{role:"img","aria-label":"Breaks a rule:",style:{color:"var(--graview-warn)"},children:"\u26A0"})," "]}):null,k.label]}),k.apart||!k.current?(0,E.jsx)("span",{className:"graview-row-glance",children:[k.apart,k.current?"":"past"].filter(Boolean).join(" \xB7 ")}):null,(0,E.jsx)(Zt,{why:k.why})]},k.id))})]},u)),f.length>0?(0,E.jsx)(bo,{asked:f}):null,f.length>0&&d.hits.length===0?(0,E.jsx)(Pi,{store:e,kinds:d.searched.kinds,words:d.words,...a?{principal:a}:{},...r?{invariantContext:r}:{}}):null]})}function Zt({why:t}){return t.strength==="near"?(0,E.jsxs)("span",{style:C,"data-testid":"search-why","data-near":"",children:["Near \u201C",t.asked,"\u201D",t.field==="label"?"":` \u2014 ${t.reading}: ${t.fragment}`]}):t.field==="label"?null:(0,E.jsxs)("span",{style:C,"data-testid":"search-why",children:[t.reading,": ",t.fragment]})}function wo(t,e){let n=Object.entries(e).map(([a,r])=>`${r} ${r===1?He(t.schema.tryDefinition(a),a):Q(t,a).toLowerCase()}`);return n.length===0?"Found":n.length===1?Re(n[0]):Re(`${n.slice(0,-1).join(", ")} and ${n[n.length-1]}`)}function xi(t,e,n={}){let a=[];for(let r of e){let i=Ye(t,r,{...n.principal?{principal:n.principal}:{},...n.invariantContext?{context:n.invariantContext}:{}});for(let o of Xt(t,r,i.actions.affordances))a.some(l=>l.mutation.name===o.mutation.name)||a.push(o)}return a}function Xt(t,e,n){let a=t.schema.tryDefinition(e)?.fieldRoles?.label,r=[];for(let i of n){let o=t.allMutations().find(c=>c.name===i.mutation);if(!o||!o.creates?.includes(e)||r.some(c=>c.mutation.name===o.name))continue;let l=Et(o.input).map(c=>c.name),d=l.includes("label")?"label":a&&l.includes(a)?a:void 0;!d||i.args[d]!==void 0||r.push({kind:e,affordance:i,mutation:o,arg:d})}return r}function Pi({store:t,kinds:e,words:n,principal:a,invariantContext:r}){let i=xi(t,e,{...a?{principal:a}:{},...r?{invariantContext:r}:{}});return i.length===0||n.trim().length===0?null:(0,E.jsx)("div",{style:{display:"grid",gap:24},"data-testid":"search-to-create",children:i.map(({kind:o,affordance:l,mutation:d,arg:c})=>(0,E.jsxs)("section",{style:{...te,display:"grid",gap:14},children:[(0,E.jsxs)("h2",{style:J,children:[Re(ua(He(t.schema.tryDefinition(o),o)))," called \u201C",n,"\u201D"]}),(0,E.jsx)(We,{store:t,mutation:d,prefilled:l.args,open:l.open,initial:{[c]:n},...a?{principal:a}:{}})]},`${l.id}|${n}`))})}function bo({asked:t}){let e=ce();return e?(0,E.jsx)(ko,{asked:t,desk:e.aiDesk}):null}function ko({asked:t,desk:e}){return Ka(e)?(0,E.jsx)("p",{style:{margin:0},children:(0,E.jsxs)("button",{type:"button","data-testid":"search-ask",onClick:a=>Ha(e,{pointed:{about:[]},asked:t,returnTo:a.currentTarget}),style:{...K,font:"inherit",padding:0,border:0,background:"transparent",cursor:"pointer",textAlign:"start"},children:["Ask: \u2018",t,"\u2019"]})}):null}var b=W(j(),1),Ci=8,Ri=40;function So(t,e){let n=e?.fields?.shape??{},a=Object.keys(n).find(r=>ma(n[r])&&ga(t[r]));return a===void 0?void 0:t[a]}function zn({context:t}){let e=Ue(),n=$e(t.store.schema,e.slug??"");return n?(0,b.jsx)(Li,{context:t,kind:n}):(0,b.jsx)(ae,{context:t,children:(0,b.jsx)(ie,{context:t,children:"No such kind of thing here."})})}function Li({context:t,kind:e,opening:n,row:a,layout:r="list",description:i,bare:o}){let{store:l,brand:d,invariantContext:c}=t;ne(l);let[p,m]=ct(),f=`list-${(0,Me.useId)().replace(/:/g,"")}`,u=l.schema.tryDefinition(e),k=ya(p.get("archived")),B=l.graph.nodesOfKind(e,{archived:k}),h=Qe(l).relations.filter(s=>s.from===e||s.to===e),R=new Set(l.violations(c).flatMap(s=>s.nodeIds)),G=xr(l.schema,Sr(l.schema,kr(l.schema,e))),M=h.map(s=>s.edgeKind),V=Lo(p,G,M),z=["sort","filter","group","q","by","with","past","archived",...M].some(s=>p.has(s)),se=B.length>=Ri,ue=u?.fieldRoles?.when,I=t.views?.arrangement?.()?.lists?.[e],_=yr(I),oe=fr(I?.group),we=Ro(se,ue),le=n??(_?{...we,..._}:we),ge=z?V.arrangement:Rn(le,G).arrangement,w=_?.sort,y=ge.sort&&w?.then&&ge.sort.by===w.by&&ge.sort.direction===w.direction?{...ge,sort:w}:ge,L=Pr(y.query??""),$=[...y.filter??[],...L.conditions].some(s=>s.key==="is"&&(s.value==="past"||s.value==="any"))||br(u,[...y.filter??[],...L.conditions]),g=$||!u?.lifecycle?y:{...y,filter:[...y.filter??[],{key:"is",value:"current"}]},A=new Map,O=$t(B,g,{schema:l.schema,graph:l.graph,flagged:R,...typeof c?.today=="string"?{today:c.today}:{},read:(s,v)=>{let N=A.get(s.id);return N||A.set(s.id,N=mt(l.schema,l.graph,s)),N[v]}}),ee=oe&&y.group?.by===oe.by&&!y.group.bucket?G.groups.find(s=>s.key===oe.by):void 0,De=oe&&ee&&(ee.type==="choice"||ee.type==="boolean")?hr(O.groups,oe,{type:ee.type,...ee.options?{options:ee.options}:{}}):O.groups.map(s=>({...s,closed:!1})),Ee=new Set((p.get("open")??"").split(",").filter(Boolean)),Oi=!!y.query||(y.filter??[]).some(s=>s.key===oe?.by),Zn=s=>ee?.type==="boolean"?s==="1"?"true":"false":s,Xn=s=>s.closed&&!Oi&&!Ee.has(Zn(s.key)),Fi=s=>{let v=new URLSearchParams(p),N=new Set(Ee);N.has(s)?N.delete(s):N.add(s),N.size>0?v.set("open",[...N].join(",")):v.delete("open"),m(v,{replace:!0})},Ce=O.nodes,nt=u?.lifecycle&&!$?B.filter(s=>it(u,s)):B,Jn=B.length-nt.length,tn=y.group?.by??null,Ii=s=>{let v=new URLSearchParams(p);for(let de of["sort","filter","group","q","by","with","past","archived",...h.map(St=>St.edgeKind)])v.delete(de);let N=Rr(s);for(let de of["sort","filter","group","q","archived"])N[de]&&v.set(de,N[de]);![...v.keys()].some(de=>["sort","filter","group","q"].includes(de))&&(n||_||se||ue)&&v.set("sort",""),m(v)},{principal:at}=t,nn=Ye(l,e,{...at?{principal:at}:{},...t.invariantContext?{context:t.invariantContext}:{}}),Be=nn.actions.affordances.map(s=>({affordance:s,mutation:l.allMutations().find(v=>v.name===s.mutation)})).filter(s=>s.mutation!==void 0),Wi=nn.actions.withheld,an=()=>new Set(Ce.length===0?Be.map(({mutation:s})=>s.name):[]),[rn,ea]=(0,Me.useState)(()=>({kind:e,open:an()}));rn.kind!==e&&ea({kind:e,open:an()});let ta=s=>(rn.kind===e?rn.open:an()).has(s),na=(s,v)=>ea(N=>{let de=new Set(N.open);return v?de.add(s):de.delete(s),{kind:N.kind,open:de}}),aa=`begin-${(0,Me.useId)().replace(/:/g,"")}`,ra=L.words&&Ce.length===0?Object.fromEntries(Xt(l,e,nn.actions.affordances).map(s=>[s.mutation.name,s.arg])):{},ze=Q(l,e),vt=t.views?.lookup(e,{cardinality:"one",fidelity:"glyph"}),on=vt!==void 0&&!st(vt)?vt:void 0,sn=(y.group?.bucket??"day")==="day"?y.group?.by:void 0,ln=(y.filter??[]).map(s=>s.key),Di=ln.filter(s=>ln.indexOf(s)===ln.lastIndexOf(s)&&/choice|boolean/.test(G.filters.find(v=>v.key===s)?.type??"")),dn=s=>{let v={...u?.computed?mt(l.schema,l.graph,s):s};sn&&!String(v[sn]).includes("T")&&delete v[sn];for(let N of Di)delete v[N];return v},wt=s=>{let v=me(u,s);if(a)return(0,b.jsxs)("li",{"data-testid":"record-row","data-graview-record":s.id,style:{minWidth:0},...fn(s.id),children:[mn(s,v),a(s,{label:v,href:Z(l.schema,e,s.id),flagged:R.has(s.id),glance:qt(dn(s),u,v)})]},s.id);if(on){let yn=Wt(vt,s,l.graph),Vi=Object.fromEntries(Object.entries(dn(s)).filter(([Ui])=>!yn?.fields.has(Ui))),da=yn?qt(Vi,u,yn.title??v):"";return(0,b.jsxs)("li",{"data-testid":"record-row","data-graview-record":s.id,style:{position:"relative",display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:16,rowGap:2,paddingBlock:10,borderTop:"1px solid var(--graview-edge)"},...fn(s.id),children:[mn(s,v),(0,b.jsx)("div",{style:{flex:"1 1 14rem",minWidth:0},children:(0,b.jsx)(on,{node:s,cardinality:"one",fidelity:"glyph",mode:"fullscreen",selected:!1,...R.has(s.id)?{flagged:[s.id]}:{}})}),da?(0,b.jsx)("span",{style:{...C,flex:"0 1 auto",minWidth:0,overflowWrap:"anywhere"},"data-testid":"record-glance",children:da}):null,(0,b.jsx)(Eo,{to:Z(l.schema,e,s.id),label:R.has(s.id)?`${v} \u2014 implicated in a problem`:v})]},s.id)}let N=qt(dn(s),u,v),de=L.words?Ar(u,s,L.words):void 0,St=se?void 0:nr(s,u),xt=So(s,u),la=(0,b.jsxs)(F,{to:Z(l.schema,e,s.id),className:"graview-row-title",...v.length>60?{title:v}:{},children:[R.has(s.id)?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{role:"img","aria-label":"Breaks a rule:",style:{color:"var(--graview-warn)"},children:"\u26A0"})," "]}):null,v]});return(0,b.jsxs)("li",{className:"graview-row","data-graview-record":s.id,...fn(s.id),children:[mn(s,v),St?(0,b.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:14,minWidth:0},children:[(0,b.jsx)(Ge,{as:"thumb",file:St}),la]}):la,N||xt?(0,b.jsxs)("span",{className:"graview-row-glance",children:[N,N&&xt?" \xB7 ":null,xt?(0,b.jsx)(Ot,{address:xt}):null]}):null,de?(0,b.jsx)(Zt,{why:de}):null]},s.id)},cn=Te(t).filter(s=>s.kind===e),ia=I?.filters,Hi=(y.filter??[]).some(s=>s.key!=="is"||s.value!=="any"),Ki=!!(y.sort||y.group||y.query||Hi),qi=nt.length>=Ci||z&&Ki,Oe=y.sort?G.sorts.find(s=>s.key===y.sort.by):void 0,pn=Oe?.type==="date"||Oe!==void 0&&Oe.key===ue,oa=se&&!O.grouped&&Oe&&(Oe.about==="label"||Oe.type==="text"||pn)?s=>{let v=Oe.about==="label"?me(u,s):s[Oe.key];if(typeof v!="string"||v.length===0)return pn?"No date":"#";if(pn)return v.slice(0,4);let N=v.trim().charAt(0).toLocaleUpperCase();return/\p{L}/u.test(N)?N:"#"}:void 0,_e=oa?Ce.reduce((s,v)=>{let N=oa(v);return s.at(-1)?.key===N?s.at(-1).nodes.push(v):s.push({key:N,nodes:[v]}),s},[]):void 0,sa=O.grouped&&tn?De.flatMap(s=>Xn(s)?[]:s.nodes):_e&&_e.length>1?_e.flatMap(s=>s.nodes):Ce,un=(0,Me.useMemo)(()=>sa.map(s=>s.id),[sa.map(s=>s.id).join(`
109
109
  `)]),Ne=Nr(un),gn=(0,Me.useId)(),pt=(at?l.permittedMutations(at):l.permittedMutations()).some(s=>{let v=s.subject?.kinds;return v!==void 0&&(v==="*"||v.includes(e))}),mn=(s,v)=>pt?(0,b.jsx)("span",{className:"graview-choose-at",children:(0,b.jsx)("input",{...Ne.boxProps(s.id,v),onPointerEnter:Ln,onFocus:Ln})}):null,fn=s=>pt?{"data-graview-choose":s}:{},Bi=(0,Me.useCallback)(s=>{Ne.choose(s),requestAnimationFrame(()=>{let v=Ne.list.current;((s[0]===void 0?null:v?.querySelector(`[data-graview-choose-box="${CSS.escape(s[0])}"]`))??v)?.focus({preventScroll:!0})})},[Ne]),rt=r==="grid"?{margin:0,padding:0,listStyle:"none",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(100%, 15rem), 1fr))",alignItems:"start",gap:12}:a||on?{margin:0,padding:0,listStyle:"none",display:"grid",gap:a&&r==="list"?6:0}:void 0,bt=rt?void 0:"graview-rows",ut=s=>`list-at-${s.replace(/[^\p{L}\p{N}]/gu,"_")}`,kt=h.map(s=>{let v=s.from===e?s.to:s.from,N=s.from===e?s.description:s.inverse??s.description;return{relation:s,far:v,words:N}}),Gi=new Set(kt.map(s=>(s.words??"").toLowerCase()).filter((s,v,N)=>s&&N.indexOf(s)!==v));return(0,b.jsxs)(o?Co:ae,{context:t,children:[(0,b.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,b.jsxs)("header",{style:{display:"grid",gap:4},children:[(0,b.jsxs)("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",columnGap:10,rowGap:4,minWidth:0},children:[(0,b.jsx)(fe,{kind:e,brand:d,schema:l.schema,size:8}),(0,b.jsx)(ie,{context:t,children:ze}),Be.length>0?(0,b.jsx)("span",{style:{marginLeft:"auto",display:"flex",flexWrap:"wrap",columnGap:14,rowGap:8},"data-testid":"beginnings-open",children:Be.map(({affordance:s,mutation:v})=>(0,b.jsx)(To,{name:v.name,title:v.title??v.name,panel:`${aa}-${v.name}`,open:ta(v.name),onOpen:N=>na(v.name,N)},s.id))}):null]}),Ce.length>0?(0,b.jsx)(Zr,{place:"here",to:[{label:`Skip to the ${Ce.length===1?He(u,e):`${Ce.length} ${ze.toLowerCase()}`}`,testid:"records",go:()=>{let s=document.querySelector(`[data-graview-skip-target="${CSS.escape(gn)}"]`);Tn(s?.querySelector('[data-graview-choose-box][tabindex="0"]')??s)}},...nt.length>0?[{label:"Skip to arranging them",testid:"arranging",go:()=>{let s=document.querySelector(`[data-graview-skip-target="${CSS.escape(gn)}"]`)?.parentElement?.querySelector('[role="group"][aria-label="Arrange"]');Tn(s?.querySelector('button[data-testid$="-add"], button[data-testid$="-all"]')??s)}}]:[]]}):null,i??u?.description?(0,b.jsx)("p",{style:re,children:i??u?.description}):null,kt.length>0||cn.length>0?(0,b.jsxs)("p",{style:{...C,margin:0,display:"flex",flexWrap:"wrap",columnGap:18,rowGap:2},"data-testid":"kind-related",children:[kt.length>0?(0,b.jsxs)("span",{"data-testid":"kind-relations",children:["Related:"," ",kt.map(({relation:s,far:v,words:N},de)=>(0,b.jsxs)("span",{"data-relation":s.edgeKind,children:[de>0?(0,b.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,v==="*"?Re(N??be(s.edgeKind)):(0,b.jsx)(F,{to:`/${Y(l.schema,v)}`,style:K,title:Q(l,v),children:N&&Gi.has(N.toLowerCase())?`${Re(N)}: ${Q(l,v).toLowerCase()}`:Re(N??Q(l,v))})]},`${s.edgeKind}|${s.from}|${s.to}`))]}):null,cn.length>0?(0,b.jsxs)("span",{"data-testid":"kind-pictures",children:["Also as:"," ",cn.map((s,v)=>(0,b.jsxs)("span",{children:[v>0?(0,b.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,(0,b.jsx)(F,{to:ye(t,s),style:K,children:s.title})]},Xe(s)))]}):null]}):null]}),Be.length>0?(0,b.jsx)("div",{style:{display:"contents"},"data-testid":"beginnings",children:Be.map(({affordance:s,mutation:v})=>{let N=!!(ra[v.name]&&Ce.length===0);return(0,b.jsx)(Mo,{name:v.name,id:`${aa}-${v.name}`,description:v.description,open:ta(v.name),onClose:()=>na(v.name,!1),children:(0,b.jsx)(We,{store:l,mutation:v,prefilled:s.args,open:s.open,...N?{initial:{[ra[v.name]]:L.words}}:{},...t.principal?{principal:t.principal}:{}},N?`${v.name}|${L.words}`:v.name)},s.id)})}):null,V.dropped.length>0?(0,b.jsxs)("p",{style:{...C,margin:0},"data-testid":"list-dropped",children:["This link asked for ",V.dropped.join(", "),", which ",ze.toLowerCase()," cannot be arranged by; the rest is shown."]}):null,nt.length>0?(0,b.jsx)(Mr,{schema:l.schema,graph:l.graph,kind:e,arrangement:y,onChange:Ii,kept:{shown:Ce.length,of:nt.length},noun:{one:He(u,e),many:ze.toLowerCase()},...qi?{}:{allow:!1},...ia?{filters:ia}:{},offers:G,chips:{nodes:nt,flagged:R,...typeof c?.today=="string"?{today:c.today}:{}},query:t.framed===!0&&t.barAbove!==!0}):null,(0,b.jsx)("style",{children:Kt}),pt?(0,b.jsx)("style",{children:$r+Ao}):null,(0,b.jsx)("div",{className:"graview-list","data-graview-skip-target":gn,...pt?{...Ne.listProps,ref:Ne.list,tabIndex:-1,"data-graview-choosable":"","aria-label":Ne.chosen.length>0?`${ze}, ${Ne.chosen.length} chosen`:ze,role:"group"}:{},children:Ce.length===0&&L.words?(0,b.jsxs)("p",{style:re,"data-testid":"none-yet",children:["Nothing here is called \u201C",L.words,"\u201D."," ",(0,b.jsx)("span",{style:C,"data-testid":"list-searched",children:Nt(l.schema,{kinds:[e],past:$})})," ",(0,b.jsx)(F,{to:"?",style:K,children:"Show every one"})]}):Ce.length===0?(0,b.jsxs)("p",{style:re,"data-testid":"none-yet",children:[y.filter?.length||y.query?"None of them.":"None yet",!y.filter?.length&&!y.query&&Be.length>0?` \u2014 the first one starts above, with \u201C${Be[0]?.mutation.title??Be[0]?.mutation.name}\u201D.`:!y.filter?.length&&!y.query?".":"",y.filter?.length||y.query?(0,b.jsxs)(b.Fragment,{children:[" ",(0,b.jsx)(F,{to:"?",style:K,children:"Show every one"})]}):null]}):O.grouped&&tn?(0,b.jsx)("div",{style:{display:"grid",gap:"1rem"},"data-testid":"records","data-grouped":tn,children:De.map(s=>{if(!s.closed)return(0,b.jsxs)("section",{style:{display:"grid",gap:0},"data-testid":"list-group",children:[(0,b.jsxs)("h2",{className:"graview-group-head",children:[s.label," ",(0,b.jsx)("span",{children:s.nodes.length})]}),(0,b.jsx)("ul",{style:rt,className:bt,"data-graview-rows":"",children:s.nodes.map(wt)})]},s.key||"-");let v=Xn(s),N=`${f}-${ut(s.key||"none")}`;return(0,b.jsxs)("section",{style:{display:"grid",gap:0},"data-testid":"list-group","data-closed":v?"shut":"open",children:[(0,b.jsx)("h2",{className:"graview-group-head",children:(0,b.jsxs)("button",{type:"button",className:"graview-group-toggle","aria-expanded":!v,"aria-controls":N,"data-testid":"list-group-toggle",onClick:()=>Fi(Zn(s.key)),children:[(0,b.jsx)("span",{"aria-hidden":"true",children:v?"\u25B8":"\u25BE"}),s.label," ",(0,b.jsxs)("span",{children:["\xB7 ",s.nodes.length]}),(0,b.jsxs)("span",{style:xo,children:[" ",s.nodes.length===1?He(u,e):ze.toLowerCase()]})]})}),(0,b.jsx)("ul",{id:N,style:v?{...rt,display:"none"}:rt,className:bt,"data-graview-rows":"",hidden:v,children:v?null:s.nodes.map(wt)})]},s.key||"-")})}):_e&&_e.length>1?(0,b.jsxs)("div",{style:{display:"grid",gap:14},"data-testid":"records","data-sectioned":Oe?.type==="date"?"year":"letter",children:[(0,b.jsx)("nav",{"aria-label":"Jump to","data-testid":"list-index",style:{...C,display:"flex",flexWrap:"wrap",gap:Oe?.type==="date"?"0 10px":"0 4px",lineHeight:1.3},children:_e.map(s=>(0,b.jsx)("a",{href:`#${ut(s.key)}`,onClick:v=>{v.preventDefault(),document.getElementById(ut(s.key))?.scrollIntoView({block:"start"})},style:{...Se,minWidth:24,justifyContent:"center"},children:s.key},s.key))}),_e.map(s=>(0,b.jsxs)("section",{"data-testid":"list-section","aria-labelledby":ut(s.key),style:{display:"grid",gap:0},children:[(0,b.jsx)("h2",{id:ut(s.key),className:"graview-group-head",children:s.key}),(0,b.jsx)("ul",{style:rt,className:bt,"data-graview-rows":"",children:s.nodes.map(wt)})]},s.key))]}):(0,b.jsx)("ul",{style:rt,className:bt,"data-testid":"records","data-graview-rows":"",children:Ce.map(wt)})}),pt?(0,b.jsx)(Or,{store:l,chosen:Ne.chosen,...at?{principal:at}:{},...c?{context:c}:{},anchor:Po,of:un.length,onChooseAll:()=>Ne.choose(un),onClear:Ne.clear,onActed:Bi}):null,Jn>0?(0,b.jsxs)(F,{to:Ai(p,"filter","is:any"),style:{...K,...C,justifySelf:"start"},"data-testid":"past-link",children:["+",Jn," past"]}):null,k===!1&&l.graph.count(e,{archived:!0})>0?(0,b.jsxs)(F,{to:Ai(p,"archived","true"),style:{...K,...C,justifySelf:"start"},"data-testid":"archived-link",children:["+",l.graph.count(e,{archived:!0})," archived"]}):null]}),(0,b.jsx)(Qt,{context:t,withheld:Wi,style:te,testId:"withheld"})]})}var xo={position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0},Po=()=>document.querySelector("[data-graview-choosable]")?.closest("[data-embed-content]")??null,Ao=`
110
110
  .graview-list[data-graview-choosable]{outline:none}
111
111
  .graview-list [data-graview-choose]{position:relative;padding-left:34px}
@@ -114,4 +114,4 @@ p:where([data-graview-part="refused"]) {
114
114
  .graview-list:not([data-graview-choosing]) [data-graview-choose]{padding-left:0}
115
115
  .graview-list:not([data-graview-choosing]) .graview-choose-at{display:none}
116
116
  }
117
- `;function Co({children:t}){return(0,b.jsx)("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:40,minWidth:0},children:t})}var Ro=(t,e)=>e?{sort:{by:e,direction:"desc"}}:t?{sort:{by:"label",direction:"asc"}}:{};function Lo(t,e,n){let a=Ct({...t.get("sort")?{sort:t.get("sort")}:{},...t.get("filter")?{filter:t.get("filter")}:{},...t.get("group")?{group:t.get("group")}:{},...t.get("q")?{q:t.get("q")}:{},...t.get("archived")?{archived:t.get("archived")}:{}}),r=[...a.filter??[]],i=t.get("by"),o=a.group??(i?{by:i}:void 0);for(let d of n){let c=t.get(d);c&&r.push({key:d,value:c})}let l=t.get("with");return l&&r.push({key:l,value:"*"}),t.get("past")==="1"&&!r.some(d=>d.key==="is")&&r.push({key:"is",value:"any"}),Rn({...a.sort?{sort:a.sort}:{},...a.query?{query:a.query}:{},...r.length>0?{filter:r}:{},...o?{group:o}:{},...a.archived!==void 0?{archived:a.archived}:{}},e)}function Ai(t,e,n){let a=new URLSearchParams(t);return a.set(e,n),a.delete("past"),`?${a.toString()}`}function To({name:t,title:e,panel:n,open:a,onOpen:r}){return(0,b.jsxs)("button",{type:"button","data-testid":`act-open-${t}`,"data-graview-act":t,"aria-expanded":a,"aria-controls":n,onClick:()=>{r(!a),a||requestAnimationFrame(()=>document.getElementById(n)?.querySelector("input, select, textarea, button")?.focus())},style:{...Se,minHeight:28,margin:"-4px 0",padding:"0 2px",border:0,background:"none",font:"inherit",fontWeight:600,color:"var(--graview-ink)",cursor:"pointer"},children:[(0,b.jsx)("span",{"aria-hidden":"true",style:{marginRight:6},children:a?"\u2212":"+"}),e]})}function Mo({name:t,id:e,description:n,open:a,onClose:r,children:i}){return(0,b.jsxs)("div",{"data-testid":`act-${t}`,id:e,hidden:!a,onKeyDown:o=>{o.key==="Escape"&&(o.preventDefault(),r(),document.querySelector(`[aria-controls="${e}"]`)?.focus())},style:a?{display:"grid",gap:12,padding:"4px 0 12px"}:void 0,children:[n?(0,b.jsx)("p",{style:{...C,margin:0,maxWidth:"58ch"},children:n}):null,i]})}function Eo({to:t,label:e}){let n=(0,Me.useRef)(null);return Fr(n),(0,b.jsx)(F,{ref:n,to:t,"aria-label":e,style:{position:"absolute",inset:0,borderRadius:6}})}var tt=W(Ie(),1);var ht=W(Ie(),1);var D=W(j(),1);function _n({context:t}){let{store:e,brand:n,invariantContext:a,principal:r}=t;ne(e);let i=e.violations(a),o=e.allInvariants(),l=Lt(e,i),d=qa(e.schema,o);return(0,D.jsxs)(ae,{context:t,children:[(0,D.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,D.jsx)(ie,{context:t,children:i.length===0?"All rules hold":"What is broken"}),(0,D.jsx)("p",{style:re,"data-testid":"problems-count",children:i.length===0?"Every declared rule is satisfied by what is here.":ha(i)})]}),(0,D.jsx)(Si,{context:t}),l.map((c,p)=>{let m=c.nodeIds[0],f=m?e.graph.getNode(m):void 0;return(0,D.jsxs)("section",{style:{display:"grid",gap:10,padding:"16px 18px",borderLeft:"3px solid var(--graview-warn)",background:"var(--graview-panel-warning)",borderRadius:"0 var(--graview-radius, 12px) var(--graview-radius, 12px) 0"},children:[c.line?null:(0,D.jsx)(Jt,{violation:c,schema:e.schema,...n?{brand:n}:{}}),f?(0,D.jsxs)("p",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:8},children:[(0,D.jsx)(fe,{kind:f.kind,brand:n,schema:e.schema,size:7}),(0,D.jsx)(F,{to:Z(e.schema,f.kind,f.id),style:K,children:me(e.schema.tryDefinition(f.kind),f)})]}):null,c.line?(0,D.jsx)(Jt,{violation:c,schema:e.schema,...n?{brand:n}:{}}):null,(0,D.jsx)(en,{store:e,repairs:c.repairs,...r?{principal:r}:{}})]},p)}),o.length>0?(0,D.jsxs)("section",{style:{...te,display:"grid",gap:12},"data-testid":"rules",children:[(0,D.jsx)("h2",{style:J,children:"The rules"}),(0,D.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:o.map(c=>{let p=i.filter(u=>u.invariant===c.name).length,m=d.get(c.name),f=c.label??c.name;return(0,D.jsxs)("li",{"data-graview-rule":c.name,style:{display:"grid",gap:2},children:[(0,D.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:12,rowGap:2},children:[m?(0,D.jsx)(Tt,{line:m,schema:e.schema,...n?{brand:n}:{},style:{flex:"1 1 18rem"}}):(0,D.jsx)("span",{style:{flex:"1 1 18rem",fontWeight:550},children:f}),(0,D.jsx)("span",{style:{...C,color:p>0?"var(--graview-warn)":"var(--graview-ink-faint)"},children:p===0?"holds":`broken in ${p} ${p===1?"place":"places"}`})]}),m&&f.trim().length>0?(0,D.jsx)("span",{style:C,children:f}):null]},c.name)})})]}):null]})}function Jt({violation:t,schema:e,brand:n}){if(!t.line)return(0,D.jsx)("p",{style:{margin:0,color:"var(--graview-warn)",fontWeight:550},children:t.message});let a=Ga(t),r=Ba(t);return r?(0,D.jsxs)("div",{style:{display:"grid",gap:4},"data-testid":"problem-line",children:[(0,D.jsx)("p",{style:{margin:0,color:"var(--graview-warn)",fontWeight:550},"data-testid":"problem-says",children:r}),a?(0,D.jsx)("span",{style:C,children:a}):null,(0,D.jsxs)("details",{"data-testid":"problem-judged",style:C,children:[(0,D.jsx)("summary",{style:{cursor:"pointer",width:"fit-content",minHeight:24},children:"How it is judged"}),(0,D.jsx)(Tt,{line:t.line,schema:e,...n?{brand:n}:{},lead:"none"})]})]}):(0,D.jsxs)("div",{style:{display:"grid",gap:2},"data-testid":"problem-line",children:[(0,D.jsx)(Tt,{line:t.line,schema:e,...n?{brand:n}:{},lead:"none",style:{color:"var(--graview-warn)"}}),a?(0,D.jsx)("span",{style:C,children:a}):null]})}function en({store:t,repairs:e,principal:n}){let[a,r]=(0,ht.useState)(null),[i,o]=(0,ht.useState)(null),l=(0,ht.useRef)([]);if(e.length===0)return null;let d=a===null?null:e[a],c=d&&(d.missing??[]).length>0?t.allMutations().find(p=>p.name===d.mutation):void 0;return(0,D.jsxs)("div",{style:{display:"grid",gap:10},"data-testid":"repairs",children:[(0,D.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:e.map((p,m)=>{let f=(p.missing??[]).length>0,u=t.permits({name:p.mutation,args:{...p.args}},n);return u.ok?(0,D.jsx)("button",{ref:k=>{l.current[m]=k},type:"button","data-graview-repair":p.mutation,"data-graview-asks":f||void 0,"aria-expanded":f?a===m:void 0,onClick:()=>{if(o(null),f){r(a===m?null:m);return}r(null);try{t.apply({name:p.mutation,args:{...p.args}},n?{author:n}:{})}catch(k){o(lt(t.schema,t.allMutations(),k))}},style:xe,children:f?`${p.label} \u2026`:p.label},m):(0,D.jsxs)("p",{"data-testid":"withheld","data-withheld":u.refusal.wouldNeed.join(",")||"nobody",style:{...C,margin:0},children:[(0,D.jsx)("s",{children:p.label})," \u2014 ",u.refusal.message]},m)})}),c&&d?(0,D.jsx)(We,{store:t,mutation:c,prefilled:{...d.args},only:d.missing??[],label:d.label,onDone:()=>{let p=a;r(null),requestAnimationFrame(()=>{let m=p===null?null:l.current[p];if(m?.isConnected){m.focus();return}let f=document.querySelector("[data-graview-page-title]")??document.querySelector("main h1, main h2");f&&(f.hasAttribute("tabindex")||(f.tabIndex=-1),f.focus())})},...n?{principal:n}:{}}):null,d&&!c&&(d.missing??[]).length>0?(0,D.jsxs)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:Mn},children:["\u201C",d.label,"\u201D names ",d.mutation,", which this app does not declare."]}):null,i?(0,D.jsx)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:Mn},children:i}):null]})}var Yn=W(Ie(),1);var je=W(j(),1);function Ti({store:t,link:e,principal:n}){let[a,r]=(0,Yn.useState)(!1),[i,o]=(0,Yn.useState)(null),l=Xa(e);return(0,je.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[(0,je.jsx)("button",{type:"button","data-graview-provisional":"",title:l,"aria-label":`Unsure link: ${l}`,"aria-expanded":a,onClick:()=>r(!a),style:{border:"1px dashed var(--graview-ink-muted)",borderRadius:999,background:"transparent",color:"var(--graview-ink-muted)",font:"inherit",fontSize:"0.75rem",lineHeight:1,padding:"2px 6px",cursor:"pointer"},children:"unsure"}),a?(0,je.jsxs)("span",{style:{...C,display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,je.jsx)("span",{children:l}),(0,je.jsx)("button",{type:"button",style:{...xe,padding:"4px 10px"},onClick:()=>{try{t.apply({name:va,args:{kind:e.edge.kind,from:e.edge.from,to:e.edge.to}},n?{author:n}:{}),r(!1)}catch(d){o(lt(t.schema,t.allMutations(),d))}},children:"Keep this link"}),i?(0,je.jsx)("span",{role:"alert",children:i}):null]}):null]})}var ve=W(j(),1);function Mi({nodeId:t,node:e,field:n,inPlace:a,labelStyle:r=ke}){return n.files?(0,ve.jsx)(Ge,{as:"field",read:!a,nodeId:t,field:n.key,label:n.label,files:n.files,labelStyle:r,style:{gap:4}}):n.long?(0,ve.jsx)(Tr,{nodeId:t,field:n.key,label:n.label,value:n.value,markdown:n.markdown,style:{gridColumn:"1 / -1",gap:4},labelStyle:r,valueStyle:{lineHeight:1.6}}):(0,ve.jsxs)("div",{style:{display:"grid",gap:2,minWidth:0,alignContent:"start"},children:[(0,ve.jsx)("dt",{style:r,children:n.label}),(0,ve.jsx)("dd",{style:{margin:0,overflowWrap:"anywhere",minWidth:0},children:n.linked?(0,ve.jsx)(rr,{relation:n.linked.relation,refs:n.linked.refs,...a?{nodeId:t,field:n.key}:{}}):n.app?(0,ve.jsx)(Ot,{address:n.app,as:"record",...a?{nodeId:t,field:n.key}:{}}):n.href?(0,ve.jsx)(Lr,{href:n.href,field:n.key,value:n.value,stored:n.stored,...a?{nodeId:t}:{}}):a?(0,ve.jsxs)(ve.Fragment,{children:[(0,ve.jsx)(Ft,{nodeId:t,field:n.key,value:n.value,stored:n.stored}),n.repeats?(0,ve.jsx)(sr,{nodeId:t,field:n.key,start:e?.[n.key],value:e?.[`${n.key}Repeat`],label:`${n.label} repeats`}):null]}):n.value})]})}var S=W(j(),1),No=[];function Qn({context:t}){let{store:e,brand:n,principal:a,invariantContext:r}=t;ne(e);let i=ce()!==null,o=Ue(),l=decodeURIComponent(o.id??""),d=si(e,l,{...a?{principal:a}:{},...r?{context:r}:{}}),c=Lt(e,d?.violations??No),[p,m]=(0,tt.useState)(null),[f,u]=(0,tt.useState)(!1),[k,B]=(0,tt.useState)(null),h=(0,tt.useRef)(null),R=(0,tt.useRef)(null),G=g=>{(h.current?.parentElement?.querySelector(`[data-affordance="${g.replace(/["\\]/g,"\\$&")}"]`)??h.current)?.focus()};if(!d)return(0,S.jsx)(ae,{context:t,children:(0,S.jsx)(ie,{context:t,children:"Nothing lives at this address."})});let M=e.graph.getNode(l),V=e.schema.tryDefinition(d.kind),z=V?.describe&&M?Va(V,M):null,se=[...e.log.all()].filter(g=>!At(g)&&(g.writes.includes(l)||g.reads.includes(l))).slice(-8).reverse(),ue=e.log.all().find(g=>!At(g)&&g.undoes===void 0&&g.primitives.some(A=>A.op==="add-node"&&A.node.id===l)),I=d.actions.affordances.filter(g=>g.provider!=="invariant"),_=I.filter(g=>g.destructive||g.setsAside),oe=f||_.length<2?I:I.filter(g=>!_.includes(g)),we=t.views?.lookup(d.kind,{cardinality:"one",fidelity:"full"}),le=we!==void 0&&!st(we)?we:void 0,ge=le&&M?Wt(we,M,e.graph):void 0,w=ge?d.fields.filter(g=>!ge.fields.has(g.key)):d.fields,y=ge?d.links.flatMap(g=>{let A=g.targets.filter(O=>!ge.records.has(O.id));return A.length>0?[{...g,targets:A}]:[]}):d.links,L=le!==void 0&&Wa(we),$=i&&tr(V).length>0;return(0,S.jsxs)(ae,{context:t,children:[(0,S.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,S.jsxs)("p",{style:{...ke,display:"flex",alignItems:"center",gap:8},children:[(0,S.jsx)(fe,{kind:d.kind,brand:n,schema:e.schema,size:8}),(0,S.jsx)(F,{to:`/${Y(e.schema,d.kind)}`,style:Se,children:Q(e,d.kind)})]}),(0,S.jsx)(ie,{context:t,children:i&&M?.label===d.label?(0,S.jsx)(Ft,{nodeId:l,field:"label",value:d.label,said:d.label}):d.label}),z&&z!==d.label?(0,S.jsx)("p",{style:re,children:z}):null,ue?.lineage?(0,S.jsxs)("p",{style:{...C,margin:0},"data-testid":"record-lineage",children:["Made by ",ft(ue,a,{graph:e.graph,schema:e.schema,...t.seats?{seats:t.seats}:{},...t.people?{people:t.people}:{}}),", ",Sn(ue.lineage)]}):null,(0,S.jsx)(Gt,{context:t,stop:`#focus=${encodeURIComponent(l)}`,style:{...K,...C},"data-testid":"spatial-link"}),i&&M?(0,S.jsx)(Pn,{choices:[{on:"changed",record:l},{on:"act",record:l},{on:"reaches",kind:d.kind,condition:"",record:l}],label:"Notify me when this changes",testId:"record-notify",style:{...xe,...C,justifySelf:"start"}}):null,Te(t).some(g=>g.kind===d.kind||g.across===d.kind)?(0,S.jsxs)("p",{style:{...C,margin:0},"data-testid":"seen-in",children:["Seen in:"," ",Te(t).filter(g=>g.kind===d.kind||g.across===d.kind).map((g,A)=>(0,S.jsxs)("span",{children:[A>0?(0,S.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,(0,S.jsx)(F,{to:ye(t,g),style:K,children:g.title})," ",(0,S.jsx)(Gt,{context:t,stop:`#view=${encodeURIComponent(g.as)}`,style:{...K,...C,display:"inline-block",minWidth:24,textAlign:"center"},title:`${g.title}, in the scene`,label:`${g.title}, in the scene`,children:(0,S.jsx)("span",{"aria-hidden":"true",children:"\u2197"})})]},Xe(g)))]}):null]}),M&&fa(M)?(0,S.jsx)(Oo,{context:t,id:l,kind:d.kind}):null,M&&wa(e,l)?(0,S.jsx)($o,{context:t,id:l,kind:d.kind}):null,le&&M?(0,S.jsx)("section",{"data-testid":"record-view",style:{display:"grid",minWidth:0},children:(0,S.jsx)(Ir,{children:(0,S.jsx)(le,{node:M,cardinality:"one",fidelity:"full",mode:"fullscreen",selected:!1,...d.violations.length>0?{flagged:[l]}:{}})})}):null,d.violations.length>0?(0,S.jsx)("section",{"data-testid":"record-violations",style:{display:"grid",gap:12,padding:"16px 18px",borderLeft:"3px solid var(--graview-warn)",background:"var(--graview-panel-warning)",borderRadius:"0 var(--graview-radius, 12px) var(--graview-radius, 12px) 0"},children:c.map((g,A)=>(0,S.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,S.jsx)(Jt,{violation:g,schema:e.schema,...n?{brand:n}:{}}),(0,S.jsx)(en,{store:e,repairs:li(d.actions,g.repairs),...a?{principal:a}:{}})]},A))}):null,!L&&(w.length>0||$)?(0,S.jsxs)("section",{style:{...te,display:"grid",gap:14},"data-testid":"record-fields",children:[(0,S.jsx)("h2",{style:J,children:"The facts"}),ja(V,w).map((g,A)=>{let O=(0,S.jsx)("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"14px 24px"},children:g.fields.map(ee=>(0,S.jsx)(Mi,{nodeId:l,node:M,field:ee,inPlace:i},ee.key))});return g.title?(0,S.jsxs)("section",{style:{display:"grid",gap:10,minWidth:0},children:[(0,S.jsx)("h3",{"data-graview-field-group":g.title,style:{...J,fontSize:"inherit"},children:g.title}),O]},A):(0,S.jsx)("div",{children:O},A)}),$?(0,S.jsx)(Ge,{as:"unfilled",nodeId:l,skip:[...ge?.fields??[]],labelStyle:ke,style:{gap:4}}):null]}):null,(L?[]:y).map(g=>(0,S.jsxs)("section",{style:{...te,display:"grid",gap:10},children:[(0,S.jsx)("p",{style:ke,children:Jr(e,g)}),g.description?(0,S.jsx)("h2",{style:J,children:Re(g.description)}):(0,S.jsxs)("h2",{style:J,"aria-label":be(g.edgeKind),children:[g.direction==="in"?"\u2190 ":"\u2192 ",be(g.edgeKind)]}),(0,S.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"6px 18px"},children:g.targets.map(A=>{let O=Ja(e,g.direction==="in"?{kind:g.edgeKind,from:A.id,to:l}:{kind:g.edgeKind,from:l,to:A.id});return(0,S.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,S.jsx)(fe,{kind:A.kind,brand:n,schema:e.schema,size:7}),(0,S.jsxs)(F,{to:Z(e.schema,A.kind,A.id),style:K,children:[A.label,A.apart?(0,S.jsxs)("span",{style:C,children:[" \xB7 ",A.apart]}):null]}),O?.provisional?(0,S.jsx)(Ti,{store:e,link:O,...a?{principal:a}:{}}):null]},A.id)})}),(g.direction==="out"&&e.schema.edge(g.edgeKind)?.cardinality==="one"?[]:[...new Set(g.targets.map(A=>A.kind))]).map(A=>(0,S.jsxs)(F,{to:`/${Y(e.schema,A)}?${encodeURIComponent(g.edgeKind)}=${encodeURIComponent(l)}`,style:{...K,...C},"data-testid":"related-all",children:["Sort and filter ",g.description??`these ${Q(e,A).toLowerCase()}`,g.targets.some(O=>O.kind!==A)?` (${Q(e,A).toLowerCase()})`:""," ",(0,S.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]},A))]},`${g.edgeKind}|${g.direction}|${g.description??""}`)),!L&&(I.length>0||d.actions.withheld.length>0)?(0,S.jsxs)("section",{style:{...te,display:"grid",gap:14},"data-testid":"record-actions",children:[(0,S.jsx)("h2",{style:J,ref:h,tabIndex:-1,children:"What can be done"}),(0,S.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:[oe.map(g=>{let A=p===g.id;return(0,S.jsx)("button",{type:"button","data-affordance":g.id,"data-rank":g.rank,"data-graview-act":g.mutation,autoFocus:f&&g===_[0],"aria-expanded":A,onClick:()=>{m(A?null:g.id),A||requestAnimationFrame(()=>R.current?.querySelector("input:not([type=hidden]), select, textarea, button")?.focus())},style:{...xe,...A?{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"}:{}},children:g.label},g.id)}),oe.length<I.length?(0,S.jsxs)("button",{type:"button","aria-expanded":!1,onClick:()=>u(!0),style:{...xe,...C},"data-testid":"record-actions-more",children:["Show ",I.length-oe.length," more"]}):null]}),I.map(g=>{if(p!==g.id)return null;let A=e.allMutations().find(O=>O.name===g.mutation);return A?(0,S.jsxs)("div",{ref:R,onKeyDown:O=>{if(O.key!=="Escape"||O.defaultPrevented)return;O.preventDefault(),m(null);let ee=g.id;requestAnimationFrame(()=>G(ee))},style:{display:"grid",gap:10,padding:18,border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,S.jsx)("h3",{style:J,children:g.label}),A.description?(0,S.jsx)("p",{style:{...C,margin:0},children:A.description}):null,(0,S.jsx)(We,{store:e,mutation:A,prefilled:g.args,open:g.open,label:g.label,onDone:()=>{m(null),B(g.mutation);let O=g.id;requestAnimationFrame(()=>G(O))},...a?{principal:a}:{}})]},g.id):null}),i&&k!==null&&p===null?(0,S.jsx)(Pn,{choices:[{on:"act",act:k,record:l},{on:"act",act:k}],label:"Notify me when someone else does this",testId:"notify-after-act",style:{...xe,...C,justifySelf:"start"}}):null,(0,S.jsx)(Qt,{context:t,withheld:d.actions.withheld})]}):null,i?(0,S.jsx)(Xr,{id:l,style:te,headingStyle:J}):null,se.length>0?(0,S.jsxs)("section",{style:{...te,display:"grid",gap:10},"data-testid":"record-history",children:[(0,S.jsx)("h2",{style:J,children:"What has happened"}),(0,S.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:se.map(g=>(0,S.jsxs)("li",{style:C,children:[(0,S.jsx)("span",{style:{color:"var(--graview-ink)"},children:g.intent}),g.lineage?(0,S.jsxs)("span",{"data-graview-lineage":"",children:[" \xB7 ",Sn(g.lineage)]}):null," \u2014 ",ft(g,a,{graph:e.graph,schema:e.schema,...t.seats?{seats:t.seats}:{},...t.people?{people:t.people}:{}})]},g.id))})]}):null]})}function $o({context:t,id:e,kind:n}){let{store:a,principal:r}=t,i={name:`allow-tidying-${n}`,args:{id:e}},o=a.allMutations().some(l=>l.name===i.name)&&a.permits(i,r).ok;return(0,S.jsxs)("section",{"data-testid":"record-left-alone",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:12,padding:"12px 16px",border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,S.jsxs)("p",{style:{margin:0,flex:"1 1 16rem"},children:[(0,S.jsx)("strong",{children:"Left alone."})," Nothing automated changes it; tidying passes it by."]}),o?(0,S.jsx)("button",{type:"button",style:xe,"data-testid":"allow-tidying",onClick:()=>a.apply(i,r?{author:r}:{}),children:"Allow tidying again"}):null]})}function Oo({context:t,id:e,kind:n}){let{store:a,principal:r}=t,i={name:`unarchive-${n}`,args:{id:e}},o=a.allMutations().some(c=>c.name===i.name)&&a.permits(i,r).ok,l=[...a.log.all()].reverse().find(c=>!At(c)&&c.mergedInto!==void 0&&c.writes.includes(e)),d=l?.mergedInto!==void 0?a.graph.getNode(l.mergedInto):void 0;return(0,S.jsxs)("section",{"data-testid":"record-archived",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:12,padding:"12px 16px",border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,S.jsxs)("p",{style:{margin:0,flex:"1 1 16rem"},children:[(0,S.jsx)("strong",{children:"Archived."})," Kept with its ties and history, and out of lists, counts and rules.",d?(0,S.jsxs)(S.Fragment,{children:[" ","Merged into ",(0,S.jsx)(F,{to:Z(a.schema,d.kind,d.id),style:K,children:me(a.schema.tryDefinition(d.kind),d)}),"."]}):null]}),o?(0,S.jsx)("button",{type:"button",style:xe,"data-testid":"bring-it-back",onClick:()=>a.apply(i,r?{author:r}:{}),children:"Bring it back"}):null]})}var P=W(j(),1),Fo=(0,U.lazy)(Rt(()=>(__graviewPreload(import.meta.url,["./chunk.W7R2GFBW.js","./chunk.CN5WAKHJ.js","./chunk.UGFDSE37.js","./chunk.PYNYHNDS.js","./chunk.LPE4FLC6.js","./chunk.XEKLEHC3.js","./chunk.VZYCILPJ.js","./chunk.4QPVS2ZM.js","./chunk.RCM7NOPF.js","./chunk.Z7LDT55A.js","./chunk.47KHZCNG.js","./chunk.XQHDP5C3.js","./chunk.BFNVG5JE.js","./chunk.ZJMDLRC5.js","./chunk.2GDXNTY5.js","./chunk.ETOGQE2V.js","./chunk.O5JKDFDH.js","./chunk.YYIKSH2F.js","./chunk.LPBM5AES.js","./chunk.5RABSIF7.js","./chunk.NGDXH66B.js","./chunk.67WWRC6Y.js","./chunk.MB7LKKUD.js","./chunk.WVUJXDXZ.js","./chunk.N6MVK3KD.js","./chunk.I7XSDXQ3.js","./chunk.UHI3D7JC.js","./chunk.WVDKYUF3.js","./chunk.ZHLQWMV5.js","./chunk.TNESS3LQ.js","./chunk.GZHZLJBF.js","./chunk.42XSBKPO.js","./chunk.OJGHDWI6.js","./chunk.6FNMDAX5.js","./chunk.2FLPDPEL.js","./chunk.UUBYFBPN.js","./chunk.2RVUDRRY.js","./chunk.LLEFYJPJ.js","./chunk.FOQZADMA.js","./chunk.SDO3U72B.js","./chunk.V5MYKNL7.js","./chunk.AJZBJBMO.js"]),import("./chunk.QCWZSSNC.js")).then(t=>({default:t.DraftPage})))),Io={kind:"human"};function Wo({list:t,store:e}){let n=new Set(t.members.map(o=>o.kind)),a=t.total-t.members.length,r=n.size===1?[...n][0]:void 0;if(!r)return(0,P.jsx)("p",{className:"graview-spec-text graview-spec-more",children:`and ${a} more`});let i=ot(e.schema,r).toLowerCase();return(0,P.jsx)("p",{className:"graview-spec-text graview-spec-more",children:(0,P.jsx)(F,{to:`/${Y(e.schema,r)}`,className:"graview-spec-link graview-spec-see-all","data-testid":"see-all",children:t.total===e.graph.nodesOfKind(r).length?`See all ${gt(t.total)} ${i}`:`${gt(a)} more \xB7 all ${i}`})})}function Do({context:t,children:e}){let n=Ke(),a=t.store.schema,r=Vt("/").replace(/\/$/,""),i=(0,U.useMemo)(()=>({href:o=>`${r}${Z(a,o.kind,o.id)}`,go:o=>n(Z(a,o.kind,o.id)),more:o=>(0,P.jsx)(Wo,{list:o,store:t.store})}),[r,a,n,t.store]);return(0,P.jsx)(It.Provider,{value:i,children:(0,P.jsx)(Wr.Provider,{value:(t.titleLevel??(t.framed&&!t.barAbove?1:2))-1,children:e})})}function Ho({steering:t}){let e=Pe(),n=Ke(),a=`${e.pathname}${e.search}`;return(0,U.useLayoutEffect)(()=>t.at(a),[a,t]),(0,U.useLayoutEffect)(()=>{let r=o=>{o!==a&&n(o)};t.go.current=r;let i=t.pending?.current;return i!==void 0&&(t.pending.current=void 0,r(i)),()=>{t.go.current===r&&(t.go.current=void 0)}},[a,n,t]),null}function Ko({context:t,to:e}){let{pathname:n}=Pe(),a=ce(),r=(e??a)?.sayWhere,i=qo(t,n);return(0,U.useEffect)(()=>(r?.(i),()=>r?.(null)),[r,i]),null}function qo(t,e){let[n="",a,r]=e.split("/").filter(Boolean).map(o=>{try{return decodeURIComponent(o)}catch{return o}});if(r!==void 0)return"#";if(n==="places"&&a!==void 0){if(a===wn)return"#overview=1";let o=t.views?.places().find(l=>l.as===a);return o?`#focus=${encodeURIComponent(Fe(o.kind))}&view=${encodeURIComponent(o.as)}`:"#"}let i=$e(t.store.schema,n);return i?`#focus=${encodeURIComponent(a??Fe(i))}`:"#"}function Bo({onNavigate:t,path:e}){let n=Pe(),a=Nn(),r=Ke(),i=n.hash&&!n.hash.includes("=")?n.hash:"",o=`${n.pathname}${n.search}${i}`,l=(0,U.useRef)(t);l.current=t;let d=(0,U.useRef)(null);(0,U.useEffect)(()=>{let p=d.current;d.current=o,p!==null&&(o===p&&a!=="PUSH"||l.current?.(o,a==="POP"?"pop":a==="REPLACE"?"replace":"push"))},[n.key]);let c=(0,U.useRef)(e);return(0,U.useEffect)(()=>{e===void 0||e===c.current||(c.current=e,e!==o&&r(e))},[e]),null}function Ei({context:t,registry:e,page:n}){let a=Ue(),r=$e(t.store.schema,a.slug??""),i=n==="list"?zn:Qn,l=(r?e?.lookup(r,n):void 0)??i;return(0,P.jsx)(l,{context:t})}function Go({context:t,registry:e,children:n}){let a=(0,U.useRef)(null);return Da(a),(0,P.jsx)("div",{ref:a,"data-graview-face":"pages",style:{display:"contents"},children:(0,P.jsx)(hi,{context:t,registry:e,root:a,children:(0,P.jsx)(wi,{context:t,root:a,children:n})})})}function Vo(t){return t instanceof HTMLElement?t.isContentEditable||t.tagName==="TEXTAREA"||t.tagName==="SELECT"?!0:t.tagName==="INPUT"&&!["button","submit","reset","checkbox","radio","image","file","color","range"].includes(t.type):!1}function Uo(){let{pathname:t}=Pe(),e=Nn(),n=(0,U.useRef)(null);(0,U.useLayoutEffect)(()=>{if(e!=="POP"){for(let i=n.current?.parentElement;i;i=i.parentElement){let{overflowY:o}=getComputedStyle(i);if((o==="auto"||o==="scroll")&&i.scrollHeight>i.clientHeight){i.scrollTop=0;return}}window.scrollTo(0,0)}},[t]);let a=(0,U.useRef)(t),r=(0,U.useRef)(!1);return(0,U.useEffect)(()=>{if(!r.current&&t===a.current)return;r.current=!0;let i=document.activeElement;if(Vo(i))return;let o=n.current?.closest("main")??document.querySelector("main"),d=n.current?.closest("[data-graview-face]")?.querySelector("[data-graview-page-title]")??o?.querySelector("h1, h2")??null??o??null;d&&(d.hasAttribute("tabindex")||d.setAttribute("tabindex","-1"),d.focus({preventScroll:!0}))},[t]),(0,P.jsx)("span",{ref:n,hidden:!0,"data-graview-scroll-reset":""})}function Ni({context:t,children:e}){let n=Ke(),a=(0,U.useMemo)(()=>({record:(r,i)=>{let o=t.store.graph.getNode(r);o&&n(Ht(Z(t.store.schema,o.kind,r),{section:i?.section}))},place:(r,i)=>{let o=t.views?.places().find(l=>l.as===r);o&&n(Ht(ye(t,o),i))},list:(r,i)=>{t.store.schema.tryDefinition(r)&&n(Ht(`/${Y(t.store.schema,r)}`,i))},draft:()=>n("/~draft")}),[t,n]);return(0,P.jsx)(Ia.Provider,{value:a,children:e})}function jo(){let{pathname:t,search:e,hash:n}=Pe();return(0,U.useEffect)(()=>{let a=decodeURIComponent(n.replace(/^#/,""));if(!(!a||a.includes("=")))return gi(a)},[t,e,n]),null}function zo({context:t,Home:e}){let n=Pe(),a=t.views,r=n.key==="default"&&!(a&&Oa(a));(0,U.useEffect)(()=>{a&&Fa(a)},[a]);let i=r?Aa(t.views?.arrangement?.()?.first,t.store.schema,t.views?.places()??[]):void 0,o=i?.to==="place"?ye(t,i.place):i?.to==="kind"?`/${Y(t.store.schema,i.kind)}`:void 0;return o?(0,P.jsx)($n,{to:o,replace:!0}):(0,P.jsx)(e,{context:t})}function $i({context:t,registry:e}){let n=e?.lookupSurface("shell"),a=n!==void 0,r=a&&(e?.without().has("bar")??!1),i=a&&!r&&!t.embedded?{...t,barAbove:!0}:t,o=k=>n===void 0?(0,P.jsx)(Ut,{context:t,children:k}):r?(0,P.jsx)(n,{context:t,children:k}):(0,P.jsx)(Ut,{context:t,children:(0,P.jsx)(n,{context:i,children:k})}),l=e?.lookupSurface("home")??Un,d=e?.lookupSurface("problems")??_n,c=a?{...i,framed:!0}:t,[p,m]=(0,U.useState)(null),f=(0,U.useMemo)(()=>({onFind:m,find:!(e?.without().has("find")??!1),places:!(e?.without().has("places")??!1)}),[e]),u=(0,P.jsx)(Ni,{context:t,children:(0,P.jsx)(Go,{context:t,registry:e,children:o((0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(er,{face:"pages"}),(0,P.jsxs)(Do,{context:c,children:[(0,P.jsx)(Uo,{}),(0,P.jsx)(jo,{}),(0,P.jsxs)(ai,{children:[(e?.routes()??[]).map(({path:k,component:B})=>(0,P.jsx)(Le,{path:k,element:(0,P.jsx)(B,{context:c})},k)),(0,P.jsx)(Le,{path:"/",element:(0,P.jsx)(zo,{context:c,Home:l})}),(0,P.jsx)(Le,{path:"/problems",element:(0,P.jsx)(d,{context:c})}),(0,P.jsx)(Le,{path:"/~draft",element:(0,P.jsx)(U.Suspense,{fallback:null,children:(0,P.jsx)(Fo,{context:c})})}),(0,P.jsx)(Le,{path:"/search",element:(0,P.jsx)(jn,{context:c})}),(0,P.jsx)(Le,{path:"/map",element:(0,P.jsx)(Vn,{context:c})}),(0,P.jsx)(Le,{path:"/places",element:(0,P.jsx)(Bn,{context:c})}),Te(c).some(k=>k.as===wn)?null:(0,P.jsx)(Le,{path:Pa,element:(0,P.jsx)($n,{to:"/",replace:!0})}),(0,P.jsx)(Le,{path:"/places/:as",element:(0,P.jsx)(Gn,{context:c})}),(0,P.jsx)(Le,{path:"/:slug",element:(0,P.jsx)(Ei,{context:c,registry:e,page:"list"})}),(0,P.jsx)(Le,{path:"/:slug/:id",element:(0,P.jsx)(Ei,{context:c,registry:e,page:"record"})})]})]})]}))})});return t.embedded||!a||r?u:(0,P.jsx)(oi.Provider,{value:f,children:(0,P.jsx)(vr.Provider,{value:p,children:u})})}var _o=()=>typeof document>"u"?null:document.body;function Yo({context:t,registry:e,basename:n,initialPath:a,onNavigate:r,path:i,steering:o,firstLook:l}){let[d,c]=(0,U.useState)(void 0),p=d!==void 0&&d.from===t.principal?{...t,principal:d.seat}:t;(0,U.useState)(()=>p.views?Hr(p.views,p.store.schema,Cn(p.brand,p.store.schema)):void 0);let m=ce();ca({reader:p.locale??m?.locale,app:p.brand?.locale??p.app?.brand?.locale,readerTimeZone:p.timeZone??m?.timeZone,appTimeZone:p.brand?.timeZone??p.app?.brand?.timeZone});let f=p.principal??Io,u=Ma(p.store,f,p.history),B=(u.past&&u.live===p.store?u.past.store:p.store).seenBy(f),h=B===p.store?p:{...p,store:B};Ea(p.store,p.principal);let R=(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(Bo,{onNavigate:r,path:i}),o?(0,P.jsx)(Ho,{steering:o}):null,h.presence||m?(0,P.jsx)(Ko,{context:h,to:m}):null,(0,P.jsx)($i,{context:h,...e?{registry:e}:{}}),l?(0,P.jsx)(Kr,{firstLook:l,root:_o,app:Cn(p.brand,p.store.schema)}):null]}),G=h.views?(0,P.jsxs)(Na,{store:h.store,views:h.views,...h.principal?{principal:h.principal}:{},...h.brand?{brand:h.brand}:{},...h.locale?{locale:h.locale}:{},...h.timeZone?{timeZone:h.timeZone}:{},...h.settings?{settings:h.settings}:{},...h.presence&&!m?{presence:h.presence}:{},...h.people?{people:h.people}:{},...h.seats?{seats:h.seats}:{},onSeat:z=>m?m.takeSeat(z):c({from:t.principal,seat:z}),...h.onKeepLens?{onKeepLens:h.onKeepLens}:{},...h.ai?{ai:h.ai}:{},...h.subscriptions?{subscriptions:h.subscriptions}:{},...h.signIn?{signIn:h.signIn}:{},resolveApp:h.resolveApp??m?.resolveApp,linkedRecords:h.linkedRecords??m?.linkedRecords,...h.app?{app:h.app}:{},...h.menuSections?{menuSections:h.menuSections}:{},children:[R,(0,P.jsx)(Ni,{context:h,children:(0,P.jsx)(mi,{context:h})})]}):R,M=(0,P.jsx)(Ta.Provider,{value:u,children:G}),V=h.files?(0,P.jsx)(La.Provider,{value:h.files,children:M}):M;if(a!==void 0){let z=n===void 0?a:`${n.replace(/\/$/,"")}${a}`;return(0,P.jsx)(ni,{initialEntries:[z],...n===void 0?{}:{basename:n},children:V})}return(0,P.jsx)(ri,{...n===void 0?{}:{basename:n},children:V})}export{Xi as a,Yo as b};
117
+ `;function Co({children:t}){return(0,b.jsx)("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:40,minWidth:0},children:t})}var Ro=(t,e)=>e?{sort:{by:e,direction:"desc"}}:t?{sort:{by:"label",direction:"asc"}}:{};function Lo(t,e,n){let a=Ct({...t.get("sort")?{sort:t.get("sort")}:{},...t.get("filter")?{filter:t.get("filter")}:{},...t.get("group")?{group:t.get("group")}:{},...t.get("q")?{q:t.get("q")}:{},...t.get("archived")?{archived:t.get("archived")}:{}}),r=[...a.filter??[]],i=t.get("by"),o=a.group??(i?{by:i}:void 0);for(let d of n){let c=t.get(d);c&&r.push({key:d,value:c})}let l=t.get("with");return l&&r.push({key:l,value:"*"}),t.get("past")==="1"&&!r.some(d=>d.key==="is")&&r.push({key:"is",value:"any"}),Rn({...a.sort?{sort:a.sort}:{},...a.query?{query:a.query}:{},...r.length>0?{filter:r}:{},...o?{group:o}:{},...a.archived!==void 0?{archived:a.archived}:{}},e)}function Ai(t,e,n){let a=new URLSearchParams(t);return a.set(e,n),a.delete("past"),`?${a.toString()}`}function To({name:t,title:e,panel:n,open:a,onOpen:r}){return(0,b.jsxs)("button",{type:"button","data-testid":`act-open-${t}`,"data-graview-act":t,"aria-expanded":a,"aria-controls":n,onClick:()=>{r(!a),a||requestAnimationFrame(()=>document.getElementById(n)?.querySelector("input, select, textarea, button")?.focus())},style:{...Se,minHeight:28,margin:"-4px 0",padding:"0 2px",border:0,background:"none",font:"inherit",fontWeight:600,color:"var(--graview-ink)",cursor:"pointer"},children:[(0,b.jsx)("span",{"aria-hidden":"true",style:{marginRight:6},children:a?"\u2212":"+"}),e]})}function Mo({name:t,id:e,description:n,open:a,onClose:r,children:i}){return(0,b.jsxs)("div",{"data-testid":`act-${t}`,id:e,hidden:!a,onKeyDown:o=>{o.key==="Escape"&&(o.preventDefault(),r(),document.querySelector(`[aria-controls="${e}"]`)?.focus())},style:a?{display:"grid",gap:12,padding:"4px 0 12px"}:void 0,children:[n?(0,b.jsx)("p",{style:{...C,margin:0,maxWidth:"58ch"},children:n}):null,i]})}function Eo({to:t,label:e}){let n=(0,Me.useRef)(null);return Fr(n),(0,b.jsx)(F,{ref:n,to:t,"aria-label":e,style:{position:"absolute",inset:0,borderRadius:6}})}var tt=W(Ie(),1);var ht=W(Ie(),1);var D=W(j(),1);function _n({context:t}){let{store:e,brand:n,invariantContext:a,principal:r}=t;ne(e);let i=e.violations(a),o=e.allInvariants(),l=Lt(e,i),d=qa(e.schema,o);return(0,D.jsxs)(ae,{context:t,children:[(0,D.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,D.jsx)(ie,{context:t,children:i.length===0?"All rules hold":"What is broken"}),(0,D.jsx)("p",{style:re,"data-testid":"problems-count",children:i.length===0?"Every declared rule is satisfied by what is here.":ha(i)})]}),(0,D.jsx)(Si,{context:t}),l.map((c,p)=>{let m=c.nodeIds[0],f=m?e.graph.getNode(m):void 0;return(0,D.jsxs)("section",{style:{display:"grid",gap:10,padding:"16px 18px",borderLeft:"3px solid var(--graview-warn)",background:"var(--graview-panel-warning)",borderRadius:"0 var(--graview-radius, 12px) var(--graview-radius, 12px) 0"},children:[c.line?null:(0,D.jsx)(Jt,{violation:c,schema:e.schema,...n?{brand:n}:{}}),f?(0,D.jsxs)("p",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:8},children:[(0,D.jsx)(fe,{kind:f.kind,brand:n,schema:e.schema,size:7}),(0,D.jsx)(F,{to:Z(e.schema,f.kind,f.id),style:K,children:me(e.schema.tryDefinition(f.kind),f)})]}):null,c.line?(0,D.jsx)(Jt,{violation:c,schema:e.schema,...n?{brand:n}:{}}):null,(0,D.jsx)(en,{store:e,repairs:c.repairs,...r?{principal:r}:{}})]},p)}),o.length>0?(0,D.jsxs)("section",{style:{...te,display:"grid",gap:12},"data-testid":"rules",children:[(0,D.jsx)("h2",{style:J,children:"The rules"}),(0,D.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:o.map(c=>{let p=i.filter(u=>u.invariant===c.name).length,m=d.get(c.name),f=c.label??c.name;return(0,D.jsxs)("li",{"data-graview-rule":c.name,style:{display:"grid",gap:2},children:[(0,D.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:12,rowGap:2},children:[m?(0,D.jsx)(Tt,{line:m,schema:e.schema,...n?{brand:n}:{},style:{flex:"1 1 18rem"}}):(0,D.jsx)("span",{style:{flex:"1 1 18rem",fontWeight:550},children:f}),(0,D.jsx)("span",{style:{...C,color:p>0?"var(--graview-warn)":"var(--graview-ink-faint)"},children:p===0?"holds":`broken in ${p} ${p===1?"place":"places"}`})]}),m&&f.trim().length>0?(0,D.jsx)("span",{style:C,children:f}):null]},c.name)})})]}):null]})}function Jt({violation:t,schema:e,brand:n}){if(!t.line)return(0,D.jsx)("p",{style:{margin:0,color:"var(--graview-warn)",fontWeight:550},children:t.message});let a=Ga(t),r=Ba(t);return r?(0,D.jsxs)("div",{style:{display:"grid",gap:4},"data-testid":"problem-line",children:[(0,D.jsx)("p",{style:{margin:0,color:"var(--graview-warn)",fontWeight:550},"data-testid":"problem-says",children:r}),a?(0,D.jsx)("span",{style:C,children:a}):null,(0,D.jsxs)("details",{"data-testid":"problem-judged",style:C,children:[(0,D.jsx)("summary",{style:{cursor:"pointer",width:"fit-content",minHeight:24},children:"How it is judged"}),(0,D.jsx)(Tt,{line:t.line,schema:e,...n?{brand:n}:{},lead:"none"})]})]}):(0,D.jsxs)("div",{style:{display:"grid",gap:2},"data-testid":"problem-line",children:[(0,D.jsx)(Tt,{line:t.line,schema:e,...n?{brand:n}:{},lead:"none",style:{color:"var(--graview-warn)"}}),a?(0,D.jsx)("span",{style:C,children:a}):null]})}function en({store:t,repairs:e,principal:n}){let[a,r]=(0,ht.useState)(null),[i,o]=(0,ht.useState)(null),l=(0,ht.useRef)([]);if(e.length===0)return null;let d=a===null?null:e[a],c=d&&(d.missing??[]).length>0?t.allMutations().find(p=>p.name===d.mutation):void 0;return(0,D.jsxs)("div",{style:{display:"grid",gap:10},"data-testid":"repairs",children:[(0,D.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:e.map((p,m)=>{let f=(p.missing??[]).length>0,u=t.permits({name:p.mutation,args:{...p.args}},n);return u.ok?(0,D.jsx)("button",{ref:k=>{l.current[m]=k},type:"button","data-graview-repair":p.mutation,"data-graview-asks":f||void 0,"aria-expanded":f?a===m:void 0,onClick:()=>{if(o(null),f){r(a===m?null:m);return}r(null);try{t.apply({name:p.mutation,args:{...p.args}},n?{author:n}:{})}catch(k){o(lt(t.schema,t.allMutations(),k))}},style:xe,children:f?`${p.label} \u2026`:p.label},m):(0,D.jsxs)("p",{"data-testid":"withheld","data-withheld":u.refusal.wouldNeed.join(",")||"nobody",style:{...C,margin:0},children:[(0,D.jsx)("s",{children:p.label})," \u2014 ",u.refusal.message]},m)})}),c&&d?(0,D.jsx)(We,{store:t,mutation:c,prefilled:{...d.args},only:d.missing??[],label:d.label,onDone:()=>{let p=a;r(null),requestAnimationFrame(()=>{let m=p===null?null:l.current[p];if(m?.isConnected){m.focus();return}let f=document.querySelector("[data-graview-page-title]")??document.querySelector("main h1, main h2");f&&(f.hasAttribute("tabindex")||(f.tabIndex=-1),f.focus())})},...n?{principal:n}:{}}):null,d&&!c&&(d.missing??[]).length>0?(0,D.jsxs)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:Mn},children:["\u201C",d.label,"\u201D names ",d.mutation,", which this app does not declare."]}):null,i?(0,D.jsx)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:Mn},children:i}):null]})}var Yn=W(Ie(),1);var je=W(j(),1);function Ti({store:t,link:e,principal:n}){let[a,r]=(0,Yn.useState)(!1),[i,o]=(0,Yn.useState)(null),l=Xa(e);return(0,je.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[(0,je.jsx)("button",{type:"button","data-graview-provisional":"",title:l,"aria-label":`Unsure link: ${l}`,"aria-expanded":a,onClick:()=>r(!a),style:{border:"1px dashed var(--graview-ink-muted)",borderRadius:999,background:"transparent",color:"var(--graview-ink-muted)",font:"inherit",fontSize:"0.75rem",lineHeight:1,padding:"2px 6px",cursor:"pointer"},children:"unsure"}),a?(0,je.jsxs)("span",{style:{...C,display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,je.jsx)("span",{children:l}),(0,je.jsx)("button",{type:"button",style:{...xe,padding:"4px 10px"},onClick:()=>{try{t.apply({name:va,args:{kind:e.edge.kind,from:e.edge.from,to:e.edge.to}},n?{author:n}:{}),r(!1)}catch(d){o(lt(t.schema,t.allMutations(),d))}},children:"Keep this link"}),i?(0,je.jsx)("span",{role:"alert",children:i}):null]}):null]})}var ve=W(j(),1);function Mi({nodeId:t,node:e,field:n,inPlace:a,labelStyle:r=ke}){return n.files?(0,ve.jsx)(Ge,{as:"field",read:!a,nodeId:t,field:n.key,label:n.label,files:n.files,labelStyle:r,style:{gap:4}}):n.long?(0,ve.jsx)(Tr,{nodeId:t,field:n.key,label:n.label,value:n.value,markdown:n.markdown,style:{gridColumn:"1 / -1",gap:4},labelStyle:r,valueStyle:{lineHeight:1.6}}):(0,ve.jsxs)("div",{style:{display:"grid",gap:2,minWidth:0,alignContent:"start"},children:[(0,ve.jsx)("dt",{style:r,children:n.label}),(0,ve.jsx)("dd",{style:{margin:0,overflowWrap:"anywhere",minWidth:0},children:n.linked?(0,ve.jsx)(rr,{relation:n.linked.relation,refs:n.linked.refs,...a?{nodeId:t,field:n.key}:{}}):n.app?(0,ve.jsx)(Ot,{address:n.app,as:"record",...a?{nodeId:t,field:n.key}:{}}):n.href?(0,ve.jsx)(Lr,{href:n.href,field:n.key,value:n.value,stored:n.stored,...a?{nodeId:t}:{}}):a?(0,ve.jsxs)(ve.Fragment,{children:[(0,ve.jsx)(Ft,{nodeId:t,field:n.key,value:n.value,stored:n.stored}),n.repeats?(0,ve.jsx)(sr,{nodeId:t,field:n.key,start:e?.[n.key],value:e?.[`${n.key}Repeat`],label:`${n.label} repeats`}):null]}):n.value})]})}var S=W(j(),1),No=[];function Qn({context:t}){let{store:e,brand:n,principal:a,invariantContext:r}=t;ne(e);let i=ce()!==null,o=Ue(),l=decodeURIComponent(o.id??""),d=si(e,l,{...a?{principal:a}:{},...r?{context:r}:{}}),c=Lt(e,d?.violations??No),[p,m]=(0,tt.useState)(null),[f,u]=(0,tt.useState)(!1),[k,B]=(0,tt.useState)(null),h=(0,tt.useRef)(null),R=(0,tt.useRef)(null),G=g=>{(h.current?.parentElement?.querySelector(`[data-affordance="${g.replace(/["\\]/g,"\\$&")}"]`)??h.current)?.focus()};if(!d)return(0,S.jsx)(ae,{context:t,children:(0,S.jsx)(ie,{context:t,children:"Nothing lives at this address."})});let M=e.graph.getNode(l),V=e.schema.tryDefinition(d.kind),z=V?.describe&&M?Va(V,M):null,se=[...e.log.all()].filter(g=>!At(g)&&(g.writes.includes(l)||g.reads.includes(l))).slice(-8).reverse(),ue=e.log.all().find(g=>!At(g)&&g.undoes===void 0&&g.primitives.some(A=>A.op==="add-node"&&A.node.id===l)),I=d.actions.affordances.filter(g=>g.provider!=="invariant"),_=I.filter(g=>g.destructive||g.setsAside),oe=f||_.length<2?I:I.filter(g=>!_.includes(g)),we=t.views?.lookup(d.kind,{cardinality:"one",fidelity:"full"}),le=we!==void 0&&!st(we)?we:void 0,ge=le&&M?Wt(we,M,e.graph):void 0,w=ge?d.fields.filter(g=>!ge.fields.has(g.key)):d.fields,y=ge?d.links.flatMap(g=>{let A=g.targets.filter(O=>!ge.records.has(O.id));return A.length>0?[{...g,targets:A}]:[]}):d.links,L=le!==void 0&&Wa(we),$=i&&tr(V).length>0;return(0,S.jsxs)(ae,{context:t,children:[(0,S.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,S.jsxs)("p",{style:{...ke,display:"flex",alignItems:"center",gap:8},children:[(0,S.jsx)(fe,{kind:d.kind,brand:n,schema:e.schema,size:8}),(0,S.jsx)(F,{to:`/${Y(e.schema,d.kind)}`,style:Se,children:Q(e,d.kind)})]}),(0,S.jsx)(ie,{context:t,children:i&&M?.label===d.label?(0,S.jsx)(Ft,{nodeId:l,field:"label",value:d.label,said:d.label}):d.label}),z&&z!==d.label?(0,S.jsx)("p",{style:re,children:z}):null,ue?.lineage?(0,S.jsxs)("p",{style:{...C,margin:0},"data-testid":"record-lineage",children:["Made by ",ft(ue,a,{graph:e.graph,schema:e.schema,...t.seats?{seats:t.seats}:{},...t.people?{people:t.people}:{}}),", ",Sn(ue.lineage)]}):null,(0,S.jsx)(Gt,{context:t,stop:`#focus=${encodeURIComponent(l)}`,style:{...K,...C},"data-testid":"spatial-link"}),i&&M?(0,S.jsx)(Pn,{choices:[{on:"changed",record:l},{on:"act",record:l},{on:"reaches",kind:d.kind,condition:"",record:l}],label:"Notify me when this changes",testId:"record-notify",style:{...xe,...C,justifySelf:"start"}}):null,Te(t).some(g=>g.kind===d.kind||g.across===d.kind)?(0,S.jsxs)("p",{style:{...C,margin:0},"data-testid":"seen-in",children:["Seen in:"," ",Te(t).filter(g=>g.kind===d.kind||g.across===d.kind).map((g,A)=>(0,S.jsxs)("span",{children:[A>0?(0,S.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,(0,S.jsx)(F,{to:ye(t,g),style:K,children:g.title})," ",(0,S.jsx)(Gt,{context:t,stop:`#view=${encodeURIComponent(g.as)}`,style:{...K,...C,display:"inline-block",minWidth:24,textAlign:"center"},title:`${g.title}, in the scene`,label:`${g.title}, in the scene`,children:(0,S.jsx)("span",{"aria-hidden":"true",children:"\u2197"})})]},Xe(g)))]}):null]}),M&&fa(M)?(0,S.jsx)(Oo,{context:t,id:l,kind:d.kind}):null,M&&wa(e,l)?(0,S.jsx)($o,{context:t,id:l,kind:d.kind}):null,le&&M?(0,S.jsx)("section",{"data-testid":"record-view",style:{display:"grid",minWidth:0},children:(0,S.jsx)(Ir,{children:(0,S.jsx)(le,{node:M,cardinality:"one",fidelity:"full",mode:"fullscreen",selected:!1,...d.violations.length>0?{flagged:[l]}:{}})})}):null,d.violations.length>0?(0,S.jsx)("section",{"data-testid":"record-violations",style:{display:"grid",gap:12,padding:"16px 18px",borderLeft:"3px solid var(--graview-warn)",background:"var(--graview-panel-warning)",borderRadius:"0 var(--graview-radius, 12px) var(--graview-radius, 12px) 0"},children:c.map((g,A)=>(0,S.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,S.jsx)(Jt,{violation:g,schema:e.schema,...n?{brand:n}:{}}),(0,S.jsx)(en,{store:e,repairs:li(d.actions,g.repairs),...a?{principal:a}:{}})]},A))}):null,!L&&(w.length>0||$)?(0,S.jsxs)("section",{style:{...te,display:"grid",gap:14},"data-testid":"record-fields",children:[(0,S.jsx)("h2",{style:J,children:"The facts"}),ja(V,w).map((g,A)=>{let O=(0,S.jsx)("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"14px 24px"},children:g.fields.map(ee=>(0,S.jsx)(Mi,{nodeId:l,node:M,field:ee,inPlace:i},ee.key))});return g.title?(0,S.jsxs)("section",{style:{display:"grid",gap:10,minWidth:0},children:[(0,S.jsx)("h3",{"data-graview-field-group":g.title,style:{...J,fontSize:"inherit"},children:g.title}),O]},A):(0,S.jsx)("div",{children:O},A)}),$?(0,S.jsx)(Ge,{as:"unfilled",nodeId:l,skip:[...ge?.fields??[]],labelStyle:ke,style:{gap:4}}):null]}):null,(L?[]:y).map(g=>(0,S.jsxs)("section",{style:{...te,display:"grid",gap:10},children:[(0,S.jsx)("p",{style:ke,children:Jr(e,g)}),g.description?(0,S.jsx)("h2",{style:J,children:Re(g.description)}):(0,S.jsxs)("h2",{style:J,"aria-label":be(g.edgeKind),children:[g.direction==="in"?"\u2190 ":"\u2192 ",be(g.edgeKind)]}),(0,S.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"6px 18px"},children:g.targets.map(A=>{let O=Ja(e,g.direction==="in"?{kind:g.edgeKind,from:A.id,to:l}:{kind:g.edgeKind,from:l,to:A.id});return(0,S.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,S.jsx)(fe,{kind:A.kind,brand:n,schema:e.schema,size:7}),(0,S.jsxs)(F,{to:Z(e.schema,A.kind,A.id),style:K,children:[A.label,A.apart?(0,S.jsxs)("span",{style:C,children:[" \xB7 ",A.apart]}):null]}),O?.provisional?(0,S.jsx)(Ti,{store:e,link:O,...a?{principal:a}:{}}):null]},A.id)})}),(g.direction==="out"&&e.schema.edge(g.edgeKind)?.cardinality==="one"?[]:[...new Set(g.targets.map(A=>A.kind))]).map(A=>(0,S.jsxs)(F,{to:`/${Y(e.schema,A)}?${encodeURIComponent(g.edgeKind)}=${encodeURIComponent(l)}`,style:{...K,...C},"data-testid":"related-all",children:["Sort and filter ",g.description??`these ${Q(e,A).toLowerCase()}`,g.targets.some(O=>O.kind!==A)?` (${Q(e,A).toLowerCase()})`:""," ",(0,S.jsx)("span",{"aria-hidden":"true",children:"\u2192"})]},A))]},`${g.edgeKind}|${g.direction}|${g.description??""}`)),!L&&(I.length>0||d.actions.withheld.length>0)?(0,S.jsxs)("section",{style:{...te,display:"grid",gap:14},"data-testid":"record-actions",children:[(0,S.jsx)("h2",{style:J,ref:h,tabIndex:-1,children:"What can be done"}),(0,S.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:[oe.map(g=>{let A=p===g.id;return(0,S.jsx)("button",{type:"button","data-affordance":g.id,"data-rank":g.rank,"data-graview-act":g.mutation,autoFocus:f&&g===_[0],"aria-expanded":A,onClick:()=>{m(A?null:g.id),A||requestAnimationFrame(()=>R.current?.querySelector("input:not([type=hidden]), select, textarea, button")?.focus())},style:{...xe,...A?{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"}:{}},children:g.label},g.id)}),oe.length<I.length?(0,S.jsxs)("button",{type:"button","aria-expanded":!1,onClick:()=>u(!0),style:{...xe,...C},"data-testid":"record-actions-more",children:["Show ",I.length-oe.length," more"]}):null]}),I.map(g=>{if(p!==g.id)return null;let A=e.allMutations().find(O=>O.name===g.mutation);return A?(0,S.jsxs)("div",{ref:R,onKeyDown:O=>{if(O.key!=="Escape"||O.defaultPrevented)return;O.preventDefault(),m(null);let ee=g.id;requestAnimationFrame(()=>G(ee))},style:{display:"grid",gap:10,padding:18,border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,S.jsx)("h3",{style:J,children:g.label}),A.description?(0,S.jsx)("p",{style:{...C,margin:0},children:A.description}):null,(0,S.jsx)(We,{store:e,mutation:A,prefilled:g.args,open:g.open,label:g.label,onDone:()=>{m(null),B(g.mutation);let O=g.id;requestAnimationFrame(()=>G(O))},...a?{principal:a}:{}})]},g.id):null}),i&&k!==null&&p===null?(0,S.jsx)(Pn,{choices:[{on:"act",act:k,record:l},{on:"act",act:k}],label:"Notify me when someone else does this",testId:"notify-after-act",style:{...xe,...C,justifySelf:"start"}}):null,(0,S.jsx)(Qt,{context:t,withheld:d.actions.withheld})]}):null,i?(0,S.jsx)(Xr,{id:l,style:te,headingStyle:J}):null,se.length>0?(0,S.jsxs)("section",{style:{...te,display:"grid",gap:10},"data-testid":"record-history",children:[(0,S.jsx)("h2",{style:J,children:"What has happened"}),(0,S.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:se.map(g=>(0,S.jsxs)("li",{style:C,children:[(0,S.jsx)("span",{style:{color:"var(--graview-ink)"},children:g.intent}),g.lineage?(0,S.jsxs)("span",{"data-graview-lineage":"",children:[" \xB7 ",Sn(g.lineage)]}):null," \u2014 ",ft(g,a,{graph:e.graph,schema:e.schema,...t.seats?{seats:t.seats}:{},...t.people?{people:t.people}:{}})]},g.id))})]}):null]})}function $o({context:t,id:e,kind:n}){let{store:a,principal:r}=t,i={name:`allow-tidying-${n}`,args:{id:e}},o=a.allMutations().some(l=>l.name===i.name)&&a.permits(i,r).ok;return(0,S.jsxs)("section",{"data-testid":"record-left-alone",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:12,padding:"12px 16px",border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,S.jsxs)("p",{style:{margin:0,flex:"1 1 16rem"},children:[(0,S.jsx)("strong",{children:"Left alone."})," Nothing automated changes it; tidying passes it by."]}),o?(0,S.jsx)("button",{type:"button",style:xe,"data-testid":"allow-tidying",onClick:()=>a.apply(i,r?{author:r}:{}),children:"Allow tidying again"}):null]})}function Oo({context:t,id:e,kind:n}){let{store:a,principal:r}=t,i={name:`unarchive-${n}`,args:{id:e}},o=a.allMutations().some(c=>c.name===i.name)&&a.permits(i,r).ok,l=[...a.log.all()].reverse().find(c=>!At(c)&&c.mergedInto!==void 0&&c.writes.includes(e)),d=l?.mergedInto!==void 0?a.graph.getNode(l.mergedInto):void 0;return(0,S.jsxs)("section",{"data-testid":"record-archived",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:12,padding:"12px 16px",border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,S.jsxs)("p",{style:{margin:0,flex:"1 1 16rem"},children:[(0,S.jsx)("strong",{children:"Archived."})," Kept with its ties and history, and out of lists, counts and rules.",d?(0,S.jsxs)(S.Fragment,{children:[" ","Merged into ",(0,S.jsx)(F,{to:Z(a.schema,d.kind,d.id),style:K,children:me(a.schema.tryDefinition(d.kind),d)}),"."]}):null]}),o?(0,S.jsx)("button",{type:"button",style:xe,"data-testid":"bring-it-back",onClick:()=>a.apply(i,r?{author:r}:{}),children:"Bring it back"}):null]})}var P=W(j(),1),Fo=(0,U.lazy)(Rt(()=>(__graviewPreload(import.meta.url,["./chunk.MUPO5S2A.js","./chunk.JYJ4LZJJ.js","./chunk.UGFDSE37.js","./chunk.USZPOOLZ.js","./chunk.C4TSM4W5.js","./chunk.XEKLEHC3.js","./chunk.53CDFJNM.js","./chunk.4QPVS2ZM.js","./chunk.RCM7NOPF.js","./chunk.Z7LDT55A.js","./chunk.BQRAIU5R.js","./chunk.57R2GXXN.js","./chunk.BFNVG5JE.js","./chunk.AIZQBPGU.js","./chunk.V3V47QRE.js","./chunk.5P556A7W.js","./chunk.QHYXXZRD.js","./chunk.BELCPW66.js","./chunk.6YPLZNVT.js","./chunk.5RABSIF7.js","./chunk.NGDXH66B.js","./chunk.67WWRC6Y.js","./chunk.MB7LKKUD.js","./chunk.WVUJXDXZ.js","./chunk.N6MVK3KD.js","./chunk.I7XSDXQ3.js","./chunk.UHI3D7JC.js","./chunk.WVDKYUF3.js","./chunk.ZHLQWMV5.js","./chunk.TNESS3LQ.js","./chunk.GZHZLJBF.js","./chunk.42XSBKPO.js","./chunk.OJGHDWI6.js","./chunk.6FNMDAX5.js","./chunk.2FLPDPEL.js","./chunk.UUBYFBPN.js","./chunk.2RVUDRRY.js","./chunk.JHEVGLKB.js","./chunk.FOQZADMA.js","./chunk.SDO3U72B.js","./chunk.V5MYKNL7.js","./chunk.AJZBJBMO.js"]),import("./chunk.4EEWBCT2.js")).then(t=>({default:t.DraftPage})))),Io={kind:"human"};function Wo({list:t,store:e}){let n=new Set(t.members.map(o=>o.kind)),a=t.total-t.members.length,r=n.size===1?[...n][0]:void 0;if(!r)return(0,P.jsx)("p",{className:"graview-spec-text graview-spec-more",children:`and ${a} more`});let i=ot(e.schema,r).toLowerCase();return(0,P.jsx)("p",{className:"graview-spec-text graview-spec-more",children:(0,P.jsx)(F,{to:`/${Y(e.schema,r)}`,className:"graview-spec-link graview-spec-see-all","data-testid":"see-all",children:t.total===e.graph.nodesOfKind(r).length?`See all ${gt(t.total)} ${i}`:`${gt(a)} more \xB7 all ${i}`})})}function Do({context:t,children:e}){let n=Ke(),a=t.store.schema,r=Vt("/").replace(/\/$/,""),i=(0,U.useMemo)(()=>({href:o=>`${r}${Z(a,o.kind,o.id)}`,go:o=>n(Z(a,o.kind,o.id)),more:o=>(0,P.jsx)(Wo,{list:o,store:t.store})}),[r,a,n,t.store]);return(0,P.jsx)(It.Provider,{value:i,children:(0,P.jsx)(Wr.Provider,{value:(t.titleLevel??(t.framed&&!t.barAbove?1:2))-1,children:e})})}function Ho({steering:t}){let e=Pe(),n=Ke(),a=`${e.pathname}${e.search}`;return(0,U.useLayoutEffect)(()=>t.at(a),[a,t]),(0,U.useLayoutEffect)(()=>{let r=o=>{o!==a&&n(o)};t.go.current=r;let i=t.pending?.current;return i!==void 0&&(t.pending.current=void 0,r(i)),()=>{t.go.current===r&&(t.go.current=void 0)}},[a,n,t]),null}function Ko({context:t,to:e}){let{pathname:n}=Pe(),a=ce(),r=(e??a)?.sayWhere,i=qo(t,n);return(0,U.useEffect)(()=>(r?.(i),()=>r?.(null)),[r,i]),null}function qo(t,e){let[n="",a,r]=e.split("/").filter(Boolean).map(o=>{try{return decodeURIComponent(o)}catch{return o}});if(r!==void 0)return"#";if(n==="places"&&a!==void 0){if(a===wn)return"#overview=1";let o=t.views?.places().find(l=>l.as===a);return o?`#focus=${encodeURIComponent(Fe(o.kind))}&view=${encodeURIComponent(o.as)}`:"#"}let i=$e(t.store.schema,n);return i?`#focus=${encodeURIComponent(a??Fe(i))}`:"#"}function Bo({onNavigate:t,path:e}){let n=Pe(),a=Nn(),r=Ke(),i=n.hash&&!n.hash.includes("=")?n.hash:"",o=`${n.pathname}${n.search}${i}`,l=(0,U.useRef)(t);l.current=t;let d=(0,U.useRef)(null);(0,U.useEffect)(()=>{let p=d.current;d.current=o,p!==null&&(o===p&&a!=="PUSH"||l.current?.(o,a==="POP"?"pop":a==="REPLACE"?"replace":"push"))},[n.key]);let c=(0,U.useRef)(e);return(0,U.useEffect)(()=>{e===void 0||e===c.current||(c.current=e,e!==o&&r(e))},[e]),null}function Ei({context:t,registry:e,page:n}){let a=Ue(),r=$e(t.store.schema,a.slug??""),i=n==="list"?zn:Qn,l=(r?e?.lookup(r,n):void 0)??i;return(0,P.jsx)(l,{context:t})}function Go({context:t,registry:e,children:n}){let a=(0,U.useRef)(null);return Da(a),(0,P.jsx)("div",{ref:a,"data-graview-face":"pages",style:{display:"contents"},children:(0,P.jsx)(hi,{context:t,registry:e,root:a,children:(0,P.jsx)(wi,{context:t,root:a,children:n})})})}function Vo(t){return t instanceof HTMLElement?t.isContentEditable||t.tagName==="TEXTAREA"||t.tagName==="SELECT"?!0:t.tagName==="INPUT"&&!["button","submit","reset","checkbox","radio","image","file","color","range"].includes(t.type):!1}function Uo(){let{pathname:t}=Pe(),e=Nn(),n=(0,U.useRef)(null);(0,U.useLayoutEffect)(()=>{if(e!=="POP"){for(let i=n.current?.parentElement;i;i=i.parentElement){let{overflowY:o}=getComputedStyle(i);if((o==="auto"||o==="scroll")&&i.scrollHeight>i.clientHeight){i.scrollTop=0;return}}window.scrollTo(0,0)}},[t]);let a=(0,U.useRef)(t),r=(0,U.useRef)(!1);return(0,U.useEffect)(()=>{if(!r.current&&t===a.current)return;r.current=!0;let i=document.activeElement;if(Vo(i))return;let o=n.current?.closest("main")??document.querySelector("main"),d=n.current?.closest("[data-graview-face]")?.querySelector("[data-graview-page-title]")??o?.querySelector("h1, h2")??null??o??null;d&&(d.hasAttribute("tabindex")||d.setAttribute("tabindex","-1"),d.focus({preventScroll:!0}))},[t]),(0,P.jsx)("span",{ref:n,hidden:!0,"data-graview-scroll-reset":""})}function Ni({context:t,children:e}){let n=Ke(),a=(0,U.useMemo)(()=>({record:(r,i)=>{let o=t.store.graph.getNode(r);o&&n(Ht(Z(t.store.schema,o.kind,r),{section:i?.section}))},place:(r,i)=>{let o=t.views?.places().find(l=>l.as===r);o&&n(Ht(ye(t,o),i))},list:(r,i)=>{t.store.schema.tryDefinition(r)&&n(Ht(`/${Y(t.store.schema,r)}`,i))},draft:()=>n("/~draft")}),[t,n]);return(0,P.jsx)(Ia.Provider,{value:a,children:e})}function jo(){let{pathname:t,search:e,hash:n}=Pe();return(0,U.useEffect)(()=>{let a=decodeURIComponent(n.replace(/^#/,""));if(!(!a||a.includes("=")))return gi(a)},[t,e,n]),null}function zo({context:t,Home:e}){let n=Pe(),a=t.views,r=n.key==="default"&&!(a&&Oa(a));(0,U.useEffect)(()=>{a&&Fa(a)},[a]);let i=r?Aa(t.views?.arrangement?.()?.first,t.store.schema,t.views?.places()??[]):void 0,o=i?.to==="place"?ye(t,i.place):i?.to==="kind"?`/${Y(t.store.schema,i.kind)}`:void 0;return o?(0,P.jsx)($n,{to:o,replace:!0}):(0,P.jsx)(e,{context:t})}function $i({context:t,registry:e}){let n=e?.lookupSurface("shell"),a=n!==void 0,r=a&&(e?.without().has("bar")??!1),i=a&&!r&&!t.embedded?{...t,barAbove:!0}:t,o=k=>n===void 0?(0,P.jsx)(Ut,{context:t,children:k}):r?(0,P.jsx)(n,{context:t,children:k}):(0,P.jsx)(Ut,{context:t,children:(0,P.jsx)(n,{context:i,children:k})}),l=e?.lookupSurface("home")??Un,d=e?.lookupSurface("problems")??_n,c=a?{...i,framed:!0}:t,[p,m]=(0,U.useState)(null),f=(0,U.useMemo)(()=>({onFind:m,find:!(e?.without().has("find")??!1),places:!(e?.without().has("places")??!1)}),[e]),u=(0,P.jsx)(Ni,{context:t,children:(0,P.jsx)(Go,{context:t,registry:e,children:o((0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(er,{face:"pages"}),(0,P.jsxs)(Do,{context:c,children:[(0,P.jsx)(Uo,{}),(0,P.jsx)(jo,{}),(0,P.jsxs)(ai,{children:[(e?.routes()??[]).map(({path:k,component:B})=>(0,P.jsx)(Le,{path:k,element:(0,P.jsx)(B,{context:c})},k)),(0,P.jsx)(Le,{path:"/",element:(0,P.jsx)(zo,{context:c,Home:l})}),(0,P.jsx)(Le,{path:"/problems",element:(0,P.jsx)(d,{context:c})}),(0,P.jsx)(Le,{path:"/~draft",element:(0,P.jsx)(U.Suspense,{fallback:null,children:(0,P.jsx)(Fo,{context:c})})}),(0,P.jsx)(Le,{path:"/search",element:(0,P.jsx)(jn,{context:c})}),(0,P.jsx)(Le,{path:"/map",element:(0,P.jsx)(Vn,{context:c})}),(0,P.jsx)(Le,{path:"/places",element:(0,P.jsx)(Bn,{context:c})}),Te(c).some(k=>k.as===wn)?null:(0,P.jsx)(Le,{path:Pa,element:(0,P.jsx)($n,{to:"/",replace:!0})}),(0,P.jsx)(Le,{path:"/places/:as",element:(0,P.jsx)(Gn,{context:c})}),(0,P.jsx)(Le,{path:"/:slug",element:(0,P.jsx)(Ei,{context:c,registry:e,page:"list"})}),(0,P.jsx)(Le,{path:"/:slug/:id",element:(0,P.jsx)(Ei,{context:c,registry:e,page:"record"})})]})]})]}))})});return t.embedded||!a||r?u:(0,P.jsx)(oi.Provider,{value:f,children:(0,P.jsx)(vr.Provider,{value:p,children:u})})}var _o=()=>typeof document>"u"?null:document.body;function Yo({context:t,registry:e,basename:n,initialPath:a,onNavigate:r,path:i,steering:o,firstLook:l}){let[d,c]=(0,U.useState)(void 0),p=d!==void 0&&d.from===t.principal?{...t,principal:d.seat}:t;(0,U.useState)(()=>p.views?Hr(p.views,p.store.schema,Cn(p.brand,p.store.schema)):void 0);let m=ce();ca({reader:p.locale??m?.locale,app:p.brand?.locale??p.app?.brand?.locale,readerTimeZone:p.timeZone??m?.timeZone,appTimeZone:p.brand?.timeZone??p.app?.brand?.timeZone});let f=p.principal??Io,u=Ma(p.store,f,p.history),B=(u.past&&u.live===p.store?u.past.store:p.store).seenBy(f),h=B===p.store?p:{...p,store:B};Ea(p.store,p.principal);let R=(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(Bo,{onNavigate:r,path:i}),o?(0,P.jsx)(Ho,{steering:o}):null,h.presence||m?(0,P.jsx)(Ko,{context:h,to:m}):null,(0,P.jsx)($i,{context:h,...e?{registry:e}:{}}),l?(0,P.jsx)(Kr,{firstLook:l,root:_o,app:Cn(p.brand,p.store.schema)}):null]}),G=h.views?(0,P.jsxs)(Na,{store:h.store,views:h.views,...h.principal?{principal:h.principal}:{},...h.brand?{brand:h.brand}:{},...h.locale?{locale:h.locale}:{},...h.timeZone?{timeZone:h.timeZone}:{},...h.settings?{settings:h.settings}:{},...h.presence&&!m?{presence:h.presence}:{},...h.people?{people:h.people}:{},...h.seats?{seats:h.seats}:{},onSeat:z=>m?m.takeSeat(z):c({from:t.principal,seat:z}),...h.onKeepLens?{onKeepLens:h.onKeepLens}:{},...h.ai?{ai:h.ai}:{},...h.subscriptions?{subscriptions:h.subscriptions}:{},...h.signIn?{signIn:h.signIn}:{},resolveApp:h.resolveApp??m?.resolveApp,linkedRecords:h.linkedRecords??m?.linkedRecords,...h.app?{app:h.app}:{},...h.menuSections?{menuSections:h.menuSections}:{},children:[R,(0,P.jsx)(Ni,{context:h,children:(0,P.jsx)(mi,{context:h})})]}):R,M=(0,P.jsx)(Ta.Provider,{value:u,children:G}),V=h.files?(0,P.jsx)(La.Provider,{value:h.files,children:M}):M;if(a!==void 0){let z=n===void 0?a:`${n.replace(/\/$/,"")}${a}`;return(0,P.jsx)(ni,{initialEntries:[z],...n===void 0?{}:{basename:n},children:V})}return(0,P.jsx)(ri,{...n===void 0?{}:{basename:n},children:V})}export{Xi as a,Yo as b};