graview 0.1.23 → 0.1.25

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 (85) hide show
  1. package/dist/preview/{chunk.Q7WQ5UIE.js → chunk.2AJMM7JG.js} +1 -1
  2. package/dist/preview/chunk.2WFEFZAW.js +1 -0
  3. package/dist/preview/chunk.2YVXTTC2.js +1 -0
  4. package/dist/preview/{chunk.6CLHFNDM.js → chunk.6DU4XN2F.js} +14 -14
  5. package/dist/preview/chunk.6OBXKKB5.js +20 -0
  6. package/dist/preview/chunk.6UL2JUEH.js +9 -0
  7. package/dist/preview/chunk.6WFN4C46.js +107 -0
  8. package/dist/preview/chunk.7BAUPTMY.js +1 -0
  9. package/dist/preview/chunk.A4SJ7EEY.js +1 -0
  10. package/dist/preview/chunk.ACKTGTOT.js +1 -0
  11. package/dist/preview/{chunk.BQV62QEL.js → chunk.B57EIGTS.js} +1 -1
  12. package/dist/preview/{chunk.ZFUQA3KT.js → chunk.BJ2Y5F66.js} +1 -1
  13. package/dist/preview/{chunk.L5G5DTFX.js → chunk.BYUQOV3O.js} +1 -1
  14. package/dist/preview/chunk.C5N4RTPF.js +1 -0
  15. package/dist/preview/chunk.CFL2B2Z5.js +1 -0
  16. package/dist/preview/{chunk.FLJP3BGP.js → chunk.DEZEXD24.js} +1 -1
  17. package/dist/preview/{chunk.6C7SJJQO.js → chunk.DJ72CUS7.js} +1 -1
  18. package/dist/preview/{chunk.LZQZP2PD.js → chunk.DSZ3I557.js} +1 -1
  19. package/dist/preview/chunk.EA4BZKPG.js +1 -0
  20. package/dist/preview/chunk.EKZWX6NG.js +1 -0
  21. package/dist/preview/{chunk.EQOU4POV.js → chunk.F26676IW.js} +1 -1
  22. package/dist/preview/chunk.F2KDFGHR.js +1 -0
  23. package/dist/preview/chunk.FWV4XAZA.js +1 -0
  24. package/dist/preview/chunk.G3BOZHKR.js +1 -0
  25. package/dist/preview/chunk.H4LHHT56.js +8 -0
  26. package/dist/preview/{chunk.VVZ2Z7OS.js → chunk.HQX5FGYT.js} +1 -1
  27. package/dist/preview/{chunk.VNC6H6IM.js → chunk.I5ELK6JF.js} +1 -1
  28. package/dist/preview/{chunk.UNRYIETM.js → chunk.I6T3FDQS.js} +1 -1
  29. package/dist/preview/chunk.IB6PGEU7.js +1 -0
  30. package/dist/preview/{chunk.LGUV2J6Q.js → chunk.JCZH55RX.js} +1 -1
  31. package/dist/preview/{chunk.ZQZ557VR.js → chunk.JEMQBV6K.js} +1 -1
  32. package/dist/preview/{chunk.7YCQZJGB.js → chunk.JIXW4WIO.js} +1 -1
  33. package/dist/preview/chunk.JW3E4SAC.js +1 -0
  34. package/dist/preview/{chunk.JE4VH767.js → chunk.KUTTVYOB.js} +1 -1
  35. package/dist/preview/{chunk.HCK6IHGP.js → chunk.LHFEOEYY.js} +1 -1
  36. package/dist/preview/{chunk.WGNF4E67.js → chunk.MJ67MK4R.js} +1 -1
  37. package/dist/preview/{chunk.ZKUXPS44.js → chunk.ORJ3T4IW.js} +1 -1
  38. package/dist/preview/{chunk.3MLQ3Q5X.js → chunk.PY42PBMB.js} +1 -1
  39. package/dist/preview/{chunk.CJQL7AHT.js → chunk.QOYC424P.js} +2 -2
  40. package/dist/preview/{chunk.M4XNUM2A.js → chunk.R6F3YMRK.js} +1 -1
  41. package/dist/preview/chunk.RAE4M3KQ.js +8 -0
  42. package/dist/preview/chunk.RUFAVEXB.js +1 -0
  43. package/dist/preview/chunk.RVEMN5WU.js +1 -0
  44. package/dist/preview/{chunk.3HEJZPJM.js → chunk.S24R4MRK.js} +3 -3
  45. package/dist/preview/{chunk.ELEHYYCN.js → chunk.S56LSUHV.js} +1 -1
  46. package/dist/preview/{chunk.SCLIBKLS.js → chunk.SSOTDXRS.js} +1 -1
  47. package/dist/preview/{chunk.AZG6V3PF.js → chunk.T6KID3WO.js} +1 -1
  48. package/dist/preview/chunk.TAOT74FR.js +1 -0
  49. package/dist/preview/chunk.TTODVIXW.js +1 -0
  50. package/dist/preview/{chunk.YAONM74M.js → chunk.U6BWYBPM.js} +1 -1
  51. package/dist/preview/{chunk.FLDFRFDH.js → chunk.UOYH2DFX.js} +2 -2
  52. package/dist/preview/{chunk.R5K7NK4U.js → chunk.US4KIJSW.js} +1 -1
  53. package/dist/preview/{chunk.SQD7ZPEJ.js → chunk.WX5CJ7PI.js} +1 -1
  54. package/dist/preview/chunk.WXO3XUNW.js +1 -0
  55. package/dist/preview/{chunk.ENMNLR73.js → chunk.YZZGD5OY.js} +1 -1
  56. package/dist/preview/{chunk.XYZ7KAMZ.js → chunk.ZJVIH6IF.js} +1 -1
  57. package/dist/preview/{chunk.ACZGK7LQ.js → chunk.ZRVDIVYY.js} +1 -1
  58. package/dist/preview/chunk.ZV7ZFH2S.js +1 -0
  59. package/dist/preview/page.js +2 -2
  60. package/package.json +6 -6
  61. package/dist/preview/chunk.2F7OKRDK.js +0 -9
  62. package/dist/preview/chunk.4CDEIDKB.js +0 -1
  63. package/dist/preview/chunk.4JSMCNF7.js +0 -1
  64. package/dist/preview/chunk.4UQLZ7VW.js +0 -1
  65. package/dist/preview/chunk.5MAMCKVU.js +0 -1
  66. package/dist/preview/chunk.75WDSWXL.js +0 -20
  67. package/dist/preview/chunk.7YC34AIK.js +0 -1
  68. package/dist/preview/chunk.AZYJTNSM.js +0 -107
  69. package/dist/preview/chunk.DAKED3WK.js +0 -1
  70. package/dist/preview/chunk.DJ26NOOW.js +0 -1
  71. package/dist/preview/chunk.DN4D4HGX.js +0 -1
  72. package/dist/preview/chunk.DO4P2UK4.js +0 -1
  73. package/dist/preview/chunk.K7UJG5II.js +0 -1
  74. package/dist/preview/chunk.KFLY4MAT.js +0 -1
  75. package/dist/preview/chunk.KWYU5NPM.js +0 -1
  76. package/dist/preview/chunk.LSLFKW4M.js +0 -1
  77. package/dist/preview/chunk.NOXC454O.js +0 -1
  78. package/dist/preview/chunk.OR6ZWN76.js +0 -1
  79. package/dist/preview/chunk.PC6FAJF5.js +0 -1
  80. package/dist/preview/chunk.THBP5EES.js +0 -1
  81. package/dist/preview/chunk.VRXWNUDR.js +0 -1
  82. package/dist/preview/chunk.WTF3CP76.js +0 -1
  83. package/dist/preview/chunk.XEJS2VS5.js +0 -8
  84. package/dist/preview/chunk.Y235YZSZ.js +0 -8
  85. package/dist/preview/chunk.YU64JSAL.js +0 -1
