graview 0.1.24 → 0.1.26

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 (109) hide show
  1. package/dist/preview/chunk.24X6LFD3.js +6 -0
  2. package/dist/preview/{chunk.AXACXB4D.js → chunk.2GFB5FOK.js} +1 -1
  3. package/dist/preview/chunk.3RT463XY.js +1 -0
  4. package/dist/preview/{chunk.KKTHQJ6F.js → chunk.4INXWGIT.js} +2 -2
  5. package/dist/preview/{chunk.7U7Q3HIS.js → chunk.4MAYBFPU.js} +1 -1
  6. package/dist/preview/chunk.4YY54TMR.js +1 -0
  7. package/dist/preview/chunk.564EIRAT.js +1 -0
  8. package/dist/preview/chunk.5CXMUC6R.js +16 -0
  9. package/dist/preview/{chunk.BLAODPYJ.js → chunk.6GJF3F7L.js} +1 -1
  10. package/dist/preview/chunk.6LJ66MB7.js +1 -0
  11. package/dist/preview/chunk.6MZBFEXW.js +1 -0
  12. package/dist/preview/chunk.6R4EI47C.js +1 -0
  13. package/dist/preview/chunk.7OOKA2DK.js +1 -0
  14. package/dist/preview/chunk.7ZJPJARU.js +1 -0
  15. package/dist/preview/{chunk.XDVKD6VX.js → chunk.AAVCTGAE.js} +4 -4
  16. package/dist/preview/chunk.AKWBAWQF.js +1 -0
  17. package/dist/preview/chunk.BK2MJOUN.js +1 -0
  18. package/dist/preview/chunk.CL7GGNEK.js +1 -0
  19. package/dist/preview/{chunk.TDW6QEG4.js → chunk.D3XF643V.js} +1 -1
  20. package/dist/preview/{chunk.UM5IPM22.js → chunk.DRIWJRQW.js} +1 -1
  21. package/dist/preview/chunk.ECG7RM6L.js +1 -0
  22. package/dist/preview/chunk.ECRZZ3U4.js +1 -0
  23. package/dist/preview/chunk.HFFEOCYY.js +107 -0
  24. package/dist/preview/chunk.I5U42VDK.js +3 -0
  25. package/dist/preview/chunk.IQLDOIWD.js +1 -0
  26. package/dist/preview/{chunk.WOTNMTIY.js → chunk.JIWB6VGT.js} +1 -1
  27. package/dist/preview/{chunk.6XBLDV4A.js → chunk.KSEKVHJJ.js} +1 -1
  28. package/dist/preview/chunk.KXWRS6LY.js +1 -0
  29. package/dist/preview/chunk.LCFCU3I3.js +1 -0
  30. package/dist/preview/chunk.LEVR7WLB.js +1 -0
  31. package/dist/preview/{chunk.FKQTQ3FV.js → chunk.LHIYFAN5.js} +2 -2
  32. package/dist/preview/chunk.LLUZMOBZ.js +1 -0
  33. package/dist/preview/{chunk.RT3XFR6E.js → chunk.LUUT2ZWF.js} +3 -3
  34. package/dist/preview/chunk.MLQQR57X.js +1 -0
  35. package/dist/preview/chunk.NIEQZOHX.js +1 -0
  36. package/dist/preview/{chunk.LW7KV5SL.js → chunk.NLFLFIDS.js} +1 -1
  37. package/dist/preview/{chunk.AKOC43TV.js → chunk.NQP3DWME.js} +1 -1
  38. package/dist/preview/{chunk.7EN53F4Q.js → chunk.OBGG4SYF.js} +1 -1
  39. package/dist/preview/chunk.OBQ4DIFO.js +1 -0
  40. package/dist/preview/chunk.P7YN4Z3K.js +8 -0
  41. package/dist/preview/{chunk.HAQ4KHRY.js → chunk.PKFL2AR4.js} +1 -1
  42. package/dist/preview/chunk.PQ2IIC27.js +1 -0
  43. package/dist/preview/chunk.QFJRXAU3.js +8 -0
  44. package/dist/preview/chunk.REODVRPZ.js +1 -0
  45. package/dist/preview/chunk.RH6VRP76.js +1 -0
  46. package/dist/preview/chunk.SVL6I37U.js +1 -0
  47. package/dist/preview/chunk.TAW67PZU.js +1 -0
  48. package/dist/preview/chunk.TUYKH4FG.js +1 -0
  49. package/dist/preview/chunk.UEEXBS2U.js +1 -0
  50. package/dist/preview/chunk.UUMXYMOX.js +19 -0
  51. package/dist/preview/chunk.VW7U4CT5.js +1 -0
  52. package/dist/preview/chunk.WWWZZAHE.js +1 -0
  53. package/dist/preview/chunk.XD4Q4FI2.js +1 -0
  54. package/dist/preview/chunk.XNYBOKLW.js +1 -0
  55. package/dist/preview/chunk.XOC5BRPU.js +1 -0
  56. package/dist/preview/chunk.XXNC2AFL.js +1 -0
  57. package/dist/preview/chunk.YIZ3DJO3.js +1 -0
  58. package/dist/preview/chunk.YOMW4MKD.js +1 -0
  59. package/dist/preview/chunk.YXQCEXZX.js +1 -0
  60. package/dist/preview/chunk.ZLPA5BAW.js +1 -0
  61. package/dist/preview/chunk.ZOWWWRYA.js +1 -0
  62. package/dist/preview/page.js +6 -6
  63. package/package.json +6 -6
  64. package/dist/preview/chunk.2STFOAXA.js +0 -1
  65. package/dist/preview/chunk.2VX6H2LL.js +0 -1
  66. package/dist/preview/chunk.33C6VZAD.js +0 -1
  67. package/dist/preview/chunk.3O2QU7LU.js +0 -1
  68. package/dist/preview/chunk.3TNQPFIK.js +0 -1
  69. package/dist/preview/chunk.42U4UBDE.js +0 -1
  70. package/dist/preview/chunk.47GRZWQN.js +0 -1
  71. package/dist/preview/chunk.53RZI5PM.js +0 -1
  72. package/dist/preview/chunk.54NSG7BX.js +0 -1
  73. package/dist/preview/chunk.6KJSFIO7.js +0 -1
  74. package/dist/preview/chunk.6MCK7K3M.js +0 -1
  75. package/dist/preview/chunk.6O67NOZR.js +0 -1
  76. package/dist/preview/chunk.7Q7S7YCA.js +0 -1
  77. package/dist/preview/chunk.BNSY25SG.js +0 -1
  78. package/dist/preview/chunk.C7KLA2MW.js +0 -1
  79. package/dist/preview/chunk.D3CYTXNZ.js +0 -1
  80. package/dist/preview/chunk.DQL3WKR3.js +0 -1
  81. package/dist/preview/chunk.EUCXNNCZ.js +0 -107
  82. package/dist/preview/chunk.FRNIWOKD.js +0 -1
  83. package/dist/preview/chunk.GDIRDJF3.js +0 -1
  84. package/dist/preview/chunk.H3HRTEW7.js +0 -1
  85. package/dist/preview/chunk.HDEQXJWX.js +0 -16
  86. package/dist/preview/chunk.HH6WIUK3.js +0 -8
  87. package/dist/preview/chunk.ISAMJ7AK.js +0 -1
  88. package/dist/preview/chunk.KWSXL3A2.js +0 -1
  89. package/dist/preview/chunk.MYCTNK6D.js +0 -1
  90. package/dist/preview/chunk.NRWJ6PLU.js +0 -1
  91. package/dist/preview/chunk.OXODTBOP.js +0 -6
  92. package/dist/preview/chunk.PRXKRG6O.js +0 -1
  93. package/dist/preview/chunk.Q5WEOX3Q.js +0 -1
  94. package/dist/preview/chunk.RGXNZ7PN.js +0 -1
  95. package/dist/preview/chunk.S4FO7Y2Q.js +0 -1
  96. package/dist/preview/chunk.TWFYXD3P.js +0 -1
  97. package/dist/preview/chunk.TWGB347L.js +0 -1
  98. package/dist/preview/chunk.UEBBASQW.js +0 -1
  99. package/dist/preview/chunk.UIZWVBJ7.js +0 -1
  100. package/dist/preview/chunk.VLNI5U6H.js +0 -1
  101. package/dist/preview/chunk.VTBAKTFP.js +0 -3
  102. package/dist/preview/chunk.WEGBBWWK.js +0 -1
  103. package/dist/preview/chunk.XCOPECOJ.js +0 -1
  104. package/dist/preview/chunk.XDPRWUCJ.js +0 -1
  105. package/dist/preview/chunk.XJNXSQT4.js +0 -19
  106. package/dist/preview/chunk.XUXCDUKC.js +0 -1
  107. package/dist/preview/chunk.Y4R77MKX.js +0 -1
  108. package/dist/preview/chunk.ZQ4HFIIS.js +0 -8
  109. /package/dist/preview/{chunk.WWRWXFYR.js → chunk.WVUJXDXZ.js} +0 -0
