graview 0.1.50 → 0.1.51

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 (191) hide show
  1. package/dist/preview/{chunk.V5IWJ3ZV.js → chunk.2534FLZZ.js} +1 -1
  2. package/dist/preview/{chunk.QSZLY62B.js → chunk.2VJ52LGS.js} +1 -1
  3. package/dist/preview/{chunk.U2M4SGUU.js → chunk.2W2YVB6X.js} +1 -1
  4. package/dist/preview/{chunk.ECSWXLBI.js → chunk.2W45NM7Q.js} +2 -2
  5. package/dist/preview/chunk.32BOL7OL.js +1 -0
  6. package/dist/preview/chunk.34HGT7HQ.js +1 -0
  7. package/dist/preview/{chunk.YUV7HZYG.js → chunk.353CGK6C.js} +1 -1
  8. package/dist/preview/{chunk.64TFAR5Z.js → chunk.3H7YIKKC.js} +1 -1
  9. package/dist/preview/{chunk.Q7RI4SI4.js → chunk.3MU37W5D.js} +1 -1
  10. package/dist/preview/chunk.3SBTQ66X.js +1 -0
  11. package/dist/preview/{chunk.L5MDUZLQ.js → chunk.3TVAE7LE.js} +1 -1
  12. package/dist/preview/{chunk.ETX4QMM2.js → chunk.4EZFOZBA.js} +1 -1
  13. package/dist/preview/chunk.4N5R4K6O.js +1 -0
  14. package/dist/preview/{chunk.KGGWFL54.js → chunk.4T67XS2D.js} +1 -1
  15. package/dist/preview/chunk.5ON3JSAK.js +1 -0
  16. package/dist/preview/{chunk.YEKHDZ45.js → chunk.5ZAK57JA.js} +2 -2
  17. package/dist/preview/chunk.6KYWJXZR.js +1 -0
  18. package/dist/preview/{chunk.BJAQRV2R.js → chunk.76QSPWSJ.js} +1 -1
  19. package/dist/preview/{chunk.3SY6WWWQ.js → chunk.7G4M2PX3.js} +2 -2
  20. package/dist/preview/{chunk.XWLGHTH6.js → chunk.7GAC7U34.js} +1 -1
  21. package/dist/preview/{chunk.GDYI5QDS.js → chunk.7NQROWHU.js} +1 -1
  22. package/dist/preview/{chunk.LGHMUUTG.js → chunk.7RIFDWDF.js} +1 -1
  23. package/dist/preview/{chunk.MQISKON2.js → chunk.ACB4TD4W.js} +1 -1
  24. package/dist/preview/chunk.AJAMTRZ3.js +1 -0
  25. package/dist/preview/chunk.AL45OI4A.js +1 -0
  26. package/dist/preview/{chunk.WGRF6EHC.js → chunk.AL7LFNOS.js} +1 -1
  27. package/dist/preview/{chunk.ZBBCUK2K.js → chunk.ALCH5H7U.js} +1 -1
  28. package/dist/preview/{chunk.UOC3SIYT.js → chunk.APFRPN5S.js} +1 -1
  29. package/dist/preview/{chunk.ODHCSYXX.js → chunk.AZOW57MT.js} +1 -1
  30. package/dist/preview/chunk.B4PUI3GO.js +1 -0
  31. package/dist/preview/chunk.B6LKLV32.js +1 -0
  32. package/dist/preview/{chunk.UDTBFAS5.js → chunk.B7LBG4UP.js} +1 -1
  33. package/dist/preview/{chunk.YCJ74LZS.js → chunk.BV6HKTHK.js} +1 -1
  34. package/dist/preview/{chunk.UN2OB6OD.js → chunk.BYY7YXBI.js} +1 -1
  35. package/dist/preview/{chunk.7QW6JYGP.js → chunk.CI4DEKPX.js} +1 -1
  36. package/dist/preview/{chunk.ZOQ3OKKI.js → chunk.CMEETACI.js} +1 -1
  37. package/dist/preview/{chunk.O6SKKF4V.js → chunk.CQPNDJAC.js} +1 -1
  38. package/dist/preview/{chunk.FFPG4PHX.js → chunk.CTOBNZLM.js} +1 -1
  39. package/dist/preview/chunk.CUB4IAUJ.js +1 -0
  40. package/dist/preview/chunk.CUN4VN42.js +1 -0
  41. package/dist/preview/chunk.CV55N3Y6.js +1 -0
  42. package/dist/preview/{chunk.M55U47A6.js → chunk.CXC5FOIO.js} +1 -1
  43. package/dist/preview/{chunk.DUJUJN35.js → chunk.DEH6O3K4.js} +1 -1
  44. package/dist/preview/chunk.DQNN5FE5.js +1 -0
  45. package/dist/preview/{chunk.4SHSEIHT.js → chunk.DUY27OJV.js} +1 -1
  46. package/dist/preview/chunk.E2R6VFZX.js +1 -0
  47. package/dist/preview/{chunk.KZ3UPV2L.js → chunk.EA2NMVRE.js} +1 -1
  48. package/dist/preview/chunk.ESK3UZRC.js +1 -0
  49. package/dist/preview/{chunk.IMFAPZ6J.js → chunk.ESSENNHM.js} +2 -2
  50. package/dist/preview/{chunk.5DZR46YG.js → chunk.ET3XJDPX.js} +1 -1
  51. package/dist/preview/chunk.FEIJ7ETK.js +1 -0
  52. package/dist/preview/{chunk.4XOSDCCE.js → chunk.FFCUZPTC.js} +1 -1
  53. package/dist/preview/chunk.FG5ZFYYL.js +1 -0
  54. package/dist/preview/{chunk.KFHXTHIY.js → chunk.FKJ3HIA5.js} +1 -1
  55. package/dist/preview/chunk.FTBH7CPZ.js +1 -0
  56. package/dist/preview/{chunk.LDE5HLTM.js → chunk.FU4YSVWX.js} +1 -1
  57. package/dist/preview/{chunk.A53G42QO.js → chunk.FYDDFOSD.js} +1 -1
  58. package/dist/preview/{chunk.ETWREHXF.js → chunk.GJQF7I22.js} +1 -1
  59. package/dist/preview/{chunk.6SHF6IL5.js → chunk.GLTWLQ6L.js} +1 -1
  60. package/dist/preview/chunk.GMAXA5GV.js +1 -0
  61. package/dist/preview/{chunk.SRU2YDTJ.js → chunk.GRYS6VSF.js} +1 -1
  62. package/dist/preview/{chunk.ZK446PSX.js → chunk.GYTVL6GR.js} +3 -3
  63. package/dist/preview/chunk.HASVT7IC.js +1 -0
  64. package/dist/preview/{chunk.RK6BK5FD.js → chunk.HFKGND5Q.js} +1 -1
  65. package/dist/preview/{chunk.JJP5OL5E.js → chunk.HVX7LFWR.js} +1 -1
  66. package/dist/preview/chunk.IBJBCZKG.js +1 -0
  67. package/dist/preview/{chunk.CDZVUCEK.js → chunk.IE4ZJQV3.js} +1 -1
  68. package/dist/preview/chunk.IFL2MYTQ.js +1 -0
  69. package/dist/preview/{chunk.F7AFJRPP.js → chunk.IUIDDNN3.js} +1 -1
  70. package/dist/preview/{chunk.RXJBYP7B.js → chunk.JBR66TUP.js} +1 -1
  71. package/dist/preview/chunk.JG2FGZF2.js +18 -0
  72. package/dist/preview/{chunk.7VX6TBNY.js → chunk.JI2UVZUU.js} +1 -1
  73. package/dist/preview/{chunk.OB7XLVK6.js → chunk.JMDKAP23.js} +1 -1
  74. package/dist/preview/{chunk.IDQHSAAQ.js → chunk.JX2C3HVD.js} +1 -1
  75. package/dist/preview/{chunk.FKUVIG6D.js → chunk.K7ECYKZL.js} +1 -1
  76. package/dist/preview/{chunk.UGJ32SEL.js → chunk.K7RKWB2K.js} +1 -1
  77. package/dist/preview/{chunk.S64LCR23.js → chunk.KK46XLGU.js} +1 -1
  78. package/dist/preview/chunk.KOBCLWPC.js +1 -0
  79. package/dist/preview/chunk.KRODTMGR.js +1 -0
  80. package/dist/preview/chunk.KYKHZZT7.js +1 -0
  81. package/dist/preview/chunk.LYIHPVDZ.js +1 -0
  82. package/dist/preview/{chunk.JLPBXG4P.js → chunk.MG3DMURZ.js} +1 -1
  83. package/dist/preview/{chunk.YG3BLY67.js → chunk.MMVCZOEX.js} +1 -1
  84. package/dist/preview/{chunk.BBNF52IB.js → chunk.MN6WHE4B.js} +1 -1
  85. package/dist/preview/{chunk.UJTRKSCK.js → chunk.MRXQBEPQ.js} +1 -1
  86. package/dist/preview/{chunk.NB6WN4DO.js → chunk.MX3Y3LPH.js} +1 -1
  87. package/dist/preview/{chunk.LJXAZ5TF.js → chunk.MY5OXSS7.js} +1 -1
  88. package/dist/preview/chunk.N5XONWU2.js +1 -0
  89. package/dist/preview/chunk.NNUUD26E.js +1 -0
  90. package/dist/preview/{chunk.ZITDUHX3.js → chunk.NQ26KMSQ.js} +1 -1
  91. package/dist/preview/{chunk.QFI4L2HK.js → chunk.NVRK6A7T.js} +1 -1
  92. package/dist/preview/{chunk.DUIKIJKC.js → chunk.NZDHXREL.js} +1 -1
  93. package/dist/preview/chunk.OHDJYGH7.js +2 -0
  94. package/dist/preview/{chunk.GZEZMU2T.js → chunk.OJ64WTLW.js} +2 -2
  95. package/dist/preview/{chunk.OUNLAMBA.js → chunk.OPCBZNKF.js} +1 -1
  96. package/dist/preview/{chunk.UCS3CBT4.js → chunk.OU5TRY4N.js} +1 -1
  97. package/dist/preview/chunk.OW72XZF4.js +1 -0
  98. package/dist/preview/chunk.P4CLT32V.js +5 -0
  99. package/dist/preview/chunk.PFXGWY3P.js +1 -0
  100. package/dist/preview/{chunk.GPJFNLEJ.js → chunk.PMV6XVVZ.js} +1 -1
  101. package/dist/preview/{chunk.2P66HH5Y.js → chunk.PPZ2TOB5.js} +1 -1
  102. package/dist/preview/{chunk.JC5NXMG3.js → chunk.PYRJDTVS.js} +1 -1
  103. package/dist/preview/chunk.QEQQXWYU.js +1 -0
  104. package/dist/preview/chunk.QPAJCRFB.js +1 -0
  105. package/dist/preview/chunk.R5R7CLOU.js +1 -0
  106. package/dist/preview/{chunk.SWLDDQJS.js → chunk.RMMJQYJJ.js} +1 -1
  107. package/dist/preview/{chunk.FDFVGHQE.js → chunk.RNOBACJ6.js} +1 -1
  108. package/dist/preview/{chunk.4BQNG3W3.js → chunk.S32AGJ3W.js} +1 -1
  109. package/dist/preview/chunk.S4CKKT3C.js +1 -0
  110. package/dist/preview/{chunk.KOPRZLJH.js → chunk.SJKHVIHA.js} +2 -2
  111. package/dist/preview/chunk.SJYQ72EC.js +1 -0
  112. package/dist/preview/chunk.SKG4IHT5.js +88 -0
  113. package/dist/preview/chunk.SLBWPVIY.js +1 -0
  114. package/dist/preview/{chunk.YZ6UKKEL.js → chunk.SPU3BVAO.js} +1 -1
  115. package/dist/preview/{chunk.VVRI7DNK.js → chunk.SRFZKDQ6.js} +1 -1
  116. package/dist/preview/{chunk.MRUDTYOL.js → chunk.SSAY4ITS.js} +2 -2
  117. package/dist/preview/{chunk.TY6VILZB.js → chunk.T3RTFTOZ.js} +1 -1
  118. package/dist/preview/{chunk.73BJYIYS.js → chunk.TBSPEO2L.js} +1 -1
  119. package/dist/preview/chunk.TMYGLXR6.js +25 -0
  120. package/dist/preview/{chunk.GTUBIJTP.js → chunk.TNL2BVCH.js} +1 -1
  121. package/dist/preview/{chunk.QAUZDLDA.js → chunk.TVWN5I4M.js} +1 -1
  122. package/dist/preview/{chunk.MCPLU2U4.js → chunk.U7SNDY3F.js} +1 -1
  123. package/dist/preview/chunk.UCUWEYKM.js +1 -0
  124. package/dist/preview/{chunk.T4UYLB3Y.js → chunk.UIWI4GKW.js} +1 -1
  125. package/dist/preview/{chunk.HGP3Q7QX.js → chunk.UK5F3S2N.js} +1 -1
  126. package/dist/preview/{chunk.ZKDJQDKX.js → chunk.UVAWWCFW.js} +1 -1
  127. package/dist/preview/{chunk.L2AV6JRA.js → chunk.UWFEXEY3.js} +1 -1
  128. package/dist/preview/chunk.V4GAOZAW.js +1 -0
  129. package/dist/preview/{chunk.TT6QBWRA.js → chunk.VICCAWAN.js} +1 -1
  130. package/dist/preview/{chunk.AXMC6XVT.js → chunk.W2DKFQ6R.js} +1 -1
  131. package/dist/preview/{chunk.53BGPCM6.js → chunk.WESWDXRW.js} +1 -1
  132. package/dist/preview/{chunk.QZMBEG4E.js → chunk.WFHFWJ6E.js} +1 -1
  133. package/dist/preview/{chunk.AXCRFJDL.js → chunk.WQLAIEWJ.js} +1 -1
  134. package/dist/preview/{chunk.JYJNRCK5.js → chunk.XCCBUWMC.js} +1 -1
  135. package/dist/preview/{chunk.GQX57JIE.js → chunk.XCQ7ZPR5.js} +1 -1
  136. package/dist/preview/chunk.XWXYC3BJ.js +1 -0
  137. package/dist/preview/chunk.XZVPVAIS.js +1 -0
  138. package/dist/preview/chunk.Y2ZBVWII.js +1 -0
  139. package/dist/preview/chunk.Y3LTHEN7.js +1 -0
  140. package/dist/preview/{chunk.TL7UGUY4.js → chunk.Y5AMZBHA.js} +2 -2
  141. package/dist/preview/{chunk.CR5MQMOL.js → chunk.Z7N3MJ36.js} +1 -1
  142. package/dist/preview/{chunk.SVH3OMU2.js → chunk.ZJXUWOG3.js} +1 -1
  143. package/dist/preview/{chunk.BORCUDGS.js → chunk.ZZODDJYK.js} +1 -1
  144. package/dist/preview/index.html +51 -51
  145. package/dist/preview/page.js +2 -2
  146. package/package.json +6 -6
  147. package/dist/preview/chunk.24MUPV4Y.js +0 -1
  148. package/dist/preview/chunk.2VZSC2MB.js +0 -1
  149. package/dist/preview/chunk.3L5USMQD.js +0 -1
  150. package/dist/preview/chunk.3O3H37WD.js +0 -1
  151. package/dist/preview/chunk.4VJARLJ5.js +0 -1
  152. package/dist/preview/chunk.5RNB6IC5.js +0 -1
  153. package/dist/preview/chunk.6BMCZPT6.js +0 -1
  154. package/dist/preview/chunk.6VA5XFRR.js +0 -1
  155. package/dist/preview/chunk.7PJVMADH.js +0 -2
  156. package/dist/preview/chunk.ATWNWPME.js +0 -1
  157. package/dist/preview/chunk.AVCW7C6V.js +0 -1
  158. package/dist/preview/chunk.BLS2G3CD.js +0 -5
  159. package/dist/preview/chunk.BNQL37AC.js +0 -88
  160. package/dist/preview/chunk.CBJHYNNT.js +0 -1
  161. package/dist/preview/chunk.EF3UB7US.js +0 -1
  162. package/dist/preview/chunk.EJUZGIQ5.js +0 -1
  163. package/dist/preview/chunk.F5FJHKWV.js +0 -1
  164. package/dist/preview/chunk.GQI53L5P.js +0 -1
  165. package/dist/preview/chunk.HG34MT7C.js +0 -1
  166. package/dist/preview/chunk.IATLUWAD.js +0 -1
  167. package/dist/preview/chunk.JLR74UFP.js +0 -1
  168. package/dist/preview/chunk.K4ITS63T.js +0 -1
  169. package/dist/preview/chunk.KT2LXHSI.js +0 -1
  170. package/dist/preview/chunk.M5RHVUZ6.js +0 -1
  171. package/dist/preview/chunk.MBZ6N5SO.js +0 -1
  172. package/dist/preview/chunk.N7FIUTVY.js +0 -1
  173. package/dist/preview/chunk.NPU4WYRB.js +0 -1
  174. package/dist/preview/chunk.OHAWUOUN.js +0 -1
  175. package/dist/preview/chunk.OKQ4JXTW.js +0 -1
  176. package/dist/preview/chunk.OYQ6ZA6T.js +0 -1
  177. package/dist/preview/chunk.Q7UQ5OXA.js +0 -1
  178. package/dist/preview/chunk.ROJZLOKZ.js +0 -1
  179. package/dist/preview/chunk.S7OFTGBQ.js +0 -18
  180. package/dist/preview/chunk.SGMVLKZO.js +0 -25
  181. package/dist/preview/chunk.SJRXBTGP.js +0 -1
  182. package/dist/preview/chunk.THTHNY4N.js +0 -1
  183. package/dist/preview/chunk.U6FGWVGB.js +0 -1
  184. package/dist/preview/chunk.UEL7FLL7.js +0 -1
  185. package/dist/preview/chunk.VM43YREJ.js +0 -1
  186. package/dist/preview/chunk.YAS6LXQ7.js +0 -1
  187. package/dist/preview/chunk.YEMNR4WU.js +0 -1
  188. package/dist/preview/chunk.YYS45ZGQ.js +0 -1
  189. package/dist/preview/chunk.ZI66HRES.js +0 -1
  190. package/dist/preview/chunk.ZVETGRUM.js +0 -1
  191. package/dist/preview/chunk.ZVOP2HHI.js +0 -1