@@ -0,0 +1,107 @@
1
+ import{A as he,B as ke,C as Jn,D as Ct,E as pe,F as Qn,G as Xn,H as A,I as We,J as Rt,K as Zn,L as At,M as rt,N as ea,O as U,P as Y,Q as Lt,a as G,b as fe,c as q,d as Un,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 jn,q as tt,r as nt,s as I,t as Pe,u as _n,v as at,w as le,x as Yn,y as de,z as Pt}from"./chunk.HQX5FGYT.js";import{a as Ze,c as V}from"./chunk.F26676IW.js";import{a as Gn,d as qn,e as Vn}from"./chunk.ONDILMIX.js";import{a as zn,e as Bn}from"./chunk.G3BOZHKR.js";import{a as xt}from"./chunk.TTODVIXW.js";import{a as $a}from"./chunk.IKT7JQUW.js";import{h as Tn,i as Mn}from"./chunk.6DU4XN2F.js";import{e as $n,i as Hn}from"./chunk.US4KIJSW.js";import{a as Qe,b as Rn,c as An,e as vt,f as Ln}from"./chunk.LHFEOEYY.js";import{f as Wn}from"./chunk.U6BWYBPM.js";import{a as bt,b as Fn,d as Nn,f as Dn,g as In,h as Kn,k as Xe}from"./chunk.QOYC424P.js";import{o as St}from"./chunk.2YVXTTC2.js";import{f as Oe}from"./chunk.BJ2Y5F66.js";import{b as En,c as kt,d as On}from"./chunk.JCZH55RX.js";import{$ as Sn,Aa as Cn,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.2WFEFZAW.js";import{Ba as ln,H as $e,I as je,J as ae,K as Qt,M as re,O as Xt,Pa as dn,Pb as wt,Q as Zt,Qa as pn,Qb as mn,Sa as cn,T as en,U as be,Ua as _e,Ub as yn,V as tn,Va as gn,W as nn,Xa as Ye,Xb as Je,Yb as fn,ea as ht,fa as an,ka as rn,ya as on,za as sn,zb as un}from"./chunk.RAE4M3KQ.js";import{a as ve,b as z}from"./chunk.MRK6QJV5.js";import{b as O}from"./chunk.AJZBJBMO.js";function ta(e,t,n={}){let r=e.graph.getNode(t);if(!r)return;let i=e.schema.tryDefinition(r.kind),a=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,g=e.graph.getNode(o);if(!g)continue;let u=(l==="out"?i:e.schema.tryDefinition(g.kind))?.edges?.[s.kind],c=l==="in"?u?.inverse??u?.description:u?.description,m=`${s.kind}|${l}|${c??""}`;(d.get(m)??(()=>{let F={edgeKind:s.kind,direction:l,...c?{description:c}:{},targets:[]};return d.set(m,F),F})()).targets.push({id:g.id,kind:g.kind,label:a(g)})}return{id:t,kind:r.kind,label:a(r),fields:tn(Oe(e.schema,e.graph,r),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 g=e.graph.getNode(o.id);return g?[g]:[]}),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,g)=>o.label.localeCompare(g.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 na(e,t){let n=(a,d)=>`${a}|${JSON.stringify(d)}`,r=new Map;for(let a of[...e.affordances,...e.withheld]){if(a.provider!=="invariant")continue;let d=n(a.mutation,a.args);r.has(d)||r.set(d,a.rank??Number.MAX_SAFE_INTEGER)}let i=Number.MAX_SAFE_INTEGER;return[...t].map((a,d)=>({repair:a,declared:d})).sort((a,d)=>(r.get(n(a.repair.mutation,a.repair.args??{}))??i)-(r.get(n(d.repair.mutation,d.repair.args??{}))??i)||a.declared-d.declared).map(a=>a.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 a=e.graph.getNode(i.from),d=e.graph.getNode(i.to);if(!a||!d)continue;let s=`${i.kind}|${a.kind}|${d.kind}`;n.set(s,(n.get(s)??0)+1)}let r=[];for(let{kind:i}of t){let a=e.schema.tryDefinition(i)?.edges??{};for(let[d,s]of Object.entries(a)){let l=s.to==="*"||s.to===void 0?(()=>{let o=[...n.keys()].filter(g=>g.startsWith(`${d}|${i}|`)).map(g=>g.split("|")[2]);return o.length>0?o:["*"]})():s.to;for(let o of l)r.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:r}}var Le=O(ve(),1);var Tt=O(ve(),1),S=O(z(),1),Ea=`
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 aa({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 Oa=e=>({label:re(e),option:t=>t});function it({store:e,spec:t,value:n,onChange:r,prefilled:i,open:a,words:d=Oa}){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=>r(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=>r(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=>r(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=>r(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)(aa,{children:(0,S.jsxs)("select",{name:t.name,required:!t.optional,value:typeof n=="string"?n:"",onChange:o=>r(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=a.find(m=>m.name===t.name)?.candidates,g=new Set(Object.values(i).filter(m=>typeof m=="string")),y=(t.kinds.includes("*")?[...e.graph.allNodes()]:t.kinds.flatMap(m=>e.graph.nodesOfKind(m))).filter(m=>!g.has(m.id)),u=o?o.map(m=>e.graph.getNode(m)).filter(m=>m!==void 0):y,c=je(u,m=>e.schema.tryDefinition(m));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)(aa,{children:(0,S.jsxs)("select",{name:t.name,required:!t.optional,value:typeof n=="string"?n:"",onChange:m=>r(m.target.value||void 0),"data-graview-part":"control",children:[(0,S.jsx)("option",{value:"",children:"\u2014"}),u.map(m=>{let P=c.get(m.id);return(0,S.jsxs)("option",{value:m.id,children:[ae(e.schema.tryDefinition(m.kind),m),P?` \xB7 ${P}`:""]},m.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(g=>(0,S.jsx)(it,{store:e,spec:g,value:o[g.name],onChange:y=>r({...o,[g.name]:y}),prefilled:i,open:a,words:d},g.name))]})}case"variant":{let o=n??{},g=typeof o[t.tag]=="string"?o[t.tag]:"",y=t.options.find(u=>u.value===g);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:g,onChange:u=>r({[t.tag]:u.target.value}),"data-graview-part":"control",children:[(0,S.jsx)("option",{value:"",children:"\u2014"}),t.options.map(u=>(0,S.jsx)("option",{value:u.value,children:re(u.value)},u.value))]})]}),y?.fields.map(u=>(0,S.jsx)(it,{store:e,spec:u,value:o[u.name],onChange:c=>r({...o,[u.name]:c}),prefilled:i,open:a,words:d},u.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((g,y)=>(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:g,onChange:u=>r(o.map((c,m)=>m===y?u:c)),prefilled:i,open:a,words:d})}),(0,S.jsx)("button",{type:"button","data-graview-part":"remove",onClick:()=>r(o.filter((u,c)=>c!==y)),children:"remove"})]},y)),(0,S.jsx)("button",{type:"button","data-graview-part":"add",onClick:()=>r([...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:r=[],onDone:i,principal:a,initial:d,label:s,only:l}){let[o,g]=(0,Tt.useState)(()=>({...d})),[y,u]=(0,Tt.useState)(null),c=Je(t.input).filter(P=>l===void 0||l.includes(P.name)),m=P=>gn(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}},a?{author:a}:{}),u(null),g({}),i?.()}catch(F){u(Ye(e.schema,e.allMutations(),F))}},"data-graview-part":"form",children:[(0,S.jsx)("style",{children:Ea}),c.map(P=>(0,S.jsx)(it,{store:e,spec:P,value:o[P.name],onChange:F=>g(C=>({...C,[P.name]:F})),prefilled:n,open:r,words:m},P.name)),y?(0,S.jsx)("p",{"data-testid":"refused","data-graview-part":"refused",role:"alert",children:y}):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(r=>n.has(r.kind))}var Ae=e=>`place:${e.kind}:${e.as}`;function ge(e,t){let n=(e.views?.places()??[]).some(r=>r.as===t.as&&r.kind!==t.kind);return Un(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(r=>$e(n,r))}function Mt(e,t,n){let r=(a,d)=>Xt(e.schema,d,a),i=r(Ke(e,t).length,t);return n?`${i} across ${r(Ke(e,n).length,n)}`:i}function $t({context:e,place:t,chosen:n}){let{store:r,views:i,invariantContext:a}=e,s=i?.resolve(t.kind,{cardinality:"many",fidelity:"full"},t.as)?.view;if(!s)return null;let l=Ke(r,t.kind),o=[...new Set(r.violations(a).flatMap(g=>g.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 Fa({store:e,views:t,as:n,invariantContext:r}){V(e);let i={store:e,views:t,...r?{invariantContext:r}:{}},a=t.places().find(d=>d.as===n);return a?(0,b.jsx)($t,{context:i,place:a}):null}function Wa({context:e,kind:t}){let{store:n,views:r,invariantContext:i}=e,a=Ke(n,t),d=n.schema.tryDefinition(t),s=I(n,t),o=r?.resolve(t,{cardinality:"many",fidelity:"full"})?.view,g=[...new Set(n.violations(i).flatMap(m=>m.nodeIds))];if(o&&!Ee(o))return(0,b.jsx)(St,{kind:t,children:(0,b.jsx)(o,{nodes:a,label:s,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1,...g.length>0?{flagged:g}:{}})});let y=r?.resolve(t,{cardinality:"one",fidelity:"summary"})?.view,u=8,c=a.slice(0,u);return(0,b.jsxs)("div",{"data-testid":"kind-sheet",style:y?{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(m=>y?(0,b.jsx)(y,{node:m,fidelity:"summary",cardinality:"one",mode:"fullscreen",selected:!1,...g.includes(m.id)?{flagged:[m.id]}:{}},m.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,m)},m.id)),a.length>u?(0,b.jsxs)("span",{style:{...k,alignSelf:"center",padding:"0 6px"},children:["+",a.length-u," more ",s.toLowerCase()]}):null]})}function Et(e){let{store:t}=e,n=_n(e),r=[...ce(e)].sort((a,d)=>n.indexOf(a.kind)-n.indexOf(d.kind)),i=new Set(r.map(a=>a.kind));return[...r.map(a=>({key:Ae(a),kind:a.kind,title:a.title,to:ge(e,a),place:a})),...at(e).filter(a=>!i.has(a)).map(a=>({key:`kind:${a}`,kind:a,title:I(t,a),to:`/${G(t.schema,a)}`}))]}var ra=.72,Na=540,ia=16/10;function Da(e){let t=(0,Le.useRef)(null),[n,r]=(0,Le.useState)(e);return(0,Le.useLayoutEffect)(()=>{let i=t.current;if(!i||typeof ResizeObserver>"u")return;let a=()=>{let s=i.getBoundingClientRect().width;s>0&&r(l=>Math.abs(l-s)<.5?l:s)};a();let d=new ResizeObserver(a);return d.observe(i),()=>d.disconnect()},[]),{ref:t,width:n}}function Ot({context:e,entry:t}){let{store:n,brand:r,principal:i}=e,{ref:a,width:d}=Da(Na),s=d/ra,l=Ke(n,t.kind),o=n.schema.tryDefinition(t.kind),g=l.length===0?Ce(n,t.kind,{...i?{principal:i}:{},...e.invariantContext?{context:e.invariantContext}:{}}).actions.affordances[0]:void 0,y=t.place!==void 0;return(0,b.jsxs)(A,{to:t.to,"data-testid":y?"place-card":"kind-card",className:"graview-gallery-card",style:{...J,display:"grid",gap:10,alignContent:"start",minWidth:0},children:[(0,b.jsxs)("span",{ref:a,"data-testid":y?"place-picture":"kind-picture","aria-hidden":"true",inert:!0,style:{display:"block",position:"relative",width:"100%",aspectRatio:`${ia}`,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/ia,display:"grid",gridTemplateRows:"minmax(0, 1fr)",transform:`scale(${ra})`,transformOrigin:"0 0"},children:t.place?(0,b.jsx)($t,{context:e,place:t.place}):(0,b.jsx)(Wa,{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"]}),g?(0,b.jsxs)("span",{style:k,children:["Begin with \u201C",g.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:[y?null:(0,b.jsx)(ee,{kind:t.kind,brand:r,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),!y&&o?.description?` \xB7 ${o.description}`:null]})]})]})}var oa={display:"grid",gap:"32px 28px",gridTemplateColumns:"repeat(auto-fill, minmax(min(420px, 100%), 1fr))"},Ia=`
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:oa,"data-testid":"gallery",children:[(0,b.jsx)("style",{children:Ia}),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),r=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."})]}),r.length>0?(0,b.jsx)("div",{style:oa,"data-testid":"places",children:r.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 r=ke(),i=he(),[a]=We(),d=decodeURIComponent(r.as??""),[s,l]=(0,Le.useState)(null),o=a.get("of"),y=ce(e).find(P=>P.as===d&&(!o||G(t.schema,P.kind)===o));if(!y)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 u=I(t,y.kind),m=Ce(t,y.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:y.title}),(0,b.jsxs)("p",{style:_,"data-testid":"place-lede",children:[Mt(t,y.kind,y.across),"."]}),(0,b.jsx)("p",{style:{...k,margin:0},children:(0,b.jsxs)(A,{to:`/${G(t.schema,y.kind)}`,style:{...$,...k},"data-testid":"place-as-list",children:["All ",u.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(y),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:y,...s?.at===Ae(y)?{chosen:s.ids}:{}})}),(0,b.jsx)("div",{style:{maxWidth:760,display:"grid",gap:40},children:m.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 sa(e,t,n){let r=Math.max(0,e.left),i=Math.min(t.width,e.right),a=Math.max(0,e.top),d=Math.min(t.height,e.bottom);return{shown:d-a>=n.height+2*16&&i-r>=n.width+2*16,left:Math.round(r),top:Math.round(a),width:Math.round(Math.max(0,i-r)),height:Math.round(Math.max(0,d-a))}}function la(e,t,n){let r=e.style;r.left=`${t.left}px`,r.top=`${t.top}px`,r.right="auto",r.bottom="auto",r.visibility=n?"":"hidden";let i=e.getBoundingClientRect();i.width!==0&&(r.left=`${Math.round(2*t.left-i.left)}px`,r.top=`${Math.round(2*t.top-i.top)}px`)}var Se=O(z(),1);function da({context:e}){let t=he(),n=oe(),{pathname:r}=de(),[,i,a]=r.split("/"),d=i==="places"&&a?decodeURIComponent(a):void 0,s=(0,Te.useRef)(null);return Ha(s,n!==null),n?(0,Se.jsxs)(Se.Fragment,{children:[(0,Se.jsx)(za,{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)(zn,{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:()=>{r!=="/~draft"&&t("/~draft")}})})]}):null}var Ka={width:160,height:40};function Ha(e,t){let{pathname:n}=de(),r=Cn(t);(0,Te.useLayoutEffect)(()=>{let i=e.current;if(!i)return;let a=i.parentElement?.closest("[data-embed-content]")??null,d=()=>a??document.querySelector("main")??null,s=()=>{let y=d(),u={width:document.documentElement.clientWidth||innerWidth,height:r??innerHeight},c=y?.getBoundingClientRect()??{left:0,top:0,right:u.width,bottom:u.height},m=sa(a?c:{left:c.left,right:c.right,top:c.top,bottom:Math.max(c.bottom,u.height)},u,Ka);i.style.width=`${m.width}px`,i.style.height=`${m.height}px`,la(i,m,m.shown)};s(),addEventListener("resize",s),addEventListener("scroll",s,!0);let l=0,o=typeof ResizeObserver=="function"?new ResizeObserver(()=>{cancelAnimationFrame(l),l=requestAnimationFrame(s)}):null,g=d();return g&&o?.observe(g),()=>{cancelAnimationFrame(l),o?.disconnect(),removeEventListener("resize",s),removeEventListener("scroll",s,!0)}},[e,t,n,r])}function za({context:e}){let{store:t}=e,n=oe(),{pathname:r}=de(),i=(0,Te.useRef)(n?.setSelection);return i.current=n?.setSelection,(0,Te.useEffect)(()=>{let a=i.current;if(!a)return;let[,d,s]=r.split("/"),l=(()=>{if(d==="places"){let g=e.views?.places().find(y=>y.as===decodeURIComponent(s??""));return g?[Ie(g.kind)]:[]}let o=d?fe(t.schema,d):void 0;return o&&s?[decodeURIComponent(s)]:o?[wn(o)]:[]})();a(o=>o.length===l.length&&o.every((g,y)=>g===l[y])?o:l)},[r]),null}var te=O(ve(),1);var ca=O($a(),1);var Q=O(z(),1);var Ba=(0,te.lazy)(hn(()=>import("./chunk.JEMQBV6K.js").then(e=>({default:e.TakeBack}))));function Ga({context:e,docked:t,at:n}){let{store:r}=e,i=V(r),[a]=(0,te.useState)(()=>r.batches().length),d=(0,te.useRef)(!1);return d.current||=i>0||!t&&a>0,d.current?(0,Q.jsx)(te.Suspense,{fallback:null,children:(0,Q.jsx)(Ba,{context:e,docked:t,at:n,since:a})}):null}function qa(e,t,n){let{store:r,principal:i,embedded:a}=e;(0,te.useEffect)(()=>{if(!n)return;let d=s=>{if(!Vn(s))return;let l=s.target,o=l instanceof Node&&t.current?.contains(l),g=l===document.body||l===document.documentElement||l===document;if(!(!o&&!(g&&!a))&&Gn(r,i)){s.preventDefault();try{qn(r,i)}catch{}}};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[r,i,a,t,n])}function ga({context:e,registry:t,root:n,children:r}){let i=(0,te.useMemo)(Zn,[]),a=t?.without()??new Set;return qa(e,n,!a.has("undo")),(0,Q.jsxs)(Rt.Provider,{value:i,children:[(0,Q.jsx)(Va,{context:e,placed:i,without:a}),r]})}function Va({context:e,placed:t,without:n}){let[r,i]=(0,te.useState)(!1);(0,te.useLayoutEffect)(()=>i(!0),[]);let a=At(t,"find"),d=At(t,"undo"),s=de(),l=Mn();if(!r)return null;let o=s.pathname.split("/").filter(Boolean),y=(o.length===1?fe(e.store.schema,o[0]):void 0)!==void 0;return(0,Q.jsxs)(Q.Fragment,{children:[!a&&!n.has("find")&&l?(0,ca.createPortal)((0,Q.jsx)(pa,{context:e,narrowsLists:y}),l.slot):null,!a&&!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)(pa,{context:e,narrowsLists:y})}):null,!d&&!n.has("undo")?(0,Q.jsx)(Ga,{context:e,docked:!0,at:s.pathname+s.search}):null,l?.own&&!n.has("undo")?(0,Q.jsx)(Yn,{context:e,own:l.own}):null]})}function pa({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 ua(e,t){return t==="*"?{label:"anything",path:null}:{label:I(e,t),path:`/${G(e.schema,t)}`}}function Ua({context:e,relation:t}){let{store:n}=e,r=ua(n,t.from),i=ua(n,t.to),a=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)(Bn,{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:[a(r)," ",(0,T.jsxs)("span",{style:k,"data-graview-speaks-ids":"",children:[re(t.edgeKind)," \u2192"]})," ",a(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 ma({context:e,heading:t=!0}){let{store:n}=e,r=new Set(Pe(n,e.principal)),i=Re(n).relations.filter(a=>r.has(a.from)&&(a.to==="*"||r.has(a.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(a=>(0,T.jsx)(Ua,{context:e,relation:a},`${a.edgeKind}|${a.from}|${a.to}`))})]})}function Dt({context:e}){let{store:t}=e;V(t);let n=new Set(Pe(t,e.principal)),r=Re(t),i=r.relations.filter(a=>n.has(a.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:r.kinds.filter(a=>n.has(a.kind)).map(a=>(0,T.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,T.jsx)(ee,{kind:a.kind,brand:e.brand,schema:t.schema,size:7}),(0,T.jsx)(A,{to:`/${G(t.schema,a.kind)}`,style:$,children:a.plural}),(0,T.jsx)("span",{style:k,children:a.count})]},a.kind))}),(0,T.jsx)(ma,{context:e,heading:!1})]})}function ya({context:e}){let n=[...oe()?.robots.values()??[]].filter(i=>i.mode==="asking"&&i.say);if(n.length===0)return null;let{store:r}=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 a=i.at?r.graph.getNode(i.at):void 0;return(0,T.jsxs)("li",{style:{display:"grid",gap:2},children:[(0,T.jsx)("span",{children:i.say}),a?(0,T.jsxs)(A,{to:q(r.schema,a.kind,a.id),style:{...$,...k},children:[ae(r.schema.tryDefinition(a.kind),a)," \u2192"]}):null]},i.participant)})})]})}var E=O(z(),1);function It({context:e}){let{principal:t}=e,{store:n,brand:r,invariantContext:i}=e;V(n);let a=n.violations(i),d=`${a.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))})),g=o.filter(C=>C.members.length>0),y=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),u=g.length===0?"Nothing here yet.":`${g.map(C=>`${C.members.length} ${C.members.length===1?C.kind:I(n,C.kind).toLowerCase()}`).join(", ").replace(/, ([^,]*)$/," and $1")}.`,c=e.views?.homeView?.(),m=n.schema.kinds.some(C=>n.graph.nodesOfKind(C).length>0);if(c&&m){let C=r?.subtitle?(0,E.jsx)("p",{style:{...k,margin:0},"data-testid":"app-subtitle",children:r.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,a.length>0?(0,E.jsx)(A,{to:"/problems",style:{...$,color:"var(--graview-warn)"},children:d}):null,(0,E.jsx)(Kn.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:[r?.subtitle?(0,E.jsx)("p",{style:{...k,margin:0},"data-testid":"app-subtitle",children:r.subtitle}):null,(0,E.jsx)(Y,{context:e,"data-testid":"standing",children:u}),(0,E.jsxs)("p",{style:{..._,display:"grid",gap:4},"data-testid":"standing-card",children:[g.length===0&&y?(0,E.jsxs)("span",{children:["Begin with \u201C",y.creator?.title??y.creator?.name,"\u201D, under"," ",(0,E.jsx)(A,{to:`/${G(n.schema,y.entry.kind)}`,style:$,children:I(n,y.entry.kind)}),"."]}):null,a.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:r,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:r,invariantContext:i}=e;V(t);let[a]=We(),d=a.get("q")??"",s=typeof i?.today=="string"?i.today:void 0,l=cn(t,d,{...r?{principal:r}:{},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"),g=l.hits.filter(c=>c.about==="kind"||c.about==="place"||c.about==="rule"),y=[...new Set(o.map(c=>c.kind))],u=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:u.length===0?"Find anything by its name":l.hits.length===0?(0,R.jsxs)(R.Fragment,{children:["Nothing here is called \u201C",u,"\u201D."]}):(0,R.jsxs)(R.Fragment,{children:[ja(t,l.byKind)," for \u201C",u,"\u201D"]})}),u.length>0?(0,R.jsxs)("p",{style:{...k,margin:0},"data-testid":"search-searched",children:[_e(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(m=>I(t,m).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."]})]}),g.length>0?(0,R.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},"data-testid":"search-named",children:g.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,y.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:u}).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(m=>m.kind===c).map(m=>(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,m.id),style:{...J,fontFamily:xe,fontSize:"1.1875rem",fontWeight:600,lineHeight:1.3,overflowWrap:"anywhere"},children:[m.flagged?(0,R.jsx)("span",{style:{color:"var(--graview-warn)"},children:"\u26A0 "}):null,m.label,m.apart?(0,R.jsxs)("span",{style:k,children:[" \xB7 ",m.apart]}):null,m.current?null:(0,R.jsx)("span",{style:k,children:" \xB7 past"})]}),(0,R.jsx)(ot,{why:m.why})]},m.id))})]},c)),u.length>0?(0,R.jsx)(_a,{asked:u}):null,u.length>0&&l.hits.length===0?(0,R.jsx)(ha,{store:t,kinds:l.searched.kinds,words:l.words,...r?{principal:r}:{},...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 ja(e,t){let n=Object.entries(t).map(([r,i])=>`${i} ${i===1?be(e.schema.tryDefinition(r),r):I(e,r).toLowerCase()}`);return n.length===0?"Found":n.length===1?le(n[0]):le(`${n.slice(0,-1).join(", ")} and ${n[n.length-1]}`)}function fa(e,t,n={}){let r=[];for(let i of t){let a=Ce(e,i,{...n.principal?{principal:n.principal}:{},...n.invariantContext?{context:n.invariantContext}:{}});for(let d of st(e,i,a.actions.affordances))r.some(s=>s.mutation.name===d.mutation.name)||r.push(d)}return r}function st(e,t,n){let r=e.schema.tryDefinition(t)?.fieldRoles?.label,i=[];for(let a of n){let d=e.allMutations().find(o=>o.name===a.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":r&&s.includes(r)?r:void 0;!l||a.args[l]!==void 0||i.push({kind:t,affordance:a,mutation:d,arg:l})}return i}function ha({store:e,kinds:t,words:n,principal:r,invariantContext:i}){let a=fa(e,t,{...r?{principal:r}:{},...i?{invariantContext:i}:{}});return a.length===0||n.trim().length===0?null:(0,R.jsx)("div",{style:{display:"grid",gap:24},"data-testid":"search-to-create",children:a.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},...r?{principal:r}:{}})]},`${s.id}|${n}`))})}function _a({asked:e}){let t=oe();return t?(0,R.jsx)(Ya,{asked:e,talk:t.seatTalk}):null}function Ya({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),wa=8,va=40;function Ht({context:e}){let t=ke(),n=fe(e.store.schema,t.slug??"");return n?(0,h.jsx)(ka,{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 ka({context:e,kind:t,opening:n,row:r,layout:i="list",description:a,bare:d}){let{store:s,brand:l,invariantContext:o}=e;V(s);let[g,y]=We(),u=s.schema.tryDefinition(t),c=s.graph.nodesOfKind(t),m=Re(s).relations.filter(p=>p.from===t||p.to===t),P=new Set(s.violations(o).flatMap(p=>p.nodeIds)),F=sn(s.schema,t),C=m.map(p=>p.edgeKind),K=Xa(g,F,C),ue=["sort","filter","group","q","by","with","past",...C].some(p=>g.has(p)),X=c.length>=va,we=u?.fieldRoles?.when,N=ue?K.arrangement:kt(n??Qa(X,we),F).arrangement,ne=dn(N.query??""),f=[...N.filter??[],...ne.conditions].some(p=>p.key==="is"&&(p.value==="past"||p.value==="any"))||on(u,[...N.filter??[],...ne.conditions]),L=f||!u?.lifecycle?N:{...N,filter:[...N.filter??[],{key:"is",value:"current"}]},Z=On(c,L,{schema:s.schema,graph:s.graph,flagged:P,...typeof o?.today=="string"?{today:o.today}:{}}),B=Z.nodes,ze=u?.lifecycle&&!f?c.filter(p=>$e(u,p)):c,Gt=c.length-ze.length,qt=N.group?.by??null,xa=p=>{let x=new URLSearchParams(g);for(let ie of["sort","filter","group","q","by","with","past",...m.map(Ue=>Ue.edgeKind)])x.delete(ie);let H=En(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",""),y(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(u,p);if(r){let De=u?.computed?Oe(s.schema,s.graph,p):p;return(0,h.jsx)("li",{"data-testid":"record-row",style:{minWidth:0},children:r(p,{label:x,href:q(s.schema,t,p.id),flagged:P.has(p.id),glance:nt(De,u,x)})},p.id)}if(_t){let De=Xe(Be,p,s.graph),La=u?.computed?Oe(s.schema,s.graph,p):p,Ta=Object.fromEntries(Object.entries(La).filter(([Ma])=>!De?.fields.has(Ma))),Jt=De?nt(Ta,u,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=u?.computed?Oe(s.schema,s.graph,p):p,ie=nt(H,u,x),Ue=ne.words?pn(u,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),Pa=(N.filter??[]).some(p=>p.key!=="is"||p.value!=="any"),Ca=!!(N.sort||N.group||N.query||Pa),Ra=ze.length>=wa||ue&&Ca,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(u,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:r&&i==="list"?6:0},qe=p=>`list-at-${p.replace(/[^\p{L}\p{N}]/gu,"_")}`,Ve=m.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}}),Aa=new Set(Ve.map(p=>(p.words??"").toLowerCase()).filter((p,x,H)=>p&&H.indexOf(p)!==x));return(0,h.jsxs)(d?Ja: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})]}),a??u?.description?(0,h.jsx)("p",{style:{..._,fontSize:"1.0625rem",lineHeight:1.4},children:a??u?.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&&Aa.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)(Wn,{schema:s.schema,graph:s.graph,kind:t,arrangement:N,onChange:xa,kept:{shown:B.length,of:ze.length},noun:{one:be(u,t),many:gt.toLowerCase()},...Ra?{}:{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:_e(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:Za(g,"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)(er,{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 Ja({children:e}){return(0,h.jsx)("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:40,minWidth:0},children:e})}var Qa=(e,t)=>t?{sort:{by:t,direction:"desc"}}:e?{sort:{by:"label",direction:"asc"}}:{};function Xa(e,t,n){let r=ln({...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=[...r.filter??[]],a=e.get("by"),d=r.group??(a?{by:a}: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({...r.sort?{sort:r.sort}:{},...r.query?{query:r.query}:{},...i.length>0?{filter:i}:{},...d?{group:d}:{}},t)}function Za(e,t,n){let r=new URLSearchParams(e);return r.set(t,n),r.delete("past"),`?${r.toString()}`}function er({name:e,title:t,description:n,open:r,children:i}){let[a,d]=(0,Me.useState)(r),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":a,"aria-controls":o,onClick:()=>{d(!a),a||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:a?"\u2212":"+"}),t]}),(0,h.jsxs)("div",{ref:l,id:o,hidden:!a,onKeyDown:g=>{g.key==="Escape"&&(g.preventDefault(),d(!1),s.current?.focus())},style:a?{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:r,principal:i}=e;V(t);let a=t.violations(r),d=t.allInvariants(),s=Qe(t,a),l=Rn(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:a.length===0?"All rules hold":"What is broken"}),(0,M.jsx)("p",{style:_,"data-testid":"problems-count",children:a.length===0?"Every declared rule is satisfied by what is here.":an(a)})]}),(0,M.jsx)(ya,{context:e}),s.map((o,g)=>{let y=o.nodeIds[0],u=y?t.graph.getNode(y):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}:{}}),u?(0,M.jsxs)("p",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:8},children:[(0,M.jsx)(ee,{kind:u.kind,brand:n,schema:t.schema,size:7}),(0,M.jsx)(A,{to:q(t.schema,u.kind,u.id),style:$,children:ae(t.schema.tryDefinition(u.kind),u)})]}):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}:{}})]},g)}),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 g=a.filter(c=>c.invariant===o.name).length,y=l.get(o.name),u=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:[y?(0,M.jsx)(vt,{line:y,schema:t.schema,...n?{brand:n}:{},style:{flex:"1 1 18rem"}}):(0,M.jsx)("span",{style:{flex:"1 1 18rem",fontWeight:550},children:u}),(0,M.jsx)("span",{style:{...k,fontSize:"0.875rem",color:g>0?"var(--graview-warn)":"var(--graview-ink-faint)"},children:g===0?"holds":`broken in ${g} ${g===1?"place":"places"}`})]}),y&&u.trim().length>0?(0,M.jsx)("span",{style:{...k,fontSize:"0.875rem"},children:u}):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 r=Ln(e);return(0,M.jsxs)("div",{style:{display:"grid",gap:2},"data-testid":"problem-line",title:An(e),children:[(0,M.jsx)(vt,{line:e.line,schema:t,...n?{brand:n}:{},lead:"none",style:{color:"var(--graview-warn)",fontSize:"1.0625rem"}}),r?(0,M.jsx)("span",{style:{...k,fontSize:"0.875rem"},children:r}):null]})}function dt({store:e,repairs:t,principal:n}){let[r,i]=(0,He.useState)(null),[a,d]=(0,He.useState)(null),s=(0,He.useRef)([]);if(t.length===0)return null;let l=r===null?null:t[r],o=l&&(l.missing??[]).length>0?e.allMutations().find(g=>g.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((g,y)=>{let u=(g.missing??[]).length>0,c=e.permits({name:g.mutation,args:{...g.args}},n);return c.ok?(0,M.jsx)("button",{ref:m=>{s.current[y]=m},type:"button","data-graview-repair":g.mutation,"data-graview-asks":u||void 0,"aria-expanded":u?r===y:void 0,onClick:()=>{if(d(null),u){i(r===y?null:y);return}i(null);try{e.apply({name:g.mutation,args:{...g.args}},n?{author:n}:{})}catch(m){d(Ye(e.schema,e.allMutations(),m))}},style:et,children:u?`${g.label} \u2026`:g.label},y):(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:g.label})," \u2014 ",c.refusal.message]},y)})}),o&&l?(0,M.jsx)(ye,{store:e,mutation:o,prefilled:{...l.args},only:l.missing??[],label:l.label,onDone:()=>{let g=r;i(null),requestAnimationFrame(()=>{let y=g===null?null:s.current[g];if(y?.isConnected){y.focus();return}let u=document.querySelector("[data-graview-page-title]")??document.querySelector("main h1, main h2");u&&(u.hasAttribute("tabindex")||(u.tabIndex=-1),u.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,a?(0,M.jsx)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:"0.875rem"},children:a}):null]})}var w=O(z(),1),tr=[];function Bt({context:e}){let{store:t,brand:n,principal:r,invariantContext:i}=e;V(t);let a=oe()!==null,d=ke(),s=decodeURIComponent(d.id??""),l=ta(t,s,{...r?{principal:r}:{},...i?{context:i}:{}}),o=Qe(t,l?.violations??tr),[g,y]=(0,pt.useState)(null),u=(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),m=t.schema.tryDefinition(l.kind),P=m?.describe&&c?Qt(m,c):null,F=[...t.log.all()].filter(f=>!rn(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:a&&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)(Nn,{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:na(l.actions,f.repairs),...r?{principal:r}:{}})]},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(m,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)(Fn,{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:a?(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:jn(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:u,tabIndex:-1,children:"What can be done"}),(0,w.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:C.map(f=>{let L=g===f.id;return(0,w.jsx)("button",{type:"button","data-affordance":f.id,"data-rank":f.rank,"aria-expanded":L,onClick:()=>y(L?null:f.id),style:{...et,...L?{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"}:{}},children:f.label},f.id)})}),C.map(f=>{if(g!==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:()=>{y(null);let Z=f.id;requestAnimationFrame(()=>{(u.current?.parentElement?.querySelector(`[data-affordance="${Z.replace(/["\\]/g,"\\$&")}"]`)??u.current)?.focus()})},...r?{principal:r}:{}})]},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,r,{graph:t.graph,schema:t.schema,...e.seats?{seats:e.seats}:{},...e.people?{people:e.people}:{}})]},f.id))})]}):null]})}var v=O(z(),1),nr=(0,W.lazy)(()=>import("./chunk.I5ELK6JF.js").then(e=>({default:e.DraftPage})));function ar({context:e,children:t}){let n=he(),r=e.store.schema,i=(0,W.useMemo)(()=>({href:a=>q(r,a.kind,a.id),go:a=>n(q(r,a.kind,a.id))}),[r,n]);return(0,v.jsx)(Dn.Provider,{value:i,children:(0,v.jsx)(In.Provider,{value:(e.titleLevel??(e.framed&&!e.barAbove?1:2))-1,children:t})})}function rr({steering:e}){let t=de(),n=he(),r=`${t.pathname}${t.search}`;return(0,W.useLayoutEffect)(()=>e.at(r),[r,e]),(0,W.useLayoutEffect)(()=>{let i=d=>{d!==r&&n(d)};e.go.current=i;let a=e.pending?.current;return a!==void 0&&(e.pending.current=void 0,i(a)),()=>{e.go.current===i&&(e.go.current=void 0)}},[r,n,e]),null}function ir({context:e,to:t}){let{pathname:n}=de(),r=oe(),i=(t??r)?.sayWhere,a=or(e,n);return(0,W.useEffect)(()=>(i?.(a),()=>i?.(null)),[i,a]),null}function or(e,t){let[n="",r,i]=t.split("/").filter(Boolean).map(d=>{try{return decodeURIComponent(d)}catch{return d}});if(i!==void 0)return"#";if(n==="places"&&r!==void 0){if(r===wt)return"#overview=1";let d=e.views?.places().find(s=>s.as===r);return d?`#focus=${encodeURIComponent(Ie(d.kind))}&view=${encodeURIComponent(d.as)}`:"#"}let a=fe(e.store.schema,n);return a?`#focus=${encodeURIComponent(r??Ie(a))}`:"#"}function sr({onNavigate:e,path:t}){let n=de(),r=Pt(),i=he(),a=`${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=a,o!==null&&(a===o&&r!=="PUSH"||d.current?.(a,r==="POP"?"pop":r==="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!==a&&i(t))},[t]),null}function Sa({context:e,registry:t,page:n}){let r=ke(),i=fe(e.store.schema,r.slug??""),a=n==="list"?Ht:Bt,s=(i?t?.lookup(i,n):void 0)??a;return(0,v.jsx)(s,{context:e})}function lr({context:e,registry:t,children:n}){let r=(0,W.useRef)(null);return Pn(r),(0,v.jsx)("div",{ref:r,"data-graview-face":"pages",style:{display:"contents"},children:(0,v.jsx)(ga,{context:e,registry:t,root:r,children:n})})}function dr(){let{pathname:e}=de(),t=Pt(),n=(0,W.useRef)(null);(0,W.useLayoutEffect)(()=>{if(t!=="POP"){for(let a=n.current?.parentElement;a;a=a.parentElement){let{overflowY:d}=getComputedStyle(a);if((d==="auto"||d==="scroll")&&a.scrollHeight>a.clientHeight){a.scrollTop=0;return}}window.scrollTo(0,0)}},[e]);let r=(0,W.useRef)(e),i=(0,W.useRef)(!1);return(0,W.useEffect)(()=>{if(!i.current&&e===r.current)return;i.current=!0;let a=document.activeElement;if(a!==null&&a!==document.body&&a!==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 pr({context:e,children:t}){let n=he(),r=(0,W.useMemo)(()=>({record:i=>{let a=e.store.graph.getNode(i);a&&n(q(e.store.schema,a.kind,i))},place:i=>{let a=e.views?.places().find(d=>d.as===i);a&&n(ge(e,a))}}),[e,n]);return(0,v.jsx)(bn.Provider,{value:r,children:t})}function cr({context:e,Home:t}){let i=de().key==="default"?yn(e.views?.arrangement?.()?.first,e.store.schema,e.views?.places()??[]):void 0,a=i?.to==="place"?ge(e,i.place):i?.to==="kind"?`/${G(e.store.schema,i.kind)}`:void 0;return a?(0,v.jsx)(Ct,{to:a,replace:!0}):(0,v.jsx)(t,{context:e})}function ba({context:e,registry:t}){let n=t?.lookupSurface("shell"),r=n!==void 0,i=r&&(t?.without().has("bar")??!1),a=r&&!i&&!e.embedded?{...e,barAbove:!0}:e,d=m=>n===void 0?(0,v.jsx)(rt,{context:e,children:m}):i?(0,v.jsx)(n,{context:e,children:m}):(0,v.jsx)(rt,{context:e,children:(0,v.jsx)(n,{context:a,children:m})}),s=t?.lookupSurface("home")??It,l=t?.lookupSurface("problems")??zt,o=r?{...a,framed:!0}:e,[g,y]=(0,W.useState)(null),u=(0,W.useMemo)(()=>({onFind:y,find:!(t?.without().has("find")??!1),places:!(t?.without().has("places")??!1)}),[t]),c=(0,v.jsx)(lr,{context:e,registry:t,children:(0,v.jsx)(pr,{context:e,children:d((0,v.jsx)(v.Fragment,{children:(0,v.jsxs)(ar,{context:o,children:[(0,v.jsx)(dr,{}),(0,v.jsxs)(Qn,{children:[(t?.routes()??[]).map(({path:m,component:P})=>(0,v.jsx)(pe,{path:m,element:(0,v.jsx)(P,{context:o})},m)),(0,v.jsx)(pe,{path:"/",element:(0,v.jsx)(cr,{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)(nr,{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(m=>m.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)(Sa,{context:o,registry:t,page:"list"})}),(0,v.jsx)(pe,{path:"/:slug/:id",element:(0,v.jsx)(Sa,{context:o,registry:t,page:"record"})})]})]})}))})});return e.embedded||!r||i?c:(0,v.jsx)(ea.Provider,{value:u,children:(0,v.jsx)(Tn.Provider,{value:g,children:c})})}function gr({context:e,registry:t,basename:n,initialPath:r,onNavigate:i,path:a,steering:d}){(0,W.useState)(()=>e.views?Hn(e.views,e.store.schema,$n(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 g=(0,v.jsxs)(v.Fragment,{children:[i||a!==void 0?(0,v.jsx)(sr,{onNavigate:i,path:a}):null,d?(0,v.jsx)(rr,{steering:d}):null,o.presence||s?(0,v.jsx)(ir,{context:o,to:s}):null,(0,v.jsx)(ba,{context:o,...t?{registry:t}:{}})]}),y=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:[g,(0,v.jsx)(da,{context:o})]}):g;if(r!==void 0){let u=n===void 0?r:`${n.replace(/\/$/,"")}${r}`;return(0,v.jsx)(Jn,{initialEntries:[u],...n===void 0?{}:{basename:n},children:y})}return(0,v.jsx)(Xn,{...n===void 0?{}:{basename:n},children:y})}export{Fa as a,gr as b};
@@ -0,0 +1 @@
1
+ import{d as R}from"./chunk.WX5CJ7PI.js";import{I as Q,J as V,M as z,P as Y,Sa as nn,T as A,U as D,V as X,Va as B,Xb as q,ea as L,fa as Z}from"./chunk.RAE4M3KQ.js";var E=c=>c.filter(Boolean).join(" "),en=new Set(["tell","me","about","what","how","show","describe","the","a","an","and","please"]),an=new Set([...en,"where","is","are","was","find","any","anything","something","things","called","named","which","who","of","for","with","to","in","on","i","my","do","does","have","has","can","you","it","that","this","there","we","our","got","be"]),dn=c=>c.length<=1?A(c[0]??"something"):`${c.slice(0,-1).map(A).join(", ")} and ${A(c[c.length-1])}`;function wn(c={}){return async(t,u,g={})=>{let w=u.toLowerCase(),h=n=>V(t.schema.tryDefinition(n.kind),n),p=(await import("./chunk.ACKTGTOT.js")).goingFrom(t,u,g,c.today);if(p.reply)return p.reply;let v=p.told,S=n=>p.moves?{...n,moves:p.moves}:n,y=[],C=w.split(/[^a-z0-9]+/).filter(Boolean),I=new Set;for(let n=0;n<C.length;n++){let e="";for(let s=n;s<Math.min(C.length,n+6);s++)e+=C[s],I.add(e)}let T=n=>n.toLowerCase().replace(/[^a-z0-9]+/g,""),H=[...t.graph.allNodes()].map(n=>({node:n,label:T(h(n))})).filter(({label:n})=>n.length>=2&&I.has(n)).sort((n,e)=>e.label.length-n.label.length),N=new Map;for(let{label:n}of H)N.set(n,(N.get(n)??0)+1);for(let{node:n,label:e}of H)(N.get(e)??0)>1||y.some(s=>s.id===n.id)||y.push(n);for(let n of g.selection??[]){let e=t.graph.getNode(n);e&&!y.some(s=>s.id===e.id)&&y.push(e)}let M=v&&t.graph.getNode(v);if(M){let n=y.findIndex(e=>e.id===M.id);n>=0&&y.splice(n,1),y.unshift(M)}let b=t.violations(),O=(n=b)=>ln(n);if(p.problems||!v&&/\b(wrong|broken|problem|violat|standing)\b/.test(w)){if(b.length===0)return S({say:"Nothing is wrong: every rule holds.",proposals:[],grounded:!0});let n=R(t,O().slice(0,4)),e=(i,r)=>{let d=t.allMutations().find(l=>l.name===i),a=d?q(d.input).find(l=>l.name===r):void 0;return a?.control==="node"&&!a.kinds.includes("*")?a.kinds.map(l=>D(t.schema.tryDefinition(l),l)).join(" or "):B(t.schema,d,r).label},s=[...new Set(b.flatMap(i=>i.repairs).filter(i=>(i.missing??[]).length>0).map(i=>`\u201C${i.label}\u201D (${(i.missing??[]).map(r=>e(i.mutation,r)).join(", ")})`))];return S({say:E([p.moves?.[0]?.said??"",`${Z(b)}:`,b.slice(0,4).map(i=>i.message).join("; ")+(b.length>4?"\u2026":"."),n.length>0?"The repairs below come from the rules themselves.":s.length>0?`Each way to fix ${b.length===1?"it":"these"} asks something first \u2014 ${s.slice(0,4).join(" or ")} \u2014 select the record and its own actions will ask.`:"No rule here names a way to fix it."]),proposals:n,grounded:!0})}let K=/\?\s*$/.test(u)||/^\s*(what|who|whom|whose|which|when|where|why|how|is|are|was|were|does|do|did|can|could|should|would|will|has|have)\b/.test(w),$=K?void 0:t.allMutations().find(n=>{let e=(n.title??n.name).toLowerCase();return e.length>3&&w.includes(e)});if($){let n={},e=[],s=u.slice(u.toLowerCase().indexOf(($.title??$.name).toLowerCase())+($.title??$.name).length),i=y.reduce((a,l)=>{let f=h(l).toLowerCase(),m=a.toLowerCase().indexOf(f);return m<0?a:`${a.slice(0,m)} it${a.slice(m+f.length)}`},s),r=u.match(/"([^"]+)"/)?.[1]??i.match(/^(?:\s+(?:it|this|that|them))?\s+(?:to|as)\s+(.+?)\s*[.!]?$/i)?.[1],d=[...y];for(let a of q($.input)){let l=un(a,d,r,c.today??g.today,w);if(l!==void 0){n[a.name]=l;let f=d.findIndex(m=>m.id===l);f>=0&&d.splice(f,1)}else a.optional||e.push(B(t.schema,$,a.name).label.toLowerCase())}return e.length===0?{say:"I can do that. Review it below.",proposals:R(t,[{mutation:$.name,args:n,why:"you asked in words"}])}:{say:`\u201C${$.title??z($.name)}\u201D needs ${dn(e)} \u2014 say ${e.length===1?"it":"them"} (or select ${e.length===1?"it":"them"}) and ask again.`,proposals:[]}}let tn={mon:"mon",monday:"mon",tue:"tue",tues:"tue",tuesday:"tue",wed:"wed",wednesday:"wed",thu:"thu",thur:"thu",thurs:"thu",thursday:"thu",fri:"fri",friday:"fri",sat:"sat",saturday:"sat",sun:"sun",sunday:"sun"},x=C.map(n=>tn[n]).find(Boolean),_=(n,e,s)=>{let i=t.schema.tryDefinition(n)?.display?.format?.[e];return i?i(s):String(s)},F=n=>{let e=t.schema.tryDefinition(n.kind)?.fieldRoles;if(!e?.start)return null;let s=n[e.start],i=e.end?n[e.end]:void 0,r=e.day?n[e.day]:e.days?n[e.days]:void 0;return s===void 0&&i===void 0?null:[s!==void 0?_(n.kind,e.start,s):null,i!==void 0&&e.end?`\u2013${_(n.kind,e.end,i)}`:null,Array.isArray(r)?` on ${r.join(", ")}`:r!==void 0?` on ${String(r)}`:null].filter(Boolean).join("")||null},sn=n=>{let e=[];for(let s of t.graph.allEdges()){let i=s.from===n?s.to:s.to===n?s.from:null;if(!i)continue;let r=t.graph.getNode(i);r&&!e.some(d=>d.id===r.id)&&e.push(r)}return e},G=n=>{let e=y[0];if(!e)return[];let s=[];for(let r of sn(e.id)){let d=0,a=T(h(r));for(let l of C)l.length>2&&a.includes(l)&&(d+=1);if(x){let l=t.schema.tryDefinition(r.kind)?.fieldRoles,f=l?.day?r[l.day]:void 0,m=l?.days?r[l.days]:void 0;f===x?d+=4:Array.isArray(m)&&m.includes(x)&&(d+=1)}n&&!F(r)||d>0&&s.push({node:r,score:d})}let i=s.sort((r,d)=>d.score-r.score).map(r=>r.node);return n&&F(e)?i.unshift(e):n||i.push(e),i};if(y.length>0&&/\bwhen\b/.test(w)){let n=G(!0)[0]??null,e=n?F(n):null;if(n&&e)return S({say:`${h(n)} runs ${e}.`,proposals:R(t,O(L(b,[n.id])).slice(0,3)),grounded:!0})}if(y.length>0&&/\bwho(m|se)?\b/.test(w))for(let n of G(!1)){let e=[],s=new Set;for(let i of t.schema.definitions)for(let[r,d]of Object.entries(i.edges)){let a=/\bwho\b/i.test(d.description??""),l=/\bwho\b/i.test(d.inverse??"");if(!a&&!l||s.has(r))continue;s.add(r);let f=[...t.graph.in(n.id,r),...t.graph.out(n.id,r)];if(f.length===0)continue;let m=a?d.description:d.inverse;e.push(`${m}: ${f.map(o=>h(o)).join(", ")}`)}if(e.length>0)return S({say:`${h(n)} \u2014 ${e.join("; ")}.`,proposals:R(t,O(L(b,[n.id])).slice(0,3)),grounded:!0})}if(y.length>0){let n=y[0],e=new Set(h(n).toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)),s=C.every(o=>e.has(o)||en.has(o)),i=K||s,r=t.schema.tryDefinition(n.kind),d=o=>o===o.toUpperCase()?o:o.charAt(0).toLowerCase()+o.slice(1),a=X(n,r,{limit:3}).map(o=>{let k=n[o.key];return typeof k=="boolean"&&!/\s/.test(o.label)?k?d(o.label):`not ${d(o.label)}`:typeof k=="string"&&hn.test(k)?`${d(o.label)} ${yn(k)}`:o.alone.startsWith(o.label)?d(o.label)+o.alone.slice(o.label.length):`${d(o.label)} ${o.alone}`}).join(", "),l=L(b,[n.id]),f=new Map;for(let o of[...t.graph.allEdges()]){let k=o.from===n.id?"out":o.to===n.id?"in":null;if(!k)continue;let J=t.graph.getNode(k==="out"?o.to:o.from);if(!J)continue;let P=`${o.kind}|${k}`;if(!f.has(P)){let W;for(let rn of t.schema.definitions){let j=rn.edges[o.kind];if(j&&(W=k==="out"?j.description:j.inverse??j.description,W))break}f.set(P,{sentence:W??z(o.kind).toLowerCase(),names:[]})}let U=f.get(P);U.names.length<6&&U.names.push(h(J))}let m=[...f.values()].slice(0,4).map(o=>`${o.sentence.charAt(0).toUpperCase()}${o.sentence.slice(1)}: ${o.names.join(", ")}`).join(". ");return S({say:E([p.moves?.[0]?.said??"",`${h(n)} \u2014 ${A(D(t.schema.tryDefinition(n.kind),n.kind))}${a?` (${a})`:""}.`,m?`${m}.`:"Connected to nothing yet.",l.length>0?`Trouble: ${l.map(o=>o.message).join("; ")}.`:"Nothing about it is broken."]),proposals:R(t,O(l).slice(0,3)),...i||v?{grounded:!0}:{}})}{let n=w.split(/[^\p{L}\p{N}]+/u).filter(e=>e.length>0&&!an.has(e));if(n.length>0){let e=nn(t,n.join(" "),{...g.principal?{principal:g.principal}:{},...g.selection?{from:g.selection}:{},...c.today??g.today?{today:c.today??g.today}:{},limit:6}),s=e.hits.filter(i=>i.about==="node");if(s.length>0){let i=Q(s.flatMap(a=>{let l=t.graph.getNode(a.id);return l?[l]:[]}),a=>t.schema.tryDefinition(a)),r=s.map(a=>`${a.label}${i.has(a.id)?` \xB7 ${i.get(a.id)}`:""} (${D(t.schema.tryDefinition(a.kind),a.kind)}${a.why.field==="label"?"":`, ${a.why.reading.toLowerCase()}: ${a.why.fragment}`})`);return{say:`${e.total===1?"One thing is":`${gn(e.total)} things are`} called \u201C${e.words}\u201D \u2014 ${r.join("; ")}${e.total>s.length?`; and ${e.total-s.length} more`:""}.`,proposals:[],picks:s}}}}let on=t.schema.kinds.filter(n=>!t.modules.disabledKinds.has(n)).map(n=>{let e=Y(t.schema,n);return`${t.graph.nodesOfKind(n).length} ${e}`}).join(", ");return{say:E([`This graph holds ${on}.`,"Ask about anything by name, ask what's wrong, or say a change in its own words \u2014",`like "${t.allMutations()[0]?.title??"an action"}".`]),proposals:[],unsure:!0}}}function ln(c){return c.flatMap(t=>{let u=t.repairs.find(g=>!g.missing?.length);return u?[{mutation:u.mutation,args:{...u.args},why:t.message}]:[]})}var cn=["No","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten"],gn=c=>cn[c]??String(c);function un(c,t,u,g,w=""){switch(c.control){case"node":return t.find(p=>c.kinds.includes("*")||c.kinds.includes(p.kind))?.id;case"text":return u;case"date":{let h=g??new Date().toISOString().slice(0,10);return c.time?`${h}T09:00`:h}case"choice":{let h=new Set(w.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)),p=(c.options??[]).filter(v=>v.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean).every(S=>h.has(S)));return p.length===1?p[0]:void 0}default:return}}function bn(c){return async(t,u,g={})=>(await import("./chunk.6OBXKKB5.js")).answerWithModel(c,t,u,g)}var hn=/^\d{4}-\d{2}-\d{2}$/,fn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function yn(c){let[t,u,g]=c.split("-").map(Number);return`${g} ${fn[u-1]??""} ${t}`}export{wn as a,ln as b,bn as c};
@@ -0,0 +1 @@
1
+ import{a as H,b as N,c as C,d as de,e as le}from"./chunk.YZZGD5OY.js";import{g as l}from"./chunk.DSZ3I557.js";import{C as ce,a as G,b as K,d as te,e as ie,f as O,h as p,k as j,l as oe,m as R,n as re,o as E,p as b,r as g,s as se,t as w,u as m,v as _,w as v,x as i,y as F,z as ae}from"./chunk.RAE4M3KQ.js";var Oe="graview-document",je=1,sn=256*1024,X=64*1024,ue=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,J=/^[a-z][A-Za-z0-9]*$/,Re=new Set(["id","kind"]),Ee=e=>e in Object.prototype,fe=F(e=>!Ee(e),"every object already has this name \u2014 choose another"),pe=(e,n)=>[...e===void 0?[]:[ie(e)],...n===void 0?[]:[te(n)]],f=(e,n)=>p().check(...pe(e,n)),h=(e,n,s)=>b(e).check(...pe(n,s)),z=e=>p().check(O(ue,`${e} names are lower-case words joined by hyphens, like "booked-vendor"`)),Ae=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,I=p().check(O(Ae,'relation names are one camelCase word, like "tendedBy"'),fe),x=p().check(O(J,'field names are one word or camelCase, like "dueDate" \u2014 rules say them bare'),F(e=>!Re.has(e),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),fe),A=f(1,500),M=f(1,2e3),q=f(1,300),Fe=["string","text","number","integer","boolean","date","datetime","enum","list","url","email"],ge=g({type:_(Fe),required:i(R()),description:i(A),label:i(f(1,60)),options:i(h(f(1,80),1,100)),of:i(_(["string","number","date"])),default:i(E()),unit:i(f(void 0,12)),format:i(_(["money","percent","duration"])),min:i(j()),max:i(j()),step:i(j()),renamedFrom:i(p().check(O(J)))}).check(ae((e,n)=>{e.type==="enum"&&!e.options&&n.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),e.type!=="enum"&&e.options&&n.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),e.type!=="list"&&e.of&&n.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]})})),Ve=g({to:w([h(z("kind"),1),v("*")]),cardinality:i(_(["one","many"])),description:i(A),inverse:i(f(1,80)),appendOnly:i(R()),renamedFrom:i(p())}),ye=w([M,g({expr:M,label:i(f(1,60)),description:i(A)})]),Te=g({noun:i(f(1,40)),plural:i(f(1,40)),description:i(A),fields:m(x,ge).check(F(e=>Object.keys(e).length>0,"a kind has at least one field")),label:i(q),describe:i(q),lifecycle:i(g({field:x,retired:h(w([p(),j(),R()]),1)})),figure:i(f(void 0,2e4)),glance:i(h(x,1,20)),page:i(g({fields:i(h(x,1,40)),groups:i(h(g({title:f(1,60),fields:h(x,1,40)}),1,12))})),edges:i(m(I,Ve)),computed:i(m(p(),ye).check(F(e=>Object.keys(e).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:i(m(p(),p())),renamedFrom:i(p().check(O(ue)))}),B=w([p(),j(),R(),re(),b(E()),g({expr:M})]),D=p().check(O(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),_e=w([g({create:z("kind"),as:i(p().check(O(J))),set:i(m(x,B))}),g({set:m(x,B),target:i(D)}),g({connect:I,from:D,to:D}),g({sever:I,from:D,to:D}),g({remove:D})]),De=g({title:i(f(1,80)),description:i(A),fromTheOtherEnd:i(f(1,80)),on:i(w([z("kind"),h(z("kind"),1)])),creates:i(z("kind")),sets:i(m(x,B)),writes:i(h(x,1)),connects:i(I),severs:i(I),setsOther:i(m(x,B)),replaces:i(w([v(!0),h(I,1,10)])),removes:i(v(!0)),args:i(m(x,ge)),effects:i(h(_e,1,20)),allowedWhen:i(M),refusal:i(q),destructive:i(R())}),Ie=g({act:z("act"),label:i(f(1,80)),args:i(m(p(),B))}),Me=g({title:i(f(1,120)),description:i(A),over:w([v("graph"),z("kind")]),when:i(M),require:M,says:i(q),repairs:i(h(Ie,void 0,10))}),Le=g({roles:w([h(z("role"),1),v("*")]),mutations:w([h(z("act"),1),v("*")]),kinds:i(w([b(z("kind")),v("*")])),describe:i(A),self:i(R())}),Ke=g({roles:w([h(z("role"),1),v("*")]),kinds:h(z("kind"),1),own:i(R())}),Be=g({grants:b(Le),sees:i(b(Ke))}),Ge=g({accent:i(p().check(O(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),name:i(f(1,60)),currency:i(p().check(O(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:i(f(2,35)),logo:i(w([f(1,X),g({src:f(1,X),alt:i(f(1,120))})])),favicon:i(f(1,X)),typography:i(g({display:i(f(1,200)),body:i(f(1,200)),mono:i(f(1,200))})),shape:i(g({radius:i(j().check(K(0),G(32))),density:i(j().check(K(.75),G(1.5)))})),accents:i(m(p(),j().check(K(0),G(360)))),scheme:i(_(["light","dark","auto"]))}),P=m(p(),E()),Ne=g({card:i(b(E())),row:i(b(E())),page:i(b(E()))}),Ce=se({order:i(b(p())),hide:i(b(p())),first:i(p()),primary:i(h(f(1,80),void 0,40)),scene:i(f(1,40)),pages:i(f(1,40))}),an=g({$schema:i(p()),format:v(Oe),formatVersion:v(je),name:f(1,80),description:i(A),version:i(j().check(oe(),K(1))),kinds:m(z("kind"),Te).check(F(e=>Object.keys(e).length>0,"a document declares at least one kind"),F(e=>Object.keys(e).length<=40,"a document declares at most 40 kinds")),computed:i(m(p(),ye)),acts:i(m(z("act"),De)),rules:i(m(z("rule"),Me)),roles:i(b(z("role"))),policy:i(Be),modules:i(P),lenses:i(b(P)),pages:i(Ce),views:i(m(p(),w([Ne,b(E())]))),brand:i(Ge),settings:i(b(P)),migrations:i(b(P))});var W=e=>e?._zod?.def,Pe=/^\^\\d\{4\}-\\d\{2\}-\\d\{2\}\$$/;function qe(e){let n=W(e),s=!0,r;for(let t=0;n&&t<4;t++){if(n.type==="optional"||n.type==="nullable")s=!1;else if(n.type==="default")s=!1,r=n.defaultValue;else break;n=W(n.innerType)}if(!n)return{why:"it is not a zod field"};let c=ce(e),d={...s?{required:!0}:{},...r!==void 0?{default:r}:{},...c?{description:c}:{}},a=(n.checks??[]).map(t=>W(t));switch(n.type){case"string":{let t=n.format;return t==="email"?{spec:{type:"email",...d}}:t==="url"?{spec:{type:"url",...d}}:t==="date"?{spec:{type:"date",...d}}:t==="datetime"?{spec:{type:"datetime",...d}}:a.some(o=>o?.format==="regex"&&Pe.test(String(o?.pattern?.source??"")))?{spec:{type:"date",...d}}:{spec:{type:"string",...d}}}case"number":{let t={};for(let o of a){let u=o?.value;typeof u=="number"&&(o?.check==="greater_than"&&o.inclusive?t.min=Math.max(t.min??u,u):o?.check==="less_than"&&o.inclusive?t.max=Math.min(t.max??u,u):o?.check==="multiple_of"&&(t.step=u))}return{spec:{type:a.some(o=>o?.format==="safeint"||o?.format==="int")?"integer":"number",...t,...d}}}case"boolean":return{spec:{type:"boolean",...d}};case"enum":{let t=Object.keys(n.entries??{});return t.length>0?{spec:{type:"enum",options:t,...d}}:{why:"it is an enum with no options"}}case"array":{let t=W(n.element),o=t?.type==="number"?"number":t?.type==="string"?"string":void 0;return o?{spec:{type:"list",of:o,...d}}:{why:`it is a list of ${String(t?.type??"something")}, and a document lists words, numbers or dates`}}default:return{why:`it is a ${String(n.type)}, which a document has no field type for`}}}function ln(e){let n=qe(e);return"spec"in n?n.spec:void 0}var Q=["card","row","page"],ee=["good","warn","bad","neutral","accent"],me=["money","percent","date","relative","count"],he=4,U=40,be=["number","money","percent"],We=["card","row"],ze=100,Z={title:[],headline:[],list:["sort","limit","group","empty","as"],text:["tone"],badge:["tone"],field:["as","currency","label"],progress:["label"],group:["direction"],when:["show"],divider:[],figure:["as","currency","label"]},Ze=Object.keys(Z),ke=`{"title": "{name}"}, {"headline": "{count(all('offer'))} offers"}, {"figure": expr, "as"?: "number"|"money"|"percent", "currency"?, "label"?}, {"list": expr, "sort"?, "limit"?, "group"?, "empty"?, "as"?: "card"|"row"}, {"text": "\u2026", "tone"?}, {"badge": "{status}", "tone"?}, {"field": "quote", "as"?, "currency"?, "label"?}, {"progress": {"value": expr, "max": expr}, "label"?}, {"group": [blocks], "direction"?: "row"|"column"}, {"when": expr, "show": [blocks]}, {"divider": true}, {"figure": true}`;function hn(e){return Object.fromEntries(Object.entries(e.views??{}).filter(([,n])=>!Array.isArray(n)))}function bn(e){let n=e.views?.home;return Array.isArray(n)?n:void 0}var Ue={field:()=>!1,relation:()=>!1,figure:!1},Ye=e=>e.kind??"the home",V=(e,n)=>e!==void 0&&Object.hasOwn(e,n),S=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function $e(e,n,s){let r=H(e);for(let c of r.unknownFunctions)s.findings.push(l("unknown-function",n,`"${c}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let c of r.names){if(s.kind===null){s.findings.push(l("view-name",n,`"${c}" names nothing here: these blocks are about no one record`,"reach records with all('<kind>'), like count(all('offer')) or first(all('party') where role == 'client').name"));continue}c==="id"||s.spec.field(c)||s.spec.relation(c)||s.findings.push(l("view-name",n,`${s.kind} has no field or relation called "${c}"`))}for(let c of r.edges)s.edges.has(c)||s.findings.push(l("view-edge",n,`"${c}" is not a relation any kind declares`));for(let c of r.sweeps)s.kinds.has(c)||s.findings.push(l("view-kind",n,`"${c}" is not a kind this document declares`))}function L(e,n,s){if(typeof e!="string"||e.length===0||e.length>2e3){s.findings.push(l("view-expression",n,`an expression is a line of the rule language, like "status == 'booked'"`));return}try{$e(C(e),n,s)}catch(r){if(!(r instanceof N))throw r;s.findings.push(l("expression",n,`${r.sentence} (at character ${r.at+1})`))}}function ne(e,n,s){if(typeof e!="string"||e.length===0||e.length>300){s.findings.push(l("view-template",n,'a template is words with {field} in braces, like "{name}" or "{quote|money}", at most 300 characters'));return}let r;try{r=le(e)}catch(c){if(c instanceof de||c instanceof N){s.findings.push(l("template",n,c.sentence));return}throw c}for(let c of r)c.expr&&$e(c.expr,n,s)}function He(e,n,s){if(typeof e=="string"){ee.includes(e)||s.findings.push(l("view-tone",n,`"${e}" is not a tone`,`use one of ${ee.join(", ")}, or {"expr": "if(status == 'booked', 'good', 'neutral')"}`));return}if(S(e)&&Object.keys(e).length===1&&"expr"in e){L(e.expr,`${n}.expr`,s);return}s.findings.push(l("view-tone",n,'a tone is a word or {"expr": \u2026}',`one of ${ee.join(", ")}`))}function Y(e,n,s,r){if(!Array.isArray(e)){r.findings.push(l("view-shape",n,"a view is a list of blocks"));return}if(s>he){r.findings.push(l("view-depth",n,`blocks nest at most ${he} deep`,"flatten a group or a condition"));return}e.forEach((c,d)=>Xe(c,`${n}.${d}`,s,r))}function Xe(e,n,s,r){if(r.count++,!S(e)){r.findings.push(l("view-block",n,"a block is an object naming what it shows",`one of ${ke}`));return}let c=Object.keys(e),d=c.filter(o=>Ze.includes(o)&&!(o==="group"&&c.includes("list")));if(d.length===0){r.findings.push(l("view-block",n,`${c.length>0?c.map(o=>`"${o}"`).join(", "):"an empty object"} is not a block Graview knows`,`one of ${ke}`));return}if(d.length>1){r.findings.push(l("view-block",n,`a block is one thing, and this says ${d.map(o=>`"${o}"`).join(" and ")}`,"split it into two blocks"));return}let a=d[0];for(let o of c)o!==a&&o!="key"&&!Z[a].includes(o)&&r.findings.push(l("unknown-key",`${n}.${o}`,`"${o}" is not part of a ${a} block`,Z[a].length>0?`a ${a} block may also say ${Z[a].map(u=>`"${u}"`).join(", ")}`:`a ${a} block says nothing else`));let t=e[a];switch(a){case"title":case"headline":case"text":case"badge":ne(t,`${n}.${a}`,r),"tone"in e&&He(e.tone,`${n}.tone`,r);return;case"field":{if(typeof t!="string"||!r.spec.field(t)){let o=typeof t=="string"&&r.spec.relation(t);r.findings.push(l("view-field",`${n}.field`,`${r.kind} has no field ${typeof t=="string"?`"${t}"`:"by that name"}`,o?`"${t}" is a relation; show it with {"text": "{${t}.name}"}`:void 0))}"as"in e&&!me.includes(e.as)&&r.findings.push(l("view-format",`${n}.as`,`"${String(e.as)}" is not a way to show a field`,`use one of ${me.join(", ")}`)),Se(e,n,r,"field"),"label"in e&&nn(e.label,`${n}.label`,r);return}case"progress":{!S(t)||Object.keys(t).some(o=>o!=="value"&&o!=="max")||!("value"in t)||!("max"in t)?r.findings.push(l("view-progress",`${n}.progress`,'progress is {"value": expression, "max": expression}')):(L(t.value,`${n}.progress.value`,r),L(t.max,`${n}.progress.max`,r)),"label"in e&&ne(e.label,`${n}.label`,r);return}case"group":"direction"in e&&e.direction!=="row"&&e.direction!=="column"&&r.findings.push(l("view-direction",`${n}.direction`,`a group runs "row" or "column", not "${String(e.direction)}"`)),Y(t,`${n}.group`,s+1,r);return;case"when":L(t,`${n}.when`,r),"show"in e?Y(e.show,`${n}.show`,s+1,r):r.findings.push(l("view-when",n,'a condition says what it shows: {"when": expr, "show": [blocks]}'));return;case"figure":if(typeof t=="string")return Je(e,n,r);for(let o of["as","currency","label"])o in e&&r.findings.push(l("unknown-key",`${n}.${o}`,`"${o}" belongs to a figure that works a number out; {"figure": true} is the kind's picture`,`write {"figure": "count(all('offer'))", "as": "number"}`));t!==!0?r.findings.push(l("view-block",`${n}.figure`,`a figure is a number worked out, {"figure": "sum(all('offer'), net)", "as": "money"}, or the kind's picture, {"figure": true}`)):r.spec.figure||r.findings.push(l("view-figure",`${n}.figure`,`${Ye(r)} has no figure to show`,r.kind===null?`work a number out: {"figure": "count(all('offer'))"}`:'give the kind a "figure", or leave this block out'));return;case"list":return en(e,n,r);case"divider":t!==!0&&r.findings.push(l("view-block",`${n}.${a}`,`write {"${a}": true}`));return}}function Je(e,n,s){L(e.figure,`${n}.figure`,s),"as"in e&&!be.includes(e.as)&&s.findings.push(l("view-format",`${n}.as`,`"${String(e.as)}" is not a way to say a figure`,`use one of ${be.join(", ")}`)),Se(e,n,s,"figure"),"label"in e&&ne(e.label,`${n}.label`,s)}function Se(e,n,s,r){"currency"in e&&(typeof e.currency!="string"||!/^[A-Z]{3}$/.test(e.currency)?s.findings.push(l("view-currency",`${n}.currency`,'a currency is its three-letter code, like "USD" or "EUR"')):e.as!=="money"&&s.findings.push(l("view-currency",`${n}.currency`,`a currency belongs on a ${r} shown as money`,'add "as": "money"')))}function Qe(e,n){let s=[...n.kinds],r=(d,a)=>{let t=new Set;for(let o of d){let u=n.vocabulary.namesOf(o)?.targets?.(a);if(u==="*")return s;for(let y of u??[])t.add(y)}return t.size>0?[...t]:void 0},c=d=>{switch(d.t){case"ident":return n.kind!==null&&n.spec.relation(d.name)?r([n.kind],d.name):void 0;case"member":{let a=c(d.object);return a?r(a,d.name):void 0}case"where":return c(d.set);case"call":{let a=d.args[0],t=a?.t==="lit"&&typeof a.value=="string"?a.value:void 0;if(d.fn==="all")return t!==void 0&&n.kinds.has(t)?[t]:void 0;let o=d.args.length===2&&d.args[1]?.t==="lit"&&typeof d.args[1].value=="string"?d.args[1].value:void 0;if(d.fn==="out"&&o!==void 0){let u=c(a);return u?r(u,o):void 0}if(d.fn==="out")return t!==void 0&&n.kind!==null?r([n.kind],t):void 0;if(d.fn==="in"){let u=o??t,y=o!==void 0?c(a):n.kind!==null?[n.kind]:void 0,k=u!==void 0?n.vocabulary.sources(u).filter($=>{let T=n.vocabulary.namesOf($)?.targets?.(u);return!y||T==="*"||y.some(xe=>T?.includes(xe))}):[];return k.length>0?k:void 0}if((d.fn==="sort"||d.fn==="first")&&a)return c(a);if(d.fn==="either"){let u=d.args.map(c);return u.every(y=>y!==void 0)?[...new Set(u.flatMap(y=>y??[]))]:void 0}return}default:return}};return c(e)}function we(e,n,s,r){let c;try{c=C(e)}catch(a){if(!(a instanceof N))throw a;r.findings.push(l("expression",n,`${a.sentence} (at character ${a.at+1})`));return}let d=H(c);for(let a of d.unknownFunctions)r.findings.push(l("unknown-function",n,`"${a}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let a of d.edges)r.edges.has(a)||r.findings.push(l("view-edge",n,`"${a}" is not a relation any kind declares`));if(s)for(let a of d.names)a==="id"||s.some(t=>r.vocabulary.namesOf(t)?.field(a)||r.vocabulary.namesOf(t)?.relation(a))||r.findings.push(l("view-name",n,`${s.join(" and ")} ${s.length===1?"has":"have"} no field or relation called "${a}"`))}function en(e,n,s){let r=e.list;L(r,`${n}.list`,s);let c;if(typeof r=="string")try{c=Qe(C(r),s)}catch{c=void 0}let d=t=>{if(!c)return[...s.kinds].map(u=>s.vocabulary.namesOf(u)?.choices?.(t)).find(u=>u!==void 0);let o=c.map(u=>s.vocabulary.namesOf(u)?.choices?.(t));return o.every(u=>u!==void 0)?[...new Set(o.flatMap(u=>u??[]))]:void 0},a=c?c.join(" and "):"any kind";if("sort"in e){let t=e.sort;if(typeof t=="string")we(t,`${n}.sort`,c,s);else if(S(t)&&typeof t.by=="string"&&Object.keys(t).every(o=>o==="by"||o==="direction")){let o=t.direction;o!==void 0&&o!=="asc"&&o!=="desc"&&o!=="choices"?s.findings.push(l("list-sort",`${n}.sort.direction`,`a list is sorted "asc", "desc" or "choices", not "${String(o)}"`,'"choices" puts a choice field in the order its choices are declared')):o==="choices"?d(t.by)===void 0&&s.findings.push(l("list-sort",`${n}.sort.by`,`"${t.by}" is not a choice field of ${a}, so it has no declared order`,'sort by a choice field, or say "asc" or "desc"')):we(t.by,`${n}.sort.by`,c,s)}else s.findings.push(l("list-sort",`${n}.sort`,'a sort is a key, like "net", or {"by": key, "direction": "asc" | "desc" | "choices"}'))}if("limit"in e){let t=e.limit;(typeof t!="number"||!Number.isInteger(t)||t<1||t>ze)&&s.findings.push(l("list-limit",`${n}.limit`,`a limit is a whole number from 1 to ${ze}`))}if("group"in e){let t=e.group,o=typeof t=="string"?t:S(t)&&typeof t.by=="string"?t.by:void 0;if(!(typeof t=="string"||S(t)&&Object.keys(t).every(y=>y==="by"||y==="headings"))||o===void 0)s.findings.push(l("list-group",`${n}.group`,'a group is a choice field, like "type", or {"by": "type", "headings": {"pain": "What hurts"}}'));else{let y=d(o);if(y===void 0&&s.findings.push(l("list-group",`${n}.group`,`"${o}" is not a choice field of ${a}, so it has no choices to group by`,"group by a field whose type is enum")),S(t)&&"headings"in t){let k=t.headings;if(!S(k)||Object.values(k).some($=>typeof $!="string"||$.length===0||$.length>80))s.findings.push(l("list-group",`${n}.group.headings`,'headings are words per choice, like {"pain": "What hurts"}, at most 80 characters each'));else if(y)for(let $ of Object.keys(k))y.includes($)||s.findings.push(l("list-group",`${n}.group.headings.${$}`,`"${$}" is not one of ${o}'s choices`,`use ${y.join(", ")}`))}}}"empty"in e&&(typeof e.empty!="string"||e.empty.length===0||e.empty.length>200)&&s.findings.push(l("list-empty",`${n}.empty`,"what an empty list says is a sentence, at most 200 characters")),"as"in e&&!We.includes(e.as)&&s.findings.push(l("list-as",`${n}.as`,`a list draws each record as its "card" or its "row", not "${String(e.as)}"`))}function nn(e,n,s){(typeof e!="string"||e.length===0||e.length>60)&&s.findings.push(l("view-label",n,"a label is a few words, at most 60 characters"))}function ve(e,n,s,r,c,d,a){let t={kind:null,spec:Ue,kinds:r,edges:c,vocabulary:s,findings:d,count:0};Array.isArray(e)&&e.length===0&&d.push(l("view-shape",n,`${a} has no blocks`,'give it one: {"headline": "\u2026"}')),Y(e,n,1,t),t.count>U&&d.push(l("view-size",n,`${a} has ${t.count} blocks; a view has at most ${U}`,"show less"))}function tn(e,n,s,r,c){Array.isArray(e)&&e.forEach((d,a)=>{if(!S(d)||d.name!=="blocks"||!S(d.options)||!("blocks"in d.options))return;let t=[];ve(d.options.blocks,`lenses.${a}.options.blocks`,n,s,r,t,`the lens "${String(d.title??a)}"`);for(let o of t)c.push({...o,severity:"warning"})})}function on(e,n,s,r,c,d,a){let t=[];if(e===void 0)return t;if(!S(e))return t.push(l("view-shape",n,'views are an object of kinds, each with a "card", a "row" or a "page"')),t;for(let[o,u]of Object.entries(e)){if(o==="home"&&Array.isArray(u)){ve(u,`${n}.home`,a,r,c,t,"the home");continue}let y=s(o);if(!y){t.push(l("view-kind",`${n}.${o}`,`"${o}" is not a kind this ${d} declares`));continue}if(!S(u)){t.push(l("view-shape",`${n}.${o}`,`a kind's views are {"card": [blocks], "row": [blocks], "page": [blocks]}`));continue}for(let k of Object.keys(u))Q.includes(k)||t.push(l("view-slot",`${n}.${o}.${k}`,`"${k}" is not a place a view is drawn`,`use ${Q.map($=>`"${$}"`).join(", ")}`));for(let k of Q){let $=u[k];if($===void 0)continue;let T={kind:o,spec:y,kinds:r,edges:c,vocabulary:a,findings:t,count:0};Y($,`${n}.${o}.${k}`,1,T),T.count>U&&t.push(l("view-size",`${n}.${o}.${k}`,`this ${k} has ${T.count} blocks; a view has at most ${U}`,"show less, or move detail to the page"))}}return t}function zn(e){let n=new Set(Object.keys(e.kinds)),s=new Set(Object.values(e.kinds).flatMap(a=>Object.keys(a.edges??{}))),r=a=>{let t=V(e.kinds,a)?e.kinds[a]:void 0;return t?{field:o=>V(t.fields,o)||V(t.computed,o),relation:o=>V(t.edges,o),figure:t.figure!==void 0,choices:o=>V(t.fields,o)&&t.fields[o].type==="enum"?t.fields[o].options:void 0,targets:o=>V(t.edges,o)?t.edges[o].to:void 0}:void 0},c={namesOf:r,sources:a=>Object.keys(e.kinds).filter(t=>V(e.kinds[t].edges,a))},d=on(e.views,"views",r,n,s,"document",c);return tn(e.lenses,c,n,s,d),d}export{Oe as a,je as b,sn as c,an as d,ln as e,ee as f,me as g,be as h,ze as i,hn as j,bn as k,zn as l};
@@ -0,0 +1 @@
1
+ import{a as ee}from"./chunk.G4JJXA63.js";import{b as nt}from"./chunk.7BAUPTMY.js";import{d as tt}from"./chunk.WX5CJ7PI.js";import"./chunk.JCZH55RX.js";import{Fa as fe,J as Ye,Ja as Se,Ka as Xe,Oa as G,P as ze,R as Je,Sa as Ze,T as Ae,U as F,V as qe,Wb as et,ea as Ve,fa as Qe,za as V}from"./chunk.RAE4M3KQ.js";import"./chunk.AJZBJBMO.js";var vt="Nothing by that name here.",$=o=>o.normalize("NFD").replace(/\p{M}+/gu,"").toLowerCase().replace(/[’']/g,"'").replace(/[^\p{L}\p{N}' ]+/gu," ").replace(/\s+/g," ").trim(),At=/^(?:(?:can you |could you |please )?(?:go|take me|bring me|head|jump|navigate|switch|get me)(?: back)? to|(?:please )?(?:open|show(?: me)?|bring up|let me see|view)) (.+)$/,St=/^(?:(?:can you |could you |please )?tell me (?:about|of)|what(?: is|'s| are) (?:in |on )?|describe|explain|who(?: is|'s)) (.+)$/,Nt=/^(?:what(?: is|'s| am i looking at| do i see)(?: (?:here|this|on (?:this|the) (?:page|screen)|in view|this place|this page))?|where am i|describe (?:this|here|this place|this page)|tell me about (?:this|here|this place|this page))$/,st=new Set(["here","this","this place","this page","on this page","on the page","on this screen","in view"]),Ot=/^(?:date|day|when|on|at|the date|the day)$/,Ct=/^(?:what(?: is|'s) (?:wrong|broken|the (?:problem|matter|trouble))|what needs (?:fixing|attention|doing)|any (?:problems|issues|trouble)|(?:show(?: me)? |go to |open )?(?:the )?(?:problems|issues|trouble|standing|what's wrong)|is (?:anything|something) (?:wrong|broken)|are there (?:any )?(?:problems|issues))(?: (?:with|about|on|in) (.+))?$/,Y=o=>o.replace(/^(?:the|a|an|my|our) /,""),te=new Set(["the","a","an","my","our","all","any","of","that","which","who","are","is","be","what","whats","what's","with","me","show","list","every","there","do","i","have","we","due","for","please","were","was","by","from","in","on"]),ct=864e5,se=o=>Date.UTC(Number(o.slice(0,4)),Number(o.slice(5,7))-1,Number(o.slice(8,10))),Me=o=>new Date(o).toISOString().slice(0,10),C=(o,i)=>Me(se(o)+i*ct),jt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],Mt=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ut=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Dt="(monday|tuesday|tues|wednesday|thursday|thurs|friday|saturday|sunday)",ot="(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sept|sep|oct|nov|dec)",rt="(\\d{1,2})(?:st|nd|rd|th)?",Wt=o=>jt.findIndex(i=>i.startsWith(o.slice(0,3))),it=o=>ut.findIndex(i=>o.startsWith(i.toLowerCase()));function xt(o,i){let p=new Date(se(o)),u=o.slice(0,4)===i.slice(0,4)?"":` ${o.slice(0,4)}`;return`${Mt[p.getUTCDay()]} ${p.getUTCDate()} ${ut[p.getUTCMonth()]}${u}`}function Ne(o,i,p){if(o<0||i<1||i>31)return;let u=Number(p.slice(0,4)),c=k=>{let j=Date.UTC(k,o,i);return new Date(j).getUTCMonth()===o?Me(j):void 0},y=c(u);if(y)return se(y)<se(p)-183*ct?c(u+1):y}function Oe(o,i,p){let u=new Date(se(i)).getUTCDay(),c=f=>{let N=(u-p+7)%7,w=C(i,-N+f*7);return{from:w,to:C(w,6)}},y=()=>{let f=`${i.slice(0,8)}01`,N=new Date(Date.UTC(Number(i.slice(0,4)),Number(i.slice(5,7)),1));return{from:f,to:C(Me(N.getTime()),-1)}},k=f=>f?{from:f,to:f,day:xt(f,i)}:void 0,j=(f,N)=>{let w=Wt(N);return k(f==="this"||f==="next"?C(c(f==="next"?1:0).from,(w-p+7)%7):f==="last"?C(i,-((u-w+6)%7+1)):C(i,(w-u+7)%7))},z=f=>{let N=C(i,u===0?-1:6-u);return{from:C(N,f*7),to:C(N,f*7+1)}},U="\\b(?:(?:due |for |on |by )(?:the )?)?",P=[[/\b(?:overdue|past due|late)\b/,()=>({overdue:!0,to:C(i,-1)})],[/\b(?:due |for |on )?today\b/,()=>({from:i,to:i})],[/\b(?:due |for |on )?tomorrow\b/,()=>k(C(i,1))],[/\b(?:due |for |on )?yesterday\b/,()=>k(C(i,-1))],[/\b(?:due |for |on )?this week\b/,()=>c(0)],[/\b(?:due |for |on )?next week\b/,()=>c(1)],[/\b(?:due |for |on )?(?:last|previous) week\b/,()=>c(-1)],[/\b(?:due |for |on )?next weekend\b/,()=>z(1)],[/\b(?:due |for |on )?(?:this |the )?weekend\b/,()=>z(0)],[/\b(?:due |for |on )?this month\b/,()=>y()],[new RegExp(`${U}(\\d{4}) (\\d{2}) (\\d{2})\\b`),f=>k(Ne(Number(f[2])-1,Number(f[3]),`${f[1]}-01-01`))],[new RegExp(`${U}${rt} (?:of )?${ot}\\b`),f=>k(Ne(it(f[2]),Number(f[1]),i))],[new RegExp(`${U}${ot} (?:the )?${rt}\\b`),f=>k(Ne(it(f[1]),Number(f[2]),i))],[new RegExp(`${U}(?:(this|next|last|coming) )?${Dt}\\b`),f=>j(f[1],f[2])]];for(let[f,N]of P){let w=o.match(f);if(!w)continue;let S=N(w);if(S)return{ask:{words:w[0],...S},rest:o.replace(w[0]," ").replace(/\s+/g," ").trim()}}}function ft(o,i,p={}){let u=p.principal??{kind:"human"},c=o.seenBy(u),y=c.schema,k=p.today??o.today?.()??new Date().toISOString().slice(0,10),j=p.weekStartsOn??1,z=o.kindsKeptFrom(u),U=o.modules.disabledKinds,P=y.kinds.filter(e=>!z.has(e)&&!U.has(e)),f=new Set(P),N=(p.places??[]).filter(e=>e.kind===null||f.has(e.kind)),w=c.graph,S=$(i).replace(/[?.!]+$/,"").trim();if(S.length===0)return{unresolved:!0};let D=e=>y.tryDefinition(e),T=e=>Ye(D(e.kind),e),H=e=>ze(y,e),oe=e=>N.find(t=>t.kind===e&&t.address===Se(y,e))?.address??Se(y,e),ge=e=>Xe(y,e.kind,e.id),De=e=>({to:"record",id:e.id,kind:e.kind,label:T(e),address:ge(e),said:`Went to ${T(e)}.`}),We=e=>{let t=`Went to ${e.title}.`;return e.kind===null?{to:"place",slug:e.slug,title:e.title,address:e.address,...e.slug==="overview"?{face:"scene"}:{},said:t}:e.lens||e.address.startsWith("/places/")?{to:"picture",kind:e.kind,as:e.slug,title:e.title,address:e.address,said:t}:{to:"kind",kind:e.kind,title:e.title,address:e.address,said:t}},xe=()=>({unresolved:!0,say:vt}),re=e=>{let t=D(e.kind),s=qe(e,t,{limit:3}).map(r=>r.alone.startsWith(r.label)?r.alone:`${r.label.toLowerCase()} ${r.alone}`).join(", "),n=c.violations().filter(r=>r.nodeIds.includes(e.id));return[`${T(e)} \u2014 ${Ae(F(t,e.kind))}${s?` (${s})`:""}.`,n.length>0?`Trouble: ${n.map(r=>r.message).join("; ")}.`:""].filter(Boolean).join(" ")},ie=e=>{let t=new Set([G(e),G(Y(e))]);for(let n of[" page"," view"," lens"," place"," picture"," list"])e.endsWith(n)&&(t.add(G(e.slice(0,-n.length))),t.add(G(Y(e.slice(0,-n.length)))));t.delete("");let s=n=>t.has(G(n.title))||t.has(G(Y($(n.title))))||t.has(G(n.slug));return N.find(n=>n.kind!==null&&n.address.startsWith("/places/")&&s(n))??N.find(s)},pe=e=>{let t=Ze(o,e,{principal:u,today:k,limit:6,...p.selection?{from:p.selection}:{}}),s=t.hits.filter(r=>r.about==="node"&&f.has(r.kind)&&w.getNode(r.id)!==void 0),n=s.filter(r=>r.why.field==="label"&&r.why.strength==="exact");return n.length===1?{one:w.getNode(n[0].id),picks:s}:n.length>1?{picks:n}:s.length===1&&t.total===1?{one:w.getNode(s[0].id),picks:s}:{picks:s}},Ee=e=>{let t=e.map(s=>`${s.label} (${F(D(s.kind),s.kind)})`);return`${e.length===1?"One thing matches":`${e.length} things match`}: ${t.join("; ")}.`},Re=(e,t)=>{if(st.has(e))return Le();let s=t?pe(Y(e)||e):void 0,n=s?.one&&$(T(s.one))===$(Y(e)||e)?void 0:ie(e);if(n){let l=We(n);return{about:"place",say:t?`${l.said} ${ye(n)}`:l.said,moves:[l],subject:n.slug}}let r=pe(Y(e)||e);if(r.one){let l=De(r.one);return{about:t?"describe":"record",say:t?`${l.said} ${re(r.one)}`:l.said,moves:[l],subject:r.one.id}}if(r.picks.length>0)return{about:"picks",say:Ee(r.picks),moves:[],picks:r.picks};let h=de(e);if(h)return h;let d=Pe(e);if(d){if(d.rest.split(" ").every(l=>l===""||te.has(l))){let l=H(d.kind),v={to:"kind",kind:d.kind,title:l,address:oe(d.kind),said:`Went to the ${l.toLowerCase()}.`};return{about:"kind",say:v.said,moves:[v]}}return{unresolved:!0}}return xe()},ye=e=>{if(e.kind===null){let h=P.map(l=>({kind:l,count:w.nodesOfKind(l).length})).filter(l=>l.count>0).map(l=>`${l.count} ${(l.count===1?F(D(l.kind),l.kind):H(l.kind)).toLowerCase()}`),d=c.violations().length;return[h.length>0?`It holds ${he(h)}.`:"It holds nothing yet.",d>0?`${d===1?"One problem":`${d} problems`} to see to.`:""].filter(Boolean).join(" ")}let t=w.nodesOfKind(e.kind).length,s=H(e.kind).toLowerCase(),n=new Set(c.violations().flatMap(h=>h.nodeIds)),r=w.nodesOfKind(e.kind).filter(h=>n.has(h.id)).length;return[e.lens?`It draws the ${s} as ${Ae(e.lens)}${t>0?` \u2014 ${t} of them`:""}.`:`${t===0?"No":t} ${t===1?F(D(e.kind),e.kind):s} ${t===1?"is":"are"} here.`,r>0?`${r} ${r===1?"has":"have"} a problem.`:""].filter(Boolean).join(" ")},Le=()=>{let e=(p.selection??[]).map(s=>w.getNode(s)).find(s=>s!==void 0);if(e)return{about:"here",say:re(e),moves:[],subject:e.id};let t=N.find(s=>s.slug===p.place)??N.find(s=>s.slug==="home");return t?{about:"here",say:`${t.title}. ${ye(t)}`,moves:[],subject:t.slug}:{about:"here",say:ye({slug:"home",title:"Home",kind:null,cardinality:"many",address:"/",stop:"#"}),moves:[]}},Pe=e=>{let t=P.flatMap(s=>[H(s),F(D(s),s),s].map(n=>({kind:s,name:$(n)}))).filter(s=>s.name.length>0).sort((s,n)=>n.name.length-s.name.length);for(let{kind:s,name:n}of t)if(!(` ${e} `.indexOf(` ${n} `)<0))return{kind:s,rest:` ${e} `.replace(` ${n} `," ").replace(/\s+/g," ").trim()}},ae=(e,t)=>{let s=V(y,e).filters.filter(d=>d.about==="field"&&d.type==="date");if(s.length===0)return;let n=s.find(d=>t.some(l=>$(d.key)===l||$(d.label)===l));if(n)return n;let r=D(e)?.fieldRoles??{};for(let d of["due","deadline","date","when","start","end"]){let l=r[d],v=l?s.find(M=>M.key===l):void 0;if(v)return v}return s.find(d=>["due","deadline","date","when","on","at"].includes(d.key.toLowerCase()))??(s.length===1?s[0]:void 0)},Te=e=>{let t=D(e),s=V(y,e).filters;if(t?.lifecycle)return{conditions:[{key:"is",value:"current"}],holds:d=>fe(be,d,{key:"is",value:"current"})};let r=s.find(d=>d.about==="field"&&d.type==="boolean"&&ne.has($(d.key)));if(r)return{conditions:[{key:r.key,value:"false"}],holds:d=>d[r.key]!==!0};let h=s.find(d=>d.about==="field"&&d.type==="choice"&&(d.options??[]).some(l=>ne.has($(l))));if(h){let d=new Set((h.options??[]).filter(v=>ne.has($(v)))),l=(h.options??[]).filter(v=>!d.has(v));return l.length===1?{conditions:[{key:h.key,value:l[0]}],holds:v=>v[h.key]===l[0]}:"unsayable"}return{conditions:[],holds:()=>!0}},He=(e,t)=>{let s=e.words.startsWith("due")||$(t.key)==="due",n=Ot.test($(t.label));if(e.day)return s?`due ${e.day}`:n?`on ${e.day}`:`${t.label.toLowerCase()} on ${e.day}`;let r=e.words.replace(/^(?:due|for|on|by) (?:the )?/,"");return s?`due ${r}`:n?r:`${t.label.toLowerCase()} ${r}`},me=new Set(c.violations().flatMap(e=>e.nodeIds)),be={schema:y,graph:c.graph,flagged:me,today:k},de=e=>{let t=Oe(e,k,j),s=Pe(t?.rest??e),n=s?.kind,r=(s?.rest??t?.rest??e).split(" ").filter(Boolean);if(!n&&t){let g=e.split(" "),m=P.filter(L=>ae(L,g)!==void 0),R=m.filter(L=>{let b=ae(L,g);return g.some(O=>$(b.key)===O||$(b.label)===O)}),B=m.length===1?m:R;if(B.length!==1)return;n=B[0]}if(!n)return;let h=V(y,n).filters,d=[],l=[],v=[],M=[],q=!1,le=[];for(let g=0;g<r.length;g++){let m=r[g],R=g>0&&(r[g-1]==="not"||r[g-1]==="un"),B=h.find(b=>b.about==="field"&&b.type==="choice"&&(b.options??[]).some(O=>$(O)===m));if(B&&!R){let b=(B.options??[]).find(O=>$(O)===m);d.push({key:B.key,value:b}),l.push(b);continue}let L=h.find(b=>b.about==="field"&&b.type==="boolean"&&[$(b.key),$(b.label)].some(O=>O===m||O===m.replace(/^un/,"")));if(L){let b=!R&&!(m.startsWith("un")&&!$(L.key).startsWith("un"));d.push({key:L.key,value:String(b)}),l.push(b?m:`not ${m.replace(/^un/,"")}`);continue}if(Lt.has(m)&&!R){let b=Te(n);b==="unsayable"?(q=!0,M.push(O=>!lt(y,O))):(d.push(...b.conditions),M.push(b.holds)),l.push(m);continue}m==="not"||m==="un"||t&&h.some(b=>b.type==="date"&&($(b.key)===m||$(b.label)===m))||le.push(m)}if(r=le,r.some(g=>!te.has(g))||!t&&d.length===0&&M.length===0)return;let I=H(n).toLowerCase(),Q=H(n);if(t){let g=ae(n,e.split(" "));if(!g){let m={to:"kind",kind:n,title:Q,address:oe(n),said:`Went to the ${I}.`};return{about:"kind",say:`${ee(Q)} carry no date, so I can't tell which are ${/^(?:due|for|on|overdue|past due|late)\b/.test(t.ask.words)?t.ask.words:`due ${t.ask.words}`}. ${m.said}`,moves:[m]}}if(t.ask.from&&d.push({key:g.key,value:`after:${C(t.ask.from,-1)}`}),t.ask.to&&d.push({key:g.key,value:`before:${C(t.ask.to,1)}`}),t.ask.overdue){let m=Te(n);m==="unsayable"?(q=!0,M.push(R=>!lt(y,R))):(d.push(...m.conditions),M.push(m.holds))}t.ask.overdue?l.push("overdue"):v.push(He(t.ask,g))}let E=w.nodesOfKind(n).filter(g=>d.every(m=>fe(be,g,m))&&M.every(m=>m(g))),K=[...l,...v].join(" and "),J=[...l,I,...v].join(" "),W=E.slice(0,6).map(g=>({about:"node",id:g.id,kind:n,label:T(g),why:{field:d[0]?.key??"label",reading:d[0]?.key??"Name",fragment:K,strength:"field"},current:!0,flagged:me.has(g.id),address:ge(g)})),X=E.length===0?`No ${I} are ${K}.`:`${E.length===1?`One ${F(D(n),n)} is`:`${E.length} ${I} are`} ${K}: ${he(E.slice(0,6).map(T))}${E.length>6?`, and ${E.length-6} more`:""}.`;if(q)return{about:"kind",say:X,moves:[],picks:W,offer:{draft:J,label:"Show as a view"}};let Z=d.map(g=>`${g.key}:${g.value}`).join(","),we=`${oe(n)}?${new URLSearchParams({filter:Z}).toString()}`,_={to:"kind",kind:n,title:ee(J),filter:Z,address:we,said:`Went to the ${J}.`};return{about:"kind",say:`${_.said} ${X}`,moves:[_],picks:W}},Ie=e=>D(e)?.figure==="person"?!0:[e,F(D(e),e),H(e)].some(s=>$(s).split(" ").some(n=>Et.has(n))),gt=e=>{let t=[],s=n=>D(n)?.edges??{};for(let[n,r]of Object.entries(s(e)))for(let h of r.to??[])f.has(h)&&t.push({key:n,direction:"out",far:h,words:dt(`${r.description??""} ${n}`)});for(let n of P)for(let[r,h]of Object.entries(s(n)))(h.to??[]).includes(e)&&t.push({key:r,direction:"in",far:n,words:dt(`${h.inverse??""} ${r}`)});return t},pt=e=>{let t=e.match(/^(who|which|what)\b/)?.[1];if(!t)return;let s=Oe(e,k,j);if(!s||s.ask.overdue)return;let n=s.rest.split(" ").filter(Boolean),r=P.flatMap(a=>[H(a),F(D(a),a),a].map(A=>({kind:a,name:$(A)}))).filter(a=>a.name.length>0).sort((a,A)=>A.name.length-a.name.length),h=` ${n.join(" ")} `,d=[];for(let{kind:a,name:A}of r)h.includes(` ${A} `)&&(h=h.replace(` ${A} `," "),d.includes(a)||d.push(a));let l=h.match(/\b(?:is|are|was|were)\b|'s\b/)?.[0],v=h.replace(/'s\b/g," ").split(" ").filter(a=>a.length>0&&!te.has(a)&&!Ce.has(a)),M=t==="who"?d.find(Ie):d[0];if(!M&&t!=="who")return;let q=d.find(a=>a!==M),le=v.flatMap(a=>[je(a),...at.has(je(a))?[...at]:[]]),I=P.filter(a=>q?a===q:a!==M).flatMap(a=>{let A=ae(a,e.split(" "))??V(y,a).filters.find(x=>x.about==="field"&&x.type==="date");return A?gt(a).filter(x=>(M?x.far===M:Ie(x.far))&&x.far!==a).map(x=>({kind:a,field:A,relation:x,said:v.length===0||le.some(ve=>x.words.some(wt=>Rt(wt,ve)))})):[]}).filter(a=>a.said);if(I.length===0)return;let Q=I.filter(a=>n.some(A=>$(a.field.key)===A||$(a.field.label)===A)),E=I.length===1?I[0]:Q.length===1?Q[0]:void 0;if(!E)return;let{kind:K,field:J,relation:W}=E,X=[...s.ask.from?[{key:J.key,value:`after:${C(s.ask.from,-1)}`}]:[],...s.ask.to?[{key:J.key,value:`before:${C(s.ask.to,1)}`}]:[]],Z=w.nodesOfKind(K).filter(a=>X.every(A=>fe(be,a,A))),we=a=>(W.direction==="out"?c.graph.out(a.id,W.key):c.graph.in(a.id,W.key)).filter(A=>A.kind===W.far&&f.has(W.far)),_=[],g=[];for(let a of Z){let A=we(a);A.length===0&&g.push(a);for(let x of A)_.some(ve=>ve.id===x.id)||_.push(x)}let m=He(s.ask,J),R=s.ask.day?`On ${s.ask.day}`:ee(s.ask.words.replace(/^(?:due|for|on|by) (?:the )?/,"")),B=H(K).toLowerCase(),L=X.map(a=>`${a.key}:${a.value}`).join(","),b=`${B} ${m}`,O={to:"kind",kind:K,title:ee(b),filter:L,address:`${oe(K)}?${new URLSearchParams({filter:L}).toString()}`,said:`Went to the ${b}.`};if(Z.length===0)return{about:"related",say:`No ${b}. ${O.said}`,moves:[O]};let ce=v.join(" "),yt=l==="was"||l==="were",Ge=a=>yt?a===1?"was":"were":a===1?"is":"are",ue=_.map(T),mt=ue.length>8?[...ue.slice(0,8),`${ue.length-8} more`]:ue,bt=_.length===0?`${R}: nobody ${Ge(1)}${ce?` ${ce}`:""}.`:`${R}: ${he(mt)}${ce?` ${Ge(_.length)} ${ce}`:""}.`,kt=t==="who"&&g.length>0?`${he(g.slice(0,4).map(T))}${g.length>4?` and ${g.length-4} more`:""} ${g.length===1?"has":"have"} nobody.`:"",$t=_.slice(0,8).map(a=>({about:"node",id:a.id,kind:a.kind,label:T(a),why:{field:W.key,reading:Je(y,W.direction==="out"?K:W.far,W.key,W.direction==="out"?"out":"in"),fragment:m,strength:"field"},current:!0,flagged:me.has(a.id),address:ge(a)}));return{about:"related",say:[bt,kt,O.said].filter(Boolean).join(" "),moves:[O],picks:$t}},Ke=S.match(Ct);if(Ke){let e=Ke[1];if(e&&!st.has(e)&&!/^(?:it|this|that)$/.test(e)){let n=ie(e),r=n?void 0:pe(Y(e)||e);if(r?.one){let h=De(r.one);return{about:"describe",say:`${h.said} ${re(r.one)}`,moves:[h],subject:r.one.id}}if(!n)return r&&r.picks.length>0?{about:"picks",say:Ee(r.picks),moves:[],picks:r.picks}:xe()}if(e&&/^(?:it|this|that)$|^(?:here|this place|this page)$/.test(e)){let n=(p.selection??[]).map(r=>w.getNode(r)).find(r=>r!==void 0);if(n)return{about:"describe",say:re(n),moves:[],subject:n.id}}let t=c.violations();if(t.length===0)return{about:"problems",say:"Nothing is wrong \u2014 every rule holds.",moves:[]};let s={to:"problems",address:"/problems",said:"Went to the problems."};return{about:"problems",say:`${s.said} ${Qe(t)}: ${t.slice(0,4).map(n=>n.message).join("; ")}${t.length>4?"\u2026":"."}`,moves:[s]}}if(Nt.test(S))return Le();let _e=pt(S);if(_e)return _e;let ke=Oe(S,k,j);if(ke&&!ie(Y(ke.ask.words))&&ke.rest.replace(/'s\b/g,"").split(" ").every(e=>e===""||te.has(e)||Ce.has(e))){let e=de(S);if(e)return e}if(/^open /.test(S)){let e=de(S);if(e)return e}let Fe=S.match(At)??S.match(/^(?:go|take me|head|get me)(?: back)? (home)$/);if(Fe)return Re(Fe[1].trim(),!1);let Ue=S.match(St);if(Ue){let e=Re(Ue[1].trim(),!0);return"unresolved"in e&&e.unresolved&&!/^tell me|^describe/.test(S)?{unresolved:!0}:e}let $e=ie(S);if($e){let e=We($e);return{about:"place",say:e.said,moves:[e],subject:$e.slug}}let Be=de(S);return Be||{unresolved:!0}}var Ce=new Set(["who","whom","whose","which","what","whats","what's","who's"]),Et=new Set(["person","people","user","users","member","members","volunteer","volunteers","gardener","gardeners","player","players","staff","worker","workers","employee","employees","owner","owners","assignee","assignees","helper","helpers","student","students","teacher","teachers","customer","customers","client","clients","contact","contacts","author","authors"]),at=new Set(["work","cover","staff","assign","do","run","schedul","roster","book","duty","serv","help"]);function je(o){let i=o.toLowerCase().replace(/'s$/,"");for(let p of["ing","ed","es","s"])if(i.length>p.length+2&&i.endsWith(p)){let u=i.slice(0,-p.length);return u.length>3&&u[u.length-1]===u[u.length-2]?u.slice(0,-1):u}return i}function dt(o){return o.toLowerCase().split(/[^a-z']+/).filter(i=>i.length>1&&!te.has(i)&&!Ce.has(i)&&!["it","they","them","their","its","this","here","to","at"].includes(i)).map(je)}var Rt=(o,i)=>o===i||o.length>=4&&i.length>=4&&(o.startsWith(i)||i.startsWith(o)),ne=new Set(["done","finished","complete","completed","closed","resolved","agreed","canceled","archived","shipped","delivered"]),Lt=new Set(["open","unfinished","outstanding","pending","remaining","undone","incomplete"]);function lt(o,i){return V(o,i.kind).filters.some(u=>u.about==="field"&&(u.type==="boolean"&&ne.has(u.key.toLowerCase())&&i[u.key]===!0||u.type==="choice"&&typeof i[u.key]=="string"&&ne.has(String(i[u.key]).toLowerCase())))}function he(o){return o.length<=1?o[0]??"":`${o.slice(0,-1).join(", ")} and ${o[o.length-1]}`}function _t(o,i,p={}){let u=p.scene!==void 0?{...p.pages,scene:p.scene}:p.pages;return[...et(o,i,u?{pages:u}:{})].map(({first:c,hidden:y,lens:k,...j})=>j)}function ht(o,i){return{...o.principal?{principal:o.principal}:{},...o.places?{places:o.places}:{},...o.selection?{selection:o.selection}:{},...o.place?{place:o.place}:{},...i??o.today?{today:i??o.today}:{},...o.weekStartsOn!==void 0?{weekStartsOn:o.weekStartsOn}:{}}}function Ft(o,i,p,u){let c=ft(o,i,ht(p,u));if(c.unresolved)return c.say?{reply:{say:c.say,proposals:[],grounded:!0}}:{};if(c.about==="picks")return{};let y=c.moves.length>0?{moves:c.moves}:{},k=c.subject?o.graph.getNode(c.subject):void 0;if(c.about==="problems")return{...y,problems:!0};if(k&&(c.about==="describe"||c.about==="here"))return{...y,told:k.id};let j=k?tt(o,nt(Ve(o.violations(),[k.id])).slice(0,3)):[];return{reply:{say:c.say,proposals:j,grounded:!0,...y,...c.picks&&c.picks.length>0?{picks:c.picks}:{},...c.offer?{offer:c.offer}:{}}}}function Ut(o,i,p={}){let u=ht(p),c=[];for(let y of i){let k=typeof y=="string"?y:typeof y=="object"&&y!==null&&typeof y.to=="string"?y.to:void 0;if(!k||k.trim().length===0)continue;let j=ft(o,/^(?:go|take me|open|show)\b/i.test(k.trim())?k:`go to ${k}`,u);if("moves"in j)for(let z of j.moves)c.some(U=>U.address===z.address)||c.push(z)}return c}export{vt as NOTHING_BY_THAT_NAME,ht as askContextOf,Ft as goingFrom,Ut as movesFromNames,_t as placesFromViews,ft as resolveAsk};
@@ -1,4 +1,4 @@
1
- import{tb as e}from"./chunk.Y235YZSZ.js";var a=`
1
+ import{yb as e}from"./chunk.RAE4M3KQ.js";var a=`
2
2
  .graview-spec { display: flex; flex-direction: column; gap: 6px; min-width: 0; color: var(--graview-ink); }
3
3
 
4
4
  .graview-spec-row { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 10px; box-sizing: border-box; max-width: 100%; padding: 5px 10px; border: 1px solid var(--graview-edge); border-radius: var(--graview-radius-sm, 8px); background: var(--graview-panel); font-size: 0.875rem; }
@@ -1 +1 @@
1
- import{e as T,f as I,g as L,h as D,i as E}from"./chunk.DO4P2UK4.js";import{a as U}from"./chunk.FLJP3BGP.js";import{c as w,e as _}from"./chunk.ENMNLR73.js";import{a as A,b as N,c as C,e as R,l as M,m,n as V}from"./chunk.LZQZP2PD.js";import{E as O,I as G,M as k,R as F}from"./chunk.Y235YZSZ.js";var S=e=>{try{return e()}catch{return null}},X=e=>typeof e=="string"&&I.includes(e);function q(e){if(e!==void 0)return X(e)?e:e&&typeof e=="object"&&typeof e.expr=="string"?{expr:S(()=>w(e.expr))}:"neutral"}var Q=4;function ee(e){let n=typeof e.list=="string"?S(()=>w(e.list)):null,a=e.sort,r=typeof a=="string"?a:a&&typeof a=="object"&&typeof a.by=="string"?a.by:void 0,t=a&&typeof a=="object"?a.direction:void 0,o=n,i;if(n&&r!==void 0)if(t==="choices")i=r;else{let f=S(()=>w(r));o=f?{t:"call",fn:"sort",args:[n,f,{t:"lit",value:t==="desc"?"desc":"asc",at:0}],at:0}:null}let l=typeof e.limit=="number"&&Number.isInteger(e.limit)&&e.limit>=1?Math.min(e.limit,E):void 0,s=e.group,d=typeof s=="string"?s:s&&typeof s=="object"&&typeof s.by=="string"?s.by:void 0,y=s&&typeof s=="object"&&s.headings&&typeof s.headings=="object"?s.headings:{};return{t:"list",source:o,...i?{choiceOrder:i}:{},...l?{limit:l}:{},...d?{group:{by:d,headings:Object.fromEntries(Object.entries(y).filter(f=>typeof f[1]=="string"))}}:{},...typeof e.empty=="string"?{empty:e.empty}:{},as:e.as==="card"?"card":"row"}}function W(e,n=1,a=""){if(!Array.isArray(e)||n>Q)return[];let r={};return e.flatMap(t=>{if(!t||typeof t!="object"||Array.isArray(t))return[];let o=t,i=p=>typeof p=="string"?S(()=>_(p)):null,l=p=>typeof p=="string"?S(()=>w(p)):null,s=q(o.tone),d=typeof o.label=="string"?o.label:void 0,y=p=>Object.hasOwn(o,p),f=typeof o.currency=="string"&&/^[A-Z]{3}$/.test(o.currency)?o.currency:void 0,u=y("list")?"list":y("headline")?"headline":typeof o.figure=="string"?"number":ne.find(y);if(!u)return[];let x=r[u]=(r[u]??0)+1,j=o.key,B=typeof j=="string"&&j?j:`${a}${u}.${x}`;return[{...(()=>{switch(u){case"list":return ee(o);case"number":{let p=D.includes(o.as)?o.as:void 0;return{t:u,value:l(o.figure),...p?{as:p}:{},...f?{currency:f}:{},...d?{label:i(d)}:{}}}case"headline":case"title":return{t:u,parts:i(o[u])};case"text":case"badge":return{t:u,parts:i(o[u]),...s?{tone:s}:{}};case"field":{let p=L.includes(o.as)?o.as:void 0;return{t:u,field:String(o.field),...p?{as:p}:{},...f?{currency:f}:{},...d?{label:d}:{}}}case"progress":{let p=o.progress??{};return{t:u,value:l(p.value),max:l(p.max),...d?{label:i(d)}:{}}}case"group":return{t:u,blocks:W(o.group,n+1,`${B}.`),direction:o.direction==="row"?"row":"column"};case"when":return{t:u,when:l(o.when),show:W(o.show,n+1,`${B}.`)};default:return{t:u}}})(),key:B}]})}var ne=["title","text","badge","field","progress","group","when","divider","figure"],h="\u2014",re=500;function g(e,n){if(!e)return{ok:!1,problem:"an expression that does not parse"};try{return{ok:!0,value:R(e,{graph:n.graph??M,subject:n.node,kinds:n.kinds,today:n.today,budget:n.budget??re})}}catch(a){return{ok:!1,problem:a instanceof Error?a.message:String(a)}}}function b(e,n){if(!e)return{text:h,problem:"a template that does not parse"};let a,r=e.map(t=>{if(t.text!==void 0)return t.text;let o=g(t.expr??null,n);return o.ok?m(o.value,t.format,n.today,t.formatArgs,n.money):(a??=`{${t.source??""}}: ${o.problem}`,h)}).join("");return a?{text:r,problem:a}:{text:r}}function $(e,n){if(e===void 0)return;if(typeof e=="string")return e;let a=g(e.expr,n);return a.ok&&X(a.value)?a.value:"neutral"}function te(e){if(typeof e=="string")try{let n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"?n.href:void 0}catch{return}}function oe(e,n,a,r,t){if(n==null||n==="")return h;if(typeof n=="boolean")return n?"yes":"no";if(r)return m(n,r,a.today,[],t?{...a.money,currency:t}:a.money);let o=a.fields[e];return a.definition?.display?.format?.[e]?k(a.definition,e,n):o?.type==="date"?m(n,"date",a.today):o?.type==="enum"&&typeof n=="string"?k(a.definition,e,n):typeof n=="number"?n.toLocaleString("en-US"):Array.isArray(n)?n.map(i=>String(i)).join(", "):typeof n=="object"?h:String(n)}function ae(e,n,a,r,t){return typeof e!="number"?String(e):n==="money"?V(e,a?{...t,currency:a}:t):n==="percent"?m(e,n,r):e.toLocaleString("en-US",{maximumFractionDigits:2})}var c=(e,n)=>n?{...e,problem:n}:e;function se(e,n,a){switch(e.t){case"title":{let r=b(e.parts,n);return c({t:"title",text:r.text},r.problem)}case"text":{let r=b(e.parts,n),t=$(e.tone,n);return c({t:"text",text:r.text,...t?{tone:t}:{}},r.problem)}case"badge":{let r=b(e.parts,n);return c({t:"badge",text:r.text,tone:$(e.tone,n)??"neutral"},r.problem)}case"field":{let r=e.label??F(n.definition,e.field);if(!n.node)return{t:"field",field:e.field,label:r,text:h,problem:`"${e.field}" names a field, and these blocks are about no one record`};let t=n.kinds.get(n.node.kind)?.computed?.has(e.field),o,i;if(t){let d=g({t:"ident",name:e.field,at:0},n);d.ok?o=d.value!==null&&typeof d.value=="object"?m(d.value,void 0,n.today):d.value:i=d.problem}else o=Object.hasOwn(n.node,e.field)?n.node[e.field]:void 0;let l=n.fields[e.field]?.type==="url"&&e.as===void 0?te(o):void 0,s=S(()=>oe(e.field,o,n,e.as,e.currency))??h;return c({t:"field",field:e.field,label:r,text:s,...l?{href:l}:{}},i)}case"progress":{let r=g(e.value,n),t=g(e.max,n),o=e.label?b(e.label,n):{text:"Progress"},i=o.text,l=r.ok?t.ok?o.problem:t.problem:r.problem;return r.ok&&t.ok&&typeof r.value=="number"&&typeof t.value=="number"&&Number.isFinite(r.value)&&Number.isFinite(t.value)&&t.value>0?c({t:"progress",label:i,value:r.value,max:t.value,text:`${m(r.value,void 0,n.today)} of ${m(t.value,void 0,n.today)}`},l):c({t:"progress",label:i,text:h},l)}case"group":return{t:"group",direction:e.direction,blocks:H(e.blocks,n)};case"when":{let r=g(e.when,n),t=r.ok&&r.value===!0;return c({t:"when",shown:t,blocks:t?H(e.show,n):[]},r.ok?void 0:r.problem)}case"divider":return{t:"divider"};case"figure":return{t:"figure"};case"headline":{let r=b(e.parts,n),t=Math.min(6,Math.max(1,(a?n.firstHeading:void 0)??n.heading??3));return c({t:"headline",level:t,text:r.text},r.problem)}case"number":{let r=g(e.value,n),t=!r.ok||r.value===null||typeof r.value=="object"?h:ae(r.value,e.as,e.currency,n.today,n.money),o=e.label?b(e.label,n):void 0;return c({t:"number",text:t,...o?{label:o.text}:{}},r.ok?o?.problem:r.problem)}case"list":return de(e,n)}}function H(e,n){let a=e.findIndex(r=>r.t==="headline");return e.map((r,t)=>({...se(r,n,t===a),key:r.key}))}var ie=new Set(["every","some","sum","min","max","sort"]);function je(e,n){let a=new Set,r=new Set,t=s=>{if(s)switch(s.t){case"ident":a.add(s.name);return;case"list":s.items.forEach(t);return;case"member":return t(s.object);case"unary":return t(s.operand);case"binary":return t(s.left),t(s.right);case"where":return t(s.set);case"call":s.args.forEach((d,y)=>{y===1&&ie.has(s.fn)||t(d)});return;default:return}},o=s=>{for(let d of s??[])t(d.expr)},i=(s,d)=>{s.forEach((y,f)=>{let u=d[f];if(u)switch(y.t){case"field":a.add(y.field);return;case"title":case"text":case"badge":case"headline":o(y.parts);return;case"number":t(y.value),o(y.label);return;case"progress":t(y.value),t(y.max);return;case"group":u.t==="group"&&i(y.blocks,u.blocks);return;case"when":u.t==="when"&&u.shown&&i(y.show,u.blocks);return;case"list":if(u.t==="list")for(let x of u.members)r.add(x.id);return;default:return}})};i(e,n);let l=n[0];return{fields:a,records:r,...e[0]?.t==="title"&&l?.t==="title"?{title:l.text}:{}}}function de(e,n){let a=Math.min(6,(n.heading??3)+1),r=g(e.source,n);if(!r.ok)return{t:"list",as:e.as,failed:!0,members:[],headingLevel:a,more:0,problem:r.problem};let t=r.value,o=t instanceof A?t.nodes:t!==null&&typeof t=="object"&&!Array.isArray(t)?[t]:[];e.choiceOrder&&n.schema&&(o=le(o,e.choiceOrder,n.schema));let i=o.length;o=o.slice(0,e.limit??E);let l=e.limit===void 0?i-o.length:0;return{t:"list",as:e.as,failed:!1,members:o,...e.group&&n.schema&&o.length>0?{groups:ue(o,e.group,n.schema)}:{},headingLevel:a,...o.length===0&&e.empty?{empty:e.empty}:{},more:l}}function J(e,n,a){let r=e.tryDefinition(n)?.fields?.shape,t=r&&Object.hasOwn(r,a)?T(r[a]):void 0;return t?.type==="enum"?t.options??[]:[]}var P=(e,n)=>Object.hasOwn(e,n)?e[n]:void 0;function le(e,n,a){let r=t=>{let o=J(a,t.kind,n).indexOf(String(P(t,n)));return o<0?Number.MAX_SAFE_INTEGER:o};return e.map((t,o)=>({node:t,i:o,rank:r(t)})).sort((t,o)=>t.rank-o.rank||t.i-o.i).map(t=>t.node)}function ue(e,n,a){let r=[];for(let i of e)for(let l of J(a,i.kind,n.by))r.includes(l)||r.push(l);let t=[];for(let i of r){let l=e.filter(d=>P(d,n.by)===i);if(l.length===0)continue;let s=a.tryDefinition(l[0].kind);t.push({value:i,heading:n.headings[i]??O(k(s,n.by,i)),members:l})}let o=e.filter(i=>!r.includes(String(P(i,n.by))));return o.length>0&&t.push({value:null,members:o}),t}function K(e){return e.t==="list"||e.t==="headline"||e.t==="number"?!0:e.t==="group"?e.blocks.some(K):e.t==="when"?e.show.some(K):!1}function z(e,n){let a=e.tryDefinition(n)?.fields?.shape??{},r={};for(let[t,o]of Object.entries(a)){let i=T(o);i&&(r[t]=i)}return r}var Y=new WeakMap;function v(e){let n=Y.get(e);return n||Y.set(e,n=U(e)),n}function ye(e,n,a,r={}){let t=v(e),o={},i={},l=s=>{if(s instanceof A)return s.nodes.map(d=>l(d));if(Array.isArray(s))return s.map(d=>l(d));if(s!==null&&typeof s=="object"){let d=s;return{id:d.id,kind:d.kind,label:G(e.tryDefinition(d.kind),d)}}return s};for(let[s,d]of t.get(a?a.kind:N)?.computed??[])try{o[s]=l(R(d,{graph:n,subject:a,kinds:t,...r.today?{today:r.today}:{},...r.budget?{budget:r.budget}:{}}))}catch(y){if(!(y instanceof C))throw y;i[s]=y.sentence}return{values:o,refused:i}}function ve(e,n,a){let{values:r}=ye(e,n,a);if(Object.keys(r).length===0)return a;let t=o=>Array.isArray(o)?o.map(t):o!==null&&typeof o=="object"?o.label:o;return{...a,...Object.fromEntries(Object.entries(r).map(([o,i])=>[o,t(i)]))}}var pe=500,fe=2e4,Z=new WeakMap;function ce(e,n){let a=Z.get(e);a||Z.set(e,a=new Map);let r=a.get(n);return r||a.set(n,r=z(e,n)),r}function Ne(e,n,a,r={}){if(n&&typeof e.seenBy!="function")throw new TypeError("blockContextFor: a seat is read from a store (its `seenBy`); a bare { graph, schema } is read as it is handed, with no principal");let t=n?e.seenBy(n):e,o=n&&a?t.graph.getNode(a.id)??null:a,i=t.schema,l=o&&i.tryDefinition(o.kind),s=!o||(r.slot??"page")==="page",{money:d,firstHeading:y}=r;return{node:o,graph:t.graph,schema:i,kinds:v(i),fields:o?ce(i,o.kind):{},definition:l||void 0,today:r.today??t.today?.()??new Date().toISOString().slice(0,10),money:d,heading:r.heading??(s?2:3),firstHeading:y,budget:r.budget??(s?fe:pe)}}export{W as a,H as b,je as c,K as d,ye as e,ve as f,Ne as g};
1
+ import{e as T,f as I,g as L,h as D,i as E}from"./chunk.A4SJ7EEY.js";import{a as U}from"./chunk.DEZEXD24.js";import{c as w,e as _}from"./chunk.YZZGD5OY.js";import{a as A,b as N,c as C,e as R,l as M,m,n as V}from"./chunk.DSZ3I557.js";import{F as O,J as G,N as k,S as F}from"./chunk.RAE4M3KQ.js";var S=e=>{try{return e()}catch{return null}},X=e=>typeof e=="string"&&I.includes(e);function q(e){if(e!==void 0)return X(e)?e:e&&typeof e=="object"&&typeof e.expr=="string"?{expr:S(()=>w(e.expr))}:"neutral"}var Q=4;function ee(e){let n=typeof e.list=="string"?S(()=>w(e.list)):null,a=e.sort,r=typeof a=="string"?a:a&&typeof a=="object"&&typeof a.by=="string"?a.by:void 0,t=a&&typeof a=="object"?a.direction:void 0,o=n,i;if(n&&r!==void 0)if(t==="choices")i=r;else{let f=S(()=>w(r));o=f?{t:"call",fn:"sort",args:[n,f,{t:"lit",value:t==="desc"?"desc":"asc",at:0}],at:0}:null}let l=typeof e.limit=="number"&&Number.isInteger(e.limit)&&e.limit>=1?Math.min(e.limit,E):void 0,s=e.group,d=typeof s=="string"?s:s&&typeof s=="object"&&typeof s.by=="string"?s.by:void 0,y=s&&typeof s=="object"&&s.headings&&typeof s.headings=="object"?s.headings:{};return{t:"list",source:o,...i?{choiceOrder:i}:{},...l?{limit:l}:{},...d?{group:{by:d,headings:Object.fromEntries(Object.entries(y).filter(f=>typeof f[1]=="string"))}}:{},...typeof e.empty=="string"?{empty:e.empty}:{},as:e.as==="card"?"card":"row"}}function W(e,n=1,a=""){if(!Array.isArray(e)||n>Q)return[];let r={};return e.flatMap(t=>{if(!t||typeof t!="object"||Array.isArray(t))return[];let o=t,i=p=>typeof p=="string"?S(()=>_(p)):null,l=p=>typeof p=="string"?S(()=>w(p)):null,s=q(o.tone),d=typeof o.label=="string"?o.label:void 0,y=p=>Object.hasOwn(o,p),f=typeof o.currency=="string"&&/^[A-Z]{3}$/.test(o.currency)?o.currency:void 0,u=y("list")?"list":y("headline")?"headline":typeof o.figure=="string"?"number":ne.find(y);if(!u)return[];let x=r[u]=(r[u]??0)+1,j=o.key,B=typeof j=="string"&&j?j:`${a}${u}.${x}`;return[{...(()=>{switch(u){case"list":return ee(o);case"number":{let p=D.includes(o.as)?o.as:void 0;return{t:u,value:l(o.figure),...p?{as:p}:{},...f?{currency:f}:{},...d?{label:i(d)}:{}}}case"headline":case"title":return{t:u,parts:i(o[u])};case"text":case"badge":return{t:u,parts:i(o[u]),...s?{tone:s}:{}};case"field":{let p=L.includes(o.as)?o.as:void 0;return{t:u,field:String(o.field),...p?{as:p}:{},...f?{currency:f}:{},...d?{label:d}:{}}}case"progress":{let p=o.progress??{};return{t:u,value:l(p.value),max:l(p.max),...d?{label:i(d)}:{}}}case"group":return{t:u,blocks:W(o.group,n+1,`${B}.`),direction:o.direction==="row"?"row":"column"};case"when":return{t:u,when:l(o.when),show:W(o.show,n+1,`${B}.`)};default:return{t:u}}})(),key:B}]})}var ne=["title","text","badge","field","progress","group","when","divider","figure"],h="\u2014",re=500;function g(e,n){if(!e)return{ok:!1,problem:"an expression that does not parse"};try{return{ok:!0,value:R(e,{graph:n.graph??M,subject:n.node,kinds:n.kinds,today:n.today,budget:n.budget??re})}}catch(a){return{ok:!1,problem:a instanceof Error?a.message:String(a)}}}function b(e,n){if(!e)return{text:h,problem:"a template that does not parse"};let a,r=e.map(t=>{if(t.text!==void 0)return t.text;let o=g(t.expr??null,n);return o.ok?m(o.value,t.format,n.today,t.formatArgs,n.money):(a??=`{${t.source??""}}: ${o.problem}`,h)}).join("");return a?{text:r,problem:a}:{text:r}}function $(e,n){if(e===void 0)return;if(typeof e=="string")return e;let a=g(e.expr,n);return a.ok&&X(a.value)?a.value:"neutral"}function te(e){if(typeof e=="string")try{let n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"?n.href:void 0}catch{return}}function oe(e,n,a,r,t){if(n==null||n==="")return h;if(typeof n=="boolean")return n?"yes":"no";if(r)return m(n,r,a.today,[],t?{...a.money,currency:t}:a.money);let o=a.fields[e];return a.definition?.display?.format?.[e]?k(a.definition,e,n):o?.type==="date"?m(n,"date",a.today):o?.type==="enum"&&typeof n=="string"?k(a.definition,e,n):typeof n=="number"?n.toLocaleString("en-US"):Array.isArray(n)?n.map(i=>String(i)).join(", "):typeof n=="object"?h:String(n)}function ae(e,n,a,r,t){return typeof e!="number"?String(e):n==="money"?V(e,a?{...t,currency:a}:t):n==="percent"?m(e,n,r):e.toLocaleString("en-US",{maximumFractionDigits:2})}var c=(e,n)=>n?{...e,problem:n}:e;function se(e,n,a){switch(e.t){case"title":{let r=b(e.parts,n);return c({t:"title",text:r.text},r.problem)}case"text":{let r=b(e.parts,n),t=$(e.tone,n);return c({t:"text",text:r.text,...t?{tone:t}:{}},r.problem)}case"badge":{let r=b(e.parts,n);return c({t:"badge",text:r.text,tone:$(e.tone,n)??"neutral"},r.problem)}case"field":{let r=e.label??F(n.definition,e.field);if(!n.node)return{t:"field",field:e.field,label:r,text:h,problem:`"${e.field}" names a field, and these blocks are about no one record`};let t=n.kinds.get(n.node.kind)?.computed?.has(e.field),o,i;if(t){let d=g({t:"ident",name:e.field,at:0},n);d.ok?o=d.value!==null&&typeof d.value=="object"?m(d.value,void 0,n.today):d.value:i=d.problem}else o=Object.hasOwn(n.node,e.field)?n.node[e.field]:void 0;let l=n.fields[e.field]?.type==="url"&&e.as===void 0?te(o):void 0,s=S(()=>oe(e.field,o,n,e.as,e.currency))??h;return c({t:"field",field:e.field,label:r,text:s,...l?{href:l}:{}},i)}case"progress":{let r=g(e.value,n),t=g(e.max,n),o=e.label?b(e.label,n):{text:"Progress"},i=o.text,l=r.ok?t.ok?o.problem:t.problem:r.problem;return r.ok&&t.ok&&typeof r.value=="number"&&typeof t.value=="number"&&Number.isFinite(r.value)&&Number.isFinite(t.value)&&t.value>0?c({t:"progress",label:i,value:r.value,max:t.value,text:`${m(r.value,void 0,n.today)} of ${m(t.value,void 0,n.today)}`},l):c({t:"progress",label:i,text:h},l)}case"group":return{t:"group",direction:e.direction,blocks:H(e.blocks,n)};case"when":{let r=g(e.when,n),t=r.ok&&r.value===!0;return c({t:"when",shown:t,blocks:t?H(e.show,n):[]},r.ok?void 0:r.problem)}case"divider":return{t:"divider"};case"figure":return{t:"figure"};case"headline":{let r=b(e.parts,n),t=Math.min(6,Math.max(1,(a?n.firstHeading:void 0)??n.heading??3));return c({t:"headline",level:t,text:r.text},r.problem)}case"number":{let r=g(e.value,n),t=!r.ok||r.value===null||typeof r.value=="object"?h:ae(r.value,e.as,e.currency,n.today,n.money),o=e.label?b(e.label,n):void 0;return c({t:"number",text:t,...o?{label:o.text}:{}},r.ok?o?.problem:r.problem)}case"list":return de(e,n)}}function H(e,n){let a=e.findIndex(r=>r.t==="headline");return e.map((r,t)=>({...se(r,n,t===a),key:r.key}))}var ie=new Set(["every","some","sum","min","max","sort"]);function je(e,n){let a=new Set,r=new Set,t=s=>{if(s)switch(s.t){case"ident":a.add(s.name);return;case"list":s.items.forEach(t);return;case"member":return t(s.object);case"unary":return t(s.operand);case"binary":return t(s.left),t(s.right);case"where":return t(s.set);case"call":s.args.forEach((d,y)=>{y===1&&ie.has(s.fn)||t(d)});return;default:return}},o=s=>{for(let d of s??[])t(d.expr)},i=(s,d)=>{s.forEach((y,f)=>{let u=d[f];if(u)switch(y.t){case"field":a.add(y.field);return;case"title":case"text":case"badge":case"headline":o(y.parts);return;case"number":t(y.value),o(y.label);return;case"progress":t(y.value),t(y.max);return;case"group":u.t==="group"&&i(y.blocks,u.blocks);return;case"when":u.t==="when"&&u.shown&&i(y.show,u.blocks);return;case"list":if(u.t==="list")for(let x of u.members)r.add(x.id);return;default:return}})};i(e,n);let l=n[0];return{fields:a,records:r,...e[0]?.t==="title"&&l?.t==="title"?{title:l.text}:{}}}function de(e,n){let a=Math.min(6,(n.heading??3)+1),r=g(e.source,n);if(!r.ok)return{t:"list",as:e.as,failed:!0,members:[],headingLevel:a,more:0,problem:r.problem};let t=r.value,o=t instanceof A?t.nodes:t!==null&&typeof t=="object"&&!Array.isArray(t)?[t]:[];e.choiceOrder&&n.schema&&(o=le(o,e.choiceOrder,n.schema));let i=o.length;o=o.slice(0,e.limit??E);let l=e.limit===void 0?i-o.length:0;return{t:"list",as:e.as,failed:!1,members:o,...e.group&&n.schema&&o.length>0?{groups:ue(o,e.group,n.schema)}:{},headingLevel:a,...o.length===0&&e.empty?{empty:e.empty}:{},more:l}}function J(e,n,a){let r=e.tryDefinition(n)?.fields?.shape,t=r&&Object.hasOwn(r,a)?T(r[a]):void 0;return t?.type==="enum"?t.options??[]:[]}var P=(e,n)=>Object.hasOwn(e,n)?e[n]:void 0;function le(e,n,a){let r=t=>{let o=J(a,t.kind,n).indexOf(String(P(t,n)));return o<0?Number.MAX_SAFE_INTEGER:o};return e.map((t,o)=>({node:t,i:o,rank:r(t)})).sort((t,o)=>t.rank-o.rank||t.i-o.i).map(t=>t.node)}function ue(e,n,a){let r=[];for(let i of e)for(let l of J(a,i.kind,n.by))r.includes(l)||r.push(l);let t=[];for(let i of r){let l=e.filter(d=>P(d,n.by)===i);if(l.length===0)continue;let s=a.tryDefinition(l[0].kind);t.push({value:i,heading:n.headings[i]??O(k(s,n.by,i)),members:l})}let o=e.filter(i=>!r.includes(String(P(i,n.by))));return o.length>0&&t.push({value:null,members:o}),t}function K(e){return e.t==="list"||e.t==="headline"||e.t==="number"?!0:e.t==="group"?e.blocks.some(K):e.t==="when"?e.show.some(K):!1}function z(e,n){let a=e.tryDefinition(n)?.fields?.shape??{},r={};for(let[t,o]of Object.entries(a)){let i=T(o);i&&(r[t]=i)}return r}var Y=new WeakMap;function v(e){let n=Y.get(e);return n||Y.set(e,n=U(e)),n}function ye(e,n,a,r={}){let t=v(e),o={},i={},l=s=>{if(s instanceof A)return s.nodes.map(d=>l(d));if(Array.isArray(s))return s.map(d=>l(d));if(s!==null&&typeof s=="object"){let d=s;return{id:d.id,kind:d.kind,label:G(e.tryDefinition(d.kind),d)}}return s};for(let[s,d]of t.get(a?a.kind:N)?.computed??[])try{o[s]=l(R(d,{graph:n,subject:a,kinds:t,...r.today?{today:r.today}:{},...r.budget?{budget:r.budget}:{}}))}catch(y){if(!(y instanceof C))throw y;i[s]=y.sentence}return{values:o,refused:i}}function ve(e,n,a){let{values:r}=ye(e,n,a);if(Object.keys(r).length===0)return a;let t=o=>Array.isArray(o)?o.map(t):o!==null&&typeof o=="object"?o.label:o;return{...a,...Object.fromEntries(Object.entries(r).map(([o,i])=>[o,t(i)]))}}var pe=500,fe=2e4,Z=new WeakMap;function ce(e,n){let a=Z.get(e);a||Z.set(e,a=new Map);let r=a.get(n);return r||a.set(n,r=z(e,n)),r}function Ne(e,n,a,r={}){if(n&&typeof e.seenBy!="function")throw new TypeError("blockContextFor: a seat is read from a store (its `seenBy`); a bare { graph, schema } is read as it is handed, with no principal");let t=n?e.seenBy(n):e,o=n&&a?t.graph.getNode(a.id)??null:a,i=t.schema,l=o&&i.tryDefinition(o.kind),s=!o||(r.slot??"page")==="page",{money:d,firstHeading:y}=r;return{node:o,graph:t.graph,schema:i,kinds:v(i),fields:o?ce(i,o.kind):{},definition:l||void 0,today:r.today??t.today?.()??new Date().toISOString().slice(0,10),money:d,heading:r.heading??(s?2:3),firstHeading:y,budget:r.budget??(s?fe:pe)}}export{W as a,H as b,je as c,K as d,ye as e,ve as f,Ne as g};
@@ -1 +1 @@
1
- import{b as m}from"./chunk.VRXWNUDR.js";import{j as f}from"./chunk.ACZGK7LQ.js";import{Aa as T,ca as c,ea as b,ua as L,xa as R}from"./chunk.4JSMCNF7.js";import{L as A,W as I,X as k,sa as x}from"./chunk.Y235YZSZ.js";import{a as W,b as C}from"./chunk.MRK6QJV5.js";import{b as w}from"./chunk.AJZBJBMO.js";var u=w(W(),1);var e=w(C(),1);function z(i=4){let{store:n}=c(),p=b();return(0,u.useMemo)(()=>[...n.batches()].reverse().slice(0,i).map(a=>({intent:a.intent,author:a.author.kind,...a.author.id?{authorId:a.author.id}:{},by:a.author,...a.ops[0]?.via?{via:a.ops[0].via}:{},touched:[...new Set(a.ops.filter(o=>!x(o)).flatMap(o=>o.writes))],batch:a.id,...a.ops.every(x)?{withheld:!0}:{}})),[n,p,i])}function H({batch:i}){let{store:n,principal:p,noteSeat:a}=c(),o=b(),[h,y]=(0,u.useState)(null),l=(0,u.useMemo)(()=>n.canUndo(i),[n,i,o]);if(!l.ok&&l.ops.length===0)return null;let s=!l.ok,g=s?l.includeBatches:[];return(0,e.jsxs)("span",{style:{marginLeft:"auto",flex:"0 0 auto",display:"grid",justifyItems:"end",gap:2},children:[(0,e.jsx)("button",{type:"button","data-testid":"undo-turn",title:s?`${l.message} \u2014 undo those too`:"Take this back, keeping everything since",onClick:()=>{y(null);try{let d=n.log.all().find(t=>t.batch===i&&t.author.kind==="agent");n.undo(s?[i,...g]:i,{author:p}),d&&a({type:"home",author:d.author})}catch(d){y(d instanceof Error?d.message:String(d))}},style:{display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,padding:"1px 8px",fontSize:"0.75rem",...s?{borderColor:"var(--graview-warn)",color:"var(--graview-warn)"}:{}},children:s?`undo +${g.length}`:"undo"}),h?(0,e.jsx)("span",{"data-testid":"undo-refused",role:"alert",style:{fontSize:"0.75rem",lineHeight:1.4,color:"var(--graview-warn)",maxWidth:260,textAlign:"right"},children:h}):null]})}function O(){let i=()=>{let n=new URL(window.location.href);return n.searchParams.set("fresh","1"),n.toString()};return(0,e.jsx)("a",{href:"#fresh","data-testid":"start-fresh",title:"Forget every edit made in this browser and return to the example",onClick:n=>{n.preventDefault(),window.location.assign(i())},style:{display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,fontSize:"0.8125rem",color:"var(--graview-ink-muted)",textDecoration:"underline",textDecorationColor:"var(--graview-edge-bright)",textUnderlineOffset:3},children:"Start fresh"})}function N({calls:i,seat:n,remembers:p=!1}){let a=z(),{store:o,principal:h,seats:y,people:l}=c(),s=i.some(t=>t.phase==="running"),g=R("activity"),d=g.open;return n===void 0&&i.length===0&&a.length===0&&!p?null:(0,e.jsxs)("div",{style:{position:"relative"},children:[(0,e.jsxs)("button",{type:"button","data-testid":"activity-button",...g.trigger,onClick:g.toggle,title:s?"An agent is working":"What has happened",style:{display:"inline-flex",alignItems:"center",gap:6,minHeight:30,padding:"0 8px",borderRadius:8,border:"1px solid transparent",background:"transparent",boxShadow:"none",fontSize:"0.875rem",whiteSpace:"nowrap",color:s?"var(--graview-accent)":"var(--graview-ink-muted)"},children:[s?(0,e.jsx)("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:999,background:"var(--graview-accent)"}}):null,a.length>0?a.length:"",(0,e.jsxs)("svg",{className:"graview-activity-mark",width:"15",height:"15",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",style:{display:"var(--graview-activity-mark, none)"},children:[(0,e.jsx)("circle",{cx:"8",cy:"8",r:"5.75",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),(0,e.jsx)("path",{d:"M8 4.75 V8 L10.25 9.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),(0,e.jsx)("span",{className:"graview-activity-word",children:" Activity"})]}),!d&&n!==void 0?(0,e.jsx)("div",{hidden:!0,"data-testid":"agent-seat-seated",children:n}):null,d?(0,e.jsxs)("section",{...g.pane,"aria-label":"Activity","data-testid":"activity","data-graview-offstage":"",style:{...L,width:300,maxHeight:"min(52cqh, 460px)",overflow:"auto",display:"flex",flexDirection:"column",gap:9,padding:12,borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)"},children:[(0,e.jsx)("h2",{style:{...T,margin:0},children:"Activity"}),n!==void 0?(0,e.jsxs)("div",{"data-testid":"agent-seat-row",style:{display:"grid",gap:5,paddingBottom:i.length>0||a.length>0?9:0,...i.length>0||a.length>0?{borderBottom:"1px solid var(--graview-edge)"}:{}},children:[(0,e.jsx)("span",{style:{fontSize:"0.75rem",letterSpacing:"0.14em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},children:"The agent's seat"}),n]}):null,i.length>0?(0,e.jsx)("ol",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:7},children:i.slice(0,6).map((t,v)=>(0,e.jsxs)("li",{style:{display:"grid",gap:2,fontSize:"0.8125rem",lineHeight:1.45},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[(0,e.jsx)("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:999,flex:"0 0 auto",background:t.phase==="running"?"var(--graview-accent)":t.phase==="failed"?"var(--graview-warn)":"var(--graview-edge-bright)"}}),(0,e.jsxs)("span",{style:{color:"var(--graview-ink)"},children:[t.mutating?"changed":"read"," \xB7"," ",o.allMutations().find(r=>r.name===t.name)?.title??A(t.name)]})]}),!t.mutating&&t.reads&&t.reads.length>0?(0,e.jsxs)("div",{"data-testid":"activity-reads",style:{display:"flex",flexWrap:"wrap",gap:4,paddingLeft:12},children:[[...new Set(t.reads)].slice(0,3).map(r=>(0,e.jsx)(f,{label:m(o,r),pickId:r},r)),new Set(t.reads).size>3?(0,e.jsxs)("span",{style:{color:"var(--graview-ink-muted)"},children:["+",new Set(t.reads).size-3]}):null]}):Object.values(t.args).some(r=>typeof r=="string")?(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4,paddingLeft:12},children:Object.entries(t.args).filter(r=>typeof r[1]=="string").slice(0,3).map(([r,S])=>(0,e.jsx)(f,{label:m(o,S),pickId:S},r))}):null,t.error?(0,e.jsx)("div",{style:{paddingLeft:12,color:"var(--graview-warn)"},children:t.error}):null]},`${t.at}:${v}`))}):null,a.length>0?(0,e.jsx)("ol",{"data-testid":"diff-log",style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6,fontSize:"0.8125rem"},children:a.map((t,v)=>t.withheld?(0,e.jsx)("li",{"data-testid":"withheld-change",style:{display:"grid",gap:3,lineHeight:1.45},children:(0,e.jsx)("span",{"data-touched":"",style:{color:"var(--graview-ink-muted)",fontStyle:"italic"},children:t.intent})},`change:${v}`):(0,e.jsxs)("li",{style:{display:"grid",gap:3,lineHeight:1.45},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[(0,e.jsxs)("span",{style:{minWidth:0},children:[(0,e.jsxs)("strong",{style:{fontWeight:600},children:[t.author==="human"&&t.by?.onBehalfOf===void 0&&(t.authorId===void 0||h.id===void 0||t.authorId===h.id)?"you":I(t.by??{kind:t.author,id:t.authorId},{graph:o.graph,schema:o.schema,seats:y,people:l}),k(t.via)?(0,e.jsxs)("span",{style:{fontWeight:400,color:"var(--graview-ink-muted)"},children:[", ",k(t.via)]}):null]})," ",(0,e.jsx)("span",{style:{color:"var(--graview-ink-muted)"},children:t.intent})]}),t.batch?(0,e.jsx)(H,{batch:t.batch}):null]}),(0,e.jsx)("div",{"data-touched":t.touched.join(" "),style:{display:"flex",flexWrap:"wrap",gap:4},children:t.touched.slice(0,4).map(r=>(0,e.jsx)(f,{label:m(o,r),pickId:r},r))})]},`change:${v}`))}):null,p?(0,e.jsxs)("div",{"data-testid":"remembered",style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:10,paddingTop:8,borderTop:"1px solid var(--graview-edge)",fontSize:"0.8125rem",color:"var(--graview-ink-faint)"},children:[(0,e.jsx)("span",{children:"Remembered in this browser"}),(0,e.jsx)(O,{})]}):null]}):null]})}export{N as a};
1
+ import{b as m}from"./chunk.F2KDFGHR.js";import{j as f}from"./chunk.ZRVDIVYY.js";import{Ba as T,ca as c,ea as b,ua as L,xa as R}from"./chunk.2WFEFZAW.js";import{M as A,X as I,Y as k,ka as x}from"./chunk.RAE4M3KQ.js";import{a as W,b as C}from"./chunk.MRK6QJV5.js";import{b as w}from"./chunk.AJZBJBMO.js";var u=w(W(),1);var e=w(C(),1);function z(i=4){let{store:n}=c(),p=b();return(0,u.useMemo)(()=>[...n.batches()].reverse().slice(0,i).map(a=>({intent:a.intent,author:a.author.kind,...a.author.id?{authorId:a.author.id}:{},by:a.author,...a.ops[0]?.via?{via:a.ops[0].via}:{},touched:[...new Set(a.ops.filter(o=>!x(o)).flatMap(o=>o.writes))],batch:a.id,...a.ops.every(x)?{withheld:!0}:{}})),[n,p,i])}function H({batch:i}){let{store:n,principal:p,noteSeat:a}=c(),o=b(),[h,y]=(0,u.useState)(null),l=(0,u.useMemo)(()=>n.canUndo(i),[n,i,o]);if(!l.ok&&l.ops.length===0)return null;let s=!l.ok,g=s?l.includeBatches:[];return(0,e.jsxs)("span",{style:{marginLeft:"auto",flex:"0 0 auto",display:"grid",justifyItems:"end",gap:2},children:[(0,e.jsx)("button",{type:"button","data-testid":"undo-turn",title:s?`${l.message} \u2014 undo those too`:"Take this back, keeping everything since",onClick:()=>{y(null);try{let d=n.log.all().find(t=>t.batch===i&&t.author.kind==="agent");n.undo(s?[i,...g]:i,{author:p}),d&&a({type:"home",author:d.author})}catch(d){y(d instanceof Error?d.message:String(d))}},style:{display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,padding:"1px 8px",fontSize:"0.75rem",...s?{borderColor:"var(--graview-warn)",color:"var(--graview-warn)"}:{}},children:s?`undo +${g.length}`:"undo"}),h?(0,e.jsx)("span",{"data-testid":"undo-refused",role:"alert",style:{fontSize:"0.75rem",lineHeight:1.4,color:"var(--graview-warn)",maxWidth:260,textAlign:"right"},children:h}):null]})}function O(){let i=()=>{let n=new URL(window.location.href);return n.searchParams.set("fresh","1"),n.toString()};return(0,e.jsx)("a",{href:"#fresh","data-testid":"start-fresh",title:"Forget every edit made in this browser and return to the example",onClick:n=>{n.preventDefault(),window.location.assign(i())},style:{display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,fontSize:"0.8125rem",color:"var(--graview-ink-muted)",textDecoration:"underline",textDecorationColor:"var(--graview-edge-bright)",textUnderlineOffset:3},children:"Start fresh"})}function N({calls:i,seat:n,remembers:p=!1}){let a=z(),{store:o,principal:h,seats:y,people:l}=c(),s=i.some(t=>t.phase==="running"),g=R("activity"),d=g.open;return n===void 0&&i.length===0&&a.length===0&&!p?null:(0,e.jsxs)("div",{style:{position:"relative"},children:[(0,e.jsxs)("button",{type:"button","data-testid":"activity-button",...g.trigger,onClick:g.toggle,title:s?"An agent is working":"What has happened",style:{display:"inline-flex",alignItems:"center",gap:6,minHeight:30,padding:"0 8px",borderRadius:8,border:"1px solid transparent",background:"transparent",boxShadow:"none",fontSize:"0.875rem",whiteSpace:"nowrap",color:s?"var(--graview-accent)":"var(--graview-ink-muted)"},children:[s?(0,e.jsx)("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:999,background:"var(--graview-accent)"}}):null,a.length>0?a.length:"",(0,e.jsxs)("svg",{className:"graview-activity-mark",width:"15",height:"15",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",style:{display:"var(--graview-activity-mark, none)"},children:[(0,e.jsx)("circle",{cx:"8",cy:"8",r:"5.75",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),(0,e.jsx)("path",{d:"M8 4.75 V8 L10.25 9.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),(0,e.jsx)("span",{className:"graview-activity-word",children:" Activity"})]}),!d&&n!==void 0?(0,e.jsx)("div",{hidden:!0,"data-testid":"agent-seat-seated",children:n}):null,d?(0,e.jsxs)("section",{...g.pane,"aria-label":"Activity","data-testid":"activity","data-graview-offstage":"",style:{...L,width:300,maxHeight:"min(52cqh, 460px)",overflow:"auto",display:"flex",flexDirection:"column",gap:9,padding:12,borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)"},children:[(0,e.jsx)("h2",{style:{...T,margin:0},children:"Activity"}),n!==void 0?(0,e.jsxs)("div",{"data-testid":"agent-seat-row",style:{display:"grid",gap:5,paddingBottom:i.length>0||a.length>0?9:0,...i.length>0||a.length>0?{borderBottom:"1px solid var(--graview-edge)"}:{}},children:[(0,e.jsx)("span",{style:{fontSize:"0.75rem",letterSpacing:"0.14em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},children:"The agent's seat"}),n]}):null,i.length>0?(0,e.jsx)("ol",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:7},children:i.slice(0,6).map((t,v)=>(0,e.jsxs)("li",{style:{display:"grid",gap:2,fontSize:"0.8125rem",lineHeight:1.45},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[(0,e.jsx)("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:999,flex:"0 0 auto",background:t.phase==="running"?"var(--graview-accent)":t.phase==="failed"?"var(--graview-warn)":"var(--graview-edge-bright)"}}),(0,e.jsxs)("span",{style:{color:"var(--graview-ink)"},children:[t.mutating?"changed":"read"," \xB7"," ",o.allMutations().find(r=>r.name===t.name)?.title??A(t.name)]})]}),!t.mutating&&t.reads&&t.reads.length>0?(0,e.jsxs)("div",{"data-testid":"activity-reads",style:{display:"flex",flexWrap:"wrap",gap:4,paddingLeft:12},children:[[...new Set(t.reads)].slice(0,3).map(r=>(0,e.jsx)(f,{label:m(o,r),pickId:r},r)),new Set(t.reads).size>3?(0,e.jsxs)("span",{style:{color:"var(--graview-ink-muted)"},children:["+",new Set(t.reads).size-3]}):null]}):Object.values(t.args).some(r=>typeof r=="string")?(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4,paddingLeft:12},children:Object.entries(t.args).filter(r=>typeof r[1]=="string").slice(0,3).map(([r,S])=>(0,e.jsx)(f,{label:m(o,S),pickId:S},r))}):null,t.error?(0,e.jsx)("div",{style:{paddingLeft:12,color:"var(--graview-warn)"},children:t.error}):null]},`${t.at}:${v}`))}):null,a.length>0?(0,e.jsx)("ol",{"data-testid":"diff-log",style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6,fontSize:"0.8125rem"},children:a.map((t,v)=>t.withheld?(0,e.jsx)("li",{"data-testid":"withheld-change",style:{display:"grid",gap:3,lineHeight:1.45},children:(0,e.jsx)("span",{"data-touched":"",style:{color:"var(--graview-ink-muted)",fontStyle:"italic"},children:t.intent})},`change:${v}`):(0,e.jsxs)("li",{style:{display:"grid",gap:3,lineHeight:1.45},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[(0,e.jsxs)("span",{style:{minWidth:0},children:[(0,e.jsxs)("strong",{style:{fontWeight:600},children:[t.author==="human"&&t.by?.onBehalfOf===void 0&&(t.authorId===void 0||h.id===void 0||t.authorId===h.id)?"you":I(t.by??{kind:t.author,id:t.authorId},{graph:o.graph,schema:o.schema,seats:y,people:l}),k(t.via)?(0,e.jsxs)("span",{style:{fontWeight:400,color:"var(--graview-ink-muted)"},children:[", ",k(t.via)]}):null]})," ",(0,e.jsx)("span",{style:{color:"var(--graview-ink-muted)"},children:t.intent})]}),t.batch?(0,e.jsx)(H,{batch:t.batch}):null]}),(0,e.jsx)("div",{"data-touched":t.touched.join(" "),style:{display:"flex",flexWrap:"wrap",gap:4},children:t.touched.slice(0,4).map(r=>(0,e.jsx)(f,{label:m(o,r),pickId:r},r))})]},`change:${v}`))}):null,p?(0,e.jsxs)("div",{"data-testid":"remembered",style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:10,paddingTop:8,borderTop:"1px solid var(--graview-edge)",fontSize:"0.8125rem",color:"var(--graview-ink-faint)"},children:[(0,e.jsx)("span",{children:"Remembered in this browser"}),(0,e.jsx)(O,{})]}):null]}):null]})}export{N as a};
@@ -0,0 +1 @@
1
+ import{a as U}from"./chunk.T6KID3WO.js";import{a as T,c as K,f as W,g as D,k as _,l as j,m as X}from"./chunk.6DU4XN2F.js";import{c as J}from"./chunk.MJ67MK4R.js";import{e as Q,g as Y,i as Z}from"./chunk.US4KIJSW.js";import{Aa as z,ca as G,ea as I,ma as V,ta as q}from"./chunk.2WFEFZAW.js";import{Hb as N,gb as H,qb as M,rb as O}from"./chunk.RAE4M3KQ.js";import{a as ae,b as $}from"./chunk.MRK6QJV5.js";import{b as F}from"./chunk.AJZBJBMO.js";var o=F(ae(),1);function se(e){let t=[e?.typography?.body,e?.typography?.display,e?.typography?.mono],n=[];for(let a of t){let r=a?.split(",")[0]?.trim().replace(/^["']|["']$/g,"");!r||O(r)||r.toLowerCase()!==H.toLowerCase()&&(n.includes(r)||n.push(r))}return n}function ee(e){let t=se(e);return t.length===0?null:`https://fonts.googleapis.com/css2?${t.map(a=>`family=${encodeURIComponent(a).replace(/%20/g,"+")}:wght@400;500;600;700`).join("&")}&display=swap`}var u=F($(),1);function ge(e,t){let{app:n}=e;return(0,o.useMemo)(()=>{let a=Y(t(n.schema,n.viewSpecs),n),r=e.views?V(a,e.views(n.schema,a)):a;return Z(r,n.schema,Q(e.brand??n.brand,n.schema)),r},[e.views,n.schema,n.viewSpecs,n.lenses,n.pages,n.home])}function ie(e,t){return new N({schema:e.schema,mutations:e.mutations??[],invariants:e.invariants??[],...t?{snapshot:t}:{},...e.policy?{policy:e.policy}:{},...e.intelligence?{intelligence:e.intelligence}:{}})}function ne(e){if(typeof document>"u")return e==="dark"?"dark":"light";let t=document.documentElement.dataset.theme;return t==="dark"||t==="light"?t:e==="dark"||e==="light"?e:typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function ce(e,t){let[n,a]=(0,o.useState)(()=>ne(t));return(0,o.useEffect)(()=>{if(!e||typeof document>"u")return;let r=()=>a(ne(t));r();let i=new MutationObserver(r);i.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});let d=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null;return d?.addEventListener?.("change",r),()=>{i.disconnect(),d?.removeEventListener?.("change",r)}},[e,t]),n}var A=e=>e?e.getBoundingClientRect().height:0;function be(e,t,n){let a=(0,o.useRef)(n);a.current=n;let r=n!==void 0;(0,o.useLayoutEffect)(()=>{let i=e.current;if(!i||!r)return;let d=()=>{let l=[...i.children],b=l.find(v=>v.hasAttribute("data-graview-app-bar")),p=l.find(v=>v.hasAttribute("data-embed-content")),f=p?.querySelector("[data-embed-measure]")??null,c=l.find(v=>v.hasAttribute("data-graview-place-line"));return{strip:b,line:c,content:p,measure:f}},s=-1,h=()=>{let{strip:l,line:b,content:p,measure:f}=d(),c=Math.ceil(A(l)+A(b)+A(f||p));c!==s&&(s=c,a.current?.(c))};if(h(),typeof ResizeObserver>"u")return;let m=new ResizeObserver(h),E=()=>{m.disconnect();let{strip:l,line:b,content:p,measure:f}=d();for(let c of[i,l,b,p,f])c&&m.observe(c)};E();let g=new MutationObserver(()=>{E(),h()});return g.observe(i,{childList:!0}),()=>{m.disconnect(),g.disconnect()}},[e,t,r])}var ve=480,de=0;function Se(e){let{app:t,seed:n,scheme:a="auto",brand:r=t.brand,fonts:i=!0,height:d="100%",label:s}=e,h=(0,o.useRef)(null);q(h);let m=d==="viewport"?"100dvh":d,E=z(typeof m=="string"&&/vh\b/.test(m)),g=(0,o.useMemo)(()=>`graview-embed-${++de}`,[]),l=(0,o.useMemo)(()=>e.store??e.remote?.store??ie(t,n),[e.store,e.remote,t,n]),b=e.presence??e.remote?.presence,p=e.hostContext?.theme,f=ce(a==="auto"&&p===void 0,r?.scheme),c=a==="auto"?p??f:a,v=(0,o.useMemo)(()=>T(c,r,{scope:`.${g}`}),[c,r,g]);K(e.favicon?M(r):void 0),(0,o.useEffect)(()=>{if(!i||typeof document>"u")return;let w=ee(r);if(!w||document.querySelector(`link[href="${w}"]`))return;let y=document.createElement("link");y.rel="stylesheet",y.href=w,document.head.appendChild(y)},[r,i]);let C=(0,o.useRef)(void 0);(0,o.useLayoutEffect)(()=>{let w=h.current,y=C.current;if(C.current=s,!w||!s)return;let oe=S=>{let x=S.getAttribute("aria-label")??"",R=y&&y!==s?x.startsWith(`${y} \xB7 `)?x.slice(y.length+3):x===y?"":x:x;R===s&&(S.getAttribute("role")==="region"||S.tagName==="SECTION"&&!S.hasAttribute("role"))&&S.setAttribute("role","group");let L=R.startsWith(`${s} \xB7 `)||R===s?R:R?`${s} \xB7 ${R}`:s;L!==x&&S.setAttribute("aria-label",L)},B=()=>w.querySelectorAll("aside, nav, main, header, footer, section[aria-label]:not([role]), [role=region], [role=complementary], [role=navigation], [role=search]").forEach(S=>{S.hasAttribute("data-graview-named-by-lens")||oe(S)});B();let P=new MutationObserver(B);return P.observe(w,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-label"]}),()=>P.disconnect()},[s]);let re=E?`${m}`.replace(/([\d.]+)[sdl]?vh\b/g,(w,y)=>`${+y*E/100}px`):m;return{rootRef:h,scope:g,css:v,scheme:c,store:l,presence:b,brand:r,auto:d==="auto",height:re}}function we({rootRef:e,board:t}){let n=(0,o.useCallback)(()=>e.current?.querySelector("[data-embed-content]")??e.current,[e]);return(0,u.jsx)(J,{board:t,anchor:n})}function Ee(e,t,n){return{brand:n,principal:e.principal,seats:e.seats,presence:t,people:e.people,memory:e.memory,presenceTtlMs:e.presenceTtlMs,onKeepLens:e.onKeepLens,ai:e.ai,app:e.app}}function xe({name:e,heading:t,faces:n,at:a,without:r,home:i,reach:d,standing:s,hostActions:h,keeping:m,onFind:E,switch:g}){let{brand:l,store:b,principal:p,views:f}=G();I();let c=r?.has("places")?[]:W({store:b,principal:p,views:f}),v=U();return(0,u.jsx)(_,{brand:l,name:e,description:l?.subtitle,heading:t,faces:n,home:i,places:c,current:a===null?null:D(c,a),reach:d,onFind:E,...g?{switch:g}:{},...n?{scenePlaces:v}:{},tools:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(X,{clean:s}),(0,u.jsx)(j,{...h?{hostActions:h}:{},...m?{keeping:m}:{}})]})})}var Re=e=>e===!1?2:Math.min(e+1,6);function Ae(e){let[t,n]=(0,o.useState)(e),a=(0,o.useRef)(void 0),r=(0,o.useRef)(void 0),i=(0,o.useMemo)(()=>({go:a,at:n,pending:r}),[]),d=(0,o.useCallback)(s=>{if(a.current){a.current(s);return}r.current=s,n(s)},[]);return{at:t,setAt:n,steering:i,steer:d}}function le(e){let t=typeof e=="object"&&e!==null?e.name:void 0;return{name:typeof t=="string"&&t.length>0?t:typeof e=="object"?"Error":typeof e}}var k=()=>typeof performance<"u"?performance.now():Date.now();function Fe(e,t){let n=(0,o.useRef)({onError:e,face:t});return n.current={onError:e,face:t},(0,o.useCallback)((a,r)=>n.current.onError?.(le(a),{module:r.module,face:n.current.face}),[])}function ke(e,t){let n=(0,o.useRef)(null);n.current===null&&(n.current=k());let a=(0,o.useRef)({onReady:e,face:t});a.current={onReady:e,face:t};let r=(0,o.useRef)(!1);return(0,o.useCallback)(i=>{r.current||(r.current=!0,a.current.onReady?.({ms:Math.max(0,k()-(n.current??k())),face:i}))},[])}var te=class extends o.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t,n){console.error(`[graview] ${this.props.module} threw while rendering`,t,n.componentStack),this.props.report(t,{module:this.props.module})}render(){return this.state.failed?(0,u.jsxs)("div",{role:"alert","data-graview-face-error":this.props.module,...this.props.content?{"data-embed-content":""}:{},style:this.props.content?{flex:"1 1 auto",display:"grid",alignContent:"center",justifyItems:"center",gap:8,padding:24,background:"var(--graview-ground)",color:"var(--graview-ink)",fontSize:"0.9375rem"}:{display:"inline-flex",alignItems:"center",gap:6,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:[(0,u.jsx)("span",{children:this.props.content?"This part of the app could not draw.":"Could not draw."}),(0,u.jsx)("button",{type:"button",onClick:()=>this.setState({failed:!1}),style:{padding:"3px 11px",fontSize:"0.8125rem"},children:"Try again"})]}):this.props.children}};export{ge as a,ie as b,be as c,ve as d,Se as e,we as f,Ee as g,xe as h,Re as i,Ae as j,Fe as k,ke as l,te as m};