@@ -1,107 +0,0 @@
1
- import{A as he,B as ke,C as Yn,D as Ct,E as pe,F as Jn,G as Qn,H as A,I as We,J as Rt,K as Xn,L as At,M as rt,N as Zn,O as U,P as Y,Q as Lt,a as G,b as fe,c as q,d as Vn,e as xe,f as Fe,g as D,h as se,i as _,j as k,k as j,l as $,m as J,n as et,o as ee,p as Un,q as tt,r as nt,s as I,t as Pe,u as jn,v as at,w as le,x as _n,y as de,z as Pt}from"./chunk.FKQTQ3FV.js";import{a as Ze,c as V}from"./chunk.RGXNZ7PN.js";import{a as Bn,d as Gn,e as qn}from"./chunk.ONDILMIX.js";import{a as Hn,e as zn}from"./chunk.VLNI5U6H.js";import{a as xt}from"./chunk.FRNIWOKD.js";import{a as Ma}from"./chunk.IKT7JQUW.js";import{h as Ln,i as Tn}from"./chunk.AKOC43TV.js";import{e as Mn,i as Kn}from"./chunk.MYCTNK6D.js";import{a as Qe,b as Cn,c as Rn,e as vt,f as An}from"./chunk.53RZI5PM.js";import{f as Fn}from"./chunk.XJNXSQT4.js";import{a as bt,b as On,d as Wn,f as Nn,g as Dn,h as In,k as Xe}from"./chunk.VTBAKTFP.js";import{o as St}from"./chunk.6O67NOZR.js";import{f as Oe}from"./chunk.ISAMJ7AK.js";import{b as $n,c as kt,d as En}from"./chunk.LW7KV5SL.js";import{$ as Sn,C as Ie,W as vn,_ as kn,a as hn,da as oe,ha as bn,ja as Ee,ka as xn,ta as Pn,y as wn}from"./chunk.2VX6H2LL.js";import{Da as sn,Ea as ln,G as $e,Ga as dn,H as je,I as ae,J as Qt,L as re,N as Xt,Nb as wt,Ob as mn,P as Zt,S as en,Sb as yn,T as be,U as tn,Ua as pn,V as nn,Va as cn,Vb as Je,Wb as fn,Xa as gn,Za as Ye,aa as an,ca as _e,oa as ht,pa as rn,ua as on,xb as un}from"./chunk.ZQ4HFIIS.js";import{a as ve,b as z}from"./chunk.MRK6QJV5.js";import{b as O}from"./chunk.AJZBJBMO.js";function ea(e,t,n={}){let a=e.graph.getNode(t);if(!a)return;let i=e.schema.tryDefinition(a.kind),r=s=>ae(e.schema.tryDefinition(s.kind),s),d=new Map;for(let s of e.graph.allEdges()){let l=s.from===t?"out":s.to===t?"in":null;if(!l)continue;let o=l==="out"?s.to:s.from,u=e.graph.getNode(o);if(!u)continue;let g=(l==="out"?i:e.schema.tryDefinition(u.kind))?.edges?.[s.kind],c=l==="in"?g?.inverse??g?.description:g?.description,y=`${s.kind}|${l}|${c??""}`;(d.get(y)??(()=>{let F={edgeKind:s.kind,direction:l,...c?{description:c}:{},targets:[]};return d.set(y,F),F})()).targets.push({id:u.id,kind:u.kind,label:r(u)})}return{id:t,kind:a.kind,label:r(a),fields:tn(Oe(e.schema,e.graph,a),i),violations:ht(e.violations(n.context),[t]),actions:xt(e,[t],{focus:t,...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}}),links:[...d.values()].map(s=>{let l=je(s.targets.flatMap(o=>{let u=e.graph.getNode(o.id);return u?[u]:[]}),o=>e.schema.tryDefinition(o));return{...s,targets:[...s.targets].map(o=>l.has(o.id)?{...o,apart:l.get(o.id)}:o).sort((o,u)=>o.label.localeCompare(u.label))}})}}function Ce(e,t,n={}){return{kind:t,members:e.graph.nodesOfKind(t),actions:xt(e,[],{kindSelection:[t],...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}})}}function ta(e,t){let n=(r,d)=>`${r}|${JSON.stringify(d)}`,a=new Map;for(let r of[...e.affordances,...e.withheld]){if(r.provider!=="invariant")continue;let d=n(r.mutation,r.args);a.has(d)||a.set(d,r.rank??Number.MAX_SAFE_INTEGER)}let i=Number.MAX_SAFE_INTEGER;return[...t].map((r,d)=>({repair:r,declared:d})).sort((r,d)=>(a.get(n(r.repair.mutation,r.repair.args??{}))??i)-(a.get(n(d.repair.mutation,d.repair.args??{}))??i)||r.declared-d.declared).map(r=>r.repair)}function Re(e){let t=e.schema.kinds.map(i=>({kind:i,plural:Zt(e.schema,i),count:e.graph.nodesOfKind(i).length})),n=new Map;for(let i of e.graph.allEdges()){let r=e.graph.getNode(i.from),d=e.graph.getNode(i.to);if(!r||!d)continue;let s=`${i.kind}|${r.kind}|${d.kind}`;n.set(s,(n.get(s)??0)+1)}let a=[];for(let{kind:i}of t){let r=e.schema.tryDefinition(i)?.edges??{};for(let[d,s]of Object.entries(r)){let l=s.to==="*"||s.to===void 0?(()=>{let o=[...n.keys()].filter(u=>u.startsWith(`${d}|${i}|`)).map(u=>u.split("|")[2]);return o.length>0?o:["*"]})():s.to;for(let o of l)a.push({edgeKind:d,from:i,to:o,...s.description?{description:s.description}:{},...s.inverse?{inverse:s.inverse}:{},count:n.get(`${d}|${i}|${o}`)??0})}}return{kinds:t,relations:a}}var Le=O(ve(),1);var Tt=O(ve(),1),S=O(z(),1),$a=`
2
- form:where([data-graview-part="form"]) {
3
- /* A grid item of the section above it and a grid container for the
4
- fields below: both halves are allowed to be narrower than what is in
5
- them, or a big enough text size pushes the page sideways. See the note
6
- on \`column\` in pages.tsx. */
7
- display: grid;
8
- grid-template-columns: minmax(0, 1fr);
9
- min-width: 0;
10
- gap: 12px;
11
- }
12
- label:where([data-graview-part="field"]) {
13
- display: grid;
14
- /* A track the width it was given: see the note on \`column\` in pages.tsx. */
15
- grid-template-columns: minmax(0, 1fr);
16
- min-width: 0;
17
- gap: 4px;
18
- }
19
- label:where([data-graview-part="field"][data-graview-field="boolean"]) {
20
- grid-auto-flow: column;
21
- justify-content: start;
22
- align-items: center;
23
- }
24
- span:where([data-graview-part="label"]),
25
- legend:where([data-graview-part="label"]),
26
- p:where([data-graview-part="unasked"]) {
27
- font-size: 0.8125rem;
28
- color: var(--graview-ink-muted);
29
- }
30
- p:where([data-graview-part="unasked"]) { margin: 0; }
31
- input:where([data-graview-part="control"]:not([type="checkbox"])),
32
- select:where([data-graview-part="control"]) {
33
- font: inherit;
34
- /* A TARGET IN EVERY ENGINE, not only in the one it was measured in.
35
- Padding and line height alone came to 24 in Chromium and to 22 in
36
- WebKit, which has its own intrinsic metrics for a \`select\` and rounds
37
- nothing up for anybody. So every picker on the routed face was under
38
- the WCAG 2.2 minimum in the browser iOS ships, and the check that says
39
- so (\`verify-pages\`' \`bigEnoughToHit\`) only ever ran there through
40
- \`pnpm engines\`. */
41
- min-height: 24px;
42
- /* NEVER WIDER THAN ITS FIELD. A select is as wide as its longest option,
43
- and a picker over 320 vehicles ("2027 Mercedes-Benz GLE AMG 53 4MATIC+
44
- Coupe") was 618 pixels on a 390 phone, and the whole page scrolled
45
- sideways. It shrinks to its track and cuts the option inside its box. */
46
- min-width: 0;
47
- max-width: 100%;
48
- text-overflow: ellipsis;
49
- box-sizing: border-box;
50
- padding: 7px 10px;
51
- border-radius: 8px;
52
- border: 1px solid var(--graview-edge);
53
- background: var(--graview-panel);
54
- color: var(--graview-ink);
55
- }
56
- /* A PICKER THAT STILL LOOKS LIKE ONE.
57
- WebKit ignores an author's padding and minimum height on a \`select\`
58
- while the native appearance is on \u2014 so every picker on the routed face
59
- came out 22 pixels tall in the browser iOS ships, under the 24 WCAG 2.2
60
- asks for, while the same element measured 35 in Chromium. Turning the
61
- appearance off is what makes the box the size it was asked to be, and it
62
- takes the platform's chevron with it; the chevron is put back, in the ink
63
- the scheme is already using. */
64
- span:where([data-graview-part="picker"]) {
65
- position: relative;
66
- display: grid;
67
- min-width: 0;
68
- }
69
- span:where([data-graview-part="picker"]) > select:where([data-graview-part="control"]) {
70
- appearance: none;
71
- padding-right: 28px;
72
- }
73
- span:where([data-graview-part="chevron"]) {
74
- position: absolute;
75
- right: 10px;
76
- top: 50%;
77
- transform: translateY(-50%);
78
- font-size: 0.75rem;
79
- line-height: 1;
80
- color: var(--graview-ink-muted);
81
- pointer-events: none;
82
- }
83
- fieldset:where([data-graview-part="group"]) {
84
- display: grid;
85
- gap: 10px;
86
- border: 1px solid var(--graview-edge);
87
- border-radius: 10px;
88
- padding: 12px;
89
- }
90
- fieldset:where([data-graview-part="group"][data-graview-field="list"]) { gap: 8px; }
91
- div:where([data-graview-part="item"]) {
92
- display: flex;
93
- gap: 8px;
94
- align-items: end;
95
- }
96
- button:where([data-graview-part="add"]),
97
- button:where([data-graview-part="submit"]) { justify-self: start; }
98
- p:where([data-graview-part="refused"]) {
99
- margin: 0;
100
- color: var(--graview-warn);
101
- font-size: 0.875rem;
102
- }
103
- `;function na({children:e}){return(0,S.jsxs)("span",{"data-graview-part":"picker",children:[e,(0,S.jsx)("span",{"aria-hidden":"true","data-graview-part":"chevron",children:"\u25BE"})]})}var Ea=e=>({label:re(e),option:t=>t});function it({store:e,spec:t,value:n,onChange:a,prefilled:i,open:r,words:d=Ea}){if(t.name in i&&t.control!=="group"&&t.control!=="variant")return null;let l=(t.control==="node"&&!t.kinds.includes("*")?t.kinds.map(o=>re(be(e.schema.tryDefinition(o),o))).join(" or "):d(t.name).label)+(t.optional||t.control==="boolean"?"":" *");switch(t.control){case"text":case"date":return t.control==="text"&&t.long?(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":"text",children:[(0,S.jsx)("span",{"data-graview-part":"label",children:l}),(0,S.jsx)("textarea",{name:t.name,required:!t.optional,rows:6,value:typeof n=="string"?n:"",onChange:o=>a(o.target.value),"data-graview-part":"control",style:{fieldSizing:"content",minHeight:"7.5em",resize:"vertical",font:"inherit",lineHeight:1.5}})]}):(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":t.control,children:[(0,S.jsx)("span",{"data-graview-part":"label",children:l}),(0,S.jsx)("input",{type:t.control==="date"?t.time?"datetime-local":"date":"text",name:t.name,required:!t.optional,value:typeof n=="string"?n:"",onChange:o=>a(o.target.value),"data-graview-part":"control"})]});case"number":return(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":t.control,children:[(0,S.jsx)("span",{"data-graview-part":"label",children:l}),(0,S.jsx)("input",{type:"number",name:t.name,required:!t.optional,...t.min===void 0?{}:{min:t.min},...t.max===void 0?{}:{max:t.max},...t.step===void 0?{}:{step:t.step},value:typeof n=="number"?n:"",onChange:o=>a(o.target.value===""?void 0:Number(o.target.value)),"data-graview-part":"control"})]});case"boolean":return(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":"boolean",children:[(0,S.jsx)("input",{type:"checkbox",name:t.name,checked:n===!0,onChange:o=>a(o.target.checked),"data-graview-part":"control"}),(0,S.jsx)("span",{"data-graview-part":"label",children:l})]});case"choice":return(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":t.control,children:[(0,S.jsx)("span",{"data-graview-part":"label",children:l}),(0,S.jsx)(na,{children:(0,S.jsxs)("select",{name:t.name,required:!t.optional,value:typeof n=="string"?n:"",onChange:o=>a(o.target.value||void 0),"data-graview-part":"control",children:[(0,S.jsx)("option",{value:"",children:"\u2014"}),(t.options??[]).map(o=>(0,S.jsx)("option",{value:o,children:d(t.name).option(o)},o))]})})]});case"node":{let o=r.find(y=>y.name===t.name)?.candidates,u=new Set(Object.values(i).filter(y=>typeof y=="string")),m=(t.kinds.includes("*")?[...e.graph.allNodes()]:t.kinds.flatMap(y=>e.graph.nodesOfKind(y))).filter(y=>!u.has(y.id)),g=o?o.map(y=>e.graph.getNode(y)).filter(y=>y!==void 0):m,c=je(g,y=>e.schema.tryDefinition(y));return(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":t.control,children:[(0,S.jsx)("span",{"data-graview-part":"label",children:l}),(0,S.jsx)(na,{children:(0,S.jsxs)("select",{name:t.name,required:!t.optional,value:typeof n=="string"?n:"",onChange:y=>a(y.target.value||void 0),"data-graview-part":"control",children:[(0,S.jsx)("option",{value:"",children:"\u2014"}),g.map(y=>{let P=c.get(y.id);return(0,S.jsxs)("option",{value:y.id,children:[ae(e.schema.tryDefinition(y.kind),y),P?` \xB7 ${P}`:""]},y.id)})]})})]})}case"group":{let o=n??{};return(0,S.jsxs)("fieldset",{"data-graview-part":"group","data-graview-field":t.control,children:[(0,S.jsx)("legend",{"data-graview-part":"label",children:l}),t.fields.map(u=>(0,S.jsx)(it,{store:e,spec:u,value:o[u.name],onChange:m=>a({...o,[u.name]:m}),prefilled:i,open:r,words:d},u.name))]})}case"variant":{let o=n??{},u=typeof o[t.tag]=="string"?o[t.tag]:"",m=t.options.find(g=>g.value===u);return(0,S.jsxs)("fieldset",{"data-graview-part":"group","data-graview-field":t.control,children:[(0,S.jsx)("legend",{"data-graview-part":"label",children:l}),(0,S.jsxs)("label",{"data-graview-part":"field","data-graview-field":"choice",children:[(0,S.jsx)("span",{"data-graview-part":"label",children:re(t.tag)}),(0,S.jsxs)("select",{value:u,onChange:g=>a({[t.tag]:g.target.value}),"data-graview-part":"control",children:[(0,S.jsx)("option",{value:"",children:"\u2014"}),t.options.map(g=>(0,S.jsx)("option",{value:g.value,children:re(g.value)},g.value))]})]}),m?.fields.map(g=>(0,S.jsx)(it,{store:e,spec:g,value:o[g.name],onChange:c=>a({...o,[g.name]:c}),prefilled:i,open:r,words:d},g.name))]})}case"list":{let o=Array.isArray(n)?n:[];return(0,S.jsxs)("fieldset",{"data-graview-part":"group","data-graview-field":"list",children:[(0,S.jsx)("legend",{"data-graview-part":"label",children:l}),o.map((u,m)=>(0,S.jsxs)("div",{"data-graview-part":"item",children:[(0,S.jsx)("div",{style:{flex:1},children:(0,S.jsx)(it,{store:e,spec:{...t.item,optional:!1},value:u,onChange:g=>a(o.map((c,y)=>y===m?g:c)),prefilled:i,open:r,words:d})}),(0,S.jsx)("button",{type:"button","data-graview-part":"remove",onClick:()=>a(o.filter((g,c)=>c!==m)),children:"remove"})]},m)),(0,S.jsx)("button",{type:"button","data-graview-part":"add",onClick:()=>a([...o,void 0]),children:"add another"})]})}case"opaque":return(0,S.jsxs)("p",{"data-graview-part":"unasked",children:["\u201C",re(t.name),"\u201D needs a structured answer this form cannot ask for yet."]})}}function ye({store:e,mutation:t,prefilled:n={},open:a=[],onDone:i,principal:r,initial:d,label:s,only:l}){let[o,u]=(0,Tt.useState)(()=>({...d})),[m,g]=(0,Tt.useState)(null),c=Je(t.input).filter(P=>l===void 0||l.includes(P.name)),y=P=>an(e.schema,t,P);return(0,S.jsxs)("form",{"data-testid":`form-${t.name}`,onSubmit:P=>{P.preventDefault();try{e.apply({name:t.name,args:{...fn(c,o),...n}},r?{author:r}:{}),g(null),u({}),i?.()}catch(F){g(_e(e.schema,e.allMutations(),F))}},"data-graview-part":"form",children:[(0,S.jsx)("style",{children:$a}),c.map(P=>(0,S.jsx)(it,{store:e,spec:P,value:o[P.name],onChange:F=>u(C=>({...C,[P.name]:F})),prefilled:n,open:a,words:y},P.name)),m?(0,S.jsx)("p",{"data-testid":"refused","data-graview-part":"refused",role:"alert",children:m}):null,(0,S.jsx)("button",{type:"submit","data-graview-part":"submit",children:s??t.title??t.name})]})}var b=O(z(),1);function ce(e){let t=e.views;if(!t)return[];let n=new Set(Pe(e.store,e.principal));return t.places().filter(a=>n.has(a.kind))}var Ae=e=>`place:${e.kind}:${e.as}`;function ge(e,t){let n=(e.views?.places()??[]).some(a=>a.as===t.as&&a.kind!==t.kind);return Vn(t.as,n?G(e.store.schema,t.kind):void 0)}function Ke(e,t){let n=e.schema.tryDefinition(t);return e.graph.nodesOfKind(t).filter(a=>$e(n,a))}function Mt(e,t,n){let a=(r,d)=>Xt(e.schema,d,r),i=a(Ke(e,t).length,t);return n?`${i} across ${a(Ke(e,n).length,n)}`:i}function $t({context:e,place:t,chosen:n}){let{store:a,views:i,invariantContext:r}=e,s=i?.resolve(t.kind,{cardinality:"many",fidelity:"full"},t.as)?.view;if(!s)return null;let l=Ke(a,t.kind),o=[...new Set(a.violations(r).flatMap(u=>u.nodeIds))];return(0,b.jsx)(St,{kind:t.kind,view:t.title,children:(0,b.jsx)(s,{nodes:l,label:t.title,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1,...n&&n.length>0?{implicated:n}:{},...o.length>0?{flagged:o}:{}})})}function Oa({store:e,views:t,as:n,invariantContext:a}){V(e);let i={store:e,views:t,...a?{invariantContext:a}:{}},r=t.places().find(d=>d.as===n);return r?(0,b.jsx)($t,{context:i,place:r}):null}function Fa({context:e,kind:t}){let{store:n,views:a,invariantContext:i}=e,r=Ke(n,t),d=n.schema.tryDefinition(t),s=I(n,t),o=a?.resolve(t,{cardinality:"many",fidelity:"full"})?.view,u=[...new Set(n.violations(i).flatMap(y=>y.nodeIds))];if(o&&!Ee(o))return(0,b.jsx)(St,{kind:t,children:(0,b.jsx)(o,{nodes:r,label:s,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1,...u.length>0?{flagged:u}:{}})});let m=a?.resolve(t,{cardinality:"one",fidelity:"summary"})?.view,g=8,c=r.slice(0,g);return(0,b.jsxs)("div",{"data-testid":"kind-sheet",style:m?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gridAutoRows:"max-content",alignContent:"center",gap:12,padding:24}:{display:"flex",flexWrap:"wrap",alignContent:"center",justifyContent:"center",gap:10,padding:24},children:[c.map(y=>m?(0,b.jsx)(m,{node:y,fidelity:"summary",cardinality:"one",mode:"fullscreen",selected:!1,...u.includes(y.id)?{flagged:[y.id]}:{}},y.id):(0,b.jsx)("span",{style:{fontSize:"1.0625rem",padding:"8px 14px",borderRadius:8,border:"1px solid var(--graview-edge-bright)",background:"var(--graview-ground)",color:"var(--graview-ink)"},children:ae(d,y)},y.id)),r.length>g?(0,b.jsxs)("span",{style:{...k,alignSelf:"center",padding:"0 6px"},children:["+",r.length-g," more ",s.toLowerCase()]}):null]})}function Et(e){let{store:t}=e,n=jn(e),a=[...ce(e)].sort((r,d)=>n.indexOf(r.kind)-n.indexOf(d.kind)),i=new Set(a.map(r=>r.kind));return[...a.map(r=>({key:Ae(r),kind:r.kind,title:r.title,to:ge(e,r),place:r})),...at(e).filter(r=>!i.has(r)).map(r=>({key:`kind:${r}`,kind:r,title:I(t,r),to:`/${G(t.schema,r)}`}))]}var aa=.72,Wa=540,ra=16/10;function Na(e){let t=(0,Le.useRef)(null),[n,a]=(0,Le.useState)(e);return(0,Le.useLayoutEffect)(()=>{let i=t.current;if(!i||typeof ResizeObserver>"u")return;let r=()=>{let s=i.getBoundingClientRect().width;s>0&&a(l=>Math.abs(l-s)<.5?l:s)};r();let d=new ResizeObserver(r);return d.observe(i),()=>d.disconnect()},[]),{ref:t,width:n}}function Ot({context:e,entry:t}){let{store:n,brand:a,principal:i}=e,{ref:r,width:d}=Na(Wa),s=d/aa,l=Ke(n,t.kind),o=n.schema.tryDefinition(t.kind),u=l.length===0?Ce(n,t.kind,{...i?{principal:i}:{},...e.invariantContext?{context:e.invariantContext}:{}}).actions.affordances[0]:void 0,m=t.place!==void 0;return(0,b.jsxs)(A,{to:t.to,"data-testid":m?"place-card":"kind-card",className:"graview-gallery-card",style:{...J,display:"grid",gap:10,alignContent:"start",minWidth:0},children:[(0,b.jsxs)("span",{ref:r,"data-testid":m?"place-picture":"kind-picture","aria-hidden":"true",inert:!0,style:{display:"block",position:"relative",width:"100%",aspectRatio:`${ra}`,overflow:"hidden",borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",pointerEvents:"none"},children:[(0,b.jsx)("span",{style:{position:"absolute",left:0,top:0,width:s,height:s/ra,display:"grid",gridTemplateRows:"minmax(0, 1fr)",transform:`scale(${aa})`,transformOrigin:"0 0"},children:t.place?(0,b.jsx)($t,{context:e,place:t.place}):(0,b.jsx)(Fa,{context:e,kind:t.kind})}),l.length===0?(0,b.jsx)("span",{"data-testid":"picture-empty",style:{position:"absolute",inset:0,display:"grid",placeContent:"center",justifyItems:"center",gap:2,padding:20,textAlign:"center"},children:(0,b.jsxs)("span",{style:{display:"grid",gap:2,padding:"10px 16px",borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-ground)",color:"var(--graview-ink)"},children:[(0,b.jsxs)("span",{style:{fontFamily:xe,fontWeight:600,fontSize:"1.0625rem"},children:["No ",I(n,t.kind).toLowerCase()," yet"]}),u?(0,b.jsxs)("span",{style:k,children:["Begin with \u201C",u.label,"\u201D"]}):null]})}):null]}),(0,b.jsxs)("span",{style:{display:"grid",gap:2,minWidth:0},children:[(0,b.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[m?null:(0,b.jsx)(ee,{kind:t.kind,brand:a,schema:n.schema,size:8}),(0,b.jsx)("span",{style:{fontFamily:xe,fontSize:"1.25rem",fontWeight:600,lineHeight:1.3,overflowWrap:"anywhere"},children:t.title})]}),(0,b.jsxs)("span",{style:k,children:[t.place?Mt(n,t.place.kind,t.place.across):Mt(n,t.kind),!m&&o?.description?` \xB7 ${o.description}`:null]})]})]})}var ia={display:"grid",gap:"32px 28px",gridTemplateColumns:"repeat(auto-fill, minmax(min(420px, 100%), 1fr))"},Da=`
104
- .graview-gallery-card > span:first-child { transition: border-color 160ms ease, box-shadow 160ms ease; }
105
- .graview-gallery-card:hover > span:first-child,
106
- .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); }
107
- `;function Ft({context:e}){V(e.store);let t=Et(e);return t.length===0?null:(0,b.jsxs)("section",{style:ia,"data-testid":"gallery",children:[(0,b.jsx)("style",{children:Da}),t.map(n=>(0,b.jsx)(Ot,{context:e,entry:n},n.key))]})}function Wt({context:e}){let{store:t}=e;V(t);let n=ce(e),a=Et(e);return(0,b.jsxs)(U,{context:e,style:Fe,children:[(0,b.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,b.jsx)("p",{style:se,children:n.length===0?"None of its own yet":`${n.length} ${n.length===1?"picture":"pictures"}`}),(0,b.jsx)(Y,{context:e,children:"Pictures"}),(0,b.jsx)("p",{style:_,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,b.jsx)("div",{style:ia,"data-testid":"places",children:a.map(i=>(0,b.jsx)(Ot,{context:e,entry:i},i.key))}):null]})}function Nt({context:e}){let{store:t,principal:n}=e;V(t);let a=ke(),i=he(),[r]=We(),d=decodeURIComponent(a.as??""),[s,l]=(0,Le.useState)(null),o=r.get("of"),m=ce(e).find(P=>P.as===d&&(!o||G(t.schema,P.kind)===o));if(!m)return(0,b.jsxs)(U,{context:e,children:[(0,b.jsx)(Y,{context:e,children:"No picture is called that."}),(0,b.jsx)("p",{style:_,children:(0,b.jsx)(A,{to:"/places",style:$,children:"The pictures there are \u2192"})})]});let g=I(t,m.kind),y=Ce(t,m.kind,{...n?{principal:n}:{},...e.invariantContext?{context:e.invariantContext}:{}}).actions.affordances.map(P=>({affordance:P,mutation:t.allMutations().find(F=>F.name===P.mutation)})).filter(P=>P.mutation!==void 0);return(0,b.jsxs)(U,{context:e,style:Fe,children:[(0,b.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,b.jsx)(Y,{context:e,children:m.title}),(0,b.jsxs)("p",{style:_,"data-testid":"place-lede",children:[Mt(t,m.kind,m.across),"."]}),(0,b.jsx)("p",{style:{...k,margin:0},children:(0,b.jsxs)(A,{to:`/${G(t.schema,m.kind)}`,style:{...$,...k},"data-testid":"place-as-list",children:["All ",g.toLowerCase()," as a list \u2192"]})})]}),(0,b.jsx)("div",{"data-testid":"place-lens",style:{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:P=>{let F=P.target?.closest("[data-graview-pick]"),C=F?.getAttribute("data-graview-pick"),K=F?.getAttribute("data-graview-joins");if(K)try{let X=JSON.parse(K);if(Array.isArray(X)&&X.every(we=>typeof we=="string")){P.preventDefault(),l({at:Ae(m),ids:X});return}}catch{}if(!C)return;let ue=t.graph.getNode(C);ue&&(P.preventDefault(),i(q(t.schema,ue.kind,C)))},children:(0,b.jsx)($t,{context:e,place:m,...s?.at===Ae(m)?{chosen:s.ids}:{}})}),(0,b.jsx)("div",{style:{maxWidth:760,display:"grid",gap:40},children:y.map(({affordance:P,mutation:F})=>(0,b.jsxs)("section",{style:{...j,display:"grid",gap:14},children:[(0,b.jsx)("h2",{style:D,children:F.title??F.name}),F.description?(0,b.jsx)("p",{style:{...k,margin:0,maxWidth:"58ch"},children:F.description}):null,(0,b.jsx)(ye,{store:t,mutation:F,prefilled:P.args,open:P.open,label:P.label,...n?{principal:n}:{}})]},P.id))})]})}var W=O(ve(),1);var Te=O(ve(),1);function oa(e,t,n){let a=Math.max(0,e.left),i=Math.min(t.width,e.right),r=Math.max(0,e.top),d=Math.min(t.height,e.bottom);return{shown:d-r>=n.height+2*16&&i-a>=n.width+2*16,left:Math.round(a),top:Math.round(r),width:Math.round(Math.max(0,i-a)),height:Math.round(Math.max(0,d-r))}}function sa(e,t,n){let a=e.style;a.left=`${t.left}px`,a.top=`${t.top}px`,a.right="auto",a.bottom="auto",a.visibility=n?"":"hidden";let i=e.getBoundingClientRect();i.width!==0&&(a.left=`${Math.round(2*t.left-i.left)}px`,a.top=`${Math.round(2*t.top-i.top)}px`)}var Se=O(z(),1);function la({context:e}){let t=he(),n=oe(),{pathname:a}=de(),[,i,r]=a.split("/"),d=i==="places"&&r?decodeURIComponent(r):void 0,s=(0,Te.useRef)(null);return Ka(s,n!==null),n?(0,Se.jsxs)(Se.Fragment,{children:[(0,Se.jsx)(Ha,{context:e}),(0,Se.jsx)("div",{ref:s,"data-testid":"page-seat",style:{position:"fixed",left:0,top:0,width:"100vw",height:"100dvh",pointerEvents:"none",zIndex:un("rail"),containerType:"size"},children:(0,Se.jsx)(Hn,{onPick:l=>{let o=e.store.graph.getNode(l);o&&t(q(e.store.schema,o.kind,l))},onMove:l=>{if(n.seatTalk.get().draft&&n.seatTalk.setDraft(null),l.to==="place"&&(l.face==="scene"||l.slug==="overview")){e.overview?e.overview("#"):e.embedded||window.location.assign(e.sceneHref??"/");return}t(l.address)},...d?{place:d}:{},onDraft:()=>{a!=="/~draft"&&t("/~draft")}})})]}):null}var Ia={width:160,height:40};function Ka(e,t){let{pathname:n}=de();(0,Te.useLayoutEffect)(()=>{let a=e.current;if(!a)return;let i=a.parentElement?.closest("[data-embed-content]")??null,r=()=>i??document.querySelector("main")??null,d=()=>{let u=r(),m={width:document.documentElement.clientWidth||innerWidth,height:innerHeight},g=u?.getBoundingClientRect()??{left:0,top:0,right:m.width,bottom:m.height},c=oa(i?g:{left:g.left,right:g.right,top:g.top,bottom:Math.max(g.bottom,m.height)},m,Ia);a.style.width=`${c.width}px`,a.style.height=`${c.height}px`,sa(a,c,c.shown)};d(),addEventListener("resize",d),addEventListener("scroll",d,!0);let s=0,l=typeof ResizeObserver=="function"?new ResizeObserver(()=>{cancelAnimationFrame(s),s=requestAnimationFrame(d)}):null,o=r();return o&&l?.observe(o),()=>{cancelAnimationFrame(s),l?.disconnect(),removeEventListener("resize",d),removeEventListener("scroll",d,!0)}},[e,t,n])}function Ha({context:e}){let{store:t}=e,n=oe(),{pathname:a}=de(),i=(0,Te.useRef)(n?.setSelection);return i.current=n?.setSelection,(0,Te.useEffect)(()=>{let r=i.current;if(!r)return;let[,d,s]=a.split("/"),l=(()=>{if(d==="places"){let u=e.views?.places().find(m=>m.as===decodeURIComponent(s??""));return u?[Ie(u.kind)]:[]}let o=d?fe(t.schema,d):void 0;return o&&s?[decodeURIComponent(s)]:o?[wn(o)]:[]})();r(o=>o.length===l.length&&o.every((u,m)=>u===l[m])?o:l)},[a]),null}var te=O(ve(),1);var pa=O(Ma(),1);var Q=O(z(),1);var za=(0,te.lazy)(hn(()=>import("./chunk.XUXCDUKC.js").then(e=>({default:e.TakeBack}))));function Ba({context:e,docked:t,at:n}){let{store:a}=e,i=V(a),[r]=(0,te.useState)(()=>a.batches().length),d=(0,te.useRef)(!1);return d.current||=i>0||!t&&r>0,d.current?(0,Q.jsx)(te.Suspense,{fallback:null,children:(0,Q.jsx)(za,{context:e,docked:t,at:n,since:r})}):null}function Ga(e,t,n){let{store:a,principal:i,embedded:r}=e;(0,te.useEffect)(()=>{if(!n)return;let d=s=>{if(!qn(s))return;let l=s.target,o=l instanceof Node&&t.current?.contains(l),u=l===document.body||l===document.documentElement||l===document;if(!(!o&&!(u&&!r))&&Bn(a,i)){s.preventDefault();try{Gn(a,i)}catch{}}};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[a,i,r,t,n])}function ca({context:e,registry:t,root:n,children:a}){let i=(0,te.useMemo)(Xn,[]),r=t?.without()??new Set;return Ga(e,n,!r.has("undo")),(0,Q.jsxs)(Rt.Provider,{value:i,children:[(0,Q.jsx)(qa,{context:e,placed:i,without:r}),a]})}function qa({context:e,placed:t,without:n}){let[a,i]=(0,te.useState)(!1);(0,te.useLayoutEffect)(()=>i(!0),[]);let r=At(t,"find"),d=At(t,"undo"),s=de(),l=Tn();if(!a)return null;let o=s.pathname.split("/").filter(Boolean),m=(o.length===1?fe(e.store.schema,o[0]):void 0)!==void 0;return(0,Q.jsxs)(Q.Fragment,{children:[!r&&!n.has("find")&&l?(0,pa.createPortal)((0,Q.jsx)(da,{context:e,narrowsLists:m}),l.slot):null,!r&&!n.has("find")&&!l?(0,Q.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,Q.jsx)(da,{context:e,narrowsLists:m})}):null,!d&&!n.has("undo")?(0,Q.jsx)(Ba,{context:e,docked:!0,at:s.pathname+s.search}):null,l?.own&&!n.has("undo")?(0,Q.jsx)(_n,{context:e,own:l.own}):null]})}function da({context:e,narrowsLists:t}){return(0,Q.jsx)(Rt.Provider,{value:null,children:(0,Q.jsx)(Lt,{context:e,narrowsLists:t})})}var T=O(z(),1);function ga(e,t){return t==="*"?{label:"anything",path:null}:{label:I(e,t),path:`/${G(e.schema,t)}`}}function Va({context:e,relation:t}){let{store:n}=e,a=ga(n,t.from),i=ga(n,t.to),r=d=>d.path?(0,T.jsx)(A,{to:d.path,style:{...J,fontWeight:550},children:d.label}):(0,T.jsx)("span",{children:d.label});return(0,T.jsxs)("li",{"data-testid":"relation","data-relation":t.edgeKind,style:{display:"grid",gridTemplateColumns:"30px minmax(0, 1fr) auto",gap:12,alignItems:"baseline"},children:[(0,T.jsx)(zn,{edgeKind:t.edgeKind,...e.brand?.kit?{kit:e.brand.kit}:{}}),(0,T.jsxs)("span",{style:{display:"grid",gap:1},children:[(0,T.jsxs)("span",{children:[r(a)," ",(0,T.jsxs)("span",{style:k,"data-graview-speaks-ids":"",children:[re(t.edgeKind)," \u2192"]})," ",r(i)]}),t.description||t.inverse?(0,T.jsxs)("span",{style:{...k,fontSize:"0.9375rem"},children:[t.description?le(t.description):null,t.description&&t.inverse?" \xB7 ":null,t.inverse?`from the other end, ${t.inverse}`:null]}):null]}),i.path?(0,T.jsx)(A,{to:`${i.path}?with=${encodeURIComponent(t.edgeKind)}`,style:{...$,...k,fontVariantNumeric:"tabular-nums",display:"inline-block",minWidth:24,minHeight:24,textAlign:"center"},title:`The ${i.label.toLowerCase()} that have this`,children:t.count}):(0,T.jsx)("span",{style:{...k,fontVariantNumeric:"tabular-nums"},children:t.count})]})}function ua({context:e,heading:t=!0}){let{store:n}=e,a=new Set(Pe(n,e.principal)),i=Re(n).relations.filter(r=>a.has(r.from)&&(r.to==="*"||a.has(r.to)));return i.length===0?null:(0,T.jsxs)("section",{style:{...j,display:"grid",gap:12},"data-testid":"kind-map",children:[t?(0,T.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,T.jsx)("h2",{style:D,children:(0,T.jsx)(A,{to:"/map",style:J,children:"Connections"})}),(0,T.jsx)("span",{style:k,children:i.length===1?"1 relation":`${i.length} relations`})]}):null,(0,T.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:i.map(r=>(0,T.jsx)(Va,{context:e,relation:r},`${r.edgeKind}|${r.from}|${r.to}`))})]})}function Dt({context:e}){let{store:t}=e;V(t);let n=new Set(Pe(t,e.principal)),a=Re(t),i=a.relations.filter(r=>n.has(r.from));return(0,T.jsxs)(U,{context:e,children:[(0,T.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,T.jsx)("p",{style:se,children:i.length===0?"No relations":`${i.length} ${i.length===1?"relation":"relations"}`}),(0,T.jsx)(Y,{context:e,children:"Connections"}),(0,T.jsx)("p",{style:_,children:i.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,T.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"6px 18px"},"data-testid":"map-kinds",children:a.kinds.filter(r=>n.has(r.kind)).map(r=>(0,T.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,T.jsx)(ee,{kind:r.kind,brand:e.brand,schema:t.schema,size:7}),(0,T.jsx)(A,{to:`/${G(t.schema,r.kind)}`,style:$,children:r.plural}),(0,T.jsx)("span",{style:k,children:r.count})]},r.kind))}),(0,T.jsx)(ua,{context:e,heading:!1})]})}function ma({context:e}){let n=[...oe()?.robots.values()??[]].filter(i=>i.mode==="asking"&&i.say);if(n.length===0)return null;let{store:a}=e;return(0,T.jsxs)("section",{style:{...j,display:"grid",gap:10},"data-testid":"seat-questions",children:[(0,T.jsx)("h2",{style:D,children:n.length===1?"The seat asked something":`The seat asked ${n.length} things`}),(0,T.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8},children:n.map(i=>{let r=i.at?a.graph.getNode(i.at):void 0;return(0,T.jsxs)("li",{style:{display:"grid",gap:2},children:[(0,T.jsx)("span",{children:i.say}),r?(0,T.jsxs)(A,{to:q(a.schema,r.kind,r.id),style:{...$,...k},children:[ae(a.schema.tryDefinition(r.kind),r)," \u2192"]}):null]},i.participant)})})]})}var E=O(z(),1);function It({context:e}){let{principal:t}=e,{store:n,brand:a,invariantContext:i}=e;V(n);let r=n.violations(i),d=`${r.length===1?"A rule is broken":"Rules are broken"} \u2014 see what, and what would fix it`,s=[...n.log.all()].slice(-5).reverse(),o=at(e).map(C=>({kind:C,members:n.graph.nodesOfKind(C).filter(K=>$e(n.schema.tryDefinition(C),K))})),u=o.filter(C=>C.members.length>0),m=o.map(C=>({entry:C,creator:n.allMutations().find(K=>(K.creates??[]).includes(C.kind)&&n.permits({name:K.name,args:{}},e.principal).ok)})).find(C=>C.creator!==void 0),g=u.length===0?"Nothing here yet.":`${u.map(C=>`${C.members.length} ${C.members.length===1?C.kind:I(n,C.kind).toLowerCase()}`).join(", ").replace(/, ([^,]*)$/," and $1")}.`,c=e.views?.homeView?.(),y=n.schema.kinds.some(C=>n.graph.nodesOfKind(C).length>0);if(c&&y){let C=a?.subtitle?(0,E.jsx)("p",{style:{...k,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,K=c[Symbol.for("graview.home-blocks")]===!0;return(0,E.jsx)(U,{context:e,style:Fe,children:(0,E.jsxs)("div",{style:{display:"grid",gap:12},"data-testid":"home-view",children:[K?null:C,r.length>0?(0,E.jsx)(A,{to:"/problems",style:{...$,color:"var(--graview-warn)"},children:d}):null,(0,E.jsx)(In.Provider,{value:K?C:null,children:(0,E.jsx)(c,{cardinality:"many",fidelity:"full",mode:"fullscreen",selected:!1})})]})})}let P=new Set(Pe(n,e.principal)),F=Re(n).relations.filter(C=>P.has(C.from)&&(C.to==="*"||P.has(C.to)));return(0,E.jsxs)(U,{context:e,style:Fe,children:[(0,E.jsxs)("header",{style:{display:"grid",gap:12},children:[a?.subtitle?(0,E.jsx)("p",{style:{...k,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,(0,E.jsx)(Y,{context:e,"data-testid":"standing",children:g}),(0,E.jsxs)("p",{style:{..._,display:"grid",gap:4},"data-testid":"standing-card",children:[u.length===0&&m?(0,E.jsxs)("span",{children:["Begin with \u201C",m.creator?.title??m.creator?.name,"\u201D, under"," ",(0,E.jsx)(A,{to:`/${G(n.schema,m.entry.kind)}`,style:$,children:I(n,m.entry.kind)}),"."]}):null,r.length===0?(0,E.jsx)("span",{children:"All rules hold."}):(0,E.jsx)(A,{to:"/problems",style:{...$,color:"var(--graview-warn)"},children:d})]})]}),(0,E.jsx)(Ft,{context:e}),(0,E.jsxs)("section",{style:{...j,display:"grid",gap:14},"data-testid":"kinds",children:[(0,E.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,E.jsx)("h2",{style:D,children:"What is here"}),F.length>0?(0,E.jsxs)(A,{to:"/map",style:{...$,...k,marginLeft:"auto"},"data-testid":"map-link",children:["Connections \xB7 ",F.length===1?"1 relation":`${F.length} relations`," \u2192"]}):null]}),(0,E.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"8px 10px"},children:o.map(({kind:C,members:K})=>(0,E.jsx)("li",{style:{maxWidth:"100%"},children:(0,E.jsxs)(A,{to:`/${G(n.schema,C)}`,style:{...J,flexWrap:"wrap",gap:8,padding:"6px 14px 6px 10px",borderRadius:8,border:"1px solid var(--graview-edge-bright)",background:"var(--graview-panel)"},children:[(0,E.jsx)(ee,{kind:C,brand:a,schema:n.schema,size:7}),(0,E.jsx)("span",{style:{fontWeight:550,overflowWrap:"anywhere"},children:I(n,C)}),(0,E.jsx)("span",{style:{...k,fontVariantNumeric:"tabular-nums"},children:K.length===0?"none yet":K.length})]})},C))})]}),s.length>0?(0,E.jsxs)("section",{style:{...j,display:"grid",gap:10},children:[(0,E.jsx)("h2",{style:D,children:"Recently"}),(0,E.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:s.map(C=>(0,E.jsxs)("li",{style:k,children:[(0,E.jsx)("span",{style:{color:"var(--graview-ink)"},children:C.intent})," \u2014 ",tt(C,t,{graph:n.graph,schema:n.schema,...e.seats?{seats:e.seats}:{},...e.people?{people:e.people}:{}})]},C.id))})]}):null]})}var Me=O(ve(),1);var R=O(z(),1);function Kt({context:e}){let{store:t,brand:n,principal:a,invariantContext:i}=e;V(t);let[r]=We(),d=r.get("q")??"",s=typeof i?.today=="string"?i.today:void 0,l=gn(t,d,{...a?{principal:a}:{},places:ce(e),flagged:new Set(t.violations(i).flatMap(c=>c.nodeIds)),...s?{today:s}:{},limit:200}),o=l.hits.filter(c=>c.about==="node"),u=l.hits.filter(c=>c.about==="kind"||c.about==="place"||c.about==="rule"),m=[...new Set(o.map(c=>c.kind))],g=d.trim();return(0,R.jsxs)(U,{context:e,children:[(0,R.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,R.jsx)("p",{style:se,children:"Search"}),(0,R.jsx)(Y,{context:e,"data-testid":"search-heading",children:g.length===0?"Find anything by its name":l.hits.length===0?(0,R.jsxs)(R.Fragment,{children:["Nothing here is called \u201C",g,"\u201D."]}):(0,R.jsxs)(R.Fragment,{children:[Ua(t,l.byKind)," for \u201C",g,"\u201D"]})}),g.length>0?(0,R.jsxs)("p",{style:{...k,margin:0},"data-testid":"search-searched",children:[Ye(t.schema,l.searched),l.conditions.filter(c=>c.key!=="is"&&c.admittedBy.length<l.searched.kinds.length).map(c=>(0,R.jsxs)("span",{children:[" ",c.key,":",c.value," narrows"," ",c.admittedBy.length===0?"nothing here":c.admittedBy.map(y=>I(t,y).toLowerCase()).join(" and "),"."]},`${c.key}:${c.value}`))]}):(0,R.jsxs)("p",{style:_,children:["Type in the box above. Words find the start of words in names and in what each record says;"," ",(0,R.jsx)("code",{children:"done:false"})," and the like narrow as a list does, and ",(0,R.jsx)("code",{children:"is:any"})," includes what is past."]})]}),u.length>0?(0,R.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},"data-testid":"search-named",children:u.map(c=>(0,R.jsx)("li",{"data-testid":"search-hit","data-about":c.about,children:c.about==="kind"?(0,R.jsxs)(A,{to:`/${G(t.schema,c.kind)}`,style:$,children:[c.label,c.count>0?(0,R.jsxs)("span",{style:k,children:[" \xB7 ",c.count," match"]}):null]}):c.about==="place"?(0,R.jsxs)(A,{to:ge(e,c),style:$,children:["Go to ",c.title]}):c.about==="rule"?(0,R.jsxs)(A,{to:"/problems",style:$,children:["The rule \u201C",c.label,"\u201D"]}):null},`${c.about}:${c.about==="rule"?c.name:c.about==="place"?c.as:c.kind}`))}):null,m.map(c=>(0,R.jsxs)("section",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:0,minWidth:0},"data-testid":"search-group","data-kind":c,children:[(0,R.jsxs)("h2",{style:{...D,fontSize:"1.0625rem",marginBottom:4,display:"flex",alignItems:"center",gap:8},children:[(0,R.jsx)(ee,{kind:c,brand:n,schema:t.schema,size:8}),(0,R.jsx)(A,{to:`/${G(t.schema,c)}?${new URLSearchParams({q:g}).toString()}`,style:$,"data-testid":"search-kind-link",children:I(t,c)}),(0,R.jsx)("span",{style:k,children:l.byKind[c]})]}),(0,R.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:0},children:o.filter(y=>y.kind===c).map(y=>(0,R.jsxs)("li",{"data-testid":"search-hit","data-about":"node",style:{display:"grid",gap:2,padding:"12px 0",minWidth:0,borderTop:"1px solid var(--graview-edge)"},children:[(0,R.jsxs)(A,{to:q(t.schema,c,y.id),style:{...J,fontFamily:xe,fontSize:"1.1875rem",fontWeight:600,lineHeight:1.3,overflowWrap:"anywhere"},children:[y.flagged?(0,R.jsx)("span",{style:{color:"var(--graview-warn)"},children:"\u26A0 "}):null,y.label,y.apart?(0,R.jsxs)("span",{style:k,children:[" \xB7 ",y.apart]}):null,y.current?null:(0,R.jsx)("span",{style:k,children:" \xB7 past"})]}),(0,R.jsx)(ot,{why:y.why})]},y.id))})]},c)),g.length>0?(0,R.jsx)(ja,{asked:g}):null,g.length>0&&l.hits.length===0?(0,R.jsx)(fa,{store:t,kinds:l.searched.kinds,words:l.words,...a?{principal:a}:{},...i?{invariantContext:i}:{}}):null]})}function ot({why:e}){return e.field==="label"?null:(0,R.jsxs)("span",{style:k,"data-testid":"search-why",children:[e.reading,": ",e.fragment]})}function Ua(e,t){let n=Object.entries(t).map(([a,i])=>`${i} ${i===1?be(e.schema.tryDefinition(a),a):I(e,a).toLowerCase()}`);return n.length===0?"Found":n.length===1?le(n[0]):le(`${n.slice(0,-1).join(", ")} and ${n[n.length-1]}`)}function ya(e,t,n={}){let a=[];for(let i of t){let r=Ce(e,i,{...n.principal?{principal:n.principal}:{},...n.invariantContext?{context:n.invariantContext}:{}});for(let d of st(e,i,r.actions.affordances))a.some(s=>s.mutation.name===d.mutation.name)||a.push(d)}return a}function st(e,t,n){let a=e.schema.tryDefinition(t)?.fieldRoles?.label,i=[];for(let r of n){let d=e.allMutations().find(o=>o.name===r.mutation);if(!d||!d.creates?.includes(t)||i.some(o=>o.mutation.name===d.name))continue;let s=Je(d.input).map(o=>o.name),l=s.includes("label")?"label":a&&s.includes(a)?a:void 0;!l||r.args[l]!==void 0||i.push({kind:t,affordance:r,mutation:d,arg:l})}return i}function fa({store:e,kinds:t,words:n,principal:a,invariantContext:i}){let r=ya(e,t,{...a?{principal:a}:{},...i?{invariantContext:i}:{}});return r.length===0||n.trim().length===0?null:(0,R.jsx)("div",{style:{display:"grid",gap:24},"data-testid":"search-to-create",children:r.map(({kind:d,affordance:s,mutation:l,arg:o})=>(0,R.jsxs)("section",{style:{...j,display:"grid",gap:14},children:[(0,R.jsxs)("h2",{style:D,children:[le(en(be(e.schema.tryDefinition(d),d)))," called \u201C",n,"\u201D"]}),(0,R.jsx)(ye,{store:e,mutation:l,prefilled:s.args,open:s.open,initial:{[o]:n},...a?{principal:a}:{}})]},`${s.id}|${n}`))})}function ja({asked:e}){let t=oe();return t?(0,R.jsx)(_a,{asked:e,talk:t.seatTalk}):null}function _a({asked:e,talk:t}){let{drawn:n}=vn(t);return n===0?null:(0,R.jsx)("p",{style:{margin:0},children:(0,R.jsxs)("button",{type:"button","data-testid":"search-ask",onClick:()=>t.ask(e),style:{...$,font:"inherit",padding:0,border:0,background:"transparent",cursor:"pointer",textAlign:"start"},children:["Ask: \u2018",e,"\u2019"]})})}var h=O(z(),1),ha=8,wa=40;function Ht({context:e}){let t=ke(),n=fe(e.store.schema,t.slug??"");return n?(0,h.jsx)(va,{context:e,kind:n}):(0,h.jsx)(U,{context:e,children:(0,h.jsx)(Y,{context:e,children:"No such kind of thing here."})})}function va({context:e,kind:t,opening:n,row:a,layout:i="list",description:r,bare:d}){let{store:s,brand:l,invariantContext:o}=e;V(s);let[u,m]=We(),g=s.schema.tryDefinition(t),c=s.graph.nodesOfKind(t),y=Re(s).relations.filter(p=>p.from===t||p.to===t),P=new Set(s.violations(o).flatMap(p=>p.nodeIds)),F=ln(s.schema,t),C=y.map(p=>p.edgeKind),K=Qa(u,F,C),ue=["sort","filter","group","q","by","with","past",...C].some(p=>u.has(p)),X=c.length>=wa,we=g?.fieldRoles?.when,N=ue?K.arrangement:kt(n??Ja(X,we),F).arrangement,ne=pn(N.query??""),f=[...N.filter??[],...ne.conditions].some(p=>p.key==="is"&&(p.value==="past"||p.value==="any"))||sn(g,[...N.filter??[],...ne.conditions]),L=f||!g?.lifecycle?N:{...N,filter:[...N.filter??[],{key:"is",value:"current"}]},Z=En(c,L,{schema:s.schema,graph:s.graph,flagged:P,...typeof o?.today=="string"?{today:o.today}:{}}),B=Z.nodes,ze=g?.lifecycle&&!f?c.filter(p=>$e(g,p)):c,Gt=c.length-ze.length,qt=N.group?.by??null,ba=p=>{let x=new URLSearchParams(u);for(let ie of["sort","filter","group","q","by","with","past",...y.map(Ue=>Ue.edgeKind)])x.delete(ie);let H=$n(p);for(let ie of["sort","filter","group","q"])H[ie]&&x.set(ie,H[ie]);![...x.keys()].some(ie=>["sort","filter","group","q"].includes(ie))&&(n||X||we)&&x.set("sort",""),m(x)},{principal:Vt}=e,ct=Ce(s,t,{...Vt?{principal:Vt}:{},...e.invariantContext?{context:e.invariantContext}:{}}),Ne=ct.actions.affordances.map(p=>({affordance:p,mutation:s.allMutations().find(x=>x.name===p.mutation)})).filter(p=>p.mutation!==void 0),Ut=ct.actions.withheld,jt=ne.words&&B.length===0?Object.fromEntries(st(s,t,ct.actions.affordances).map(p=>[p.mutation.name,p.arg])):{},gt=I(s,t),Be=e.views?.lookup(t,{cardinality:"one",fidelity:"glyph"}),_t=Be!==void 0&&!Ee(Be)?Be:void 0,ut=p=>{let x=ae(g,p);if(a){let De=g?.computed?Oe(s.schema,s.graph,p):p;return(0,h.jsx)("li",{"data-testid":"record-row",style:{minWidth:0},children:a(p,{label:x,href:q(s.schema,t,p.id),flagged:P.has(p.id),glance:nt(De,g,x)})},p.id)}if(_t){let De=Xe(Be,p,s.graph),Aa=g?.computed?Oe(s.schema,s.graph,p):p,La=Object.fromEntries(Object.entries(Aa).filter(([Ta])=>!De?.fields.has(Ta))),Jt=De?nt(La,g,De.title??x):"";return(0,h.jsxs)("li",{"data-testid":"record-row",style:{position:"relative",display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:16,rowGap:2,padding:"10px 0",borderTop:"1px solid var(--graview-edge)"},children:[(0,h.jsx)("div",{style:{flex:"1 1 14rem",minWidth:0},children:(0,h.jsx)(_t,{node:p,cardinality:"one",fidelity:"glyph",mode:"fullscreen",selected:!1,...P.has(p.id)?{flagged:[p.id]}:{}})}),Jt?(0,h.jsx)("span",{style:{...k,flex:"0 1 auto",minWidth:0,overflowWrap:"anywhere"},"data-testid":"record-glance",children:Jt}):null,(0,h.jsx)(A,{to:q(s.schema,t,p.id),"aria-label":P.has(p.id)?`${x} \u2014 implicated in a problem`:x,style:{position:"absolute",inset:0,borderRadius:6}})]},p.id)}let H=g?.computed?Oe(s.schema,s.graph,p):p,ie=nt(H,g,x),Ue=ne.words?cn(g,p,ne.words):void 0;return(0,h.jsxs)("li",{style:X?{display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:16,rowGap:0,padding:"5px 0",borderTop:"1px solid var(--graview-edge)",overflowWrap:"anywhere"}:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:2,padding:"14px 0",borderTop:"1px solid var(--graview-edge)",overflowWrap:"anywhere"},children:[(0,h.jsxs)(A,{to:q(s.schema,t,p.id),style:X?{...J,flex:"1 1 14rem",minWidth:0,fontSize:"1rem",fontWeight:600,lineHeight:1.35}:{...J,fontFamily:xe,fontSize:"1.25rem",fontWeight:600,lineHeight:1.3},children:[P.has(p.id)?(0,h.jsx)("span",{style:{color:"var(--graview-warn)"},children:"\u26A0 "}):null,x]}),ie?(0,h.jsx)("span",{style:X?{...k,flex:"0 1 auto",minWidth:0,fontSize:"0.875rem"}:k,children:ie}):null,Ue?(0,h.jsx)(ot,{why:Ue}):null]},p.id)},mt=ce(e).filter(p=>p.kind===t),xa=(N.filter??[]).some(p=>p.key!=="is"||p.value!=="any"),Pa=!!(N.sort||N.group||N.query||xa),Ca=ze.length>=ha||ue&&Pa,me=N.sort?F.sorts.find(p=>p.key===N.sort.by):void 0,yt=me?.type==="date"||me!==void 0&&me.key===we,Yt=X&&!Z.grouped&&me&&(me.about==="label"||me.type==="text"||yt)?p=>{let x=me.about==="label"?ae(g,p):p[me.key];if(typeof x!="string"||x.length===0)return yt?"No date":"#";if(yt)return x.slice(0,4);let H=x.trim().charAt(0).toLocaleUpperCase();return/\p{L}/u.test(H)?H:"#"}:void 0,Ge=Yt?B.reduce((p,x)=>{let H=Yt(x);return p.at(-1)?.key===H?p.at(-1).nodes.push(x):p.push({key:H,nodes:[x]}),p},[]):void 0,ft=i==="grid"?{margin:0,padding:0,listStyle:"none",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(100%, 15rem), 1fr))",gap:12}:{margin:0,padding:0,listStyle:"none",display:"grid",gap:a&&i==="list"?6:0},qe=p=>`list-at-${p.replace(/[^\p{L}\p{N}]/gu,"_")}`,Ve=y.map(p=>{let x=p.from===t?p.to:p.from,H=p.from===t?p.description:p.inverse??p.description;return{relation:p,far:x,words:H}}),Ra=new Set(Ve.map(p=>(p.words??"").toLowerCase()).filter((p,x,H)=>p&&H.indexOf(p)!==x));return(0,h.jsxs)(d?Ya:U,{context:e,children:[(0,h.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,h.jsxs)("header",{style:{display:"grid",gap:4},children:[(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,minWidth:0},children:[(0,h.jsx)(ee,{kind:t,brand:l,schema:s.schema,size:8}),(0,h.jsx)(Y,{context:e,children:gt})]}),r??g?.description?(0,h.jsx)("p",{style:{..._,fontSize:"1.0625rem",lineHeight:1.4},children:r??g?.description}):null,Ve.length>0||mt.length>0?(0,h.jsxs)("p",{style:{...k,margin:0,display:"flex",flexWrap:"wrap",columnGap:18,rowGap:2},"data-testid":"kind-related",children:[Ve.length>0?(0,h.jsxs)("span",{"data-testid":"kind-relations",children:["Related:"," ",Ve.map(({relation:p,far:x,words:H},ie)=>(0,h.jsxs)("span",{"data-relation":p.edgeKind,children:[ie>0?" \xB7 ":null,x==="*"?le(H??re(p.edgeKind)):(0,h.jsx)(A,{to:`/${G(s.schema,x)}`,style:$,title:I(s,x),children:H&&Ra.has(H.toLowerCase())?`${le(H)}: ${I(s,x).toLowerCase()}`:le(H??I(s,x))})]},`${p.edgeKind}|${p.from}|${p.to}`))]}):null,mt.length>0?(0,h.jsxs)("span",{"data-testid":"kind-pictures",children:["Also as:"," ",mt.map((p,x)=>(0,h.jsxs)("span",{children:[x>0?" \xB7 ":null,(0,h.jsx)(A,{to:ge(e,p),style:$,children:p.title})]},Ae(p)))]}):null]}):null]}),K.dropped.length>0?(0,h.jsxs)("p",{style:{...k,margin:0},"data-testid":"list-dropped",children:["This link asked for ",K.dropped.join(", "),", which ",gt.toLowerCase()," cannot be arranged by; the rest is shown."]}):null,ze.length>0?(0,h.jsx)(Fn,{schema:s.schema,graph:s.graph,kind:t,arrangement:N,onChange:ba,kept:{shown:B.length,of:ze.length},noun:{one:be(g,t),many:gt.toLowerCase()},...Ca?{}:{allow:!1},query:e.framed===!0&&e.barAbove!==!0}):null,B.length===0&&ne.words?(0,h.jsxs)("p",{style:{..._,fontSize:"1.0625rem"},"data-testid":"none-yet",children:["Nothing here is called \u201C",ne.words,"\u201D."," ",(0,h.jsx)("span",{style:k,"data-testid":"list-searched",children:Ye(s.schema,{kinds:[t],past:f})})," ",(0,h.jsx)(A,{to:"?",style:$,children:"Show every one"})]}):B.length===0?(0,h.jsxs)("p",{style:{..._,fontSize:"1.0625rem"},"data-testid":"none-yet",children:[N.filter?.length||N.query?"None of them.":"None yet",!N.filter?.length&&!N.query&&Ne.length>0?` \u2014 the first one starts below, with \u201C${Ne[0]?.mutation.title??Ne[0]?.mutation.name}\u201D.`:!N.filter?.length&&!N.query?".":"",N.filter?.length||N.query?(0,h.jsxs)(h.Fragment,{children:[" ",(0,h.jsx)(A,{to:"?",style:$,children:"Show every one"})]}):null]}):Z.grouped&&qt?(0,h.jsx)("div",{style:{display:"grid",gap:18},"data-testid":"records","data-grouped":qt,children:Z.groups.map(p=>(0,h.jsxs)("section",{style:{display:"grid",gap:0},"data-testid":"list-group",children:[(0,h.jsxs)("h2",{style:{...D,fontSize:"1.0625rem",marginBottom:4},children:[p.label," ",(0,h.jsx)("span",{style:k,children:p.nodes.length})]}),(0,h.jsx)("ul",{style:ft,"data-graview-rows":"",children:p.nodes.map(ut)})]},p.key||"-"))}):Ge&&Ge.length>1?(0,h.jsxs)("div",{style:{display:"grid",gap:14},"data-testid":"records","data-sectioned":me?.type==="date"?"year":"letter",children:[(0,h.jsx)("nav",{"aria-label":"Jump to","data-testid":"list-index",style:{...k,display:"flex",flexWrap:"wrap",gap:me?.type==="date"?"0 10px":"0 4px",fontSize:"0.8125rem",lineHeight:1.3},children:Ge.map(p=>(0,h.jsx)("a",{href:`#${qe(p.key)}`,onClick:x=>{x.preventDefault(),document.getElementById(qe(p.key))?.scrollIntoView({block:"start"})},style:{...$,flex:"0 0 auto",minWidth:24,justifyContent:"center",textDecoration:"none"},children:p.key},p.key))}),Ge.map(p=>(0,h.jsxs)("section",{"data-testid":"list-section","aria-labelledby":qe(p.key),style:{display:"grid",gap:0},children:[(0,h.jsx)("h2",{id:qe(p.key),style:{...D,fontSize:"0.9375rem",color:"var(--graview-ink-muted)",marginBottom:2,scrollMarginTop:64},children:p.key}),(0,h.jsx)("ul",{style:ft,"data-graview-rows":"",children:p.nodes.map(ut)})]},p.key))]}):(0,h.jsx)("ul",{style:ft,"data-testid":"records","data-graview-rows":"",children:B.map(ut)}),Gt>0?(0,h.jsxs)(A,{to:Xa(u,"filter","is:any"),style:{...$,...k,justifySelf:"start"},"data-testid":"past-link",children:["+",Gt," past"]}):null,Ne.length>0?(0,h.jsx)("div",{style:{display:"grid",gap:6},"data-testid":"beginnings",children:Ne.map(({affordance:p,mutation:x})=>{let H=!!(jt[x.name]&&B.length===0);return(0,h.jsx)(Za,{name:x.name,title:x.title??x.name,description:x.description,open:B.length===0,children:(0,h.jsx)(ye,{store:s,mutation:x,prefilled:p.args,open:p.open,...H?{initial:{[jt[x.name]]:ne.words}}:{},...e.principal?{principal:e.principal}:{}},H?`${x.name}|${ne.words}`:x.name)},p.id)})}):null]}),Ut.length>0?(0,h.jsx)("ul",{style:{...j,margin:0,padding:0,listStyle:"none",display:"grid",gap:4},"data-testid":"withheld",children:Ut.map(p=>(0,h.jsxs)("li",{style:k,children:[(0,h.jsx)("s",{children:p.label})," \u2014 ",p.refusal.message]},p.id))}):null]})}function Ya({children:e}){return(0,h.jsx)("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:40,minWidth:0},children:e})}var Ja=(e,t)=>t?{sort:{by:t,direction:"desc"}}:e?{sort:{by:"label",direction:"asc"}}:{};function Qa(e,t,n){let a=dn({...e.get("sort")?{sort:e.get("sort")}:{},...e.get("filter")?{filter:e.get("filter")}:{},...e.get("group")?{group:e.get("group")}:{},...e.get("q")?{q:e.get("q")}:{}}),i=[...a.filter??[]],r=e.get("by"),d=a.group??(r?{by:r}:void 0);for(let l of n){let o=e.get(l);o&&i.push({key:l,value:o})}let s=e.get("with");return s&&i.push({key:s,value:"*"}),e.get("past")==="1"&&!i.some(l=>l.key==="is")&&i.push({key:"is",value:"any"}),kt({...a.sort?{sort:a.sort}:{},...a.query?{query:a.query}:{},...i.length>0?{filter:i}:{},...d?{group:d}:{}},t)}function Xa(e,t,n){let a=new URLSearchParams(e);return a.set(t,n),a.delete("past"),`?${a.toString()}`}function Za({name:e,title:t,description:n,open:a,children:i}){let[r,d]=(0,Me.useState)(a),s=(0,Me.useRef)(null),l=(0,Me.useRef)(null),o=`begin-${(0,Me.useId)().replace(/:/g,"")}`;return(0,h.jsxs)("div",{"data-testid":`act-${e}`,style:{display:"grid",gap:10},children:[(0,h.jsxs)("button",{ref:s,type:"button","data-testid":`act-open-${e}`,"aria-expanded":r,"aria-controls":o,onClick:()=>{d(!r),r||requestAnimationFrame(()=>l.current?.querySelector("input, select, textarea, button")?.focus())},style:{...J,justifySelf:"start",minHeight:32,padding:"0 2px",border:0,background:"none",font:"inherit",fontSize:"0.9375rem",fontWeight:600,color:"var(--graview-ink)",cursor:"pointer"},children:[(0,h.jsx)("span",{"aria-hidden":"true",style:{marginRight:6},children:r?"\u2212":"+"}),t]}),(0,h.jsxs)("div",{ref:l,id:o,hidden:!r,onKeyDown:u=>{u.key==="Escape"&&(u.preventDefault(),d(!1),s.current?.focus())},style:r?{display:"grid",gap:12,padding:"4px 0 12px"}:void 0,children:[n?(0,h.jsx)("p",{style:{...k,margin:0,maxWidth:"58ch"},children:n}):null,i]})]})}var pt=O(ve(),1);var He=O(ve(),1);var M=O(z(),1);function zt({context:e}){let{store:t,brand:n,invariantContext:a,principal:i}=e;V(t);let r=t.violations(a),d=t.allInvariants(),s=Qe(t,r),l=Cn(t.schema,d);return(0,M.jsxs)(U,{context:e,children:[(0,M.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,M.jsx)(Y,{context:e,children:r.length===0?"All rules hold":"What is broken"}),(0,M.jsx)("p",{style:_,"data-testid":"problems-count",children:r.length===0?"Every declared rule is satisfied by what is here.":rn(r)})]}),(0,M.jsx)(ma,{context:e}),s.map((o,u)=>{let m=o.nodeIds[0],g=m?t.graph.getNode(m):void 0;return(0,M.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:[o.line?null:(0,M.jsx)(lt,{violation:o,schema:t.schema,...n?{brand:n}:{}}),g?(0,M.jsxs)("p",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:8},children:[(0,M.jsx)(ee,{kind:g.kind,brand:n,schema:t.schema,size:7}),(0,M.jsx)(A,{to:q(t.schema,g.kind,g.id),style:$,children:ae(t.schema.tryDefinition(g.kind),g)})]}):null,o.line?(0,M.jsx)(lt,{violation:o,schema:t.schema,...n?{brand:n}:{}}):null,(0,M.jsx)(dt,{store:t,repairs:o.repairs,...i?{principal:i}:{}})]},u)}),d.length>0?(0,M.jsxs)("section",{style:{...j,display:"grid",gap:12},"data-testid":"rules",children:[(0,M.jsx)("h2",{style:D,children:"The rules"}),(0,M.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:d.map(o=>{let u=r.filter(c=>c.invariant===o.name).length,m=l.get(o.name),g=o.label??o.name;return(0,M.jsxs)("li",{"data-graview-rule":o.name,style:{display:"grid",gap:2},children:[(0,M.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:12,rowGap:2},children:[m?(0,M.jsx)(vt,{line:m,schema:t.schema,...n?{brand:n}:{},style:{flex:"1 1 18rem"}}):(0,M.jsx)("span",{style:{flex:"1 1 18rem",fontWeight:550},children:g}),(0,M.jsx)("span",{style:{...k,fontSize:"0.875rem",color:u>0?"var(--graview-warn)":"var(--graview-ink-faint)"},children:u===0?"holds":`broken in ${u} ${u===1?"place":"places"}`})]}),m&&g.trim().length>0?(0,M.jsx)("span",{style:{...k,fontSize:"0.875rem"},children:g}):null]},o.name)})})]}):null]})}function lt({violation:e,schema:t,brand:n}){if(!e.line)return(0,M.jsx)("p",{style:{margin:0,color:"var(--graview-warn)",fontWeight:550},children:e.message});let a=An(e);return(0,M.jsxs)("div",{style:{display:"grid",gap:2},"data-testid":"problem-line",title:Rn(e),children:[(0,M.jsx)(vt,{line:e.line,schema:t,...n?{brand:n}:{},lead:"none",style:{color:"var(--graview-warn)",fontSize:"1.0625rem"}}),a?(0,M.jsx)("span",{style:{...k,fontSize:"0.875rem"},children:a}):null]})}function dt({store:e,repairs:t,principal:n}){let[a,i]=(0,He.useState)(null),[r,d]=(0,He.useState)(null),s=(0,He.useRef)([]);if(t.length===0)return null;let l=a===null?null:t[a],o=l&&(l.missing??[]).length>0?e.allMutations().find(u=>u.name===l.mutation):void 0;return(0,M.jsxs)("div",{style:{display:"grid",gap:10},"data-testid":"repairs",children:[(0,M.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:t.map((u,m)=>{let g=(u.missing??[]).length>0,c=e.permits({name:u.mutation,args:{...u.args}},n);return c.ok?(0,M.jsx)("button",{ref:y=>{s.current[m]=y},type:"button","data-graview-repair":u.mutation,"data-graview-asks":g||void 0,"aria-expanded":g?a===m:void 0,onClick:()=>{if(d(null),g){i(a===m?null:m);return}i(null);try{e.apply({name:u.mutation,args:{...u.args}},n?{author:n}:{})}catch(y){d(_e(e.schema,e.allMutations(),y))}},style:et,children:g?`${u.label} \u2026`:u.label},m):(0,M.jsxs)("p",{"data-testid":"withheld","data-withheld":c.refusal.wouldNeed.join(",")||"nobody",style:{margin:0,fontSize:"0.875rem",color:"var(--graview-ink-muted)"},children:[(0,M.jsx)("s",{children:u.label})," \u2014 ",c.refusal.message]},m)})}),o&&l?(0,M.jsx)(ye,{store:e,mutation:o,prefilled:{...l.args},only:l.missing??[],label:l.label,onDone:()=>{let u=a;i(null),requestAnimationFrame(()=>{let m=u===null?null:s.current[u];if(m?.isConnected){m.focus();return}let g=document.querySelector("[data-graview-page-title]")??document.querySelector("main h1, main h2");g&&(g.hasAttribute("tabindex")||(g.tabIndex=-1),g.focus())})},...n?{principal:n}:{}}):null,l&&!o&&(l.missing??[]).length>0?(0,M.jsxs)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:"0.875rem"},children:["\u201C",l.label,"\u201D names ",l.mutation,", which this app does not declare."]}):null,r?(0,M.jsx)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:"0.875rem"},children:r}):null]})}var w=O(z(),1),er=[];function Bt({context:e}){let{store:t,brand:n,principal:a,invariantContext:i}=e;V(t);let r=oe()!==null,d=ke(),s=decodeURIComponent(d.id??""),l=ea(t,s,{...a?{principal:a}:{},...i?{context:i}:{}}),o=Qe(t,l?.violations??er),[u,m]=(0,pt.useState)(null),g=(0,pt.useRef)(null);if(!l)return(0,w.jsx)(U,{context:e,children:(0,w.jsx)(Y,{context:e,children:"Nothing lives at this address."})});let c=t.graph.getNode(s),y=t.schema.tryDefinition(l.kind),P=y?.describe&&c?Qt(y,c):null,F=[...t.log.all()].filter(f=>!on(f)&&(f.writes.includes(s)||f.reads.includes(s))).slice(-8).reverse(),C=l.actions.affordances.filter(f=>f.provider!=="invariant"),K=e.views?.lookup(l.kind,{cardinality:"one",fidelity:"full"}),ue=K!==void 0&&!Ee(K)?K:void 0,X=ue&&c?Xe(K,c,t.graph):void 0,we=X?l.fields.filter(f=>!X.fields.has(f.key)):l.fields,N=X?l.links.flatMap(f=>{let L=f.targets.filter(Z=>!X.records.has(Z.id));return L.length>0?[{...f,targets:L}]:[]}):l.links,ne=ue!==void 0&&xn(K);return(0,w.jsxs)(U,{context:e,children:[(0,w.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,w.jsxs)("p",{style:{...se,display:"flex",alignItems:"center",gap:8},children:[(0,w.jsx)(ee,{kind:l.kind,brand:n,schema:t.schema,size:8}),(0,w.jsx)(A,{to:`/${G(t.schema,l.kind)}`,style:J,children:I(t,l.kind)})]}),(0,w.jsx)(Y,{context:e,children:r&&c?.label===l.label?(0,w.jsx)(bt,{nodeId:s,field:"label",value:l.label}):l.label}),P&&P!==l.label?(0,w.jsx)("p",{style:_,children:P}):null,(0,w.jsx)(Ze,{context:e,stop:`#focus=${encodeURIComponent(s)}`,style:{...$,...k},"data-testid":"spatial-link"}),ce(e).some(f=>f.kind===l.kind||f.across===l.kind)?(0,w.jsxs)("p",{style:{...k,margin:0},"data-testid":"seen-in",children:["Seen in:"," ",ce(e).filter(f=>f.kind===l.kind||f.across===l.kind).map((f,L)=>(0,w.jsxs)("span",{children:[L>0?" \xB7 ":null,(0,w.jsx)(A,{to:ge(e,f),style:$,children:f.title})," ",(0,w.jsx)(Ze,{context:e,stop:`#view=${encodeURIComponent(f.as)}`,style:{...$,...k,display:"inline-block",minWidth:24,textAlign:"center"},title:`${f.title}, in the scene`,children:"\u2197"})]},Ae(f)))]}):null]}),ue&&c?(0,w.jsx)("section",{"data-testid":"record-view",style:{display:"grid",minWidth:0},children:(0,w.jsx)(Wn,{children:(0,w.jsx)(ue,{node:c,cardinality:"one",fidelity:"full",mode:"fullscreen",selected:!1,...l.violations.length>0?{flagged:[s]}:{}})})}):null,l.violations.length>0?(0,w.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:o.map((f,L)=>(0,w.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,w.jsx)(lt,{violation:f,schema:t.schema,...n?{brand:n}:{}}),(0,w.jsx)(dt,{store:t,repairs:ta(l.actions,f.repairs),...a?{principal:a}:{}})]},L))}):null,!ne&&we.length>0?(0,w.jsxs)("section",{style:{...j,display:"grid",gap:14},"data-testid":"record-fields",children:[(0,w.jsx)("h2",{style:D,children:"The facts"}),nn(y,we).map((f,L)=>{let Z=(0,w.jsx)("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"14px 24px"},children:f.fields.map(B=>B.long?(0,w.jsx)(On,{nodeId:s,field:B.key,label:B.label,value:B.value,style:{gridColumn:"1 / -1",gap:4},labelStyle:{...se,fontSize:"0.75rem"},valueStyle:{fontSize:"1.0625rem",lineHeight:1.6}},B.key):(0,w.jsxs)("div",{style:{display:"grid",gap:2,minWidth:0,alignContent:"start"},children:[(0,w.jsx)("dt",{style:{...se,fontSize:"0.75rem"},children:B.label}),(0,w.jsx)("dd",{style:{margin:0,fontSize:"1.125rem",overflowWrap:"anywhere",minWidth:0},children:r?(0,w.jsx)(bt,{nodeId:s,field:B.key,value:B.value,stored:B.stored}):B.value})]},B.key))});return f.title?(0,w.jsxs)("section",{style:{display:"grid",gap:10,minWidth:0},children:[(0,w.jsx)("h3",{"data-graview-field-group":f.title,style:{...D,fontSize:"1.0625rem"},children:f.title}),Z]},L):(0,w.jsx)("div",{children:Z},L)})]}):null,(ne?[]:N).map(f=>(0,w.jsxs)("section",{style:{...j,display:"grid",gap:10},children:[(0,w.jsx)("p",{style:se,children:Un(t,f)}),f.description?(0,w.jsx)("h2",{style:D,children:le(f.description)}):(0,w.jsxs)("h2",{style:D,"aria-label":re(f.edgeKind),children:[f.direction==="in"?"\u2190 ":"\u2192 ",re(f.edgeKind)]}),(0,w.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"6px 18px"},children:f.targets.map(L=>(0,w.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,w.jsx)(ee,{kind:L.kind,brand:n,schema:t.schema,size:7}),(0,w.jsxs)(A,{to:q(t.schema,L.kind,L.id),style:{...$,fontSize:"1.125rem"},children:[L.label,L.apart?(0,w.jsxs)("span",{style:k,children:[" \xB7 ",L.apart]}):null]})]},L.id))}),(f.direction==="out"&&t.schema.edge(f.edgeKind)?.cardinality==="one"?[]:[...new Set(f.targets.map(L=>L.kind))]).map(L=>(0,w.jsxs)(A,{to:`/${G(t.schema,L)}?${encodeURIComponent(f.edgeKind)}=${encodeURIComponent(s)}`,style:{...$,...k},"data-testid":"related-all",children:["Sort and filter ",f.description??`these ${I(t,L).toLowerCase()}`,f.targets.some(Z=>Z.kind!==L)?` (${I(t,L).toLowerCase()})`:""," \u2192"]},L))]},`${f.edgeKind}|${f.direction}|${f.description??""}`)),!ne&&(C.length>0||l.actions.withheld.length>0)?(0,w.jsxs)("section",{style:{...j,display:"grid",gap:14},"data-testid":"record-actions",children:[(0,w.jsx)("h2",{style:D,ref:g,tabIndex:-1,children:"What can be done"}),(0,w.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:C.map(f=>{let L=u===f.id;return(0,w.jsx)("button",{type:"button","data-affordance":f.id,"data-rank":f.rank,"aria-expanded":L,onClick:()=>m(L?null:f.id),style:{...et,...L?{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"}:{}},children:f.label},f.id)})}),C.map(f=>{if(u!==f.id)return null;let L=t.allMutations().find(Z=>Z.name===f.mutation);return L?(0,w.jsxs)("div",{style:{display:"grid",gap:10,padding:18,border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,w.jsx)("h3",{style:{...D,fontSize:"1.1875rem"},children:f.label}),L.description?(0,w.jsx)("p",{style:{...k,margin:0},children:L.description}):null,(0,w.jsx)(ye,{store:t,mutation:L,prefilled:f.args,open:f.open,label:f.label,onDone:()=>{m(null);let Z=f.id;requestAnimationFrame(()=>{(g.current?.parentElement?.querySelector(`[data-affordance="${Z.replace(/["\\]/g,"\\$&")}"]`)??g.current)?.focus()})},...a?{principal:a}:{}})]},f.id):null}),l.actions.withheld.length>0?(0,w.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:l.actions.withheld.map(f=>(0,w.jsxs)("li",{style:k,children:[(0,w.jsx)("s",{children:f.label})," \u2014 ",f.refusal.message]},f.id))}):null]}):null,F.length>0?(0,w.jsxs)("section",{style:{...j,display:"grid",gap:10},"data-testid":"record-history",children:[(0,w.jsx)("h2",{style:D,children:"What has happened"}),(0,w.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:F.map(f=>(0,w.jsxs)("li",{style:k,children:[(0,w.jsx)("span",{style:{color:"var(--graview-ink)"},children:f.intent})," \u2014 ",tt(f,a,{graph:t.graph,schema:t.schema,...e.seats?{seats:e.seats}:{},...e.people?{people:e.people}:{}})]},f.id))})]}):null]})}var v=O(z(),1),tr=(0,W.lazy)(()=>import("./chunk.TWFYXD3P.js").then(e=>({default:e.DraftPage})));function nr({context:e,children:t}){let n=he(),a=e.store.schema,i=(0,W.useMemo)(()=>({href:r=>q(a,r.kind,r.id),go:r=>n(q(a,r.kind,r.id))}),[a,n]);return(0,v.jsx)(Nn.Provider,{value:i,children:(0,v.jsx)(Dn.Provider,{value:(e.titleLevel??(e.framed&&!e.barAbove?1:2))-1,children:t})})}function ar({steering:e}){let t=de(),n=he(),a=`${t.pathname}${t.search}`;return(0,W.useLayoutEffect)(()=>e.at(a),[a,e]),(0,W.useLayoutEffect)(()=>{let i=d=>{d!==a&&n(d)};e.go.current=i;let r=e.pending?.current;return r!==void 0&&(e.pending.current=void 0,i(r)),()=>{e.go.current===i&&(e.go.current=void 0)}},[a,n,e]),null}function rr({context:e,to:t}){let{pathname:n}=de(),a=oe(),i=(t??a)?.sayWhere,r=ir(e,n);return(0,W.useEffect)(()=>(i?.(r),()=>i?.(null)),[i,r]),null}function ir(e,t){let[n="",a,i]=t.split("/").filter(Boolean).map(d=>{try{return decodeURIComponent(d)}catch{return d}});if(i!==void 0)return"#";if(n==="places"&&a!==void 0){if(a===wt)return"#overview=1";let d=e.views?.places().find(s=>s.as===a);return d?`#focus=${encodeURIComponent(Ie(d.kind))}&view=${encodeURIComponent(d.as)}`:"#"}let r=fe(e.store.schema,n);return r?`#focus=${encodeURIComponent(a??Ie(r))}`:"#"}function or({onNavigate:e,path:t}){let n=de(),a=Pt(),i=he(),r=`${n.pathname}${n.search}`,d=(0,W.useRef)(e);d.current=e;let s=(0,W.useRef)(null);(0,W.useEffect)(()=>{let o=s.current;s.current=r,o!==null&&(r===o&&a!=="PUSH"||d.current?.(r,a==="POP"?"pop":a==="REPLACE"?"replace":"push"))},[n.key]);let l=(0,W.useRef)(t);return(0,W.useEffect)(()=>{t===void 0||t===l.current||(l.current=t,t!==r&&i(t))},[t]),null}function ka({context:e,registry:t,page:n}){let a=ke(),i=fe(e.store.schema,a.slug??""),r=n==="list"?Ht:Bt,s=(i?t?.lookup(i,n):void 0)??r;return(0,v.jsx)(s,{context:e})}function sr({context:e,registry:t,children:n}){let a=(0,W.useRef)(null);return Pn(a),(0,v.jsx)("div",{ref:a,"data-graview-face":"pages",style:{display:"contents"},children:(0,v.jsx)(ca,{context:e,registry:t,root:a,children:n})})}function lr(){let{pathname:e}=de(),t=Pt(),n=(0,W.useRef)(null);(0,W.useLayoutEffect)(()=>{if(t!=="POP"){for(let r=n.current?.parentElement;r;r=r.parentElement){let{overflowY:d}=getComputedStyle(r);if((d==="auto"||d==="scroll")&&r.scrollHeight>r.clientHeight){r.scrollTop=0;return}}window.scrollTo(0,0)}},[e]);let a=(0,W.useRef)(e),i=(0,W.useRef)(!1);return(0,W.useEffect)(()=>{if(!i.current&&e===a.current)return;i.current=!0;let r=document.activeElement;if(r!==null&&r!==document.body&&r!==document.documentElement)return;let d=n.current?.closest("main")??document.querySelector("main"),l=n.current?.closest("[data-graview-face]")?.querySelector("[data-graview-page-title]")??d?.querySelector("h1, h2")??null??d??null;l&&(l.hasAttribute("tabindex")||l.setAttribute("tabindex","-1"),l.focus({preventScroll:!0}))},[e]),(0,v.jsx)("span",{ref:n,hidden:!0,"data-graview-scroll-reset":""})}function dr({context:e,children:t}){let n=he(),a=(0,W.useMemo)(()=>({record:i=>{let r=e.store.graph.getNode(i);r&&n(q(e.store.schema,r.kind,i))},place:i=>{let r=e.views?.places().find(d=>d.as===i);r&&n(ge(e,r))}}),[e,n]);return(0,v.jsx)(bn.Provider,{value:a,children:t})}function pr({context:e,Home:t}){let i=de().key==="default"?yn(e.views?.arrangement?.()?.first,e.store.schema,e.views?.places()??[]):void 0,r=i?.to==="place"?ge(e,i.place):i?.to==="kind"?`/${G(e.store.schema,i.kind)}`:void 0;return r?(0,v.jsx)(Ct,{to:r,replace:!0}):(0,v.jsx)(t,{context:e})}function Sa({context:e,registry:t}){let n=t?.lookupSurface("shell"),a=n!==void 0,i=a&&(t?.without().has("bar")??!1),r=a&&!i&&!e.embedded?{...e,barAbove:!0}:e,d=y=>n===void 0?(0,v.jsx)(rt,{context:e,children:y}):i?(0,v.jsx)(n,{context:e,children:y}):(0,v.jsx)(rt,{context:e,children:(0,v.jsx)(n,{context:r,children:y})}),s=t?.lookupSurface("home")??It,l=t?.lookupSurface("problems")??zt,o=a?{...r,framed:!0}:e,[u,m]=(0,W.useState)(null),g=(0,W.useMemo)(()=>({onFind:m,find:!(t?.without().has("find")??!1),places:!(t?.without().has("places")??!1)}),[t]),c=(0,v.jsx)(sr,{context:e,registry:t,children:(0,v.jsx)(dr,{context:e,children:d((0,v.jsx)(v.Fragment,{children:(0,v.jsxs)(nr,{context:o,children:[(0,v.jsx)(lr,{}),(0,v.jsxs)(Jn,{children:[(t?.routes()??[]).map(({path:y,component:P})=>(0,v.jsx)(pe,{path:y,element:(0,v.jsx)(P,{context:o})},y)),(0,v.jsx)(pe,{path:"/",element:(0,v.jsx)(pr,{context:o,Home:s})}),(0,v.jsx)(pe,{path:"/problems",element:(0,v.jsx)(l,{context:o})}),(0,v.jsx)(pe,{path:"/~draft",element:(0,v.jsx)(W.Suspense,{fallback:null,children:(0,v.jsx)(tr,{context:o})})}),(0,v.jsx)(pe,{path:"/search",element:(0,v.jsx)(Kt,{context:o})}),(0,v.jsx)(pe,{path:"/map",element:(0,v.jsx)(Dt,{context:o})}),(0,v.jsx)(pe,{path:"/places",element:(0,v.jsx)(Wt,{context:o})}),ce(o).some(y=>y.as===wt)?null:(0,v.jsx)(pe,{path:mn,element:(0,v.jsx)(Ct,{to:"/",replace:!0})}),(0,v.jsx)(pe,{path:"/places/:as",element:(0,v.jsx)(Nt,{context:o})}),(0,v.jsx)(pe,{path:"/:slug",element:(0,v.jsx)(ka,{context:o,registry:t,page:"list"})}),(0,v.jsx)(pe,{path:"/:slug/:id",element:(0,v.jsx)(ka,{context:o,registry:t,page:"record"})})]})]})}))})});return e.embedded||!a||i?c:(0,v.jsx)(Zn.Provider,{value:g,children:(0,v.jsx)(Ln.Provider,{value:u,children:c})})}function cr({context:e,registry:t,basename:n,initialPath:a,onNavigate:i,path:r,steering:d}){(0,W.useState)(()=>e.views?Kn(e.views,e.store.schema,Mn(e.brand,e.store.schema)):void 0);let s=oe(),l=e.store.seenBy(e.principal??{kind:"human"}),o=l===e.store?e:{...e,store:l};kn(e.store,e.principal);let u=(0,v.jsxs)(v.Fragment,{children:[i||r!==void 0?(0,v.jsx)(or,{onNavigate:i,path:r}):null,d?(0,v.jsx)(ar,{steering:d}):null,o.presence||s?(0,v.jsx)(rr,{context:o,to:s}):null,(0,v.jsx)(Sa,{context:o,...t?{registry:t}:{}})]}),m=o.views?(0,v.jsxs)(Sn,{store:o.store,views:o.views,...o.principal?{principal:o.principal}:{},...o.brand?{brand:o.brand}:{},...o.settings?{settings:o.settings}:{},...o.presence&&!s?{presence:o.presence}:{},...o.people?{people:o.people}:{},...o.onKeepLens?{onKeepLens:o.onKeepLens}:{},...o.ai?{ai:o.ai}:{},...o.app?{app:o.app}:{},children:[u,(0,v.jsx)(la,{context:o})]}):u;if(a!==void 0){let g=n===void 0?a:`${n.replace(/\/$/,"")}${a}`;return(0,v.jsx)(Yn,{initialEntries:[g],...n===void 0?{}:{basename:n},children:m})}return(0,v.jsx)(Qn,{...n===void 0?{}:{basename:n},children:m})}export{Oa as a,cr as b};
@@ -1 +0,0 @@
1
- import{e as ge}from"./chunk.ISAMJ7AK.js";import{Cb as he,I as _,K as M,L as J,La as G,N as re,O as se,Q as W,R as ae,S as B,T as K,W as de,Xa as pe,ga as ce,ha as P,ia as le,ja as j,ka as ue,wa as fe}from"./chunk.ZQ4HFIIS.js";function me(e){let t=new Set;for(let n=e;n;n=n.onBehalfOf)n.id!==void 0&&t.add(`${n.kind}:${n.id}`);return t}function F(e,t){let n=me(t),u=p=>{if(p.kind==="rule")return!1;let d=me(p);if(d.size===0)return!1;for(let g of d)if(n.has(g))return!1;return!0},f,c=()=>{if(f)return f;f=new Map;for(let p of e.log.live()){if(p.undoes!==void 0)continue;let d=u(p.author)?p.author:void 0;for(let g of p.primitives){g.op==="remove-node"&&f.delete(g.node.id);let s=g.op==="add-node"?g.node.id:g.op==="patch-node"?g.id:void 0;if(s===void 0)continue;let a=g.op==="add-node"?Object.keys(g.node):Object.keys(g.after),h=f.get(s);(g.op==="add-node"||!h)&&f.set(s,h=new Map);for(let y of a)y==="id"||y==="kind"||(d?h.set(y,d):h.delete(y))}}return f},S=e.schema,v=new Map,i=(p,d)=>{let g=`${p}\0${d}`,s=v.get(g);if(s===void 0){let a=S.tryDefinition(p)?.fields?.shape;s=a!==void 0&&d in a&&le(a[d]).type==="text",v.set(g,s)}return s},l=p=>e.graph.getNode(p)?.kind;return{prose:i,say:p=>de(p,{graph:e.graph,schema:S}),fieldBy(p,d){let g=l(p);if(!(g===void 0||!i(g,d)))return c().get(p)?.get(d)},recordBy(p){let d=l(p),g=c().get(p);if(d===void 0||!g)return;let s;for(let[a,h]of g)i(d,a)&&(s=h);return s}}}var E=(e,t,n)=>({untrusted:!0,authoredBy:n.say(t),text:e});function z(e,t){let n;for(let[u,f]of Object.entries(e)){if(typeof f!="string"||u==="id"||u==="kind")continue;let c=t.fieldBy(e.id,u);c&&(n??={...e},n[u]=E(f,c,t))}return n??e}function ye(e,t,n){let u=f=>{if(Array.isArray(f))return f.map(u);if(f!==null&&typeof f=="object"&&"id"in f&&"label"in f){let c=f,S=n.recordBy(c.id);return S?{...c,label:E(c.label,S,n)}:c}if(typeof f=="string"){let c=n.recordBy(e);return c?E(f,c,n):f}return f};return Object.fromEntries(Object.entries(t).map(([f,c])=>[f,u(c)]))}function ke(e,t){return{...e,nodes:e.nodes.map(n=>z(n,t))}}function we(e,t){return{...e,hits:e.hits.map(n=>{if(n.about!=="node")return n;let u=t.recordBy(n.id);if(!u)return n;let f=t.prose(n.kind,n.why.field)?t.fieldBy(n.id,n.why.field):u;return{...n,label:E(n.label,u,t),...n.apart!==void 0?{apart:E(n.apart,u,t)}:{},why:f?{...n.why,fragment:E(n.why.fragment,f,t)}:n.why}})}}function be(){return{name:"insight",derive({store:e,nodes:t,kindSelection:n}){let u=[],f=c=>_(e.schema.tryDefinition(c.kind),c);for(let c of t){if([...e.schema.edgeKinds].reduce((v,i)=>v+e.graph.out(c.id,i).length+e.graph.in(c.id,i).length,0)===0){u.push({id:`insight:island:${c.id}`,text:`${f(c)} is connected to nothing yet`,nodeIds:[c.id]});continue}for(let v of e.schema.edgeKinds){let i=e.graph.in(c.id,v).length;if(i<3)continue;let l=[...e.graph.allEdges()].filter(d=>d.kind===v),p=l.length;p>=4&&i/p>.6&&u.push({id:`insight:load:${c.id}:${v}`,text:`${f(c)} ${Ee(e,l,v,i)}`,nodeIds:[c.id]})}}for(let c of n){if(e.graph.nodesOfKind(c).length>0)continue;let S=e.schema.definitions.filter(v=>v.kind!==c).filter(v=>Object.values(v.edges).some(i=>i.to!=="*"&&i.to.includes(c))).map(v=>v.plural??`${v.kind}s`);S.length>0&&u.push({id:`insight:gap:${c}`,text:`Nothing here yet, though ${S.join(" and ")} expect to connect to these`,nodeIds:[]})}return{observations:u}}}}function Ee(e,t,n,u){let f=new Set(t.map(l=>e.graph.getNode(l.from)?.kind).filter(l=>l!==void 0)),c=f.size===1?[...f][0]:void 0,S=t.length,v=W(e.schema,c??[...f][0]??"",n,"in"),i=l=>c?re(e.schema,c,l):String(l);return u===S?`${v}: all ${i(u)}`:`${v}: ${u} of the ${i(S)}`}function ve(e){let t=new Map;if(e.length===0)return t;let n=e.slice(-512),u=new Set;for(let c of n)c.undoes&&u.add(c.undoes);let f=e[e.length-1].seq;for(let c of n){if(!c.mutation||u.has(c.id))continue;let S=Math.pow(.5,(f-c.seq)/64);t.set(c.mutation.name,(t.get(c.mutation.name)??0)+S)}return t}function Se(e){return 8*(e/(e+1))}var Ce=100;function Ae(){return{name:"invariant",derive({store:e,selection:t,nodes:n,violations:u}){let f=l=>_(e.schema.tryDefinition(l.kind),l),c=new Set(t),S=u.filter(l=>l.nodeIds.some(p=>c.has(p))||l.subjectId!==void 0&&c.has(l.subjectId)),v=[],i=[];S.forEach((l,p)=>{i.push({id:`violation:${l.invariant}:${p}`,text:l.message,nodeIds:l.nodeIds}),l.repairs.forEach((d,g)=>{v.push({id:`invariant:${l.invariant}:${p}:${g}`,label:d.label,provider:"invariant",mutation:d.mutation,args:d.args??{},open:(d.missing??[]).map(s=>{let a=e.allMutations().find(o=>o.name===d.mutation);if(!a)return{name:s};let h=P(a.input).find(o=>o.name===s),y=h?h.kinds.includes("*")?e.graph.allNodes().map(o=>o.id):h.kinds.flatMap(o=>e.graph.nodesOfKind(o).map(r=>r.id)):void 0;return{name:s,shape:j(a.input,s),...h?{kinds:h.kinds}:{},...y?{candidates:y}:{}}}),score:Ce-g-(d.missing?.length??0),why:l.message,nodeIds:l.nodeIds,...l.subjectId===void 0?{}:{subjectId:l.subjectId}})})});for(let l of n){let p=e.allInvariants().filter(d=>{if(d.scope==="graph")return!1;let g=d.scope;return g.kind!==l.kind?!1:g.match?g.match(l):!0});p.length!==0&&(S.some(d=>d.subjectId===l.id||d.nodeIds.includes(l.id))||i.push({id:`holds:${l.id}`,text:`${f(l)} holds \u2014 nothing currently breaks ${p.length===1?"it":`any of its ${p.length} rules`}`,nodeIds:[l.id]}))}return{affordances:v,observations:i}}}}var Z=40;function $e(){return{name:"schema",derive({store:e,selection:t,nodes:n,kindSelection:u,edgeSelection:f}){let c=[];if(n.length===0&&f.length>0){for(let i of f){let l=e.graph.getNode(i.from),p=e.graph.getNode(i.to);if(!(!l||!p))for(let d of e.allMutations()){let g=(d.connects??[]).includes(i.kind),s=(d.severs??[]).includes(i.kind);if(!g&&!s)continue;let a={},h=[],y=P(d.input);for(let r of y){let w=r.kinds.includes("*")||r.kinds.includes(l.kind),b=r.kinds.includes("*")||r.kinds.includes(p.kind),A=w&&!y.some(k=>k!==r&&(k.kinds.includes(l.kind)||k.kinds.includes("*")));w&&!b?a[r.name]=i.from:b&&!w?a[r.name]=i.to:w&&b&&A?a[r.name]=i.from:h.push({name:r.name,kinds:r.kinds,candidates:[i.from,i.to],shape:j(d.input,r.name)})}for(let r of q(d.input,""))r in a||h.some(w=>w.name===r)||h.push({name:r,shape:j(d.input,r)});h.every(r=>r.optional===!0?!0:r.kinds!==void 0?(r.candidates?.length??0)>0:(r.candidates?.length??0)>0||r.shape!==void 0&&r.shape.type!=="unknown")&&(g&&!s&&h.length===0||c.push({id:`schema:edge:${d.name}:${i.kind}:${i.from}:${i.to}`,label:M(d),provider:"schema",mutation:d.name,args:a,open:h,...d.destructive?{destructive:!0}:{},score:(s?62:58)-h.length,why:`this line is "${W(e.schema,e.graph.getNode(i.from)?.kind??"",i.kind,"out")}"`,nodeIds:[i.from,i.to]}))}}return{affordances:c}}if(n.length===0&&u.length>0){let i=new Set(u),l=[];for(let p of e.allMutations()){if(!(p.creates??[]).some(s=>i.has(s)))continue;let d=[];for(let s of P(p.input)){let a=s.kinds.includes("*")?e.graph.allNodes().map(h=>h.id):s.kinds.flatMap(h=>e.graph.nodesOfKind(h).map(y=>y.id));d.push({name:s.name,kinds:s.kinds,candidates:a,shape:j(p.input,s.name),...s.optional?{optional:!0}:{}})}for(let s of q(p.input,""))d.some(a=>a.name===s)||d.push({name:s,shape:j(p.input,s)});if(!d.every(s=>s.optional===!0?!0:s.kinds!==void 0?(s.candidates?.length??0)>0:(s.candidates?.length??0)>0||s.shape!==void 0&&s.shape.type!=="unknown")){let s=d.filter(a=>a.optional!==!0&&a.kinds!==void 0&&!a.kinds.includes("*")&&(a.candidates?.length??0)===0);if(s.length>0){let a=[...new Set(s.flatMap(h=>h.kinds??[]))].map(h=>B(K(e.schema.tryDefinition(h),h)));l.push({id:`schema:waits:${p.name}`,text:`"${p.title??p.name}" cannot begin until there is ${a.length===1?a[0]:`${a.slice(0,-1).join(", ")} and ${a[a.length-1]}`}.`,nodeIds:[]})}continue}c.push({id:`schema:add:${p.name}`,label:M(p),provider:"schema",mutation:p.name,args:{},open:d,score:Z-d.length,why:`this makes ${(p.creates??[]).filter(s=>i.has(s)).map(s=>B(K(e.schema.tryDefinition(s),s))).join(", ")}`,nodeIds:[]})}return{affordances:c,observations:l}}if(n.length===0)return{};let S=new Set(n.map(i=>i.kind)),v=(i,l,p)=>{let d=[];for(let g of e.graph.allEdges()){if(!l.includes(g.kind))continue;let s=g.from===i?g.to:g.to===i?g.from:null;if(!s)continue;let a=e.graph.getNode(s);a&&(!p.includes("*")&&!p.includes(a.kind)||d.includes(s)||d.push(s))}return d};for(let i of e.allMutations()){let l=i.subject;if(!l||!(l.kinds==="*"?!0:[...S].every(o=>l.kinds.includes(o))))continue;let d=n.length===1?n[0].id:null,g=i.severs??[],s=i.connects??[];if(d&&g.length>0&&s.length===0&&v(d,g,["*"]).length===0)continue;let a=[];for(let o of P(i.input)){if(o.name===l.arg)continue;let r=o.kinds.includes("*")?e.graph.allNodes().map(w=>w.id):o.kinds.flatMap(w=>e.graph.nodesOfKind(w).map(b=>b.id));if(d&&s.length>0){let w=new Set(v(d,s,o.kinds));r=r.filter(b=>!w.has(b))}else d&&g.length>0&&(r=v(d,g,o.kinds));a.push({name:o.name,kinds:o.kinds,candidates:r.filter(w=>!t.includes(w)),shape:j(i.input,o.name),...o.optional?{optional:!0}:{}})}for(let o of q(i.input,l.arg))a.some(r=>r.name===o)||a.push({name:o,shape:j(i.input,o)});if(a.length===0&&d){let o=He(i.input,l.arg);if(o.length>0&&!Le(e,i.name,{[l.arg]:d}))for(let r of o){let w=P(i.input).find(b=>b.name===r);a.push({name:r,optional:!0,...w?{kinds:w.kinds}:{},shape:j(i.input,r)})}}if(!a.every(o=>o.optional===!0?!0:o.kinds!==void 0?(o.candidates?.length??0)>0:(o.candidates?.length??0)>0||o.shape!==void 0&&o.shape.type!=="unknown"))continue;let y=n.map(o=>({[l.arg]:o.id}));a.length===0&&!y.some(o=>e.wouldChange({name:i.name,args:o}))||c.push({id:`schema:${i.name}`,label:n.length>1?`${M(i)} (${n.length})`:M(i),provider:"schema",mutation:i.name,args:y[0]??{},open:a,...i.destructive?{destructive:!0}:{},...g.length>0||s.length>0?{ties:!0}:{},...n.length>1?{batch:y}:{},score:Z-a.length,why:n.length>1?`all ${n.length} selected nodes are ${[...S].map(o=>se(e.schema,o).toLowerCase()).join(" or ")}`:`this is ${B(K(e.schema.tryDefinition(n[0].kind),n[0].kind))}`,nodeIds:n.map(o=>o.id)})}if(n.length===1){let i=n[0];for(let l of e.allMutations()){let p=l.subject,d=l.severs??[],g=l.connects??[];if(!p||d.length===0&&g.length===0)continue;let s=p.kinds==="*"?"*":p.kinds;if(s==="*"||s.includes(i.kind))continue;let a=P(l.input),h=a.find(k=>k.name!==p.arg&&(k.kinds.includes("*")||k.kinds.includes(i.kind)));if(!h)continue;let y=s,o=y.includes("*")?e.graph.allNodes().map(k=>k.id):y.flatMap(k=>e.graph.nodesOfKind(k).map(R=>R.id)),r=new Set(v(i.id,g.length>0?g:d,y)),w=g.length>0?o.filter(k=>!r.has(k)):o.filter(k=>r.has(k));if(w.length===0)continue;let b=[{name:p.arg,kinds:y,candidates:w,shape:j(l.input,p.arg)}];for(let k of a){if(k.name===h.name||k.name===p.arg)continue;let R=k.kinds.includes("*")?e.graph.allNodes().map(x=>x.id):k.kinds.flatMap(x=>e.graph.nodesOfKind(x).map(O=>O.id));b.push({name:k.name,kinds:k.kinds,candidates:R,shape:j(l.input,k.name),...k.optional?{optional:!0}:{}})}for(let k of q(l.input,h.name))k===p.arg||b.some(R=>R.name===k)||b.push({name:k,shape:j(l.input,k)});b.every(k=>k.optional===!0?!0:k.kinds!==void 0?(k.candidates?.length??0)>0:(k.candidates?.length??0)>0||k.shape!==void 0&&k.shape.type!=="unknown")&&c.push({id:`schema:tie:${l.name}:${i.id}`,label:l.fromTheOtherEnd??M(l),provider:"schema",mutation:l.name,args:{[h.name]:i.id},open:b,ties:!0,...l.destructive?{destructive:!0}:{},score:Z-b.length+2,why:`${d.length>0?"this one is on":"this one could join"} ${b[0].candidates.length===1?"it":"one of these"}`,nodeIds:[i.id]})}}return{affordances:c}}}}function He(e,t){let n=e.shape;return n?Object.entries(n).filter(([u,f])=>u!==t&&f.safeParse(void 0).success).map(([u])=>u):[]}function Le(e,t,n){try{return e.preview({name:t,args:n}),!0}catch{return!1}}function q(e,t){let n=e.shape;return n?Object.entries(n).filter(([u,f])=>u!==t&&!f.safeParse(void 0).success).map(([u])=>u):[]}var We=70,Be=80,Ke=new Set(["id","kind"]);function Oe(){return{name:"structure",derive({store:e,nodes:t}){let n=i=>_(e.schema.tryDefinition(i.kind),i);if(t.length<2)return{};let u=[],f=[],c=t.map(i=>i.id);for(let i of e.schema.edgeKinds){let l=Ge(t.map(d=>new Set([...e.graph.out(d.id,i).map(g=>g.id),...e.graph.in(d.id,i).map(g=>g.id)])));for(let d of l){let g=e.graph.getNode(d);g&&u.push({id:`shared:${i}:${d}`,text:`all ${t.length} share "${n(g)}" (${J(i).toLowerCase()})`,nodeIds:[...c,d]})}let p=new Map;for(let d of t)for(let g of[...e.graph.out(d.id,i),...e.graph.in(d.id,i)])p.set(g.id,(p.get(g.id)??0)+1);for(let[d,g]of p){if(g!==t.length-1||t.length<3)continue;let s=e.graph.getNode(d);if(!s)continue;let a=t.find(h=>![...e.graph.out(h.id,i),...e.graph.in(h.id,i)].some(y=>y.id===d));if(a){u.push({id:`near-shared:${i}:${d}`,text:`all but "${n(a)}" share "${n(s)}" (${J(i).toLowerCase()})`,nodeIds:[...c,d]});for(let h of e.allMutations()){let y=h.subject;if(!y||y.kinds!=="*"&&!y.kinds.includes(a.kind))continue;let o=Fe(h.input,s.kind);o&&f.push({id:`structure:join:${h.name}:${a.id}:${d}`,label:`${M(h)}: bring "${n(a)}" in line with the others`,provider:"structure",mutation:h.name,args:{[y.arg]:a.id,[o]:d},open:[],score:We,why:`every other selected node is connected to "${n(s)}"`,nodeIds:[a.id,d]})}}}}let S=new Set;for(let i of t)for(let l of Object.keys(i))Ke.has(l)||S.add(l);let v=i=>e.schema.definitions.find(l=>l.kind===i);for(let i of[...S].sort()){let l=v(t[0].kind),p=ae(l,i).toLowerCase(),d=l?.display?.format?.[i],g=A=>{if(!d)return A;try{return String(d(JSON.parse(A)))}catch{return A}},s=t.map(A=>A[i]),a=new Map;if(s.forEach((A,k)=>{let R=JSON.stringify(A??null),x=a.get(R);x?x.push(t[k]):a.set(R,[t[k]])}),a.size===1){let A=[...a.keys()][0];if(A==="null")continue;u.push({id:`agree:${i}`,text:`all ${t.length} share the ${p} ${g(A)}`,nodeIds:c});continue}if(t.length<3||a.size!==2)continue;let h=[...a.entries()].sort((A,k)=>k[1].length-A[1].length),[y,o]=h[0],[,r]=h[1];if(r.length!==1||y==="null")continue;let w=r[0],b=JSON.parse(y);u.push({id:`odd-one-out:${i}`,text:`${o.length} share the ${p} ${g(y)}; "${n(w)}" does not`,nodeIds:c});for(let A of e.allMutations()){let k=A.subject;if(!k||k.kinds!=="*"&&!k.kinds.includes(w.kind))continue;let R=Re(A.input);if(!R||!(i in R))continue;let x={[k.arg]:w.id,[i]:b},O=!0;for(let[D,U]of Object.entries(R)){if(D in x||U.safeParse(void 0).success)continue;let C=w[D];if(C===void 0){O=!1;break}x[D]=C}O&&f.push({id:`structure:align:${A.name}:${i}:${w.id}`,label:`Align the ${p} of "${n(w)}" with the other ${o.length}`,provider:"structure",mutation:A.name,args:x,open:[],score:Be,why:`${o.length} of ${t.length} share the ${p} ${g(y)}`,nodeIds:c})}}return{affordances:f,observations:u}}}}function Ge(e){if(e.length===0)return[];let[t,...n]=e;return[...t].filter(u=>n.every(f=>f.has(u))).sort()}function Re(e){return e.shape??null}function Fe(e,t){let n=Re(e);if(!n)return null;for(let[u]of Object.entries(n)){let f=ce(n[u]);if(f&&(f.includes("*")||f.includes(t)))return u}return null}function qe(){return[Ae(),Oe(),$e(),be()]}function je(e,t,n={}){let u=xe(),f=n.providers??qe(),c=t.map(m=>e.graph.getNode(m)).filter(m=>m!==void 0),S={store:e,selection:t,nodes:c,kindSelection:n.kindSelection??[],edgeSelection:n.edgeSelection??[],violations:e.violations(n.context),context:n.context??{}},v=[],i=[];for(let m of f){let $=m.derive(S);v.push(...$.affordances??[]),i.push(...$.observations??[])}let l=new Set(e.allMutations().filter(m=>m.pinned).map(m=>m.name)),p=new Set(n.pins?.pinned??[]),d=new Set(n.pins?.unpinned??[]),g=m=>p.has(m.mutation)?"user":l.has(m.mutation)&&!d.has(m.mutation)?"declared":void 0,s=m=>{let $=g(m);return $?{...m,pinned:$}:m},a=new Map;for(let[m,$]of ve(e.log.all()))a.set(m,Se($));let h=m=>m.pinned==="user"?0:m.pinned==="declared"?1:2,y=m=>m.score+(a.get(m.mutation)??0),o=new Map(e.allMutations().map(m=>[m.name,m])),r=new Map,w=m=>{let $=o.get(m.mutation);if(!$)return[];let N=r.get(m.mutation);N||(N=P($.input).map(V=>V.name),r.set(m.mutation,N));let H=[];for(let V of m.batch??[m.args])for(let ie of N){let oe=V[ie]??m.args[ie];typeof oe=="string"&&H.push(oe)}return H},b=n.focus,A=4,k=m=>m.open.length>0?1:0,R=m=>{if(b===void 0)return A;let $=w(m);return $.length>0?$.includes(b)?x(m,0):A:m.nodeIds.includes(b)||m.subjectId===b?x(m,1):A},x=(m,$)=>m.provider==="invariant"?$:2+k(m),O=Ue(v).map(s),D=new Map(O.map((m,$)=>[m,$])),U=O.sort((m,$)=>{let N=Number(m.destructive??!1)-Number($.destructive??!1);if(N!==0)return N;let H=R(m)-R($);return H!==0?H:R(m)<2?D.get(m)-D.get($):+($.provider==="invariant")-+(m.provider==="invariant")||h(m)-h($)||y($)-y(m)||m.id.localeCompare($.id)}),C=n.principal??{kind:"human"},L=[],ne=[];for(let m of U){let $=e.permits({name:m.mutation,args:{...m.args,...m.batch?.[0]??{}}},C);if($.ok)L.push(m);else{let N=ze(e,m,C);if(N==="done")continue;N?L.push(N):ne.push({...m,refusal:$.refusal})}}let te=L.map((m,$)=>({...m,rank:$})),_e=ne.map((m,$)=>({...m,rank:L.length+$}));return{affordances:n.limit===void 0?te:te.slice(0,n.limit),withheld:_e,observations:Ve(i),ms:xe()-u}}function Ue(e){let t=new Map;for(let n of e){let u=[n.mutation,JSON.stringify(n.args),JSON.stringify(n.batch??null)].join("|"),f=t.get(u);(!f||n.score>f.score)&&t.set(u,n)}return[...t.values()]}function Ve(e){let t=new Map;for(let n of e)t.set(n.text,n);return[...t.values()]}function xe(){return typeof performance<"u"?performance.now():Date.now()}function Je(e,t,n={},u={}){let f=(t.batch??[t.args]).map(S=>({name:t.mutation,args:{...t.args,...S,...n}})),c=e.allMutations().find(S=>S.name===t.mutation);return e.applyAll(f,{...c?.describe?{}:{intent:t.label},...u.author?{author:u.author}:{}})}function Rn(e,t,n={}){return e.preview({name:t.mutation,args:{...t.args,...n}})}function ze(e,t,n){let u=e.allMutations().find(i=>i.name===t.mutation)?.subject;if(!u||t.args[u.arg]!==void 0)return;let f=t.open.find(i=>i.name===u.arg);if(!f?.candidates)return;let c=i=>e.permits({name:t.mutation,args:{...t.args,...t.batch?.[0]??{},[u.arg]:i}},n).ok,S=f.candidates.filter(c),v=n.id===void 0?void 0:e.graph.getNode(n.id);return S.length===0?v!==void 0&&(u.kinds==="*"||u.kinds.includes(v.kind))&&c(v.id)?"done":void 0:S.length===1&&S[0]===n.id?{...t,args:{...t.args,[u.arg]:n.id},open:t.open.filter(i=>i!==f)}:{...t,open:t.open.map(i=>i===f?{...i,candidates:S}:i)}}var Pe,Ze=()=>Pe??=import("./chunk.3TNQPFIK.js").catch(e=>{throw Pe=void 0,e}),Xe=()=>import("./chunk.KWSXL3A2.js").catch(()=>{}),Ye=async()=>{(await Xe())?.judgeWithLines()},Ne,Qe=()=>Ne??=import("./chunk.OXODTBOP.js").catch(e=>{throw Ne=void 0,e}),T=e=>({title:e,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}),X=[{name:"search_graph",title:"Find by name",description:"Find things by name: records whose name or readable fields carry the words, and the kinds, places and rules the words name \u2014 each with why it matched. Reach for this before get_graph when you know what something is called. Words match the start of words, case and accents aside; key:value tokens narrow as a list's filter does (done:false, is:any for past records, kind:<kind>). Pass subject (a node id) to get the acts you may run on it as hits too.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Words, with optional key:value conditions."},limit:{type:"number",description:"Most hits to return; 20 when unsaid."},subject:{type:"string",description:"A node id whose acts to include."}},required:["query"],additionalProperties:!1},mutating:!1,annotations:T("Find by name")},{name:"get_graph",title:"Read the whole graph",description:"Read the whole graph: every node with its fields, and every edge. Start here when you need the shape of the domain rather than one thing in it.",inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:T("Read the whole graph")},{name:"get_node",title:"Read one node",description:"Read one node, its edges, and the violations that implicate it, with its computed values: read-only fields worked out from what you can see, which no act sets. Use this to check a thing before you change it.",inputSchema:{type:"object",properties:{id:{type:"string",description:"A node's id, or its name."}},required:["id"],additionalProperties:!1},mutating:!1,annotations:T("Read one node")},{name:"get_violations",title:"List the problems",description:"List every invariant violation the graph currently has, with the repairs that would resolve each one. Read this before proposing work: a rule that is already broken is more urgent than anything you could add.",inputSchema:{type:"object",properties:{context:{type:"object",description:"Evaluation context, e.g. { weekStart }."}},additionalProperties:!1},mutating:!1,annotations:T("List the problems")},{name:"get_affordances",title:"Ask what can be done",description:"Ask what can legally be done with a selection, ranked. Prefer these over composing a mutation by hand: they are derived from the schema, the invariants and the shape of the graph, so they cannot name an action that does not exist.",inputSchema:{type:"object",properties:{selection:{type:"array",items:{type:"string"},description:"Node ids."},context:{type:"object"}},required:["selection"],additionalProperties:!1},mutating:!1,annotations:T("Ask what can be done")},{name:"describe_place",title:"Say what a place shows",description:`Say what one place of the app shows you, as a person in your seat would see it: its headings, its figures as drawn, its lists with each record's title and what its card or row says, the headings a list is grouped under, what an empty list says, and any block that could not be worked out. Pass a place's slug ("home", a lens's address like "the-offers", a kind's like "offers") or a record's id, and width 390 for a phone. Use it after a change to check what somebody now sees, instead of guessing.`,inputSchema:{type:"object",properties:{place:{type:"string",description:`"home", a place's slug, or a record's id.`},width:{type:"number",description:"The screen's width in CSS pixels; 390 is a phone, 1440 when unsaid."}},required:["place"],additionalProperties:!1},mutating:!1,annotations:T("Say what a place shows")},{name:"preview_mutation",title:"Try an act without applying it",description:"Try a mutation without applying it: get back the diff it would produce and any invariant it would break. Do this when you are unsure, rather than applying and undoing.",inputSchema:{type:"object",properties:{mutation:{type:"string"},args:{type:"object"}},required:["mutation","args"],additionalProperties:!1},mutating:!1,annotations:T("Try an act without applying it")},{name:"undo_batch",title:"Undo a batch",description:"Undo one batch of operations. Fails, naming the blocking operation, when a later operation read what it wrote.",inputSchema:{type:"object",properties:{batch:{type:"string"},include:{type:"array",items:{type:"string"}}},required:["batch"],additionalProperties:!1},mutating:!0,annotations:{title:"Undo a batch",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}}],Y={type:"object",description:"A lens, as draft_view returns one.",properties:{title:{type:"string"},lens:{type:"string"},on:{type:"string"},bindings:{type:"object"},options:{type:"object"}},required:["title","lens","on"]},Q={name:"draft_view",title:"Draw a view",description:'Draw a view of the data from words ("a board of tasks by status", "who covers what") as a lens the app could keep; or check a lens you wrote (lens); or change the one on screen (current, with ask: "only this month"). Returns the lens and its add-lens edit, or one sentence saying why not. Writes nothing.',inputSchema:{type:"object",properties:{ask:{type:"string",description:"What to see, in words."},lens:Y,current:Y},additionalProperties:!1},mutating:!1,annotations:T("Draw a view")},De={name:"keep_lens",title:"Keep a view as a lens",description:"Keep a lens draft_view drew as one of the app's places: checked again, then written as the add-lens edit. Returns the remove-lens edit that takes it back.",inputSchema:{...Y,additionalProperties:!1},mutating:!0,annotations:{title:"Keep a view as a lens",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}};function en(e,t){return e===void 0?[]:e==="keep"&&!t?[Q,De]:[Q]}var nn="An argument that names a record takes its id or its name.",Te=[...X.map(e=>e.name),Q.name,De.name],Ie=64;function I(e){let{line:t,...n}=e;return n}function Me(e){return{...e,...e.introduces?{introduces:e.introduces.map(I)}:{},...e.resolves?{resolves:e.resolves.map(I)}:{},...e.violationsAfter?{violationsAfter:e.violationsAfter.map(I)}:{}}}function tn(e){let t=e.normalize("NFKD").replace(/\p{M}/gu,"").replace(/[^A-Za-z0-9_-]/g,"_");return t.length===0&&(t="act"),/^[A-Za-z_]/.test(t)||(t=`act_${t}`),t.slice(0,Ie)}function on(e){let t=new Set(Te),n=new Map;for(let u of e){let f=tn(u),c=f;for(let S=2;t.has(c);S+=1)c=`${f.slice(0,Ie-`_${S}`.length)}_${S}`;t.add(c),n.set(u,c)}return n}function rn(e,t){let n=ue(e),u=M(e),f=n.nodeRefs.length>0?`${n.description}${/[.!?]$/.test(n.description)?"":"."} ${nn}`:n.description;return{name:t,title:u,description:f,inputSchema:n.inputSchema,mutating:!0,annotations:{title:u,readOnlyHint:!1,destructiveHint:e.destructive===!0||(e.severs?.length??0)>0,idempotentHint:e.idempotent===!0,openWorldHint:!1},act:e.name}}function ee(e){if(e===null||typeof e!="object")return JSON.stringify(e)??"null";if(Array.isArray(e))return`[${e.map(ee).join(",")}]`;let t=e;return`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${ee(t[n])}`).join(",")}}`}function sn(e){return`sha256:${he(ee(e))}`}function an(e,t,n,u){let f=on(e.map(v=>v.name)),c=en(u,n);return{definitions:n?[...X.filter(v=>!v.mutating),...c]:[...X,...c,...e.filter(v=>t.has(v.name)).map(v=>rn(v,f.get(v.name)))],names:f}}function Cn(e,t={}){let n=t.author??{kind:"agent"},u=e.allMutations(),f=new Set(e.permittedMutations(n).map(s=>s.name)),{definitions:c,names:S}=an(u,f,t.readOnly===!0,t.drafts?t.drafts.keep?"keep":"draw":void 0),v=sn(c),i=s=>{if(!Te.includes(s)){for(let[a,h]of S)if(h===s)return a;return S.has(s)?s:void 0}},l=(s,a)=>{let h=u.find(r=>r.name===s);if(!h)return{args:a,resolved:[]};let y={...a},o=[];for(let r of P(h.input)){let w=y[r.name];if(typeof w!="string"||w.trim()==="")continue;let b=e.resolveRef(r,w,n);if(!b.ok){let A=b.reason==="none"?` Nothing was changed. Use search_graph to look it up, then pass its id as ${r.name}.`:" Nothing was changed.";return{ok:!1,error:`${b.message}${A}`,argument:r.name,candidates:b.candidates}}b.by!=="id"&&(y[r.name]=b.id,o.push({argument:r.name,given:w,id:b.id,label:b.label}))}return{args:y,resolved:o}},p=async(s,a)=>{try{await Ye();let h=c.find(o=>o.name===s)??c.find(o=>o.act===s);if(!h){let o=i(s);if(o){let r=e.permits({name:o,args:a},n);if(!r.ok)return{ok:!1,error:r.refusal.message,reason:"forbidden"}}return{ok:!1,error:`Unknown tool "${s}". Available: ${c.map(r=>r.name).join(", ")}`}}if(h.mutating&&t.readOnly)return{ok:!1,error:`"${s}" changes the graph, and this seat is read-only.`,reason:"forbidden"};if(h.act!==void 0){let o=l(h.act,a);if("ok"in o)return o;let r=G(e,n,e.apply({name:h.act,args:o.args},{...t.author?{author:t.author}:{},...dn(t.via)}));return{ok:!0,data:{batch:r.batch,intent:r.intent,introduces:r.introduces.map(I),resolves:r.resolves.map(I),...o.resolved.length>0?{resolved:o.resolved}:{}},diff:r.diff}}let y=e.seenBy(n);switch(h.name){case"search_graph":{let o=typeof t.places=="function"?t.places():t.places,r=typeof a.subject=="string"?a.subject:void 0,w=pe(y,String(a.query??""),{principal:n,limit:typeof a.limit=="number"?a.limit:20,...o?{places:o}:{},...r?{subject:r,from:[r]}:{}});return{ok:!0,data:we(w,F(y,n)),reads:w.hits.flatMap(b=>b.about==="node"?[b.id]:[])}}case"get_graph":{let o=y.graph.snapshot();return{ok:!0,data:ke(o,F(y,n)),reads:o.nodes.map(r=>r.id)}}case"get_node":{let o=String(a.id??""),r=o,w;if(!y.graph.getNode(o)){let O=o.trim()===""?void 0:e.resolveRef({name:"id",kinds:["*"]},o,n);if(O?.ok)r=O.id,w={argument:"id",given:o,id:r,label:O.label};else return O?.reason==="ambiguous"?{ok:!1,error:O.message,argument:"id",candidates:O.candidates}:{ok:!1,error:`No node "${o}".`}}let b=y.graph.getNode(r),A=y.graph.outEdges(r),k=y.graph.inEdges(r),R=F(y,n),x=ge(y.schema,y.graph,b);return{ok:!0,data:{node:z(b,R),...Object.keys(x.values).length>0?{computed:ye(r,x.values,R)}:{},...Object.keys(x.refused).length>0?{uncomputed:x.refused}:{},out:A,in:k,violations:y.violations().filter(O=>O.nodeIds.includes(r)).map(I),...w?{resolved:[w]}:{}},reads:[r,...A.map(O=>O.to),...k.map(O=>O.from)]}}case"describe_place":{let o=t.app??{name:"",schema:e.schema},r=typeof a.width=="number"&&Number.isFinite(a.width)&&a.width>0?a.width:1440,{describePlace:w}=await Ze(),b=w(e,n,String(a.place??""),{app:o,width:r});if(!b.ok)return{ok:!1,error:`${b.error} The places are: ${b.places.join(", ")}.`};let A=new Set,k=R=>{for(let x of R)for(let O of x.groups??[])for(let D of O.items)A.add(D.id),k(D.parts)};return k(b.description.parts),{ok:!0,data:b.description,reads:[...A]}}case"draft_view":case"keep_lens":{let o=t.app??{name:"",schema:e.schema};return(await Qe()).runDraftTool(h.name,a,{app:o,principal:n,...t.drafts?{drafts:t.drafts}:{}})}case"get_violations":{let o=y.violations(a.context);return{ok:!0,data:o.map(I),reads:[...new Set(o.flatMap(r=>r.nodeIds))]}}case"get_affordances":{let o=a.selection??[];return{ok:!0,data:je(y,o,{...typeof t.derive=="function"?t.derive():t.derive,...t.author?{principal:t.author}:{},...a.context?{context:a.context}:{}}),reads:o.filter(w=>y.graph.has(w))}}case"preview_mutation":{let o=String(a.mutation),r=i(o)??o,w=l(r,a.args??{});if("ok"in w)return w;let b=e.missingFor({name:r,args:w.args},n);if(b)return{ok:!1,error:b.message,reason:"missing"};let A=G(e,n,e.preview({name:r,args:w.args},void 0,{author:n})),k=Me(A);return{ok:!0,data:w.resolved.length>0?{...k,resolved:w.resolved}:k}}case"undo_batch":{let o=String(a.batch),r=a.include??[],w=y.canUndo([o,...r]);if(!w.ok)return{ok:!1,error:w.message};let b=G(e,n,e.undo([o,...r],{...t.author?{author:t.author}:{}}));return{ok:!0,data:Me(b),diff:b.diff}}default:return{ok:!1,error:`Unknown tool "${s}".`}}}catch(h){let{reason:y,wouldNeed:o}=fe(h);return{ok:!1,error:h instanceof Error?h.message:String(h),reason:y,...o?{wouldNeed:o}:{}}}},d=new Set,g=s=>{for(let a of d)a(s)};return{definitions:c,hash:v,...t.author?{author:t.author}:{},onDiff(s){return e.subscribe(s)},onCall(s){return d.add(s),()=>d.delete(s)},async call(s,a){let h=(c.find(r=>r.name===s)??c.find(r=>r.act===s))?.mutating??!1,y={name:s,args:a,mutating:h,at:new Date().toISOString()};return g({...y,phase:"running"}),(r=>(g(r.ok?{...y,phase:"ok",...!h&&r.reads?{reads:r.reads}:{}}:{...y,phase:"failed",error:r.error}),r))(await p(s,a))}}}function dn(e){let t=typeof e=="function"?e():e;return t?{via:t}:{}}export{je as a,Je as b,Rn as c,Cn as d};
@@ -1 +0,0 @@
1
- import{a as x,c as P}from"./chunk.Y4R77MKX.js";import{S as w}from"./chunk.2VX6H2LL.js";var v="graview:pins",m={pinned:[],unpinned:[]},g=e=>Array.isArray(e)?e.filter(n=>typeof n=="string"):[];function O(){try{let e=globalThis.localStorage?.getItem(v);if(!e)return m;let n=JSON.parse(e);if(Array.isArray(n))return{pinned:g(n),unpinned:[]};if(typeof n=="object"&&n!==null){let r=n;return{pinned:g(r.pinned),unpinned:g(r.unpinned)}}return m}catch{return m}}function S(e){try{globalThis.localStorage?.setItem(v,JSON.stringify(e))}catch{}}function C(e,n,r=!1){let o=s=>s.filter(l=>l!==n),i=r?e.unpinned.includes(n)?{pinned:o(e.pinned),unpinned:o(e.unpinned)}:{pinned:o(e.pinned),unpinned:[...e.unpinned,n]}:e.pinned.includes(n)?{pinned:o(e.pinned),unpinned:o(e.unpinned)}:{pinned:[...e.pinned,n],unpinned:o(e.unpinned)};return S(i),i}var E=e=>`ai:${e.name??(e.complete||e.turn?"model":"on-device")}`;var A="Llama-3.2-3B-Instruct-q4f16_1-MLC",L=new Map;function R(e={}){let n=e.load?null:e.model??A,r=n?L.get(n)??L.set(n,{engine:null,failed:null}).get(n):{engine:null,failed:null},o=r.engine,i=!1,s=t=>e.onStatus?.(t),l=async()=>{if(e.load)return e.load();let t=globalThis.LanguageModel;if(t){let u=await t.create();return{chat:{completions:{create:async({messages:h})=>({choices:[{message:{content:await u.prompt(h[h.length-1]?.content??"")}}]})}}}}if(!globalThis.navigator?.gpu)throw new Error("this browser has no WebGPU, which the local model needs");return(await import("https://esm.run/@mlc-ai/web-llm")).CreateMLCEngine(e.model??A,{initProgressCallback:u=>s({state:"warming",progress:u.progress,detail:u.text})})},a=Promise.resolve();return{complete:async t=>{if(o=r.engine??o,!o)throw new Error("The local model is not warm yet");let f=(await o.chat.completions.create({messages:[{role:"user",content:t}]})).choices?.[0]?.message?.content;if(typeof f!="string")throw new Error("The local model answered with no content");return f},ready:()=>(r.engine??o)!==null,warm:()=>(o=r.engine??o,o?Promise.resolve():i?a:r.failed!==null?(s({state:"failed",detail:r.failed}),Promise.resolve()):(i=!0,s({state:"warming"}),a=l().then(t=>{o=t,r.engine=t,s({state:"ready"})}).catch(t=>{r.failed=t instanceof Error?t.message:String(t),s({state:"failed",detail:r.failed})}).finally(()=>{i=!1}),a)),failed:()=>r.failed}}function T(e,n={}){return b(e,n)?.complete}function b(e,n){let r=e.turn,o=e.complete??(r?l=>r({system:"",messages:[{role:"user",content:l}],tools:[],call:async()=>({error:"No tools here."})}):void 0);if(o)return{complete:o,ready:()=>!0,warm:()=>Promise.resolve(),failed:()=>null};if(!e.onDevice)return;let i=typeof e.onDevice=="object"?e.onDevice.model:void 0,s=R({...i?{model:i}:{},...n.onStatus?{onStatus:n.onStatus}:{}});return{complete:async l=>(s.ready()||s.warm(),s.complete(l)),ready:s.ready,warm:s.warm,failed:s.failed}}function D(e,n={}){let r=n.floor??x(),o=(a,d,p)=>r(p?.principal?a.seenBy(p.principal):a,d,p),i=b(e,n);if(!i)return async(a,d,p)=>{let t=await o(a,d,p);return t.unsure?{...t,say:e.withoutModel??w}:t};let s=P({complete:i.complete,...e.turn?{turn:e.turn}:{}}),l=E(e);return async(a,d,p)=>{let t=await o(a,d,p);if(t.grounded)return t;if(!i.ready()){if(await Promise.race([i.warm(),new Promise(c=>setTimeout(c,100))]),i.failed()!==null)return y(t,"(AI isn't available in this browser, so this is from the app alone.)");if(!i.ready())return y(t,"(AI is still getting ready on this device, so this is from the app alone.)")}try{let c=await s(a,d,{...p,...t.proposals.length>0?{reading:t.proposals}:{}});return c.proposals.length===0&&t.proposals.length>0?t:{...c,via:l}}catch{return y(t,"(AI didn't answer just now, so this is from the app alone.)")}}}function y(e,n){return{...e,say:`${e.say} ${n}`}}export{O as a,C as b,T as c,D as d};
@@ -1 +0,0 @@
1
- import{c as a,l as o}from"./chunk.VTBAKTFP.js";import"./chunk.7U7Q3HIS.js";import"./chunk.6O67NOZR.js";import"./chunk.WWRWXFYR.js";import"./chunk.ISAMJ7AK.js";import"./chunk.54NSG7BX.js";import"./chunk.6KJSFIO7.js";import"./chunk.UM5IPM22.js";import"./chunk.6XBLDV4A.js";import"./chunk.WOTNMTIY.js";import"./chunk.HAQ4KHRY.js";import"./chunk.PRXKRG6O.js";import"./chunk.AHDOKM4O.js";import"./chunk.TDW6QEG4.js";import"./chunk.LW7KV5SL.js";import{la as n}from"./chunk.2VX6H2LL.js";import"./chunk.ZQ4HFIIS.js";import"./chunk.MRK6QJV5.js";import"./chunk.AJZBJBMO.js";var w=new WeakMap;function p(e,i){let t=w.get(e);t||w.set(e,t=new Map);let r=t.get(i);return r||t.set(i,r=o(a(e,n(e)),e,i)),r}export{p as frameworkViews};
@@ -1,16 +0,0 @@
1
- import{c as E,d as I}from"./chunk.XJNXSQT4.js";import"./chunk.TDW6QEG4.js";import"./chunk.LW7KV5SL.js";import"./chunk.2VX6H2LL.js";import{I as A,M as k}from"./chunk.ZQ4HFIIS.js";import{a as F,b as S}from"./chunk.MRK6QJV5.js";import{b as f}from"./chunk.AJZBJBMO.js";var v=f(F(),1);var a=f(S(),1),C=40,O=60;function D(l,i,p){return l.allNodes().filter(o=>o.kind===i).map(o=>o[p])}function G(l){if(l.length<2)return[];let i=[...l].sort((n,d)=>n-d),p=i[i.length-1]-i[0];if(p<=0)return[];let o=Math.max(1,10**Math.floor(Math.log10(p/4))),e=p/4>=o*5?o*5:o,r=n=>Math.round(n/e)*e;return[...new Set([.2,.4,.6,.8].map(n=>r(i[Math.floor(n*(i.length-1))])))].filter(n=>n>0)}function T(l,i,p){let o=p.far??[],e=new Map,r=new Set(o);for(let t of i.allNodes())r.has(t.kind)&&e.set(t.id,A(l.tryDefinition(t.kind),t));let n=[...e.entries()].map(([t,g])=>({id:t,label:g}));return(n.length<=C?n:n.map(t=>({end:t,ties:i.out(t.id).length+i.in(t.id).length})).sort((t,g)=>g.ties-t.ties||t.end.label.localeCompare(g.end.label)).slice(0,C).map(t=>t.end)).sort((t,g)=>t.label.localeCompare(g.label))}function R(l,i,p){let o=[];for(let e of p.filters)if(e.about==="is")for(let r of e.options??[])o.push({value:`is:${r}`,label:r,group:e.label,condition:{key:"is",value:r}});else if(e.about==="edge"){o.push({value:`${e.key}:*`,label:"anything",group:e.label,condition:{key:e.key,value:"*"}}),o.push({value:`${e.key}:none`,label:"nothing",group:e.label,condition:{key:e.key,value:"none"}});for(let r of T(l,i,e))o.push({value:`${e.key}:${r.id}`,label:r.label,group:e.label,condition:{key:e.key,value:r.id}})}else if(e.type==="date")for(let r of["before","after","on"])o.push({value:`${e.key}:${r}`,label:`${r}\u2026`,group:e.label,ask:{key:e.key,op:r,label:e.label}});else if(e.type==="number"){let r=l.tryDefinition(p.kind),n=G(D(i,p.kind,e.key).filter(d=>typeof d=="number"));for(let d of["at-most","at-least"])for(let t of d==="at-most"?n:[...n].reverse())o.push({value:`${e.key}:${d}:${t}`,label:`${d==="at-most"?"at most":"at least"} ${k(r,e.key,t)}`,group:e.label,condition:{key:e.key,value:`${d}:${t}`}})}else if(e.type==="text"){let r=[...new Set(D(i,p.kind,e.key).filter(n=>typeof n=="string"&&n.length>0&&!n.includes(",")))].sort((n,d)=>n.localeCompare(d));if(r.length>=2&&r.length<=O)for(let n of r)o.push({value:`${e.key}:${n}`,label:n,group:e.label,condition:{key:e.key,value:n}})}else if(e.type==="boolean")o.push({value:`${e.key}:true`,label:"yes",group:e.label,condition:{key:e.key,value:"true"}}),o.push({value:`${e.key}:false`,label:"no",group:e.label,condition:{key:e.key,value:"false"}});else for(let r of e.options??[])o.push({value:`${e.key}:${r}`,label:k(l.tryDefinition(p.kind),e.key,r),group:e.label,condition:{key:e.key,value:r}});return o}var H=["day","week","month","year","decade"];function K(l){let{which:i,schema:p,graph:o,offers:e,arrangement:r,set:n,toggle:d,has:t,done:g}=l,y=l.testId,h=(0,v.useRef)(null);(0,v.useEffect)(()=>{let u=h.current?.closest("[data-graview-popover]");!u||document.activeElement!==u||(u.querySelector('[aria-pressed="true"]')??u.querySelector("button, input"))?.focus({preventScroll:!0})},[]);let L=r.sort?e.sorts.find(u=>u.key===r.sort.by):void 0,P=r.group?e.groups.find(u=>u.key===r.group.by):void 0,M=I(L),m=e.natural?e.sorts.find(u=>u.key===e.natural.by):void 0,N=i==="filter"||i==="all"&&l.parts?.filter?R(p,o,e):[],w=u=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{children:"Sort by"}),(0,a.jsx)(c,{testId:`${y}-sort-default`,value:"",on:!r.sort,onPress:()=>(n({sort:void 0}),u()),children:m?`As declared (${E(m.label)})`:"As they were added"}),e.sorts.map(s=>(0,a.jsx)(c,{value:s.key,on:r.sort?.by===s.key,onPress:()=>(n({sort:{by:s.key,direction:r.sort?.direction??"asc"}}),u()),children:s.label},s.key)),r.sort?(0,a.jsxs)("div",{role:"group","aria-label":"Order","data-testid":`${y}-direction`,children:[(0,a.jsx)("p",{"aria-hidden":"true",children:"Order"}),["asc","desc"].map(s=>(0,a.jsx)(c,{testId:`${y}-direction-${s}`,value:s,on:r.sort.direction===s,onPress:()=>(n({sort:{by:r.sort.by,direction:s}}),u()),children:M[s]},s))]}):null]}),x=u=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{children:"Group by"}),(0,a.jsx)(c,{testId:`${y}-group-none`,value:"",on:!r.group,onPress:()=>(n({group:void 0}),u()),children:"Not grouped"}),e.groups.map(s=>(0,a.jsx)(c,{value:s.key,on:r.group?.by===s.key,onPress:()=>(n({group:{by:s.key}}),u()),children:s.label},s.key)),r.group&&P?.buckets?(0,a.jsxs)("div",{role:"group","aria-label":"How wide a group is","data-testid":`${y}-bucket`,children:[(0,a.jsx)("p",{"aria-hidden":"true",children:"Each group"}),H.map(s=>(0,a.jsx)(c,{testId:`${y}-bucket-${s}`,value:s,on:(r.group.bucket??"day")===s,onPress:()=>(n({group:{by:r.group.by,bucket:s}}),u()),children:`A ${s}`},s))]}):null]}),$=u=>(0,a.jsx)(z,{entries:N,has:t,testId:y,onToggle:s=>(d(s),u())}),b=l.parts??{sort:!0,group:!0,filter:!0};return(0,a.jsxs)("div",{ref:h,style:{display:"contents"},children:[(0,a.jsx)("style",{children:W}),i==="sort"?w(g):i==="group"?x(g):i==="filter"?$(g):(0,a.jsxs)(a.Fragment,{children:[b.sort?(0,a.jsx)("div",{role:"group","aria-label":"Sort",children:w(g)}):null,b.group?(0,a.jsx)("div",{role:"group","aria-label":"Group",children:x(g)}):null,b.filter?(0,a.jsx)("div",{role:"group","aria-label":"Filter",children:$(g)}):null]})]})}function c({value:l,on:i,onPress:p,testId:o,children:e}){return(0,a.jsx)("button",{type:"button",className:"graview-arrange-item",value:l,"data-value":l,"aria-pressed":i,onClick:p,...o?{"data-testid":o}:{},children:e})}function z({entries:l,has:i,testId:p,onToggle:o}){let[e,r]=(0,v.useState)(null);if(e)return(0,a.jsx)(B,{ask:e,testId:p,onDay:d=>o({key:e.key,value:`${e.op}:${d}`}),onCancel:()=>r(null)});let n=[...new Set(l.map(d=>d.group))];return(0,a.jsx)(a.Fragment,{children:n.map(d=>(0,a.jsxs)("div",{role:"group","aria-label":d,children:[(0,a.jsx)("p",{"aria-hidden":"true",children:d}),l.filter(t=>t.group===d).map(t=>(0,a.jsx)(c,{value:t.value,on:t.condition?i(t.condition):!1,onPress:()=>t.condition?o(t.condition):r(t.ask),children:t.label},t.value))]},d))})}function B({ask:l,testId:i,onDay:p,onCancel:o}){let[e,r]=(0,v.useState)(""),n=/^\d{4}-\d{2}-\d{2}$/.test(e)&&Number(e.slice(0,4))>=1e3,d=()=>{n&&p(e)};return(0,a.jsxs)("div",{role:"group","aria-label":`${l.label} ${l.op} which day`,"data-testid":`${i}-ask-day`,className:"graview-arrange-ask",children:[(0,a.jsx)("p",{"aria-hidden":"true",children:`${l.label} ${l.op}`}),(0,a.jsx)("input",{type:"date","data-testid":`${i}-day`,"aria-label":`${l.label} ${l.op} which day`,autoFocus:!0,value:e,onChange:t=>r(t.target.value),onKeyDown:t=>{t.key==="Enter"?(t.preventDefault(),d()):t.key==="Escape"&&(t.preventDefault(),t.stopPropagation(),t.nativeEvent.stopImmediatePropagation(),o())}}),(0,a.jsxs)("span",{children:[(0,a.jsx)("button",{type:"button","data-testid":`${i}-day-add`,disabled:!n,onClick:d,children:"Add"}),(0,a.jsx)("button",{type:"button",onClick:o,children:"Never mind"})]})]})}var W=`
2
- .graview-arrange-list{display:grid;align-content:start;width:min(300px,calc(100vw - 24px));height:auto;max-height:min(70vh,520px);overflow:auto;margin:0;padding:6px;border-radius:10px;border:1px solid var(--graview-edge);background:var(--graview-float);box-shadow:var(--graview-lift-high);color:var(--graview-ink);font-size:.875rem;line-height:1.3}
3
- .graview-arrange-list [role=group]{display:grid}
4
- .graview-arrange-list p{margin:8px 8px 2px;font-size:.6875rem;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--graview-ink-muted)}
5
- .graview-arrange-item{display:flex;align-items:flex-start;gap:8px;width:100%;min-height:30px;margin:0;padding:6px 8px;border:0;border-radius:7px;background:none;font:inherit;text-align:left;color:var(--graview-ink);cursor:pointer;overflow-wrap:anywhere}
6
- .graview-arrange-item::before{content:"";flex:0 0 12px}
7
- .graview-arrange-item[aria-pressed=true]{font-weight:600}
8
- .graview-arrange-item[aria-pressed=true]::before{content:"\u2713";color:var(--graview-accent)}
9
- .graview-arrange-item:hover{background:color-mix(in srgb,var(--graview-ink) 7%,transparent)}
10
- .graview-arrange-ask{display:grid;gap:8px;padding:0 8px 8px}
11
- .graview-arrange-ask p{margin:8px 0 0}
12
- .graview-arrange-ask input{box-sizing:border-box;width:100%;min-height:32px;padding:0 8px;border:1px solid var(--graview-edge);border-radius:7px;background:var(--graview-panel);font:inherit;color:var(--graview-ink)}
13
- .graview-arrange-ask span{display:flex;gap:8px}
14
- .graview-arrange-ask button{min-height:30px;padding:0 12px;border:1px solid var(--graview-edge);border-radius:7px;background:var(--graview-panel);font:inherit;color:var(--graview-ink);cursor:pointer}
15
- .graview-arrange-ask button:disabled{opacity:.5;cursor:default}
16
- `;export{K as ArrangeLists,C as FAR_ENDS,R as filterEntries,G as roundSteps};