@@ -1 +1 @@
1
- import{a as ve,b as qe,c as Ie,d as pe,e as R,f as fe,h as Ve}from"./chunk.BJAQRV2R.js";import{h as Le,i as Ue,j as We}from"./chunk.GQX57JIE.js";import{a as se,b as ie,c as H,d as Be,e as J,g as ne,h as Ze}from"./chunk.QFI4L2HK.js";import{c as _e,h as y,i as Ne,j as le}from"./chunk.KFHXTHIY.js";import{A as Re,Aa as Fe,Ha as De,Ia as ee,Ja as ce,Ob as Ke,Pb as de,Qb as Me,Rb as Pe,Sb as Te,b as W,c as L,e as xe,ec as Ge,f as Ee,fc as Ce,g as q,h as O,k as C,l as X,m as _,n as Ae,o as U,p as K,r as $,s as Q,t as x,u as E,v as I,w as P,x as n,y as M,z as Z}from"./chunk.BLS2G3CD.js";var ue=e=>Object.entries(e).map(([s,r])=>[s,Object.keys(ee(r?.edges))]),me=(e,s)=>Me(e,ue(s));function Ye(e){return[...Object.keys(e.acts??{}),...Object.keys(e.kinds).flatMap(s=>Ke(s)),...Pe(ue(e.kinds))]}var V=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function He(e){if(!V(e)||!V(e.kinds))return e;let s;try{let f=Object.fromEntries(Object.entries(e.kinds).map(([z,i])=>[z,V(i)&&V(i.edges)?{edges:i.edges}:{}]));s=Ye({acts:V(e.acts)?e.acts:{},kinds:f})}catch{return e}let r=new Set(s),t=!1,a=f=>{if(typeof f!="string"||r.has(f))return f;let z=Ge(f,s);return z===void 0?f:(t=!0,z)},d=V(e.policy)&&Array.isArray(e.policy.grants)?{...e.policy,grants:e.policy.grants.map(f=>V(f)&&Array.isArray(f.mutations)?{...f,mutations:f.mutations.map(a)}:f)}:void 0,u=V(e.rules)?Object.fromEntries(Object.entries(e.rules).map(([f,z])=>[f,V(z)&&Array.isArray(z.repairs)?{...z,repairs:z.repairs.map(i=>V(i)?{...i,act:a(i.act)}:i)}:z])):void 0;return t?{...e,...d?{policy:d}:{},...u?{rules:u}:{}}:e}function ge(e,s){let r=Ce(e,Ye(s));return r&&r!==e?`did you mean "${r}"?`:void 0}var he="graview-document",be=1,ke=256*1024,te=64*1024,ze=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,ye=/^[a-z][A-Za-z0-9]*$/,zn=new Set(["id","kind"]),yn=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,hn=["string","text","number","integer","boolean","date","datetime","enum","list","url","email","image","video","file","app-link","phone","place","duration"];function bn(){let e=k=>k in Object.prototype,s=Z(k=>!e(k),"every object already has this name \u2014 choose another"),r=(k,N)=>[...k===void 0?[]:[Ee(k)],...N===void 0?[]:[xe(N)]],t=(k,N)=>O().check(...r(k,N)),a=(k,N,gn)=>K(k).check(...r(N,gn)),d=k=>O().check(q(ze,`${k} names are kebab-case, lower-case words joined by hyphens like "tool-note" (field and relation names are camelCase, like "supersededBy")`)),u=O().check(q(yn,'relation names are one camelCase word, like "supersededBy" (kind names are kebab-case, like "tool-note")'),s),f=O().check(q(ye,'field names are one word or camelCase, like "dueDate", so rules say them bare (kind names are kebab-case, like "tool-note")'),Z(k=>!zn.has(k),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),s),z=t(1,500),i=t(1,2e3),o=t(1,300),p=$({type:I(hn),required:n(_()),description:n(z),label:n(t(1,60)),options:n(a(t(1,80),1,100)),of:n(I(["string","number","date","image","video","file"])),default:n(U()),unit:n(t(void 0,12)),format:n(I(["money","percent","duration","markdown"])),min:n(C()),max:n(C()),step:n(C()),renamedFrom:n(O().check(q(ye))),repeats:n(_()),collaborative:n(_())}).check(Re((k,N)=>{k.type==="enum"&&!k.options&&N.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),k.type!=="enum"&&k.options&&N.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),k.type!=="list"&&k.of&&N.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]}),k.repeats&&k.type!=="date"&&k.type!=="datetime"&&N.addIssue({code:"custom",message:'"repeats" belongs only on a date or datetime field',path:["repeats"]})})),w=O().check(q(new RegExp(`${ze.source}|${Fe.source}`),'a relation goes to a kind of this document, like "house", or of another app, like "@nick/house/house"')),m=$({to:x([a(w,1),P("*")]),cardinality:n(I(["one","many"])),description:n(z),inverse:n(t(1,80)),appendOnly:n(_()),renamedFrom:n(O()),tidying:n(P("never"))}),l=x([i,$({expr:i,label:n(t(1,60)),description:n(z)})]),c=$({noun:n(t(1,40)),plural:n(t(1,40)),description:n(z),fields:E(f,p).check(Z(k=>Object.keys(k).length>0,"a kind has at least one field")),label:n(o),describe:n(o),lifecycle:n($({field:f,retired:a(x([O(),C(),_()]),1)})),figure:n(t(void 0,2e4)),glance:n(a(f,1,20)),page:n($({fields:n(a(f,1,40)),groups:n(a($({title:t(1,60),fields:a(f,1,40)}),1,12))})),edges:n(E(u,m)),computed:n(E(O(),l).check(Z(k=>Object.keys(k).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:n(E(O(),O())),renamedFrom:n(O().check(q(ze))),people:n(_()),archives:n(P(!1)),tidying:n(I(["never","no-links"]))}),j=x([O(),C(),_(),Ae(),K(U()),$({expr:i})]),h=O().check(q(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),S=x([$({create:d("kind"),as:n(O().check(q(ye))),set:n(E(f,j))}),$({set:E(f,j),target:n(h)}),$({connect:u,from:h,to:h}),$({sever:u,from:h,to:h}),$({remove:h})]),A=$({title:n(t(1,80)),description:n(z),fromTheOtherEnd:n(t(1,80)),on:n(x([d("kind"),a(d("kind"),1)])),creates:n(d("kind")),sets:n(E(f,j)),writes:n(a(f,1)),connects:n(u),severs:n(u),setsOther:n(E(f,j)),replaces:n(x([P(!0),a(u,1,10)])),removes:n(P(!0)),args:n(E(f,p)),effects:n(a(S,1,20)),allowedWhen:n(i),refusal:n(o),destructive:n(_())}),b=$({act:d("act"),label:n(t(1,80)),args:n(E(O(),j))}),G=$({title:n(t(1,120)),description:n(z),over:x([P("graph"),d("kind")]),when:n(i),require:i,says:n(o),repairs:n(a(b,void 0,10))}),F=$({roles:x([a(d("role"),1),P("*")]),mutations:x([a(d("act"),1),P("*")]),kinds:n(x([K(d("kind")),P("*")])),describe:n(z),self:n(_()),ownEnd:n(_())}),g=n(a(d("field"),1)),v=$({roles:x([a(d("role"),1),P("*")]),kinds:a(d("kind"),1),own:n(_()),via:n(u),fields:g,hide:g}),D=$({grants:K(F),sees:n(K(v))}),oe=$({accent:n(O().check(q(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),name:n(t(1,60)),currency:n(O().check(q(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:n(t(2,35)),timeZone:n(t(1,64)),logo:n(x([t(1,te),$({src:t(1,te),alt:n(t(1,120))}),$({light:t(1,te),dark:n(t(1,te)),alt:n(t(1,120)),darkFallback:n(P("invert"))})])),favicon:n(x([t(1,te),$({emoji:O()})])),typography:n($({display:n(t(1,200)),body:n(t(1,200)),mono:n(t(1,200))})),shape:n($({radius:n(C().check(L(0),W(32))),density:n(C().check(L(.75),W(1.5)))})),accents:n(E(O(),C().check(L(0),W(360)))),scheme:n(I(["light","dark","auto"])),subtitle:n(P(!1))}),B=E(O(),U()),Y=x([t(1,120),$({by:t(1,120),direction:n(I(["asc","desc"]))})]),je=C().check(X(),L(1),W(9999)),dn=Q({create:n(_()),options:n(Q({sort:n(Y),columnSort:n(Y),search:n(a(t(1,120),void 0,40)),filters:n(a(t(1,120),void 0,40)),horizon:n(x([C().check(X(),L(1),W(200)),Q({years:C().check(X(),L(1),W(200)),title:t(1,80),from:n(je),to:n(je)})]))}))}),ln=$({card:n(K(U())),row:n(K(U())),page:n(K(U()))}),pn=()=>{let k=n(I(["asc","desc"]));return x([t(1,120),$({by:t(1,120),direction:k,then:n(x([t(1,120),$({by:t(1,120),direction:k})]))})])},fn=()=>x([t(1,120),$({by:t(1,120),order:n(a(t(1,80),void 0,40)),closed:n(a(t(1,80),void 0,40))})]),Oe=Q({order:n(K(O())),hide:n(K(O())),first:n(O()),primary:n(a(t(1,80),void 0,40)),scene:n(t(1,40)),pages:n(t(1,40)),lists:n(E(O(),$({filters:n(a(t(1,120),void 0,40)),sort:n(pn()),group:n(fn())})))}),un=$({act:d("act"),title:n(t(1,80)),intro:n(z),fields:n(a(f,1,40)),say:n(z),submit:n(t(1,80)),role:n(d("role"))}),mn=$({$schema:n(O()),format:P(he),formatVersion:P(be),name:t(1,80),description:n(z),version:n(C().check(X(),L(1))),kinds:E(d("kind"),c).check(Z(k=>Object.keys(k).length>0,"a document declares at least one kind"),Z(k=>Object.keys(k).length<=40,"a document declares at most 40 kinds")),computed:n(E(O(),l)),acts:n(E(d("act"),A)),rules:n(E(d("rule"),G)),roles:n(K(d("role"))),policy:n(D),modules:n(B),lenses:n(K(dn)),pages:n(Oe),views:n(E(O(),x([ln,K(U())]))),brand:n(oe),settings:n(K(B)),migrations:n(K(B)),connections:n(E(d("connection"),B)),forms:n(E(d("form"),un)),publishing:n($({mode:I(["live","on-publish"]),working:a(d("role"),void 0,40),publishers:n(a(d("role"),1,40))}))});return{FieldSpec:p,EdgeSpec:m,ComputedSpec:l,KindSpec:c,ValueSpec:j,EffectSpec:S,ActSpec:A,RepairSpec:b,RuleSpec:G,GrantSpec:F,SightSpec:v,PolicySpec:D,BrandSpec:oe,PagesSpec:Oe,DocumentSpec:mn}}var kn,T=()=>kn??=bn(),_n=M(()=>T().FieldSpec),Nn=M(()=>T().EdgeSpec),qn=M(()=>T().ComputedSpec),In=M(()=>T().KindSpec),Vn=M(()=>T().ValueSpec),Bn=M(()=>T().EffectSpec),Ln=M(()=>T().ActSpec),Un=M(()=>T().RepairSpec),Wn=M(()=>T().RuleSpec),Zn=M(()=>T().GrantSpec),Yn=M(()=>T().SightSpec),Hn=M(()=>T().PolicySpec),Jn=M(()=>T().BrandSpec),Xn=M(()=>T().PagesSpec),Je=M(()=>T().DocumentSpec);var $n={};function Xe(e,s=$n,r=be){let{document:t,respelled:a}=ve(e),d=a.length>0?{respelled:a}:{};if(!t||typeof t!="object"||Array.isArray(t))return{document:t};let u=t;if(u.format!==he||typeof u.formatVersion!="number"||u.formatVersion>=r)return{document:t,...d};let f=u.formatVersion,z=structuredClone(u);for(let i=f;i<r;i++){let o=s[i];if(!o)throw new Error(`there is no upgrade from format ${i} to ${i+1}`);z={...o(z),formatVersion:i+1}}return{document:z,from:f,...d}}function Qe(e,s,r){let t=Object.keys(e).filter(f=>e[f].edges?.[s]!==void 0);if(t.length===0)return;let a=t.map(f=>e[f].edges[s].to),d=a.some(f=>f==="*")?"*":[...new Set(a.flatMap(f=>f))];if(r.length===0||r.some(f=>t.includes(f)))return{reversed:!1,kinds:d};let u=t.filter(f=>{let z=e[f].edges[s].to;return z==="*"||r.every(i=>z.includes(i))});return u.length>0?{reversed:!0,kinds:u}:{reversed:!1,kinds:d}}var tn=(e,s)=>{let r=e?.fields[s];return r!==void 0&&(r.type==="duration"||(r.type==="number"||r.type==="integer")&&r.format==="duration")};function en(e,s,r,t){if(t==="out"){let a=e[s]?.edges?.[r]?.to;return a===void 0?[]:a==="*"?Object.keys(e):a}return Object.entries(e).filter(([,a])=>{let d=a.edges?.[r]?.to;return d!==void 0&&(d==="*"||d.includes(s))}).map(([a])=>a)}function $e(e,s,r){if(r.t==="ident")return e[s]?.edges?.[r.name]?en(e,s,r.name,"out"):void 0;if(r.t==="where")return $e(e,s,r.set);if(r.t==="call"&&(r.fn==="out"||r.fn==="in")&&r.args[0]?.t==="lit"&&typeof r.args[0].value=="string")return en(e,s,r.args[0].value,r.fn)}var nn=(e,s,r)=>{let t=s.filter(a=>e[a]?.fields[r]!==void 0);return t.length>0&&t.every(a=>tn(e[a],r))};function on(e,s,r){let t=e.kinds,a=t[s],d=new Map(r),u=new Map,f=(i,o)=>{if(o>8)return!1;switch(i.t){case"ident":return tn(a,i.name)||z(i.name,o+1);case"member":{let p=$e(t,s,i.object);return p!==void 0&&nn(t,p,i.name)}case"call":{if(i.fn!=="sum"&&i.fn!=="min"&&i.fn!=="max")return!1;let[p,w]=i.args,m=p&&$e(t,s,p);return m!==void 0&&w?.t==="ident"&&nn(t,m,w.name)}case"binary":return(i.op==="+"||i.op==="-")&&f(i.left,o)&&f(i.right,o);case"unary":return i.op==="-"&&f(i.operand,o);default:return!1}},z=(i,o)=>{if(a?.computed?.[i]===void 0)return!1;if(u.has(i))return u.get(i);u.set(i,!1);let p=d.get(i),w=p!==void 0&&f(p,o);return u.set(i,w),w};return r.map(([i])=>i).filter(i=>z(i,0))}function sn(e,s,r=`kinds.${e}.page`){let t=s.page;if(!t)return[];let a=[],d=[...Object.keys(s.fields),...Object.keys(s.computed??{})],u=new Set,f=(i,o)=>{d.includes(i)?u.has(i)&&a.push(y("page-field-twice",o,`"${i}" is on ${e}'s page twice; name each field once`)):a.push(y("page-field",o,`${e}'s page is to show "${i}", and ${e} has no field or computed field called that`,`use one of: ${d.join(", ")}`)),u.add(i)};(t.fields??[]).forEach((i,o)=>f(i,`${r}.fields.${o}`));let z=new Set;return(t.groups??[]).forEach((i,o)=>{let p=i.title.trim().toLowerCase();z.has(p)&&a.push(y("page-group-twice",`${r}.groups.${o}.title`,`${e}'s page has two groups called "${i.title}"; give each its own title`)),z.add(p),i.fields.forEach((w,m)=>f(w,`${r}.groups.${o}.fields.${m}`))}),a}function rn(e,s=[]){return Te({declared:Object.keys(e.fields),paged:[...e.page?.fields??[],...(e.page?.groups??[]).flatMap(r=>r.fields)],must:r=>!!e.fields[r].required&&e.fields[r].default===void 0,naming:s})}var wn=new Set(["subject","now","today","me"]);function Sn(e){if((typeof e=="string"?e:JSON.stringify(e??null)).length>ke)return{findings:[y("too-large","",`a document may be at most ${ke/1024} KB`)]};if(typeof e=="string")try{e=JSON.parse(e)}catch(t){return{findings:[y("not-json","",`this is not JSON: ${t.message}`)]}}try{e=Xe(e).document}catch(t){return{findings:[y("format","formatVersion",t.message)]}}e=He(e);let s=Je.safeParse(e);if(!s.success)return{findings:s.error.issues.map(t=>{let a=t.path.map(String).join(".");if(t.code==="unrecognized_keys")return y("unknown-key",a,`${t.keys.map(d=>`"${d}"`).join(", ")} ${t.keys.length===1?"is":"are"} not part of a Graview document here`,"check the spelling against docs/declaration-document.md");if(t.code==="invalid_union"&&/\.effects\.\d+$/.test(a))return y("effect-shape",a,"this effect is not one Graview knows",'an effect is one of {"create": kind, "as"?: name, "set"?: {field: value}}, {"set": {field: value, \u2026}, "target"?: "$ref"}, {"connect"|"sever": relation, "from": "$ref", "to": "$ref"}, {"remove": "$ref"}');if(t.code==="invalid_key"){let d=t.issues?.[0]?.message;return y("shape",a,`the name "${String(t.path.at(-1))}" is not allowed here${d?`: ${d}`:""}`)}return y("shape",a,t.message)})};let r=s.data;return{document:r,findings:jn(r)}}var ae=e=>[e??[]].flat();function an(e){let s=new Map;for(let[r,t]of Object.entries(e.kinds))for(let[a,d]of Object.entries(ee(t.edges))){let u=s.get(a);s.set(a,{name:a,from:[...u?.from??[],r],to:d.to==="*"||u?.to==="*"?"*":[...new Set([...u?.to??[],...d.to])],cardinality:d.cardinality??"many"})}return s}function Et(e){let s=new Map;for(let[t,a]of Object.entries(e.kinds)){let d=ne(a),u=ce(a.edges);s.set(t,{fields:new Set([...Object.keys(a.fields),...u.keys()]),edges:new Map(Object.entries(ee(a.edges)).map(([f,z])=>[f,z.cardinality??"many"])),...d?{computed:d}:{},...u.size>0?{linked:u}:{}})}let r=ne(e);return r&&s.set(_e,{computed:r}),s}function cn(e,s){let r=[],t=ae(e.on),a=(d,u)=>{let f=Qe(s.kinds,d,t)?.reversed===!0,[z,i]=f?["$to","$subject"]:["$subject","$to"];return u==="connect"?{connect:d,from:z,to:i}:{sever:d,from:z,to:i}};if(e.creates){let d=s.kinds[e.creates],u={};for(let f of Object.keys(d?.fields??{}))u[f]=`$${f}`;for(let f of e.effects??[])"set"in f&&!("create"in f)&&R(f.target)==="new"&&Object.assign(u,f.set);r.push({create:e.creates,as:"new",set:u})}return e.sets&&r.push({set:e.sets}),e.writes&&!(e.creates&&e.on===void 0)&&r.push({set:Object.fromEntries(e.writes.map(d=>[d,`$${d}`]))}),e.connects&&(e.replaces&&r.push({replace:e.replaces===!0?[e.connects]:[...e.replaces],keep:e.connects}),r.push(a(e.connects,"connect"))),e.severs&&r.push(a(e.severs,"sever")),e.setsOther&&(e.connects||e.severs)&&r.push({set:e.setsOther,target:"$to"}),e.removes&&r.push({remove:"$subject"}),e.effects&&r.push(...e.effects.filter(d=>!(e.creates&&"set"in d&&!("create"in d)&&R(d.target)==="new"))),r}function we(e,s,r){try{let t=H(e),a=se(t);for(let d of a.unknownFunctions)r.push(y("unknown-function",s,`"${d}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));return t}catch(t){if(t instanceof ie){r.push(y("expression",s,t.sentence+` (at character ${t.at+1})`));return}throw t}}function Se(e,s,r){try{return J(e)}catch(t){if(t instanceof Be||t instanceof ie){r.push(y("template",s,(t instanceof ie,t.sentence)));return}throw t}}function jn(e){let s=[],r=new Set(Object.keys(e.kinds)),t=an(e),a=e.acts??{},d=new Set(e.roles??[]),u=(i,o)=>ce(e.kinds[i]?.edges).has(o),f=i=>Object.keys(e.kinds).some(o=>u(o,i));for(let[i,o]of Object.entries(e.kinds)){let p=`kinds.${i}`;for(let[m,l]of Object.entries(o.edges??{})){if(!De(l)&&l.to!=="*")for(let c of l.to)r.has(c)||s.push(y("edge-target",`${p}.edges.${m}.to`,`"${c}" is not a kind this document declares`));o.fields[m]&&s.push(y("edge-field-clash",`${p}.edges.${m}`,`"${m}" is both a field and a relation of ${i}`,"rename one of them"))}o.lifecycle&&!o.fields[o.lifecycle.field]&&s.push(y("lifecycle-field",`${p}.lifecycle.field`,`${i} has no field "${o.lifecycle.field}"`));let w=m=>o.computed!==void 0&&Object.hasOwn(o.computed,m);for(let m of o.glance??[])!o.fields[m]&&!w(m)&&s.push(y("glance-field",`${p}.glance`,`a glance at ${i} is to say "${m}", and ${i} has no field or computed field called that`,`use one of: ${[...Object.keys(o.fields),...Object.keys(o.computed??{})].join(", ")}`));s.push(...sn(i,o));for(let m of["label","describe"]){let l=o[m];if(!l)continue;let c=Se(l,`${p}.${m}`,s);for(let j of c??[])if(j.expr){for(let h of se(j.expr).names)if(!o.fields[h]){if(w(h)){Ze(o,h)||s.push(y("template-field",`${p}.${m}`,`${i}'s ${h} is worked out from beyond the record, and a ${m} is said with no graph to read`,`show it in a view instead, or name a computed field worked out from ${i}'s own fields`));continue}s.push(y("template-field",`${p}.${m}`,`${i} has no field "${h}" for its ${m} to show`,m==="label"?"a label can only show the record's own fields and what they work out":void 0))}}}for(let[m,l]of Object.entries(o.fields)){l.default!==void 0&&l.type==="enum"&&!l.options?.includes(String(l.default))&&s.push(y("default-option",`${p}.fields.${m}.default`,`"${String(l.default)}" is not one of ${m}'s options`));let c=`${m}Repeat`;l.repeats&&(o.fields[c]||o.edges?.[c]||o.computed?.[c])&&s.push(y("repeat-clash",`${p}.fields.${m}.repeats`,`${i} already has "${c}", where how ${m} repeats is kept`))}}for(let[i,o]of Object.entries(a)){let p=`acts.${i}`;for(let c of ae(o.on))r.has(c)||s.push(y("act-kind",`${p}.on`,`"${c}" is not a kind this document declares`));let w=ae(o.on),m=cn(o,e);if(o.creates&&o.on===void 0&&o.writes&&r.has(o.creates)){for(let c of o.writes)if(!e.kinds[o.creates].fields[c])if(e.kinds[o.creates].computed?.[c]!==void 0)s.push(y("computed-written",`${p}.writes`,`${o.creates}'s ${c} is worked out, not written: no act can set it`,"write the stored fields it is worked out from"));else{if(u(o.creates,c))continue;s.push(y("act-field",`${p}.writes`,`${o.creates} has no field "${c}"`))}}m.length===0&&s.push(y("act-empty",p,`"${i}" does nothing`,"give it effects or a shorthand such as sets or creates"));let l=new Map;m.forEach((c,j)=>{let h=m.length-(o.effects?.length??0),S=o.effects&&j>=h?`${p}.effects.${j-h}`:p;if("create"in c){if(!r.has(c.create))s.push(y("act-kind",`${S}.create`,`"${c.create}" is not a kind this document declares`));else for(let b of Object.keys(c.set??{}))e.kinds[c.create].fields[b]||(e.kinds[c.create].computed?.[b]!==void 0?s.push(y("computed-written",`${S}.set.${b}`,`${c.create}'s ${b} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):s.push(y("act-field",`${S}.set.${b}`,`${c.create} has no field "${b}"`)));c.as&&l.set(c.as,c.create)}else if("connect"in c||"sever"in c){let b="connect"in c?c.connect:c.sever;!t.has(b)&&!f(b)&&s.push(y("act-edge",`${S}.${"connect"in c?"connect":"sever"}`,`"${b}" is not a relation any kind declares`)),R(c.from)==="subject"&&w.length===0&&s.push(y("act-subject",`${p}.on`,`"${i}" acts on "$subject" but does not say which kinds it is "on"`))}else if("set"in c){let b=R(c.target??"$subject"),G=b==="subject"?w:l.has(b??"")?[l.get(b)]:[];b==="subject"&&w.length===0&&s.push(y("act-subject",`${p}.on`,`"${i}" changes "$subject" but does not say which kinds it is "on"`));for(let F of Object.keys(c.set))for(let g of G)if(!(!r.has(g)||e.kinds[g].fields[F]))if(e.kinds[g].computed?.[F]!==void 0)s.push(y("computed-written",`${S}.set.${F}`,`${g}'s ${F} is worked out, not written: no act can set it`,"set the stored fields it is worked out from"));else{if(u(g,F))continue;s.push(y("act-field",`${S}.set.${F}`,`${g} has no field "${F}"`))}}else"remove"in c&&R(c.remove)==="subject"&&w.length===0&&s.push(y("act-subject",`${p}.on`,`"${i}" removes "$subject" but does not say which kinds it is "on"`));("set"in c&&c.set?Object.values(c.set):[]).forEach(b=>{b&&typeof b=="object"&&!Array.isArray(b)&&"expr"in b&&we(b.expr,`${S}.set`,s)})}),o.allowedWhen&&we(o.allowedWhen,`${p}.allowedWhen`,s),o.refusal&&Se(o.refusal,`${p}.refusal`,s)}for(let[i,o]of Object.entries(e.rules??{})){let p=`rules.${i}`;o.over!=="graph"&&!r.has(o.over)&&s.push(y("rule-kind",`${p}.over`,`"${o.over}" is not a kind this document declares`));let w=o.over==="graph"?void 0:e.kinds[o.over];for(let m of["when","require"]){let l=o[m];if(!l)continue;let c=we(l,`${p}.${m}`,s);if(!c)continue;let j=se(c);for(let h of j.names)if(o.over==="graph")s.push(y("rule-name",`${p}.${m}`,`"${h}" means nothing in a rule over the whole graph`,`name a kind in "over", or use all('kind')`));else if(w&&!w.fields[h]&&!w.edges?.[h]&&w.computed?.[h]===void 0){let S=Object.keys(w.edges??{}).find(A=>A.includes("-")&&A.split("-").includes(h));s.push(y("rule-name",`${p}.${m}`,`${o.over} has no field or relation called "${h}"`,S?`"${S}" reads as a subtraction in a rule; rename the relation to one camelCase word, like "${S.replace(/-([a-z0-9])/g,(A,b)=>b.toUpperCase())}"`:void 0))}for(let h of j.edges)!t.has(h)&&!f(h)&&s.push(y("rule-edge",`${p}.${m}`,`"${h}" is not a relation any kind declares`));for(let h of j.sweeps)r.has(h)?o.over!=="graph"&&s.push(Ne("rule-cost",`${p}.${m}`,`this rule looks at every ${h} for every ${o.over}, which grows slowly as the app grows`,"walk a relation with out()/in() instead of all() where you can")):s.push(y("rule-kind",`${p}.${m}`,`"${h}" is not a kind this document declares`))}o.says&&Se(o.says,`${p}.says`,s),(o.repairs??[]).forEach((m,l)=>{!a[m.act]&&!de(m.act)&&!me(m.act,e.kinds)&&s.push(y("repair-act",`${p}.repairs.${l}.act`,`"${m.act}" is not an act this document declares`,ge(m.act,e)))})}let z=e.policy;return z&&(z.grants.forEach((i,o)=>{if(i.roles!=="*"&&d.size>0)for(let p of i.roles)d.has(p)||s.push(y("grant-role",`policy.grants.${o}.roles`,`"${p}" is not one of the document's roles`));if(i.mutations!=="*")for(let p of i.mutations)!a[p]&&!de(p)&&!me(p,e.kinds)&&s.push(y("grant-act",`policy.grants.${o}.mutations`,`"${p}" is not an act this document declares`,ge(p,e)))}),(z.sees??[]).forEach((i,o)=>{for(let p of i.kinds)r.has(p)||s.push(y("sight-kind",`policy.sees.${o}.kinds`,`"${p}" is not a kind this document declares`));if(i.roles!=="*"&&d.size>0)for(let p of i.roles)d.has(p)||s.push(y("sight-role",`policy.sees.${o}.roles`,`"${p}" is not one of the document's roles`))})),s.push(...We(e)),s}function On(e){return e.label?[...e.label.matchAll(/\{\s*([A-Za-z_][A-Za-z0-9_]*)/g)].map(s=>s[1]):[fe(e)??[]].flat()}function vn(e,s,r,t){let a=new Map,d=ae(e.on),u=new Map,f=new Map;(d.length>0||s.some(l=>"remove"in l&&R(l.remove)==="subject"||"from"in l&&(R(l.from)==="subject"||R(l.to)==="subject")||"set"in l&&!("create"in l)&&R(l.target??"$subject")==="subject"))&&a.set(pe,{ref:d.length>0?d:"*",required:!0});let i=e.args??{},o=e.writes?.length===1,p=(l,c)=>c&&l.type===c.type&&l.min===void 0&&l.max===void 0&&l.step===void 0?{...l,...c.min===void 0?{}:{min:c.min},...c.max===void 0?{}:{max:c.max},...c.step===void 0?{}:{step:c.step}}:l,w=(l,c)=>c&&l.type===c.type&&l.format===void 0&&l.unit===void 0?{...p(l,c),...c.format?{format:c.format}:{},...c.unit?{unit:c.unit}:{}}:p(l,c),m=(l,c,j)=>{if(l===pe||wn.has(l)||u.has(l)||a.has(l))return;let h=i[l]?w(i[l],j):void 0;a.set(l,h?{field:h,optional:!h.required,required:!!h.required}:c())};for(let l of s)if("create"in l){let c=r.kinds[l.create],j=c?rn(c,On(c)):[],h=S=>j.includes(S)?j.indexOf(S):j.length;for(let[S,A]of Object.entries(l.set??{}).sort(([b],[G])=>h(b)-h(G))){let b=R(A),G=c?.fields[S];if(b&&G){let F=!!G.required&&G.default===void 0;m(b,()=>({field:G,optional:!F,required:F}),G)}}l.as&&u.set(l.as,l.create)}else if("connect"in l||"sever"in l){let c=t.get("connect"in l?l.connect:l.sever);for(let[j,h]of[["from",l.from],["to",l.to]]){let S=R(h);if(!S)continue;let A=j==="to"?c?.to??"*":c?.from??"*";A!=="*"&&!f.has(S)&&f.set(S,A),m(S,()=>({ref:A,required:!0}))}}else if("set"in l){let c=R(l.target??"$subject"),j=c==="subject"?d[0]:u.get(c??"")??f.get(c??"")?.[0];c&&c!=="subject"&&!u.has(c)&&m(c,()=>({ref:"*",required:!0}));for(let[h,S]of Object.entries(l.set)){let A=R(S);if(!A)continue;let b=j?r.kinds[j]?.fields[h]:void 0;m(A,()=>b?{field:b,optional:!o,required:o}:{any:!0,required:!1},b)}}else if("remove"in l){let c=R(l.remove);c&&m(c,()=>({ref:"*",required:!0}))}for(let[l,c]of Object.entries(i))a.has(l)||a.set(l,{field:c,optional:!c.required,required:!!c.required});return a}function At(e,s={}){let r=Sn(e);if(!r.document||le(r.findings))return{ok:!1,findings:r.findings};let t=r.document,a=[...r.findings];s.previous&&a.push(...En(t,s.previous));let d=xn(t,a);return le(d.findings)?{ok:!1,findings:d.findings}:Ve(d,s)}function re(e,s){return e.map(r=>{let t=!r.format&&r.expr?.t==="ident"?s?.[r.expr.name]?.format:void 0;return t==="money"||t==="percent"?{...r,format:t}:r})}function xn(e,s){let r=an(e),t={};for(let[i,o]of Object.entries(e.kinds)){let p=fe(o),w=o.label??(p?`{${p}}`:void 0),m=ne(o),l=m?on(e,i,[...m]):[];t[i]={...w?{label:re(J(w),o.fields)}:{},...o.describe?{describe:re(J(o.describe),o.fields)}:{},...m?{computed:[...m]}:{},...l.length>0?{durations:l}:{}}}let a={};for(let[i,o]of Object.entries(e.acts??{})){let p=cn(o,e),w=vn(o,p,e,r),m=o.destructive??p.some(g=>"remove"in g||"sever"in g||"replace"in g),l=[...new Set(p.flatMap(g=>"create"in g?[g.create]:[]))],c=[...new Set(p.flatMap(g=>"connect"in g?[g.connect]:[]))],j=[...new Set(p.flatMap(g=>"sever"in g?[g.sever]:"replace"in g?g.replace:[]))],h=[...new Set(p.flatMap(g=>"set"in g&&!("create"in g)&&R(g.target??"$subject")==="subject"?Object.keys(g.set):[]))],S=new Map;for(let g of p){if(!("connect"in g)&&!("sever"in g))continue;let v=r.get("connect"in g?g.connect:g.sever);for(let[D,oe]of[["from",g.from],["to",g.to]]){let B=R(oe),Y=D==="to"?v?.to:v?.from;B&&B!=="subject"&&Y&&Y!=="*"&&S.set(B,[...new Set([...S.get(B)??[],...Y])])}}let A={};for(let g of p){if(!("set"in g)||"create"in g)continue;let v=R(g.target??"$subject");for(let D of v&&v!=="subject"&&S.get(v)||[])A[D]=[...new Set([...A[D]??[],...Object.keys(g.set)])]}let b={};for(let g of p)if(!(!("set"in g)||"create"in g||R(g.target??"$subject")!=="subject"))for(let[v,D]of Object.entries(g.set??{}))typeof D=="string"&&R(D)===void 0||typeof D=="number"||typeof D=="boolean"?b[v]=typeof D=="string"&&D.startsWith("$$")?D.slice(1):D:delete b[v];let G=l.length===0&&p.every(g=>!("set"in g)||!g.set||Object.values(g.set).every(v=>!(v&&typeof v=="object"&&!Array.isArray(v)&&"expr"in v))),F=new Map;for(let g of p)if(!(!("set"in g)||!g.set))for(let v of Object.values(g.set))v&&typeof v=="object"&&!Array.isArray(v)&&"expr"in v&&F.set(v.expr,H(v.expr));a[i]={title:o.title??i.replace(/-/g," "),effects:p,args:[...w],...o.allowedWhen?{guard:H(o.allowedWhen)}:{},...o.refusal?{refusal:re(J(o.refusal),e.kinds[[o.on??[]].flat()[0]??""]?.fields)}:{},exprs:[...F],destructive:m,idempotent:G,creates:l,connects:c,severs:j,writes:h,writesOther:A,sets:b}}let d={};for(let[i,o]of Object.entries(e.rules??{}))d[i]={title:o.title??i.replace(/-/g," "),require:H(o.require),...o.when?{when:H(o.when)}:{},...o.says?{says:re(J(o.says),e.kinds[o.over]?.fields)}:{}};let u=qe(e,s),f=Le(e),z=Ue(e);return{format:Ie,document:e,findings:s,kinds:t,...e.computed?{facts:[...ne(e)??[]]}:{},edges:[...r].map(([i,{from:o,to:p,cardinality:w}])=>[i,{from:o,to:p,cardinality:w}]),acts:a,rules:d,brand:u,...Object.keys(f).length>0?{viewSpecs:f}:{},...z?{home:z}:{}}}function Rt(e,s,r){let t=/^defineNode\("([^"]+)"\)/.exec(s)?.[1],a=t?r.kinds[t]:void 0;if(!t||!a)return e;let d=Object.keys(a.fields).filter(u=>u!=="label").slice(0,3);return{...e,path:`kinds.${t}.glance`,fix:`Say which: "glance": [${d.map(u=>`"${u}"`).join(", ")}] on kinds.${t} \u2014 the facts a person compares one by, at a glance.`}}function En(e,s){let r=[],t=new Set(Object.values(s.kinds).flatMap(a=>Object.keys(a.edges??{})));for(let[a,d]of Object.entries(e.kinds)){let u=d.renamedFrom;u&&!s.kinds[u]&&r.push(y("renamed-from-nothing",`kinds.${a}.renamedFrom`,`${a} says it was ${u}, and the previous version has no kind called ${u}`,"name the kind it was, or drop renamedFrom"));let f=s.kinds[u??a];for(let[z,i]of Object.entries(d.fields)){let o=i.renamedFrom;o&&!f?.fields[o]&&r.push(y("renamed-from-nothing",`kinds.${a}.fields.${z}.renamedFrom`,`${z} says it was ${o}, and the previous ${u??a} has no field called ${o}`,"name the field it was, or drop renamedFrom"))}for(let[z,i]of Object.entries(d.edges??{})){let o=i.renamedFrom;o&&!t.has(o)&&r.push(y("renamed-from-nothing",`kinds.${a}.edges.${z}.renamedFrom`,`${z} says it was ${o}, and the previous version has no relation called ${o}`,"name the relation it was, or drop renamedFrom"))}}return r}export{Sn as a,Et as b,cn as c,At as d,Rt as e};
1
+ import{a as ve,b as qe,c as Ie,d as pe,e as R,f as fe,h as Ve}from"./chunk.76QSPWSJ.js";import{h as Le,i as Ue,j as We}from"./chunk.XCQ7ZPR5.js";import{a as se,b as ie,c as H,d as Be,e as J,g as ne,h as Ze}from"./chunk.NVRK6A7T.js";import{c as _e,h as y,i as Ne,j as le}from"./chunk.FKJ3HIA5.js";import{A as Re,Aa as Fe,Ha as De,Ia as ee,Ja as ce,Rb as Ke,Sb as de,Tb as Me,Ub as Pe,Vb as Te,b as W,c as L,e as xe,f as Ee,g as q,h as O,k as C,kc as Ge,l as X,lc as Ce,m as _,n as Ae,o as U,p as K,r as $,s as Q,t as x,u as E,v as I,w as P,x as n,y as M,z as Z}from"./chunk.P4CLT32V.js";var ue=e=>Object.entries(e).map(([s,r])=>[s,Object.keys(ee(r?.edges))]),me=(e,s)=>Me(e,ue(s));function Ye(e){return[...Object.keys(e.acts??{}),...Object.keys(e.kinds).flatMap(s=>Ke(s)),...Pe(ue(e.kinds))]}var V=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function He(e){if(!V(e)||!V(e.kinds))return e;let s;try{let f=Object.fromEntries(Object.entries(e.kinds).map(([z,i])=>[z,V(i)&&V(i.edges)?{edges:i.edges}:{}]));s=Ye({acts:V(e.acts)?e.acts:{},kinds:f})}catch{return e}let r=new Set(s),t=!1,a=f=>{if(typeof f!="string"||r.has(f))return f;let z=Ge(f,s);return z===void 0?f:(t=!0,z)},d=V(e.policy)&&Array.isArray(e.policy.grants)?{...e.policy,grants:e.policy.grants.map(f=>V(f)&&Array.isArray(f.mutations)?{...f,mutations:f.mutations.map(a)}:f)}:void 0,u=V(e.rules)?Object.fromEntries(Object.entries(e.rules).map(([f,z])=>[f,V(z)&&Array.isArray(z.repairs)?{...z,repairs:z.repairs.map(i=>V(i)?{...i,act:a(i.act)}:i)}:z])):void 0;return t?{...e,...d?{policy:d}:{},...u?{rules:u}:{}}:e}function ge(e,s){let r=Ce(e,Ye(s));return r&&r!==e?`did you mean "${r}"?`:void 0}var he="graview-document",be=1,ke=256*1024,te=64*1024,ze=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,ye=/^[a-z][A-Za-z0-9]*$/,zn=new Set(["id","kind"]),yn=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,hn=["string","text","number","integer","boolean","date","datetime","enum","list","url","email","image","video","file","app-link","phone","place","duration"];function bn(){let e=k=>k in Object.prototype,s=Z(k=>!e(k),"every object already has this name \u2014 choose another"),r=(k,N)=>[...k===void 0?[]:[Ee(k)],...N===void 0?[]:[xe(N)]],t=(k,N)=>O().check(...r(k,N)),a=(k,N,gn)=>K(k).check(...r(N,gn)),d=k=>O().check(q(ze,`${k} names are kebab-case, lower-case words joined by hyphens like "tool-note" (field and relation names are camelCase, like "supersededBy")`)),u=O().check(q(yn,'relation names are one camelCase word, like "supersededBy" (kind names are kebab-case, like "tool-note")'),s),f=O().check(q(ye,'field names are one word or camelCase, like "dueDate", so rules say them bare (kind names are kebab-case, like "tool-note")'),Z(k=>!zn.has(k),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),s),z=t(1,500),i=t(1,2e3),o=t(1,300),p=$({type:I(hn),required:n(_()),description:n(z),label:n(t(1,60)),options:n(a(t(1,80),1,100)),of:n(I(["string","number","date","image","video","file"])),default:n(U()),unit:n(t(void 0,12)),format:n(I(["money","percent","duration","markdown"])),min:n(C()),max:n(C()),step:n(C()),renamedFrom:n(O().check(q(ye))),repeats:n(_()),collaborative:n(_())}).check(Re((k,N)=>{k.type==="enum"&&!k.options&&N.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),k.type!=="enum"&&k.options&&N.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),k.type!=="list"&&k.of&&N.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]}),k.repeats&&k.type!=="date"&&k.type!=="datetime"&&N.addIssue({code:"custom",message:'"repeats" belongs only on a date or datetime field',path:["repeats"]})})),w=O().check(q(new RegExp(`${ze.source}|${Fe.source}`),'a relation goes to a kind of this document, like "house", or of another app, like "@nick/house/house"')),m=$({to:x([a(w,1),P("*")]),cardinality:n(I(["one","many"])),description:n(z),inverse:n(t(1,80)),appendOnly:n(_()),renamedFrom:n(O()),tidying:n(P("never"))}),l=x([i,$({expr:i,label:n(t(1,60)),description:n(z)})]),c=$({noun:n(t(1,40)),plural:n(t(1,40)),description:n(z),fields:E(f,p).check(Z(k=>Object.keys(k).length>0,"a kind has at least one field")),label:n(o),describe:n(o),lifecycle:n($({field:f,retired:a(x([O(),C(),_()]),1)})),figure:n(t(void 0,2e4)),glance:n(a(f,1,20)),page:n($({fields:n(a(f,1,40)),groups:n(a($({title:t(1,60),fields:a(f,1,40)}),1,12))})),edges:n(E(u,m)),computed:n(E(O(),l).check(Z(k=>Object.keys(k).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:n(E(O(),O())),renamedFrom:n(O().check(q(ze))),people:n(_()),archives:n(P(!1)),tidying:n(I(["never","no-links"]))}),j=x([O(),C(),_(),Ae(),K(U()),$({expr:i})]),h=O().check(q(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),S=x([$({create:d("kind"),as:n(O().check(q(ye))),set:n(E(f,j))}),$({set:E(f,j),target:n(h)}),$({connect:u,from:h,to:h}),$({sever:u,from:h,to:h}),$({remove:h})]),A=$({title:n(t(1,80)),description:n(z),fromTheOtherEnd:n(t(1,80)),on:n(x([d("kind"),a(d("kind"),1)])),creates:n(d("kind")),sets:n(E(f,j)),writes:n(a(f,1)),connects:n(u),severs:n(u),setsOther:n(E(f,j)),replaces:n(x([P(!0),a(u,1,10)])),removes:n(P(!0)),args:n(E(f,p)),effects:n(a(S,1,20)),allowedWhen:n(i),refusal:n(o),destructive:n(_())}),b=$({act:d("act"),label:n(t(1,80)),args:n(E(O(),j))}),G=$({title:n(t(1,120)),description:n(z),over:x([P("graph"),d("kind")]),when:n(i),require:i,says:n(o),repairs:n(a(b,void 0,10))}),F=$({roles:x([a(d("role"),1),P("*")]),mutations:x([a(d("act"),1),P("*")]),kinds:n(x([K(d("kind")),P("*")])),describe:n(z),self:n(_()),ownEnd:n(_())}),g=n(a(d("field"),1)),v=$({roles:x([a(d("role"),1),P("*")]),kinds:a(d("kind"),1),own:n(_()),via:n(u),fields:g,hide:g}),D=$({grants:K(F),sees:n(K(v))}),oe=$({accent:n(O().check(q(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),name:n(t(1,60)),currency:n(O().check(q(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:n(t(2,35)),timeZone:n(t(1,64)),logo:n(x([t(1,te),$({src:t(1,te),alt:n(t(1,120))}),$({light:t(1,te),dark:n(t(1,te)),alt:n(t(1,120)),darkFallback:n(P("invert"))})])),favicon:n(x([t(1,te),$({emoji:O()})])),typography:n($({display:n(t(1,200)),body:n(t(1,200)),mono:n(t(1,200))})),shape:n($({radius:n(C().check(L(0),W(32))),density:n(C().check(L(.75),W(1.5)))})),accents:n(E(O(),C().check(L(0),W(360)))),scheme:n(I(["light","dark","auto"])),subtitle:n(P(!1))}),B=E(O(),U()),Y=x([t(1,120),$({by:t(1,120),direction:n(I(["asc","desc"]))})]),je=C().check(X(),L(1),W(9999)),dn=Q({create:n(_()),options:n(Q({sort:n(Y),columnSort:n(Y),search:n(a(t(1,120),void 0,40)),filters:n(a(t(1,120),void 0,40)),horizon:n(x([C().check(X(),L(1),W(200)),Q({years:C().check(X(),L(1),W(200)),title:t(1,80),from:n(je),to:n(je)})]))}))}),ln=$({card:n(K(U())),row:n(K(U())),page:n(K(U()))}),pn=()=>{let k=n(I(["asc","desc"]));return x([t(1,120),$({by:t(1,120),direction:k,then:n(x([t(1,120),$({by:t(1,120),direction:k})]))})])},fn=()=>x([t(1,120),$({by:t(1,120),order:n(a(t(1,80),void 0,40)),closed:n(a(t(1,80),void 0,40))})]),Oe=Q({order:n(K(O())),hide:n(K(O())),first:n(O()),primary:n(a(t(1,80),void 0,40)),scene:n(t(1,40)),pages:n(t(1,40)),lists:n(E(O(),$({filters:n(a(t(1,120),void 0,40)),sort:n(pn()),group:n(fn())})))}),un=$({act:d("act"),title:n(t(1,80)),intro:n(z),fields:n(a(f,1,40)),say:n(z),submit:n(t(1,80)),role:n(d("role"))}),mn=$({$schema:n(O()),format:P(he),formatVersion:P(be),name:t(1,80),description:n(z),version:n(C().check(X(),L(1))),kinds:E(d("kind"),c).check(Z(k=>Object.keys(k).length>0,"a document declares at least one kind"),Z(k=>Object.keys(k).length<=40,"a document declares at most 40 kinds")),computed:n(E(O(),l)),acts:n(E(d("act"),A)),rules:n(E(d("rule"),G)),roles:n(K(d("role"))),policy:n(D),modules:n(B),lenses:n(K(dn)),pages:n(Oe),views:n(E(O(),x([ln,K(U())]))),brand:n(oe),settings:n(K(B)),migrations:n(K(B)),connections:n(E(d("connection"),B)),forms:n(E(d("form"),un)),publishing:n($({mode:I(["live","on-publish"]),working:a(d("role"),void 0,40),publishers:n(a(d("role"),1,40))}))});return{FieldSpec:p,EdgeSpec:m,ComputedSpec:l,KindSpec:c,ValueSpec:j,EffectSpec:S,ActSpec:A,RepairSpec:b,RuleSpec:G,GrantSpec:F,SightSpec:v,PolicySpec:D,BrandSpec:oe,PagesSpec:Oe,DocumentSpec:mn}}var kn,T=()=>kn??=bn(),_n=M(()=>T().FieldSpec),Nn=M(()=>T().EdgeSpec),qn=M(()=>T().ComputedSpec),In=M(()=>T().KindSpec),Vn=M(()=>T().ValueSpec),Bn=M(()=>T().EffectSpec),Ln=M(()=>T().ActSpec),Un=M(()=>T().RepairSpec),Wn=M(()=>T().RuleSpec),Zn=M(()=>T().GrantSpec),Yn=M(()=>T().SightSpec),Hn=M(()=>T().PolicySpec),Jn=M(()=>T().BrandSpec),Xn=M(()=>T().PagesSpec),Je=M(()=>T().DocumentSpec);var $n={};function Xe(e,s=$n,r=be){let{document:t,respelled:a}=ve(e),d=a.length>0?{respelled:a}:{};if(!t||typeof t!="object"||Array.isArray(t))return{document:t};let u=t;if(u.format!==he||typeof u.formatVersion!="number"||u.formatVersion>=r)return{document:t,...d};let f=u.formatVersion,z=structuredClone(u);for(let i=f;i<r;i++){let o=s[i];if(!o)throw new Error(`there is no upgrade from format ${i} to ${i+1}`);z={...o(z),formatVersion:i+1}}return{document:z,from:f,...d}}function Qe(e,s,r){let t=Object.keys(e).filter(f=>e[f].edges?.[s]!==void 0);if(t.length===0)return;let a=t.map(f=>e[f].edges[s].to),d=a.some(f=>f==="*")?"*":[...new Set(a.flatMap(f=>f))];if(r.length===0||r.some(f=>t.includes(f)))return{reversed:!1,kinds:d};let u=t.filter(f=>{let z=e[f].edges[s].to;return z==="*"||r.every(i=>z.includes(i))});return u.length>0?{reversed:!0,kinds:u}:{reversed:!1,kinds:d}}var tn=(e,s)=>{let r=e?.fields[s];return r!==void 0&&(r.type==="duration"||(r.type==="number"||r.type==="integer")&&r.format==="duration")};function en(e,s,r,t){if(t==="out"){let a=e[s]?.edges?.[r]?.to;return a===void 0?[]:a==="*"?Object.keys(e):a}return Object.entries(e).filter(([,a])=>{let d=a.edges?.[r]?.to;return d!==void 0&&(d==="*"||d.includes(s))}).map(([a])=>a)}function $e(e,s,r){if(r.t==="ident")return e[s]?.edges?.[r.name]?en(e,s,r.name,"out"):void 0;if(r.t==="where")return $e(e,s,r.set);if(r.t==="call"&&(r.fn==="out"||r.fn==="in")&&r.args[0]?.t==="lit"&&typeof r.args[0].value=="string")return en(e,s,r.args[0].value,r.fn)}var nn=(e,s,r)=>{let t=s.filter(a=>e[a]?.fields[r]!==void 0);return t.length>0&&t.every(a=>tn(e[a],r))};function on(e,s,r){let t=e.kinds,a=t[s],d=new Map(r),u=new Map,f=(i,o)=>{if(o>8)return!1;switch(i.t){case"ident":return tn(a,i.name)||z(i.name,o+1);case"member":{let p=$e(t,s,i.object);return p!==void 0&&nn(t,p,i.name)}case"call":{if(i.fn!=="sum"&&i.fn!=="min"&&i.fn!=="max")return!1;let[p,w]=i.args,m=p&&$e(t,s,p);return m!==void 0&&w?.t==="ident"&&nn(t,m,w.name)}case"binary":return(i.op==="+"||i.op==="-")&&f(i.left,o)&&f(i.right,o);case"unary":return i.op==="-"&&f(i.operand,o);default:return!1}},z=(i,o)=>{if(a?.computed?.[i]===void 0)return!1;if(u.has(i))return u.get(i);u.set(i,!1);let p=d.get(i),w=p!==void 0&&f(p,o);return u.set(i,w),w};return r.map(([i])=>i).filter(i=>z(i,0))}function sn(e,s,r=`kinds.${e}.page`){let t=s.page;if(!t)return[];let a=[],d=[...Object.keys(s.fields),...Object.keys(s.computed??{})],u=new Set,f=(i,o)=>{d.includes(i)?u.has(i)&&a.push(y("page-field-twice",o,`"${i}" is on ${e}'s page twice; name each field once`)):a.push(y("page-field",o,`${e}'s page is to show "${i}", and ${e} has no field or computed field called that`,`use one of: ${d.join(", ")}`)),u.add(i)};(t.fields??[]).forEach((i,o)=>f(i,`${r}.fields.${o}`));let z=new Set;return(t.groups??[]).forEach((i,o)=>{let p=i.title.trim().toLowerCase();z.has(p)&&a.push(y("page-group-twice",`${r}.groups.${o}.title`,`${e}'s page has two groups called "${i.title}"; give each its own title`)),z.add(p),i.fields.forEach((w,m)=>f(w,`${r}.groups.${o}.fields.${m}`))}),a}function rn(e,s=[]){return Te({declared:Object.keys(e.fields),paged:[...e.page?.fields??[],...(e.page?.groups??[]).flatMap(r=>r.fields)],must:r=>!!e.fields[r].required&&e.fields[r].default===void 0,naming:s})}var wn=new Set(["subject","now","today","me"]);function Sn(e){if((typeof e=="string"?e:JSON.stringify(e??null)).length>ke)return{findings:[y("too-large","",`a document may be at most ${ke/1024} KB`)]};if(typeof e=="string")try{e=JSON.parse(e)}catch(t){return{findings:[y("not-json","",`this is not JSON: ${t.message}`)]}}try{e=Xe(e).document}catch(t){return{findings:[y("format","formatVersion",t.message)]}}e=He(e);let s=Je.safeParse(e);if(!s.success)return{findings:s.error.issues.map(t=>{let a=t.path.map(String).join(".");if(t.code==="unrecognized_keys")return y("unknown-key",a,`${t.keys.map(d=>`"${d}"`).join(", ")} ${t.keys.length===1?"is":"are"} not part of a Graview document here`,"check the spelling against docs/declaration-document.md");if(t.code==="invalid_union"&&/\.effects\.\d+$/.test(a))return y("effect-shape",a,"this effect is not one Graview knows",'an effect is one of {"create": kind, "as"?: name, "set"?: {field: value}}, {"set": {field: value, \u2026}, "target"?: "$ref"}, {"connect"|"sever": relation, "from": "$ref", "to": "$ref"}, {"remove": "$ref"}');if(t.code==="invalid_key"){let d=t.issues?.[0]?.message;return y("shape",a,`the name "${String(t.path.at(-1))}" is not allowed here${d?`: ${d}`:""}`)}return y("shape",a,t.message)})};let r=s.data;return{document:r,findings:jn(r)}}var ae=e=>[e??[]].flat();function an(e){let s=new Map;for(let[r,t]of Object.entries(e.kinds))for(let[a,d]of Object.entries(ee(t.edges))){let u=s.get(a);s.set(a,{name:a,from:[...u?.from??[],r],to:d.to==="*"||u?.to==="*"?"*":[...new Set([...u?.to??[],...d.to])],cardinality:d.cardinality??"many"})}return s}function Et(e){let s=new Map;for(let[t,a]of Object.entries(e.kinds)){let d=ne(a),u=ce(a.edges);s.set(t,{fields:new Set([...Object.keys(a.fields),...u.keys()]),edges:new Map(Object.entries(ee(a.edges)).map(([f,z])=>[f,z.cardinality??"many"])),...d?{computed:d}:{},...u.size>0?{linked:u}:{}})}let r=ne(e);return r&&s.set(_e,{computed:r}),s}function cn(e,s){let r=[],t=ae(e.on),a=(d,u)=>{let f=Qe(s.kinds,d,t)?.reversed===!0,[z,i]=f?["$to","$subject"]:["$subject","$to"];return u==="connect"?{connect:d,from:z,to:i}:{sever:d,from:z,to:i}};if(e.creates){let d=s.kinds[e.creates],u={};for(let f of Object.keys(d?.fields??{}))u[f]=`$${f}`;for(let f of e.effects??[])"set"in f&&!("create"in f)&&R(f.target)==="new"&&Object.assign(u,f.set);r.push({create:e.creates,as:"new",set:u})}return e.sets&&r.push({set:e.sets}),e.writes&&!(e.creates&&e.on===void 0)&&r.push({set:Object.fromEntries(e.writes.map(d=>[d,`$${d}`]))}),e.connects&&(e.replaces&&r.push({replace:e.replaces===!0?[e.connects]:[...e.replaces],keep:e.connects}),r.push(a(e.connects,"connect"))),e.severs&&r.push(a(e.severs,"sever")),e.setsOther&&(e.connects||e.severs)&&r.push({set:e.setsOther,target:"$to"}),e.removes&&r.push({remove:"$subject"}),e.effects&&r.push(...e.effects.filter(d=>!(e.creates&&"set"in d&&!("create"in d)&&R(d.target)==="new"))),r}function we(e,s,r){try{let t=H(e),a=se(t);for(let d of a.unknownFunctions)r.push(y("unknown-function",s,`"${d}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));return t}catch(t){if(t instanceof ie){r.push(y("expression",s,t.sentence+` (at character ${t.at+1})`));return}throw t}}function Se(e,s,r){try{return J(e)}catch(t){if(t instanceof Be||t instanceof ie){r.push(y("template",s,(t instanceof ie,t.sentence)));return}throw t}}function jn(e){let s=[],r=new Set(Object.keys(e.kinds)),t=an(e),a=e.acts??{},d=new Set(e.roles??[]),u=(i,o)=>ce(e.kinds[i]?.edges).has(o),f=i=>Object.keys(e.kinds).some(o=>u(o,i));for(let[i,o]of Object.entries(e.kinds)){let p=`kinds.${i}`;for(let[m,l]of Object.entries(o.edges??{})){if(!De(l)&&l.to!=="*")for(let c of l.to)r.has(c)||s.push(y("edge-target",`${p}.edges.${m}.to`,`"${c}" is not a kind this document declares`));o.fields[m]&&s.push(y("edge-field-clash",`${p}.edges.${m}`,`"${m}" is both a field and a relation of ${i}`,"rename one of them"))}o.lifecycle&&!o.fields[o.lifecycle.field]&&s.push(y("lifecycle-field",`${p}.lifecycle.field`,`${i} has no field "${o.lifecycle.field}"`));let w=m=>o.computed!==void 0&&Object.hasOwn(o.computed,m);for(let m of o.glance??[])!o.fields[m]&&!w(m)&&s.push(y("glance-field",`${p}.glance`,`a glance at ${i} is to say "${m}", and ${i} has no field or computed field called that`,`use one of: ${[...Object.keys(o.fields),...Object.keys(o.computed??{})].join(", ")}`));s.push(...sn(i,o));for(let m of["label","describe"]){let l=o[m];if(!l)continue;let c=Se(l,`${p}.${m}`,s);for(let j of c??[])if(j.expr){for(let h of se(j.expr).names)if(!o.fields[h]){if(w(h)){Ze(o,h)||s.push(y("template-field",`${p}.${m}`,`${i}'s ${h} is worked out from beyond the record, and a ${m} is said with no graph to read`,`show it in a view instead, or name a computed field worked out from ${i}'s own fields`));continue}s.push(y("template-field",`${p}.${m}`,`${i} has no field "${h}" for its ${m} to show`,m==="label"?"a label can only show the record's own fields and what they work out":void 0))}}}for(let[m,l]of Object.entries(o.fields)){l.default!==void 0&&l.type==="enum"&&!l.options?.includes(String(l.default))&&s.push(y("default-option",`${p}.fields.${m}.default`,`"${String(l.default)}" is not one of ${m}'s options`));let c=`${m}Repeat`;l.repeats&&(o.fields[c]||o.edges?.[c]||o.computed?.[c])&&s.push(y("repeat-clash",`${p}.fields.${m}.repeats`,`${i} already has "${c}", where how ${m} repeats is kept`))}}for(let[i,o]of Object.entries(a)){let p=`acts.${i}`;for(let c of ae(o.on))r.has(c)||s.push(y("act-kind",`${p}.on`,`"${c}" is not a kind this document declares`));let w=ae(o.on),m=cn(o,e);if(o.creates&&o.on===void 0&&o.writes&&r.has(o.creates)){for(let c of o.writes)if(!e.kinds[o.creates].fields[c])if(e.kinds[o.creates].computed?.[c]!==void 0)s.push(y("computed-written",`${p}.writes`,`${o.creates}'s ${c} is worked out, not written: no act can set it`,"write the stored fields it is worked out from"));else{if(u(o.creates,c))continue;s.push(y("act-field",`${p}.writes`,`${o.creates} has no field "${c}"`))}}m.length===0&&s.push(y("act-empty",p,`"${i}" does nothing`,"give it effects or a shorthand such as sets or creates"));let l=new Map;m.forEach((c,j)=>{let h=m.length-(o.effects?.length??0),S=o.effects&&j>=h?`${p}.effects.${j-h}`:p;if("create"in c){if(!r.has(c.create))s.push(y("act-kind",`${S}.create`,`"${c.create}" is not a kind this document declares`));else for(let b of Object.keys(c.set??{}))e.kinds[c.create].fields[b]||(e.kinds[c.create].computed?.[b]!==void 0?s.push(y("computed-written",`${S}.set.${b}`,`${c.create}'s ${b} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):s.push(y("act-field",`${S}.set.${b}`,`${c.create} has no field "${b}"`)));c.as&&l.set(c.as,c.create)}else if("connect"in c||"sever"in c){let b="connect"in c?c.connect:c.sever;!t.has(b)&&!f(b)&&s.push(y("act-edge",`${S}.${"connect"in c?"connect":"sever"}`,`"${b}" is not a relation any kind declares`)),R(c.from)==="subject"&&w.length===0&&s.push(y("act-subject",`${p}.on`,`"${i}" acts on "$subject" but does not say which kinds it is "on"`))}else if("set"in c){let b=R(c.target??"$subject"),G=b==="subject"?w:l.has(b??"")?[l.get(b)]:[];b==="subject"&&w.length===0&&s.push(y("act-subject",`${p}.on`,`"${i}" changes "$subject" but does not say which kinds it is "on"`));for(let F of Object.keys(c.set))for(let g of G)if(!(!r.has(g)||e.kinds[g].fields[F]))if(e.kinds[g].computed?.[F]!==void 0)s.push(y("computed-written",`${S}.set.${F}`,`${g}'s ${F} is worked out, not written: no act can set it`,"set the stored fields it is worked out from"));else{if(u(g,F))continue;s.push(y("act-field",`${S}.set.${F}`,`${g} has no field "${F}"`))}}else"remove"in c&&R(c.remove)==="subject"&&w.length===0&&s.push(y("act-subject",`${p}.on`,`"${i}" removes "$subject" but does not say which kinds it is "on"`));("set"in c&&c.set?Object.values(c.set):[]).forEach(b=>{b&&typeof b=="object"&&!Array.isArray(b)&&"expr"in b&&we(b.expr,`${S}.set`,s)})}),o.allowedWhen&&we(o.allowedWhen,`${p}.allowedWhen`,s),o.refusal&&Se(o.refusal,`${p}.refusal`,s)}for(let[i,o]of Object.entries(e.rules??{})){let p=`rules.${i}`;o.over!=="graph"&&!r.has(o.over)&&s.push(y("rule-kind",`${p}.over`,`"${o.over}" is not a kind this document declares`));let w=o.over==="graph"?void 0:e.kinds[o.over];for(let m of["when","require"]){let l=o[m];if(!l)continue;let c=we(l,`${p}.${m}`,s);if(!c)continue;let j=se(c);for(let h of j.names)if(o.over==="graph")s.push(y("rule-name",`${p}.${m}`,`"${h}" means nothing in a rule over the whole graph`,`name a kind in "over", or use all('kind')`));else if(w&&!w.fields[h]&&!w.edges?.[h]&&w.computed?.[h]===void 0){let S=Object.keys(w.edges??{}).find(A=>A.includes("-")&&A.split("-").includes(h));s.push(y("rule-name",`${p}.${m}`,`${o.over} has no field or relation called "${h}"`,S?`"${S}" reads as a subtraction in a rule; rename the relation to one camelCase word, like "${S.replace(/-([a-z0-9])/g,(A,b)=>b.toUpperCase())}"`:void 0))}for(let h of j.edges)!t.has(h)&&!f(h)&&s.push(y("rule-edge",`${p}.${m}`,`"${h}" is not a relation any kind declares`));for(let h of j.sweeps)r.has(h)?o.over!=="graph"&&s.push(Ne("rule-cost",`${p}.${m}`,`this rule looks at every ${h} for every ${o.over}, which grows slowly as the app grows`,"walk a relation with out()/in() instead of all() where you can")):s.push(y("rule-kind",`${p}.${m}`,`"${h}" is not a kind this document declares`))}o.says&&Se(o.says,`${p}.says`,s),(o.repairs??[]).forEach((m,l)=>{!a[m.act]&&!de(m.act)&&!me(m.act,e.kinds)&&s.push(y("repair-act",`${p}.repairs.${l}.act`,`"${m.act}" is not an act this document declares`,ge(m.act,e)))})}let z=e.policy;return z&&(z.grants.forEach((i,o)=>{if(i.roles!=="*"&&d.size>0)for(let p of i.roles)d.has(p)||s.push(y("grant-role",`policy.grants.${o}.roles`,`"${p}" is not one of the document's roles`));if(i.mutations!=="*")for(let p of i.mutations)!a[p]&&!de(p)&&!me(p,e.kinds)&&s.push(y("grant-act",`policy.grants.${o}.mutations`,`"${p}" is not an act this document declares`,ge(p,e)))}),(z.sees??[]).forEach((i,o)=>{for(let p of i.kinds)r.has(p)||s.push(y("sight-kind",`policy.sees.${o}.kinds`,`"${p}" is not a kind this document declares`));if(i.roles!=="*"&&d.size>0)for(let p of i.roles)d.has(p)||s.push(y("sight-role",`policy.sees.${o}.roles`,`"${p}" is not one of the document's roles`))})),s.push(...We(e)),s}function On(e){return e.label?[...e.label.matchAll(/\{\s*([A-Za-z_][A-Za-z0-9_]*)/g)].map(s=>s[1]):[fe(e)??[]].flat()}function vn(e,s,r,t){let a=new Map,d=ae(e.on),u=new Map,f=new Map;(d.length>0||s.some(l=>"remove"in l&&R(l.remove)==="subject"||"from"in l&&(R(l.from)==="subject"||R(l.to)==="subject")||"set"in l&&!("create"in l)&&R(l.target??"$subject")==="subject"))&&a.set(pe,{ref:d.length>0?d:"*",required:!0});let i=e.args??{},o=e.writes?.length===1,p=(l,c)=>c&&l.type===c.type&&l.min===void 0&&l.max===void 0&&l.step===void 0?{...l,...c.min===void 0?{}:{min:c.min},...c.max===void 0?{}:{max:c.max},...c.step===void 0?{}:{step:c.step}}:l,w=(l,c)=>c&&l.type===c.type&&l.format===void 0&&l.unit===void 0?{...p(l,c),...c.format?{format:c.format}:{},...c.unit?{unit:c.unit}:{}}:p(l,c),m=(l,c,j)=>{if(l===pe||wn.has(l)||u.has(l)||a.has(l))return;let h=i[l]?w(i[l],j):void 0;a.set(l,h?{field:h,optional:!h.required,required:!!h.required}:c())};for(let l of s)if("create"in l){let c=r.kinds[l.create],j=c?rn(c,On(c)):[],h=S=>j.includes(S)?j.indexOf(S):j.length;for(let[S,A]of Object.entries(l.set??{}).sort(([b],[G])=>h(b)-h(G))){let b=R(A),G=c?.fields[S];if(b&&G){let F=!!G.required&&G.default===void 0;m(b,()=>({field:G,optional:!F,required:F}),G)}}l.as&&u.set(l.as,l.create)}else if("connect"in l||"sever"in l){let c=t.get("connect"in l?l.connect:l.sever);for(let[j,h]of[["from",l.from],["to",l.to]]){let S=R(h);if(!S)continue;let A=j==="to"?c?.to??"*":c?.from??"*";A!=="*"&&!f.has(S)&&f.set(S,A),m(S,()=>({ref:A,required:!0}))}}else if("set"in l){let c=R(l.target??"$subject"),j=c==="subject"?d[0]:u.get(c??"")??f.get(c??"")?.[0];c&&c!=="subject"&&!u.has(c)&&m(c,()=>({ref:"*",required:!0}));for(let[h,S]of Object.entries(l.set)){let A=R(S);if(!A)continue;let b=j?r.kinds[j]?.fields[h]:void 0;m(A,()=>b?{field:b,optional:!o,required:o}:{any:!0,required:!1},b)}}else if("remove"in l){let c=R(l.remove);c&&m(c,()=>({ref:"*",required:!0}))}for(let[l,c]of Object.entries(i))a.has(l)||a.set(l,{field:c,optional:!c.required,required:!!c.required});return a}function At(e,s={}){let r=Sn(e);if(!r.document||le(r.findings))return{ok:!1,findings:r.findings};let t=r.document,a=[...r.findings];s.previous&&a.push(...En(t,s.previous));let d=xn(t,a);return le(d.findings)?{ok:!1,findings:d.findings}:Ve(d,s)}function re(e,s){return e.map(r=>{let t=!r.format&&r.expr?.t==="ident"?s?.[r.expr.name]?.format:void 0;return t==="money"||t==="percent"?{...r,format:t}:r})}function xn(e,s){let r=an(e),t={};for(let[i,o]of Object.entries(e.kinds)){let p=fe(o),w=o.label??(p?`{${p}}`:void 0),m=ne(o),l=m?on(e,i,[...m]):[];t[i]={...w?{label:re(J(w),o.fields)}:{},...o.describe?{describe:re(J(o.describe),o.fields)}:{},...m?{computed:[...m]}:{},...l.length>0?{durations:l}:{}}}let a={};for(let[i,o]of Object.entries(e.acts??{})){let p=cn(o,e),w=vn(o,p,e,r),m=o.destructive??p.some(g=>"remove"in g||"sever"in g||"replace"in g),l=[...new Set(p.flatMap(g=>"create"in g?[g.create]:[]))],c=[...new Set(p.flatMap(g=>"connect"in g?[g.connect]:[]))],j=[...new Set(p.flatMap(g=>"sever"in g?[g.sever]:"replace"in g?g.replace:[]))],h=[...new Set(p.flatMap(g=>"set"in g&&!("create"in g)&&R(g.target??"$subject")==="subject"?Object.keys(g.set):[]))],S=new Map;for(let g of p){if(!("connect"in g)&&!("sever"in g))continue;let v=r.get("connect"in g?g.connect:g.sever);for(let[D,oe]of[["from",g.from],["to",g.to]]){let B=R(oe),Y=D==="to"?v?.to:v?.from;B&&B!=="subject"&&Y&&Y!=="*"&&S.set(B,[...new Set([...S.get(B)??[],...Y])])}}let A={};for(let g of p){if(!("set"in g)||"create"in g)continue;let v=R(g.target??"$subject");for(let D of v&&v!=="subject"&&S.get(v)||[])A[D]=[...new Set([...A[D]??[],...Object.keys(g.set)])]}let b={};for(let g of p)if(!(!("set"in g)||"create"in g||R(g.target??"$subject")!=="subject"))for(let[v,D]of Object.entries(g.set??{}))typeof D=="string"&&R(D)===void 0||typeof D=="number"||typeof D=="boolean"?b[v]=typeof D=="string"&&D.startsWith("$$")?D.slice(1):D:delete b[v];let G=l.length===0&&p.every(g=>!("set"in g)||!g.set||Object.values(g.set).every(v=>!(v&&typeof v=="object"&&!Array.isArray(v)&&"expr"in v))),F=new Map;for(let g of p)if(!(!("set"in g)||!g.set))for(let v of Object.values(g.set))v&&typeof v=="object"&&!Array.isArray(v)&&"expr"in v&&F.set(v.expr,H(v.expr));a[i]={title:o.title??i.replace(/-/g," "),effects:p,args:[...w],...o.allowedWhen?{guard:H(o.allowedWhen)}:{},...o.refusal?{refusal:re(J(o.refusal),e.kinds[[o.on??[]].flat()[0]??""]?.fields)}:{},exprs:[...F],destructive:m,idempotent:G,creates:l,connects:c,severs:j,writes:h,writesOther:A,sets:b}}let d={};for(let[i,o]of Object.entries(e.rules??{}))d[i]={title:o.title??i.replace(/-/g," "),require:H(o.require),...o.when?{when:H(o.when)}:{},...o.says?{says:re(J(o.says),e.kinds[o.over]?.fields)}:{}};let u=qe(e,s),f=Le(e),z=Ue(e);return{format:Ie,document:e,findings:s,kinds:t,...e.computed?{facts:[...ne(e)??[]]}:{},edges:[...r].map(([i,{from:o,to:p,cardinality:w}])=>[i,{from:o,to:p,cardinality:w}]),acts:a,rules:d,brand:u,...Object.keys(f).length>0?{viewSpecs:f}:{},...z?{home:z}:{}}}function Rt(e,s,r){let t=/^defineNode\("([^"]+)"\)/.exec(s)?.[1],a=t?r.kinds[t]:void 0;if(!t||!a)return e;let d=Object.keys(a.fields).filter(u=>u!=="label").slice(0,3);return{...e,path:`kinds.${t}.glance`,fix:`Say which: "glance": [${d.map(u=>`"${u}"`).join(", ")}] on kinds.${t} \u2014 the facts a person compares one by, at a glance.`}}function En(e,s){let r=[],t=new Set(Object.values(s.kinds).flatMap(a=>Object.keys(a.edges??{})));for(let[a,d]of Object.entries(e.kinds)){let u=d.renamedFrom;u&&!s.kinds[u]&&r.push(y("renamed-from-nothing",`kinds.${a}.renamedFrom`,`${a} says it was ${u}, and the previous version has no kind called ${u}`,"name the kind it was, or drop renamedFrom"));let f=s.kinds[u??a];for(let[z,i]of Object.entries(d.fields)){let o=i.renamedFrom;o&&!f?.fields[o]&&r.push(y("renamed-from-nothing",`kinds.${a}.fields.${z}.renamedFrom`,`${z} says it was ${o}, and the previous ${u??a} has no field called ${o}`,"name the field it was, or drop renamedFrom"))}for(let[z,i]of Object.entries(d.edges??{})){let o=i.renamedFrom;o&&!t.has(o)&&r.push(y("renamed-from-nothing",`kinds.${a}.edges.${z}.renamedFrom`,`${z} says it was ${o}, and the previous version has no relation called ${o}`,"name the relation it was, or drop renamedFrom"))}}return r}export{Sn as a,Et as b,cn as c,At as d,Rt as e};
@@ -0,0 +1,18 @@
1
+ var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{A as zt,B as Re,C as ri,D as Ze,E as fe,F as Wn,G as De,H as Ue,I as ii,J as Kn,K as Le,L as oi,M as si,N as H,O as pt,P as wt,Q as li,R as vt,S as Qt,T as di,U as te,V as Zt,W as ie,X as Bn,a as V,b as ve,c as z,d as jt,e as Hn,f as In,g as ct,h as J,i as we,j as re,k as C,l as ee,m as U,n as qe,o as Se,p as _t,q as ke,r as ce,s as ti,t as ht,u as ni,v as Fn,w as Dn,x as Q,y as Fe,z as ai}from"./chunk.IE4ZJQV3.js";import{a as Qe,b as Yt,d as Z}from"./chunk.TVWN5I4M.js";import{a as Ie}from"./chunk.B7LBG4UP.js";import{b as Nn,c as Jr,d as ei}from"./chunk.7G4M2PX3.js";import{a as Qr,d as Zr,e as Xr}from"./chunk.UGFDSE37.js";import{a as Ur,c as Vr,f as jr,g as _r,i as zr,j as Yr}from"./chunk.NNUUD26E.js";import{a as Ut,b as Vt}from"./chunk.PXQVXBNG.js";import{a as Nr,b as Hr,c as Ir,d as On}from"./chunk.OJ64WTLW.js";import{b as Or}from"./chunk.GMAXA5GV.js";import{a as Fr,b as Dr,d as Gt,e as Wr,f as Kr,g as Br,j as qt}from"./chunk.IBJBCZKG.js";import{m as $r}from"./chunk.OPCBZNKF.js";import{a as hr,b as wr,c as vr,e as Tr,f as $n,h as Wt}from"./chunk.2VJ52LGS.js";import{d as br,e as xr,f as Pr,g as Cr,n as Ar,o as Rr,q as Lr,s as Dt}from"./chunk.JI2UVZUU.js";import{a as Ht,b as za,c as Ya,d as It,e as Qa}from"./chunk.CTOBNZLM.js";import{b as ar,c as mr,e as fr,f as Tn}from"./chunk.34HGT7HQ.js";import{a as Ln,b as gr}from"./chunk.TNL2BVCH.js";import{a as Kt,b as Bt,c as Mr,e as Er}from"./chunk.5ON3JSAK.js";import{a as dt,b as pr,e as ur}from"./chunk.3SBTQ66X.js";import{a as Mn}from"./chunk.3TVAE7LE.js";import{a as An,b as tr,c as nr}from"./chunk.JX2C3HVD.js";import{a as yr}from"./chunk.Z7N3MJ36.js";import{c as ir,d as or,e as sr,f as lr,k as yt,l as dr}from"./chunk.GLTWLQ6L.js";import{a as rr}from"./chunk.ACB4TD4W.js";import{r as Rn,s as cr}from"./chunk.OW72XZF4.js";import{b as Za,c as Xa,d as Ja,e as er,l as Ft}from"./chunk.OU5TRY4N.js";import{C as En,K as Gr,N as qr,e as ja,f as _a,j as Zi,u as Sr,v as kr}from"./chunk.GYTVL6GR.js";import{Aa as Nt,G as He,L as Ha,N as Ia,Pa as Va,R as Fa,T as q,U as Cn,X as Da,Y as Wa,aa as Ka,ba as de,ea as Ba,fa as Ga,ha as qa,la as lt,na as Ua,pa as Ot,r as Na,v as Ne}from"./chunk.TMYGLXR6.js";import{a as Oa}from"./chunk.SDO3U72B.js";import{$a as Pa,Dd as Pn,Ed as Ea,J as wa,Jd as $a,Nc as Ta,U as ft,Za as xa,ca as st,da as me,fa as ze,ga as Tt,hc as Aa,ia as Ge,ka as va,la as Sa,lb as bn,ma as Ye,mb as Ca,md as xn,oc as Ra,qc as La,rd as Et,sd as Ma,ud as $t,wb as Mt,xa as ka,ya as ba}from"./chunk.P4CLT32V.js";import{b as I}from"./chunk.AJZBJBMO.js";function ci(e,t,n={}){let a=e.graph.getNode(t);if(!a)return;let r=e.schema.tryDefinition(a.kind),i=l=>me(e.schema.tryDefinition(l.kind),l),d=new Map;for(let l of e.graph.allEdges()){let s=l.from===t?"out":l.to===t?"in":null;if(!s)continue;let c=s==="out"?l.to:l.from,m=e.graph.getNode(c);if(!m)continue;let g=(s==="out"?r:e.schema.tryDefinition(m.kind))?.edges?.[l.kind],u=s==="in"?g?.inverse??g?.description:g?.description,A=`${l.kind}|${s}|${u??""}`;(d.get(A)??(()=>{let G={edgeKind:l.kind,direction:s,...u?{description:u}:{},targets:[]};return d.set(A,G),G})()).targets.push({id:m.id,kind:m.kind,label:i(m)})}return{id:t,kind:a.kind,label:i(a),fields:Ja(yt(e.schema,e.graph,a),r),violations:bn(e.violations(n.context),[t]),actions:Mn(e,[t],{focus:t,...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}}),links:[...d.values()].map(l=>{let s=Za(l.targets.flatMap(c=>{let m=e.graph.getNode(c.id);return m?[m]:[]}),c=>e.schema.tryDefinition(c));return{...l,targets:[...l.targets].map(c=>s.has(c.id)?{...c,apart:s.get(c.id)}:c).sort((c,m)=>c.label.localeCompare(m.label))}})}}function Xe(e,t,n={}){return{kind:t,members:e.graph.nodesOfKind(t),actions:Mn(e,[],{kindSelection:[t],...n.principal?{principal:n.principal}:{},...n.context?{context:n.context}:{}})}}function pi(e,t){let n=(i,d)=>`${i}|${JSON.stringify(d)}`,a=new Map;for(let i of[...e.affordances,...e.withheld]){if(i.provider!=="invariant")continue;let d=n(i.mutation,i.args);a.has(d)||a.set(d,i.rank??Number.MAX_SAFE_INTEGER)}let r=Number.MAX_SAFE_INTEGER;return[...t].map((i,d)=>({repair:i,declared:d})).sort((i,d)=>(a.get(n(i.repair.mutation,i.repair.args??{}))??r)-(a.get(n(d.repair.mutation,d.repair.args??{}))??r)||i.declared-d.declared).map(i=>i.repair)}function Je(e){let t=e.schema.kinds.map(r=>({kind:r,plural:Ge(e.schema,r),count:e.graph.nodesOfKind(r).length})),n=new Map;for(let r of e.graph.allEdges()){let i=e.graph.getNode(r.from),d=e.graph.getNode(r.to);if(!i||!d)continue;let l=`${r.kind}|${i.kind}|${d.kind}`;n.set(l,(n.get(l)??0)+1)}let a=[];for(let{kind:r}of t){let i=e.schema.tryDefinition(r)?.edges??{};for(let[d,l]of Object.entries(i)){let s=l.to==="*"||l.to===void 0?(()=>{let c=[...n.keys()].filter(m=>m.startsWith(`${d}|${r}|`)).map(m=>m.split("|")[2]);return c.length>0?c:["*"]})():l.to;for(let c of s)a.push({edgeKind:d,from:r,to:c,...l.description?{description:l.description}:{},...l.inverse?{inverse:l.inverse}:{},count:n.get(`${d}|${r}|${c}`)??0})}}return{kinds:t,relations:a}}var We=I(He(),1);var St=I(He(),1);var Te=I(q(),1),Ji={problems:"Problems",search:"Search",map:"Connections",places:"Pictures","~draft":"A view drawn"},eo=e=>{try{return decodeURIComponent(e)}catch{return e}};function to(e,t,n={}){let{store:a}=e,r=a.schema,i=(n.base??"").replace(/\/$/,""),[d="/",l=""]=t.split("#")[0].split("?"),s=(b,E,k)=>({label:b,href:`${i}${E}`,path:E,...k?{current:k}:{}}),c=b=>{let E=n.registry?.sectionOf(b);return E?[E.path===void 0?{label:E.label}:s(E.label,E.path)]:[]},m=b=>n.registry?.sectionOf(b)?.label,x=b=>{let E=m(b);return E===void 0?{}:{section:E}},[g,u,...A]=d.split("/").filter(Boolean).map(eo);if(g===void 0)return{as:"home",label:"Home",trail:[s("Home","/",!0)]};if(g==="places"&&u!==void 0&&A.length===0){let b=new URLSearchParams(l).get("of"),E=new Set(Fe(a,e.principal)),k=e.views?.places()??[],P=k.find(K=>E.has(K.kind)&&K.as===u&&(!b||V(r,K.kind)===b));if(P){let K=jt(P.as,Et(P,k)?V(r,P.kind):void 0);return{as:"place",kind:P.kind,label:P.title,...x(P.kind),trail:[...c(P.kind),s(P.title,K,!0)]}}}let N=A.length===0?ve(r,g):void 0;if(N!==void 0){let b=s(Ge(r,N),`/${V(r,N)}`);if(u===void 0)return{as:"list",kind:N,label:b.label,...x(N),trail:[...c(N),{...b,current:!0}]};let E=a.graph.getNode(u),k=E&&E.kind===N?me(r.tryDefinition(N),E):"Nothing lives here";return{as:"record",kind:N,id:u,label:k,...x(N),trail:[...c(N),b,s(k,z(r,N,u),!0)]}}let G=Ji[g]??no((A.at(-1)??u??g).replace(/[-_]+/g," "));return{as:"page",label:G,trail:[s(G,d,!0)]}}var no=e=>e.charAt(0).toUpperCase()+e.slice(1),Gn=(0,St.createContext)(null);function ao(e){let t=fe(),n=Ze("/");return Z(e.context.store),to(e.context,`${t.pathname}${t.search}`,{registry:e.registry,base:n})}var ro={position:"absolute",width:1,height:1,margin:-1,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0},ui={display:"flex",alignItems:"center",gap:6,minWidth:0},gi={display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,lineHeight:"24px"};function ut({context:e,style:t}){let n=(0,St.useContext)(Gn),a=(0,St.useContext)(wt);return vt(a??oo,"trail")||n?.registry?.without().has("trail")?null:(0,Te.jsx)(io,{root:n??{context:e,registry:void 0},context:e,...t?{style:t}:{}})}function io({root:e,context:t,style:n}){let a=ao(e);return a.trail.length<2?null:(0,Te.jsx)(so,{here:a,mark:a.as==="record"?{kind:a.kind,context:t}:void 0,...n?{style:n}:{},"data-testid":"page-trail"})}var oo={count:()=>0,place:()=>()=>{},subscribe:()=>()=>{}};function so({here:e,mark:t,style:n,...a}){let r=e.as==="record"?e.trail.length-2:-1;return(0,Te.jsx)("nav",{"aria-label":"You are here","data-graview-trail":"",style:{minWidth:0,...n},...a,children:(0,Te.jsx)("ol",{style:{...we,listStyle:"none",padding:0,display:"flex",alignItems:"center",gap:6,minWidth:0,overflow:"hidden"},children:e.trail.map((i,d)=>(0,Te.jsxs)("li",{style:i.current?ro:{...ui,flexShrink:d===e.trail.length-2?0:1,maxWidth:"100%"},...i.current?{"aria-current":"page"}:{},children:[d>0&&!i.current?(0,Te.jsx)("span",{"aria-hidden":"true",children:"\u203A"}):null,i.current?i.label:i.path!==void 0?(0,Te.jsxs)(H,{to:i.path,style:{...Se,...ui},...d===r?{"data-testid":"trail-list"}:{},children:[d===r&&t?(0,Te.jsx)(ce,{kind:t.kind,brand:t.context.brand,schema:t.context.store.schema,size:8}):null,(0,Te.jsx)("span",{style:gi,children:i.label})]}):(0,Te.jsx)("span",{style:gi,children:i.label})]},`${d}:${i.label}`))})})}var R=I(q(),1);function $e(e){let t=e.views;if(!t)return[];let n=new Set(Fe(e.store,e.principal));return t.places().filter(a=>n.has(a.kind))}function Xt(e,t){if(!t.over)return[t.kind];let n=new Set(Fe(e.store,e.principal));return t.over.filter(a=>a===t.kind||n.has(a))}var et=e=>`place:${e.kind}:${e.as}`;function ye(e,t){return jt(t.as,Et(t,e.views?.places()??[])?V(e.store.schema,t.kind):void 0)}function kt(e,t){let n=e.schema.tryDefinition(t);return e.graph.nodesOfKind(t).filter(a=>st(n,a))}function qn(e,t,n){let a=(i,d)=>Tt(e.schema,d,i),r=(typeof t=="string"?[t]:t).map(i=>a(kt(e,i).length,i)).join(" and ");return n?`${r} across ${a(kt(e,n).length,n)}`:r}function Un({context:e,place:t,chosen:n,filter:a}){let{store:r,views:i,invariantContext:d}=e,s=i?.resolve(t.kind,{cardinality:"many",fidelity:"full"},t.as)?.view,c=[...new Set(r.violations(d).flatMap(g=>g.nodeIds))],m=Xt(e,t).flatMap(g=>kt(r,g));if(!s)return null;let x=lo(r,m,a,c);return(0,R.jsx)(Rn,{kind:t.kind,view:t.title,children:(0,R.jsx)(s,{nodes:x,label:t.title,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1,...n&&n.length>0?{implicated:n}:{},...c.length>0?{flagged:c}:{}})})}function lo(e,t,n,a){let r=n?$t({filter:n}).filter??[]:[];return r.length===0?t:Wt(t,{filter:r},{schema:e.schema,graph:e.graph,flagged:new Set(a)}).nodes}function co({store:e,views:t,as:n,invariantContext:a}){Z(e);let r={store:e,views:t,...a?{invariantContext:a}:{}},i=t.places().find(d=>d.as===n);return i?(0,R.jsx)(Un,{context:r,place:i}):null}function po({context:e,kind:t}){let{store:n,views:a,invariantContext:r}=e,i=kt(n,t),d=n.schema.tryDefinition(t),l=Q(n,t),c=a?.resolve(t,{cardinality:"many",fidelity:"full"})?.view,m=[...new Set(n.violations(r).flatMap(A=>A.nodeIds))];if(c&&!lt(c))return(0,R.jsx)(Rn,{kind:t,children:(0,R.jsx)(c,{nodes:i,label:l,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1,...m.length>0?{flagged:m}:{}})});let x=a?.resolve(t,{cardinality:"one",fidelity:"summary"})?.view,g=8,u=i.slice(0,g);return(0,R.jsxs)("div",{"data-testid":"kind-sheet",style:x?{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:[u.map(A=>x?(0,R.jsx)(x,{node:A,fidelity:"summary",cardinality:"one",mode:"fullscreen",selected:!1,...m.includes(A.id)?{flagged:[A.id]}:{}},A.id):(0,R.jsx)("span",{style:{padding:"8px 14px",borderRadius:8,border:"1px solid var(--graview-edge-bright)",background:"var(--graview-ground)",color:"var(--graview-ink)"},children:me(d,A)},A.id)),i.length>g?(0,R.jsxs)("span",{style:{...C,alignSelf:"center",padding:"0 6px"},children:["+",i.length-g," more ",l.toLowerCase()]}):null]})}function Vn(e){let{store:t}=e,n=ai(e),a=$e(e),r=e.views?.arrangement?.()?.order??[],i=s=>{let c=s.name===void 0?-1:r.indexOf(`view:${s.name}`);return c>=0?c-r.length:n.indexOf(s.kind)},d=xn([...a].sort((s,c)=>i(s)-i(c))).filter(s=>!s.hidden),l=new Set(d.flatMap(s=>s.over??[s.kind]));return[...d.map(s=>({key:et(s),kind:s.kind,title:Ma(s,a,t.schema),to:ye(e,s),place:s})),...zt(e).filter(s=>!l.has(s)).map(s=>({key:`kind:${s}`,kind:s,title:Q(t,s),to:`/${V(t.schema,s)}`}))]}var mi=.72,uo=540,fi=16/10;function go(e){let t=(0,We.useRef)(null),[n,a]=(0,We.useState)(e);return(0,We.useLayoutEffect)(()=>{let r=t.current;if(!r||typeof ResizeObserver>"u")return;let i=()=>{let l=r.getBoundingClientRect().width;l>0&&a(s=>Math.abs(s-l)<.5?s:l)};i();let d=new ResizeObserver(i);return d.observe(r),()=>d.disconnect()},[]),{ref:t,width:n}}function mo(e){for(let t=e.parentElement;t;t=t.parentElement)if(/(auto|scroll)/.test(getComputedStyle(t).overflowY))return t;return null}function fo(e){let[t,n]=(0,We.useState)(()=>typeof IntersectionObserver>"u");return(0,We.useLayoutEffect)(()=>{let a=e.current;if(t||!a)return;let r=new IntersectionObserver(i=>{i.some(d=>d.isIntersecting)&&(r.disconnect(),n(!0))},{root:mo(a),rootMargin:"50% 0px"});return r.observe(a),()=>r.disconnect()},[t,e]),t}function jn({context:e,entry:t}){let{store:n,brand:a,principal:r}=e,{ref:i,width:d}=go(uo),l=fo(i),s=d/mi,c=kt(n,t.kind),m=n.schema.tryDefinition(t.kind),x=c.length===0?Xe(n,t.kind,{...r?{principal:r}:{},...e.invariantContext?{context:e.invariantContext}:{}}).actions.affordances[0]:void 0,g=t.place!==void 0;return(0,R.jsxs)(H,{to:t.to,"data-testid":g?"place-card":"kind-card",className:"graview-gallery-card",style:{...Se,display:"grid",gap:10,alignContent:"start",minWidth:0},children:[(0,R.jsxs)("span",{ref:i,"data-testid":g?"place-picture":"kind-picture","aria-hidden":"true",inert:!0,style:{display:"block",position:"relative",width:"100%",aspectRatio:`${fi}`,overflow:"hidden",borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",pointerEvents:"none"},children:[(0,R.jsx)("span",{style:{position:"absolute",left:0,top:0,width:s,height:s/fi,display:"grid",gridTemplateRows:"minmax(0, 1fr)",transform:`scale(${mi})`,transformOrigin:"0 0"},children:l?(0,R.jsx)(Gt.Provider,{value:null,children:t.place?(0,R.jsx)(Un,{context:e,place:t.place}):(0,R.jsx)(po,{context:e,kind:t.kind})}):null}),c.length===0?(0,R.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,R.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,R.jsxs)("span",{style:{fontFamily:In,fontWeight:"var(--graview-weight-display)"},children:["No ",Q(n,t.kind).toLowerCase()," yet"]}),x?(0,R.jsxs)("span",{style:C,children:["Begin with \u201C",x.label,"\u201D"]}):null]})}):null]}),(0,R.jsxs)("span",{style:{display:"grid",gap:2,minWidth:0},children:[(0,R.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[g?null:(0,R.jsx)(ce,{kind:t.kind,brand:a,schema:n.schema,size:8}),(0,R.jsx)("span",{style:{fontFamily:In,fontSize:"var(--graview-text-heading)",fontWeight:"var(--graview-weight-display)",lineHeight:1.3,overflowWrap:"anywhere",textWrap:"balance"},children:t.title})]}),(0,R.jsxs)("span",{style:C,children:[t.place?qn(n,Xt(e,t.place),t.place.across):qn(n,t.kind),!g&&m?.description?` \xB7 ${m.description}`:null]})]})]})}var yi={display:"grid",gap:"32px 28px",gridTemplateColumns:"repeat(auto-fill, minmax(min(420px, 100%), 1fr))"},yo=`
2
+ .graview-gallery-card > span:first-child { transition: border-color 160ms ease, box-shadow 160ms ease; }
3
+ .graview-gallery-card:hover > span:first-child,
4
+ .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); }
5
+ `;function _n({context:e}){Z(e.store);let t=Vn(e);return t.length===0?null:(0,R.jsxs)("section",{style:yi,"data-testid":"gallery",children:[(0,R.jsx)("style",{children:yo}),t.map(n=>(0,R.jsx)(jn,{context:e,entry:n},n.key))]})}function zn({context:e}){let{store:t}=e;Z(t);let n=xn($e(e)).filter(r=>!r.hidden),a=Vn(e);return(0,R.jsxs)(te,{context:e,style:ct,children:[(0,R.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,R.jsx)("p",{style:we,children:n.length===0?"None of its own yet":`${n.length} ${n.length===1?"picture":"pictures"}`}),(0,R.jsx)(ie,{context:e,children:"Pictures"}),(0,R.jsx)("p",{style:re,children:n.length===0?"Nothing here has a picture of its own yet, so each kind is drawn as the scene draws it. Title a group view and it appears here by name.":"The ways this installation looks at what it holds \u2014 each one the same picture the scene shows, here as a page."})]}),a.length>0?(0,R.jsx)("div",{style:yi,"data-testid":"places",children:a.map(r=>(0,R.jsx)(jn,{context:e,entry:r},r.key))}):null]})}var ho={lede:!0},wo={lede:!1},vo={...re,textWrap:"pretty"};function So(e,t){if(t===void 0)return;let[n]=lr(sr([t]),dr(e.store,null,null,e.brand?{money:e.brand}:{}));return n?.t==="headline"&&!n.problem&&n.text.trim()!==""?n.text:void 0}function Yn({context:e}){let{store:t,principal:n}=e;Z(t);let a=Ue(),r=De(),[i]=pt(),d=decodeURIComponent(a.as??""),[l,s]=(0,We.useState)(null),c=i.get("of"),m=i.get("filter"),g=$e(e).find(P=>P.as===d&&(!c||V(t.schema,P.kind)===c));if(!g)return(0,R.jsxs)(te,{context:e,children:[(0,R.jsx)(ie,{context:e,children:"No picture is called that."}),(0,R.jsx)("p",{style:re,children:(0,R.jsx)(H,{to:"/places",style:qe,children:(0,R.jsx)(Qe,{children:"The pictures there are"})})})]});let u=Q(t,g.kind),A=e.views?.resolve(g.kind,{cardinality:"many",fidelity:"full"},g.as)?.view,N=A?.flows===!0,G=A?.creates!==!1,b=So(e,A?.lede),E=Xe(t,g.kind,{...n?{principal:n}:{},...e.invariantContext?{context:e.invariantContext}:{}}),k=G?E.actions.affordances.map(P=>({affordance:P,mutation:t.allMutations().find(K=>K.name===P.mutation)})).filter(P=>P.mutation!==void 0):[];return(0,R.jsxs)(te,{context:e,style:{...ct,gap:"var(--graview-space-6, 32px)"},children:[(0,R.jsxs)("header",{style:{display:"grid",gap:"var(--graview-space-2, 8px)"},children:[(0,R.jsx)(ut,{context:e}),(0,R.jsx)(ie,{context:e,children:g.title}),(0,R.jsx)("p",{style:vo,"data-testid":"place-lede",...b!==void 0?{"data-graview-lede":"headline"}:{},children:b??`${qn(t,Xt(e,g),g.across)}.`}),m&&!N?(0,R.jsxs)("p",{style:{...C,margin:0},"data-testid":"place-narrowed",children:[`Only those where ${m.split(",").map(P=>P.replace(":"," is ")).join(" and ")}. `,(0,R.jsx)(H,{to:`?${(()=>{let P=new URLSearchParams(i);return P.delete("filter"),P.toString()})()}`,style:{...U,...C},children:"Show all"})]}):null,(0,R.jsx)("p",{style:{...C,margin:0,display:"flex",flexWrap:"wrap",gap:"4px 16px"},children:Xt(e,g).map((P,K)=>(0,R.jsx)(H,{to:`/${V(t.schema,P)}`,style:{...qe,...C},...K===0?{"data-testid":"place-as-list"}:{},children:(0,R.jsxs)(Qe,{children:["All ",(P===g.kind?u:Q(t,P)).toLowerCase()," as a list"]})},P))})]}),(0,R.jsx)("div",{"data-testid":"place-lens","data-flows":N?"":void 0,...N?{}:{role:"group","aria-label":g.title,tabIndex:0},style:N?{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",maxWidth:"100%"}:{height:"min(72vh, 760px)",display:"grid",gridTemplateRows:"minmax(0, 1fr)",overflow:"auto",maxWidth:"100%",borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)"},onClick:P=>{let K=P.target?.closest("[data-graview-pick]"),ae=K?.getAttribute("data-graview-pick"),ue=K?.getAttribute("data-graview-joins");if(ue)try{let _=JSON.parse(ue);if(Array.isArray(_)&&_.every(ge=>typeof ge=="string")){P.preventDefault(),s({at:et(g),ids:_});return}}catch{}if(!ae)return;let oe=t.graph.getNode(ae);oe&&(P.preventDefault(),r(z(t.schema,oe.kind,ae)))},children:(0,R.jsx)(Br.Provider,{value:b!==void 0?ho:wo,children:(0,R.jsx)(Un,{context:e,place:g,filter:m,...l?.at===et(g)?{chosen:l.ids}:{}})})}),k.length>0?(0,R.jsx)("div",{style:{maxWidth:760,display:"grid",gap:40},"data-testid":"place-creators",children:k.map(({affordance:P,mutation:K})=>(0,R.jsxs)("section",{style:{...ee,display:"grid",gap:14},children:[(0,R.jsx)("h2",{style:J,children:K.title??K.name}),K.description?(0,R.jsx)("p",{style:{...C,margin:0,maxWidth:"58ch"},children:K.description}):null,(0,R.jsx)(Ie,{store:t,mutation:K,prefilled:P.args,open:P.open,label:P.label,...n?{principal:n}:{}})]},P.id))}):null]})}function ko(e,t=document){let n=Ut(e);if(!n)return null;let a=[t,...[...t.querySelectorAll("[data-worker-view]")].flatMap(r=>r.shadowRoot?[r.shadowRoot]:[])];for(let r of a)for(let i of r.querySelectorAll("[id], [data-section]")){let d=i.getAttribute("data-section")??i.id;if(d===e||Ut(d)===n)return i}for(let r of a)for(let i of r.querySelectorAll("h1, h2, h3, h4, h5, h6, [role=heading]"))if(Ut(i.textContent??"")===n)return i;return null}function hi(e,t={}){if(typeof document>"u"||typeof requestAnimationFrame>"u")return()=>{};let n=t.frames??120,a=0,r=()=>{let i=ko(e,t.root??document);if(i){i.hasAttribute("tabindex")||i.setAttribute("tabindex","-1"),i.scrollIntoView?.({block:"start"}),i.focus({preventScroll:!0});return}n-=1,n>0&&(a=requestAnimationFrame(r))};return a=requestAnimationFrame(()=>{a=requestAnimationFrame(r)}),()=>cancelAnimationFrame(a)}var B=I(He(),1);var Jt=I(He(),1);var tt=I(q(),1);function wi({context:e}){return de()?(0,tt.jsxs)(tt.Fragment,{children:[(0,tt.jsx)(bo,{context:e}),(0,tt.jsx)(Vr,{face:"pages",on:e.quickAsk??!0})]}):null}function bo({context:e}){let{store:t}=e,n=de(),{pathname:a}=fe(),r=(0,Jt.useRef)(n?.setSelection);return r.current=n?.setSelection,(0,Jt.useEffect)(()=>{let i=r.current;if(!i)return;let[,d,l]=a.split("/"),s=(()=>{if(d==="places"){let m=e.views?.places().find(x=>x.as===decodeURIComponent(l??""));return m?[Ne(m.kind)]:[]}let c=d?ve(t.schema,d):void 0;return c&&l?[decodeURIComponent(l)]:c?[Na(c)]:[]})();i(c=>c.length===s.length&&c.every((m,x)=>m===s[x])?c:s)},[a]),null}var be=I(He(),1);var Si=I(Zi(),1);var pe=I(q(),1);var xo=Nt(Oa(()=>(__graviewPreload(import.meta.url,["./chunk.TVWN5I4M.js","./chunk.7G4M2PX3.js","./chunk.UGFDSE37.js","./chunk.NNUUD26E.js","./chunk.OJ64WTLW.js","./chunk.GMAXA5GV.js","./chunk.IBJBCZKG.js","./chunk.NQ26KMSQ.js","./chunk.GJQF7I22.js","./chunk.SPU3BVAO.js","./chunk.OPCBZNKF.js","./chunk.UK5F3S2N.js","./chunk.2VJ52LGS.js","./chunk.JI2UVZUU.js","./chunk.CTOBNZLM.js","./chunk.34HGT7HQ.js","./chunk.TNL2BVCH.js","./chunk.NZDHXREL.js","./chunk.TBSPEO2L.js","./chunk.5ON3JSAK.js","./chunk.3SBTQ66X.js","./chunk.SSAY4ITS.js","./chunk.MB7LKKUD.js","./chunk.WVUJXDXZ.js","./chunk.GLTWLQ6L.js","./chunk.ACB4TD4W.js","./chunk.XCQ7ZPR5.js","./chunk.MY5OXSS7.js","./chunk.NVRK6A7T.js","./chunk.FKJ3HIA5.js","./chunk.GZHZLJBF.js","./chunk.OW72XZF4.js","./chunk.OJGHDWI6.js","./chunk.KRODTMGR.js","./chunk.VICCAWAN.js","./chunk.OU5TRY4N.js","./chunk.CQPNDJAC.js","./chunk.GYTVL6GR.js","./chunk.TMYGLXR6.js","./chunk.SDO3U72B.js","./chunk.P4CLT32V.js","./chunk.SLBWPVIY.js","./chunk.AJZBJBMO.js"]),import("./chunk.HFKGND5Q.js")).then(e=>({default:e.TakeBack}))));function Po({context:e,docked:t,at:n,...a}){let{store:r}=e,i=Z(r),[d]=(0,be.useState)(()=>r.batches().length),l=(0,be.useRef)(!1);return l.current||=i>0||!t&&d>0,l.current?(0,pe.jsx)(be.Suspense,{fallback:null,children:(0,pe.jsx)(xo,{context:e,docked:t,at:n,since:d,...a})}):null}function Co(e,t,n){let{store:a,principal:r,embedded:i}=e;(0,be.useEffect)(()=>{if(!n)return;let d=l=>{if(!Xr(l))return;let s=l.target,c=s instanceof Node&&t.current?.contains(s),m=s===document.body||s===document.documentElement||s===document;if(!(!c&&!(m&&!i))&&Qr(a,r)){l.preventDefault();try{Zr(a,r)}catch{}}};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[a,r,i,t,n])}function ki({context:e,registry:t,root:n,children:a}){let r=(0,be.useMemo)(li,[]),i=t?.without()??new Set;return Co(e,n,!i.has("undo")),(0,pe.jsxs)(wt.Provider,{value:r,children:[(0,pe.jsx)(Ao,{context:e,placed:r,without:i}),a]})}function Ao({context:e,placed:t,without:n}){let[a,r]=(0,be.useState)(!1);(0,be.useLayoutEffect)(()=>r(!0),[]);let i=vt(t,"find"),d=vt(t,"undo"),l=fe(),s=kr();if(!a)return null;let c=l.pathname.split("/").filter(Boolean),x=(c.length===1?ve(e.store.schema,c[0]):void 0)!==void 0;return(0,pe.jsxs)(pe.Fragment,{children:[!i&&!n.has("find")&&s?(0,Si.createPortal)((0,pe.jsx)(vi,{context:e,narrowsLists:x}),s.slot):null,!i&&!n.has("find")&&!s?(0,pe.jsx)("div",{"data-testid":"face-find-bar",style:{display:"flex",alignItems:"center",padding:"8px 16px",borderBottom:"1px solid var(--graview-edge)",background:"var(--graview-bar)",minWidth:0},children:(0,pe.jsx)(vi,{context:e,narrowsLists:x})}):null,!d&&!n.has("undo")?(0,pe.jsx)(Po,{context:e,docked:!0,at:l.pathname+l.search}):null,s?.own&&!n.has("undo")?(0,pe.jsx)(ri,{context:e,own:s.own}):null]})}function vi({context:e,narrowsLists:t}){return(0,pe.jsx)(wt.Provider,{value:null,children:(0,pe.jsx)(Bn,{context:e,narrowsLists:t})})}var X=I(He(),1);var xe=I(q(),1),Ro=500,Lo=10;function en(e){return e instanceof HTMLElement?e.isContentEditable||e.tagName==="TEXTAREA"||e.tagName==="SELECT"?!0:e.tagName==="INPUT"&&!["button","submit","reset","checkbox","radio","image","file","color","range"].includes(e.type):!1}function To(e){let t=typeof getSelection=="function"?getSelection():null;return t!==null&&!t.isCollapsed&&t.containsNode(e,!0)}function bi(e){let t=e.closest('a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])');if(t)return t;let n=document.activeElement;return n instanceof HTMLElement&&n!==document.body?n:null}function xi({context:e,root:t,children:n}){return de()===null?(0,xe.jsx)(xe.Fragment,{children:n}):(0,xe.jsx)(Mo,{context:e,root:t,children:n})}function Mo({context:e,root:t,children:n}){let{setMenuAt:a}=Ka(),{store:r}=e,i=r.schema,d=De(),{pathname:l,search:s}=fe(),c=Ze("/").replace(/\/$/,""),m=(0,X.useCallback)((w,f)=>e.views?.places().find(L=>L.as===w&&(f===null||L.kind===f)),[e.views]),x=(0,X.useCallback)((w,f)=>{let[L="",$,ne]=w.split("/").filter(Boolean).map(p=>{try{return decodeURIComponent(p)}catch{return p}});if(ne!==void 0)return null;if(L==="places"&&$!==void 0){let p=m($,new URLSearchParams(f).get("of"));return p?{face:"pages",place:p.as,about:[Ne(p.kind)],title:p.title}:null}let Y=ve(i,L);return Y?$===void 0?{face:"pages",about:[Ne(Y)],title:Ge(i,Y)}:r.graph.getNode($)?{face:"pages",on:$,about:[$]}:null:null},[i,r,m]),g=(0,X.useCallback)(w=>{let f=w.href;try{let L=new URL(f,location.href);if(L.origin===location.origin&&(c===""||L.pathname===c||L.pathname.startsWith(`${c}/`))){let $=x(L.pathname.slice(c.length),L.search);if($)return{...$,href:f}}}catch{}return{face:"pages",about:[],href:f}},[c,x]),u=(0,X.useCallback)(()=>x(l,s)??{face:"pages",about:[]},[x,l,s]),A=(0,X.useCallback)(w=>{let f=u(),L=w.closest("[data-graview-field]")?.getAttribute("data-graview-field");if(L&&f.on!==void 0&&w.closest("[data-graview-pick], a[href]")===null)return{...f,field:L};let $=w.closest("[data-graview-act]")?.getAttribute("data-graview-act");if($)return{...f,act:$};let ne=w.closest("a[href]"),Y=w.closest("[data-graview-listed]"),p=[w.closest("[data-graview-pick]")?.getAttribute("data-graview-pick"),Y&&(!ne||Y.contains(ne)&&ne.classList.contains("graview-spec-item-link"))?Y.getAttribute("data-graview-listed"):null].map(j=>j?r.graph.getNode(j):void 0).find(Boolean);if(p)return{face:"pages",on:p.id,about:[p.id],href:`${c}${z(i,p.kind,p.id)}`};if(ne)return g(ne);let T=w.closest("[data-graview-record]")?.getAttribute("data-graview-record");return T&&r.graph.getNode(T)?{face:"pages",on:T,about:[T]}:f},[u,g,r,i,c]),N=(0,X.useCallback)(w=>{let f=t.current;if(f===null||!f.contains(w)||en(w)||w.closest("[data-graview-popover]"))return null;let L=A(w);return{face:"pages",on:L.on,about:L.about??[],field:L.field,place:L.place,href:L.href,act:L.act,element:bi(w)}},[A,t]),G=(0,X.useCallback)((w,f,L)=>{let $=A(w);a({...$,x:Math.round(f),y:Math.round(L),returnTo:bi(w)})},[A,a]),b=(0,X.useCallback)(w=>{let f=w.getBoundingClientRect();G(w,f.left+Math.min(16,f.width/2),Math.min(f.bottom,f.top+36))},[G]),E=(0,X.useRef)(0),k=(0,X.useRef)(null),P=(0,X.useRef)(!1),K=()=>{k.current&&clearTimeout(k.current.timer),k.current=null};(0,X.useEffect)(()=>K,[]),(0,X.useEffect)(()=>{let w=f=>{if(f.defaultPrevented||!(f.key==="ContextMenu"||f.key==="F10"&&f.shiftKey))return;let L=t.current,$=f.target instanceof Element?f.target:null,ne=$===null||$===document.body||$===document.documentElement,Y=L!==null&&$!==null&&L.contains($);if(!Y&&!(ne&&document.querySelector("[data-graview-face='pages']")===L)||en($)||$?.closest("[data-graview-popover]"))return;f.preventDefault(),E.current=Date.now();let p=Y&&$ instanceof HTMLElement?$:L?.querySelector("[data-graview-page-title], main h1, main")??null;p&&b(p)};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[t,b]),(0,X.useEffect)(()=>{let w=t.current;if(!w)return;let f=L=>{let $=L.detail;$&&a({...$,face:"pages"})};return w.addEventListener(Cn,f),()=>w.removeEventListener(Cn,f)},[t,a]);let ae=(0,X.useMemo)(()=>w=>{if(w.face!=="pages")return null;let f=[],L=w.on===void 0?void 0:r.graph.getNode(w.on),$=w.place===void 0?void 0:e.views?.places().find(se=>se.as===w.place),ne=L?void 0:w.about.length===1&&w.about[0].startsWith("aggregate:")&&!$?Eo(w.about[0]):void 0,Y=L?z(i,L.kind,L.id):$?ye(e,$):ne?`/${V(i,ne)}`:void 0,p=Y!==void 0&&l===Y.split("?")[0];Y!==void 0&&!p&&f.push({id:"open",label:"Open",run:()=>d(Y)});let T=Y!==void 0?`${c}${Y}`:w.href;T!==void 0&&f.push({id:"open-in-a-new-tab",label:"Open in a new tab",run:()=>void window.open(T,"_blank","noopener")});let j=L?`#focus=${encodeURIComponent(L.id)}`:$?`#focus=${encodeURIComponent(Ne($.kind))}&view=${encodeURIComponent($.as)}`:ne?`#focus=${encodeURIComponent(Ne(ne))}`:void 0;if(j!==void 0&&(e.overview||!e.embedded)){let se=e.overview;f.push({id:"in-the-scene",label:"Show in the scene",run:()=>se?se(j):location.assign(`${e.sceneHref??"/"}${j}`)})}return L===void 0&&w.href===void 0&&f.push({id:"find",label:"Find\u2026",run:()=>{let se=t.current?.querySelector('[data-testid="nav-find"]')??document.querySelector('[data-testid="nav-find"]');se&&se.offsetParent!==null?se.focus():d("/search")}}),f.length>0?{id:"pages",items:f}:null},[r,i,e,l,c,d,t]),ue=(0,X.useMemo)(()=>w=>{if(w.face!=="pages"||w.field===void 0||w.on===void 0)return null;let f=r.graph.getNode(w.on),L=w.element?.closest("[data-graview-field]")??t.current?.querySelector(`[data-graview-field="${CSS.escape(w.field)}"]`);return!f||!(L instanceof HTMLElement)||!L.hasAttribute("data-graview-editable")?null:{id:"field",at:"start",items:[{id:"change-field",label:`Change \u201C${va(i.tryDefinition(f.kind),w.field)}\u201D`,run:()=>L.click()}]}},[r,i,t]),oe=_r(),_=mr(),ge=Or(),Ke=(0,X.useCallback)((w,f)=>{l===ye(e,w).split("?")[0]&&d(f?ye(e,f):"/")},[l,e,d]),Pe=Yr(Ke),Ce=(0,X.useMemo)(()=>[ue,ge,ae,...Pe?[Pe]:[],..._?[_]:[],...oe?[oe]:[]],[ue,ge,ae,Pe,_,oe]);return(0,xe.jsxs)(cr,{sections:Ce,children:[(0,xe.jsx)("div",{"data-graview-menu-ground":"",style:{display:"contents"},onContextMenu:w=>{let f=w.target;w.shiftKey||en(f)||To(f)||(w.preventDefault(),!f.closest("[data-graview-popover]")&&(Date.now()-E.current<700||(w.clientX===0&&w.clientY===0&&f instanceof HTMLElement?b(f):G(f,w.clientX,w.clientY))))},onPointerDown:w=>{if(P.current=!1,w.pointerType==="mouse"||!w.isPrimary)return;let f=w.target;if(en(f)||f.closest("[data-graview-choose], [data-graview-popover]"))return;K();let{clientX:L,clientY:$}=w;k.current={x:L,y:$,timer:setTimeout(()=>{k.current=null,P.current=!0,E.current=Date.now(),G(f,L,$)},Ro)}},onPointerMove:w=>{let f=k.current;f&&Math.hypot(w.clientX-f.x,w.clientY-f.y)>Lo&&K()},onPointerUp:K,onPointerCancel:K,onClickCapture:w=>{P.current&&(P.current=!1,w.preventDefault(),w.stopPropagation())},children:n}),(0,xe.jsx)($o,{openAt:b,readyAt:N}),(0,xe.jsx)(zr,{placement:"page"}),(0,xe.jsx)(fr,{})]})}function Eo(e){let t=e.slice(10).split("+");return t.length===1&&t[0]?t[0]:void 0}function $o({openAt:e,readyAt:t}){return(0,xe.jsx)("span",{"data-graview-menu-home":"",tabIndex:-1,onFocus:n=>{if(n.target!==n.currentTarget)return;let a=n.currentTarget.closest("[data-graview-face]"),r=a?.querySelector("[data-graview-page-title]")??a?.querySelector("main h1, main")??null;r&&(r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),r.focus({preventScroll:!0}))},style:{position:"absolute",width:0,height:0,overflow:"hidden"},children:(0,xe.jsx)(Ur,{placement:"menu",openActs:e,aimAt:t})})}var D=I(q(),1);function Pi(e,t){return t==="*"?{label:"anything",path:null}:{label:Q(e,t),path:`/${V(e.schema,t)}`}}function Oo({context:e,relation:t}){let{store:n}=e,a=Pi(n,t.from),r=Pi(n,t.to),i=d=>d.path?(0,D.jsx)(H,{to:d.path,style:{...Se,fontWeight:550},children:d.label}):(0,D.jsx)("span",{children:d.label});return(0,D.jsxs)("li",{"data-testid":"relation","data-relation":t.edgeKind,style:{display:"grid",gridTemplateColumns:"30px minmax(0, 1fr) auto",gap:12,alignItems:"baseline"},children:[(0,D.jsx)(jr,{edgeKind:t.edgeKind,...e.brand?.kit?{kit:e.brand.kit}:{}}),(0,D.jsxs)("span",{style:{display:"grid",gap:1},children:[(0,D.jsxs)("span",{children:[i(a)," ",(0,D.jsxs)("span",{style:C,"data-graview-speaks-ids":"",children:[ze(t.edgeKind)," \u2192"]})," ",i(r)]}),t.description||t.inverse?(0,D.jsxs)("span",{style:C,children:[t.description?Re(t.description):null,t.description&&t.inverse?" \xB7 ":null,t.inverse?`from the other end, ${t.inverse}`:null]}):null]}),r.path?(0,D.jsx)(H,{to:`${r.path}?with=${encodeURIComponent(t.edgeKind)}`,style:{...U,...C,fontVariantNumeric:"tabular-nums",display:"inline-block",minWidth:24,minHeight:24,textAlign:"center"},title:`The ${r.label.toLowerCase()} that have this`,children:t.count}):(0,D.jsx)("span",{style:{...C,fontVariantNumeric:"tabular-nums"},children:t.count})]})}function Ci({context:e,heading:t=!0}){let{store:n}=e,a=new Set(Fe(n,e.principal)),r=Je(n).relations.filter(i=>a.has(i.from)&&(i.to==="*"||a.has(i.to)));return r.length===0?null:(0,D.jsxs)("section",{style:{...ee,display:"grid",gap:12},"data-testid":"kind-map",children:[t?(0,D.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,D.jsx)("h2",{style:J,children:(0,D.jsx)(H,{to:"/map",style:Se,children:"Connections"})}),(0,D.jsx)("span",{style:C,children:r.length===1?"1 relation":`${r.length} relations`})]}):null,(0,D.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:r.map(i=>(0,D.jsx)(Oo,{context:e,relation:i},`${i.edgeKind}|${i.from}|${i.to}`))})]})}function Qn({context:e}){let{store:t}=e;Z(t);let n=new Set(Fe(t,e.principal)),a=Je(t),r=a.relations.filter(i=>n.has(i.from));return(0,D.jsxs)(te,{context:e,children:[(0,D.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,D.jsx)("p",{style:we,children:r.length===0?"No relations":`${r.length} ${r.length===1?"relation":"relations"}`}),(0,D.jsx)(ie,{context:e,children:"Connections"}),(0,D.jsx)("p",{style:re,children:r.length===0?"Nothing here is declared to relate to anything else yet.":"The kinds this installation holds, and the relations declared between them \u2014 each in the declaration's own words, with how many of it there are."})]}),(0,D.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"6px 18px"},"data-testid":"map-kinds",children:a.kinds.filter(i=>n.has(i.kind)).map(i=>(0,D.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,D.jsx)(ce,{kind:i.kind,brand:e.brand,schema:t.schema,size:7}),(0,D.jsx)(H,{to:`/${V(t.schema,i.kind)}`,style:U,children:i.plural}),(0,D.jsx)("span",{style:C,children:i.count})]},i.kind))}),(0,D.jsx)(Ci,{context:e,heading:!1})]})}function Ai({context:e}){let n=[...de()?.robots.values()??[]].filter(r=>r.mode==="asking"&&r.say);if(n.length===0)return null;let{store:a}=e;return(0,D.jsxs)("section",{style:{...ee,display:"grid",gap:10},"data-testid":"seat-questions",children:[(0,D.jsx)("h2",{style:J,children:n.length===1?"The seat asked something":`The seat asked ${n.length} things`}),(0,D.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8},children:n.map(r=>{let i=r.at?a.graph.getNode(r.at):void 0;return(0,D.jsxs)("li",{style:{display:"grid",gap:2},children:[(0,D.jsx)("span",{children:r.say}),i?(0,D.jsxs)(H,{to:z(a.schema,i.kind,i.id),style:{...U,...C},children:[me(a.schema.tryDefinition(i.kind),i)," \u2192"]}):null]},r.participant)})})]})}var W=I(q(),1);function Zn({context:e}){let{principal:t}=e,{store:n,brand:a,invariantContext:r}=e;Z(n);let i=n.violations(r),d=`${i.length===1?"A rule is broken":"Rules are broken"} \u2014 see what, and what would fix it`,l=[...n.log.all()].slice(-5).reverse(),c=zt(e).map(b=>({kind:b,members:n.graph.nodesOfKind(b).filter(E=>st(n.schema.tryDefinition(b),E))})),m=c.filter(b=>b.members.length>0),x=c.map(b=>({entry:b,creator:n.allMutations().find(E=>(E.creates??[]).includes(b.kind)&&n.permits({name:E.name,args:{}},e.principal).ok)})).find(b=>b.creator!==void 0),g=m.length===0?"Nothing here yet.":`${m.map(b=>Tt(n.schema,b.kind,b.members.length)).join(", ").replace(/, ([^,]*)$/," and $1")}.`,u=e.views?.homeView?.(),A=n.schema.kinds.some(b=>n.graph.nodesOfKind(b).length>0);if(u&&A){let b=a?.subtitle&&a.subtitleDrawn!==!1?(0,W.jsx)("p",{style:{...C,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,E=u[Symbol.for("graview.home-blocks")]===!0;return(0,W.jsx)(te,{context:e,style:ct,children:(0,W.jsxs)("div",{style:{display:"grid",gap:12},"data-testid":"home-view",children:[E?null:b,i.length>0?(0,W.jsx)(H,{to:"/problems",style:{...U,color:"var(--graview-warn)"},children:d}):null,(0,W.jsx)(Kr.Provider,{value:E?b:null,children:(0,W.jsx)(Zt,{when:Ot(u),children:(0,W.jsx)(u,{cardinality:"many",fidelity:"full",mode:"fullscreen",selected:!1})})})]})})}let N=new Set(Fe(n,e.principal)),G=Je(n).relations.filter(b=>N.has(b.from)&&(b.to==="*"||N.has(b.to)));return(0,W.jsxs)(te,{context:e,style:ct,children:[(0,W.jsxs)("header",{style:{display:"grid",gap:12},children:[a?.subtitle&&a.subtitleDrawn!==!1?(0,W.jsx)("p",{style:{...C,margin:0},"data-testid":"app-subtitle",children:a.subtitle}):null,(0,W.jsx)(ie,{context:e,"data-testid":"standing",children:g}),(0,W.jsxs)("p",{style:{...re,display:"grid",gap:4},"data-testid":"standing-card",children:[m.length===0&&x?(0,W.jsxs)("span",{children:["Begin with \u201C",x.creator?.title??x.creator?.name,"\u201D, under"," ",(0,W.jsx)(H,{to:`/${V(n.schema,x.entry.kind)}`,style:U,children:Q(n,x.entry.kind)}),"."]}):null,i.length===0?(0,W.jsx)("span",{children:"All rules hold."}):(0,W.jsx)(H,{to:"/problems",style:{...U,color:"var(--graview-warn)"},children:d})]})]}),(0,W.jsx)(_n,{context:e}),(0,W.jsxs)("section",{style:{...ee,display:"grid",gap:14},"data-testid":"kinds",children:[(0,W.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:[(0,W.jsx)("h2",{style:J,children:"What is here"}),G.length>0?(0,W.jsx)(H,{to:"/map",style:{...qe,...C,marginLeft:"auto"},"data-testid":"map-link",children:(0,W.jsxs)(Qe,{children:["Connections \xB7 ",G.length===1?"1 relation":`${G.length} relations`]})}):null]}),(0,W.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"8px 10px"},children:c.map(({kind:b,members:E})=>(0,W.jsx)("li",{style:{maxWidth:"100%"},children:(0,W.jsxs)(H,{to:`/${V(n.schema,b)}`,style:{...Se,flexWrap:"wrap",gap:8,padding:"6px 14px 6px 10px",borderRadius:8,border:"1px solid var(--graview-edge-bright)",background:"var(--graview-panel)"},children:[(0,W.jsx)(ce,{kind:b,brand:a,schema:n.schema,size:7}),(0,W.jsx)("span",{style:{fontWeight:550,overflowWrap:"anywhere"},children:Q(n,b)}),(0,W.jsx)("span",{style:{...C,fontVariantNumeric:"tabular-nums"},children:E.length===0?"none yet":ft(E.length)})]})},b))})]}),l.length>0?(0,W.jsxs)("section",{style:{...ee,display:"grid",gap:10},children:[(0,W.jsx)("h2",{style:J,children:"Recently"}),(0,W.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:l.map(b=>(0,W.jsxs)("li",{style:C,children:[(0,W.jsx)("span",{style:{color:"var(--graview-ink)"},children:b.intent})," \u2014 ",ht(b,t,{graph:n.graph,schema:n.schema,...e.seats?{seats:e.seats}:{},...e.people?{people:e.people}:{}})]},b.id))})]}):null]})}var Me=I(He(),1);var nt=I(q(),1);function tn({context:e,withheld:t,style:n,testId:a}){let r=de(),i=La(t,e.signIn??r?.signIn);return i?(0,nt.jsx)("p",{style:{...n,margin:0},children:(0,nt.jsx)("button",{type:"button","data-testid":"sign-in",onClick:()=>i.run(),style:ke,children:i.label})}):t.length===0?null:(0,nt.jsx)("ul",{style:{...n,margin:0,padding:0,listStyle:"none",display:"grid",gap:4},...a?{"data-testid":a}:{},children:t.map(d=>(0,nt.jsxs)("li",{style:C,children:[(0,nt.jsx)("s",{children:d.label})," \u2014 ",d.refusal.message]},d.id))})}var M=I(q(),1);function Xn({context:e}){let{store:t,brand:n,principal:a,invariantContext:r}=e;Z(t);let[i]=pt(),d=i.get("q")??"",l=typeof r?.today=="string"?r.today:void 0,s=Lr(t,d,{...a?{principal:a}:{},places:$e(e),flagged:new Set(t.violations(r).flatMap(u=>u.nodeIds)),...l?{today:l}:{},limit:200}),c=s.hits.filter(u=>u.about==="node"),m=s.hits.filter(u=>u.about==="kind"||u.about==="place"||u.about==="rule"),x=[...new Set(c.map(u=>u.kind))],g=d.trim();return(0,M.jsxs)(te,{context:e,children:[(0,M.jsx)("style",{children:_t}),(0,M.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,M.jsx)("p",{style:we,children:"Search"}),(0,M.jsx)(ie,{context:e,"data-testid":"search-heading",children:g.length===0?"Find anything by its name":s.hits.length===0?(0,M.jsxs)(M.Fragment,{children:["Nothing here is called \u201C",g,"\u201D."]}):(0,M.jsxs)(M.Fragment,{children:[No(t,s.byKind)," for \u201C",g,"\u201D"]})}),g.length>0?(0,M.jsxs)("p",{style:{...C,margin:0},"data-testid":"search-searched",children:[Dt(t.schema,s.searched),s.conditions.filter(u=>u.key!=="is"&&u.admittedBy.length<s.searched.kinds.length).map(u=>(0,M.jsxs)("span",{children:[" ",u.key,":",u.value," narrows"," ",u.admittedBy.length===0?"nothing here":u.admittedBy.map(A=>Q(t,A).toLowerCase()).join(" and "),"."]},`${u.key}:${u.value}`))]}):(0,M.jsxs)("p",{style:re,children:["Type in the box above. Words find the start of words in names and in what each record says;"," ",(0,M.jsx)("code",{children:"done:false"})," and the like narrow as a list does, and ",(0,M.jsx)("code",{children:"is:any"})," includes what is past."]})]}),m.length>0?(0,M.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},"data-testid":"search-named",children:m.map(u=>(0,M.jsx)("li",{"data-testid":"search-hit","data-about":u.about,children:u.about==="kind"?(0,M.jsxs)(H,{to:`/${V(t.schema,u.kind)}`,style:U,children:[u.label,u.count>0?(0,M.jsxs)("span",{style:C,children:[" \xB7 ",u.count," match"]}):null]}):u.about==="place"?(0,M.jsxs)(H,{to:ye(e,u),style:U,children:["Go to ",u.title]}):u.about==="rule"?(0,M.jsxs)(H,{to:"/problems",style:U,children:["The rule \u201C",u.label,"\u201D"]}):null},`${u.about}:${u.about==="rule"?u.name:u.about==="place"?u.as:u.kind}`))}):null,x.map(u=>(0,M.jsxs)("section",{className:"graview-list",style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",minWidth:0},"data-testid":"search-group","data-kind":u,children:[(0,M.jsxs)("h2",{className:"graview-group-head",style:{alignItems:"center"},children:[(0,M.jsx)(ce,{kind:u,brand:n,schema:t.schema,size:8}),(0,M.jsx)(H,{to:`/${V(t.schema,u)}?${new URLSearchParams({q:g}).toString()}`,style:U,"data-testid":"search-kind-link",children:Q(t,u)}),(0,M.jsx)("span",{children:s.byKind[u]})]}),(0,M.jsx)("ul",{className:"graview-rows",children:c.filter(A=>A.kind===u).map(A=>(0,M.jsxs)("li",{"data-testid":"search-hit","data-about":"node",className:"graview-row",children:[(0,M.jsxs)(H,{to:z(t.schema,u,A.id),className:"graview-row-title",...A.label.length>60?{title:A.label}:{},children:[A.flagged?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)("span",{role:"img","aria-label":"Breaks a rule:",style:{color:"var(--graview-warn)"},children:"\u26A0"})," "]}):null,A.label]}),A.apart||!A.current?(0,M.jsx)("span",{className:"graview-row-glance",children:[A.apart,A.current?"":"past"].filter(Boolean).join(" \xB7 ")}):null,(0,M.jsx)(nn,{why:A.why})]},A.id))})]},u)),g.length>0?(0,M.jsx)(Ho,{asked:g}):null,g.length>0&&s.hits.length===0?(0,M.jsx)(Li,{store:t,kinds:s.searched.kinds,words:s.words,...a?{principal:a}:{},...r?{invariantContext:r}:{}}):null]})}function nn({why:e}){return e.strength==="near"?(0,M.jsxs)("span",{style:C,"data-testid":"search-why","data-near":"",children:["Near \u201C",e.asked,"\u201D",e.field==="label"?"":` \u2014 ${e.reading}: ${e.fragment}`]}):e.field==="label"?null:(0,M.jsxs)("span",{style:C,"data-testid":"search-why",children:[e.reading,": ",e.fragment]})}function No(e,t){let n=Object.entries(t).map(([a,r])=>`${r} ${r===1?Ye(e.schema.tryDefinition(a),a):Q(e,a).toLowerCase()}`);return n.length===0?"Found":n.length===1?Re(n[0]):Re(`${n.slice(0,-1).join(", ")} and ${n[n.length-1]}`)}function Ri(e,t,n={}){let a=[];for(let r of t){let i=Xe(e,r,{...n.principal?{principal:n.principal}:{},...n.invariantContext?{context:n.invariantContext}:{}});for(let d of an(e,r,i.actions.affordances))a.some(l=>l.mutation.name===d.mutation.name)||a.push(d)}return a}function an(e,t,n){let a=e.schema.tryDefinition(t)?.fieldRoles?.label,r=[];for(let i of n){let d=e.allMutations().find(c=>c.name===i.mutation);if(!d||!d.creates?.includes(t)||r.some(c=>c.mutation.name===d.name))continue;let l=yr(d.input).map(c=>c.name),s=l.includes("label")?"label":a&&l.includes(a)?a:void 0;!s||i.args[s]!==void 0||r.push({kind:t,affordance:i,mutation:d,arg:s})}return r}function Li({store:e,kinds:t,words:n,principal:a,invariantContext:r}){let i=Ri(e,t,{...a?{principal:a}:{},...r?{invariantContext:r}:{}});return i.length===0||n.trim().length===0?null:(0,M.jsx)("div",{style:{display:"grid",gap:24},"data-testid":"search-to-create",children:i.map(({kind:d,affordance:l,mutation:s,arg:c})=>(0,M.jsxs)("section",{style:{...ee,display:"grid",gap:14},children:[(0,M.jsxs)("h2",{style:J,children:[Re(Sa(Ye(e.schema.tryDefinition(d),d)))," called \u201C",n,"\u201D"]}),(0,M.jsx)(Ie,{store:e,mutation:s,prefilled:l.args,open:l.open,initial:{[c]:n},...a?{principal:a}:{}})]},`${l.id}|${n}`))})}function Ho({asked:e}){let t=de();return t?(0,M.jsx)(Io,{asked:e,desk:t.aiDesk}):null}function Io({asked:e,desk:t}){return _a(t)?(0,M.jsx)("p",{style:{margin:0},children:(0,M.jsxs)("button",{type:"button","data-testid":"search-ask",onClick:a=>ja(t,{pointed:{about:[]},asked:e,returnTo:a.currentTarget}),style:{...U,font:"inherit",padding:0,border:0,background:"transparent",cursor:"pointer",textAlign:"start"},children:["Ask: \u2018",e,"\u2019"]})}):null}var h=I(q(),1),Mi=8,Ei=40;function Fo(e,t){let n=t?.fields?.shape??{},a=Object.keys(n).find(r=>ba(n[r])&&ka(e[r]));return a===void 0?void 0:e[a]}function Jn({context:e}){let t=Ue(),n=ve(e.store.schema,t.slug??"");return n?(0,h.jsx)($i,{context:e,kind:n}):(0,h.jsx)(te,{context:e,children:(0,h.jsx)(ie,{context:e,children:"No such kind of thing here."})})}function $i({context:e,kind:t,opening:n,row:a,layout:r="list",description:i,bare:d}){let{store:l,brand:s,invariantContext:c}=e;Z(l);let[m,x]=pt(),g=`list-${(0,Me.useId)().replace(/:/g,"")}`,u=l.schema.tryDefinition(t),A=Pa(m.get("archived")),N=l.graph.nodesOfKind(t,{archived:A}),G=Je(l).relations.filter(o=>o.from===t||o.to===t),b=new Set(l.violations(c).flatMap(o=>o.nodeIds)),E=Cr(l.schema,Pr(l.schema,xr(l.schema,t))),k=G.map(o=>o.edgeKind),P=qo(m,E,k),K=["sort","filter","group","q","by","with","past","archived",...k].some(o=>m.has(o)),ae=N.length>=Ei,ue=u?.fieldRoles?.when,oe=e.views?.arrangement?.()?.lists?.[t],_=wr(oe),ge=hr(oe?.group),Ke=Go(ae,ue),Pe=n??(_?{...Ke,..._}:Ke),Ce=K?P.arrangement:$n(Pe,E).arrangement,w=_?.sort,f=Ce.sort&&w?.then&&Ce.sort.by===w.by&&Ce.sort.direction===w.direction?{...Ce,sort:w}:Ce,L=Ar(f.query??""),$=[...f.filter??[],...L.conditions].some(o=>o.key==="is"&&(o.value==="past"||o.value==="any"))||br(u,[...f.filter??[],...L.conditions]),ne=$||!u?.lifecycle?f:{...f,filter:[...f.filter??[],{key:"is",value:"current"}]},Y=new Map,p=Wt(N,ne,{schema:l.schema,graph:l.graph,flagged:b,...typeof c?.today=="string"?{today:c.today}:{},read:(o,y)=>{let O=Y.get(o.id);return O||Y.set(o.id,O=yt(l.schema,l.graph,o)),O[y]}}),T=ge&&f.group?.by===ge.by&&!f.group.bucket?E.groups.find(o=>o.key===ge.by):void 0,j=ge&&T&&(T.type==="choice"||T.type==="boolean")?vr(p.groups,ge,{type:T.type,...T.options?{options:T.options}:{}}):p.groups.map(o=>({...o,closed:!1})),se=new Set((m.get("open")??"").split(",").filter(Boolean)),Wi=!!f.query||(f.filter??[]).some(o=>o.key===ge?.by),aa=o=>T?.type==="boolean"?o==="1"?"true":"false":o,ra=o=>o.closed&&!Wi&&!se.has(aa(o.key)),Ki=o=>{let y=new URLSearchParams(m),O=new Set(se);O.has(o)?O.delete(o):O.add(o),O.size>0?y.set("open",[...O].join(",")):y.delete("open"),x(y,{replace:!0})},Ae=p.nodes,rt=u?.lifecycle&&!$?N.filter(o=>st(u,o)):N,ia=N.length-rt.length,sn=f.group?.by??null,Bi=o=>{let y=new URLSearchParams(m);for(let le of["sort","filter","group","q","by","with","past","archived",...G.map(Rt=>Rt.edgeKind)])y.delete(le);let O=Tr(o);for(let le of["sort","filter","group","q","archived"])O[le]&&y.set(le,O[le]);![...y.keys()].some(le=>["sort","filter","group","q"].includes(le))&&(n||_||ae||ue)&&y.set("sort",""),x(y)},{principal:it}=e,ln=Xe(l,t,{...it?{principal:it}:{},...e.invariantContext?{context:e.invariantContext}:{}}),Be=ln.actions.affordances.map(o=>({affordance:o,mutation:l.allMutations().find(y=>y.name===o.mutation)})).filter(o=>o.mutation!==void 0),Gi=ln.actions.withheld,dn=()=>new Set(Ae.length===0?Be.map(({mutation:o})=>o.name):[]),[cn,oa]=(0,Me.useState)(()=>({kind:t,open:dn()}));cn.kind!==t&&oa({kind:t,open:dn()});let sa=o=>(cn.kind===t?cn.open:dn()).has(o),la=(o,y)=>oa(O=>{let le=new Set(O.open);return y?le.add(o):le.delete(o),{kind:O.kind,open:le}}),da=`begin-${(0,Me.useId)().replace(/:/g,"")}`,ca=L.words&&Ae.length===0?Object.fromEntries(an(l,t,ln.actions.affordances).map(o=>[o.mutation.name,o.arg])):{},je=Q(l,t),xt=e.views?.lookup(t,{cardinality:"one",fidelity:"glyph"}),pn=xt!==void 0&&!lt(xt)?xt:void 0,un=(f.group?.bucket??"day")==="day"?f.group?.by:void 0,gn=(f.filter??[]).map(o=>o.key),qi=gn.filter(o=>gn.indexOf(o)===gn.lastIndexOf(o)&&/choice|boolean/.test(E.filters.find(y=>y.key===o)?.type??"")),mn=o=>{let y={...u?.computed?yt(l.schema,l.graph,o):o};un&&!String(y[un]).includes("T")&&delete y[un];for(let O of qi)delete y[O];return y},pa=o=>rr(u?.fields?.shape?.[o])?.type==="enum",Pt=o=>{let y=me(u,o);if(a)return(0,h.jsxs)("li",{"data-testid":"record-row","data-graview-record":o.id,style:{minWidth:0},...Sn(o.id),children:[vn(o,y),a(o,{label:y,href:z(l.schema,t,o.id),flagged:b.has(o.id),glance:ni(mn(o),u,y)})]},o.id);if(pn){let kn=qt(xt,o,l.graph),Yi=Object.fromEntries(Object.entries(mn(o)).filter(([Qi])=>!kn?.fields.has(Qi))),ha=kn?Fn(Yi,u,kn.title??y,pa):[];return(0,h.jsxs)("li",{"data-testid":"record-row","data-graview-record":o.id,style:{position:"relative",display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:16,rowGap:2,paddingBlock:10,borderTop:"1px solid var(--graview-edge)"},...Sn(o.id),children:[vn(o,y),(0,h.jsx)("div",{style:{flex:"1 1 14rem",minWidth:0},children:(0,h.jsx)(pn,{node:o,cardinality:"one",fidelity:"glyph",mode:"fullscreen",selected:!1,...b.has(o.id)?{flagged:[o.id]}:{}})}),ha.length>0?(0,h.jsx)("span",{style:{...C,flex:"0 1 auto",minWidth:0,overflowWrap:"anywhere"},"data-testid":"record-glance",children:(0,h.jsx)(Dn,{runs:ha})}):null,(0,h.jsx)(jo,{to:z(l.schema,t,o.id),label:b.has(o.id)?`${y} \u2014 implicated in a problem`:y})]},o.id)}let O=Fn(mn(o),u,y,pa),le=O.length>0,Rt=L.words?Rr(u,o,L.words):void 0,fa=ae?void 0:or(o,u),Lt=Fo(o,u),ya=(0,h.jsxs)(H,{to:z(l.schema,t,o.id),className:"graview-row-title",...y.length>60?{title:y}:{},children:[b.has(o.id)?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("span",{role:"img","aria-label":"Breaks a rule:",style:{color:"var(--graview-warn)"},children:"\u26A0"})," "]}):null,y]});return(0,h.jsxs)("li",{className:"graview-row","data-graview-record":o.id,...Sn(o.id),children:[vn(o,y),fa?(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:14,minWidth:0},children:[(0,h.jsx)(dt,{as:"thumb",file:fa}),ya]}):ya,le||Lt?(0,h.jsxs)("span",{className:"graview-row-glance",children:[(0,h.jsx)(Dn,{runs:O}),le&&Lt?" \xB7 ":null,Lt?(0,h.jsx)(Kt,{address:Lt}):null]}):null,Rt?(0,h.jsx)(nn,{why:Rt}):null]},o.id)},fn=$e(e).filter(o=>o.kind===t&&!o.hidden),ua=oe?.filters,Ui=(f.filter??[]).some(o=>o.key!=="is"||o.value!=="any"),Vi=!!(f.sort||f.group||f.query||Ui),ji=rt.length>=Mi||K&&Vi,Oe=f.sort?E.sorts.find(o=>o.key===f.sort.by):void 0,yn=Oe?.type==="date"||Oe!==void 0&&Oe.key===ue,ga=ae&&!p.grouped&&Oe&&(Oe.about==="label"||Oe.type==="text"||yn)?o=>{let y=Oe.about==="label"?me(u,o):o[Oe.key];if(typeof y!="string"||y.length===0)return yn?"No date":"#";if(yn)return y.slice(0,4);let O=y.trim().charAt(0).toLocaleUpperCase();return/\p{L}/u.test(O)?O:"#"}:void 0,_e=ga?Ae.reduce((o,y)=>{let O=ga(y);return o.at(-1)?.key===O?o.at(-1).nodes.push(y):o.push({key:O,nodes:[y]}),o},[]):void 0,ma=p.grouped&&sn?j.flatMap(o=>ra(o)?[]:o.nodes):_e&&_e.length>1?_e.flatMap(o=>o.nodes):Ae,hn=(0,Me.useMemo)(()=>ma.map(o=>o.id),[ma.map(o=>o.id).join(`
6
+ `)]),Ee=Nr(hn),wn=(0,Me.useId)(),gt=(it?l.permittedMutations(it):l.permittedMutations()).some(o=>{let y=o.subject?.kinds;return y!==void 0&&(y==="*"||y.includes(t))}),vn=(o,y)=>gt?(0,h.jsx)("span",{className:"graview-choose-at",children:(0,h.jsx)("input",{...Ee.boxProps(o.id,y),onPointerEnter:On,onFocus:On})}):null,Sn=o=>gt?{"data-graview-choose":o}:{},_i=(0,Me.useCallback)(o=>{Ee.choose(o),requestAnimationFrame(()=>{let y=Ee.list.current;((o[0]===void 0?null:y?.querySelector(`[data-graview-choose-box="${CSS.escape(o[0])}"]`))??y)?.focus({preventScroll:!0})})},[Ee]),ot=r==="grid"?{margin:0,padding:0,listStyle:"none",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(100%, 15rem), 1fr))",alignItems:"start",gap:12}:a||pn?{margin:0,padding:0,listStyle:"none",display:"grid",gap:a&&r==="list"?6:0}:void 0,Ct=ot?void 0:"graview-rows",mt=o=>`list-at-${o.replace(/[^\p{L}\p{N}]/gu,"_")}`,At=G.map(o=>{let y=o.from===t?o.to:o.from,O=o.from===t?o.description:o.inverse??o.description;return{relation:o,far:y,words:O}}),zi=new Set(At.map(o=>(o.words??"").toLowerCase()).filter((o,y,O)=>o&&O.indexOf(o)!==y));return(0,h.jsxs)(d?Bo:te,{context:e,children:[(0,h.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,h.jsxs)("header",{style:{display:"grid",gap:4},children:[d?null:(0,h.jsx)(ut,{context:e}),(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",columnGap:10,rowGap:4,minWidth:0},children:[(0,h.jsx)(ce,{kind:t,brand:s,schema:l.schema,size:8}),(0,h.jsx)(ie,{context:e,children:je}),Be.length>0?(0,h.jsx)("span",{style:{marginLeft:"auto",display:"flex",flexWrap:"wrap",columnGap:14,rowGap:8},"data-testid":"beginnings-open",children:Be.map(({affordance:o,mutation:y})=>(0,h.jsx)(Uo,{name:y.name,title:y.title??y.name,panel:`${da}-${y.name}`,open:sa(y.name),onOpen:O=>la(y.name,O)},o.id))}):null]}),Ae.length>0?(0,h.jsx)(Jr,{place:"here",to:[{label:`Skip to the ${Ae.length===1?Ye(u,t):`${Ae.length} ${je.toLowerCase()}`}`,testid:"records",go:()=>{let o=document.querySelector(`[data-graview-skip-target="${CSS.escape(wn)}"]`);Nn(o?.querySelector('[data-graview-choose-box][tabindex="0"]')??o)}},...rt.length>0?[{label:"Skip to arranging them",testid:"arranging",go:()=>{let o=document.querySelector(`[data-graview-skip-target="${CSS.escape(wn)}"]`)?.parentElement?.querySelector('[role="group"][aria-label="Arrange"]');Nn(o?.querySelector('button[data-testid$="-add"], button[data-testid$="-all"]')??o)}}]:[]]}):null,i??u?.description?(0,h.jsx)("p",{style:re,children:i??u?.description}):null,At.length>0||fn.length>0?(0,h.jsxs)("p",{style:{...C,margin:0,display:"flex",flexWrap:"wrap",columnGap:18,rowGap:2},"data-testid":"kind-related",children:[At.length>0?(0,h.jsxs)("span",{"data-testid":"kind-relations",children:["Related:"," ",At.map(({relation:o,far:y,words:O},le)=>(0,h.jsxs)("span",{"data-relation":o.edgeKind,children:[le>0?(0,h.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,y==="*"?Re(O??ze(o.edgeKind)):(0,h.jsx)(H,{to:`/${V(l.schema,y)}`,style:U,title:Q(l,y),children:O&&zi.has(O.toLowerCase())?`${Re(O)}: ${Q(l,y).toLowerCase()}`:Re(O??Q(l,y))})]},`${o.edgeKind}|${o.from}|${o.to}`))]}):null,fn.length>0?(0,h.jsxs)("span",{"data-testid":"kind-pictures",children:["Also as:"," ",fn.map((o,y)=>(0,h.jsxs)("span",{children:[y>0?(0,h.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,(0,h.jsx)(H,{to:ye(e,o),style:U,children:o.title})]},et(o)))]}):null]}):null]}),Be.length>0?(0,h.jsx)("div",{style:{display:"contents"},"data-testid":"beginnings",children:Be.map(({affordance:o,mutation:y})=>{let O=!!(ca[y.name]&&Ae.length===0);return(0,h.jsx)(Vo,{name:y.name,id:`${da}-${y.name}`,description:y.description,open:sa(y.name),onClose:()=>la(y.name,!1),children:(0,h.jsx)(Ie,{store:l,mutation:y,prefilled:o.args,open:o.open,...O?{initial:{[ca[y.name]]:L.words}}:{},...e.principal?{principal:e.principal}:{}},O?`${y.name}|${L.words}`:y.name)},o.id)})}):null,P.dropped.length>0?(0,h.jsxs)("p",{style:{...C,margin:0},"data-testid":"list-dropped",children:["This link asked for ",P.dropped.join(", "),", which ",je.toLowerCase()," cannot be arranged by; the rest is shown."]}):null,rt.length>0?(0,h.jsx)($r,{schema:l.schema,graph:l.graph,kind:t,arrangement:f,onChange:Bi,kept:{shown:Ae.length,of:rt.length},noun:{one:Ye(u,t),many:je.toLowerCase()},...ji?{}:{allow:!1},...ua?{filters:ua}:{},offers:E,chips:{nodes:rt,flagged:b,...typeof c?.today=="string"?{today:c.today}:{}},query:e.framed===!0&&e.barAbove!==!0}):null,(0,h.jsx)("style",{children:_t}),gt?(0,h.jsx)("style",{children:Hr+Ko}):null,(0,h.jsx)("div",{className:"graview-list","data-graview-skip-target":wn,...gt?{...Ee.listProps,ref:Ee.list,tabIndex:-1,"data-graview-choosable":"","aria-label":Ee.chosen.length>0?`${je}, ${Ee.chosen.length} chosen`:je,role:"group"}:{},children:Ae.length===0&&L.words?(0,h.jsxs)("p",{style:re,"data-testid":"none-yet",children:["Nothing here is called \u201C",L.words,"\u201D."," ",(0,h.jsx)("span",{style:C,"data-testid":"list-searched",children:Dt(l.schema,{kinds:[t],past:$})})," ",(0,h.jsx)(H,{to:"?",style:U,children:"Show every one"})]}):Ae.length===0?(0,h.jsxs)("p",{style:re,"data-testid":"none-yet",children:[f.filter?.length||f.query?"None of them.":"None yet",!f.filter?.length&&!f.query&&Be.length>0?` \u2014 the first one starts above, with \u201C${Be[0]?.mutation.title??Be[0]?.mutation.name}\u201D.`:!f.filter?.length&&!f.query?".":"",f.filter?.length||f.query?(0,h.jsxs)(h.Fragment,{children:[" ",(0,h.jsx)(H,{to:"?",style:U,children:"Show every one"})]}):null]}):p.grouped&&sn?(0,h.jsx)("div",{style:{display:"grid",gap:"1rem"},"data-testid":"records","data-grouped":sn,children:j.map(o=>{if(!o.closed)return(0,h.jsxs)("section",{style:{display:"grid",gap:0},"data-testid":"list-group",children:[(0,h.jsxs)("h2",{className:"graview-group-head",children:[o.label," ",(0,h.jsx)("span",{children:o.nodes.length})]}),(0,h.jsx)("ul",{style:ot,className:Ct,"data-graview-rows":"",children:o.nodes.map(Pt)})]},o.key||"-");let y=ra(o),O=`${g}-${mt(o.key||"none")}`;return(0,h.jsxs)("section",{style:{display:"grid",gap:0},"data-testid":"list-group","data-closed":y?"shut":"open",children:[(0,h.jsx)("h2",{className:"graview-group-head",children:(0,h.jsxs)("button",{type:"button",className:"graview-group-toggle","aria-expanded":!y,"aria-controls":O,"data-testid":"list-group-toggle",onClick:()=>Ki(aa(o.key)),children:[(0,h.jsx)("span",{"aria-hidden":"true",children:y?"\u25B8":"\u25BE"}),o.label," ",(0,h.jsxs)("span",{children:["\xB7 ",o.nodes.length]}),(0,h.jsxs)("span",{style:Do,children:[" ",o.nodes.length===1?Ye(u,t):je.toLowerCase()]})]})}),(0,h.jsx)("ul",{id:O,style:y?{...ot,display:"none"}:ot,className:Ct,"data-graview-rows":"",hidden:y,children:y?null:o.nodes.map(Pt)})]},o.key||"-")})}):_e&&_e.length>1?(0,h.jsxs)("div",{style:{display:"grid",gap:14},"data-testid":"records","data-sectioned":Oe?.type==="date"?"year":"letter",children:[(0,h.jsx)("nav",{"aria-label":"Jump to","data-testid":"list-index",style:{...C,display:"flex",flexWrap:"wrap",gap:Oe?.type==="date"?"0 10px":"0 4px",lineHeight:1.3},children:_e.map(o=>(0,h.jsx)("a",{href:`#${mt(o.key)}`,onClick:y=>{y.preventDefault(),document.getElementById(mt(o.key))?.scrollIntoView({block:"start"})},style:{...Se,minWidth:24,justifyContent:"center"},children:o.key},o.key))}),_e.map(o=>(0,h.jsxs)("section",{"data-testid":"list-section","aria-labelledby":mt(o.key),style:{display:"grid",gap:0},children:[(0,h.jsx)("h2",{id:mt(o.key),className:"graview-group-head",children:o.key}),(0,h.jsx)("ul",{style:ot,className:Ct,"data-graview-rows":"",children:o.nodes.map(Pt)})]},o.key))]}):(0,h.jsx)("ul",{style:ot,className:Ct,"data-testid":"records","data-graview-rows":"",children:Ae.map(Pt)})}),gt?(0,h.jsx)(Ir,{store:l,chosen:Ee.chosen,...it?{principal:it}:{},...c?{context:c}:{},anchor:Wo,of:hn.length,onChooseAll:()=>Ee.choose(hn),onClear:Ee.clear,onActed:_i}):null,ia>0?(0,h.jsxs)(H,{to:Ti(m,"filter","is:any"),style:{...U,...C,justifySelf:"start"},"data-testid":"past-link",children:["+",ia," past"]}):null,A===!1&&l.graph.count(t,{archived:!0})>0?(0,h.jsxs)(H,{to:Ti(m,"archived","true"),style:{...U,...C,justifySelf:"start"},"data-testid":"archived-link",children:["+",l.graph.count(t,{archived:!0})," archived"]}):null]}),(0,h.jsx)(tn,{context:e,withheld:Gi,style:ee,testId:"withheld"})]})}var Do={position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0},Wo=()=>document.querySelector("[data-graview-choosable]")?.closest("[data-embed-content]")??null,Ko=`
7
+ .graview-list[data-graview-choosable]{outline:none}
8
+ .graview-list [data-graview-choose]{position:relative;padding-left:34px}
9
+ .graview-choose-at{position:absolute;left:2px;top:0;bottom:0;z-index:${Ta.raised};display:flex;align-items:center}
10
+ @media (min-width: 900px) and (pointer: fine){
11
+ .graview-list [data-graview-choose]{padding-left:0}
12
+ .graview-choose-at{left:-34px}
13
+ }
14
+ @media (pointer: coarse){
15
+ .graview-list:not([data-graview-choosing]) [data-graview-choose]{padding-left:0}
16
+ .graview-list:not([data-graview-choosing]) .graview-choose-at{display:none}
17
+ }
18
+ `;function Bo({children:e}){return(0,h.jsx)("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:40,minWidth:0},children:e})}var Go=(e,t)=>t?{sort:{by:t,direction:"desc"}}:e?{sort:{by:"label",direction:"asc"}}:{};function qo(e,t,n){let a=$t({...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")}:{},...e.get("archived")?{archived:e.get("archived")}:{}}),r=[...a.filter??[]],i=e.get("by"),d=a.group??(i?{by:i}:void 0);for(let s of n){let c=e.get(s);c&&r.push({key:s,value:c})}let l=e.get("with");return l&&r.push({key:l,value:"*"}),e.get("past")==="1"&&!r.some(s=>s.key==="is")&&r.push({key:"is",value:"any"}),$n({...a.sort?{sort:a.sort}:{},...a.query?{query:a.query}:{},...r.length>0?{filter:r}:{},...d?{group:d}:{},...a.archived!==void 0?{archived:a.archived}:{}},t)}function Ti(e,t,n){let a=new URLSearchParams(e);return a.set(t,n),a.delete("past"),`?${a.toString()}`}function Uo({name:e,title:t,panel:n,open:a,onOpen:r}){return(0,h.jsxs)("button",{type:"button","data-testid":`act-open-${e}`,"data-graview-act":e,"aria-expanded":a,"aria-controls":n,onClick:()=>{r(!a),a||requestAnimationFrame(()=>document.getElementById(n)?.querySelector("input, select, textarea, button")?.focus())},style:{...Se,minHeight:28,margin:"-4px 0",padding:"0 2px",border:0,background:"none",font:"inherit",fontWeight:600,color:"var(--graview-ink)",cursor:"pointer"},children:[(0,h.jsx)("span",{"aria-hidden":"true",style:{marginRight:6},children:a?"\u2212":"+"}),t]})}function Vo({name:e,id:t,description:n,open:a,onClose:r,children:i}){return(0,h.jsxs)("div",{"data-testid":`act-${e}`,id:t,hidden:!a,onKeyDown:d=>{d.key==="Escape"&&(d.preventDefault(),r(),document.querySelector(`[aria-controls="${t}"]`)?.focus())},style:a?{display:"grid",gap:12,padding:"4px 0 12px"}:void 0,children:[n?(0,h.jsx)("p",{style:{...C,margin:0,maxWidth:"58ch"},children:n}):null,i]})}function jo({to:e,label:t}){let n=(0,Me.useRef)(null);return Fr(n),(0,h.jsx)(H,{ref:n,to:e,"aria-label":t,style:{position:"absolute",inset:0,borderRadius:6}})}var at=I(He(),1);var bt=I(He(),1);var F=I(q(),1);function ea({context:e}){let{store:t,brand:n,invariantContext:a,principal:r}=e;Z(t);let i=t.violations(a),d=t.allInvariants(),l=Ht(t,i),s=za(t.schema,d);return(0,F.jsxs)(te,{context:e,children:[(0,F.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,F.jsx)(ie,{context:e,children:i.length===0?"All rules hold":"What is broken"}),(0,F.jsx)("p",{style:re,"data-testid":"problems-count",children:i.length===0?"Every declared rule is satisfied by what is here.":Ca(i)})]}),(0,F.jsx)(Ai,{context:e}),l.map((c,m)=>{let x=c.nodeIds[0],g=x?t.graph.getNode(x):void 0;return(0,F.jsxs)("section",{style:{display:"grid",gap:10,padding:"16px 18px",borderLeft:"3px solid var(--graview-warn)",background:"var(--graview-panel-warning)",borderRadius:"0 var(--graview-radius, 12px) var(--graview-radius, 12px) 0"},children:[c.line?null:(0,F.jsx)(rn,{violation:c,schema:t.schema,...n?{brand:n}:{}}),g?(0,F.jsxs)("p",{style:{margin:0,display:"inline-flex",alignItems:"center",gap:8},children:[(0,F.jsx)(ce,{kind:g.kind,brand:n,schema:t.schema,size:7}),(0,F.jsx)(H,{to:z(t.schema,g.kind,g.id),style:U,children:me(t.schema.tryDefinition(g.kind),g)})]}):null,c.line?(0,F.jsx)(rn,{violation:c,schema:t.schema,...n?{brand:n}:{}}):null,(0,F.jsx)(on,{store:t,repairs:c.repairs,...r?{principal:r}:{}})]},m)}),d.length>0?(0,F.jsxs)("section",{style:{...ee,display:"grid",gap:12},"data-testid":"rules",children:[(0,F.jsx)("h2",{style:J,children:"The rules"}),(0,F.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:10},children:d.map(c=>{let m=i.filter(u=>u.invariant===c.name).length,x=s.get(c.name),g=c.label??c.name;return(0,F.jsxs)("li",{"data-graview-rule":c.name,style:{display:"grid",gap:2},children:[(0,F.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",columnGap:12,rowGap:2},children:[x?(0,F.jsx)(It,{line:x,schema:t.schema,...n?{brand:n}:{},style:{flex:"1 1 18rem"}}):(0,F.jsx)("span",{style:{flex:"1 1 18rem",fontWeight:550},children:g}),(0,F.jsx)("span",{style:{...C,color:m>0?"var(--graview-warn)":"var(--graview-ink-faint)"},children:m===0?"holds":`broken in ${m} ${m===1?"place":"places"}`})]}),x&&g.trim().length>0?(0,F.jsx)("span",{style:C,children:g}):null]},c.name)})})]}):null]})}function rn({violation:e,schema:t,brand:n}){if(!e.line)return(0,F.jsx)("p",{style:{margin:0,color:"var(--graview-warn)",fontWeight:550},children:e.message});let a=Qa(e),r=Ya(e);return r?(0,F.jsxs)("div",{style:{display:"grid",gap:4},"data-testid":"problem-line",children:[(0,F.jsx)("p",{style:{margin:0,color:"var(--graview-warn)",fontWeight:550},"data-testid":"problem-says",children:r}),a?(0,F.jsx)("span",{style:C,children:a}):null,(0,F.jsxs)("details",{"data-testid":"problem-judged",style:C,children:[(0,F.jsx)("summary",{style:{cursor:"pointer",width:"fit-content",minHeight:24},children:"How it is judged"}),(0,F.jsx)(It,{line:e.line,schema:t,...n?{brand:n}:{},lead:"none"})]})]}):(0,F.jsxs)("div",{style:{display:"grid",gap:2},"data-testid":"problem-line",children:[(0,F.jsx)(It,{line:e.line,schema:t,...n?{brand:n}:{},lead:"none",style:{color:"var(--graview-warn)"}}),a?(0,F.jsx)("span",{style:C,children:a}):null]})}function on({store:e,repairs:t,principal:n}){let[a,r]=(0,bt.useState)(null),[i,d]=(0,bt.useState)(null),l=(0,bt.useRef)([]);if(t.length===0)return null;let s=a===null?null:t[a],c=s&&(s.missing??[]).length>0?e.allMutations().find(m=>m.name===s.mutation):void 0;return(0,F.jsxs)("div",{style:{display:"grid",gap:10},"data-testid":"repairs",children:[(0,F.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:t.map((m,x)=>{let g=(m.missing??[]).length>0,u=e.permits({name:m.mutation,args:{...m.args}},n);return u.ok?(0,F.jsx)("button",{ref:A=>{l.current[x]=A},type:"button","data-graview-repair":m.mutation,"data-graview-asks":g||void 0,"aria-expanded":g?a===x:void 0,onClick:()=>{if(d(null),g){r(a===x?null:x);return}r(null);try{e.apply({name:m.mutation,args:{...m.args}},n?{author:n}:{})}catch(A){d(Ft(e.schema,e.allMutations(),A))}},style:ke,children:g?`${m.label} \u2026`:m.label},x):(0,F.jsxs)("p",{"data-testid":"withheld","data-withheld":u.refusal.wouldNeed.join(",")||"nobody",style:{...C,margin:0},children:[(0,F.jsx)("s",{children:m.label})," \u2014 ",u.refusal.message]},x)})}),c&&s?(0,F.jsx)(Ie,{store:e,mutation:c,prefilled:{...s.args},only:s.missing??[],label:s.label,autoFocus:!0,onDone:()=>{let m=a;r(null),requestAnimationFrame(()=>{let x=m===null?null:l.current[m];if(x?.isConnected){x.focus();return}let g=document.querySelector("[data-graview-page-title]")??document.querySelector("main h1, main h2");g&&(g.hasAttribute("tabindex")||(g.tabIndex=-1),g.focus())})},...n?{principal:n}:{}}):null,s&&!c&&(s.missing??[]).length>0?(0,F.jsxs)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:Hn},children:["\u201C",s.label,"\u201D names ",s.mutation,", which this app does not declare."]}):null,i?(0,F.jsx)("p",{"data-testid":"refused",role:"alert",style:{margin:0,color:"var(--graview-warn)",fontSize:Hn},children:i}):null]})}var ta=I(He(),1);var Ve=I(q(),1);function Oi({store:e,link:t,principal:n}){let[a,r]=(0,ta.useState)(!1),[i,d]=(0,ta.useState)(null),l=tr(t);return(0,Ve.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[(0,Ve.jsx)("button",{type:"button","data-graview-provisional":"",title:l,"aria-label":`Unsure link: ${l}`,"aria-expanded":a,onClick:()=>r(!a),style:{border:"1px dashed var(--graview-ink-muted)",borderRadius:999,background:"transparent",color:"var(--graview-ink-muted)",font:"inherit",fontSize:"0.75rem",lineHeight:1,padding:"2px 6px",cursor:"pointer"},children:"unsure"}),a?(0,Ve.jsxs)("span",{style:{...C,display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,Ve.jsx)("span",{children:l}),(0,Ve.jsx)("button",{type:"button",style:{...ke,padding:"4px 10px"},onClick:()=>{try{e.apply({name:Aa,args:{kind:t.edge.kind,from:t.edge.from,to:t.edge.to}},n?{author:n}:{}),r(!1)}catch(s){d(Ft(e.schema,e.allMutations(),s))}},children:"Keep this link"}),i?(0,Ve.jsx)("span",{role:"alert",children:i}):null]}):null]})}var he=I(q(),1);function Ni({nodeId:e,node:t,field:n,inPlace:a,labelStyle:r=we}){return n.files?(0,he.jsx)(dt,{as:"field",read:!a,nodeId:e,field:n.key,label:n.label,files:n.files,labelStyle:r,style:{gap:4}}):n.long?(0,he.jsx)(Er,{nodeId:e,field:n.key,label:n.label,value:n.value,markdown:n.markdown,style:{gridColumn:"1 / -1",gap:4},labelStyle:r,valueStyle:{lineHeight:1.6}}):(0,he.jsxs)("div",{style:{display:"grid",gap:2,minWidth:0,alignContent:"start"},children:[(0,he.jsx)("dt",{style:r,children:n.label}),(0,he.jsx)("dd",{style:{margin:0,overflowWrap:"anywhere",minWidth:0},children:n.linked?(0,he.jsx)(pr,{relation:n.linked.relation,refs:n.linked.refs,...a?{nodeId:e,field:n.key}:{}}):n.app?(0,he.jsx)(Kt,{address:n.app,as:"record",...a?{nodeId:e,field:n.key}:{}}):n.href?(0,he.jsx)(Mr,{href:n.href,field:n.key,value:n.value,stored:n.stored,...a?{nodeId:e}:{}}):a?(0,he.jsxs)(he.Fragment,{children:[(0,he.jsx)(Bt,{nodeId:e,field:n.key,value:n.value,stored:n.stored}),n.repeats?(0,he.jsx)(ur,{nodeId:e,field:n.key,start:t?.[n.key],value:t?.[`${n.key}Repeat`],label:`${n.label} repeats`}):null]}):n.value})]})}var v=I(q(),1),_o=[];function na({context:e}){let{store:t,brand:n,principal:a,invariantContext:r}=e;Z(t);let i=de()!==null,d=Ue(),l=decodeURIComponent(d.id??""),s=ci(t,l,{...a?{principal:a}:{},...r?{context:r}:{}}),c=Ht(t,s?.violations??_o),[m,x]=(0,at.useState)(null),[g,u]=(0,at.useState)(!1),[A,N]=(0,at.useState)(null),G=(0,at.useRef)(null),b=(0,at.useRef)(null),E=gr({flow:"both",letters:!0}),k=p=>{(G.current?.parentElement?.querySelector(`[data-affordance="${p.replace(/["\\]/g,"\\$&")}"]`)??G.current)?.focus()};if(!s)return(0,v.jsx)(te,{context:e,children:(0,v.jsx)(ie,{context:e,children:"Nothing lives at this address."})});let P=t.graph.getNode(l),K=t.schema.tryDefinition(s.kind),ae=K?.describe&&P?Xa(K,P):null,ue=[...t.log.all()].filter(p=>!Mt(p)&&(p.writes.includes(l)||p.reads.includes(l))).slice(-8).reverse(),oe=t.log.all().find(p=>!Mt(p)&&p.undoes===void 0&&p.primitives.some(T=>T.op==="add-node"&&T.node.id===l)),_=s.actions.affordances.filter(p=>p.provider!=="invariant"),ge=_.filter(p=>p.destructive||p.setsAside),Ke=g||ge.length<2?_:_.filter(p=>!ge.includes(p)),Pe=e.views?.lookup(s.kind,{cardinality:"one",fidelity:"full"}),Ce=Pe!==void 0&&!lt(Pe)?Pe:void 0,w=Ce&&P?qt(Pe,P,t.graph):void 0,f=w?s.fields.filter(p=>!w.fields.has(p.key)):s.fields,L=w?s.links.flatMap(p=>{let T=p.targets.filter(j=>!w.records.has(j.id));return T.length>0?[{...p,targets:T}]:[]}):s.links,$=Ce!==void 0&&Ua(Pe),ne=i&&ir(K).length>0,Y=$e(e).filter(p=>!p.hidden&&(p.kind===s.kind||p.across===s.kind));return(0,v.jsxs)(te,{context:e,children:[(0,v.jsxs)("header",{style:{display:"grid",gap:12},children:[(0,v.jsx)(ut,{context:e}),(0,v.jsx)(ie,{context:e,children:i&&P?.label===s.label?(0,v.jsx)(Bt,{nodeId:l,field:"label",value:s.label,said:s.label}):s.label}),ae&&ae!==s.label?(0,v.jsx)("p",{style:re,children:ae}):null,oe?.lineage?(0,v.jsxs)("p",{style:{...C,margin:0},"data-testid":"record-lineage",children:["Made by ",ht(oe,a,{graph:t.graph,schema:t.schema,...e.seats?{seats:e.seats}:{},...e.people?{people:e.people}:{}}),", ",An(oe.lineage)]}):null,(0,v.jsx)(Yt,{context:e,stop:`#focus=${encodeURIComponent(l)}`,style:{...qe,...C},"data-testid":"spatial-link"}),i&&P?(0,v.jsx)(Tn,{choices:[{on:"changed",record:l},{on:"act",record:l},{on:"reaches",kind:s.kind,condition:"",record:l}],label:"Notify me when this changes",testId:"record-notify",style:{...ke,...C,justifySelf:"start"}}):null,Y.length>0?(0,v.jsxs)("p",{style:{...C,margin:0},"data-testid":"seen-in",children:["Seen in:"," ",Y.map((p,T)=>(0,v.jsxs)("span",{children:[T>0?(0,v.jsx)("span",{"aria-hidden":"true",children:" \xB7 "}):null,(0,v.jsx)(H,{to:ye(e,p),style:U,children:p.title})," ",(0,v.jsx)(Yt,{context:e,stop:`#view=${encodeURIComponent(p.as)}`,style:{...U,...C,display:"inline-block",minWidth:24,textAlign:"center"},title:`${p.title}, in the scene`,label:`${p.title}, in the scene`,children:(0,v.jsx)("span",{"aria-hidden":"true",children:"\u2197"})})]},et(p)))]}):null]}),P&&xa(P)?(0,v.jsx)(Yo,{context:e,id:l,kind:s.kind}):null,P&&Ra(t,l)?(0,v.jsx)(zo,{context:e,id:l,kind:s.kind}):null,Ce&&P?(0,v.jsx)("section",{"data-testid":"record-view",style:{display:"grid",minWidth:0},children:(0,v.jsx)(Dr,{children:(0,v.jsx)(Zt,{when:Ot(Pe),children:(0,v.jsx)(Ce,{node:P,cardinality:"one",fidelity:"full",mode:"fullscreen",selected:!1,...s.violations.length>0?{flagged:[l]}:{}})})})}):null,s.violations.length>0?(0,v.jsx)("section",{"data-testid":"record-violations",style:{display:"grid",gap:12,padding:"16px 18px",borderLeft:"3px solid var(--graview-warn)",background:"var(--graview-panel-warning)",borderRadius:"0 var(--graview-radius, 12px) var(--graview-radius, 12px) 0"},children:c.map((p,T)=>(0,v.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,v.jsx)(rn,{violation:p,schema:t.schema,...n?{brand:n}:{}}),(0,v.jsx)(on,{store:t,repairs:pi(s.actions,p.repairs),...a?{principal:a}:{}})]},T))}):null,!$&&(f.length>0||ne)?(0,v.jsxs)("section",{style:{...ee,display:"grid",gap:14},"data-testid":"record-fields",children:[(0,v.jsx)("h2",{style:J,children:"The facts"}),er(K,f).map((p,T)=>{let j=(0,v.jsx)("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"14px 24px"},children:p.fields.map(se=>(0,v.jsx)(Ni,{nodeId:l,node:P,field:se,inPlace:i},se.key))});return p.title?(0,v.jsxs)("section",{style:{display:"grid",gap:10,minWidth:0},children:[(0,v.jsx)("h3",{"data-graview-field-group":p.title,style:{...J,fontSize:"inherit"},children:p.title}),j]},T):(0,v.jsx)("div",{children:j},T)}),ne?(0,v.jsx)(dt,{as:"unfilled",nodeId:l,skip:[...w?.fields??[]],labelStyle:we,style:{gap:4}}):null]}):null,($?[]:L).map(p=>(0,v.jsxs)("section",{style:{...ee,display:"grid",gap:10},children:[(0,v.jsx)("p",{style:we,children:ti(t,p)}),p.description?(0,v.jsx)("h2",{style:J,children:Re(p.description)}):(0,v.jsxs)("h2",{style:J,"aria-label":ze(p.edgeKind),children:[p.direction==="in"?"\u2190 ":"\u2192 ",ze(p.edgeKind)]}),(0,v.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:"6px 18px"},children:p.targets.map(T=>{let j=nr(t,p.direction==="in"?{kind:p.edgeKind,from:T.id,to:l}:{kind:p.edgeKind,from:l,to:T.id});return(0,v.jsxs)("li",{style:{display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,v.jsx)(ce,{kind:T.kind,brand:n,schema:t.schema,size:7}),(0,v.jsxs)(H,{to:z(t.schema,T.kind,T.id),style:U,children:[T.label,T.apart?(0,v.jsxs)("span",{style:C,children:[" \xB7 ",T.apart]}):null]}),j?.provisional?(0,v.jsx)(Oi,{store:t,link:j,...a?{principal:a}:{}}):null]},T.id)})}),(p.direction==="out"&&t.schema.edge(p.edgeKind)?.cardinality==="one"?[]:[...new Set(p.targets.map(T=>T.kind))]).map(T=>(0,v.jsx)(H,{to:`/${V(t.schema,T)}?${encodeURIComponent(p.edgeKind)}=${encodeURIComponent(l)}`,style:{...qe,...C},"data-testid":"related-all",children:(0,v.jsxs)(Qe,{children:["Sort and filter ",p.description??`these ${Q(t,T).toLowerCase()}`,p.targets.some(j=>j.kind!==T)?` (${Q(t,T).toLowerCase()})`:""]})},T))]},`${p.edgeKind}|${p.direction}|${p.description??""}`)),!$&&(_.length>0||s.actions.withheld.length>0)?(0,v.jsxs)("section",{style:{...ee,display:"grid",gap:14},"data-testid":"record-actions",children:[(0,v.jsx)("h2",{style:J,ref:G,tabIndex:-1,children:"What can be done"}),(0,v.jsxs)("div",{role:"toolbar","aria-label":"What can be done",...E,style:{display:"flex",flexWrap:"wrap",gap:8},children:[Ke.map(p=>{let T=m===p.id;return(0,v.jsx)("button",{type:"button","data-affordance":p.id,"data-rank":p.rank,"data-graview-act":p.mutation,[Ln]:"",autoFocus:g&&p===ge[0],"aria-expanded":T,onClick:()=>x(T?null:p.id),style:{...ke,...T?{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"}:{}},children:p.label},p.id)}),Ke.length<_.length?(0,v.jsxs)("button",{type:"button","aria-expanded":!1,onClick:()=>u(!0),style:{...ke,...C},"data-testid":"record-actions-more",[Ln]:"",children:["Show ",_.length-Ke.length," more"]}):null]}),_.map(p=>{if(m!==p.id)return null;let T=t.allMutations().find(j=>j.name===p.mutation);return T?(0,v.jsxs)("div",{ref:b,onKeyDown:j=>{if(j.key!=="Escape"||j.defaultPrevented)return;j.preventDefault(),x(null);let se=p.id;requestAnimationFrame(()=>k(se))},style:{display:"grid",gap:10,padding:18,border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,v.jsx)("h3",{style:J,children:p.label}),T.description?(0,v.jsx)("p",{style:{...C,margin:0},children:T.description}):null,(0,v.jsx)(Ie,{store:t,mutation:T,prefilled:p.args,open:p.open,label:p.label,autoFocus:!0,onDone:()=>{x(null),N(p.mutation);let j=p.id;requestAnimationFrame(()=>k(j))},...a?{principal:a}:{}})]},p.id):null}),i&&A!==null&&m===null?(0,v.jsx)(Tn,{choices:[{on:"act",act:A,record:l},{on:"act",act:A}],label:"Notify me when someone else does this",testId:"notify-after-act",style:{...ke,...C,justifySelf:"start"}}):null,(0,v.jsx)(tn,{context:e,withheld:s.actions.withheld})]}):null,i?(0,v.jsx)(ei,{id:l,style:ee,headingStyle:J}):null,ue.length>0?(0,v.jsxs)("section",{style:{...ee,display:"grid",gap:10},"data-testid":"record-history",children:[(0,v.jsx)("h2",{style:J,children:"What has happened"}),(0,v.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6},children:ue.map(p=>(0,v.jsxs)("li",{style:C,children:[(0,v.jsx)("span",{style:{color:"var(--graview-ink)"},children:p.intent}),p.lineage?(0,v.jsxs)("span",{"data-graview-lineage":"",children:[" \xB7 ",An(p.lineage)]}):null," \u2014 ",ht(p,a,{graph:t.graph,schema:t.schema,...e.seats?{seats:e.seats}:{},...e.people?{people:e.people}:{}})]},p.id))})]}):null]})}function zo({context:e,id:t,kind:n}){let{store:a,principal:r}=e,i={name:`allow-tidying-${n}`,args:{id:t}},d=a.allMutations().some(l=>l.name===i.name)&&a.permits(i,r).ok;return(0,v.jsxs)("section",{"data-testid":"record-left-alone",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:12,padding:"12px 16px",border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,v.jsxs)("p",{style:{margin:0,flex:"1 1 16rem"},children:[(0,v.jsx)("strong",{children:"Left alone."})," Nothing automated changes it; tidying passes it by."]}),d?(0,v.jsx)("button",{type:"button",style:ke,"data-testid":"allow-tidying",onClick:()=>a.apply(i,r?{author:r}:{}),children:"Allow tidying again"}):null]})}function Yo({context:e,id:t,kind:n}){let{store:a,principal:r}=e,i={name:`unarchive-${n}`,args:{id:t}},d=a.allMutations().some(c=>c.name===i.name)&&a.permits(i,r).ok,l=[...a.log.all()].reverse().find(c=>!Mt(c)&&c.mergedInto!==void 0&&c.writes.includes(t)),s=l?.mergedInto!==void 0?a.graph.getNode(l.mergedInto):void 0;return(0,v.jsxs)("section",{"data-testid":"record-archived",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:12,padding:"12px 16px",border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)"},children:[(0,v.jsxs)("p",{style:{margin:0,flex:"1 1 16rem"},children:[(0,v.jsx)("strong",{children:"Archived."})," Kept with its ties and history, and out of lists, counts and rules.",s?(0,v.jsxs)(v.Fragment,{children:[" ","Merged into ",(0,v.jsx)(H,{to:z(a.schema,s.kind,s.id),style:U,children:me(a.schema.tryDefinition(s.kind),s)}),"."]}):null]}),d?(0,v.jsx)("button",{type:"button",style:ke,"data-testid":"bring-it-back",onClick:()=>a.apply(i,r?{author:r}:{}),children:"Bring it back"}):null]})}var S=I(q(),1),Qo=Nt(()=>(__graviewPreload(import.meta.url,["./chunk.IE4ZJQV3.js","./chunk.TVWN5I4M.js","./chunk.7G4M2PX3.js","./chunk.UGFDSE37.js","./chunk.NNUUD26E.js","./chunk.OJ64WTLW.js","./chunk.GMAXA5GV.js","./chunk.IBJBCZKG.js","./chunk.NQ26KMSQ.js","./chunk.GJQF7I22.js","./chunk.SPU3BVAO.js","./chunk.OPCBZNKF.js","./chunk.UK5F3S2N.js","./chunk.2VJ52LGS.js","./chunk.JI2UVZUU.js","./chunk.CTOBNZLM.js","./chunk.34HGT7HQ.js","./chunk.TNL2BVCH.js","./chunk.NZDHXREL.js","./chunk.TBSPEO2L.js","./chunk.5ON3JSAK.js","./chunk.3SBTQ66X.js","./chunk.SSAY4ITS.js","./chunk.MB7LKKUD.js","./chunk.WVUJXDXZ.js","./chunk.GLTWLQ6L.js","./chunk.ACB4TD4W.js","./chunk.XCQ7ZPR5.js","./chunk.MY5OXSS7.js","./chunk.NVRK6A7T.js","./chunk.FKJ3HIA5.js","./chunk.GZHZLJBF.js","./chunk.OW72XZF4.js","./chunk.OJGHDWI6.js","./chunk.KRODTMGR.js","./chunk.VICCAWAN.js","./chunk.OU5TRY4N.js","./chunk.CQPNDJAC.js","./chunk.GYTVL6GR.js","./chunk.TMYGLXR6.js","./chunk.SDO3U72B.js","./chunk.P4CLT32V.js","./chunk.SLBWPVIY.js","./chunk.AJZBJBMO.js"]),import("./chunk.FG5ZFYYL.js")).then(e=>({default:e.DraftPage}))),Zo={kind:"human"};function Xo({list:e,store:t}){let n=new Set(e.members.map(d=>d.kind)),a=e.total-e.members.length,r=n.size===1?[...n][0]:void 0;if(!r)return(0,S.jsx)("p",{className:"graview-spec-text graview-spec-more",children:`and ${a} more`});let i=Ge(t.schema,r).toLowerCase();return(0,S.jsx)("p",{className:"graview-spec-text graview-spec-more",children:(0,S.jsx)(H,{to:`/${V(t.schema,r)}`,className:"graview-spec-link graview-spec-see-all","data-testid":"see-all",children:e.total===t.graph.nodesOfKind(r).length?`See all ${ft(e.total)} ${i}`:`${ft(a)} more \xB7 all ${i}`})})}function Jo({context:e,children:t}){let n=De(),a=e.store.schema,r=Ze("/").replace(/\/$/,""),i=(0,B.useMemo)(()=>({href:d=>`${r}${z(a,d.kind,d.id)}`,go:d=>n(z(a,d.kind,d.id)),more:d=>(0,S.jsx)(Xo,{list:d,store:e.store})}),[r,a,n,e.store]);return(0,S.jsx)(Gt.Provider,{value:i,children:(0,S.jsx)(Wr.Provider,{value:(e.titleLevel??(e.framed&&!e.barAbove?1:2))-1,children:t})})}var Ii=(0,B.createContext)(void 0);function es({steering:e}){let t=fe(),n=De(),a=`${t.pathname}${t.search}`;return(0,B.useLayoutEffect)(()=>e.at(a),[a,e]),(0,B.useLayoutEffect)(()=>{let r=d=>{d!==a&&n(d)};e.go.current=r;let i=e.pending?.current;return i!==void 0&&(e.pending.current=void 0,r(i)),()=>{e.go.current===r&&(e.go.current=void 0)}},[a,n,e]),null}function ts({context:e,to:t}){let{pathname:n}=fe(),a=de(),r=(t??a)?.sayWhere,i=ns(e,n);return(0,B.useEffect)(()=>(r?.(i),()=>r?.(null)),[r,i]),null}function ns(e,t){let[n="",a,r]=t.split("/").filter(Boolean).map(d=>{try{return decodeURIComponent(d)}catch{return d}});if(r!==void 0)return"#";if(n==="places"&&a!==void 0){if(a===Pn)return"#overview=1";let d=e.views?.places().find(l=>l.as===a);return d?`#focus=${encodeURIComponent(Ne(d.kind))}&view=${encodeURIComponent(d.as)}`:"#"}let i=ve(e.store.schema,n);return i?`#focus=${encodeURIComponent(a??Ne(i))}`:"#"}function as({onNavigate:e,path:t}){let n=fe(),a=Wn(),r=De(),i=n.hash&&!n.hash.includes("=")?n.hash:"",d=`${n.pathname}${n.search}${i}`,l=(0,B.useRef)(e);l.current=e;let s=(0,B.useRef)(null);(0,B.useEffect)(()=>{let m=s.current;s.current=d,m!==null&&(d===m&&a!=="PUSH"||l.current?.(d,a==="POP"?"pop":a==="REPLACE"?"replace":"push"))},[n.key]);let c=(0,B.useRef)(t);return(0,B.useEffect)(()=>{t===void 0||t===c.current||(c.current=t,t!==d&&r(t))},[t]),null}function Hi({context:e,registry:t,page:n}){let a=Ue(),r=ve(e.store.schema,a.slug??""),i=n==="list"?Jn:na,l=(r?t?.lookup(r,n):void 0)??i;return(0,S.jsx)(l,{context:e})}function rs({context:e,registry:t,children:n}){let a=(0,B.useRef)(null);return Va(a),(0,S.jsx)("div",{ref:a,"data-graview-face":"pages",style:{display:"contents"},children:(0,S.jsx)(ki,{context:e,registry:t,root:a,children:(0,S.jsx)(xi,{context:e,root:a,children:n})})})}function is(e){return e instanceof HTMLElement?e.isContentEditable||e.tagName==="TEXTAREA"||e.tagName==="SELECT"?!0:e.tagName==="INPUT"&&!["button","submit","reset","checkbox","radio","image","file","color","range"].includes(e.type):!1}function os(){let{pathname:e}=fe(),t=Wn(),n=(0,B.useRef)(null);(0,B.useLayoutEffect)(()=>{if(t!=="POP"){for(let i=n.current?.parentElement;i;i=i.parentElement){let{overflowY:d}=getComputedStyle(i);if((d==="auto"||d==="scroll")&&i.scrollHeight>i.clientHeight){i.scrollTop=0;return}}window.scrollTo(0,0)}},[e]);let a=(0,B.useRef)(e),r=(0,B.useRef)(!1);return(0,B.useEffect)(()=>{if(!r.current&&e===a.current)return;r.current=!0;let i=document.activeElement;if(is(i))return;let d=n.current?.closest("main")??document.querySelector("main"),s=n.current?.closest("[data-graview-face]")?.querySelector("[data-graview-page-title]")??d?.querySelector("h1, h2")??null??d??null;s&&(s.hasAttribute("tabindex")||s.setAttribute("tabindex","-1"),s.focus({preventScroll:!0}))},[e]),(0,S.jsx)("span",{ref:n,hidden:!0,"data-graview-scroll-reset":""})}function Fi({context:e,children:t}){let n=De(),a=Ze("/").replace(/\/$/,""),r=(0,B.useContext)(Ii),i=(0,B.useMemo)(()=>{let d=(s,c)=>{if("record"in s){let m=e.store.graph.getNode(s.record);return m?Vt(z(e.store.schema,m.kind,s.record),{section:c?.section}):void 0}if("place"in s){let m=e.views?.places().find(x=>x.as===s.place);return m?Vt(ye(e,m),c):void 0}return e.store.schema.tryDefinition(s.list)?Vt(`/${V(e.store.schema,s.list)}`,c):void 0},l=s=>{s!==void 0&&n(s)};return{record:(s,c)=>l(d({record:s},c)),place:(s,c)=>l(d({place:s},c)),list:(s,c)=>l(d({list:s},c)),draft:()=>n("/~draft"),href:(s,c)=>{let m=r===!1?void 0:d(s,c);if(m!==void 0)return r?r(m):`${a}${m}`}}},[e,n,a,r]);return(0,S.jsx)(qa.Provider,{value:i,children:t})}function ss(){let{pathname:e,search:t,hash:n}=fe();return(0,B.useEffect)(()=>{let a=decodeURIComponent(n.replace(/^#/,""));if(!(!a||a.includes("=")))return hi(a)},[e,t,n]),null}function ls({context:e,Home:t}){let n=fe(),a=e.views,r=n.key==="default"&&!(a&&Ba(a));(0,B.useEffect)(()=>{a&&Ga(a)},[a]);let i=r?$a(e.views?.arrangement?.()?.first,e.store.schema,e.views?.places()??[]):void 0,d=i?.to==="place"?ye(e,i.place):i?.to==="kind"?`/${V(e.store.schema,i.kind)}`:void 0;return d?(0,S.jsx)(Kn,{to:d,replace:!0}):(0,S.jsx)(t,{context:e})}function Di({context:e,registry:t}){let n=t?.lookupSurface("shell"),a=n!==void 0,r=a&&(t?.without().has("bar")??!1),i=a&&!r&&!e.embedded?{...e,barAbove:!0}:e,d=N=>n===void 0?(0,S.jsx)(Qt,{context:e,children:N}):r?(0,S.jsx)(n,{context:e,children:N}):(0,S.jsx)(Qt,{context:e,children:(0,S.jsx)(n,{context:i,children:N})}),l=t?.lookupSurface("home")??Zn,s=t?.lookupSurface("problems")??ea,c=a?{...i,framed:!0}:e,[m,x]=(0,B.useState)(null),g=(0,B.useMemo)(()=>({context:c,registry:t}),[c,t]),u=(0,B.useMemo)(()=>({onFind:x,find:!(t?.without().has("find")??!1),places:!(t?.without().has("places")??!1)}),[t]),A=(0,S.jsx)(Gn.Provider,{value:g,children:(0,S.jsx)(Fi,{context:e,children:(0,S.jsx)(rs,{context:e,registry:t,children:d((0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(ar,{face:"pages"}),(0,S.jsxs)(Jo,{context:c,children:[(0,S.jsx)(os,{}),(0,S.jsx)(ss,{}),(0,S.jsxs)(oi,{children:[(t?.routes()??[]).map(({path:N,component:G})=>(0,S.jsx)(Le,{path:N,element:(0,S.jsx)(G,{context:c})},N)),(0,S.jsx)(Le,{path:"/",element:(0,S.jsx)(ls,{context:c,Home:l})}),(0,S.jsx)(Le,{path:"/problems",element:(0,S.jsx)(s,{context:c})}),(0,S.jsx)(Le,{path:"/~draft",element:(0,S.jsx)(B.Suspense,{fallback:null,children:(0,S.jsx)(Qo,{context:c})})}),(0,S.jsx)(Le,{path:"/search",element:(0,S.jsx)(Xn,{context:c})}),(0,S.jsx)(Le,{path:"/map",element:(0,S.jsx)(Qn,{context:c})}),(0,S.jsx)(Le,{path:"/places",element:(0,S.jsx)(zn,{context:c})}),$e(c).some(N=>N.as===Pn)?null:(0,S.jsx)(Le,{path:Ea,element:(0,S.jsx)(Kn,{to:"/",replace:!0})}),(0,S.jsx)(Le,{path:"/places/:as",element:(0,S.jsx)(Yn,{context:c})}),(0,S.jsx)(Le,{path:"/:slug",element:(0,S.jsx)(Hi,{context:c,registry:t,page:"list"})}),(0,S.jsx)(Le,{path:"/:slug/:id",element:(0,S.jsx)(Hi,{context:c,registry:t,page:"record"})})]})]})]}))})})});return e.embedded||!a||r?A:(0,S.jsx)(di.Provider,{value:u,children:(0,S.jsx)(Sr.Provider,{value:m,children:A})})}var ds=()=>typeof document>"u"?null:document.body;function cs({context:e,registry:t,basename:n,initialPath:a,onNavigate:r,path:i,steering:d,firstLook:l,hrefOf:s,typing:c}){let[m,x]=(0,B.useState)(void 0),g=m!==void 0&&m.from===e.principal?{...e,principal:m.seat}:e;(0,B.useState)(()=>g.views?Gr(g.views,g.store.schema,En(g.brand,g.store.schema)):void 0);let u=de(),A=c??g.typing;wa({reader:g.locale??u?.locale,app:g.brand?.locale??g.app?.brand?.locale,readerTimeZone:g.timeZone??u?.timeZone,appTimeZone:g.brand?.timeZone??g.app?.brand?.timeZone});let N=g.principal??Zo,G=Fa(g.store,N,g.history),E=(G.past&&G.live===g.store?G.past.store:g.store).seenBy(N),k=E===g.store?g:{...g,store:E};Da(g.store,g.principal);let P=(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(as,{onNavigate:r,path:i}),d?(0,S.jsx)(es,{steering:d}):null,k.presence||u?(0,S.jsx)(ts,{context:k,to:u}):null,(0,S.jsx)(Di,{context:k,...t?{registry:t}:{}}),l?(0,S.jsx)(qr,{firstLook:l,root:ds,app:En(g.brand,g.store.schema)}):null]}),K=k.views?(0,S.jsxs)(Wa,{store:k.store,views:k.views,...k.principal?{principal:k.principal}:{},...k.brand?{brand:k.brand}:{},...k.locale?{locale:k.locale}:{},...k.timeZone?{timeZone:k.timeZone}:{},...k.settings?{settings:k.settings}:{},...k.presence&&!u?{presence:k.presence}:{},...A?{typing:A}:{},...k.people?{people:k.people}:{},...k.seats?{seats:k.seats}:{},onSeat:_=>u?u.takeSeat(_):x({from:e.principal,seat:_}),...k.onKeepLens?{onKeepLens:k.onKeepLens}:{},...k.ai?{ai:k.ai}:{},...k.subscriptions?{subscriptions:k.subscriptions}:{},dismissals:k.dismissals,whileAway:k.whileAway,...k.signIn?{signIn:k.signIn}:{},resolveApp:k.resolveApp??u?.resolveApp,linkedRecords:k.linkedRecords??u?.linkedRecords,...k.app?{app:k.app}:{},...k.menuSections?{menuSections:k.menuSections}:{},children:[P,(0,S.jsx)(Fi,{context:k,children:(0,S.jsx)(wi,{context:k})})]}):P,ae=(0,S.jsx)(Ia.Provider,{value:G,children:K}),ue=k.files?(0,S.jsx)(Ha.Provider,{value:k.files,children:ae}):ae,oe=s===void 0?ue:(0,S.jsx)(Ii.Provider,{value:s,children:ue});if(a!==void 0){let _=n===void 0?a:`${n.replace(/\/$/,"")}${a}`;return(0,S.jsx)(ii,{initialEntries:[_],...n===void 0?{}:{basename:n},children:oe})}return(0,S.jsx)(si,{...n===void 0?{}:{basename:n},children:oe})}export{co as a,cs as b};
@@ -1 +1 @@
1
- import{b as Ce,d as $e,i as ae}from"./chunk.UCS3CBT4.js";import{e as Te}from"./chunk.O6SKKF4V.js";import{Fd as je,I as ke,Kc as oe,Oc as ve,Pc as Oe,Wa as Se,Za as G,_ as M,aa as xe,ca as _,da as z,ea as Ae,fa as W,gd as Re,ha as we,hc as ie,ia as Ne,id as De,kd as We,ld as Me}from"./chunk.BLS2G3CD.js";function se(n,e){return n.display?.labels?.[e]??W(e)}function de(n){let e=ae(n);switch(e.type){case"text":case"date":case"number":case"boolean":case"choice":return e.type;default:return}}function Je(n,e){let t=new Map,o=n.tryDefinition(e);for(let[r,a]of Object.entries(o?.edges??{}))t.set(r,{key:r,label:a.description?M(a.description):W(r),about:"edge",far:a.to==="*"?[...n.kinds]:[...a.to]});for(let r of n.definitions)if(r.kind!==e)for(let[a,d]of Object.entries(r.edges??{}))t.has(a)||d.to!=="*"&&!d.to.includes(e)||t.set(a,{key:a,label:d.inverse?M(d.inverse):W(a),about:"edge",far:[r.kind]});return[...t.values()]}var Ze=["current","past","any","flagged","clear"];function Fe(n,e){let t=n?.lifecycle;if(!t||t.retired==="date")return!1;let o=t.retired.map(String);return e.some(r=>r.key===t.field&&o.includes(r.value))}function Be(n,e){let t=n.tryDefinition(e);if(!t)return{kind:e,sorts:[],filters:[],groups:[]};let o=new Set(t.display?.hide??[]),r=t.fields.shape??{},a=[{key:"label",label:"Name",about:"label",type:"text"}],d=[],f=[];for(let[y,x]of Object.entries(r)){if(y==="id"||y==="kind"||y==="label"||o.has(y))continue;let p=de(x);if(!p)continue;let O=se(t,y),w=p==="choice"?Le(x):p==="boolean"?["true","false"]:void 0,N={key:y,label:O,about:"field",type:p,...w?{options:w}:{}};a.push(N),d.push(N),(p==="boolean"||p==="choice")&&f.push(N),p==="date"&&f.push({...N,buckets:["day","week","month","year","decade"]})}for(let y of Je(n,e))a.push(y),d.push(y),f.push(y);let l={key:"is",label:t.lifecycle?"Standing and currency":"Standing",about:"is",type:"choice",options:t.lifecycle?[...Ze]:["flagged","clear"]};d.push(l);let u=t.fieldRoles?.order,g=u&&(u in r||u==="label")?{by:u,direction:"asc"}:void 0;return{kind:e,sorts:a,filters:d,groups:f,...g?{natural:g}:{}}}function vn(n,e){let t=[];for(let r of e.filters){let a=r.about==="edge"&&r.far?.length===1?n.tryDefinition(r.far[0]):void 0;if(!(!a||a.kind===e.kind))for(let[d,f]of Object.entries(a.fields.shape??{}))de(f)!=="choice"||a.display?.hide?.includes(d)||t.push({key:`${r.key}.${d}`,label:`${r.label} \xB7 ${se(a,d)}`,about:"via",type:"choice",options:Le(f),far:[a.kind]})}if(t.length===0)return e;let o=e.filters.filter(r=>r.about!=="is");return{...e,filters:[...o,...t,...e.filters.filter(r=>r.about==="is")]}}function On(n,e){let t=n.tryDefinition(e.kind),o=Object.entries(t?.computed??{});if(!t||o.length===0)return e;let r=o.filter(([a])=>!e.sorts.some(d=>d.key===a)).map(([a,d])=>({key:a,label:(typeof d=="object"?d.label:void 0)??se(t,a),about:"field",type:"number"}));return{...e,sorts:[...e.sorts,...r]}}function Le(n){let e=ae(n);return e.type==="choice"?e.options:[]}var Ie=n=>n,Pe=n=>n;function en(n,e,t){let o=new Map;for(let r of[...n.out(e,t),...n.in(e,t)])o.set(r.id,r);return[...o.values()]}function le(n,e,t){let o=n.schema.tryDefinition(e.kind);if(t.key==="is")switch(t.value){case"current":return _(o,Pe(e),n.today);case"past":return!_(o,Pe(e),n.today);case"any":return!0;case"flagged":return n.flagged?.has(e.id)??!1;case"clear":return!(n.flagged?.has(e.id)??!1);default:return!0}let r=o?.fields.shape??{};if(t.key in r){let l=Se(Ie(e),t.key,n.today??ke()),u=de(r[t.key]);if(u==="date"){let[g,y]=t.value.split(":");if(typeof l!="string"||!y)return!1;let x=l.slice(0,10);return g==="before"?x<y:g==="after"?x>y:x===y}if(u==="boolean")return String(l)===t.value;if(u==="number"){let g=t.value.lastIndexOf(":"),y=g>0?t.value.slice(0,g):"",x=Number(t.value.slice(g+1));if(y==="at-most"||y==="at-least")return typeof l!="number"||!Number.isFinite(x)?!1:y==="at-most"?l<=x:l>=x}return String(l)===t.value}let[a,d]=t.key.split("."),f=en(n.graph,e.id,a);return d?f.some(l=>String(Ie(l)[d])===t.value):t.value==="*"?f.length>0:t.value==="none"?f.length===0:f.some(l=>l.id===t.value)}var nn=5;function ze(n){return n.normalize("NFD").replace(/\p{M}+/gu,"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim()}function ce(n){return ze(n).replace(/ /g,"")}var U=new Map,tn=5e4;function $(n){let e=U.get(n);if(e===void 0){U.size>=tn&&U.clear();let t=ze(n);e={tokens:t.split(" ").filter(Boolean),whole:t.replace(/ /g,"")},U.set(n,e)}return e}var T=n=>[...$(n).tokens];function j(n,e){if(e.length===0)return;let{whole:t,tokens:o}=$(n),r=e.join("");if(t.length===0)return;if(t===r)return"exact";if(e.every(d=>o.some(f=>f.startsWith(d))))return t.startsWith(r)?"prefix":e.every(d=>o.includes(d))?"word":"part"}function q(n,e,t=48){let o=n.replace(/\s+/g," ").trim();if(o.length<=t)return o;let r=e[0],a=o.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase(),d=r?a.search(new RegExp(`(^|[^\\p{L}\\p{N}])${rn(r)}`,"u")):-1,f=d<0?0:d+(a[d]&&/[\p{L}\p{N}]/u.test(a[d])?0:1),l=Math.max(0,f-Math.floor(t/3));if(l>0){let g=o.lastIndexOf(" ",l);l=g<0?0:g+1}let u=Math.min(o.length,l+t);if(u<o.length){let g=o.indexOf(" ",u);u=g<0||g-u>16?u:g}return`${l>0?"\u2026":""}${o.slice(l,u).trim()}${u<o.length?"\u2026":""}`}var rn=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),on=/^([\p{L}][\p{L}\p{N}_-]*):(\S+)$/u;function an(n){let e=[],t=[];for(let o of n.trim().split(/\s+/).filter(Boolean)){let r=on.exec(o);r?t.push({key:r[1],value:r[2]}):e.push(o)}return{words:e.join(" "),conditions:t}}var Ee=new WeakMap;function Q(n,e){let t=Ee.get(e);if(t&&t.definition===n)return t.texts;let o=sn(n,e);return Ee.set(e,{definition:n,texts:o}),o}function sn(n,e){let t=z(n,e),o=[{field:"label",reading:"Name",text:t}];for(let r of $e(e,n,{limit:Number.POSITIVE_INFINITY}))r.key==="label"||r.value===t||typeof e[r.key]!="boolean"&&o.push({field:r.key,reading:r.label,text:r.markdown?Te(r.value):r.value});return o}var I={exact:0,prefix:1,word:2,part:3,field:4,near:5},Ge=new Set(["a","an","the","of","and","or","for","to","in","on","at","by","with","my","our","is"]);function Ke(n){let e=n;e.length>4&&e.endsWith("ies")?e=`${e.slice(0,-3)}y`:e.length>4&&/(ss|x|ch|sh|z)es$/.test(e)?e=e.slice(0,-2):e.length>3&&e.endsWith("s")&&!/(ss|us|is)$/.test(e)&&(e=e.slice(0,-1));for(let t of["ing","ed"])if(e.length>t.length+2&&e.endsWith(t)){e=e.slice(0,-t.length),/([b-df-hj-km-np-rtv-z])\1$/.test(e)&&(e=e.slice(0,-1));break}return e.length>3&&e.endsWith("e")?e.slice(0,-1):e}function He(n,e,t){if(Math.abs(n.length-e.length)>t)return t+1;let o=[],r=Array.from({length:e.length+1},(a,d)=>d);for(let a=1;a<=n.length;a++){let d=[a],f=a;for(let l=1;l<=e.length;l++){let u=Math.min(r[l]+1,d[l-1]+1,r[l-1]+(n[a-1]===e[l-1]?0:1));a>1&&l>1&&n[a-1]===e[l-2]&&n[a-2]===e[l-1]&&(u=Math.min(u,o[l-2]+1)),d[l]=u,u<f&&(f=u)}if(f>t)return t+1;o=r,r=d}return r[e.length]}var V=new Map;function dn(n,e){let t=V.get(n);t||(V.size>=64&&V.clear(),V.set(n,t=new Map));let o=t.get(e);return o===void 0&&(o=ln(n,e)??null,t.set(e,o)),o??void 0}function ln(n,e){if(/\d/.test(n))return;let t=Ke(n);if(t.length>=3&&(Ke(e)===t||t.length>=4&&e.startsWith(t)))return"stem";let o=n.length<4?0:n.length<=7?1:2;if(o!==0){if(He(n,e,o)<=o)return"spelling";if(n.length>=5){for(let r=n.length-o;r<=n.length+o;r++)if(r<e.length&&He(n,e.slice(0,r),o)<=o)return"spelling"}}}function cn(n,e){let t=e.length>1?e.filter(r=>!Ge.has(r)):e;if(t.length===0)return;let o;for(let r of t){let a;for(let d of n){for(let f of $(d.text).tokens){if(f.startsWith(r)){a={text:d,matched:f};break}let l=a?void 0:dn(r,f);l&&(a={text:d,matched:f,by:l})}if(a&&!a.by)break}if(!a)return;a.by&&!o&&(o={text:a.text,asked:r,matched:a.matched,by:a.by})}if(o)return{field:o.text.field,reading:o.text.reading,fragment:q(o.text.text,[o.matched]),strength:"near",asked:o.asked,matched:o.matched,by:o.by}}var fn=80;function gn(n,e,t){let o=T(e).filter(d=>!Ge.has(d)).join(" ")||e,r=t===void 0?[]:T(t),a=r.length>0&&n.find(d=>r.every(f=>$(d.text).tokens.some(l=>l.startsWith(f))))||n[0];return{field:a.field,reading:a.reading,fragment:q(a.text,r),strength:"near",asked:o,matched:(t??a.text).slice(0,fn),by:"meaning"}}function _e(n,e,t,o){let r=T(t);if(r.length===0)return;if(o){let p=Q(n,e),O=o.includes("label")||o.some(v=>typeof e[v]=="string"&&e[v]===p[0].text),w=p.filter((v,D)=>D===0?O:o.includes(v.field)),N=v=>D=>$(D.text).tokens.some(P=>P.startsWith(v));if(!r.every(v=>w.some(N(v))))return;let S=w.find(N(r[0]));return{field:S.field,reading:S.reading,fragment:q(S.text,r),strength:S.field==="label"?j(S.text,r)??"field":"field"}}let a=Q(n,e),[d,...f]=a,l=j(d.text,r);if(l)return{field:"label",reading:d.reading,fragment:q(d.text,r),strength:l};let u=p=>O=>$(O.text).tokens.some(w=>w.startsWith(p));if(!r.every(p=>a.some(u(p))))return;let g=T(d.text),y=r.find(p=>!g.some(O=>O.startsWith(p)))??r[0],x=f.find(u(y));return{field:x.field,reading:x.reading,fragment:q(x.text,[y]),strength:"field"}}var un=512,yn=64;function hn(n){let e=new Map;if(n.length===0)return e;let t=n.slice(-un),o=n[n.length-1].seq;for(let r of t){let a=Math.pow(.5,(o-r.seq)/yn);for(let d of r.writes)e.set(d,(e.get(d)??0)+a)}return e}var ge=(n,e)=>we({tryDefinition:()=>n},e),fe=(n,e)=>De({tryDefinition:()=>n},e);function pn(n,e,t){let o=n.tryDefinition(e),r=[{field:"plural",text:ge(o,e)},{field:"kind",text:W(e)},...o?.noun?[{field:"noun",text:o.noun}]:[]],a;for(let d of r){let f=j(d.text,t);f&&(!a||I[f]<I[a.strength])&&(a={strength:f,...d})}return a}var mn,bn=(n,e)=>(mn??=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0})).compare(n,e),qe=(n,e)=>(n.nearly??0)-(e.nearly??0)||(n.archived??0)-(e.archived??0)||n.tier-e.tier||n.inKind-e.inKind||n.near-e.near||n.past-e.past||n.touched-e.touched||n.flagged-e.flagged||bn(n.name,e.name)||(n.id<e.id?-1:n.id>e.id?1:0);function Ln(n,e,t={}){let o=n.schema,r=an(e),a=T(r.words),d=t.principal??{kind:"human"},f=n.kindsKeptFrom(d),l=n.modules.disabledKinds,u=r.conditions.filter(i=>i.key==="kind").map(i=>i.value),g=r.conditions.filter(i=>i.key==="is").map(i=>i.value),y=g.includes("any")||g.includes("past"),x=g.includes("past")&&!g.includes("any")&&!g.includes("current"),p=g.includes("archived")?!0:t.archived??"all",O=(i,s)=>{let c=ce(s),h=o.tryDefinition(i);return ce(i)===c||ce(ge(h,i))===c},w=o.kinds.filter(i=>!f.has(i)&&!l.has(i)&&(t.kinds===void 0||t.kinds.includes(i))&&(u.length===0||u.some(s=>O(i,s)))),S=r.conditions.filter(i=>i.key!=="kind").map(i=>({...i,admittedBy:w.filter(s=>Be(o,s).filters.some(c=>c.key===i.key))})),v=S.filter(i=>i.key!=="is"),D=g.filter(i=>i==="flagged"||i==="clear"||i==="past"||i==="archived"),P={kinds:w,past:y},Qe={hits:[],words:r.words,conditions:S,searched:P,byKind:{},total:0,matched:[]};if(a.length===0&&v.length===0&&D.length===0)return Qe;let X=t.today,F=t.flagged??new Set(n.violations().flatMap(i=>i.nodeIds)),Ue=t.touched??hn(n.log.all()),Y=new Set;for(let i of t.from??[]){Y.add(i);for(let s of n.graph.neighbors(i))Y.add(s.id)}let ue=ve(n,d)?Oe(n,d):void 0,J=oe.keptFrom?.(n,d)&&n.seenBy(d).graph,Z=i=>je(i,t.basePath===void 0?{}:{basePath:t.basePath}),ye={schema:o,graph:n.graph,flagged:F,...X?{today:X}:{}},R=[],B={},L=[],E=[],K=(i,s,c,h,m,b)=>{let A=z(c,i);B[s]=(B[s]??0)+1,R.push({hit:{about:"node",id:i.id,kind:s,label:A,why:m,current:h,flagged:F.has(i.id),address:Z(`${fe(c,s)}/${encodeURIComponent(i.id)}`),...b===void 0?{}:{near:!0},...G(i)?{archived:!0}:{}},...b===void 0?{}:{nearly:2-b},tier:I[m.strength],inKind:s===t.inKind?0:1,near:Y.has(i.id)?0:1,past:h?0:1,archived:G(i)?1:0,touched:-(Ue.get(i.id)??0),flagged:F.has(i.id)?0:1,name:A,id:i.id})};for(let i of w){let s=o.tryDefinition(i),c=S.filter(m=>m.key!=="is"&&m.admittedBy.includes(i));if(a.length===0&&c.length===0&&D.length===0)continue;let h=Fe(s,c);for(let m of n.graph.nodesOfKind(i,{archived:p})){if(ue&&!ue(m.id))continue;let b=J?J.getNode(m.id):m;if(!b)continue;let A=_(s,b,X);if(!y&&!h&&!A){if(a.length>0&&g.length===0&&c.every(k=>le(ye,b,k))){let k=_e(s,b,r.words);k&&E.push({node:b,kind:i,definition:s,why:k})}continue}if(x&&A||!c.every(k=>le(ye,b,k))||g.includes("flagged")&&!F.has(b.id)||g.includes("clear")&&F.has(b.id))continue;let C=a.length>0?_e(s,b,r.words):c[0]?{field:c[0].key,reading:W(c[0].key),fragment:`${c[0].key}:${c[0].value}`,strength:"field"}:{field:"is",reading:"Is",fragment:`is:${D[0]}`,strength:"field"};C?K(b,i,s,A,C):a.length>0&&L.push({node:b,kind:i,definition:s,current:A})}}let ee=i=>i.strength!=="field",ne=!1;if(E.length>0&&R.length===0){ne=!0;for(let i of E)K(i.node,i.kind,i.definition,!1,i.why)}else if(E.some(i=>ee(i.why))&&!R.some(i=>ee(i.hit.why))){ne=!0;for(let i of E)ee(i.why)&&K(i.node,i.kind,i.definition,!1,i.why)}let he=t.near!==!1&&a.length>0&&R.length<nn&&L.length>0,te=new Set;if(he)for(let i of L){let s=cn(Q(i.definition,i.node),a);s&&(te.add(i.node.id),K(i.node,i.kind,i.definition,i.current,s,s.by==="stem"?.9:.8))}let Ve=i=>i==="exact"||i==="prefix"?-1:I[i],re=(i,s,c,h)=>({hit:i,tier:Ve(s),inKind:1,near:1,past:0,touched:0,flagged:1,name:c,id:h});if(a.length>0){for(let s of w){let c=pn(o,s,a);if(!c)continue;let h=Ne(o,s),m={field:c.field,reading:c.field==="plural"?"Plural":"Kind",fragment:c.text,strength:c.strength};R.push(re({about:"kind",kind:s,label:h,why:m,count:B[s]??0,address:Z(fe(o.tryDefinition(s),s))},c.strength,h,`kind:${s}`))}let i=t.places??[];for(let s of Re(i.filter(c=>w.includes(c.kind)))){if(s.across&&f.has(s.across))continue;let c=j(s.title,a);if(!c)continue;let h={field:"title",reading:"Title",fragment:s.title,strength:c},m=Me(s,i)?fe(o.tryDefinition(s.kind),s.kind).slice(1):void 0,b=Z(We(s.as,m));R.push(re({about:"place",kind:s.kind,title:s.title,as:s.as,why:h,address:b},c,s.title,`place:${s.kind}:${s.as}`))}for(let s of n.allInvariants()){let c=s.scope==="graph"?void 0:s.scope.kind;if(c&&!w.includes(c))continue;let h=s.label??W(s.name),m=j(h,a),b=m?void 0:j(W(s.name),a),A=m??b;if(!A)continue;let C={field:m?"label":"name",reading:m?"Rule":"Name",fragment:m?h:s.name,strength:A};R.push(re({about:"rule",name:s.name,label:h,...c?{kind:c}:{},why:C},A,h,`rule:${s.name}`))}}let pe=()=>{R.sort(qe);let i=t.limit??50,s=R.slice(0,i).map(k=>k.hit),c=s.flatMap(k=>k.about==="node"?[(J||n.graph).getNode(k.id)]:[]).filter(Boolean),h=Ce(c,k=>o.tryDefinition(k)),m=s.map(k=>k.about==="node"&&h.has(k.id)?{...k,apart:h.get(k.id)}:k),b=Object.values(B).reduce((k,Ye)=>k+Ye,0),A=R.flatMap(k=>k.hit.about==="node"?[k.hit.id]:[]),C=t.subject&&w.includes(String(n.graph.getNode(t.subject)?.kind))?kn(n,t.subject,r.words,{principal:d}):[];return{hits:[...m,...C],words:r.words,conditions:S,searched:ne?{...P,past:!0}:P,byKind:{...B},total:b,matched:A}},H=pe(),me=t.rank;if(!he||!me)return H;let be=L.filter(i=>!te.has(i.node.id)).map(({node:i,kind:s,definition:c})=>({id:i.id,kind:s,label:z(c,i),texts:Q(c,i)}));if(be.length===0)return H;let Xe=(async()=>{let i;try{i=await me(r.words,be)}catch{return H}let s=new Map(L.filter(h=>!te.has(h.node.id)).map(h=>[h.node.id,h])),c=!1;for(let{id:h,score:m,matched:b}of Array.isArray(i)?i:[]){let A=s.get(h);!A||!(m>0)||(s.delete(h),c=!0,K(A.node,A.kind,A.definition,A.current,gn(Q(A.definition,A.node),r.words,typeof b=="string"?b:void 0),Math.min(1,m)))}return c?pe():H})();return{...H,later:Xe}}function kn(n,e,t,o={}){let r=o.principal??{kind:"human"},a=(oe.keptFrom?.(n,r)?n.seenBy(r):n).graph.getNode(e);if(!a)return[];if(n.kindsKeptFrom(r).has(a.kind))return[];let d=T(t),f=z(n.schema.tryDefinition(a.kind),a),l=[];for(let g of n.allMutations()){let y=g.subject;if(!y||y.kinds!=="*"&&!y.kinds.includes(a.kind))continue;let x=g.derived?.act;if((x==="archive"||x==="merge")&&G(a)||x==="unarchive"&&!G(a)||x==="leave-alone"&&ie(a)||x==="allow-tidying"&&!ie(a)||!n.permits({name:g.name,args:{[y.arg]:a.id}},r).ok)continue;let p=Ae(g),O=T(p),w=d.filter(v=>O.some(D=>D.startsWith(v))),N=w.length>0?j(p,w):void 0,S=N?{field:"title",reading:"Act",fragment:p,strength:N}:{field:"subject",reading:"On",fragment:f,strength:"field"};l.push({hit:{about:"act",name:g.name,title:p,subject:a.id,why:S,destructive:g.destructive===!0},tier:N?I[N]:I.field+1,inKind:0,near:0,past:g.destructive?1:0,touched:0,flagged:g.pinned?0:1,name:p,id:`act:${g.name}`})}l.sort(qe);let u=l.map(g=>g.hit);return o.limit===void 0?u:u.slice(0,o.limit)}function En(n,e){let t=e.kinds.map((a,d)=>{let f=ge(n.tryDefinition(a),a);return d===0?f:f.toLowerCase()}),o=xe(t)||"Nothing";return e.kinds.some(a=>n.tryDefinition(a)?.lifecycle)?e.past?`${M(o)}, past ones included.`:`${M(o)}, current ones; add is:any for past ones.`:`${M(o)}.`}export{se as a,de as b,Je as c,Fe as d,Be as e,vn as f,On as g,Le as h,Ie as i,Pe as j,en as k,le as l,ce as m,an as n,_e as o,hn as p,Ln as q,kn as r,En as s};
1
+ import{b as Ce,d as $e,i as ae}from"./chunk.OU5TRY4N.js";import{e as Te}from"./chunk.CQPNDJAC.js";import{I as ke,Ld as je,Qc as oe,Uc as ve,Vc as Oe,Wa as Se,Za as G,_ as M,aa as xe,ca as _,da as z,ea as Ae,fa as W,ha as we,ia as Ne,md as Re,nc as ie,od as De,qd as We,rd as Me}from"./chunk.P4CLT32V.js";function se(n,e){return n.display?.labels?.[e]??W(e)}function de(n){let e=ae(n);switch(e.type){case"text":case"date":case"number":case"boolean":case"choice":return e.type;default:return}}function Je(n,e){let t=new Map,o=n.tryDefinition(e);for(let[r,a]of Object.entries(o?.edges??{}))t.set(r,{key:r,label:a.description?M(a.description):W(r),about:"edge",far:a.to==="*"?[...n.kinds]:[...a.to]});for(let r of n.definitions)if(r.kind!==e)for(let[a,d]of Object.entries(r.edges??{}))t.has(a)||d.to!=="*"&&!d.to.includes(e)||t.set(a,{key:a,label:d.inverse?M(d.inverse):W(a),about:"edge",far:[r.kind]});return[...t.values()]}var Ze=["current","past","any","flagged","clear"];function Fe(n,e){let t=n?.lifecycle;if(!t||t.retired==="date")return!1;let o=t.retired.map(String);return e.some(r=>r.key===t.field&&o.includes(r.value))}function Be(n,e){let t=n.tryDefinition(e);if(!t)return{kind:e,sorts:[],filters:[],groups:[]};let o=new Set(t.display?.hide??[]),r=t.fields.shape??{},a=[{key:"label",label:"Name",about:"label",type:"text"}],d=[],f=[];for(let[y,x]of Object.entries(r)){if(y==="id"||y==="kind"||y==="label"||o.has(y))continue;let p=de(x);if(!p)continue;let O=se(t,y),w=p==="choice"?Le(x):p==="boolean"?["true","false"]:void 0,N={key:y,label:O,about:"field",type:p,...w?{options:w}:{}};a.push(N),d.push(N),(p==="boolean"||p==="choice")&&f.push(N),p==="date"&&f.push({...N,buckets:["day","week","month","year","decade"]})}for(let y of Je(n,e))a.push(y),d.push(y),f.push(y);let l={key:"is",label:t.lifecycle?"Standing and currency":"Standing",about:"is",type:"choice",options:t.lifecycle?[...Ze]:["flagged","clear"]};d.push(l);let u=t.fieldRoles?.order,g=u&&(u in r||u==="label")?{by:u,direction:"asc"}:void 0;return{kind:e,sorts:a,filters:d,groups:f,...g?{natural:g}:{}}}function vn(n,e){let t=[];for(let r of e.filters){let a=r.about==="edge"&&r.far?.length===1?n.tryDefinition(r.far[0]):void 0;if(!(!a||a.kind===e.kind))for(let[d,f]of Object.entries(a.fields.shape??{}))de(f)!=="choice"||a.display?.hide?.includes(d)||t.push({key:`${r.key}.${d}`,label:`${r.label} \xB7 ${se(a,d)}`,about:"via",type:"choice",options:Le(f),far:[a.kind]})}if(t.length===0)return e;let o=e.filters.filter(r=>r.about!=="is");return{...e,filters:[...o,...t,...e.filters.filter(r=>r.about==="is")]}}function On(n,e){let t=n.tryDefinition(e.kind),o=Object.entries(t?.computed??{});if(!t||o.length===0)return e;let r=o.filter(([a])=>!e.sorts.some(d=>d.key===a)).map(([a,d])=>({key:a,label:(typeof d=="object"?d.label:void 0)??se(t,a),about:"field",type:"number"}));return{...e,sorts:[...e.sorts,...r]}}function Le(n){let e=ae(n);return e.type==="choice"?e.options:[]}var Ie=n=>n,Pe=n=>n;function en(n,e,t){let o=new Map;for(let r of[...n.out(e,t),...n.in(e,t)])o.set(r.id,r);return[...o.values()]}function le(n,e,t){let o=n.schema.tryDefinition(e.kind);if(t.key==="is")switch(t.value){case"current":return _(o,Pe(e),n.today);case"past":return!_(o,Pe(e),n.today);case"any":return!0;case"flagged":return n.flagged?.has(e.id)??!1;case"clear":return!(n.flagged?.has(e.id)??!1);default:return!0}let r=o?.fields.shape??{};if(t.key in r){let l=Se(Ie(e),t.key,n.today??ke()),u=de(r[t.key]);if(u==="date"){let[g,y]=t.value.split(":");if(typeof l!="string"||!y)return!1;let x=l.slice(0,10);return g==="before"?x<y:g==="after"?x>y:x===y}if(u==="boolean")return String(l)===t.value;if(u==="number"){let g=t.value.lastIndexOf(":"),y=g>0?t.value.slice(0,g):"",x=Number(t.value.slice(g+1));if(y==="at-most"||y==="at-least")return typeof l!="number"||!Number.isFinite(x)?!1:y==="at-most"?l<=x:l>=x}return String(l)===t.value}let[a,d]=t.key.split("."),f=en(n.graph,e.id,a);return d?f.some(l=>String(Ie(l)[d])===t.value):t.value==="*"?f.length>0:t.value==="none"?f.length===0:f.some(l=>l.id===t.value)}var nn=5;function ze(n){return n.normalize("NFD").replace(/\p{M}+/gu,"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim()}function ce(n){return ze(n).replace(/ /g,"")}var U=new Map,tn=5e4;function $(n){let e=U.get(n);if(e===void 0){U.size>=tn&&U.clear();let t=ze(n);e={tokens:t.split(" ").filter(Boolean),whole:t.replace(/ /g,"")},U.set(n,e)}return e}var T=n=>[...$(n).tokens];function j(n,e){if(e.length===0)return;let{whole:t,tokens:o}=$(n),r=e.join("");if(t.length===0)return;if(t===r)return"exact";if(e.every(d=>o.some(f=>f.startsWith(d))))return t.startsWith(r)?"prefix":e.every(d=>o.includes(d))?"word":"part"}function q(n,e,t=48){let o=n.replace(/\s+/g," ").trim();if(o.length<=t)return o;let r=e[0],a=o.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase(),d=r?a.search(new RegExp(`(^|[^\\p{L}\\p{N}])${rn(r)}`,"u")):-1,f=d<0?0:d+(a[d]&&/[\p{L}\p{N}]/u.test(a[d])?0:1),l=Math.max(0,f-Math.floor(t/3));if(l>0){let g=o.lastIndexOf(" ",l);l=g<0?0:g+1}let u=Math.min(o.length,l+t);if(u<o.length){let g=o.indexOf(" ",u);u=g<0||g-u>16?u:g}return`${l>0?"\u2026":""}${o.slice(l,u).trim()}${u<o.length?"\u2026":""}`}var rn=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),on=/^([\p{L}][\p{L}\p{N}_-]*):(\S+)$/u;function an(n){let e=[],t=[];for(let o of n.trim().split(/\s+/).filter(Boolean)){let r=on.exec(o);r?t.push({key:r[1],value:r[2]}):e.push(o)}return{words:e.join(" "),conditions:t}}var Ee=new WeakMap;function Q(n,e){let t=Ee.get(e);if(t&&t.definition===n)return t.texts;let o=sn(n,e);return Ee.set(e,{definition:n,texts:o}),o}function sn(n,e){let t=z(n,e),o=[{field:"label",reading:"Name",text:t}];for(let r of $e(e,n,{limit:Number.POSITIVE_INFINITY}))r.key==="label"||r.value===t||typeof e[r.key]!="boolean"&&o.push({field:r.key,reading:r.label,text:r.markdown?Te(r.value):r.value});return o}var I={exact:0,prefix:1,word:2,part:3,field:4,near:5},Ge=new Set(["a","an","the","of","and","or","for","to","in","on","at","by","with","my","our","is"]);function Ke(n){let e=n;e.length>4&&e.endsWith("ies")?e=`${e.slice(0,-3)}y`:e.length>4&&/(ss|x|ch|sh|z)es$/.test(e)?e=e.slice(0,-2):e.length>3&&e.endsWith("s")&&!/(ss|us|is)$/.test(e)&&(e=e.slice(0,-1));for(let t of["ing","ed"])if(e.length>t.length+2&&e.endsWith(t)){e=e.slice(0,-t.length),/([b-df-hj-km-np-rtv-z])\1$/.test(e)&&(e=e.slice(0,-1));break}return e.length>3&&e.endsWith("e")?e.slice(0,-1):e}function He(n,e,t){if(Math.abs(n.length-e.length)>t)return t+1;let o=[],r=Array.from({length:e.length+1},(a,d)=>d);for(let a=1;a<=n.length;a++){let d=[a],f=a;for(let l=1;l<=e.length;l++){let u=Math.min(r[l]+1,d[l-1]+1,r[l-1]+(n[a-1]===e[l-1]?0:1));a>1&&l>1&&n[a-1]===e[l-2]&&n[a-2]===e[l-1]&&(u=Math.min(u,o[l-2]+1)),d[l]=u,u<f&&(f=u)}if(f>t)return t+1;o=r,r=d}return r[e.length]}var V=new Map;function dn(n,e){let t=V.get(n);t||(V.size>=64&&V.clear(),V.set(n,t=new Map));let o=t.get(e);return o===void 0&&(o=ln(n,e)??null,t.set(e,o)),o??void 0}function ln(n,e){if(/\d/.test(n))return;let t=Ke(n);if(t.length>=3&&(Ke(e)===t||t.length>=4&&e.startsWith(t)))return"stem";let o=n.length<4?0:n.length<=7?1:2;if(o!==0){if(He(n,e,o)<=o)return"spelling";if(n.length>=5){for(let r=n.length-o;r<=n.length+o;r++)if(r<e.length&&He(n,e.slice(0,r),o)<=o)return"spelling"}}}function cn(n,e){let t=e.length>1?e.filter(r=>!Ge.has(r)):e;if(t.length===0)return;let o;for(let r of t){let a;for(let d of n){for(let f of $(d.text).tokens){if(f.startsWith(r)){a={text:d,matched:f};break}let l=a?void 0:dn(r,f);l&&(a={text:d,matched:f,by:l})}if(a&&!a.by)break}if(!a)return;a.by&&!o&&(o={text:a.text,asked:r,matched:a.matched,by:a.by})}if(o)return{field:o.text.field,reading:o.text.reading,fragment:q(o.text.text,[o.matched]),strength:"near",asked:o.asked,matched:o.matched,by:o.by}}var fn=80;function gn(n,e,t){let o=T(e).filter(d=>!Ge.has(d)).join(" ")||e,r=t===void 0?[]:T(t),a=r.length>0&&n.find(d=>r.every(f=>$(d.text).tokens.some(l=>l.startsWith(f))))||n[0];return{field:a.field,reading:a.reading,fragment:q(a.text,r),strength:"near",asked:o,matched:(t??a.text).slice(0,fn),by:"meaning"}}function _e(n,e,t,o){let r=T(t);if(r.length===0)return;if(o){let p=Q(n,e),O=o.includes("label")||o.some(v=>typeof e[v]=="string"&&e[v]===p[0].text),w=p.filter((v,D)=>D===0?O:o.includes(v.field)),N=v=>D=>$(D.text).tokens.some(P=>P.startsWith(v));if(!r.every(v=>w.some(N(v))))return;let S=w.find(N(r[0]));return{field:S.field,reading:S.reading,fragment:q(S.text,r),strength:S.field==="label"?j(S.text,r)??"field":"field"}}let a=Q(n,e),[d,...f]=a,l=j(d.text,r);if(l)return{field:"label",reading:d.reading,fragment:q(d.text,r),strength:l};let u=p=>O=>$(O.text).tokens.some(w=>w.startsWith(p));if(!r.every(p=>a.some(u(p))))return;let g=T(d.text),y=r.find(p=>!g.some(O=>O.startsWith(p)))??r[0],x=f.find(u(y));return{field:x.field,reading:x.reading,fragment:q(x.text,[y]),strength:"field"}}var un=512,yn=64;function hn(n){let e=new Map;if(n.length===0)return e;let t=n.slice(-un),o=n[n.length-1].seq;for(let r of t){let a=Math.pow(.5,(o-r.seq)/yn);for(let d of r.writes)e.set(d,(e.get(d)??0)+a)}return e}var ge=(n,e)=>we({tryDefinition:()=>n},e),fe=(n,e)=>De({tryDefinition:()=>n},e);function pn(n,e,t){let o=n.tryDefinition(e),r=[{field:"plural",text:ge(o,e)},{field:"kind",text:W(e)},...o?.noun?[{field:"noun",text:o.noun}]:[]],a;for(let d of r){let f=j(d.text,t);f&&(!a||I[f]<I[a.strength])&&(a={strength:f,...d})}return a}var mn,bn=(n,e)=>(mn??=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0})).compare(n,e),qe=(n,e)=>(n.nearly??0)-(e.nearly??0)||(n.archived??0)-(e.archived??0)||n.tier-e.tier||n.inKind-e.inKind||n.near-e.near||n.past-e.past||n.touched-e.touched||n.flagged-e.flagged||bn(n.name,e.name)||(n.id<e.id?-1:n.id>e.id?1:0);function Ln(n,e,t={}){let o=n.schema,r=an(e),a=T(r.words),d=t.principal??{kind:"human"},f=n.kindsKeptFrom(d),l=n.modules.disabledKinds,u=r.conditions.filter(i=>i.key==="kind").map(i=>i.value),g=r.conditions.filter(i=>i.key==="is").map(i=>i.value),y=g.includes("any")||g.includes("past"),x=g.includes("past")&&!g.includes("any")&&!g.includes("current"),p=g.includes("archived")?!0:t.archived??"all",O=(i,s)=>{let c=ce(s),h=o.tryDefinition(i);return ce(i)===c||ce(ge(h,i))===c},w=o.kinds.filter(i=>!f.has(i)&&!l.has(i)&&(t.kinds===void 0||t.kinds.includes(i))&&(u.length===0||u.some(s=>O(i,s)))),S=r.conditions.filter(i=>i.key!=="kind").map(i=>({...i,admittedBy:w.filter(s=>Be(o,s).filters.some(c=>c.key===i.key))})),v=S.filter(i=>i.key!=="is"),D=g.filter(i=>i==="flagged"||i==="clear"||i==="past"||i==="archived"),P={kinds:w,past:y},Qe={hits:[],words:r.words,conditions:S,searched:P,byKind:{},total:0,matched:[]};if(a.length===0&&v.length===0&&D.length===0)return Qe;let X=t.today,F=t.flagged??new Set(n.violations().flatMap(i=>i.nodeIds)),Ue=t.touched??hn(n.log.all()),Y=new Set;for(let i of t.from??[]){Y.add(i);for(let s of n.graph.neighbors(i))Y.add(s.id)}let ue=ve(n,d)?Oe(n,d):void 0,J=oe.keptFrom?.(n,d)&&n.seenBy(d).graph,Z=i=>je(i,t.basePath===void 0?{}:{basePath:t.basePath}),ye={schema:o,graph:n.graph,flagged:F,...X?{today:X}:{}},R=[],B={},L=[],E=[],K=(i,s,c,h,m,b)=>{let A=z(c,i);B[s]=(B[s]??0)+1,R.push({hit:{about:"node",id:i.id,kind:s,label:A,why:m,current:h,flagged:F.has(i.id),address:Z(`${fe(c,s)}/${encodeURIComponent(i.id)}`),...b===void 0?{}:{near:!0},...G(i)?{archived:!0}:{}},...b===void 0?{}:{nearly:2-b},tier:I[m.strength],inKind:s===t.inKind?0:1,near:Y.has(i.id)?0:1,past:h?0:1,archived:G(i)?1:0,touched:-(Ue.get(i.id)??0),flagged:F.has(i.id)?0:1,name:A,id:i.id})};for(let i of w){let s=o.tryDefinition(i),c=S.filter(m=>m.key!=="is"&&m.admittedBy.includes(i));if(a.length===0&&c.length===0&&D.length===0)continue;let h=Fe(s,c);for(let m of n.graph.nodesOfKind(i,{archived:p})){if(ue&&!ue(m.id))continue;let b=J?J.getNode(m.id):m;if(!b)continue;let A=_(s,b,X);if(!y&&!h&&!A){if(a.length>0&&g.length===0&&c.every(k=>le(ye,b,k))){let k=_e(s,b,r.words);k&&E.push({node:b,kind:i,definition:s,why:k})}continue}if(x&&A||!c.every(k=>le(ye,b,k))||g.includes("flagged")&&!F.has(b.id)||g.includes("clear")&&F.has(b.id))continue;let C=a.length>0?_e(s,b,r.words):c[0]?{field:c[0].key,reading:W(c[0].key),fragment:`${c[0].key}:${c[0].value}`,strength:"field"}:{field:"is",reading:"Is",fragment:`is:${D[0]}`,strength:"field"};C?K(b,i,s,A,C):a.length>0&&L.push({node:b,kind:i,definition:s,current:A})}}let ee=i=>i.strength!=="field",ne=!1;if(E.length>0&&R.length===0){ne=!0;for(let i of E)K(i.node,i.kind,i.definition,!1,i.why)}else if(E.some(i=>ee(i.why))&&!R.some(i=>ee(i.hit.why))){ne=!0;for(let i of E)ee(i.why)&&K(i.node,i.kind,i.definition,!1,i.why)}let he=t.near!==!1&&a.length>0&&R.length<nn&&L.length>0,te=new Set;if(he)for(let i of L){let s=cn(Q(i.definition,i.node),a);s&&(te.add(i.node.id),K(i.node,i.kind,i.definition,i.current,s,s.by==="stem"?.9:.8))}let Ve=i=>i==="exact"||i==="prefix"?-1:I[i],re=(i,s,c,h)=>({hit:i,tier:Ve(s),inKind:1,near:1,past:0,touched:0,flagged:1,name:c,id:h});if(a.length>0){for(let s of w){let c=pn(o,s,a);if(!c)continue;let h=Ne(o,s),m={field:c.field,reading:c.field==="plural"?"Plural":"Kind",fragment:c.text,strength:c.strength};R.push(re({about:"kind",kind:s,label:h,why:m,count:B[s]??0,address:Z(fe(o.tryDefinition(s),s))},c.strength,h,`kind:${s}`))}let i=t.places??[];for(let s of Re(i.filter(c=>w.includes(c.kind)))){if(s.across&&f.has(s.across))continue;let c=j(s.title,a);if(!c)continue;let h={field:"title",reading:"Title",fragment:s.title,strength:c},m=Me(s,i)?fe(o.tryDefinition(s.kind),s.kind).slice(1):void 0,b=Z(We(s.as,m));R.push(re({about:"place",kind:s.kind,title:s.title,as:s.as,why:h,address:b},c,s.title,`place:${s.kind}:${s.as}`))}for(let s of n.allInvariants()){let c=s.scope==="graph"?void 0:s.scope.kind;if(c&&!w.includes(c))continue;let h=s.label??W(s.name),m=j(h,a),b=m?void 0:j(W(s.name),a),A=m??b;if(!A)continue;let C={field:m?"label":"name",reading:m?"Rule":"Name",fragment:m?h:s.name,strength:A};R.push(re({about:"rule",name:s.name,label:h,...c?{kind:c}:{},why:C},A,h,`rule:${s.name}`))}}let pe=()=>{R.sort(qe);let i=t.limit??50,s=R.slice(0,i).map(k=>k.hit),c=s.flatMap(k=>k.about==="node"?[(J||n.graph).getNode(k.id)]:[]).filter(Boolean),h=Ce(c,k=>o.tryDefinition(k)),m=s.map(k=>k.about==="node"&&h.has(k.id)?{...k,apart:h.get(k.id)}:k),b=Object.values(B).reduce((k,Ye)=>k+Ye,0),A=R.flatMap(k=>k.hit.about==="node"?[k.hit.id]:[]),C=t.subject&&w.includes(String(n.graph.getNode(t.subject)?.kind))?kn(n,t.subject,r.words,{principal:d}):[];return{hits:[...m,...C],words:r.words,conditions:S,searched:ne?{...P,past:!0}:P,byKind:{...B},total:b,matched:A}},H=pe(),me=t.rank;if(!he||!me)return H;let be=L.filter(i=>!te.has(i.node.id)).map(({node:i,kind:s,definition:c})=>({id:i.id,kind:s,label:z(c,i),texts:Q(c,i)}));if(be.length===0)return H;let Xe=(async()=>{let i;try{i=await me(r.words,be)}catch{return H}let s=new Map(L.filter(h=>!te.has(h.node.id)).map(h=>[h.node.id,h])),c=!1;for(let{id:h,score:m,matched:b}of Array.isArray(i)?i:[]){let A=s.get(h);!A||!(m>0)||(s.delete(h),c=!0,K(A.node,A.kind,A.definition,A.current,gn(Q(A.definition,A.node),r.words,typeof b=="string"?b:void 0),Math.min(1,m)))}return c?pe():H})();return{...H,later:Xe}}function kn(n,e,t,o={}){let r=o.principal??{kind:"human"},a=(oe.keptFrom?.(n,r)?n.seenBy(r):n).graph.getNode(e);if(!a)return[];if(n.kindsKeptFrom(r).has(a.kind))return[];let d=T(t),f=z(n.schema.tryDefinition(a.kind),a),l=[];for(let g of n.allMutations()){let y=g.subject;if(!y||y.kinds!=="*"&&!y.kinds.includes(a.kind))continue;let x=g.derived?.act;if((x==="archive"||x==="merge")&&G(a)||x==="unarchive"&&!G(a)||x==="leave-alone"&&ie(a)||x==="allow-tidying"&&!ie(a)||!n.permits({name:g.name,args:{[y.arg]:a.id}},r).ok)continue;let p=Ae(g),O=T(p),w=d.filter(v=>O.some(D=>D.startsWith(v))),N=w.length>0?j(p,w):void 0,S=N?{field:"title",reading:"Act",fragment:p,strength:N}:{field:"subject",reading:"On",fragment:f,strength:"field"};l.push({hit:{about:"act",name:g.name,title:p,subject:a.id,why:S,destructive:g.destructive===!0},tier:N?I[N]:I.field+1,inKind:0,near:0,past:g.destructive?1:0,touched:0,flagged:g.pinned?0:1,name:p,id:`act:${g.name}`})}l.sort(qe);let u=l.map(g=>g.hit);return o.limit===void 0?u:u.slice(0,o.limit)}function En(n,e){let t=e.kinds.map((a,d)=>{let f=ge(n.tryDefinition(a),a);return d===0?f:f.toLowerCase()}),o=xe(t)||"Nothing";return e.kinds.some(a=>n.tryDefinition(a)?.lifecycle)?e.past?`${M(o)}, past ones included.`:`${M(o)}, current ones; add is:any for past ones.`:`${M(o)}.`}export{se as a,de as b,Je as c,Fe as d,Be as e,vn as f,On as g,Le as h,Ie as i,Pe as j,en as k,le as l,ce as m,an as n,_e as o,hn as p,Ln as q,kn as r,En as s};
@@ -1 +1 @@
1
- import"./chunk.ZK446PSX.js";import{G as W,S as x}from"./chunk.SGMVLKZO.js";import"./chunk.SDO3U72B.js";import"./chunk.BLS2G3CD.js";import"./chunk.EJUZGIQ5.js";import{b as D}from"./chunk.AJZBJBMO.js";var g=D(W(),1);var o=D(x(),1),v=864e5,l=t=>Date.UTC(+t.slice(0,4),+t.slice(5,7)-1,+t.slice(8,10)),I=t=>new Date(t).toISOString().slice(0,10),s=(t,i)=>I(l(t)+i*v),m=(t,i)=>{let a=new Date(l(t)),u=a.getUTCMonth()+i,d=Date.UTC(a.getUTCFullYear(),u,1),w=new Date(Date.UTC(a.getUTCFullYear(),u+1,0)).getUTCDate();return I(d+(Math.min(a.getUTCDate(),w)-1)*v)};function p(t,i,a){try{return new Intl.DateTimeFormat(t??"en-US",{...i,timeZone:"UTC"}).format(a)}catch{return new Intl.DateTimeFormat("en-US",{...i,timeZone:"UTC"}).format(a)}}function F(t){try{let i=new Intl.Locale(t??"en-US"),a=i.getWeekInfo?.().firstDay??i.weekInfo?.firstDay;if(a!==void 0)return a%7}catch{return 0}return/^en-US|^en$|-(US|CA|JP|BR|IL|MX|PH)$/.test(t??"en-US")?0:1}function L({id:t,label:i,selected:a,today:u,locale:d,onPick:w,onClose:T}){let[r,f]=(0,g.useState)(a??u),U=(0,g.useRef)(null),y=F(d),b=`${r.slice(0,7)}-01`,M=(new Date(l(b)).getUTCDay()-y+7)%7,P=s(b,-M),A=Array.from({length:6},(e,n)=>Array.from({length:7},(S,c)=>s(P,n*7+c))),$=p(d,{month:"long",year:"numeric"},l(b)),h=(0,g.useRef)(!0);(0,g.useEffect)(()=>{h.current&&U.current?.querySelector(`[data-day="${r}"]`)?.focus(),h.current=!1},[r]);let E=e=>{let n={ArrowLeft:()=>s(r,-1),ArrowRight:()=>s(r,1),ArrowUp:()=>s(r,-7),ArrowDown:()=>s(r,7),PageUp:()=>m(r,e.shiftKey?-12:-1),PageDown:()=>m(r,e.shiftKey?12:1),Home:()=>s(r,-((new Date(l(r)).getUTCDay()-y+7)%7)),End:()=>s(r,6-(new Date(l(r)).getUTCDay()-y+7)%7)};n[e.key]?(e.preventDefault(),h.current=!0,f(n[e.key]())):e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),T())},R=Array.from({length:7},(e,n)=>l("1970-01-04")+(y+n)%7*v),C={minWidth:32,minHeight:32,padding:"0 8px",borderRadius:6};return(0,o.jsxs)("div",{id:t,role:"group","aria-label":`Pick a date for ${i}`,"data-graview-part":"when-month",onKeyDown:e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),T())},style:{flexBasis:"100%",width:"min(100%, 20rem)",boxSizing:"border-box",padding:8,border:"1px solid var(--graview-edge)",borderRadius:8,background:"var(--graview-panel)",color:"var(--graview-ink)"},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6,marginBottom:6},children:[(0,o.jsx)("button",{type:"button","aria-label":"Previous month",onClick:()=>f(m(r,-1)),style:C,children:"\u2039"}),(0,o.jsx)("span",{id:`${t}-title`,"aria-live":"polite",style:{fontWeight:600,fontSize:"0.875rem"},children:$}),(0,o.jsx)("button",{type:"button","aria-label":"Next month",onClick:()=>f(m(r,1)),style:C,children:"\u203A"})]}),(0,o.jsxs)("table",{ref:U,role:"grid","aria-labelledby":`${t}-title`,onKeyDown:E,style:{width:"100%",borderCollapse:"collapse",tableLayout:"fixed",fontSize:"0.8125rem"},children:[(0,o.jsx)("thead",{children:(0,o.jsx)("tr",{children:R.map(e=>(0,o.jsx)("th",{scope:"col",abbr:p(d,{weekday:"long"},e),style:{fontWeight:500,color:"var(--graview-ink-faint)",padding:"2px 0"},children:p(d,{weekday:"narrow"},e)},e))})}),(0,o.jsx)("tbody",{children:A.map(e=>(0,o.jsx)("tr",{children:e.map(n=>{let S=n.slice(0,7)===b.slice(0,7),c=n===a,k=n===u;return(0,o.jsx)("td",{role:"gridcell","aria-selected":c||void 0,style:{padding:1,textAlign:"center"},children:(0,o.jsx)("button",{type:"button","data-day":n,tabIndex:n===r?0:-1,"aria-label":`${p(d,{weekday:"long",year:"numeric",month:"long",day:"numeric"},l(n))}${k?", today":""}${c?", selected":""}`,...k?{"aria-current":"date"}:{},onClick:()=>w(n),onFocus:()=>n!==r&&f(n),style:{width:"100%",minHeight:36,padding:0,borderRadius:6,border:k?"1px solid var(--graview-accent)":"1px solid transparent",background:c?"var(--graview-accent)":"transparent",color:c?"var(--graview-accent-ink)":S?"var(--graview-ink)":"var(--graview-ink-faint)",fontWeight:c?600:400},children:Number(n.slice(8,10))})},n)})},e[0]))})]})]})}export{L as WhenMonth};
1
+ import"./chunk.GYTVL6GR.js";import{G as W,T as x}from"./chunk.TMYGLXR6.js";import"./chunk.SDO3U72B.js";import"./chunk.P4CLT32V.js";import"./chunk.SLBWPVIY.js";import{b as D}from"./chunk.AJZBJBMO.js";var g=D(W(),1);var o=D(x(),1),v=864e5,l=t=>Date.UTC(+t.slice(0,4),+t.slice(5,7)-1,+t.slice(8,10)),I=t=>new Date(t).toISOString().slice(0,10),s=(t,i)=>I(l(t)+i*v),m=(t,i)=>{let a=new Date(l(t)),u=a.getUTCMonth()+i,d=Date.UTC(a.getUTCFullYear(),u,1),w=new Date(Date.UTC(a.getUTCFullYear(),u+1,0)).getUTCDate();return I(d+(Math.min(a.getUTCDate(),w)-1)*v)};function p(t,i,a){try{return new Intl.DateTimeFormat(t??"en-US",{...i,timeZone:"UTC"}).format(a)}catch{return new Intl.DateTimeFormat("en-US",{...i,timeZone:"UTC"}).format(a)}}function F(t){try{let i=new Intl.Locale(t??"en-US"),a=i.getWeekInfo?.().firstDay??i.weekInfo?.firstDay;if(a!==void 0)return a%7}catch{return 0}return/^en-US|^en$|-(US|CA|JP|BR|IL|MX|PH)$/.test(t??"en-US")?0:1}function L({id:t,label:i,selected:a,today:u,locale:d,onPick:w,onClose:T}){let[r,f]=(0,g.useState)(a??u),U=(0,g.useRef)(null),y=F(d),b=`${r.slice(0,7)}-01`,M=(new Date(l(b)).getUTCDay()-y+7)%7,P=s(b,-M),A=Array.from({length:6},(e,n)=>Array.from({length:7},(S,c)=>s(P,n*7+c))),$=p(d,{month:"long",year:"numeric"},l(b)),h=(0,g.useRef)(!0);(0,g.useEffect)(()=>{h.current&&U.current?.querySelector(`[data-day="${r}"]`)?.focus(),h.current=!1},[r]);let E=e=>{let n={ArrowLeft:()=>s(r,-1),ArrowRight:()=>s(r,1),ArrowUp:()=>s(r,-7),ArrowDown:()=>s(r,7),PageUp:()=>m(r,e.shiftKey?-12:-1),PageDown:()=>m(r,e.shiftKey?12:1),Home:()=>s(r,-((new Date(l(r)).getUTCDay()-y+7)%7)),End:()=>s(r,6-(new Date(l(r)).getUTCDay()-y+7)%7)};n[e.key]?(e.preventDefault(),h.current=!0,f(n[e.key]())):e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),T())},R=Array.from({length:7},(e,n)=>l("1970-01-04")+(y+n)%7*v),C={minWidth:32,minHeight:32,padding:"0 8px",borderRadius:6};return(0,o.jsxs)("div",{id:t,role:"group","aria-label":`Pick a date for ${i}`,"data-graview-part":"when-month",onKeyDown:e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),T())},style:{flexBasis:"100%",width:"min(100%, 20rem)",boxSizing:"border-box",padding:8,border:"1px solid var(--graview-edge)",borderRadius:8,background:"var(--graview-panel)",color:"var(--graview-ink)"},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6,marginBottom:6},children:[(0,o.jsx)("button",{type:"button","aria-label":"Previous month",onClick:()=>f(m(r,-1)),style:C,children:"\u2039"}),(0,o.jsx)("span",{id:`${t}-title`,"aria-live":"polite",style:{fontWeight:600,fontSize:"0.875rem"},children:$}),(0,o.jsx)("button",{type:"button","aria-label":"Next month",onClick:()=>f(m(r,1)),style:C,children:"\u203A"})]}),(0,o.jsxs)("table",{ref:U,role:"grid","aria-labelledby":`${t}-title`,onKeyDown:E,style:{width:"100%",borderCollapse:"collapse",tableLayout:"fixed",fontSize:"0.8125rem"},children:[(0,o.jsx)("thead",{children:(0,o.jsx)("tr",{children:R.map(e=>(0,o.jsx)("th",{scope:"col",abbr:p(d,{weekday:"long"},e),style:{fontWeight:500,color:"var(--graview-ink-faint)",padding:"2px 0"},children:p(d,{weekday:"narrow"},e)},e))})}),(0,o.jsx)("tbody",{children:A.map(e=>(0,o.jsx)("tr",{children:e.map(n=>{let S=n.slice(0,7)===b.slice(0,7),c=n===a,k=n===u;return(0,o.jsx)("td",{role:"gridcell","aria-selected":c||void 0,style:{padding:1,textAlign:"center"},children:(0,o.jsx)("button",{type:"button","data-day":n,tabIndex:n===r?0:-1,"aria-label":`${p(d,{weekday:"long",year:"numeric",month:"long",day:"numeric"},l(n))}${k?", today":""}${c?", selected":""}`,...k?{"aria-current":"date"}:{},onClick:()=>w(n),onFocus:()=>n!==r&&f(n),style:{width:"100%",minHeight:36,padding:0,borderRadius:6,border:k?"1px solid var(--graview-accent)":"1px solid transparent",background:c?"var(--graview-accent)":"transparent",color:c?"var(--graview-accent-ink)":S?"var(--graview-ink)":"var(--graview-ink-faint)",fontWeight:c?600:400},children:Number(n.slice(8,10))})},n)})},e[0]))})]})]})}export{L as WhenMonth};
@@ -1 +1 @@
1
- import{Xa as g}from"./chunk.BLS2G3CD.js";function y(e){return[`based on \u201C${e.basis}\u201D`,...e.confidence!==void 0?[`${Math.round(e.confidence*100)}% sure`]:[],...e.model?[e.model]:[]].join(" \xB7 ")}var u=e=>`Not yet kept by a person. ${e.by.name??e.by.id??"Something"} made it${e.lineage?`, ${y(e.lineage)}`:""}.`,p=e=>`${e.kind}\0${e.from}\0${e.to}`;function k(e,o){let r=new Map;for(let n of e){if(n.undoes!==void 0||o.has(n.id)||n.withheld)continue;let l=g(n.author),s=l==="human"||l==="visitor",c=new Map;for(let t of n.primitives){if(t.op!=="add-edge"&&t.op!=="remove-edge")continue;let i=p(t.edge),a=r.get(i)??c.get(i);if(r.delete(i),t.op==="remove-edge")a&&c.set(i,a);else if(a&&(s||!n.lineage))r.set(i,s?{...a,provisional:!1,keptBy:n.id}:a);else{let d=n.lineage;r.set(i,{edge:t.edge,made:n.id,by:n.author,...d?{lineage:d}:{},provisional:!s&&(d?.confidence??1)<1})}}}return r}var f=new WeakMap;function v({log:e}){let o=e.all(),r=`${e.horizon}:${o.length}:${o.at(-1)?.id}`,n=f.get(e);return n?.at!==r&&f.set(e,n={at:r,links:k(o,e.undoneIds())}),n.links}var L=(e,o)=>v(e).get(p(o));var m=e=>[...v(e).values()].filter(o=>o.provisional);export{y as a,u as b,L as c,m as d};
1
+ import{Xa as g}from"./chunk.P4CLT32V.js";function y(e){return[`based on \u201C${e.basis}\u201D`,...e.confidence!==void 0?[`${Math.round(e.confidence*100)}% sure`]:[],...e.model?[e.model]:[]].join(" \xB7 ")}var u=e=>`Not yet kept by a person. ${e.by.name??e.by.id??"Something"} made it${e.lineage?`, ${y(e.lineage)}`:""}.`,p=e=>`${e.kind}\0${e.from}\0${e.to}`;function k(e,o){let r=new Map;for(let n of e){if(n.undoes!==void 0||o.has(n.id)||n.withheld)continue;let l=g(n.author),s=l==="human"||l==="visitor",c=new Map;for(let t of n.primitives){if(t.op!=="add-edge"&&t.op!=="remove-edge")continue;let i=p(t.edge),a=r.get(i)??c.get(i);if(r.delete(i),t.op==="remove-edge")a&&c.set(i,a);else if(a&&(s||!n.lineage))r.set(i,s?{...a,provisional:!1,keptBy:n.id}:a);else{let d=n.lineage;r.set(i,{edge:t.edge,made:n.id,by:n.author,...d?{lineage:d}:{},provisional:!s&&(d?.confidence??1)<1})}}}return r}var f=new WeakMap;function v({log:e}){let o=e.all(),r=`${e.horizon}:${o.length}:${o.at(-1)?.id}`,n=f.get(e);return n?.at!==r&&f.set(e,n={at:r,links:k(o,e.undoneIds())}),n.links}var L=(e,o)=>v(e).get(p(o));var m=e=>[...v(e).values()].filter(o=>o.provisional);export{y as a,u as b,L as c,m as d};