graview 0.1.65 → 0.1.67

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 (265) hide show
  1. package/dist/index.js +4 -4
  2. package/dist/index.js.map +1 -1
  3. package/dist/preview/{chunk.3IZEZPJB.js → chunk.25QFDTCU.js} +1 -1
  4. package/dist/preview/{chunk.SOMRYDDH.js → chunk.264PB572.js} +1 -1
  5. package/dist/preview/chunk.2FHIINXG.js +2 -0
  6. package/dist/preview/chunk.2VUX54XH.js +1 -0
  7. package/dist/preview/chunk.32SHA3EY.js +1 -0
  8. package/dist/preview/{chunk.ZDUTEM3Z.js → chunk.35KMZHB7.js} +1 -1
  9. package/dist/preview/{chunk.74B6KQF4.js → chunk.37RFCHSS.js} +1 -1
  10. package/dist/preview/chunk.3ENPWZBG.js +1 -0
  11. package/dist/preview/chunk.3GNT5MKP.js +50 -0
  12. package/dist/preview/chunk.3NSV3WKM.js +22 -0
  13. package/dist/preview/chunk.3ZODN6BW.js +1 -0
  14. package/dist/preview/{chunk.7VQ3C7F4.js → chunk.47XEJZ3O.js} +1 -1
  15. package/dist/preview/{chunk.KIQXTQDU.js → chunk.4EMKCKDB.js} +1 -1
  16. package/dist/preview/{chunk.LKK5YF2H.js → chunk.4UUJHLHR.js} +1 -1
  17. package/dist/preview/{chunk.L6FGKJ5H.js → chunk.4W57E7AX.js} +1 -1
  18. package/dist/preview/chunk.55G4IPOO.js +1 -0
  19. package/dist/preview/chunk.5AKZROMR.js +1 -0
  20. package/dist/preview/chunk.5J6DVR7S.js +1 -0
  21. package/dist/preview/chunk.5R744JGZ.js +19 -0
  22. package/dist/preview/{chunk.64FCAUAJ.js → chunk.6KJGRM7A.js} +1 -1
  23. package/dist/preview/{chunk.INTJD5WG.js → chunk.6N4PE3U5.js} +1 -1
  24. package/dist/preview/{chunk.44ZHHPPJ.js → chunk.6NG76MDA.js} +2 -2
  25. package/dist/preview/chunk.6SJEZWH3.js +1 -0
  26. package/dist/preview/chunk.6UQFV53C.js +1 -0
  27. package/dist/preview/chunk.6W6XMLSF.js +1 -0
  28. package/dist/preview/chunk.77C556NM.js +1 -0
  29. package/dist/preview/{chunk.7E4CSXBT.js → chunk.7ARRVNUR.js} +1 -1
  30. package/dist/preview/chunk.7BJRHPE3.js +23 -0
  31. package/dist/preview/{chunk.TY74U3EI.js → chunk.7S6ZRMW4.js} +1 -1
  32. package/dist/preview/{chunk.F5VEHAP2.js → chunk.7UHPHEH5.js} +1 -1
  33. package/dist/preview/chunk.7WHQWLL6.js +1 -0
  34. package/dist/preview/{chunk.NSO6RUKW.js → chunk.A4EZAGG7.js} +1 -1
  35. package/dist/preview/chunk.A5PSEU3W.js +25 -0
  36. package/dist/preview/{chunk.2TZSLREX.js → chunk.A7GVTE5Y.js} +2 -2
  37. package/dist/preview/chunk.AJMVRFYX.js +5 -0
  38. package/dist/preview/chunk.AKJS2NUM.js +1 -0
  39. package/dist/preview/chunk.ARWO4WOV.js +1 -0
  40. package/dist/preview/chunk.B5SJMCTT.js +7 -0
  41. package/dist/preview/{chunk.2QQ37RCZ.js → chunk.B7KZBT27.js} +1 -1
  42. package/dist/preview/chunk.BDNQMKDG.js +35 -0
  43. package/dist/preview/chunk.BKYZSV2Y.js +2 -0
  44. package/dist/preview/chunk.CEQQIW7Z.js +1 -0
  45. package/dist/preview/chunk.CKDCTFLU.js +1 -0
  46. package/dist/preview/chunk.CTUJZ3IV.js +1 -0
  47. package/dist/preview/chunk.CY7FFKEZ.js +1 -0
  48. package/dist/preview/chunk.D4WJ7OM5.js +1 -0
  49. package/dist/preview/{chunk.AB4RZSYW.js → chunk.D7NWMXSX.js} +16 -16
  50. package/dist/preview/chunk.DEKRFTRN.js +4 -0
  51. package/dist/preview/{chunk.6YDC6IDA.js → chunk.DKEIEH2D.js} +1 -1
  52. package/dist/preview/{chunk.S2DOVJRL.js → chunk.DWM7AR5Y.js} +1 -1
  53. package/dist/preview/{chunk.FHHVW2WB.js → chunk.DZMIYEHQ.js} +1 -1
  54. package/dist/preview/chunk.E5PYNAYT.js +21 -0
  55. package/dist/preview/chunk.EBKH3ILT.js +1 -0
  56. package/dist/preview/chunk.EFVSZKB5.js +1 -0
  57. package/dist/preview/chunk.EG7OOJH5.js +1 -0
  58. package/dist/preview/chunk.EGPCVMDU.js +1 -0
  59. package/dist/preview/{chunk.C437FVD7.js → chunk.EJ2EZL2G.js} +1 -1
  60. package/dist/preview/{chunk.IR4OW67N.js → chunk.EP6Q32WT.js} +1 -1
  61. package/dist/preview/{chunk.G3Q5IMM3.js → chunk.F464JKHZ.js} +1 -1
  62. package/dist/preview/{chunk.IFBGYFS4.js → chunk.FLJXYESX.js} +1 -1
  63. package/dist/preview/chunk.FOUBDGL3.js +1 -0
  64. package/dist/preview/chunk.FPHRAO3R.js +1 -0
  65. package/dist/preview/chunk.FRQSLWP4.js +1 -0
  66. package/dist/preview/chunk.FVQKSN33.js +1 -0
  67. package/dist/preview/{chunk.CGQ6KXVK.js → chunk.G3GFDVO2.js} +1 -1
  68. package/dist/preview/{chunk.4O3C2LJF.js → chunk.G5GVT6JY.js} +1 -1
  69. package/dist/preview/chunk.GFLH7RCI.js +1 -0
  70. package/dist/preview/chunk.GG47EIKO.js +1 -0
  71. package/dist/preview/chunk.GMLONS5L.js +1 -0
  72. package/dist/preview/{chunk.RFVOXX3P.js → chunk.GRFD42WM.js} +1 -1
  73. package/dist/preview/{chunk.2PK335JQ.js → chunk.GVT4UUQA.js} +1 -1
  74. package/dist/preview/{chunk.5M34BJIQ.js → chunk.H3EGBDW2.js} +1 -1
  75. package/dist/preview/chunk.H6KIEDZN.js +1 -0
  76. package/dist/preview/chunk.HAOB6O72.js +1 -0
  77. package/dist/preview/chunk.HB5NWHFP.js +3 -0
  78. package/dist/preview/{chunk.GPCKOYSF.js → chunk.HJUZMOW2.js} +1 -1
  79. package/dist/preview/chunk.HN4ZJ4B4.js +1 -0
  80. package/dist/preview/chunk.HVBKI5ZO.js +1 -0
  81. package/dist/preview/chunk.I3SDKMQS.js +1 -0
  82. package/dist/preview/chunk.IAEGJDF3.js +1 -0
  83. package/dist/preview/{chunk.CS72MISN.js → chunk.IDALEKIW.js} +1 -1
  84. package/dist/preview/chunk.ILJDLBPJ.js +1 -0
  85. package/dist/preview/chunk.J2OPIS3H.js +111 -0
  86. package/dist/preview/chunk.J5OLYVZ4.js +1 -0
  87. package/dist/preview/{chunk.3KUYB5ZT.js → chunk.J6HF7IRQ.js} +1 -1
  88. package/dist/preview/chunk.JEC5FDKX.js +1 -0
  89. package/dist/preview/chunk.JKFVNQY7.js +1 -0
  90. package/dist/preview/chunk.JO2X52D4.js +1 -0
  91. package/dist/preview/{chunk.LVD3V77M.js → chunk.JQ2WNKDW.js} +1 -1
  92. package/dist/preview/{chunk.NBVPWLRY.js → chunk.JQ63N4MZ.js} +1 -1
  93. package/dist/preview/{chunk.7Q43N5JS.js → chunk.JU6UFWS3.js} +1 -1
  94. package/dist/preview/chunk.JVB5KDSG.js +1 -0
  95. package/dist/preview/chunk.KFT7JIEH.js +1 -0
  96. package/dist/preview/chunk.KGMSSXZL.js +1 -0
  97. package/dist/preview/chunk.KX5ZBHMA.js +2 -0
  98. package/dist/preview/{chunk.XTTESA7X.js → chunk.LP2ZMAT2.js} +1 -1
  99. package/dist/preview/{chunk.IMKD6QQG.js → chunk.LRNFE3UK.js} +1 -1
  100. package/dist/preview/{chunk.BUQKRXI6.js → chunk.LVOTLGJB.js} +1 -1
  101. package/dist/preview/chunk.LYEGRY77.js +3 -0
  102. package/dist/preview/{chunk.B3WVCSW5.js → chunk.M5FP4Y4Q.js} +1 -1
  103. package/dist/preview/{chunk.MH46V556.js → chunk.M7KXQGQL.js} +1 -1
  104. package/dist/preview/{chunk.LY5CY7GE.js → chunk.MAKCZ6B6.js} +1 -1
  105. package/dist/preview/{chunk.5THLLSS4.js → chunk.MJY4SLWA.js} +1 -1
  106. package/dist/preview/{chunk.J6KNEI5R.js → chunk.MSAYU25L.js} +1 -1
  107. package/dist/preview/chunk.MUSMNKE4.js +1 -0
  108. package/dist/preview/chunk.MW7R5G3C.js +1 -0
  109. package/dist/preview/chunk.N4ZKZ4GM.js +6 -0
  110. package/dist/preview/chunk.NAXOXBOF.js +1 -0
  111. package/dist/preview/{chunk.LGRQDILY.js → chunk.NKLPL7QD.js} +1 -1
  112. package/dist/preview/chunk.NKYWIGC7.js +3 -0
  113. package/dist/preview/{chunk.35E75QJ7.js → chunk.NRURQGXV.js} +1 -1
  114. package/dist/preview/chunk.NSOPYIT4.js +1 -0
  115. package/dist/preview/chunk.NXZL5CA2.js +1 -0
  116. package/dist/preview/chunk.NYLKG25K.js +4 -0
  117. package/dist/preview/{chunk.BU5PVRX7.js → chunk.O2OL6RQQ.js} +1 -1
  118. package/dist/preview/chunk.O5VFKVZS.js +1 -0
  119. package/dist/preview/chunk.OCXY5DCD.js +6 -0
  120. package/dist/preview/chunk.OHAO6KKH.js +1 -0
  121. package/dist/preview/{chunk.CXDGE5ZS.js → chunk.OWO3OV62.js} +1 -1
  122. package/dist/preview/chunk.P2EKKKK2.js +1 -0
  123. package/dist/preview/chunk.PSNMZBVS.js +1 -0
  124. package/dist/preview/{chunk.NKYYDFIX.js → chunk.PZ7KY6XH.js} +1 -1
  125. package/dist/preview/chunk.QAM76AXV.js +1 -0
  126. package/dist/preview/chunk.QDVGHI7R.js +1 -0
  127. package/dist/preview/{chunk.HJS3LTSR.js → chunk.QF5QB5YR.js} +1 -1
  128. package/dist/preview/chunk.QNP5OR3P.js +93 -0
  129. package/dist/preview/chunk.QRQ5WPZI.js +1 -0
  130. package/dist/preview/chunk.QWGWOEBZ.js +90 -0
  131. package/dist/preview/chunk.QXLJGHMC.js +23 -0
  132. package/dist/preview/{chunk.3RFAUIGT.js → chunk.QZQCQWQG.js} +1 -1
  133. package/dist/preview/chunk.R6JBA7UK.js +1 -0
  134. package/dist/preview/chunk.R7CRBRD4.js +1 -0
  135. package/dist/preview/chunk.RD2FSSLV.js +1 -0
  136. package/dist/preview/{chunk.CD6YWH6T.js → chunk.RG5G6YQD.js} +1 -1
  137. package/dist/preview/{chunk.T3KNLP7C.js → chunk.RJY7VJBH.js} +1 -1
  138. package/dist/preview/chunk.RR25BGWP.js +1 -0
  139. package/dist/preview/chunk.RSMCTI2N.js +1 -0
  140. package/dist/preview/{chunk.ZYNC73DJ.js → chunk.RSQ432QN.js} +1 -1
  141. package/dist/preview/chunk.SFBHPYRD.js +1 -0
  142. package/dist/preview/{chunk.FOSY7MZF.js → chunk.SJQPTDAT.js} +1 -1
  143. package/dist/preview/{chunk.TUCSUZNO.js → chunk.SNHKYH72.js} +1 -1
  144. package/dist/preview/chunk.SO6NT5K7.js +1 -0
  145. package/dist/preview/{chunk.FDWRH5P2.js → chunk.STPA7HBK.js} +3 -3
  146. package/dist/preview/{chunk.R2TSTDS3.js → chunk.SY5ID44D.js} +1 -1
  147. package/dist/preview/chunk.T27QKVKP.js +1 -0
  148. package/dist/preview/{chunk.FXG5AJF6.js → chunk.T2OUHRAA.js} +1 -1
  149. package/dist/preview/chunk.T3WCRS6M.js +1 -0
  150. package/dist/preview/chunk.TI5FR2QQ.js +1 -0
  151. package/dist/preview/{chunk.N2FNHRI2.js → chunk.TTSGCNPT.js} +1 -1
  152. package/dist/preview/{chunk.P6TZGR3A.js → chunk.TXZQEJ5T.js} +1 -1
  153. package/dist/preview/chunk.U6QXLNHF.js +15 -0
  154. package/dist/preview/{chunk.DICM56FT.js → chunk.UDHPMVC4.js} +1 -1
  155. package/dist/preview/{chunk.ZMWAZACO.js → chunk.UGQYMN4J.js} +1 -1
  156. package/dist/preview/chunk.UJPX3BUV.js +1 -0
  157. package/dist/preview/{chunk.CPYBJNHP.js → chunk.UQIPEMJ5.js} +1 -1
  158. package/dist/preview/{chunk.XSWR5LI4.js → chunk.URQTF5SY.js} +1 -1
  159. package/dist/preview/{chunk.7IGD2K4M.js → chunk.UW52CMGJ.js} +1 -1
  160. package/dist/preview/chunk.UWS4RMM3.js +1 -0
  161. package/dist/preview/{chunk.KHAVEYT7.js → chunk.V7H4BUEB.js} +1 -1
  162. package/dist/preview/{chunk.KHRS2SKB.js → chunk.VBHV4TLG.js} +1 -1
  163. package/dist/preview/chunk.VBLQJVQ5.js +1 -0
  164. package/dist/preview/{chunk.SPCAMQJE.js → chunk.WALVW3KJ.js} +1 -1
  165. package/dist/preview/{chunk.6RZHKQP3.js → chunk.WEMUKZKH.js} +1 -1
  166. package/dist/preview/chunk.X226YATK.js +2 -0
  167. package/dist/preview/{chunk.IJ3YDBWI.js → chunk.XFLGSUYO.js} +1 -1
  168. package/dist/preview/{chunk.ZTN7BS5O.js → chunk.XSWSBTUO.js} +1 -1
  169. package/dist/preview/{chunk.ZJFXM3LE.js → chunk.YCD4JSXD.js} +1 -1
  170. package/dist/preview/{chunk.QSDBF7VL.js → chunk.YZPESGCP.js} +1 -1
  171. package/dist/preview/{chunk.QO5RXOCS.js → chunk.Z27NSSYL.js} +2 -2
  172. package/dist/preview/chunk.Z2XUVJAL.js +1 -0
  173. package/dist/preview/{chunk.S3EEY7T3.js → chunk.Z3O2VZAJ.js} +1 -1
  174. package/dist/preview/chunk.Z4TY44CD.js +1 -0
  175. package/dist/preview/{chunk.O2W5JTWA.js → chunk.ZAPS4J6G.js} +1 -1
  176. package/dist/preview/{chunk.F2TWV4TX.js → chunk.ZAQ4IDX6.js} +1 -1
  177. package/dist/preview/chunk.ZEZUKRC6.js +5 -0
  178. package/dist/preview/{chunk.PTQPS2FJ.js → chunk.ZG5VGP5U.js} +1 -1
  179. package/dist/preview/chunk.ZRBGYXAO.js +6 -0
  180. package/dist/preview/index.html +57 -55
  181. package/dist/preview/page.js +2 -2
  182. package/dist/preview/splash.js +17 -14
  183. package/package.json +6 -6
  184. package/dist/preview/chunk.2P34ML3O.js +0 -111
  185. package/dist/preview/chunk.2UW5CRHF.js +0 -1
  186. package/dist/preview/chunk.2YMO7ZVX.js +0 -1
  187. package/dist/preview/chunk.33ULA3CG.js +0 -1
  188. package/dist/preview/chunk.3CJLAJXP.js +0 -25
  189. package/dist/preview/chunk.3IJSB5ET.js +0 -1
  190. package/dist/preview/chunk.3KO35VN4.js +0 -1
  191. package/dist/preview/chunk.3L37FY3G.js +0 -4
  192. package/dist/preview/chunk.3WP66LB5.js +0 -1
  193. package/dist/preview/chunk.4GJ7F4SP.js +0 -35
  194. package/dist/preview/chunk.4IJTPV5X.js +0 -1
  195. package/dist/preview/chunk.4JFBLVXJ.js +0 -1
  196. package/dist/preview/chunk.4PCVQEVI.js +0 -1
  197. package/dist/preview/chunk.5FQSYMAE.js +0 -1
  198. package/dist/preview/chunk.5NCLZ4NZ.js +0 -1
  199. package/dist/preview/chunk.5YNLFOBJ.js +0 -5
  200. package/dist/preview/chunk.77XQEDT5.js +0 -1
  201. package/dist/preview/chunk.7HPQI5SY.js +0 -1
  202. package/dist/preview/chunk.A4VA3DU5.js +0 -1
  203. package/dist/preview/chunk.ABSY3UZF.js +0 -1
  204. package/dist/preview/chunk.ARHAD5IS.js +0 -1
  205. package/dist/preview/chunk.BOC2EOGB.js +0 -9
  206. package/dist/preview/chunk.BR6TINGU.js +0 -1
  207. package/dist/preview/chunk.CDEAAWPS.js +0 -1
  208. package/dist/preview/chunk.CXJJB3MK.js +0 -1
  209. package/dist/preview/chunk.CXLQPE4J.js +0 -1
  210. package/dist/preview/chunk.DA4RSHLW.js +0 -1
  211. package/dist/preview/chunk.DJMSXXP4.js +0 -90
  212. package/dist/preview/chunk.DJPNVXBQ.js +0 -6
  213. package/dist/preview/chunk.DJVHKBEI.js +0 -1
  214. package/dist/preview/chunk.DVSTLVIH.js +0 -15
  215. package/dist/preview/chunk.E5WJSTOV.js +0 -1
  216. package/dist/preview/chunk.FEGSYSA7.js +0 -1
  217. package/dist/preview/chunk.HJUXC5GM.js +0 -1
  218. package/dist/preview/chunk.HNMSYQRA.js +0 -1
  219. package/dist/preview/chunk.HWLRKOI3.js +0 -1
  220. package/dist/preview/chunk.IHUMKFYH.js +0 -10
  221. package/dist/preview/chunk.IQ54QTA5.js +0 -1
  222. package/dist/preview/chunk.IQC3GOXO.js +0 -1
  223. package/dist/preview/chunk.ISN2QTVL.js +0 -2
  224. package/dist/preview/chunk.J24YPQ5I.js +0 -5
  225. package/dist/preview/chunk.J545NAMY.js +0 -1
  226. package/dist/preview/chunk.K2HDEL7I.js +0 -1
  227. package/dist/preview/chunk.K3JARAWU.js +0 -1
  228. package/dist/preview/chunk.KROR65KD.js +0 -2
  229. package/dist/preview/chunk.KV7GZBJ6.js +0 -50
  230. package/dist/preview/chunk.L7NJLZWV.js +0 -1
  231. package/dist/preview/chunk.LON75VHP.js +0 -1
  232. package/dist/preview/chunk.LQWVJQ5X.js +0 -18
  233. package/dist/preview/chunk.M5W2RHC6.js +0 -1
  234. package/dist/preview/chunk.M6BTLH24.js +0 -1
  235. package/dist/preview/chunk.MAGKI4PD.js +0 -1
  236. package/dist/preview/chunk.MD36ZSM5.js +0 -74
  237. package/dist/preview/chunk.MFZJVHWP.js +0 -1
  238. package/dist/preview/chunk.MHTA4HYB.js +0 -19
  239. package/dist/preview/chunk.N2YM247R.js +0 -1
  240. package/dist/preview/chunk.N35SJWAM.js +0 -1
  241. package/dist/preview/chunk.NJSK3UO2.js +0 -6
  242. package/dist/preview/chunk.OHMHPTEW.js +0 -1
  243. package/dist/preview/chunk.OJGHDWI6.js +0 -1
  244. package/dist/preview/chunk.PV2I4UPH.js +0 -1
  245. package/dist/preview/chunk.QFQSSZN7.js +0 -1
  246. package/dist/preview/chunk.RSS6OHXG.js +0 -1
  247. package/dist/preview/chunk.SBCAYTMT.js +0 -1
  248. package/dist/preview/chunk.SMTGRCMG.js +0 -3
  249. package/dist/preview/chunk.TCZIZ2PU.js +0 -1
  250. package/dist/preview/chunk.U74PTRHJ.js +0 -1
  251. package/dist/preview/chunk.UAORKZLO.js +0 -1
  252. package/dist/preview/chunk.UDVTPI2W.js +0 -1
  253. package/dist/preview/chunk.UETLP5KC.js +0 -1
  254. package/dist/preview/chunk.UHI3X2YD.js +0 -1
  255. package/dist/preview/chunk.UL62ELNR.js +0 -1
  256. package/dist/preview/chunk.VRYSZYAD.js +0 -1
  257. package/dist/preview/chunk.VUZFLDOX.js +0 -1
  258. package/dist/preview/chunk.X2NGFOAF.js +0 -1
  259. package/dist/preview/chunk.XE762VL2.js +0 -2
  260. package/dist/preview/chunk.Y2RZ5B4U.js +0 -1
  261. package/dist/preview/chunk.YKMBXMZE.js +0 -1
  262. package/dist/preview/chunk.Z34KASY7.js +0 -1
  263. package/dist/preview/chunk.ZMGKWMID.js +0 -1
  264. package/dist/preview/chunk.ZT5YQSSP.js +0 -21
  265. package/dist/preview/chunk.ZZM75ZTN.js +0 -4
@@ -0,0 +1,2 @@
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 Ve,b as Qt}from"./chunk.VBHV4TLG.js";import"./chunk.T6PU3NKP.js";import"./chunk.VBLQJVQ5.js";import"./chunk.47XEJZ3O.js";import{j as Bt,k as Ut,l as Gt}from"./chunk.DEKRFTRN.js";import"./chunk.BKYZSV2Y.js";import"./chunk.GVT4UUQA.js";import"./chunk.J6HF7IRQ.js";import"./chunk.LRNFE3UK.js";import"./chunk.HJCQ6I3S.js";import"./chunk.YCD4JSXD.js";import"./chunk.ZG5VGP5U.js";import"./chunk.NAXOXBOF.js";import{a as jt,b as O}from"./chunk.6W6XMLSF.js";import{a as Ye,b as Ft}from"./chunk.PZ7KY6XH.js";import"./chunk.WEMUKZKH.js";import"./chunk.T27QKVKP.js";import"./chunk.TBY5IR7C.js";import"./chunk.URQTF5SY.js";import"./chunk.BIDL7GQD.js";import"./chunk.LP2ZMAT2.js";import"./chunk.MSAYU25L.js";import{b as qt,c as Kt}from"./chunk.EGPCVMDU.js";import"./chunk.M7KXQGQL.js";import"./chunk.XOZU4OFA.js";import"./chunk.H3EGBDW2.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.6SJEZWH3.js";import"./chunk.6N4PE3U5.js";import"./chunk.YFVJUHAK.js";import"./chunk.B7KZBT27.js";import"./chunk.DWM7AR5Y.js";import"./chunk.6KJGRM7A.js";import"./chunk.WALVW3KJ.js";import"./chunk.SNHKYH72.js";import"./chunk.UGQYMN4J.js";import"./chunk.RG5G6YQD.js";import{v as _t}from"./chunk.QRQ5WPZI.js";import"./chunk.RD2FSSLV.js";import"./chunk.37RFCHSS.js";import"./chunk.SO6NT5K7.js";import"./chunk.MUSMNKE4.js";import{l as Wt}from"./chunk.SJQPTDAT.js";import{b as Nt}from"./chunk.JQ63N4MZ.js";import"./chunk.Z3O2VZAJ.js";import{a as Be,c as Ue,e as Ge,f as zt,m as Qe}from"./chunk.QNP5OR3P.js";import"./chunk.4W57E7AX.js";import{G as Se,Pa as Ke,Ua as Dt,W as Ot,Ya as Pt,ea as xe,h as Lt,u as It}from"./chunk.A5PSEU3W.js";import"./chunk.SDO3U72B.js";import{Lc as Rt,Nc as $t,Pb as Et,nd as Ht,pa as At,ta as ve,td as Ct,ua as ke}from"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import{b as ee}from"./chunk.AJZBJBMO.js";var s=ee(Se(),1);function Yt(a){return a.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").split(/[^\p{L}\p{N}]+/u).filter(Boolean)}function Vt(a,r){let n=Yt(r);if(n.length===0)return!0;let l=Yt(a);return n.every(b=>l.some(m=>m.startsWith(b)))}var te=ee(Se(),1),Je=250,Xe=.2,Ln=a=>a===void 0||a.off?void 0:a.fast??(a.decide?{model:a.name??"decide",decide:a.decide}:void 0);function Jt(a,r,n){let[l,b]=(0,te.useState)(null),m=(0,te.useRef)(n);m.current=n;let y=n.map(c=>`${c.key}\0${c.label}`).join(""),u=Ln(a);return(0,te.useEffect)(()=>{let c=r.trim();if(!u||c===""||m.current.length===0)return;let g=!0,x=new Map(m.current.map((w,f)=>[`r${f+1}`,w])),v=setTimeout(()=>{u.decide({typed:c},{row:{type:"choice",instructions:`Which of these menu rows does somebody typing \u201C${c}\u201D mean?`,criteria:{...Object.fromEntries([...x].map(([w,f])=>[w,f.label])),none:"None of these rows"}}}).then(w=>{a?.meter?.({tier:"fast",model:u.model,inputTokens:w.usage.inputTokens,outputTokens:w.usage.outputTokens,interaction:"menu"});let f=w.answers.row;if(!g||f?.type!=="choice")return;let k=new Map;for(let[G,ne]of Object.entries(f.probabilities)){let B=x.get(G);B&&k.set(B.key,ne)}if(f.choice==="none")return b({words:c,chances:new Map});let S=x.get(f.choice);S&&!k.has(S.key)&&k.set(S.key,f.confidence),b({words:c,chances:k})}).catch(()=>{})},Je);return()=>{g=!1,clearTimeout(v)}},[r,y,u===void 0]),l!==null&&l.words===r.trim()?l.chances:null}var z=ee(Se(),1),Zt=2,Xt,In=()=>Xt??=(__graviewPreload(import.meta.url,["./chunk.X226YATK.js","./chunk.BJUUSIQY.js","./chunk.6KJGRM7A.js","./chunk.Z3O2VZAJ.js","./chunk.QNP5OR3P.js","./chunk.4W57E7AX.js","./chunk.A5PSEU3W.js","./chunk.SDO3U72B.js","./chunk.ZEZUKRC6.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.CKDCTFLU.js")).catch(a=>(Xt=void 0,Promise.reject(a)));function en(a,r,n,l,b,m,y=4){let u=a&&!a.off?a.told:void 0,c=l.trim()!=="",[g,x]=(0,z.useState)(null);(0,z.useEffect)(()=>x(null),[m]);let[v,w]=(0,z.useState)(!1);return(0,z.useEffect)(()=>{if(!u||m===null||m===void 0)return;let f=globalThis;if(!f.requestIdleCallback)return;let k=f.requestIdleCallback(()=>w(!0),{timeout:3e3});return()=>f.cancelIdleCallback?.(k)},[u,m]),(0,z.useEffect)(()=>{if(!u||g||!(c||v))return;let f=!0;return In().then(async k=>{let S=await k.readToldHere(u,r,n);f&&x({tellings:S,module:k})}).catch(()=>{}),()=>{f=!1}},[u,c,v,g,r,n]),(0,z.useMemo)(()=>g?c?g.module.toldSuggestionsFrom(g.tellings,r,n,l,b,y):g.module.toldForHere(g.tellings,r,n,b,3):[],[g,c,l,r,n,b,y])}var K=ee(Se(),1),tn=a=>a.replace(/\s*…\s*$/u,"").replace(/\s+/g," ").trim().toLowerCase();function on(a,r,n={},l){if(!r)return[];let b=[],m=[];for(let y of a){if(y.destructive||y.setsAside||y.ties)continue;let u=y.open.filter(f=>!f.optional);if(u.length===0&&y.open.length===0&&l){let f=y.label.replace(/\b(it|this one|this)\b/u,`\u201C${l}\u201D`);m.push({key:`act:${y.id}`,label:f!==y.label?f:`${y.label} \u201C${l}\u201D`,mode:"chat",source:"act"});continue}let c=u[0];if(u.length!==1||c?.shape?.type!=="choice"||!c.shape.options||c.shape.options.length<2)continue;let g=c.shape.options,x=g.indexOf(String(r[c.name]??"")),v=x>=0?g[x+1]:void 0;if(v===void 0)continue;let w=n[c.name]?.[v]??v.replace(/[-_]+/g," ").replace(/^./u,f=>f.toUpperCase());b.push({key:`act:${y.id}:${v}`,label:`${y.label.replace(/\s*…\s*$/u,"")} to ${w}`,mode:"chat",source:"act"})}return[...b,...m]}function rn(a,r){let n=new Set(r.map(tn));return a.filter(l=>!n.has(tn(l.label)))}var On=3,Dn=a=>a===void 0||a.off||a.suggestOnOpen===!1?void 0:a.fast??(a.decide?{model:a.name??"decide",decide:a.decide}:void 0),Ze=new WeakMap,nn=(a,r)=>a?Ze.get(a)?.get(r):void 0;function Pn(a){let r=u=>a.filter(c=>c.source===u),[n,l,b]=[r("nudge"),r("told"),r("act")],m=[],y=Math.max(n.length,l.length,b.length);for(let u=0;u<y;u++)for(let c of[n,l,b])c[u]&&m.push(c[u]);return m}function an(a,r,n,l){let b=Dn(a),m=r.map(v=>`${v.key}\0${v.label}`).join(""),[y,u]=(0,K.useState)(null),c=nn(n.depends,m)??y;(0,K.useEffect)(()=>{if(nn(n.depends,m)||(u(null),!b||r.length===0||n.opened===null||n.opened===void 0))return;let v=!0,w=new Map(r.map((k,S)=>[`s${S+1}`,k])),f={pick:{type:"choice",instructions:`Somebody right-clicked \u201C${n.name}\u201D in an app. Which of these would they most likely want to do next?`,criteria:Object.fromEntries([...w].map(([k,S])=>[k,S.label]))}};if(n.better)for(let[k,S]of w)f[`about_${k}`]={type:"choice",instructions:`Is \u201C${S.label}\u201D about how \u201C${n.name}\u201D looks or is laid out, or about the records in it?`,criteria:{look:"How it looks or is laid out: style, size, what each row or card shows, its order or grouping",records:"The records themselves: changing, finishing, adding, assigning or asking about them"}};return b.decide({on:n.name},f).then(k=>{if(a?.meter?.({tier:"fast",model:b.model,inputTokens:k.usage.inputTokens,outputTokens:k.usage.outputTokens,interaction:"menu"}),!v)return;let S=k.answers.pick,G=R=>S?.type==="choice"?S.probabilities[R]??(S.choice===R?S.confidence:0):0,ne=[...w.keys()].sort((R,oe)=>G(oe)-G(R)).map(R=>w.get(R).key),B=new Map;for(let[R,oe]of w){let Q=k.answers[`about_${R}`];Q?.type==="choice"&&B.set(oe.key,Q.choice==="look"?"better":"chat")}let p={said:m,order:ne,modes:B};if(n.depends){let R=Ze.get(n.depends)??new Map;R.set(m,p),Ze.set(n.depends,R)}u(p)}).catch(()=>{}),()=>{v=!1}},[m,n.opened,n.depends,b===void 0]);let g=(0,K.useMemo)(()=>(c&&c.said===m?c.order.map(w=>r.find(f=>f.key===w)).filter(Boolean):Pn(r)).slice(0,On).map(w=>({...w,mode:c?.modes.get(w.key)??w.mode})),[c,m,r]),x=(0,K.useRef)(g);return l||(x.current=g),l?x.current:g}var i=ee(Ot(),1);function po(a,r,n){let l=r.on??r.about[r.about.length-1];Bt(a,r.about,{...n,pins:Ve(),...l===void 0?{}:{focus:l}})}function ho({placement:a="float",chosen:r=!0}={}){let{menuAt:n}=xe();return a==="menu"&&n===null?r?(0,i.jsx)(zn,{}):null:(0,i.jsx)(Wn,{placement:a})}function zn(){let{store:a,setMenuAt:r,view:n}=xe(),{selection:l}=Ke(),b=(0,s.useRef)(null),[m,y]=(0,s.useState)(null),[u,c]=(0,s.useState)(null);(0,s.useLayoutEffect)(()=>{let x=b.current?.offsetParent??b.current?.parentElement;if(!x)return;let v=x.getBoundingClientRect(),w=Math.round(v.width);w!==m&&y(w);let f=[...x.querySelectorAll('[data-testid="lines-key"][data-graview-up-row], [data-testid="overview"]')].map(S=>S.getBoundingClientRect()).filter(S=>S.width>0&&S.top-v.top<40),k=f.length>0?Math.round(v.right-Math.min(...f.map(S=>S.left))+8):null;k!==u&&c(k)});let g=l.length===1&&!n.overview?a.graph.getNode(l[0]):void 0;return!g||m===null||m>=dn?(0,i.jsx)("span",{ref:b,hidden:!0}):(0,i.jsx)("button",{type:"button",ref:b,"data-testid":"chosen-acts","aria-label":`What can be done with ${O(a,g.id)}`,"aria-haspopup":"menu",onClick:x=>{let v=x.currentTarget.getBoundingClientRect();r({x:Math.round(v.right),y:Math.round(v.bottom+4),on:g.id})},style:{position:"absolute",...u!==null?{right:u,top:14,minHeight:38}:{right:"calc(14px + var(--graview-dock, 0px))",top:98},zIndex:"var(--graview-layer-overview, 10)",...u===null?{minHeight:30}:{},padding:"0 12px",borderRadius:8,fontSize:"0.8125rem",background:"var(--graview-float)",boxShadow:"var(--graview-lift-low)"},children:"Acts\u2026"})}function Nn(a,r,n){let l=u=>ke(a.schema.tryDefinition(u),u),b=u=>At(a.schema,u).toLowerCase(),m=r.filter(u=>a.allMutations().some(c=>{let g=c.subject;return g?.kinds==="*"||(g?.kinds??[]).includes(u)})),y=n.length!==1||n.some(u=>u.startsWith("aggregate:"));return m.length>0&&y?r.length===1?`Nothing here is done to all the ${b(r[0])} at once. Right-click one ${l(r[0])} to see what you can do with it.`:"Nothing here is done to all of these at once. Right-click one of them to see what you can do with it.":m.length>0?`There is nothing you can do with ${r.length===1?ve(l(r[0])):"these"} here right now.`:r.length===1?`There is nothing to do with ${ve(l(r[0]))} in this app yet.`:"There is nothing to do with these in this app yet."}var dn=564;function Wn({placement:a}){let{store:r,menuAt:n,setMenuAt:l,view:b,signIn:m,aiDesk:y,ai:u,principal:c}=xe(),g=(0,s.useRef)(null),x=(0,s.useRef)(null),v=(0,s.useRef)(null),w=(0,s.useRef)(null);n?.returnTo&&(w.current=n.returnTo);let f=e=>{let t=e.closest("[data-graview-asking]")?.getAttribute("data-graview-asking"),o=e.getAttribute("data-pin-for"),d=t??e.getAttribute("data-affordance")??(o===null?null:`pin:${o}`)??e.getAttribute("data-menu-item");x.current=d===null?null:{key:d,element:e}};(0,s.useEffect)(()=>{let e=g.current,t=x.current;if(t===null||document.activeElement!==document.body||t.element.isConnected)return;let o=t.key;if(!e){x.current=null;let M=w.current;w.current=null,(M?.isConnected?M:v.current)?.focus();return}((o.startsWith("pin:")?e.querySelector(`[data-pin-for="${CSS.escape(o.slice(4))}"]`):null)??e.querySelector(`[data-affordance="${CSS.escape(o)}"]:not([disabled])`)??e).focus()});let[k,S]=(0,s.useState)(null);(0,s.useLayoutEffect)(()=>{let e=g.current?.offsetParent??g.current?.parentElement;if(e instanceof HTMLElement&&(v.current=e),!e)return;let t=e.getBoundingClientRect();S(o=>o&&o.left===t.left&&o.top===t.top&&o.width===t.width&&o.height===t.height?o:{left:t.left,top:t.top,width:t.width,height:t.height})});let{selection:G,set:ne,clear:B}=Ke(),p=n?.about??G,[R,oe]=(0,s.useState)(()=>Ve()),Q=n?.on??p[p.length-1],Ae=n?.about,cn=(0,s.useMemo)(()=>({pins:R,...Q===void 0?{}:{focus:Q},...Ae?{about:Ae}:{}}),[R,Q,Ae]),gn=(0,s.useMemo)(()=>new Set(r.allMutations().filter(e=>e.pinned).map(e=>e.name)),[r]),{affordances:T,withheld:de,observations:Ee}=Ut(cn),re=$t(de,m),D=re?Un:de,pn=n===null?null:{face:n.face??"scene",on:n.on,about:p,field:n.field,place:n.place,href:n.href,act:n.act,column:n.column,...n.section?{section:n.section}:{},...n.page?{page:n.page}:{},element:n.returnTo},P=_t(pn),tt=Ee.some(e=>e.id.startsWith("schema:waits:")),{apply:hn,preview:mn}=Gt(),[ie,Y]=(0,s.useState)(null),[Re,fn]=(0,s.useState)(null),[nt,$e]=(0,s.useState)(!1),[ot,rt]=(0,s.useState)(!1),[ue,ce]=(0,s.useState)(""),yn=Ft({letters:n===null}),[H,ge]=(0,s.useState)(""),it=(0,s.useRef)(null);(0,s.useEffect)(()=>ge(""),[n]);let V=zt(y),U=en(V?u:void 0,r,c,n===null?"":H,n?.on,n),bn=(0,s.useMemo)(()=>n===null?[]:[...P.start.flatMap(e=>(e.items??[]).map(t=>({key:`item:${t.id}`,label:t.label}))),...T.map(e=>({key:`act:${e.id}`,label:e.label})),...P.end.flatMap(e=>(e.items??[]).map(t=>({key:`item:${t.id}`,label:t.label}))),...U.map(e=>({key:e.key,label:e.label}))],[n,P,T,U]),at=Jt(u,n===null?"":H,bn),[ae,lt]=(0,s.useState)(!1),He=(0,s.useRef)({words:"",rank:null});ae||(He.current={words:H.trim(),rank:at});let N=ae?He.current.words===H.trim()?He.current.rank:null:at,L=(0,s.useMemo)(()=>[...P.start,...P.end].find(e=>e.mode)?.mode,[P]),$=n===null?[]:[...V?["chat"]:[],...L?["better"]:[]],[wn,st]=(0,s.useState)(null),[Ce,vn]=(0,s.useState)(null);(0,s.useEffect)(()=>st(null),[n,H]),(0,s.useEffect)(()=>{let e=H.trim();if(!L||!V||e==="")return;let t=!0,o=setTimeout(()=>void L.claims(e).then(d=>t&&vn({words:e,mode:d?"better":"chat"}),()=>{}),Je);return()=>{t=!1,clearTimeout(o)}},[H,L,V]);let pe=$.length===0?null:wn??($.length===1?$[0]:Ce&&Ce.words===H.trim()?Ce.mode:"chat"),kn=(0,s.useMemo)(()=>{if(n===null||$.length===0)return[];let e=(L?.nudges?.()??[]).map((C,q)=>({key:`nudge:${q}`,label:C,mode:"better",source:"nudge"})),t=U.slice(0,2).map(C=>({key:C.key,label:C.label,mode:"chat",source:"told"})),o=n.on??(p.length===1?p[0]:void 0),d=o!==void 0?r.graph.getNode(o):void 0,M=on(T,d,d?Ht(r.schema,[d.kind])[d.kind]:void 0,d?O(r,d.id):void 0).slice(0,2);return rn(V?[...e,...t,...M]:e,[...T,...de].map(C=>C.label))},[n,$.length,L,U,T,de,V,r,p]),Sn=(0,s.useMemo)(()=>(n?.on!==void 0?r.graph.getNode(n.on):void 0)??Fn(r),[n,r,T]),Le=an(u,kn,{name:n?.title??(p.length===1?O(r,p[0]):"this"),opened:n,better:L!==void 0,depends:Sn},ae),[dt,Ie]=(0,s.useState)(null),Oe=(0,s.useRef)([]),he=(e,t)=>{try{return mn(e,t),hn(e,t),Ie(null),l(null),Oe.current=[],!0}catch(o){return Ie(Wt(r.schema,r.allMutations(),o)),Oe.current=o instanceof Et?o.issues.map(d=>String(d.path[0]??"")).filter(Boolean):[],!1}},me=[...new Set(p.flatMap(e=>{let t=r.graph.getNode(e);return t?[t.kind]:[]}))],fe=me.length>0?me:[...new Set(p.flatMap(e=>It(e)))],A=p.length===1?Lt(p[0]):null,De=A?{from:r.graph.getNode(A.from),to:r.graph.getNode(A.to)}:null,ut=A?Kt(r,A):void 0,ct=ut?.provisional?ut:void 0,gt=A?(()=>{let e=r.schema.tryDefinition(r.graph.getNode(A.from)?.kind??"")?.edges?.[A.kind],t=r.graph.getNode(A.to);return e?.inverse&&t?`From ${O(r,t.id)}: ${e.inverse}`:null})():null;(0,s.useEffect)(()=>{Y(null),$e(!1),rt(!1),Ie(null),ce("")},[p,n?.about]);let pt=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=n?.begin;if(!e||pt.current===n)return;let t=T.find(d=>d.mutation===e.act);if(!t)return;pt.current=n;let o={...e.given};fn({id:t.id,given:o}),t.open.every(d=>d.name in o)?he({...t,args:{...t.args,...o},open:[]}):Y(t.id)},[n,T]);let h=n!==null,xn=a==="menu"&&!h,J=(0,s.useRef)(n);J.current=n;let ht=Pt("acts",{open:h&&a==="menu",onOpenChange:e=>{e||l(null)},at:()=>J.current?{x:J.current.x,y:J.current.y}:null,returnTo:()=>{let e=J.current?.returnTo;if(e?.isConnected)return e;let t=J.current?.on;return t?document.querySelector(`[data-graview-view="${CSS.escape(t)}"]`):null},align:"start"}),mt=(k?.width??Number.POSITIVE_INFINITY)<dn;if((0,s.useLayoutEffect)(()=>{let e=g.current?.offsetParent;if(!e||!mt||h)return;let t=g.current?.getBoundingClientRect().height??0,o=`${Math.round(t)+20}px`;if(e.style.paddingBottom===o)return;let d=e.style.paddingBottom;return e.style.paddingBottom=o,()=>{e.style.paddingBottom=d}}),p.length===0&&!h)return null;let ft=n?.title!==void 0||p.length>0&&!(p.length===1&&p[0]===b.focusId),le=h?4:Math.max(1,Math.min(9,T.length)),W=[...T.filter(e=>e.provider==="invariant"&&!e.destructive),...T.filter(e=>e.pinned&&e.provider!=="invariant"&&!e.destructive),...T.filter(e=>!e.ties&&!e.destructive&&!e.pinned&&e.provider!=="invariant"),...T.filter(e=>e.ties&&!e.destructive&&!e.pinned&&e.provider!=="invariant"),...T.filter(e=>e.destructive)],yt=W.length>le&&!h,bt=ue.trim().toLowerCase(),_=yt&&bt.length>0?W.filter(e=>`${e.label} ${e.why}`.toLowerCase().includes(bt)):null,E=h?H.trim():"",Pe=(e,t)=>E===""||Vt(t,E)||(N?.get(e)??0)>=Xe,F=(_??(nt||h?W:W.slice(0,le))).filter(e=>Pe(`act:${e.id}`,e.label)),wt=_||E?0:W.length-F.length,ye=E?D.filter(e=>Pe(`act:${e.id}`,e.label)):D,vt=e=>E===""?e:e.flatMap(t=>{let o=(t.items??[]).filter(d=>Pe(`item:${d.id}`,d.label));return o.length>0?[{id:t.id,...t.heading?{heading:t.heading}:{},items:o}]:[]}),j=h&&!nt&&E==="",ze=vt(P.start).filter(e=>(e.items?.length??0)>0||e.render),be=vt(P.end).filter(e=>(e.items?.length??0)>0||e.render),kt=new Set(j?F.slice(le).map(e=>e.id):[]),Ne=j&&W.length>=le,Mn=j&&(W.length>le||Ne&&D.length>0||Ee.length>0||P.end.some(e=>(e.items?.length??0)>0||e.render)),Tn=n?.title??(p.length===1?O(r,p[0]):p.length>1?`${p.length} selected`:"this"),St=h&&E!==""&&$.length>0,We=h&&E!==""?(N===null?U:[...U].sort((e,t)=>(N.get(t.key)??0)-(N.get(e.key)??0))).slice(0,Zt):[],An=[...ze.flatMap(e=>(e.items??[]).map(t=>`item:${t.id}`)),...F.filter(e=>!e.destructive).map(e=>`act:${e.id}`),...be.flatMap(e=>(e.items??[]).map(t=>`item:${t.id}`)),...We.map(e=>e.key)],En=N===null?void 0:[...An].sort((e,t)=>(N.get(t)??0)-(N.get(e)??0)).find(e=>(N.get(e)??0)>=Xe),I=E===""?null:En??ze.flatMap(e=>(e.items??[]).map(t=>`item:${t.id}`))[0]??F.filter(e=>!e.destructive).map(e=>`act:${e.id}`)[0]??be.flatMap(e=>(e.items??[]).map(t=>`item:${t.id}`))[0]??(St&&pe?"mode":null),Rn=(e=E)=>{if(!n)return;let t=n.returnTo??null,o=Be(g.current);l(null),Ge(y,{pointed:{on:n.on,about:p,field:n.field,place:n.place},...e?{asked:e}:{},returnTo:t,...o?{from:o}:{}})},_e=(e,t=E)=>{if(n){if(e==="chat")return Rn(t);l(null),L?.open(t||void 0)}},$n=e=>{let t=e.source==="told"?U.find(o=>o.key===e.key):void 0;if(t&&e.mode==="chat")return xt(t);_e(e.mode==="better"&&L?"better":"chat",e.label)},xt=e=>{if(!n)return;let t=n.returnTo??null,o=Be(g.current);l(null),Ge(y,{pointed:{on:n.on,about:p,field:n.field,place:n.place},asked:e.label,suggested:e.telling.id,returnTo:t,...o?{from:o}:{}})},Fe=()=>[...g.current?.querySelectorAll("[data-affordance]:not([disabled]), [data-menu-item]:not([data-menu-mode])")??[]].filter(e=>e.closest("[data-graview-asking], [hidden]")===null),je=()=>g.current?.querySelector("[data-menu-lit]")??null,Hn=e=>{let t=e.target,o=it.current;if(!o||t===o||e.metaKey||e.ctrlKey||e.altKey||t.closest("[data-graview-asking]")||_n(t))return;let d=e.key.length===1&&e.key!==" ";if(d||e.key==="Backspace"&&H!==""){e.preventDefault(),e.stopPropagation(),d&&H===""&&y&&Ue(y),ge(M=>d?M+e.key:M.slice(0,-1)),o.focus({preventScroll:!0});return}e.key==="ArrowUp"&&Fe()[0]===t&&(e.preventDefault(),e.stopPropagation(),o.focus({preventScroll:!0}))},we=[];for(let e of F){let t=!h&&e.provider==="invariant",o=!h&&!t&&e.pinned!==void 0&&!e.destructive,d=!h&&!t&&!o&&e.ties===!0&&!e.destructive,M=t?e.why:o?"pinned":d?"its ties":null,C=t?"violation":o||d?"ties":null,q=we[we.length-1];q&&q.heading===M?q.items.push(e):we.push({heading:M,tone:C,items:[e]})}let X=T.find(e=>e.id===ie),qe=X&&Re?.id===X.id?{...X,args:{...X.args,...Re.given},open:X.open.filter(e=>!(e.name in Re.given))}:X,se=p.length===1?O(r,p[0]):null,Mt=e=>{if(!se)return e;let t=e.startsWith(`"${se}"`)?e.slice(se.length+2):e.startsWith(se)?e.slice(se.length):null;if(t===null)return e;let o=t.trimStart();return o.length===0?e:o[0].toUpperCase()+o.slice(1)},Cn=new Set(h?[]:F.filter(e=>e.provider==="invariant").map(e=>e.why)),Z=Ee.filter(e=>!Cn.has(e.text)).map(e=>({...e,text:Mt(e.text)}));return xn?null:(0,i.jsxs)("section",{...h?ht.pane:{},ref:e=>{g.current=e,h&&ht.pane.ref(e)},"aria-label":"Inspector","data-graview-offstage":"","data-testid":h?"context-menu":"inspector-strip",tabIndex:-1,onFocus:e=>f(e.target),onBlur:e=>{e.relatedTarget!==null&&(x.current=null)},onMouseDown:e=>e.stopPropagation(),onKeyDownCapture:h?e=>Hn(e):void 0,onPointerMove:h?e=>{let t=e.target.closest?.("[data-menu-item], [data-affordance]")!=null;t!==ae&&lt(t)}:void 0,onPointerLeave:h&&ae?()=>lt(!1):void 0,style:{...h?Dt:{position:"absolute",zIndex:Ct("rail")},boxSizing:"border-box",display:"flex",flexDirection:"column",gap:7,padding:"9px 12px",borderRadius:"var(--graview-radius, 12px)",border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)",...h?{width:300,maxHeight:"min(52cqh, 420px)",overflow:"auto"}:mt?{left:10,right:10,width:"auto",bottom:10,maxHeight:"min(42cqh, 300px)",overflow:"auto"}:{left:14,top:b.overview?"min(296px, 38cqh)":44,width:236,maxHeight:b.overview?"calc(100cqh - min(296px, 38cqh) - 20px)":"calc(68cqh - 94px)",overflow:"auto"}},children:[(0,i.jsx)("h2",{style:{...Qe,margin:0},children:"Inspector"}),(0,i.jsxs)("div",{style:{display:ft||!h?"flex":"none",alignItems:"baseline",flexWrap:"wrap",gap:"2px 8px",minWidth:0,paddingRight:h?0:24},children:[ft?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("strong",{style:{fontSize:"0.9375rem",whiteSpace:"nowrap"},children:n?.title??(p.length===1?O(r,p[0]):`${p.length} selected`)}),me.length>0||A?(0,i.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",whiteSpace:"nowrap"},children:A?"relation":me.map(e=>ke(r.schema.tryDefinition(e),e)).join(" \xB7 ")}):null,p.length===1&&!A&&n?.face!=="pages"?(0,i.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",whiteSpace:"nowrap"},children:b.expanded.includes(p[0])?"\xB7 double-click closes":"\xB7 double-click opens"}):null]}):null,(0,i.jsx)("span",{style:{flex:"1 1 auto"}})]}),h?null:(0,i.jsx)("button",{type:"button",onClick:()=>{l(null),B()},"aria-label":"Clear selection",title:"Clear selection",style:{position:"absolute",top:6,right:6,flex:"0 0 auto",width:24,height:24,display:"grid",placeItems:"center",padding:0,fontSize:"0.875rem",lineHeight:1,borderRadius:7},children:"\xD7"}),h?(0,i.jsx)("input",{ref:it,type:"text","data-testid":"menu-type",...jn()?{}:{"data-graview-not-first":""},value:H,onChange:e=>{H===""&&e.target.value!==""&&y&&Ue(y),ge(e.target.value)},onKeyDown:e=>{if(e.key==="Enter"){e.preventDefault();let t=je();t?.focus({preventScroll:!0}),t?.click()}else e.key==="ArrowDown"?(e.preventDefault(),(je()??Fe()[0])?.focus()):e.key==="ArrowUp"?(e.preventDefault(),Fe().at(-1)?.focus()):e.key==="Enter"&&!je()&&pe?(e.preventDefault(),_e(pe)):e.key==="Escape"&&H!==""&&(e.preventDefault(),e.stopPropagation(),ge(""))},placeholder:$.length>0?"Tell Graview what you want\u2026":"Type to filter\u2026","aria-label":$.length>0?`Tell Graview what you want with ${Tn}, or filter what can be done here`:"Filter what can be done here",autoComplete:"off",autoCorrect:"off",spellCheck:!1,enterKeyHint:"go",style:{boxSizing:"border-box",width:"100%",font:"inherit",fontSize:"max(1rem, 16px)",padding:"5px 9px",borderRadius:8,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)"}}):null,h&&$.length>0?(0,i.jsx)("div",{role:"group","aria-label":$.length>1?"Chat or Better UI":"Chat","data-testid":"menu-modes",style:{display:"flex",gap:6},children:$.map(e=>{let t=pe===e,o=e==="chat"?"Chat":L?.label??"Better UI",d=e==="chat"?"\u{1F4AC}":L?.mark??"\u2728";return(0,i.jsxs)("button",{type:"button","data-menu-mode":e,...e==="chat"?{"data-menu-item":"ask-typed"}:{},"data-menu-lit":I==="mode"&&t||void 0,"aria-pressed":t,"aria-label":E?`${o}: ${E}`:o,onClick:()=>_e(e),onKeyDown:M=>{if(M.key!=="ArrowLeft"&&M.key!=="ArrowRight")return;M.preventDefault(),M.stopPropagation();let C=$[($.indexOf(e)+(M.key==="ArrowRight"?1:$.length-1))%$.length];st(C),g.current?.querySelector(`[data-menu-mode="${C}"]`)?.focus()},style:t?qn:Kn,children:[(0,i.jsx)("span",{"aria-hidden":"true",children:d})," ",o,I==="mode"&&t?Te:null]},e)})}):null,h&&E===""&&Le.length>0?(0,i.jsxs)("div",{"data-menu-section":"suggested",role:"group","aria-label":"Suggested",style:{display:"grid",gap:2,borderTop:"1px solid var(--graview-edge)",paddingTop:5,minHeight:Le.length*31+22},children:[(0,i.jsx)("span",{"aria-hidden":"true",style:Bn,children:"Suggested"}),Le.map((e,t)=>(0,i.jsxs)("button",{type:"button","data-menu-item":`suggested-${t}`,"data-suggested-mode":e.mode,onClick:()=>$n(e),style:{...Me,display:"flex",gap:8,alignItems:"baseline",minWidth:0},children:[(0,i.jsx)("span",{"aria-hidden":"true",style:{color:"var(--graview-accent)"},children:"\u2726"}),(0,i.jsx)("span",{title:e.label,style:{flex:"1 1 auto",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.label}),(0,i.jsxs)("span",{title:e.mode==="better"?"Better UI":"Chat",style:{fontSize:"0.8125rem"},children:[(0,i.jsx)("span",{"aria-hidden":"true",children:e.mode==="better"?"\u2728":"\u{1F4AC}"}),(0,i.jsx)("span",{style:Qe,children:e.mode==="better"?" (Better UI)":" (Chat)"})]})]},e.key))]}):null,A&&De?(0,i.jsxs)("div",{style:{display:"grid",gap:6},children:[gt?(0,i.jsx)("p",{"data-testid":"edge-said",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:gt}):null,ct?(0,i.jsx)("p",{"data-testid":"edge-provisional",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:qt(ct)}):null,(0,i.jsx)("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[["from",De.from],["to",De.to]].map(([e,t],o)=>(0,i.jsxs)(s.Fragment,{children:[o===1?(0,i.jsx)("span",{"aria-hidden":"true",style:{color:"var(--graview-ink-faint)"},children:"\u2192"}):null,t?(0,i.jsx)("button",{type:"button","data-testid":`edge-${e}`,onClick:()=>ne([t.id]),title:`Select ${O(r,t.id)}`,style:{fontSize:"0.8125rem",padding:"3px 9px",borderRadius:6},children:O(r,t.id)}):(0,i.jsx)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-ink-faint)"},children:"gone"})]},e))})]}):null,!A&&p.length===1&&Rt(r,p[0])?(0,i.jsx)("p",{"data-testid":"left-alone",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:"Left alone: nothing automated changes it."}):null,Z.length>0?(0,i.jsx)("div",{"data-testid":"observations",title:Z.map(e=>e.text).join(`
2
+ `),hidden:j,style:{display:j?"none":"grid",gap:3},children:Z.slice(0,2).map(e=>(0,i.jsxs)("p",{style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:[e.text,e===Z[1]&&Z.length>2?(0,i.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" +",Z.length-2]}):null]},e.id))}):null,h?ze.map(e=>(0,i.jsx)(sn,{section:e,lit:I,close:()=>l(null)},e.id)):null,dt?(0,i.jsx)("p",{"data-testid":"refused",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-warn)"},children:dt}):null,yt?(0,i.jsx)("input",{"data-testid":"action-filter",value:ue,onChange:e=>ce(e.target.value),placeholder:`Filter ${W.length} actions\u2026`,"aria-label":"Filter actions",onKeyDown:e=>{if(e.key==="Escape"){e.stopPropagation(),ue.length>0?ce(""):e.currentTarget.blur();return}if(e.key==="Enter"&&_?.length===1){let t=_[0];if(t.destructive)return;t.open.length>0?Y(t.id):he(t)&&ce("")}},style:{font:"inherit",fontSize:"0.875rem",padding:"5px 9px",borderRadius:8,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)"}}):null,_!==null&&_.length===0?(0,i.jsxs)("p",{"data-testid":"no-matches",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:["Nothing offered here matches \u201C",ue.trim(),"\u201D."]}):null,E!==""&&F.length===0||re&&T.length===0||T.length===0&&!tt&&p.length===0?null:T.length===0&&!tt?(0,i.jsx)("p",{"data-testid":"no-affordances",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:D.length>0?`Nothing you may do with ${A?"this relation":fe.length===1?ve(ke(r.schema.tryDefinition(fe[0]),fe[0])):"this mix of kinds"} \u2014 ${D.length} action${D.length===1?"":"s"} withheld.`:A?`There is nothing to do with this line here: nothing in this app makes or breaks \u201C${Nt(r.schema,r.graph.getNode(A.from)?.kind??"",A.kind,"out")}\u201D.`:Nn(r,fe,p)}):(0,i.jsxs)("ol",{...yn,"data-testid":"affordances",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",flexWrap:"nowrap",gap:2},children:[we.map((e,t)=>(0,i.jsxs)(s.Fragment,{children:[e.heading?(0,i.jsxs)("li",{"data-graview-heading":e.tone,style:{fontSize:"0.75rem",lineHeight:1.4,color:e.tone==="violation"?"var(--graview-warn)":"var(--graview-ink-faint)",...e.tone!=="violation"?{letterSpacing:"0.12em",textTransform:"uppercase",fontSize:"0.75rem"}:{},padding:"2px 2px 1px",marginTop:t>0?6:0},children:[e.tone==="violation"?"\u26A0 ":"",e.tone==="violation"?Mt(e.heading):e.heading]}):t>0?(0,i.jsx)("li",{"aria-hidden":"true",style:{borderTop:"1px solid var(--graview-edge)",margin:"6px 0 3px"}}):null,e.items.map(o=>(0,i.jsxs)("li",{hidden:kt.has(o.id),style:{display:kt.has(o.id)?"none":"flex",gap:2,alignItems:"stretch"},onKeyDown:d=>{if(d.metaKey||d.ctrlKey||d.altKey)return;let M=d.currentTarget.querySelector("[data-affordance]"),C=d.currentTarget.querySelector("[data-pin-for]"),q=d.target===C,Tt=d.key==="ArrowRight"&&!q?C:q&&["ArrowLeft","ArrowUp","ArrowDown"].includes(d.key)?M:null;Tt&&(d.preventDefault(),d.stopPropagation(),Tt.focus())},children:[(0,i.jsxs)("button",{type:"button",[Ye]:"","data-affordance":o.id,"data-rank":o.rank,"data-graview-destructive":o.destructive||void 0,"data-menu-lit":I===`act:${o.id}`||void 0,"aria-pressed":ie===o.id,title:o.why,style:{padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left",borderWidth:1,borderStyle:"solid",borderColor:ie===o.id?"var(--graview-accent)":h?"transparent":"var(--graview-edge)",background:h?"none":"var(--graview-panel)",boxShadow:"none",...o.destructive?{color:"var(--graview-warn)"}:{},...ie===o.id?{color:"var(--graview-accent)"}:{},...I===`act:${o.id}`?et:{}},onClick:()=>{if(o.open.length>0){Y(ie===o.id?null:o.id);return}he(o)},children:[o.label,o.open.length>0?(0,i.jsx)("span",{style:{color:"var(--graview-ink-faint)"},children:" \u2026"}):null,I===`act:${o.id}`?Te:null,_?.length===1&&_[0]?.id===o.id&&!o.destructive?(0,i.jsx)("span",{"aria-hidden":"true",title:"Enter runs it",style:{float:"right",color:"var(--graview-ink-faint)",fontSize:"0.75rem"},children:"\u21B5"}):null]}),(0,i.jsx)("button",{type:"button","data-testid":"pin-toggle",tabIndex:-1,"data-pin-for":o.mutation,"aria-pressed":o.pinned!==void 0,"aria-label":o.pinned!==void 0?`Unpin ${o.label}`:`Pin ${o.label}`,title:o.pinned==="declared"?"Pinned by the app \u2014 unpin it for yourself":o.pinned==="user"?"Unpin":"Pin to the top",onClick:()=>oe(Qt(R,o.mutation,gn.has(o.mutation))),style:{flex:"0 0 auto",width:24,minHeight:24,display:"grid",placeItems:"center",padding:0,fontSize:"0.75rem",border:"1px solid transparent",background:"none",boxShadow:"none",borderRadius:7,color:o.pinned==="user"?"var(--graview-accent)":o.pinned==="declared"?"var(--graview-ink-muted)":"var(--graview-ink-faint)"},children:o.pinned!==void 0?"\u2605":"\u2606"})]},o.id))]},`${e.heading??"plain"}-${t}`)),wt>0&&!h?(0,i.jsx)("li",{children:(0,i.jsxs)("button",{type:"button",[Ye]:"",onClick:()=>$e(!0),title:`Show all ${T.length} actions`,style:{padding:"4px 10px",fontSize:"0.875rem",borderRadius:8},children:["Show ",wt," more"]})}):null]}),re?(0,i.jsx)("button",{type:"button","data-testid":"sign-in",onClick:()=>{l(null),re.run()},style:{padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left"},children:re.label}):null,ye.length>0?(0,i.jsxs)("ul",{hidden:Ne,"data-testid":"withheld",style:{margin:0,padding:0,listStyle:"none",display:Ne?"none":"flex",flexDirection:"column",flexWrap:"nowrap",gap:2},children:[ye.slice(0,h||ot?ye.length:3).map(e=>(0,i.jsxs)("li",{style:{display:"grid",gap:2},children:[(0,i.jsx)("button",{type:"button",disabled:!0,"data-affordance":e.id,"data-rank":e.rank,"data-withheld":e.refusal.wouldNeed.join(",")||"nobody",style:{padding:"4px 10px",fontSize:"0.875rem",borderRadius:8,borderStyle:"dashed",width:"100%",textAlign:"left",background:"none"},children:(0,i.jsx)("s",{children:e.label})}),(0,i.jsx)("span",{"data-testid":"withheld-why",style:{fontSize:"0.8125rem",lineHeight:1.4,color:"var(--graview-ink-muted)",padding:"0 10px"},children:e.refusal.message})]},e.id)),!h&&!ot&&D.length>3?(0,i.jsx)("li",{children:(0,i.jsxs)("button",{type:"button","data-testid":"withheld-more",onClick:()=>rt(!0),title:`Show all ${D.length} actions this seat may not take`,style:{padding:"4px 10px",fontSize:"0.875rem",borderRadius:8},children:["Show ",D.length-3," more withheld"]})}):null]}):null,Mn?(0,i.jsx)("button",{type:"button","data-menu-item":"more",onClick:e=>{let o=[...e.currentTarget.parentElement?.querySelectorAll("li[hidden], [data-menu-more][hidden]")??[]];$e(!0),requestAnimationFrame(()=>{for(let d of o){let M=d.querySelector("button:not([disabled]), a[href], input");if(M&&M.getClientRects().length>0)return M.focus()}})},style:{...Me,color:"var(--graview-ink-muted)"},children:"More\u2026"}):null,h&&be.length>0?(0,i.jsx)("div",{"data-menu-more":"",hidden:j,style:{display:j?"none":"contents"},children:be.filter(e=>!j||!e.render).map(e=>(0,i.jsx)(sn,{section:e,lit:I,close:()=>l(null)},e.id))}):null,We.length>0?(0,i.jsx)("div",{"data-menu-section":"told",role:"group","aria-label":"Suggested",style:{display:"grid",gap:2,borderTop:"1px solid var(--graview-edge)",paddingTop:5},children:We.map(e=>(0,i.jsxs)("button",{type:"button","data-menu-item":e.key,"data-told-suggestion":e.telling.id,"data-menu-lit":I===e.key||void 0,onClick:()=>xt(e),style:{...Me,...I===e.key?et:{}},children:[e.label,I===e.key?Te:null]},e.key))}):null,h&&E!==""&&!St&&I===null&&F.length===0&&ye.length===0?(0,i.jsxs)("p",{"data-testid":"menu-no-match",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:["Nothing here matches \u201C",E,"\u201D."]}):null,qe?(0,i.jsx)(jt,{affordance:qe,onApply:e=>{if(he(qe,e))Y(null);else return Oe.current},onCancel:()=>Y(null)}):null]})}function _n(a){return a.isContentEditable||a instanceof HTMLTextAreaElement||a instanceof HTMLSelectElement?!0:a instanceof HTMLInputElement&&!["button","submit","reset","checkbox","radio","image","file","color","range"].includes(a.type)}var Me={padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left",borderWidth:1,borderStyle:"solid",borderColor:"transparent",background:"none",boxShadow:"none"},et={background:"var(--graview-panel-muted)"},ln=new WeakMap;function Fn(a){let r=a.log.all().length,n=ln.get(a);if(n&&n.length===r)return n.stamp;let l={length:r};return ln.set(a,{length:r,stamp:l}),l}var jn=()=>typeof matchMedia=="function"&&matchMedia("(pointer: fine)").matches,un={display:"inline-flex",alignItems:"center",gap:5,minHeight:30,padding:"0 11px",fontSize:"0.8125rem",borderRadius:999,cursor:"pointer",borderWidth:1,borderStyle:"solid",boxShadow:"none"},qn={...un,borderColor:"var(--graview-accent)",background:"color-mix(in srgb, var(--graview-accent) 14%, transparent)",color:"var(--graview-ink)",fontWeight:600},Kn={...un,borderColor:"var(--graview-edge)",background:"none",color:"var(--graview-ink-muted)"},Bn={fontSize:"0.6875rem",letterSpacing:"0.12em",textTransform:"uppercase",color:"var(--graview-ink-faint)",padding:"0 10px"},Te=(0,i.jsx)("span",{"aria-hidden":"true",title:"Enter runs it",style:{float:"right",color:"var(--graview-ink-faint)",fontSize:"0.75rem"},children:"\u21B5"}),Un=[];function sn({section:a,lit:r=null,close:n}){return(0,i.jsxs)("div",{"data-menu-section":a.id,...a.heading?{role:"group","aria-label":a.heading}:{},style:{display:"grid",gap:2,borderTop:"1px solid var(--graview-edge)",paddingTop:5},children:[a.heading?(0,i.jsx)("p",{"aria-hidden":"true",style:{margin:0,padding:"2px 2px 1px",fontSize:"0.75rem",lineHeight:1.4,letterSpacing:"0.12em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},children:a.heading}):null,a.items&&a.items.length>0?(0,i.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:2},children:a.items.map(l=>(0,i.jsx)("li",{children:(0,i.jsxs)("button",{type:"button","data-menu-item":l.id,"data-menu-lit":r===`item:${l.id}`||void 0,onClick:()=>{n(),l.run()},style:{...Me,...r===`item:${l.id}`?et:{}},children:[l.label,l.hint?(0,i.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",l.hint]}):null,r===`item:${l.id}`?Te:null]})},l.id))}):null,a.render?.(n)]})}export{ho as InspectorPane,po as prepareActs};
@@ -1 +1 @@
1
- import{Rd as w,Sd as v,Ud as $,Vd as c,Xd as k,Yd as x,ee as f,ie as b,je as S,ke as P,le as A,oe as L,pa as u,pe as N}from"./chunk.J24YPQ5I.js";function T(s){if(!(s.attach==="home"||s.cardinality==="one"||!s.title))return{kind:s.attach,title:s.title,as:$(s.title),name:s.name,lens:"view",...s.hidden?{hidden:!0}:{}}}function G(s,r=[]){let a=[];for(let n of f(s).drawn)for(let i of n.kinds)a.push({kind:i,title:n.title,as:n.as,...n.across?{across:n.across}:{},...n.kinds.length>1?{over:n.kinds}:{},...n.hidden?{hidden:!0}:{}});for(let n of[...s.views?.places?.()??[],...r.flatMap(i=>T(i)??[])])a.some(i=>i.kind===n.kind&&i.as===n.as)||a.push(n);return a}function J(s,r={}){return V(s.schema,G(s,r.views),{...s.pages?{pages:s.pages}:{},lenses:f(s).drawn,home:(s.home?.length??0)>0})}function V(s,r,a={}){let{pages:n}=a,i=s.kinds,d=r.filter(e=>i.includes(e.kind)),o=N(n?.first,s,d),O=new Set(n?.hide??[]),p=L(i,n?.order,d),m=p.flatMap(e=>e.view?[]:[e.kind]),E=p.flatMap(e=>e.view?[e.view]:[]),h=[{slug:b,title:"Home",kind:null,cardinality:"many",address:"/",stop:"#",...o?.to==="home"||o===void 0&&a.home?{first:!0}:{}},{slug:S,title:A(n),kind:null,cardinality:"many",address:P,stop:"#"}],H=v([...d].sort((e,t)=>m.indexOf(e.kind)-m.indexOf(t.kind))),g=e=>{let t=a.lenses?.find(l=>l.as===e.as&&l.kinds.includes(e.kind)),y=x(e,d);return{slug:e.as,title:e.title,kind:e.kind,...e.over?{over:e.over.filter(l=>i.includes(l))}:{},cardinality:"many",address:k(e.as,y?c(s,e.kind).slice(1):void 0),stop:y?`#focus=aggregate:${e.kind}&in.view=${encodeURIComponent(e.as)}`:`#view=${encodeURIComponent(e.as)}`,...t?{lens:t.lens}:{},...e.name!==void 0?{view:e.name}:{},...e.hidden?{hidden:!0}:{},...o?.to==="place"&&o.place.as===e.as&&(o.place.kind===e.kind||e.over?.includes(o.place.kind))?{first:!0}:{}}};for(let e of H)E.some(t=>w(t,e))||h.push(g(e));for(let e of p){if(e.view){h.push(g(e.view));continue}let t=e.kind;h.push({slug:c(s,t).slice(1),title:u(s,t),kind:t,cardinality:"many",address:c(s,t),stop:`#focus=aggregate:${t}`,...O.has(t)?{hidden:!0}:{},...o?.to==="kind"&&o.kind===t?{first:!0}:{}})}return h}export{J as a,V as b};
1
+ import{$d as k,Vd as w,Wd as v,Yd as $,Zd as c,ae as x,ie as f,me as b,ne as S,oe as P,pa as u,pe as A,se as L,te as N}from"./chunk.ZEZUKRC6.js";function T(s){if(!(s.attach==="home"||s.cardinality==="one"||!s.title))return{kind:s.attach,title:s.title,as:$(s.title),name:s.name,lens:"view",...s.hidden?{hidden:!0}:{}}}function G(s,r=[]){let a=[];for(let n of f(s).drawn)for(let i of n.kinds)a.push({kind:i,title:n.title,as:n.as,...n.across?{across:n.across}:{},...n.kinds.length>1?{over:n.kinds}:{},...n.hidden?{hidden:!0}:{}});for(let n of[...s.views?.places?.()??[],...r.flatMap(i=>T(i)??[])])a.some(i=>i.kind===n.kind&&i.as===n.as)||a.push(n);return a}function J(s,r={}){return V(s.schema,G(s,r.views),{...s.pages?{pages:s.pages}:{},lenses:f(s).drawn,home:(s.home?.length??0)>0})}function V(s,r,a={}){let{pages:n}=a,i=s.kinds,d=r.filter(e=>i.includes(e.kind)),o=N(n?.first,s,d),O=new Set(n?.hide??[]),p=L(i,n?.order,d),m=p.flatMap(e=>e.view?[]:[e.kind]),E=p.flatMap(e=>e.view?[e.view]:[]),h=[{slug:b,title:"Home",kind:null,cardinality:"many",address:"/",stop:"#",...o?.to==="home"||o===void 0&&a.home?{first:!0}:{}},{slug:S,title:A(n),kind:null,cardinality:"many",address:P,stop:"#"}],H=v([...d].sort((e,t)=>m.indexOf(e.kind)-m.indexOf(t.kind))),g=e=>{let t=a.lenses?.find(l=>l.as===e.as&&l.kinds.includes(e.kind)),y=x(e,d);return{slug:e.as,title:e.title,kind:e.kind,...e.over?{over:e.over.filter(l=>i.includes(l))}:{},cardinality:"many",address:k(e.as,y?c(s,e.kind).slice(1):void 0),stop:y?`#focus=aggregate:${e.kind}&in.view=${encodeURIComponent(e.as)}`:`#view=${encodeURIComponent(e.as)}`,...t?{lens:t.lens}:{},...e.name!==void 0?{view:e.name}:{},...e.hidden?{hidden:!0}:{},...o?.to==="place"&&o.place.as===e.as&&(o.place.kind===e.kind||e.over?.includes(o.place.kind))?{first:!0}:{}}};for(let e of H)E.some(t=>w(t,e))||h.push(g(e));for(let e of p){if(e.view){h.push(g(e.view));continue}let t=e.kind;h.push({slug:c(s,t).slice(1),title:u(s,t),kind:t,cardinality:"many",address:c(s,t),stop:`#focus=aggregate:${t}`,...O.has(t)?{hidden:!0}:{},...o?.to==="kind"&&o.kind===t?{first:!0}:{}})}return h}export{T as a,J as b,V as c};
@@ -1 +1 @@
1
- import{b as Ce,d as $e,i as U}from"./chunk.FOSY7MZF.js";import{d as Te}from"./chunk.NBVPWLRY.js";import{L as ke,Lc as se,Pb as ae,Sd as Re,Vd as De,Xd as We,Yd as Me,bb as Se,da as M,fa as xe,fb as G,ga as W,ka as _,la as z,ma as Ae,oa as we,pa as Ne,re as je,vd as ve,wd as Oe}from"./chunk.J24YPQ5I.js";function V(n,e){return n.display?.labels?.[e]??W(e)}function de(n){let e=U(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,i=n.tryDefinition(e);for(let[r,a]of Object.entries(i?.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,s]of Object.entries(r.edges??{}))t.has(a)||s.to!=="*"&&!s.to.includes(e)||t.set(a,{key:a,label:s.inverse?M(s.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 i=t.retired.map(String);return e.some(r=>r.key===t.field&&i.includes(r.value))}function Be(n,e){let t=n.tryDefinition(e);if(!t)return{kind:e,sorts:[],filters:[],groups:[]};let i=new Set(t.display?.hide??[]),r=t.fields.shape??{},a=[{key:"label",label:"Name",about:"label",type:"text"}],s=[],u=[];for(let[g,k]of Object.entries(r)){if(g==="id"||g==="kind"||g==="label"||i.has(g))continue;let A=en(k);if(A){s.push({key:g,label:V(t,g),about:"field",type:"choice",options:A});continue}let w=de(k);if(!w)continue;let N=V(t,g),O=w==="choice"?Le(k):w==="boolean"?["true","false"]:void 0,S={key:g,label:N,about:"field",type:w,...O?{options:O}:{}};a.push(S),s.push(S),(w==="boolean"||w==="choice")&&u.push(S),w==="date"&&u.push({...S,buckets:["day","week","month","year","decade"]})}for(let g of Je(n,e))a.push(g),s.push(g),u.push(g);let l={key:"is",label:t.lifecycle?"Standing and currency":"Standing",about:"is",type:"choice",options:t.lifecycle?[...Ze]:["flagged","clear"]};s.push(l);let y=t.fieldRoles?.order,f=y&&(y in r||y==="label")?{by:y,direction:"asc"}:void 0;return{kind:e,sorts:a,filters:s,groups:u,...f?{natural:f}:{}}}function On(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[s,u]of Object.entries(a.fields.shape??{}))de(u)!=="choice"||a.display?.hide?.includes(s)||t.push({key:`${r.key}.${s}`,label:`${r.label} \xB7 ${V(a,s)}`,about:"via",type:"choice",options:Le(u),far:[a.kind]})}if(t.length===0)return e;let i=e.filters.filter(r=>r.about!=="is");return{...e,filters:[...i,...t,...e.filters.filter(r=>r.about==="is")]}}function Rn(n,e){let t=n.tryDefinition(e.kind),i=Object.entries(t?.computed??{});if(!t||i.length===0)return e;let r=i.filter(([a])=>!e.sorts.some(s=>s.key===a)).map(([a,s])=>({key:a,label:(typeof s=="object"?s.label:void 0)??V(t,a),about:"field",type:"number"}));return{...e,sorts:[...e.sorts,...r]}}function Le(n){let e=U(n);return e.type==="choice"?e.options:[]}function en(n){let e=U(n);return e.type==="several"&&e.of.type==="choice"?e.of.options:void 0}var Ie=n=>n,Pe=n=>n;function nn(n,e,t){let i=new Map;for(let r of[...n.out(e,t),...n.in(e,t)])i.set(r.id,r);return[...i.values()]}function le(n,e,t){let i=n.schema.tryDefinition(e.kind);if(t.key==="is")switch(t.value){case"current":return _(i,Pe(e),n.today);case"past":return!_(i,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=i?.fields.shape??{};if(t.key in r){let l=Se(Ie(e),t.key,n.today??ke()),y=de(r[t.key]);if(y==="date"){let[f,g]=t.value.split(":");if(typeof l!="string"||!g)return!1;let k=l.slice(0,10);return f==="before"?k<g:f==="after"?k>g:k===g}if(y==="boolean")return String(l)===t.value;if(Array.isArray(l))return l.some(f=>String(f)===t.value);if(y==="number"){let f=t.value.lastIndexOf(":"),g=f>0?t.value.slice(0,f):"",k=Number(t.value.slice(f+1));if(g==="at-most"||g==="at-least")return typeof l!="number"||!Number.isFinite(k)?!1:g==="at-most"?l<=k:l>=k}return String(l)===t.value}let[a,s]=t.key.split("."),u=nn(n.graph,e.id,a);return s?u.some(l=>String(Ie(l)[s])===t.value):t.value==="*"?u.length>0:t.value==="none"?u.length===0:u.some(l=>l.id===t.value)}var tn=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 X=new Map,rn=5e4;function $(n){let e=X.get(n);if(e===void 0){X.size>=rn&&X.clear();let t=ze(n);e={tokens:t.split(" ").filter(Boolean),whole:t.replace(/ /g,"")},X.set(n,e)}return e}var T=n=>[...$(n).tokens];function j(n,e){if(e.length===0)return;let{whole:t,tokens:i}=$(n),r=e.join("");if(t.length===0)return;if(t===r)return"exact";if(e.every(s=>i.some(u=>u.startsWith(s))))return t.startsWith(r)?"prefix":e.every(s=>i.includes(s))?"word":"part"}function q(n,e,t=48){let i=n.replace(/\s+/g," ").trim();if(i.length<=t)return i;let r=e[0],a=i.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase(),s=r?a.search(new RegExp(`(^|[^\\p{L}\\p{N}])${on(r)}`,"u")):-1,u=s<0?0:s+(a[s]&&/[\p{L}\p{N}]/u.test(a[s])?0:1),l=Math.max(0,u-Math.floor(t/3));if(l>0){let f=i.lastIndexOf(" ",l);l=f<0?0:f+1}let y=Math.min(i.length,l+t);if(y<i.length){let f=i.indexOf(" ",y);y=f<0||f-y>16?y:f}return`${l>0?"\u2026":""}${i.slice(l,y).trim()}${y<i.length?"\u2026":""}`}var on=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),an=/^([\p{L}][\p{L}\p{N}_-]*):(\S+)$/u;function sn(n){let e=[],t=[];for(let i of n.trim().split(/\s+/).filter(Boolean)){let r=an.exec(i);r?t.push({key:r[1],value:r[2]}):e.push(i)}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 i=dn(n,e);return Ee.set(e,{definition:n,texts:i}),i}function dn(n,e){let t=z(n,e),i=[{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"&&i.push({field:r.key,reading:r.label,text:r.markdown?Te(r.value):r.value});return i}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 i=[],r=Array.from({length:e.length+1},(a,s)=>s);for(let a=1;a<=n.length;a++){let s=[a],u=a;for(let l=1;l<=e.length;l++){let y=Math.min(r[l]+1,s[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]&&(y=Math.min(y,i[l-2]+1)),s[l]=y,y<u&&(u=y)}if(u>t)return t+1;i=r,r=s}return r[e.length]}var Y=new Map;function ln(n,e){let t=Y.get(n);t||(Y.size>=64&&Y.clear(),Y.set(n,t=new Map));let i=t.get(e);return i===void 0&&(i=cn(n,e)??null,t.set(e,i)),i??void 0}function cn(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 i=n.length<4?0:n.length<=7?1:2;if(i!==0){if(He(n,e,i)<=i)return"spelling";if(n.length>=5){for(let r=n.length-i;r<=n.length+i;r++)if(r<e.length&&He(n,e.slice(0,r),i)<=i)return"spelling"}}}function fn(n,e){let t=e.length>1?e.filter(r=>!Ge.has(r)):e;if(t.length===0)return;let i;for(let r of t){let a;for(let s of n){for(let u of $(s.text).tokens){if(u.startsWith(r)){a={text:s,matched:u};break}let l=a?void 0:ln(r,u);l&&(a={text:s,matched:u,by:l})}if(a&&!a.by)break}if(!a)return;a.by&&!i&&(i={text:a.text,asked:r,matched:a.matched,by:a.by})}if(i)return{field:i.text.field,reading:i.text.reading,fragment:q(i.text.text,[i.matched]),strength:"near",asked:i.asked,matched:i.matched,by:i.by}}var un=80;function gn(n,e,t){let i=T(e).filter(s=>!Ge.has(s)).join(" ")||e,r=t===void 0?[]:T(t),a=r.length>0&&n.find(s=>r.every(u=>$(s.text).tokens.some(l=>l.startsWith(u))))||n[0];return{field:a.field,reading:a.reading,fragment:q(a.text,r),strength:"near",asked:i,matched:(t??a.text).slice(0,un),by:"meaning"}}function _e(n,e,t,i){let r=T(t);if(r.length===0)return;if(i){let A=Q(n,e),w=i.includes("label")||i.some(v=>typeof e[v]=="string"&&e[v]===A[0].text),N=A.filter((v,D)=>D===0?w:i.includes(v.field)),O=v=>D=>$(D.text).tokens.some(P=>P.startsWith(v));if(!r.every(v=>N.some(O(v))))return;let S=N.find(O(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),[s,...u]=a,l=j(s.text,r);if(l)return{field:"label",reading:s.reading,fragment:q(s.text,r),strength:l};let y=A=>w=>$(w.text).tokens.some(N=>N.startsWith(A));if(!r.every(A=>a.some(y(A))))return;let f=T(s.text),g=r.find(A=>!f.some(w=>w.startsWith(A)))??r[0],k=u.find(y(g));return{field:k.field,reading:k.reading,fragment:q(k.text,[g]),strength:"field"}}var yn=512,hn=64;function pn(n){let e=new Map;if(n.length===0)return e;let t=n.slice(-yn),i=n[n.length-1].seq;for(let r of t){let a=Math.pow(.5,(i-r.seq)/hn);for(let s of r.writes)e.set(s,(e.get(s)??0)+a)}return e}var ue=(n,e)=>we({tryDefinition:()=>n},e),fe=(n,e)=>De({tryDefinition:()=>n},e);function mn(n,e,t){let i=n.tryDefinition(e),r=[{field:"plural",text:ue(i,e)},{field:"kind",text:W(e)},...i?.noun?[{field:"noun",text:i.noun}]:[],...(i?.aliases??[]).map(s=>({field:"alias",text:s}))],a;for(let s of r){let u=j(s.text,t);u&&(!a||I[u]<I[a.strength])&&(a={strength:u,...s})}return a}var bn,kn=(n,e)=>(bn??=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||kn(n.name,e.name)||(n.id<e.id?-1:n.id>e.id?1:0);function En(n,e,t={}){let i=n.schema,r=sn(e),a=T(r.words),s=t.principal??{kind:"human"},u=n.kindsKeptFrom(s),l=n.modules.disabledKinds,y=r.conditions.filter(o=>o.key==="kind").map(o=>o.value),f=r.conditions.filter(o=>o.key==="is").map(o=>o.value),g=f.includes("any")||f.includes("past"),k=f.includes("past")&&!f.includes("any")&&!f.includes("current"),A=f.includes("archived")?!0:t.archived??"all",w=(o,d)=>{let c=ce(d),h=i.tryDefinition(o);return ce(o)===c||ce(ue(h,o))===c},N=i.kinds.filter(o=>!u.has(o)&&!l.has(o)&&(t.kinds===void 0||t.kinds.includes(o))&&(y.length===0||y.some(d=>w(o,d)))),S=r.conditions.filter(o=>o.key!=="kind").map(o=>({...o,admittedBy:N.filter(d=>Be(i,d).filters.some(c=>c.key===o.key))})),v=S.filter(o=>o.key!=="is"),D=f.filter(o=>o==="flagged"||o==="clear"||o==="past"||o==="archived"),P={kinds:N,past:g},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 J=t.today,F=t.flagged??new Set(n.violations().flatMap(o=>o.nodeIds)),Ue=t.touched??pn(n.log.all()),Z=new Set;for(let o of t.from??[]){Z.add(o);for(let d of n.graph.neighbors(o))Z.add(d.id)}let ge=ve(n,s)?Oe(n,s):void 0,ee=ae.keptFrom?.(n,s)&&n.seenBy(s).graph,ne=o=>je(o,t.basePath===void 0?{}:{basePath:t.basePath}),ye={schema:i,graph:n.graph,flagged:F,...J?{today:J}:{}},R=[],B={},L=[],E=[],K=(o,d,c,h,p,m)=>{let x=z(c,o);B[d]=(B[d]??0)+1,R.push({hit:{about:"node",id:o.id,kind:d,label:x,why:p,current:h,flagged:F.has(o.id),address:ne(`${fe(c,d)}/${encodeURIComponent(o.id)}`),...m===void 0?{}:{near:!0},...G(o)?{archived:!0}:{}},...m===void 0?{}:{nearly:2-m},tier:I[p.strength],inKind:d===t.inKind?0:1,near:Z.has(o.id)?0:1,past:h?0:1,archived:G(o)?1:0,touched:-(Ue.get(o.id)??0),flagged:F.has(o.id)?0:1,name:x,id:o.id})};for(let o of N){let d=i.tryDefinition(o),c=S.filter(p=>p.key!=="is"&&p.admittedBy.includes(o));if(a.length===0&&c.length===0&&D.length===0)continue;let h=Fe(d,c);for(let p of n.graph.nodesOfKind(o,{archived:A})){if(ge&&!ge(p.id))continue;let m=ee?ee.getNode(p.id):p;if(!m)continue;let x=_(d,m,J);if(!g&&!h&&!x){if(a.length>0&&f.length===0&&c.every(b=>le(ye,m,b))){let b=_e(d,m,r.words);b&&E.push({node:m,kind:o,definition:d,why:b})}continue}if(k&&x||!c.every(b=>le(ye,m,b))||f.includes("flagged")&&!F.has(m.id)||f.includes("clear")&&F.has(m.id))continue;let C=a.length>0?_e(d,m,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(m,o,d,x,C):a.length>0&&L.push({node:m,kind:o,definition:d,current:x})}}let te=o=>o.strength!=="field",re=!1;if(E.length>0&&R.length===0){re=!0;for(let o of E)K(o.node,o.kind,o.definition,!1,o.why)}else if(E.some(o=>te(o.why))&&!R.some(o=>te(o.hit.why))){re=!0;for(let o of E)te(o.why)&&K(o.node,o.kind,o.definition,!1,o.why)}let he=t.near!==!1&&a.length>0&&R.length<tn&&L.length>0,ie=new Set;if(he)for(let o of L){let d=fn(Q(o.definition,o.node),a);d&&(ie.add(o.node.id),K(o.node,o.kind,o.definition,o.current,d,d.by==="stem"?.9:.8))}let Ve=o=>o==="exact"||o==="prefix"?-1:I[o],oe=(o,d,c,h)=>({hit:o,tier:Ve(d),inKind:1,near:1,past:0,touched:0,flagged:1,name:c,id:h});if(a.length>0){for(let d of N){let c=mn(i,d,a);if(!c)continue;let h=Ne(i,d),p={field:c.field,reading:c.field==="plural"?"Plural":"Kind",fragment:c.text,strength:c.strength};R.push(oe({about:"kind",kind:d,label:h,why:p,count:B[d]??0,address:ne(fe(i.tryDefinition(d),d))},c.strength,h,`kind:${d}`))}let o=t.places??[];for(let d of Re(o.filter(c=>N.includes(c.kind)))){if(d.across&&u.has(d.across))continue;let c=j(d.title,a);if(!c)continue;let h={field:"title",reading:"Title",fragment:d.title,strength:c},p=Me(d,o)?fe(i.tryDefinition(d.kind),d.kind).slice(1):void 0,m=ne(We(d.as,p));R.push(oe({about:"place",kind:d.kind,title:d.title,as:d.as,why:h,address:m},c,d.title,`place:${d.kind}:${d.as}`))}for(let d of n.allInvariants()){let c=d.scope==="graph"?void 0:d.scope.kind;if(c&&!N.includes(c))continue;let h=d.label??W(d.name),p=j(h,a),m=p?void 0:j(W(d.name),a),x=p??m;if(!x)continue;let C={field:p?"label":"name",reading:p?"Rule":"Name",fragment:p?h:d.name,strength:x};R.push(oe({about:"rule",name:d.name,label:h,...c?{kind:c}:{},why:C},x,h,`rule:${d.name}`))}}let pe=()=>{R.sort(qe);let o=t.limit??50,d=R.slice(0,o).map(b=>b.hit),c=d.flatMap(b=>b.about==="node"?[(ee||n.graph).getNode(b.id)]:[]).filter(Boolean),h=Ce(c,b=>i.tryDefinition(b)),p=d.map(b=>b.about==="node"&&h.has(b.id)?{...b,apart:h.get(b.id)}:b),m=Object.values(B).reduce((b,Ye)=>b+Ye,0),x=R.flatMap(b=>b.hit.about==="node"?[b.hit.id]:[]),C=t.subject&&N.includes(String(n.graph.getNode(t.subject)?.kind))?xn(n,t.subject,r.words,{principal:s}):[];return{hits:[...p,...C],words:r.words,conditions:S,searched:re?{...P,past:!0}:P,byKind:{...B},total:m,matched:x}},H=pe(),me=t.rank;if(!he||!me)return H;let be=L.filter(o=>!ie.has(o.node.id)).map(({node:o,kind:d,definition:c})=>({id:o.id,kind:d,label:z(c,o),texts:Q(c,o)}));if(be.length===0)return H;let Xe=(async()=>{let o;try{o=await me(r.words,be)}catch{return H}let d=new Map(L.filter(h=>!ie.has(h.node.id)).map(h=>[h.node.id,h])),c=!1;for(let{id:h,score:p,matched:m}of Array.isArray(o)?o:[]){let x=d.get(h);!x||!(p>0)||(d.delete(h),c=!0,K(x.node,x.kind,x.definition,x.current,gn(Q(x.definition,x.node),r.words,typeof m=="string"?m:void 0),Math.min(1,p)))}return c?pe():H})();return{...H,later:Xe}}function xn(n,e,t,i={}){let r=i.principal??{kind:"human"},a=(ae.keptFrom?.(n,r)?n.seenBy(r):n).graph.getNode(e);if(!a)return[];if(n.kindsKeptFrom(r).has(a.kind))return[];let s=T(t),u=z(n.schema.tryDefinition(a.kind),a),l=[];for(let f of n.allMutations()){let g=f.subject;if(!g||g.kinds!=="*"&&!g.kinds.includes(a.kind))continue;let k=f.derived?.act;if((k==="archive"||k==="merge")&&G(a)||k==="unarchive"&&!G(a)||k==="leave-alone"&&se(a)||k==="allow-tidying"&&!se(a)||!n.permits({name:f.name,args:{[g.arg]:a.id}},r).ok)continue;let A=Ae(f),w=T(A),N=s.filter(v=>w.some(D=>D.startsWith(v))),O=N.length>0?j(A,N):void 0,S=O?{field:"title",reading:"Act",fragment:A,strength:O}:{field:"subject",reading:"On",fragment:u,strength:"field"};l.push({hit:{about:"act",name:f.name,title:A,subject:a.id,why:S,destructive:f.destructive===!0},tier:O?I[O]:I.field+1,inKind:0,near:0,past:f.destructive?1:0,touched:0,flagged:f.pinned?0:1,name:A,id:`act:${f.name}`})}l.sort(qe);let y=l.map(f=>f.hit);return i.limit===void 0?y:y.slice(0,i.limit)}function Kn(n,e){let t=e.kinds.map((a,s)=>{let u=ue(n.tryDefinition(a),a);return s===0?u:u.toLowerCase()}),i=xe(t)||"Nothing";return e.kinds.some(a=>n.tryDefinition(a)?.lifecycle)?e.past?`${M(i)}, past ones included.`:`${M(i)}, current ones; add is:any for past ones.`:`${M(i)}.`}export{V as a,de as b,Je as c,Fe as d,Be as e,On as f,Rn as g,Le as h,Ie as i,Pe as j,nn as k,le as l,ze as m,ce as n,sn as o,_e as p,pn as q,En as r,xn as s,Kn as t};
1
+ import{b as Ce,d as $e,i as U}from"./chunk.SJQPTDAT.js";import{d as Te}from"./chunk.JQ63N4MZ.js";import{$d as We,Kc as se,L as ke,Qb as ae,Wd as Re,Zd as De,ae as Me,cb as Se,da as M,fa as xe,ga as W,gb as G,ka as _,la as z,ma as Ae,oa as we,pa as Ne,ve as je,wd as ve,xd as Oe}from"./chunk.ZEZUKRC6.js";function V(n,e){return n.display?.labels?.[e]??W(e)}function de(n){let e=U(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,i=n.tryDefinition(e);for(let[r,a]of Object.entries(i?.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,s]of Object.entries(r.edges??{}))t.has(a)||s.to!=="*"&&!s.to.includes(e)||t.set(a,{key:a,label:s.inverse?M(s.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 i=t.retired.map(String);return e.some(r=>r.key===t.field&&i.includes(r.value))}function Be(n,e){let t=n.tryDefinition(e);if(!t)return{kind:e,sorts:[],filters:[],groups:[]};let i=new Set(t.display?.hide??[]),r=t.fields.shape??{},a=[{key:"label",label:"Name",about:"label",type:"text"}],s=[],u=[];for(let[g,k]of Object.entries(r)){if(g==="id"||g==="kind"||g==="label"||i.has(g))continue;let A=en(k);if(A){s.push({key:g,label:V(t,g),about:"field",type:"choice",options:A});continue}let w=de(k);if(!w)continue;let N=V(t,g),O=w==="choice"?Le(k):w==="boolean"?["true","false"]:void 0,S={key:g,label:N,about:"field",type:w,...O?{options:O}:{}};a.push(S),s.push(S),(w==="boolean"||w==="choice")&&u.push(S),w==="date"&&u.push({...S,buckets:["day","week","month","year","decade"]})}for(let g of Je(n,e))a.push(g),s.push(g),u.push(g);let l={key:"is",label:t.lifecycle?"Standing and currency":"Standing",about:"is",type:"choice",options:t.lifecycle?[...Ze]:["flagged","clear"]};s.push(l);let y=t.fieldRoles?.order,f=y&&(y in r||y==="label")?{by:y,direction:"asc"}:void 0;return{kind:e,sorts:a,filters:s,groups:u,...f?{natural:f}:{}}}function On(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[s,u]of Object.entries(a.fields.shape??{}))de(u)!=="choice"||a.display?.hide?.includes(s)||t.push({key:`${r.key}.${s}`,label:`${r.label} \xB7 ${V(a,s)}`,about:"via",type:"choice",options:Le(u),far:[a.kind]})}if(t.length===0)return e;let i=e.filters.filter(r=>r.about!=="is");return{...e,filters:[...i,...t,...e.filters.filter(r=>r.about==="is")]}}function Rn(n,e){let t=n.tryDefinition(e.kind),i=Object.entries(t?.computed??{});if(!t||i.length===0)return e;let r=i.filter(([a])=>!e.sorts.some(s=>s.key===a)).map(([a,s])=>({key:a,label:(typeof s=="object"?s.label:void 0)??V(t,a),about:"field",type:"number"}));return{...e,sorts:[...e.sorts,...r]}}function Le(n){let e=U(n);return e.type==="choice"?e.options:[]}function en(n){let e=U(n);return e.type==="several"&&e.of.type==="choice"?e.of.options:void 0}var Ie=n=>n,Pe=n=>n;function nn(n,e,t){let i=new Map;for(let r of[...n.out(e,t),...n.in(e,t)])i.set(r.id,r);return[...i.values()]}function le(n,e,t){let i=n.schema.tryDefinition(e.kind);if(t.key==="is")switch(t.value){case"current":return _(i,Pe(e),n.today);case"past":return!_(i,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=i?.fields.shape??{};if(t.key in r){let l=Se(Ie(e),t.key,n.today??ke()),y=de(r[t.key]);if(y==="date"){let[f,g]=t.value.split(":");if(typeof l!="string"||!g)return!1;let k=l.slice(0,10);return f==="before"?k<g:f==="after"?k>g:k===g}if(y==="boolean")return String(l)===t.value;if(Array.isArray(l))return l.some(f=>String(f)===t.value);if(y==="number"){let f=t.value.lastIndexOf(":"),g=f>0?t.value.slice(0,f):"",k=Number(t.value.slice(f+1));if(g==="at-most"||g==="at-least")return typeof l!="number"||!Number.isFinite(k)?!1:g==="at-most"?l<=k:l>=k}return String(l)===t.value}let[a,s]=t.key.split("."),u=nn(n.graph,e.id,a);return s?u.some(l=>String(Ie(l)[s])===t.value):t.value==="*"?u.length>0:t.value==="none"?u.length===0:u.some(l=>l.id===t.value)}var tn=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 X=new Map,rn=5e4;function $(n){let e=X.get(n);if(e===void 0){X.size>=rn&&X.clear();let t=ze(n);e={tokens:t.split(" ").filter(Boolean),whole:t.replace(/ /g,"")},X.set(n,e)}return e}var T=n=>[...$(n).tokens];function j(n,e){if(e.length===0)return;let{whole:t,tokens:i}=$(n),r=e.join("");if(t.length===0)return;if(t===r)return"exact";if(e.every(s=>i.some(u=>u.startsWith(s))))return t.startsWith(r)?"prefix":e.every(s=>i.includes(s))?"word":"part"}function q(n,e,t=48){let i=n.replace(/\s+/g," ").trim();if(i.length<=t)return i;let r=e[0],a=i.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase(),s=r?a.search(new RegExp(`(^|[^\\p{L}\\p{N}])${on(r)}`,"u")):-1,u=s<0?0:s+(a[s]&&/[\p{L}\p{N}]/u.test(a[s])?0:1),l=Math.max(0,u-Math.floor(t/3));if(l>0){let f=i.lastIndexOf(" ",l);l=f<0?0:f+1}let y=Math.min(i.length,l+t);if(y<i.length){let f=i.indexOf(" ",y);y=f<0||f-y>16?y:f}return`${l>0?"\u2026":""}${i.slice(l,y).trim()}${y<i.length?"\u2026":""}`}var on=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),an=/^([\p{L}][\p{L}\p{N}_-]*):(\S+)$/u;function sn(n){let e=[],t=[];for(let i of n.trim().split(/\s+/).filter(Boolean)){let r=an.exec(i);r?t.push({key:r[1],value:r[2]}):e.push(i)}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 i=dn(n,e);return Ee.set(e,{definition:n,texts:i}),i}function dn(n,e){let t=z(n,e),i=[{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"&&i.push({field:r.key,reading:r.label,text:r.markdown?Te(r.value):r.value});return i}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 i=[],r=Array.from({length:e.length+1},(a,s)=>s);for(let a=1;a<=n.length;a++){let s=[a],u=a;for(let l=1;l<=e.length;l++){let y=Math.min(r[l]+1,s[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]&&(y=Math.min(y,i[l-2]+1)),s[l]=y,y<u&&(u=y)}if(u>t)return t+1;i=r,r=s}return r[e.length]}var Y=new Map;function ln(n,e){let t=Y.get(n);t||(Y.size>=64&&Y.clear(),Y.set(n,t=new Map));let i=t.get(e);return i===void 0&&(i=cn(n,e)??null,t.set(e,i)),i??void 0}function cn(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 i=n.length<4?0:n.length<=7?1:2;if(i!==0){if(He(n,e,i)<=i)return"spelling";if(n.length>=5){for(let r=n.length-i;r<=n.length+i;r++)if(r<e.length&&He(n,e.slice(0,r),i)<=i)return"spelling"}}}function fn(n,e){let t=e.length>1?e.filter(r=>!Ge.has(r)):e;if(t.length===0)return;let i;for(let r of t){let a;for(let s of n){for(let u of $(s.text).tokens){if(u.startsWith(r)){a={text:s,matched:u};break}let l=a?void 0:ln(r,u);l&&(a={text:s,matched:u,by:l})}if(a&&!a.by)break}if(!a)return;a.by&&!i&&(i={text:a.text,asked:r,matched:a.matched,by:a.by})}if(i)return{field:i.text.field,reading:i.text.reading,fragment:q(i.text.text,[i.matched]),strength:"near",asked:i.asked,matched:i.matched,by:i.by}}var un=80;function gn(n,e,t){let i=T(e).filter(s=>!Ge.has(s)).join(" ")||e,r=t===void 0?[]:T(t),a=r.length>0&&n.find(s=>r.every(u=>$(s.text).tokens.some(l=>l.startsWith(u))))||n[0];return{field:a.field,reading:a.reading,fragment:q(a.text,r),strength:"near",asked:i,matched:(t??a.text).slice(0,un),by:"meaning"}}function _e(n,e,t,i){let r=T(t);if(r.length===0)return;if(i){let A=Q(n,e),w=i.includes("label")||i.some(v=>typeof e[v]=="string"&&e[v]===A[0].text),N=A.filter((v,D)=>D===0?w:i.includes(v.field)),O=v=>D=>$(D.text).tokens.some(P=>P.startsWith(v));if(!r.every(v=>N.some(O(v))))return;let S=N.find(O(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),[s,...u]=a,l=j(s.text,r);if(l)return{field:"label",reading:s.reading,fragment:q(s.text,r),strength:l};let y=A=>w=>$(w.text).tokens.some(N=>N.startsWith(A));if(!r.every(A=>a.some(y(A))))return;let f=T(s.text),g=r.find(A=>!f.some(w=>w.startsWith(A)))??r[0],k=u.find(y(g));return{field:k.field,reading:k.reading,fragment:q(k.text,[g]),strength:"field"}}var yn=512,hn=64;function pn(n){let e=new Map;if(n.length===0)return e;let t=n.slice(-yn),i=n[n.length-1].seq;for(let r of t){let a=Math.pow(.5,(i-r.seq)/hn);for(let s of r.writes)e.set(s,(e.get(s)??0)+a)}return e}var ue=(n,e)=>we({tryDefinition:()=>n},e),fe=(n,e)=>De({tryDefinition:()=>n},e);function mn(n,e,t){let i=n.tryDefinition(e),r=[{field:"plural",text:ue(i,e)},{field:"kind",text:W(e)},...i?.noun?[{field:"noun",text:i.noun}]:[],...(i?.aliases??[]).map(s=>({field:"alias",text:s}))],a;for(let s of r){let u=j(s.text,t);u&&(!a||I[u]<I[a.strength])&&(a={strength:u,...s})}return a}var bn,kn=(n,e)=>(bn??=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||kn(n.name,e.name)||(n.id<e.id?-1:n.id>e.id?1:0);function En(n,e,t={}){let i=n.schema,r=sn(e),a=T(r.words),s=t.principal??{kind:"human"},u=n.kindsKeptFrom(s),l=n.modules.disabledKinds,y=r.conditions.filter(o=>o.key==="kind").map(o=>o.value),f=r.conditions.filter(o=>o.key==="is").map(o=>o.value),g=f.includes("any")||f.includes("past"),k=f.includes("past")&&!f.includes("any")&&!f.includes("current"),A=f.includes("archived")?!0:t.archived??"all",w=(o,d)=>{let c=ce(d),h=i.tryDefinition(o);return ce(o)===c||ce(ue(h,o))===c},N=i.kinds.filter(o=>!u.has(o)&&!l.has(o)&&(t.kinds===void 0||t.kinds.includes(o))&&(y.length===0||y.some(d=>w(o,d)))),S=r.conditions.filter(o=>o.key!=="kind").map(o=>({...o,admittedBy:N.filter(d=>Be(i,d).filters.some(c=>c.key===o.key))})),v=S.filter(o=>o.key!=="is"),D=f.filter(o=>o==="flagged"||o==="clear"||o==="past"||o==="archived"),P={kinds:N,past:g},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 J=t.today,F=t.flagged??new Set(n.violations().flatMap(o=>o.nodeIds)),Ue=t.touched??pn(n.log.all()),Z=new Set;for(let o of t.from??[]){Z.add(o);for(let d of n.graph.neighbors(o))Z.add(d.id)}let ge=ve(n,s)?Oe(n,s):void 0,ee=ae.keptFrom?.(n,s)&&n.seenBy(s).graph,ne=o=>je(o,t.basePath===void 0?{}:{basePath:t.basePath}),ye={schema:i,graph:n.graph,flagged:F,...J?{today:J}:{}},R=[],B={},L=[],E=[],K=(o,d,c,h,p,m)=>{let x=z(c,o);B[d]=(B[d]??0)+1,R.push({hit:{about:"node",id:o.id,kind:d,label:x,why:p,current:h,flagged:F.has(o.id),address:ne(`${fe(c,d)}/${encodeURIComponent(o.id)}`),...m===void 0?{}:{near:!0},...G(o)?{archived:!0}:{}},...m===void 0?{}:{nearly:2-m},tier:I[p.strength],inKind:d===t.inKind?0:1,near:Z.has(o.id)?0:1,past:h?0:1,archived:G(o)?1:0,touched:-(Ue.get(o.id)??0),flagged:F.has(o.id)?0:1,name:x,id:o.id})};for(let o of N){let d=i.tryDefinition(o),c=S.filter(p=>p.key!=="is"&&p.admittedBy.includes(o));if(a.length===0&&c.length===0&&D.length===0)continue;let h=Fe(d,c);for(let p of n.graph.nodesOfKind(o,{archived:A})){if(ge&&!ge(p.id))continue;let m=ee?ee.getNode(p.id):p;if(!m)continue;let x=_(d,m,J);if(!g&&!h&&!x){if(a.length>0&&f.length===0&&c.every(b=>le(ye,m,b))){let b=_e(d,m,r.words);b&&E.push({node:m,kind:o,definition:d,why:b})}continue}if(k&&x||!c.every(b=>le(ye,m,b))||f.includes("flagged")&&!F.has(m.id)||f.includes("clear")&&F.has(m.id))continue;let C=a.length>0?_e(d,m,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(m,o,d,x,C):a.length>0&&L.push({node:m,kind:o,definition:d,current:x})}}let te=o=>o.strength!=="field",re=!1;if(E.length>0&&R.length===0){re=!0;for(let o of E)K(o.node,o.kind,o.definition,!1,o.why)}else if(E.some(o=>te(o.why))&&!R.some(o=>te(o.hit.why))){re=!0;for(let o of E)te(o.why)&&K(o.node,o.kind,o.definition,!1,o.why)}let he=t.near!==!1&&a.length>0&&R.length<tn&&L.length>0,ie=new Set;if(he)for(let o of L){let d=fn(Q(o.definition,o.node),a);d&&(ie.add(o.node.id),K(o.node,o.kind,o.definition,o.current,d,d.by==="stem"?.9:.8))}let Ve=o=>o==="exact"||o==="prefix"?-1:I[o],oe=(o,d,c,h)=>({hit:o,tier:Ve(d),inKind:1,near:1,past:0,touched:0,flagged:1,name:c,id:h});if(a.length>0){for(let d of N){let c=mn(i,d,a);if(!c)continue;let h=Ne(i,d),p={field:c.field,reading:c.field==="plural"?"Plural":"Kind",fragment:c.text,strength:c.strength};R.push(oe({about:"kind",kind:d,label:h,why:p,count:B[d]??0,address:ne(fe(i.tryDefinition(d),d))},c.strength,h,`kind:${d}`))}let o=t.places??[];for(let d of Re(o.filter(c=>N.includes(c.kind)))){if(d.across&&u.has(d.across))continue;let c=j(d.title,a);if(!c)continue;let h={field:"title",reading:"Title",fragment:d.title,strength:c},p=Me(d,o)?fe(i.tryDefinition(d.kind),d.kind).slice(1):void 0,m=ne(We(d.as,p));R.push(oe({about:"place",kind:d.kind,title:d.title,as:d.as,why:h,address:m},c,d.title,`place:${d.kind}:${d.as}`))}for(let d of n.allInvariants()){let c=d.scope==="graph"?void 0:d.scope.kind;if(c&&!N.includes(c))continue;let h=d.label??W(d.name),p=j(h,a),m=p?void 0:j(W(d.name),a),x=p??m;if(!x)continue;let C={field:p?"label":"name",reading:p?"Rule":"Name",fragment:p?h:d.name,strength:x};R.push(oe({about:"rule",name:d.name,label:h,...c?{kind:c}:{},why:C},x,h,`rule:${d.name}`))}}let pe=()=>{R.sort(qe);let o=t.limit??50,d=R.slice(0,o).map(b=>b.hit),c=d.flatMap(b=>b.about==="node"?[(ee||n.graph).getNode(b.id)]:[]).filter(Boolean),h=Ce(c,b=>i.tryDefinition(b)),p=d.map(b=>b.about==="node"&&h.has(b.id)?{...b,apart:h.get(b.id)}:b),m=Object.values(B).reduce((b,Ye)=>b+Ye,0),x=R.flatMap(b=>b.hit.about==="node"?[b.hit.id]:[]),C=t.subject&&N.includes(String(n.graph.getNode(t.subject)?.kind))?xn(n,t.subject,r.words,{principal:s}):[];return{hits:[...p,...C],words:r.words,conditions:S,searched:re?{...P,past:!0}:P,byKind:{...B},total:m,matched:x}},H=pe(),me=t.rank;if(!he||!me)return H;let be=L.filter(o=>!ie.has(o.node.id)).map(({node:o,kind:d,definition:c})=>({id:o.id,kind:d,label:z(c,o),texts:Q(c,o)}));if(be.length===0)return H;let Xe=(async()=>{let o;try{o=await me(r.words,be)}catch{return H}let d=new Map(L.filter(h=>!ie.has(h.node.id)).map(h=>[h.node.id,h])),c=!1;for(let{id:h,score:p,matched:m}of Array.isArray(o)?o:[]){let x=d.get(h);!x||!(p>0)||(d.delete(h),c=!0,K(x.node,x.kind,x.definition,x.current,gn(Q(x.definition,x.node),r.words,typeof m=="string"?m:void 0),Math.min(1,p)))}return c?pe():H})();return{...H,later:Xe}}function xn(n,e,t,i={}){let r=i.principal??{kind:"human"},a=(ae.keptFrom?.(n,r)?n.seenBy(r):n).graph.getNode(e);if(!a)return[];if(n.kindsKeptFrom(r).has(a.kind))return[];let s=T(t),u=z(n.schema.tryDefinition(a.kind),a),l=[];for(let f of n.allMutations()){let g=f.subject;if(!g||g.kinds!=="*"&&!g.kinds.includes(a.kind))continue;let k=f.derived?.act;if((k==="archive"||k==="merge")&&G(a)||k==="unarchive"&&!G(a)||k==="leave-alone"&&se(a)||k==="allow-tidying"&&!se(a)||!n.permits({name:f.name,args:{[g.arg]:a.id}},r).ok)continue;let A=Ae(f),w=T(A),N=s.filter(v=>w.some(D=>D.startsWith(v))),O=N.length>0?j(A,N):void 0,S=O?{field:"title",reading:"Act",fragment:A,strength:O}:{field:"subject",reading:"On",fragment:u,strength:"field"};l.push({hit:{about:"act",name:f.name,title:A,subject:a.id,why:S,destructive:f.destructive===!0},tier:O?I[O]:I.field+1,inKind:0,near:0,past:f.destructive?1:0,touched:0,flagged:f.pinned?0:1,name:A,id:`act:${f.name}`})}l.sort(qe);let y=l.map(f=>f.hit);return i.limit===void 0?y:y.slice(0,i.limit)}function Kn(n,e){let t=e.kinds.map((a,s)=>{let u=ue(n.tryDefinition(a),a);return s===0?u:u.toLowerCase()}),i=xe(t)||"Nothing";return e.kinds.some(a=>n.tryDefinition(a)?.lifecycle)?e.past?`${M(i)}, past ones included.`:`${M(i)}, current ones; add is:any for past ones.`:`${M(i)}.`}export{V as a,de as b,Je as c,Fe as d,Be as e,On as f,Rn as g,Le as h,Ie as i,Pe as j,nn as k,le as l,ze as m,ce as n,sn as o,_e as p,pn as q,En as r,xn as s,Kn as t};
@@ -1 +1 @@
1
- import{G as h}from"./chunk.3CJLAJXP.js";import{Md as u,Rc as a,dd as m}from"./chunk.J24YPQ5I.js";import{b as l}from"./chunk.AJZBJBMO.js";function f(e){let t=[e?.typography?.body,e?.typography?.display,e?.typography?.mono],o=[];for(let i of t){let n=i?.split(",")[0]?.trim().replace(/^["']|["']$/g,"");!n||m(n)||n.toLowerCase()!==a.toLowerCase()&&(o.includes(n)||o.push(n))}return o}function g(e){let t=f(e);return t.length===0?null:`https://fonts.googleapis.com/css2?${t.map(i=>`family=${encodeURIComponent(i).replace(/%20/g,"+")}:wght@400;500;600;700`).join("&")}&display=swap`}var r=l(h(),1);function k(e,t){return new u({schema:e.schema,mutations:e.mutations??[],invariants:e.invariants??[],...t?{snapshot:t}:{},...e.policy?{policy:e.policy}:{},...e.publishing?{publishing:e.publishing}:{},...e.tidying?{tidying:e.tidying}:{},...e.intelligence?{intelligence:e.intelligence}:{},...e.brand?.timeZone?{timeZone:e.brand.timeZone}:{}})}function d(e){if(typeof document>"u")return e==="dark"?"dark":"light";let t=document.documentElement.dataset.theme;return t==="dark"||t==="light"?t:e==="dark"||e==="light"?e:typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function v(e,t){let[o,i]=(0,r.useState)(()=>d(t));return(0,r.useEffect)(()=>{if(!e||typeof document>"u")return;let n=()=>i(d(t));n();let s=new MutationObserver(n);s.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});let c=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null;return c?.addEventListener?.("change",n),()=>{s.disconnect(),c?.removeEventListener?.("change",n)}},[e,t]),o}export{g as a,k as b,v as c};
1
+ import{G as h}from"./chunk.A5PSEU3W.js";import{Qd as u,Sc as a,ed as m}from"./chunk.ZEZUKRC6.js";import{b as l}from"./chunk.AJZBJBMO.js";function f(e){let t=[e?.typography?.body,e?.typography?.display,e?.typography?.mono],o=[];for(let i of t){let n=i?.split(",")[0]?.trim().replace(/^["']|["']$/g,"");!n||m(n)||n.toLowerCase()!==a.toLowerCase()&&(o.includes(n)||o.push(n))}return o}function g(e){let t=f(e);return t.length===0?null:`https://fonts.googleapis.com/css2?${t.map(i=>`family=${encodeURIComponent(i).replace(/%20/g,"+")}:wght@400;500;600;700`).join("&")}&display=swap`}var r=l(h(),1);function k(e,t){return new u({schema:e.schema,mutations:e.mutations??[],invariants:e.invariants??[],...t?{snapshot:t}:{},...e.policy?{policy:e.policy}:{},...e.publishing?{publishing:e.publishing}:{},...e.tidying?{tidying:e.tidying}:{},...e.intelligence?{intelligence:e.intelligence}:{},...e.brand?.timeZone?{timeZone:e.brand.timeZone}:{}})}function d(e){if(typeof document>"u")return e==="dark"?"dark":"light";let t=document.documentElement.dataset.theme;return t==="dark"||t==="light"?t:e==="dark"||e==="light"?e:typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function v(e,t){let[o,i]=(0,r.useState)(()=>d(t));return(0,r.useEffect)(()=>{if(!e||typeof document>"u")return;let n=()=>i(d(t));n();let s=new MutationObserver(n);s.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});let c=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null;return c?.addEventListener?.("change",n),()=>{s.disconnect(),c?.removeEventListener?.("change",n)}},[e,t]),o}export{g as a,k as b,v as c};
@@ -0,0 +1,3 @@
1
+ import"./chunk.DEKRFTRN.js";import{a as _,b as me,c as he,e as fe}from"./chunk.SY5ID44D.js";import"./chunk.GVT4UUQA.js";import"./chunk.J6HF7IRQ.js";import"./chunk.LRNFE3UK.js";import"./chunk.HJCQ6I3S.js";import{a as we,d as ve}from"./chunk.YCD4JSXD.js";import"./chunk.ZG5VGP5U.js";import{d as ye}from"./chunk.QAM76AXV.js";import"./chunk.Z27NSSYL.js";import{a as de}from"./chunk.WEMUKZKH.js";import"./chunk.T27QKVKP.js";import"./chunk.URQTF5SY.js";import"./chunk.BIDL7GQD.js";import"./chunk.LP2ZMAT2.js";import"./chunk.MSAYU25L.js";import"./chunk.EGPCVMDU.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.6SJEZWH3.js";import"./chunk.6N4PE3U5.js";import"./chunk.B7KZBT27.js";import"./chunk.WVUJXDXZ.js";import"./chunk.DWM7AR5Y.js";import"./chunk.6KJGRM7A.js";import"./chunk.WALVW3KJ.js";import"./chunk.SNHKYH72.js";import"./chunk.UGQYMN4J.js";import"./chunk.RG5G6YQD.js";import"./chunk.MIE4TJRW.js";import{p as pe,s as K}from"./chunk.QRQ5WPZI.js";import"./chunk.RD2FSSLV.js";import{a as ue}from"./chunk.37RFCHSS.js";import"./chunk.SO6NT5K7.js";import"./chunk.MUSMNKE4.js";import"./chunk.SJQPTDAT.js";import{b as ce}from"./chunk.JQ63N4MZ.js";import"./chunk.Z3O2VZAJ.js";import{t as ge}from"./chunk.QNP5OR3P.js";import"./chunk.4W57E7AX.js";import{G as Ee,K as L,Qa as le,Ra as W,W as ie,Z as se,ea as P,ga as $,j as N,l as ae,m as q,r as C,ra as G,v as re,z as oe}from"./chunk.A5PSEU3W.js";import"./chunk.SDO3U72B.js";import{Z as V,ka as I,la as B,na as F,pa as M,td as ne,ua as te}from"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import{b as D}from"./chunk.AJZBJBMO.js";var p=D(Ee(),1);var e=D(ie(),1),Ae=ge.part((t,s)=>(0,e.jsx)(t.ProblemRows,{...s}),{what:"The problems",as:"li"}),R="var(--graview-gap, 8px)",Re=720;function je({showing:t}){return t.what==="lens"?(0,e.jsx)(Ne,{kind:t.kind},`lens:${t.kind}`):t.what==="record"?(0,e.jsx)(Ie,{id:t.id},`record:${t.id}`):(0,e.jsx)($e,{kind:t.kind},`district:${t.kind}`)}var U=[{height:"52%",share:.52,said:"Half of the screen"},{height:"66%",share:.66,said:"Two thirds of the screen"},{height:"calc(100% - 56px)",share:1,said:"Nearly all of the screen"}],xe=1,be=xe;function Ce(){let[t,s]=(0,p.useState)(be);return[t,n=>{be=n,s(n)}]}var Pe=t=>U.map(s=>s.share===1?t-56:t*s.share);function Te({region:t,rest:s,setRest:n,label:i}){let l=(0,p.useRef)(null),c=o=>n(Math.max(0,Math.min(2,o)));return(0,e.jsx)("div",{role:"separator","aria-orientation":"horizontal","aria-label":`How much of the screen ${i} takes`,"aria-valuemin":0,"aria-valuemax":2,"aria-valuenow":s,"aria-valuetext":U[s].said,tabIndex:0,"data-testid":"map-panel-handle","data-graview-rest":s,title:"Drag to see more or less of the map",onKeyDown:o=>{let r=o.key==="ArrowUp"?s+1:o.key==="ArrowDown"?s-1:o.key==="Home"?0:o.key==="End"?2:null;r!==null&&(o.preventDefault(),c(r))},onPointerDown:o=>{let r=t.current,u=r?.parentElement?.getBoundingClientRect().height??0;if(!(!r||u<=0||o.button!==0)){o.stopPropagation(),l.current={id:o.pointerId,from:o.clientY,height:r.getBoundingClientRect().height,rests:Pe(u)},r.style.transition="none";try{o.currentTarget.setPointerCapture(o.pointerId)}catch{}}},onPointerMove:o=>{let r=l.current,u=t.current;if(!r||!u||o.pointerId!==r.id)return;let g=r.rests;u.style.height=`${Math.round(Math.max(g[0]-24,Math.min(g[2],r.height+r.from-o.clientY)))}px`},onPointerUp:o=>{let r=l.current,u=t.current;if(l.current=null,!r||!u)return;let g=u.getBoundingClientRect().height;u.style.transition="",u.style.height="",Math.abs(o.clientY-r.from)<6?c(s===2?xe:s+1):c(r.rests.reduce((f,d,w)=>Math.abs(d-g)<Math.abs(r.rests[f]-g)?w:f,0))},onPointerCancel:()=>{let o=t.current;l.current=null,o&&(o.style.transition="",o.style.height="")},style:{flex:"0 0 auto",display:"flex",justifyContent:"center",alignItems:"center",height:22,cursor:"ns-resize",touchAction:"none"},children:(0,e.jsx)("span",{"aria-hidden":"true",style:{width:40,height:4,borderRadius:2,background:"var(--graview-edge-strong, var(--graview-edge))"}})})}function X({label:t,wide:s,testId:n,head:i,onClose:l,children:c}){let o=(0,p.useRef)(null),[r,u]=(0,p.useState)(!1),[g,f]=Ce(),d=U[g].height;(0,p.useLayoutEffect)(()=>{let v=o.current?.parentElement;if(!v)return;let S=()=>u(v.getBoundingClientRect().width<Re);if(S(),typeof ResizeObserver>"u")return;let h=new ResizeObserver(S);return h.observe(v),()=>h.disconnect()},[]);let w=(0,p.useRef)(l);return w.current=l,(0,p.useEffect)(()=>{let v=k=>{if(k.key!=="Escape"||k.defaultPrevented)return;let A=document.activeElement;A instanceof HTMLInputElement||A instanceof HTMLTextAreaElement||document.querySelector("[data-graview-popover]:popover-open")||S||w.current()},S=!1,h=()=>{S=document.querySelector('[data-testid="following-who"]')!==null};return window.addEventListener("keydown",h,!0),document.addEventListener("keydown",v),()=>{window.removeEventListener("keydown",h,!0),document.removeEventListener("keydown",v)}},[]),(0,e.jsxs)("section",{ref:o,"aria-label":t,"data-testid":n,"data-graview-map-panel":r?"sheet":"dock","data-graview-overlay":"","data-graview-offstage":"",className:"graview-map-panel",style:{position:"absolute",zIndex:ne("rail"),boxSizing:"border-box",display:"flex",flexDirection:"column",background:"var(--graview-panel)",color:"var(--graview-ink)",overflow:"hidden",border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",boxShadow:"var(--graview-lift-high)",...r?{left:R,right:R,bottom:`calc(${R} + env(safe-area-inset-bottom, 0px))`,height:d,transition:"height 180ms ease-out"}:{top:R,right:R,bottom:R,width:s}},children:[r?(0,e.jsx)("style",{children:`:has(> [data-graview-map-panel="sheet"]) { --graview-sheet: calc(${d} + 2 * ${R} + env(safe-area-inset-bottom, 0px)); }`}):(0,e.jsx)("style",{children:`:has(> [data-graview-map-panel="dock"]) { --graview-dock: calc(${s} + 2 * ${R}); }`}),r?(0,e.jsx)(Te,{region:o,rest:g,setRest:f,label:t}):null,(0,e.jsxs)("header",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:r?"4px 14px 10px 18px":"14px 14px 10px 18px",borderBottom:"1px solid var(--graview-edge)"},children:[(0,e.jsx)("div",{style:{flex:"1 1 auto",minWidth:0},children:i}),(0,e.jsx)("button",{type:"button","data-testid":"map-panel-close","aria-label":"Close",title:"Close (Escape)",onClick:l,style:{flex:"0 0 auto",minWidth:32,height:32,borderRadius:8,fontSize:"1.1rem",lineHeight:1},children:"\xD7"})]}),(0,e.jsx)("div",{style:{flex:"1 1 auto",minHeight:0,overflow:"auto"},children:c})]})}var J={fontSize:"0.75rem",letterSpacing:"0.09em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},Q={margin:"2px 0 0",fontSize:"1.125rem",fontWeight:600,lineHeight:1.3,overflowWrap:"anywhere"},Z={margin:"4px 0 0",fontSize:"0.875rem",color:"var(--graview-ink-muted)"},j={margin:"14px 18px 6px",fontSize:"0.8125rem",fontWeight:600,color:"var(--graview-ink-muted)"},z={listStyle:"none",margin:0,padding:"0 10px 6px"},Y={all:"unset",outline:"revert-layer",boxSizing:"border-box",display:"flex",alignItems:"baseline",gap:8,width:"100%",padding:"6px 8px",borderRadius:6,cursor:"pointer",fontSize:"0.875rem"},H={minHeight:30,padding:"0 12px",borderRadius:8,fontSize:"0.8125rem"};function ee(){let{setSelection:t,setMenuAt:s}=P();return(n,i)=>{n.preventDefault(),t([i]),s({x:n.clientX,y:n.clientY,on:i})}}function Se({on:t,about:s}){let{setSelection:n,setMenuAt:i}=P();return(0,e.jsx)("button",{type:"button","data-testid":"map-panel-acts","aria-label":`What can be done with ${s}`,"aria-haspopup":"menu",style:H,onClick:l=>{let c=l.currentTarget.getBoundingClientRect();n([t]),i({x:Math.round(c.left),y:Math.round(c.bottom+4),on:t})},children:"Acts\u2026"})}var ke=(t,s)=>({...N(q(t,!1),s),relation:null});function Me(t,s){let n=`[data-graview-stage] [data-graview-view="${CSS.escape(t)}"][tabindex]`,i=null;for(let r=s?.parentElement??null;r&&!i;r=r.parentElement)i=r.querySelector(".graview-ground");i??=document.querySelector(".graview-ground");let l=i!==null&&!i.hasAttribute("tabindex");i&&l&&(i.setAttribute("tabindex","-1"),i.addEventListener("focusout",r=>{r.target===i&&i.removeAttribute("tabindex")},{once:!0})),i?.focus({preventScroll:!0});let c=performance.now()+5e3,o=()=>{let r=document.activeElement;if(!(r===null||r===document.body||r===document.documentElement||r===s||r===i))return;let g=document.querySelector(n);if(g&&g.isConnected&&!g.closest("[inert]"))return g.focus({preventScroll:!0});performance.now()<c&&requestAnimationFrame(o)};requestAnimationFrame(o)}function Ne({kind:t}){let s=ee(),{store:n,views:i,view:l,selection:c,setSelection:o}=P(),{go:r}=W(),u=$(),g=l.within?.view,f=i.places().filter(b=>b.kind===t),d=(g!==void 0?f.find(b=>b.as===g):void 0)??f.at(-1),w=i.resolve(t,{cardinality:"many",fidelity:"full"},d?.as??g),v=w?.view,S=n.schema.tryDefinition(t),h=(0,p.useMemo)(()=>n.graph.nodesOfKind(t).filter(b=>l.past===!0||I(S,b)),[n,t,u,l.past,S]),k=w?.title??d?.title??M(n.schema,t),A=v!==void 0&&G(v),m=c.filter(b=>n.graph.getNode(b)!==void 0),y=ue();return(0,e.jsxs)(X,{label:k,testId:"lens-panel",wide:"min(max(440px, 46%), 760px)",onClose:()=>r(ae(N(l,null),"view",null)),head:A?null:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:J,children:M(n.schema,t)}),(0,e.jsx)("h2",{style:Q,"data-testid":"lens-panel-title",children:k}),(0,e.jsxs)("p",{style:Z,children:[F(n.schema,t,h.length),S?.description?` \xB7 ${S.description}`:""]}),d?(0,e.jsx)("div",{style:{marginTop:10},children:(0,e.jsx)("button",{type:"button","data-testid":"lens-panel-open",style:H,title:`Open ${k} on its own`,onClick:()=>r(oe(l,t,d.as)),children:"Open \u2197"})}):null]}),children:[(0,e.jsx)("style",{children:`.graview-ground[data-graview-altitude] .graview-plot:not([data-graview-plot="${C(t)}"]) { opacity: 0.35; }
2
+ .graview-ground[data-graview-altitude] [data-graview-view^="kind:"]:not([data-graview-view="${C(t)}"]) { opacity: 0.4; }`}),(0,e.jsx)("div",{"data-graview-lens":d?.as??"",style:{padding:"8px 12px 16px",minHeight:"100%",boxSizing:"border-box",display:"grid",gridTemplateRows:"1fr",gridTemplateColumns:"minmax(0, 1fr)",alignItems:"start"},onClick:b=>{let a=L(b.target);if(!a||n.graph.getNode(a)===void 0)return;let x=b.target.closest("button, a, input, select, textarea, [contenteditable='true']");x&&!x.hasAttribute("data-graview-pick")||o([a])},onDoubleClick:b=>{let a=L(b.target);!a||n.graph.getNode(a)===void 0||r(ke(l,a))},onContextMenu:b=>{let a=L(b.target);!a||n.graph.getNode(a)===void 0||s(b,a)},children:v?(0,e.jsx)(de.Provider,{value:k,children:(0,e.jsx)(se,{mode:"fullscreen",children:(0,e.jsx)(K,{kind:t,...w?.title?{view:w.title}:{},children:(0,e.jsx)(v,{nodes:h,label:k,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1,...m.length>0?{implicated:m}:{},...y.length>0?{flagged:y}:{}})})})}):null})]})}function He(t,s,n,i){let l=i(n),c=new Map;for(let o of s){let r=o.from===n;if(!r&&o.to!==n)continue;let u=r?o.to:o.from,g=i(u);if(g===void 0||l===void 0)continue;let f=`${o.kind}|${r?"out":"in"}|${g}`,d=c.get(f);if(d){d.others.includes(u)||d.others.push(u);continue}c.set(f,{key:f,edge:o.kind,words:ce(t,r?l:g,o.kind,r?"out":"in"),kind:g,others:[u]})}return[...c.values()]}function Ie({id:t}){let s=ee(),{store:n,views:i,view:l,setSelection:c}=P(),{go:o}=W(),r=$(),u=n.graph.getNode(t),g=m=>n.graph.getNode(m)?.kind,f=(0,p.useMemo)(()=>He(n.schema,n.graph.allEdges(),t,g),[n,t,r]);if(!u)return null;let d=u.kind,w=m=>{let y=n.graph.getNode(m);return y?B(n.schema.tryDefinition(y.kind),y):m},v=te(n.schema.tryDefinition(d),d),h=i.resolve(d,{cardinality:"one",fidelity:"full"})?.view,k=h!==void 0&&!G(h),A=()=>l.focusId===t?o({...N(l,null),selection:[]}):c([]);return(0,e.jsxs)(X,{label:`${w(t)}: its links`,testId:"record-panel",wide:k?"min(max(440px, 46%), 760px)":"min(360px, 40%)",onClose:A,head:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:J,children:v}),(0,e.jsx)("h2",{style:Q,"data-testid":"record-panel-title",children:w(t)}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginTop:10},children:[(0,e.jsx)("button",{type:"button","data-testid":"record-panel-go",style:H,onClick:m=>{o(ke(l,t)),Me(t,m.currentTarget)},children:"Go to it"}),(0,e.jsx)(Se,{on:t,about:w(t)}),(0,e.jsxs)("button",{type:"button","data-testid":"record-panel-district",style:H,onClick:()=>c([C(d)]),children:["All ",M(n.schema,d).toLowerCase()]})]})]}),children:[(0,e.jsx)("div",{"data-graview-record-card":t,style:{padding:"8px 18px 0"},children:k?(0,e.jsx)(K,{kind:d,children:(0,e.jsx)(h,{node:u,fidelity:"full",cardinality:"one",mode:"fullscreen",selected:!1})}):(0,e.jsx)(ye,{id:t,shown:[w(t)]})}),f.length===0?(0,e.jsx)("p",{style:{...Z,margin:"14px 18px"},children:"No links yet."}):null,f.map(m=>(0,e.jsxs)("section",{"aria-label":m.words,"data-graview-links":m.edge,children:[(0,e.jsxs)("h3",{style:j,children:[m.words.charAt(0).toUpperCase()+m.words.slice(1)," ",(0,e.jsxs)("span",{style:{fontWeight:400,color:"var(--graview-ink-faint)"},children:["\xB7 ",m.others.length]})]}),(0,e.jsx)("ul",{style:z,children:m.others.map(y=>(0,e.jsx)("li",{children:(0,e.jsxs)("button",{type:"button",className:"graview-map-panel-row","data-graview-record":y,style:Y,onClick:()=>c([y]),onContextMenu:T=>s(T,y),children:[(0,e.jsx)("span",{style:{flex:"1 1 auto",minWidth:0,overflowWrap:"anywhere"},children:w(y)}),m.kind!==d?null:(0,e.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:v})]})},y))})]},m.key))]})}var Le=24;function $e({kind:t}){let s=ee(),{store:n,view:i,setSelection:l,setEmphasis:c}=P(),{go:o}=W(),r=$(),[u,g]=(0,p.useState)(""),f=n.schema.tryDefinition(t),d=(0,p.useMemo)(()=>n.graph.nodesOfKind(t).filter(a=>i.past===!0||I(f,a)).map(a=>({id:a.id,name:B(f,a)})).sort((a,x)=>a.name.localeCompare(x.name)),[n,t,r,i.past,f]),w=(0,p.useMemo)(()=>{let a=E=>{let O=n.graph.getNode(E);return O!==void 0&&(i.past===!0||I(n.schema.tryDefinition(O.kind),O))},x=n.graph.allEdges().filter(E=>a(E.from)&&a(E.to));return we(x,E=>n.graph.getNode(E)?.kind).filter(E=>E.from===t||E.to===t)},[n,t,r,i.past]);(0,p.useEffect)(()=>()=>c(null),[c]);let v=le(),S=pe().marks.flag,h=(0,p.useMemo)(()=>{let a=new Set(d.map(x=>x.id));return v.filter(x=>x.nodeIds.some(E=>a.has(E)))},[v,d]),k=(0,p.useMemo)(()=>[...new Set(h.flatMap(a=>a.nodeIds))].filter(a=>n.graph.getNode(a)?.kind===t).slice(0,300),[h,n,t]),A=(0,p.useRef)(null),m=(0,p.useSyncExternalStore)(me,_,_);(0,p.useEffect)(()=>{m?.kind!==t||h.length===0||(A.current?.scrollIntoView?.({block:"start"}),A.current?.focus({preventScroll:!0}))},[m?.n,m?.kind,t,h.length>0]),(0,p.useEffect)(()=>()=>{he(),setTimeout(()=>{let a=document.activeElement;if(a&&a!==document.body)return;let x=CSS.escape(t);document.querySelector(`[data-testid="district-problems-${x}"]`)?.focus({preventScroll:!0})??document.querySelector(`[data-graview-view="${C(t).replace(/["\\]/g,"\\$&")}"]`)?.focus({preventScroll:!0})},0)},[t]);let y=M(n.schema,t),T=u.trim().toLowerCase(),b=T?d.filter(a=>a.name.toLowerCase().includes(T)):d;return(0,e.jsxs)(X,{label:y,testId:"district-panel",wide:"min(360px, 40%)",onClose:()=>l([]),head:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:J,children:"District"}),(0,e.jsx)("h2",{style:Q,"data-testid":"district-panel-title",children:y}),(0,e.jsxs)("p",{style:Z,children:[F(n.schema,t,d.length),f?.description?` \xB7 ${f.description}`:""]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginTop:10},children:[(0,e.jsx)("button",{type:"button","data-testid":"district-panel-go",style:H,onClick:()=>o({...N(q(i,!1),re(t)),relation:null}),children:"Go in"}),(0,e.jsx)(Se,{on:C(t),about:`the ${y.toLowerCase()}`})]})]}),children:[h.length>0?(0,e.jsxs)("section",{"aria-label":"Problems","data-testid":"district-problems","data-graview-problems":h.length,children:[(0,e.jsx)("style",{children:`${k.map(a=>`.graview-ground[data-graview-altitude] .graview-building[data-graview-building="${CSS.escape(a)}"] polygon`).join(`,
3
+ `)} { stroke: var(--graview-accent); stroke-width: 2.2; stroke-opacity: 1; }`}),(0,e.jsxs)("h3",{ref:A,tabIndex:-1,"data-testid":"district-problems-heading",style:{display:"flex",alignItems:"baseline",gap:8,margin:0,padding:"14px 18px 8px",fontSize:"0.9375rem",fontWeight:600,color:"var(--graview-warn)",borderTop:"1px solid var(--graview-edge)",scrollMarginTop:0,outlineOffset:-2},children:[(0,e.jsx)("span",{"aria-hidden":"true",children:S}),(0,e.jsx)("span",{style:{color:"var(--graview-ink)"},children:fe(h.length,y)})]}),(0,e.jsx)("ol",{style:z,"data-testid":"district-problem-rows",children:(0,e.jsx)(p.Suspense,{fallback:null,children:(0,e.jsx)(Ae,{violations:h,pick:a=>{let x=a.subjectId??a.nodeIds[0];x!==void 0&&l([x])}})})})]}):null,w.length>0?(0,e.jsxs)("section",{"aria-label":"Relations",children:[(0,e.jsx)("h3",{style:j,children:"Relations"}),(0,e.jsx)("ul",{style:z,children:w.map(a=>(0,e.jsx)("li",{children:(0,e.jsxs)("div",{"data-graview-relation-said":a.edge,tabIndex:0,style:{...Y,cursor:"default"},onPointerEnter:()=>c(a.edge),onPointerLeave:()=>c(null),onFocus:()=>c(a.edge),onBlur:()=>c(null),children:[(0,e.jsx)("span",{style:{flex:"1 1 auto",minWidth:0},children:ve(n.schema,a)}),(0,e.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",fontVariantNumeric:"tabular-nums"},title:`${V(a.links)} links`,children:V(a.links)})]})},a.key))})]}):null,(0,e.jsxs)("div",{role:"group","aria-label":y,children:[(0,e.jsxs)("h3",{style:j,children:[y," ",(0,e.jsxs)("span",{style:{fontWeight:400,color:"var(--graview-ink-faint)"},children:["\xB7 ",d.length]})]}),d.length>Le?(0,e.jsx)("div",{style:{padding:"0 18px 6px"},children:(0,e.jsx)("input",{type:"search","data-testid":"district-panel-narrow","aria-label":`Narrow the ${y.toLowerCase()} by name`,placeholder:"Narrow by name",value:u,onChange:a=>g(a.target.value),style:{width:"100%",boxSizing:"border-box",minHeight:32}})}):null,(0,e.jsx)("ul",{style:z,children:b.map(a=>(0,e.jsx)("li",{children:(0,e.jsx)("button",{type:"button",className:"graview-map-panel-row","data-graview-record":a.id,style:Y,onClick:()=>l([a.id]),onContextMenu:x=>s(x,a.id),children:(0,e.jsx)("span",{style:{flex:"1 1 auto",minWidth:0,overflowWrap:"anywhere"},children:a.name})})},a.id))})]})]})}export{je as MapPanelFor};
@@ -1 +1 @@
1
- var n="http://www.w3.org/1999/xhtml",u=new Set(["button","submit","reset","checkbox","radio","image"]),d=new Set(["button","checkbox","switch","tab","menuitem","menuitemcheckbox","menuitemradio","option","radio","slider","spinbutton","textbox","combobox","link"]),c=new Set(["div","span","section","article","aside","header","footer","figure","p","b","i","em","strong","small","mark","time","img"]),e=(t,...r)=>t.namespaceURI===n&&r.includes(t.localName),l=t=>(t.getAttribute("type")??"text").toLowerCase(),b=t=>e(t,"textarea","select")||e(t,"input")&&!u.has(l(t)),i=t=>e(t,"input","select","textarea");function f(t){return e(t,"button","summary")||e(t,"input")&&u.has(l(t))||t.localName==="a"&&t.hasAttribute("data-graview-link")}function p(t){if(e(t,"option","optgroup","datalist"))return'An option is never pressed by itself: put data-act on its select, with data-save="change", or on a button.';if(e(t,"label"))return"A press on a label presses its field too, and would ask for the act twice: put data-act on a button, or on the field.";if(b(t)&&!t.hasAttribute("data-save"))return'A click into a field to type or to pick is not a press: give it data-save ("input" or "change") to save it as it is typed, or put data-act on a button beside it.'}var A=t=>t.hasAttribute("data-act")&&p(t)===void 0&&!(i(t)&&t.hasAttribute("data-save")),h=new Set(["button","checkbox","switch","tab"]);function E(t,r=t.getAttribute("role")){return f(t)||i(t)||e(t,"label","option")||t.hasAttribute("data-graview-link")?!1:h.has(r??"")||t.hasAttribute("aria-pressed")||t.hasAttribute("aria-expanded")}function x(t){return e(t,"button","input","select","textarea","summary","iframe")||t.localName==="a"&&t.hasAttribute("href")?!0:t.hasAttribute("tabindex")||(t.getAttribute("contenteditable")??"false")!=="false"}var P=t=>!t.hasAttribute("role")&&(t.namespaceURI!==n||c.has(t.localName));function g(t){return e(t,"button","input","select","textarea","label","summary","option")||t.hasAttribute("data-act")||t.hasAttribute("data-lightbox")||t.hasAttribute("data-drop")?!0:d.has(t.getAttribute("role")??"")}function w(t,r){return!t.hasAttribute("data-record")&&!t.hasAttribute("data-place")?!1:t.localName==="a"?!0:r||i(t)||e(t,"fieldset","form","label","option")||t.localName==="graview-video"||t.hasAttribute("data-act")||t.hasAttribute("data-lightbox")||t.hasAttribute("data-drop")||t.hasAttribute("data-field")?!1:t.getAttribute("role")!=="group"}function m(t,r){if(t.localName==="a"||t.localName==="button")return!1;let s=t.getAttribute("data-record"),a=t.getAttribute("data-place");for(let o of r)if(o.localName==="a"&&(s!==null?o.getAttribute("data-record")===s:a!==null&&o.getAttribute("data-place")===a))return!0;return!1}function k(t,r,s){for(let a=t;a&&a!==r;a=a.parentElement){if(s(a))return a;if(g(a))return}}export{b as a,f as b,A as c,E as d,x as e,P as f,w as g,m as h,k as i};
1
+ var n="http://www.w3.org/1999/xhtml",u=new Set(["button","submit","reset","checkbox","radio","image"]),l=new Set(["button","checkbox","switch","tab","menuitem","menuitemcheckbox","menuitemradio","option","radio","slider","spinbutton","textbox","combobox","link"]),c=new Set(["div","span","section","article","aside","header","footer","figure","p","b","i","em","strong","small","mark","time","img"]),e=(t,...r)=>t.namespaceURI===n&&r.includes(t.localName),d=t=>(t.getAttribute("type")??"text").toLowerCase(),b=t=>e(t,"textarea","select")||e(t,"input")&&!u.has(d(t)),i=t=>e(t,"input","select","textarea");function f(t){return e(t,"button","summary")||e(t,"input")&&u.has(d(t))||t.localName==="a"&&t.hasAttribute("data-graview-link")}function p(t){if(e(t,"option","optgroup","datalist"))return'An option is never pressed by itself: put data-act on its select, with data-save="change", or on a button.';if(e(t,"label"))return"A press on a label presses its field too, and would ask for the act twice: put data-act on a button, or on the field.";if(b(t)&&!t.hasAttribute("data-save"))return'A click into a field to type or to pick is not a press: give it data-save ("input" or "change") to save it as it is typed, or put data-act on a button beside it.'}var g=t=>t.hasAttribute("data-act")&&p(t)===void 0&&!(i(t)&&t.hasAttribute("data-save")),h=new Set(["button","checkbox","switch","tab"]);function E(t,r=t.getAttribute("role")){return f(t)||i(t)||e(t,"label","option")||t.hasAttribute("data-graview-link")?!1:h.has(r??"")||t.hasAttribute("aria-pressed")||t.hasAttribute("aria-expanded")}function x(t){return e(t,"button","input","select","textarea","summary","iframe")||t.localName==="a"&&t.hasAttribute("href")?!0:t.hasAttribute("tabindex")||(t.getAttribute("contenteditable")??"false")!=="false"}var P=t=>!t.hasAttribute("role")&&(t.namespaceURI!==n||c.has(t.localName));function A(t){return e(t,"button","input","select","textarea","label","summary","option")||t.hasAttribute("data-act")||t.hasAttribute("data-lightbox")||t.hasAttribute("data-drop")||t.hasAttribute("data-file")||t.localName==="a"&&t.hasAttribute("href")&&!t.hasAttribute("data-record")&&!t.hasAttribute("data-place")?!0:l.has(t.getAttribute("role")??"")}function w(t,r){return!t.hasAttribute("data-record")&&!t.hasAttribute("data-place")?!1:t.localName==="a"?!0:r||i(t)||e(t,"fieldset","form","label","option")||t.localName==="graview-video"||t.hasAttribute("data-act")||t.hasAttribute("data-lightbox")||t.hasAttribute("data-drop")||t.hasAttribute("data-field")?!1:t.getAttribute("role")!=="group"}function k(t,r){if(t.localName==="a"||t.localName==="button")return!1;let s=t.getAttribute("data-record"),a=t.getAttribute("data-place");for(let o of r)if(o.localName==="a"&&(s!==null?o.getAttribute("data-record")===s:a!==null&&o.getAttribute("data-place")===a))return!0;return!1}function N(t,r,s){for(let a=t;a&&a!==r;a=a.parentElement){if(s(a))return a;if(A(a))return}}export{b as a,f as b,p as c,g as d,E as e,x as f,P as g,w as h,k as i,N as j};
@@ -1 +1 @@
1
- import{a as f}from"./chunk.5M34BJIQ.js";import{la as d}from"./chunk.J24YPQ5I.js";function S(e){let o=e.indexOf("{"),a=e.indexOf("["),t=a!==-1&&(o===-1||a<o)?a:o;if(t===-1)return;let n=e[t],r=n==="["?"]":"}",i=0,u=!1,l=!1;for(let s=t;s<e.length;s++){let c=e[s];if(u){l?l=!1:c==="\\"?l=!0:c==='"'&&(u=!1);continue}if(c==='"')u=!0;else if(c===n)i+=1;else if(c===r&&(i-=1,i===0))try{return JSON.parse(e.slice(t,s+1))}catch{return}}}function w(e,o){let a;try{a=e.mutation(o.mutation)}catch{return o}let t={...o.args},n=!1;for(let r of f(a.input)){if(r.control!=="node")continue;let i=t[r.name];if(typeof i!="string"||i.length===0||e.graph.getNode(i))continue;let u=i.trim().toLowerCase(),l=[...e.graph.allNodes()].filter(s=>(r.kinds.includes("*")||r.kinds.includes(s.kind))&&d(e.schema.tryDefinition(s.kind),s).trim().toLowerCase()===u);l.length===1&&(t[r.name]=l[0].id,n=!0)}return n?{...o,args:t}:o}function x(e,o,a){let t=a===void 0?null:new Set(a),n=[];for(let r of o){if(typeof r.mutation!="string")continue;let i=!0;try{e.mutation(r.mutation)}catch{i=!1}i?t&&!t.has(r.mutation)&&n.push({proposal:r,why:"not-allowed"}):n.push({proposal:r,why:"unknown"})}return n}function v(e,o,a){let t=a===void 0?null:new Set(a);return o.filter(n=>{if(typeof n.mutation!="string"||t&&!t.has(n.mutation))return!1;try{e.mutation(n.mutation)}catch{return!1}return n.args!==null&&typeof n.args=="object"})}export{S as a,w as b,x as c,v as d};
1
+ import{a as f}from"./chunk.H3EGBDW2.js";import{la as d}from"./chunk.ZEZUKRC6.js";function S(e){let o=e.indexOf("{"),a=e.indexOf("["),t=a!==-1&&(o===-1||a<o)?a:o;if(t===-1)return;let n=e[t],r=n==="["?"]":"}",i=0,u=!1,l=!1;for(let s=t;s<e.length;s++){let c=e[s];if(u){l?l=!1:c==="\\"?l=!0:c==='"'&&(u=!1);continue}if(c==='"')u=!0;else if(c===n)i+=1;else if(c===r&&(i-=1,i===0))try{return JSON.parse(e.slice(t,s+1))}catch{return}}}function w(e,o){let a;try{a=e.mutation(o.mutation)}catch{return o}let t={...o.args},n=!1;for(let r of f(a.input)){if(r.control!=="node")continue;let i=t[r.name];if(typeof i!="string"||i.length===0||e.graph.getNode(i))continue;let u=i.trim().toLowerCase(),l=[...e.graph.allNodes()].filter(s=>(r.kinds.includes("*")||r.kinds.includes(s.kind))&&d(e.schema.tryDefinition(s.kind),s).trim().toLowerCase()===u);l.length===1&&(t[r.name]=l[0].id,n=!0)}return n?{...o,args:t}:o}function x(e,o,a){let t=a===void 0?null:new Set(a),n=[];for(let r of o){if(typeof r.mutation!="string")continue;let i=!0;try{e.mutation(r.mutation)}catch{i=!1}i?t&&!t.has(r.mutation)&&n.push({proposal:r,why:"not-allowed"}):n.push({proposal:r,why:"unknown"})}return n}function v(e,o,a){let t=a===void 0?null:new Set(a);return o.filter(n=>{if(typeof n.mutation!="string"||t&&!t.has(n.mutation))return!1;try{e.mutation(n.mutation)}catch{return!1}return n.args!==null&&typeof n.args=="object"})}export{S as a,w as b,x as c,v as d};
@@ -1 +1 @@
1
- import{b as X}from"./chunk.QO5RXOCS.js";import"./chunk.MD36ZSM5.js";import"./chunk.L6FGKJ5H.js";import{G as ce,V as Y,da as N,ga as _}from"./chunk.3CJLAJXP.js";import"./chunk.SDO3U72B.js";import{Eb as R,ue as U}from"./chunk.J24YPQ5I.js";import"./chunk.FQLNBIQ5.js";import{b as O}from"./chunk.AJZBJBMO.js";var u=O(ce(),1);function M(e,t,s=!1){if(e<t.at||e===t.at&&s)return e;let i=t.at+t.removed.length;return e>=i?e+t.inserted.length-t.removed.length:s?t.at:t.at+t.inserted.length}var G=e=>e>=55296&&e<=56319,V=e=>e>=56320&&e<=57343;function q(e,t,s){let i=Math.min(e.length,t.length),n=0,l=Math.max(0,Math.min(i,t.length-s));for(;n<l&&e.charCodeAt(e.length-1-n)===t.charCodeAt(t.length-1-n);)n++;let r=0;for(;r<i-n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;return r>0&&G(e.charCodeAt(r-1))&&r--,n>0&&V(e.charCodeAt(e.length-n))&&n--,{at:r,removed:e.slice(r,e.length-n),inserted:t.slice(r,t.length-n)}}function B(e,t){let s=Math.min(e.length,t.length),i=0;for(;i<s&&e.charCodeAt(i)===t.charCodeAt(i);)i++;i>0&&G(e.charCodeAt(i-1))&&i--;let n=0;for(;n<s-i&&e.charCodeAt(e.length-1-n)===t.charCodeAt(t.length-1-n);)n++;return n>0&&V(e.charCodeAt(e.length-n))&&n--,{at:i,removed:e.slice(i,e.length-n),inserted:t.slice(i,t.length-n)}}function Z(e,t){let s=c=>c.at+c.removed.length;if(s(e)<t.at)return e;if(e.at>s(t))return{...e,at:e.at+t.inserted.length-t.removed.length};let i=Math.min(e.at,t.at),n=s(e)-s(t),l=e.removed.slice(0,t.at-i)+t.inserted+(n>0?e.removed.slice(e.removed.length-n):""),r=t.at<=e.at?t.inserted+e.inserted:e.inserted+t.inserted,d=B(l,r);return{...d,at:i+d.at}}function I(e,t){let s=M(e.start,t,!0),i=e.end===e.start?s:M(e.end,t);return{start:s,end:Math.max(s,i)}}function le(e,t){let{kind:s,id:i,session:n}=e.author,l=`${s}:${i??""}:`;return t.startsWith(l)&&(!n||t.slice(l.length)===n)}function J(e,t,s,i){let n=e.anchor,l=e.head;for(let d of s)if(!(d.seq<e.rev||le(d,t)))for(let c of d.primitives)c.op!=="splice-text"||c.id!==e.node||c.field!==e.field||(n=M(n,c),l=M(l,c));let r=d=>Math.max(0,Math.min(i,d));return{start:r(n),end:r(l)}}var W=(e,t,s)=>e.ops.length>0&&e.ops.every(i=>{let n=i.mutation?.args;return i.mutation?.name===R&&n?.node===t&&n.field===s}),de=(e,t,s,i)=>t.ops.length>0&&t.ops.every(n=>n.undoes!==void 0)&&e.batches().some(n=>t.ops.some(l=>l.undoes===n.id||l.undoes===n.ops[0]?.id)&&W(n,s,i)),Q=(e,t)=>e.author.kind==="human"&&(t?.id===void 0||e.author.id===void 0||e.author.id===t.id);function j(e,t,s,i){let n=e.batches();for(let l=n.length-1;l>=0;l--){let r=n[l];if(!(!Q(r,t)||r.undone||!W(r,s,i))&&e.canUndo(r.id).ok)return r.id}}function ee(e,t,s,i){let n=e.batches();for(let l=n.length-1;l>=0;l--){let r=n[l];if(Q(r,t)){if(W(r,s,i))return;if(de(e,r,s,i))return r.undone?void 0:r.id}}}var p=O(Y(),1);function ue(e){let{store:t}=N(),{live:s,nodeId:i,field:n}=e,[l,r]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let d=!0;return s.typing(i,n).then(c=>d&&r(c)),()=>{d=!1}},[i,n]),l&&!t.collaborative(i,n)?(0,p.jsx)(p.Fragment,{children:e.writtenWhole}):(0,p.jsx)(pe,{...e,typing:l})}function pe({nodeId:e,field:t,label:s,markdown:i,live:n,onDone:l,typing:r}){let{store:d,principal:c}=N(),m=_(e),f=ne(m?.[t]),[T,ie]=(0,u.useState)(!1),v=(0,u.useRef)(null),D=(0,u.useRef)(f),E=(0,u.useRef)(!1),H=(0,u.useRef)(n);H.current=n;let K=()=>ne(d.graph.getNode(e)?.[t]),b=!r||d.permits({name:R,args:{node:e,field:t,at:0,remove:0,insert:""}},c).ok;(0,u.useEffect)(()=>v.current?.focus(),[T,r]);let C=(0,u.useRef)(void 0),k=()=>{C.current===void 0&&(C.current=setTimeout(()=>{C.current=void 0;let o=v.current;if(!o||o.ownerDocument.activeElement!==o)return;let a=o.selectionDirection==="backward";H.current.sayCaret({node:e,field:t,anchor:a?o.selectionEnd:o.selectionStart,head:a?o.selectionStart:o.selectionEnd,rev:d.log.length})},ge))};(0,u.useEffect)(()=>()=>{clearTimeout(C.current),H.current.sayCaret(null)},[]);let F=o=>{let a=v.current;if(a){if(a.value!==o){let h=I({start:a.selectionStart,end:a.selectionEnd},B(a.value,o)),g=a.selectionDirection??"none";a.value=o,a.setSelectionRange(h.start,h.end,g)}D.current=o}},$=()=>{let o=v.current;if(!o||!r||!b||E.current)return;let a=D.current,h=K(),g=q(a,o.value,o.selectionEnd);if(g.removed===""&&g.inserted==="")return F(h);let y=a===h?g:Z(g,B(a,h));try{r.splice(y.at,y.removed.length,y.inserted)}catch{}let w=K();if(o.value!==w){o.value=w;let S=Math.min(w.length,y.at+y.inserted.length);o.setSelectionRange(S,S)}D.current=w,k()};(0,u.useLayoutEffect)(()=>{E.current||F(f)},[f]);let ae=async o=>{if(!r)return;r.flush();for(let h=0;r.waiting()>0&&h<100;h++)await new Promise(g=>setTimeout(g,30));let a=o?ee(d,c,e,t):j(d,c,e,t);if(a)try{o?d.redo(a,{author:c}):d.undo(a,{author:c})}catch{}},x=o=>{r?.flush(),n.sayCaret(null),l(o)},A=(0,u.useRef)(void 0);(0,u.useEffect)(()=>()=>A.current?.(),[]);let se=o=>{A.current?.();let a=o.ownerDocument,h=v.current?.closest("[data-graview-live]"),g=P=>{let L=P.target;if(L instanceof Node&&h?.contains(L))return S();L instanceof Element&&L.closest(te)||(S(),x(!0))},y=()=>{let P=a.activeElement;P!==null&&P!==a.body||o.isConnected&&fe(o)||(S(),v.current?.focus({preventScroll:!0}))},w=new MutationObserver(y);w.observe(a.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["open","hidden"]}),a.addEventListener("focusin",g),a.addEventListener("toggle",y,!0);let S=()=>{A.current=void 0,w.disconnect(),a.removeEventListener("focusin",g),a.removeEventListener("toggle",y,!0)};A.current=S},z=[...n.who.values()].filter(o=>o.caret?.node===e&&o.caret.field===t);return(0,p.jsxs)("div",{style:{display:"grid",gap:8,minWidth:0},"data-graview-live":t,children:[T?(0,p.jsx)("div",{"data-graview-preview":t,"aria-label":`${s}, as it will read`,role:"region",style:ye,children:(0,p.jsx)(X,{text:f,markdown:!0})}):(0,p.jsxs)("div",{style:{position:"relative",minWidth:0},children:[(0,p.jsx)("textarea",{ref:v,"aria-label":s,"data-graview-field":t,defaultValue:f,readOnly:!r||!b,rows:3,onInput:$,onCompositionStart:()=>{E.current=!0},onCompositionEnd:()=>{E.current=!1,$()},onSelect:k,onFocus:k,onPointerDown:()=>r?.flush(),onKeyDown:o=>{let a=o.key;a==="Escape"?(o.preventDefault(),x(!1)):(o.metaKey||o.ctrlKey)&&!o.altKey&&a.toLowerCase()==="z"?(o.preventDefault(),ae(o.shiftKey)):(o.metaKey||o.ctrlKey)&&a==="Enter"?(o.preventDefault(),x(!1)):(a==="Enter"||me.has(a))&&r?.flush()},onKeyUp:k,onBlur:o=>{r?.flush(),n.sayCaret(null);let a=o.relatedTarget;if(a instanceof Node&&o.currentTarget.closest("[data-graview-live]")?.contains(a))return;let h=a instanceof Element?a.closest(te):null;if(h)return se(h);x(!0)},style:ve}),z.length>0?(0,p.jsx)(he,{text:f,others:z,area:v,log:d.log.all()}):null]}),(0,p.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:8},children:[(0,p.jsx)("button",{type:"button",onClick:()=>x(!1),style:re,children:"Done"}),i?(0,p.jsx)("button",{type:"button","aria-pressed":T,onClick:()=>ie(!T),style:re,children:T?"Write":"Preview"}):null,(0,p.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)"},...b?{}:{"data-graview-readonly":""},children:b?"Saved as you type \xB7 Ctrl or \u2318 Z takes back your typing":`Read only: the ${s.toLowerCase()} can't be changed here now`})]})]})}function he({text:e,others:t,area:s,log:i}){let n=(0,u.useRef)(null);(0,u.useLayoutEffect)(()=>{let c=s.current,m=n.current;if(!c||!m)return;let f=()=>{m.scrollTop=c.scrollTop};return f(),c.addEventListener("scroll",f),()=>c.removeEventListener("scroll",f)});let l=t.map(c=>({one:c,at:J(c.caret,c.participant,i,e.length).end})).sort((c,m)=>c.at-m.at),r=[],d=0;for(let{one:c,at:m}of l){r.push(e.slice(d,m)),d=m;let f=U(c)||"Somebody";r.push((0,p.jsx)("span",{"data-graview-caret":c.participant,title:`${f} is typing here`,style:{borderLeft:`2px solid hsl(${Math.round(c.hue)} 55% 52%)`,marginLeft:-1,marginRight:-1,pointerEvents:"auto"}},c.participant))}return r.push(`${e.slice(d)}\u200B`),(0,p.jsx)("div",{ref:n,"aria-hidden":"true",style:we,children:r})}var te='[data-graview-overlay], dialog, [role="dialog"], [role="alertdialog"], [popover]',fe=e=>{if(e.hasAttribute("hidden")||e instanceof HTMLDialogElement&&!e.open)return!1;if(e.hasAttribute("popover"))try{return e.matches(":popover-open")}catch{}return!0},ge=120,ne=e=>typeof e=="string"?e:"",me=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]),ye={minHeight:"7.5em",padding:"8px 10px",border:"1px dashed var(--graview-edge-bright)",borderRadius:6,lineHeight:1.6,minWidth:0},re={font:"inherit",fontSize:"0.8125rem",minHeight:28,padding:"2px 12px"},oe={font:"inherit",lineHeight:1.5,width:"100%",boxSizing:"border-box",minHeight:"7.5em",padding:"8px 10px",borderRadius:6},ve={...oe,resize:"vertical",fieldSizing:"content",color:"var(--graview-ink)",background:"var(--graview-panel, transparent)",border:"1px solid var(--graview-edge-bright)"},we={...oe,position:"absolute",inset:0,height:"100%",border:"1px solid transparent",color:"transparent",whiteSpace:"pre-wrap",overflowWrap:"break-word",overflow:"hidden",pointerEvents:"none"};export{ue as default};
1
+ import{b as X}from"./chunk.Z27NSSYL.js";import"./chunk.QNP5OR3P.js";import"./chunk.4W57E7AX.js";import{G as ce,W as Y,ea as N,ha as _}from"./chunk.A5PSEU3W.js";import"./chunk.SDO3U72B.js";import{Fb as R,ye as U}from"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import{b as O}from"./chunk.AJZBJBMO.js";var u=O(ce(),1);function M(e,t,s=!1){if(e<t.at||e===t.at&&s)return e;let i=t.at+t.removed.length;return e>=i?e+t.inserted.length-t.removed.length:s?t.at:t.at+t.inserted.length}var G=e=>e>=55296&&e<=56319,V=e=>e>=56320&&e<=57343;function q(e,t,s){let i=Math.min(e.length,t.length),n=0,l=Math.max(0,Math.min(i,t.length-s));for(;n<l&&e.charCodeAt(e.length-1-n)===t.charCodeAt(t.length-1-n);)n++;let r=0;for(;r<i-n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;return r>0&&G(e.charCodeAt(r-1))&&r--,n>0&&V(e.charCodeAt(e.length-n))&&n--,{at:r,removed:e.slice(r,e.length-n),inserted:t.slice(r,t.length-n)}}function B(e,t){let s=Math.min(e.length,t.length),i=0;for(;i<s&&e.charCodeAt(i)===t.charCodeAt(i);)i++;i>0&&G(e.charCodeAt(i-1))&&i--;let n=0;for(;n<s-i&&e.charCodeAt(e.length-1-n)===t.charCodeAt(t.length-1-n);)n++;return n>0&&V(e.charCodeAt(e.length-n))&&n--,{at:i,removed:e.slice(i,e.length-n),inserted:t.slice(i,t.length-n)}}function Z(e,t){let s=c=>c.at+c.removed.length;if(s(e)<t.at)return e;if(e.at>s(t))return{...e,at:e.at+t.inserted.length-t.removed.length};let i=Math.min(e.at,t.at),n=s(e)-s(t),l=e.removed.slice(0,t.at-i)+t.inserted+(n>0?e.removed.slice(e.removed.length-n):""),r=t.at<=e.at?t.inserted+e.inserted:e.inserted+t.inserted,d=B(l,r);return{...d,at:i+d.at}}function I(e,t){let s=M(e.start,t,!0),i=e.end===e.start?s:M(e.end,t);return{start:s,end:Math.max(s,i)}}function le(e,t){let{kind:s,id:i,session:n}=e.author,l=`${s}:${i??""}:`;return t.startsWith(l)&&(!n||t.slice(l.length)===n)}function J(e,t,s,i){let n=e.anchor,l=e.head;for(let d of s)if(!(d.seq<e.rev||le(d,t)))for(let c of d.primitives)c.op!=="splice-text"||c.id!==e.node||c.field!==e.field||(n=M(n,c),l=M(l,c));let r=d=>Math.max(0,Math.min(i,d));return{start:r(n),end:r(l)}}var W=(e,t,s)=>e.ops.length>0&&e.ops.every(i=>{let n=i.mutation?.args;return i.mutation?.name===R&&n?.node===t&&n.field===s}),de=(e,t,s,i)=>t.ops.length>0&&t.ops.every(n=>n.undoes!==void 0)&&e.batches().some(n=>t.ops.some(l=>l.undoes===n.id||l.undoes===n.ops[0]?.id)&&W(n,s,i)),Q=(e,t)=>e.author.kind==="human"&&(t?.id===void 0||e.author.id===void 0||e.author.id===t.id);function j(e,t,s,i){let n=e.batches();for(let l=n.length-1;l>=0;l--){let r=n[l];if(!(!Q(r,t)||r.undone||!W(r,s,i))&&e.canUndo(r.id).ok)return r.id}}function ee(e,t,s,i){let n=e.batches();for(let l=n.length-1;l>=0;l--){let r=n[l];if(Q(r,t)){if(W(r,s,i))return;if(de(e,r,s,i))return r.undone?void 0:r.id}}}var p=O(Y(),1);function ue(e){let{store:t}=N(),{live:s,nodeId:i,field:n}=e,[l,r]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let d=!0;return s.typing(i,n).then(c=>d&&r(c)),()=>{d=!1}},[i,n]),l&&!t.collaborative(i,n)?(0,p.jsx)(p.Fragment,{children:e.writtenWhole}):(0,p.jsx)(pe,{...e,typing:l})}function pe({nodeId:e,field:t,label:s,markdown:i,live:n,onDone:l,typing:r}){let{store:d,principal:c}=N(),m=_(e),f=ne(m?.[t]),[T,ie]=(0,u.useState)(!1),v=(0,u.useRef)(null),D=(0,u.useRef)(f),E=(0,u.useRef)(!1),H=(0,u.useRef)(n);H.current=n;let K=()=>ne(d.graph.getNode(e)?.[t]),b=!r||d.permits({name:R,args:{node:e,field:t,at:0,remove:0,insert:""}},c).ok;(0,u.useEffect)(()=>v.current?.focus(),[T,r]);let C=(0,u.useRef)(void 0),k=()=>{C.current===void 0&&(C.current=setTimeout(()=>{C.current=void 0;let o=v.current;if(!o||o.ownerDocument.activeElement!==o)return;let a=o.selectionDirection==="backward";H.current.sayCaret({node:e,field:t,anchor:a?o.selectionEnd:o.selectionStart,head:a?o.selectionStart:o.selectionEnd,rev:d.log.length})},ge))};(0,u.useEffect)(()=>()=>{clearTimeout(C.current),H.current.sayCaret(null)},[]);let F=o=>{let a=v.current;if(a){if(a.value!==o){let h=I({start:a.selectionStart,end:a.selectionEnd},B(a.value,o)),g=a.selectionDirection??"none";a.value=o,a.setSelectionRange(h.start,h.end,g)}D.current=o}},$=()=>{let o=v.current;if(!o||!r||!b||E.current)return;let a=D.current,h=K(),g=q(a,o.value,o.selectionEnd);if(g.removed===""&&g.inserted==="")return F(h);let y=a===h?g:Z(g,B(a,h));try{r.splice(y.at,y.removed.length,y.inserted)}catch{}let w=K();if(o.value!==w){o.value=w;let S=Math.min(w.length,y.at+y.inserted.length);o.setSelectionRange(S,S)}D.current=w,k()};(0,u.useLayoutEffect)(()=>{E.current||F(f)},[f]);let ae=async o=>{if(!r)return;r.flush();for(let h=0;r.waiting()>0&&h<100;h++)await new Promise(g=>setTimeout(g,30));let a=o?ee(d,c,e,t):j(d,c,e,t);if(a)try{o?d.redo(a,{author:c}):d.undo(a,{author:c})}catch{}},x=o=>{r?.flush(),n.sayCaret(null),l(o)},A=(0,u.useRef)(void 0);(0,u.useEffect)(()=>()=>A.current?.(),[]);let se=o=>{A.current?.();let a=o.ownerDocument,h=v.current?.closest("[data-graview-live]"),g=P=>{let L=P.target;if(L instanceof Node&&h?.contains(L))return S();L instanceof Element&&L.closest(te)||(S(),x(!0))},y=()=>{let P=a.activeElement;P!==null&&P!==a.body||o.isConnected&&fe(o)||(S(),v.current?.focus({preventScroll:!0}))},w=new MutationObserver(y);w.observe(a.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["open","hidden"]}),a.addEventListener("focusin",g),a.addEventListener("toggle",y,!0);let S=()=>{A.current=void 0,w.disconnect(),a.removeEventListener("focusin",g),a.removeEventListener("toggle",y,!0)};A.current=S},z=[...n.who.values()].filter(o=>o.caret?.node===e&&o.caret.field===t);return(0,p.jsxs)("div",{style:{display:"grid",gap:8,minWidth:0},"data-graview-live":t,children:[T?(0,p.jsx)("div",{"data-graview-preview":t,"aria-label":`${s}, as it will read`,role:"region",style:ye,children:(0,p.jsx)(X,{text:f,markdown:!0})}):(0,p.jsxs)("div",{style:{position:"relative",minWidth:0},children:[(0,p.jsx)("textarea",{ref:v,"aria-label":s,"data-graview-field":t,defaultValue:f,readOnly:!r||!b,rows:3,onInput:$,onCompositionStart:()=>{E.current=!0},onCompositionEnd:()=>{E.current=!1,$()},onSelect:k,onFocus:k,onPointerDown:()=>r?.flush(),onKeyDown:o=>{let a=o.key;a==="Escape"?(o.preventDefault(),x(!1)):(o.metaKey||o.ctrlKey)&&!o.altKey&&a.toLowerCase()==="z"?(o.preventDefault(),ae(o.shiftKey)):(o.metaKey||o.ctrlKey)&&a==="Enter"?(o.preventDefault(),x(!1)):(a==="Enter"||me.has(a))&&r?.flush()},onKeyUp:k,onBlur:o=>{r?.flush(),n.sayCaret(null);let a=o.relatedTarget;if(a instanceof Node&&o.currentTarget.closest("[data-graview-live]")?.contains(a))return;let h=a instanceof Element?a.closest(te):null;if(h)return se(h);x(!0)},style:ve}),z.length>0?(0,p.jsx)(he,{text:f,others:z,area:v,log:d.log.all()}):null]}),(0,p.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:8},children:[(0,p.jsx)("button",{type:"button",onClick:()=>x(!1),style:re,children:"Done"}),i?(0,p.jsx)("button",{type:"button","aria-pressed":T,onClick:()=>ie(!T),style:re,children:T?"Write":"Preview"}):null,(0,p.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)"},...b?{}:{"data-graview-readonly":""},children:b?"Saved as you type \xB7 Ctrl or \u2318 Z takes back your typing":`Read only: the ${s.toLowerCase()} can't be changed here now`})]})]})}function he({text:e,others:t,area:s,log:i}){let n=(0,u.useRef)(null);(0,u.useLayoutEffect)(()=>{let c=s.current,m=n.current;if(!c||!m)return;let f=()=>{m.scrollTop=c.scrollTop};return f(),c.addEventListener("scroll",f),()=>c.removeEventListener("scroll",f)});let l=t.map(c=>({one:c,at:J(c.caret,c.participant,i,e.length).end})).sort((c,m)=>c.at-m.at),r=[],d=0;for(let{one:c,at:m}of l){r.push(e.slice(d,m)),d=m;let f=U(c)||"Somebody";r.push((0,p.jsx)("span",{"data-graview-caret":c.participant,title:`${f} is typing here`,style:{borderLeft:`2px solid hsl(${Math.round(c.hue)} 55% 52%)`,marginLeft:-1,marginRight:-1,pointerEvents:"auto"}},c.participant))}return r.push(`${e.slice(d)}\u200B`),(0,p.jsx)("div",{ref:n,"aria-hidden":"true",style:we,children:r})}var te='[data-graview-overlay], dialog, [role="dialog"], [role="alertdialog"], [popover]',fe=e=>{if(e.hasAttribute("hidden")||e instanceof HTMLDialogElement&&!e.open)return!1;if(e.hasAttribute("popover"))try{return e.matches(":popover-open")}catch{}return!0},ge=120,ne=e=>typeof e=="string"?e:"",me=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]),ye={minHeight:"7.5em",padding:"8px 10px",border:"1px dashed var(--graview-edge-bright)",borderRadius:6,lineHeight:1.6,minWidth:0},re={font:"inherit",fontSize:"0.8125rem",minHeight:28,padding:"2px 12px"},oe={font:"inherit",lineHeight:1.5,width:"100%",boxSizing:"border-box",minHeight:"7.5em",padding:"8px 10px",borderRadius:6},ve={...oe,resize:"vertical",fieldSizing:"content",color:"var(--graview-ink)",background:"var(--graview-panel, transparent)",border:"1px solid var(--graview-edge-bright)"},we={...oe,position:"absolute",inset:0,height:"100%",border:"1px solid transparent",color:"transparent",whiteSpace:"pre-wrap",overflowWrap:"break-word",overflow:"hidden",pointerEvents:"none"};export{ue as default};
@@ -1 +1 @@
1
- import{c as m}from"./chunk.ZMWAZACO.js";import{ga as c,la as u,ma as p,oa as f,sa as h,ta as l}from"./chunk.J24YPQ5I.js";function M(t,e){let n=t.schema.kinds,r="kind"in e?e.kind:void 0;if(r!==void 0&&!n.includes(r))return`There is no kind "${r}" in this app. Its kinds are: ${n.join(", ")}.`;if(e.on==="act"&&e.act!==void 0&&t.allMutations&&!t.allMutations().some(i=>i.name===e.act))return`There is no act "${e.act}" in this app.`;let o="record"in e?e.record:void 0;if(o!==void 0&&t.graph&&!t.graph.getNode(o))return`No record "${o}" is here to be told about.`;if(o!==void 0&&r!==void 0&&t.graph&&t.graph.getNode(o)?.kind!==r)return`\u201C${o}\u201D is not ${h(r)}.`;if(e.on==="changed"&&e.kind===void 0&&e.record===void 0)return"Say which kind, or which record, to be told about.";if(e.on==="reaches"){if(e.condition.trim()==="")return"Say what it should reach: a condition like done == true.";try{m(e.condition)}catch(i){return`The condition does not read: ${i instanceof Error?i.message:String(i)}.`}}}function d(t,e){let n=t.graph?.getNode(e);return n?u(t.schema.tryDefinition(n.kind),n):e}function g(t,e){let n=t.allMutations?.().find(r=>r.name===e);return n?p(n):c(e)}function v(t,e){let{when:n}=e,r=e.alsoMine?"anyone":"someone else",o=s=>l(t.schema.tryDefinition(s),s),i=s=>{let a=o(s);return`${/^[aeiou]/i.test(a)?"an":"a"} ${a}`};switch(n.on){case"act":{let s=n.act!==void 0?`\u201C${g(t,n.act)}\u201D`:"an act";return`When ${r} runs ${s}${n.record!==void 0?` on \u201C${d(t,n.record)}\u201D`:""}`}case"created":return`When ${r} adds ${i(n.kind)}`;case"changed":return n.record!==void 0?`When ${r} changes \u201C${d(t,n.record)}\u201D`:`When ${r} changes any of the ${f(t.schema,n.kind)}`;case"reaches":return`When ${n.record!==void 0?`\u201C${d(t,n.record)}\u201D`:i(n.kind)} reaches ${n.condition}${e.alsoMine?"":" (by someone else)"}`}}export{M as a,v as b};
1
+ import{c as m}from"./chunk.UGQYMN4J.js";import{ga as c,la as u,ma as p,oa as f,ta as h,ua as l}from"./chunk.ZEZUKRC6.js";function M(t,e){let n=t.schema.kinds,r="kind"in e?e.kind:void 0;if(r!==void 0&&!n.includes(r))return`There is no kind "${r}" in this app. Its kinds are: ${n.join(", ")}.`;if(e.on==="act"&&e.act!==void 0&&t.allMutations&&!t.allMutations().some(i=>i.name===e.act))return`There is no act "${e.act}" in this app.`;let o="record"in e?e.record:void 0;if(o!==void 0&&t.graph&&!t.graph.getNode(o))return`No record "${o}" is here to be told about.`;if(o!==void 0&&r!==void 0&&t.graph&&t.graph.getNode(o)?.kind!==r)return`\u201C${o}\u201D is not ${h(r)}.`;if(e.on==="changed"&&e.kind===void 0&&e.record===void 0)return"Say which kind, or which record, to be told about.";if(e.on==="reaches"){if(e.condition.trim()==="")return"Say what it should reach: a condition like done == true.";try{m(e.condition)}catch(i){return`The condition does not read: ${i instanceof Error?i.message:String(i)}.`}}}function d(t,e){let n=t.graph?.getNode(e);return n?u(t.schema.tryDefinition(n.kind),n):e}function g(t,e){let n=t.allMutations?.().find(r=>r.name===e);return n?p(n):c(e)}function v(t,e){let{when:n}=e,r=e.alsoMine?"anyone":"someone else",o=s=>l(t.schema.tryDefinition(s),s),i=s=>{let a=o(s);return`${/^[aeiou]/i.test(a)?"an":"a"} ${a}`};switch(n.on){case"act":{let s=n.act!==void 0?`\u201C${g(t,n.act)}\u201D`:"an act";return`When ${r} runs ${s}${n.record!==void 0?` on \u201C${d(t,n.record)}\u201D`:""}`}case"created":return`When ${r} adds ${i(n.kind)}`;case"changed":return n.record!==void 0?`When ${r} changes \u201C${d(t,n.record)}\u201D`:`When ${r} changes any of the ${f(t.schema,n.kind)}`;case"reaches":return`When ${n.record!==void 0?`\u201C${d(t,n.record)}\u201D`:i(n.kind)} reaches ${n.condition}${e.alsoMine?"":" (by someone else)"}`}}export{M as a,v as b};
@@ -1 +1 @@
1
- import{b as cn,c as un}from"./chunk.2YMO7ZVX.js";import{j as x}from"./chunk.FOSY7MZF.js";import{b as Z}from"./chunk.NBVPWLRY.js";import{Ac as Q,Gd as dn,Mc as U,dc as on,ec as E,fb as V,ga as H,la as T,ma as K,mc as rn,na as en,nc as an,oa as tn,ra as sn,sa as J,ta as G}from"./chunk.J24YPQ5I.js";function fn(){return{name:"insight",derive({store:n,nodes:d,kindSelection:t}){let f=[],v=l=>T(n.schema.tryDefinition(l.kind),l);for(let l of d){if([...n.schema.edgeKinds].reduce((c,w)=>c+n.graph.out(l.id,w).length+n.graph.in(l.id,w).length,0)===0){f.push({id:`insight:island:${l.id}`,text:`${v(l)} is connected to nothing yet`,nodeIds:[l.id]});continue}for(let c of n.schema.edgeKinds){let w=n.graph.in(l.id,c).length;if(w<3)continue;let s=[...n.graph.allEdges()].filter(a=>a.kind===c),e=s.length;e>=4&&w/e>.6&&f.push({id:`insight:load:${l.id}:${c}`,text:`${v(l)} ${vn(n,s,c,w)}`,nodeIds:[l.id]})}}for(let l of t){if(n.graph.nodesOfKind(l).length>0)continue;let A=n.schema.definitions.filter(c=>c.kind!==l).filter(c=>Object.values(c.edges).some(w=>w.to!=="*"&&w.to.includes(l))).map(c=>c.plural??`${c.kind}s`);A.length>0&&f.push({id:`insight:gap:${l}`,text:`Nothing here yet, though ${A.join(" and ")} expect to connect to these`,nodeIds:[]})}return{observations:f}}}}function vn(n,d,t,f){let v=new Set(d.map(s=>n.graph.getNode(s.from)?.kind).filter(s=>s!==void 0)),l=v.size===1?[...v][0]:void 0,A=d.length,c=Z(n.schema,l??[...v][0]??"",t,"in"),w=s=>l?en(n.schema,l,s):String(s);return f===A?`${c}: all ${w(f)}`:`${c}: ${f} of the ${w(A)}`}function ln(n){let d=new Map;if(n.length===0)return d;let t=n.slice(-512),f=new Set;for(let l of t)l.undoes&&f.add(l.undoes);let v=n[n.length-1].seq;for(let l of t){if(!l.mutation||f.has(l.id))continue;let A=Math.pow(.5,(v-l.seq)/64);d.set(l.mutation.name,(d.get(l.mutation.name)??0)+A)}return d}function hn(n){return 8*(n/(n+1))}var bn=100;function gn(){return{name:"invariant",derive({store:n,selection:d,nodes:t,violations:f}){let v=s=>T(n.schema.tryDefinition(s.kind),s),l=new Set(d),A=f.filter(s=>s.nodeIds.some(e=>l.has(e))||s.subjectId!==void 0&&l.has(s.subjectId)),c=[],w=[];A.forEach((s,e)=>{w.push({id:`violation:${s.invariant}:${e}`,text:s.message,nodeIds:s.nodeIds}),s.repairs.forEach((a,h)=>{c.push({id:`invariant:${s.invariant}:${e}:${h}`,label:a.label,provider:"invariant",mutation:a.mutation,args:a.args??{},open:(a.missing??[]).map(m=>{let r=n.allMutations().find(g=>g.name===a.mutation);if(!r)return{name:m};let o=E(r.input).find(g=>g.name===m),k=o?o.kinds.includes("*")?n.graph.allNodes().map(g=>g.id):o.kinds.flatMap(g=>n.graph.nodesOfKind(g).map($=>$.id)):void 0;return{name:m,shape:x(r.input,m),...o?{kinds:o.kinds}:{},...k?{candidates:k}:{}}}),score:bn-h-(a.missing?.length??0),why:s.message,nodeIds:s.nodeIds,...s.subjectId===void 0?{}:{subjectId:s.subjectId}})})});for(let s of t){let e=n.allInvariants().filter(a=>{if(a.scope==="graph")return!1;let h=a.scope;return h.kind!==s.kind?!1:h.match?h.match(s):!0});e.length!==0&&(A.some(a=>a.subjectId===s.id||a.nodeIds.includes(s.id))||w.push({id:`holds:${s.id}`,text:`${v(s)} holds \u2014 nothing currently breaks ${e.length===1?"it":`any of its ${e.length} rules`}`,nodeIds:[s.id]}))}return{affordances:c,observations:w}}}}var X=40;function pn(){return{name:"schema",derive({store:n,selection:d,nodes:t,kindSelection:f,edgeSelection:v,principal:l}){let A=(e,a)=>l!==void 0&&!n.permits({name:e,args:a},l).ok,c=[];if(t.length===0&&v.length>0){for(let e of v){let a=n.graph.getNode(e.from),h=n.graph.getNode(e.to);if(!a||!h)continue;let m=un(n,e);m?.provisional&&c.push({id:`schema:edge:${Q}:${e.kind}:${e.from}:${e.to}`,label:"Keep this link",provider:"schema",mutation:Q,args:{kind:e.kind,from:e.from,to:e.to},open:[],score:64,why:cn(m),nodeIds:[e.from,e.to]});for(let r of n.allMutations()){let o=(r.connects??[]).includes(e.kind),k=(r.severs??[]).includes(e.kind);if(!o&&!k||r.derived?.relation!==void 0&&r.derived.kind!==a.kind)continue;let g={},$=[],j=E(r.input);for(let p of j){let S=p.kinds.includes("*")||p.kinds.includes(a.kind),P=p.kinds.includes("*")||p.kinds.includes(h.kind),y=S&&!j.some(I=>I!==p&&(I.kinds.includes(a.kind)||I.kinds.includes("*")));S&&!P?g[p.name]=e.from:P&&!S?g[p.name]=e.to:S&&P&&y?g[p.name]=e.from:$.push({name:p.name,kinds:p.kinds,candidates:[e.from,e.to],shape:x(r.input,p.name)})}for(let p of q(r.input,""))p in g||$.some(S=>S.name===p)||$.push({name:p,shape:x(r.input,p)});$.every(p=>p.optional===!0?!0:p.kinds!==void 0?(p.candidates?.length??0)>0:(p.candidates?.length??0)>0||p.shape!==void 0&&p.shape.type!=="unknown")&&(o&&!k&&$.length===0||c.push({id:`schema:edge:${r.name}:${e.kind}:${e.from}:${e.to}`,label:K(r),provider:"schema",mutation:r.name,args:g,open:$,...r.destructive?{destructive:!0}:{},score:(k?62:58)-$.length,why:`this line is "${Z(n.schema,n.graph.getNode(e.from)?.kind??"",e.kind,"out")}"`,nodeIds:[e.from,e.to]}))}}return{affordances:c}}if(t.length===0&&f.length>0){let e=new Set(f),a=[];for(let h of n.allMutations()){if(!(h.creates??[]).some(o=>e.has(o)))continue;let m=[];for(let o of E(h.input)){let k=o.kinds.includes("*")?n.graph.allNodes().map(g=>g.id):o.kinds.flatMap(g=>n.graph.nodesOfKind(g).map($=>$.id));m.push({name:o.name,kinds:o.kinds,candidates:k,shape:x(h.input,o.name),...o.optional?{optional:!0}:{}})}for(let o of q(h.input,""))m.some(k=>k.name===o)||m.push({name:o,shape:x(h.input,o)});if(!m.every(o=>o.optional===!0?!0:o.kinds!==void 0?(o.candidates?.length??0)>0:(o.candidates?.length??0)>0||o.shape!==void 0&&o.shape.type!=="unknown")&&!A(h.name,{})){let o=m.filter(k=>k.optional!==!0&&k.kinds!==void 0&&!k.kinds.includes("*")&&(k.candidates?.length??0)===0);if(o.length>0){let k=[...new Set(o.flatMap(g=>g.kinds??[]))].map(g=>J(G(n.schema.tryDefinition(g),g)));a.push({id:`schema:waits:${h.name}`,text:`"${h.title??h.name}" cannot begin until there is ${k.length===1?k[0]:`${k.slice(0,-1).join(", ")} and ${k[k.length-1]}`}.`,nodeIds:[]})}continue}c.push({id:`schema:add:${h.name}`,label:K(h),provider:"schema",mutation:h.name,args:{},open:m,score:X-m.length,why:`this makes ${(h.creates??[]).filter(o=>e.has(o)).map(o=>J(G(n.schema.tryDefinition(o),o))).join(", ")}`,nodeIds:[]})}return{affordances:c,observations:a}}if(t.length===0)return{};let w=new Set(t.map(e=>e.kind)),s=(e,a,h)=>{let m=[];for(let r of n.graph.allEdges()){if(!a.includes(r.kind))continue;let o=r.from===e?r.to:r.to===e?r.from:null;if(!o)continue;let k=n.graph.getNode(o);k&&(!h.includes("*")&&!h.includes(k.kind)||m.includes(o)||m.push(o))}return m};for(let e of n.allMutations()){let a=e.subject;if(!a||!(a.kinds==="*"?!0:[...w].every(u=>a.kinds.includes(u))))continue;let m=e.derived?.act;if((m==="archive"||m==="merge")&&t.some(u=>V(u))||m==="unarchive"&&!t.some(u=>V(u))||m==="leave-alone"&&t.every(u=>U(n,u.id))||m==="allow-tidying"&&!t.some(u=>U(n,u.id)))continue;let r=t.length===1?t[0].id:null,o=e.severs??[],k=e.connects??[];if(r&&o.length>0&&k.length===0&&s(r,o,["*"]).length===0)continue;let g=[];for(let u of E(e.input)){if(u.name===a.arg)continue;let p=u.kinds.includes("*")?n.graph.allNodes().map(S=>S.id):u.kinds.flatMap(S=>n.graph.nodesOfKind(S).map(P=>P.id));if(r&&k.length>0){let S=new Set(s(r,k,u.kinds));p=p.filter(P=>!S.has(P))}else r&&o.length>0&&(p=s(r,o,u.kinds));g.push({name:u.name,kinds:u.kinds,candidates:p.filter(S=>!d.includes(S)),shape:x(e.input,u.name),...u.optional?{optional:!0}:{}})}for(let u of q(e.input,a.arg))g.some(p=>p.name===u)||g.push({name:u,shape:x(e.input,u)});if(g.length===0&&r){let u=Sn(e.input,a.arg);if(u.length>0&&!wn(n,e.name,{[a.arg]:r}))for(let p of u){let S=E(e.input).find(P=>P.name===p);g.push({name:p,optional:!0,...S?{kinds:S.kinds}:{},shape:x(e.input,p)})}}if(!g.every(u=>u.optional===!0?!0:u.kinds!==void 0?(u.candidates?.length??0)>0:(u.candidates?.length??0)>0||u.shape!==void 0&&u.shape.type!=="unknown")&&!A(e.name,r?{[a.arg]:r}:{}))continue;let j=t.map(u=>({[a.arg]:u.id}));g.length===0&&!j.some(u=>n.wouldChange({name:e.name,args:u}))||c.push({id:`schema:${e.name}`,label:t.length>1?`${K(e)} (${t.length})`:K(e),provider:"schema",mutation:e.name,args:j[0]??{},open:g,...e.destructive?{destructive:!0}:{},...e.derived?.act==="archive"||e.derived?.act==="merge"||e.derived?.act==="leave-alone"||e.derived?.act==="allow-tidying"?{setsAside:!0}:{},...o.length>0||k.length>0?{ties:!0}:{},...t.length>1?{batch:j}:{},score:X-g.length,why:t.length>1?`all ${t.length} selected nodes are ${[...w].map(u=>tn(n.schema,u).toLowerCase()).join(" or ")}`:`this is ${J(G(n.schema.tryDefinition(t[0].kind),t[0].kind))}`,nodeIds:t.map(u=>u.id)})}if(t.length===1){let e=t[0];for(let a of n.allMutations()){let h=a.subject,m=a.severs??[],r=a.connects??[];if(!h||m.length===0&&r.length===0)continue;let o=h.kinds==="*"?"*":h.kinds;if(o==="*"||o.includes(e.kind))continue;let k=E(a.input),g=k.find(y=>y.name!==h.arg&&(y.kinds.includes("*")||y.kinds.includes(e.kind)));if(!g)continue;let $=o,j=$.includes("*")?n.graph.allNodes().map(y=>y.id):$.flatMap(y=>n.graph.nodesOfKind(y).map(I=>I.id)),u=new Set(s(e.id,r.length>0?r:m,$)),p=r.length>0?j.filter(y=>!u.has(y)):j.filter(y=>u.has(y));if(p.length===0)continue;let S=[{name:h.arg,kinds:$,candidates:p,shape:x(a.input,h.arg)}];for(let y of k){if(y.name===g.name||y.name===h.arg)continue;let I=y.kinds.includes("*")?n.graph.allNodes().map(L=>L.id):y.kinds.flatMap(L=>n.graph.nodesOfKind(L).map(O=>O.id));S.push({name:y.name,kinds:y.kinds,candidates:I,shape:x(a.input,y.name),...y.optional?{optional:!0}:{}})}for(let y of q(a.input,g.name))y===h.arg||S.some(I=>I.name===y)||S.push({name:y,shape:x(a.input,y)});S.every(y=>y.optional===!0?!0:y.kinds!==void 0?(y.candidates?.length??0)>0:(y.candidates?.length??0)>0||y.shape!==void 0&&y.shape.type!=="unknown")&&c.push({id:`schema:tie:${a.name}:${e.id}`,label:a.fromTheOtherEnd??K(a),provider:"schema",mutation:a.name,args:{[g.name]:e.id},open:S,ties:!0,...a.destructive?{destructive:!0}:{},score:X-S.length+2,why:`${m.length>0?"this one is on":"this one could join"} ${S[0].candidates.length===1?"it":"one of these"}`,nodeIds:[e.id]})}}return{affordances:c}}}}function Sn(n,d){let t=n.shape;return t?Object.entries(t).filter(([f,v])=>f!==d&&v.safeParse(void 0).success).map(([f])=>f):[]}function wn(n,d,t){try{return n.preview({name:d,args:t}),!0}catch{return!1}}function q(n,d){let t=n.shape;return t?Object.entries(t).filter(([f,v])=>f!==d&&!v.safeParse(void 0).success).map(([f])=>f):[]}var An=70,$n=80,On=new Set(["id","kind"]);function mn(){return{name:"structure",derive({store:n,nodes:d}){let t=c=>T(n.schema.tryDefinition(c.kind),c);if(d.length<2)return{};let f=[],v=[],l=d.map(c=>c.id);for(let c of n.schema.edgeKinds){let w=In(d.map(e=>new Set([...n.graph.out(e.id,c).map(a=>a.id),...n.graph.in(e.id,c).map(a=>a.id)])));for(let e of w){let a=n.graph.getNode(e);a&&f.push({id:`shared:${c}:${e}`,text:`all ${d.length} share "${t(a)}" (${H(c).toLowerCase()})`,nodeIds:[...l,e]})}let s=new Map;for(let e of d)for(let a of[...n.graph.out(e.id,c),...n.graph.in(e.id,c)])s.set(a.id,(s.get(a.id)??0)+1);for(let[e,a]of s){if(a!==d.length-1||d.length<3||l.includes(e))continue;let h=n.graph.getNode(e);if(!h)continue;let m=d.find(r=>![...n.graph.out(r.id,c),...n.graph.in(r.id,c)].some(o=>o.id===e));if(m&&(f.push({id:`near-shared:${c}:${e}`,text:`all but "${t(m)}" share "${t(h)}" (${H(c).toLowerCase()})`,nodeIds:[...l,e]}),!(!n.schema.edgeAllowed(c,m.kind,h.kind)&&!n.schema.edgeAllowed(c,h.kind,m.kind))))for(let r of n.allMutations()){let o=r.subject;if(!o||o.kinds!=="*"&&!o.kinds.includes(m.kind)||(r.connects!==void 0||r.severs!==void 0)&&!(r.connects??[]).includes(c))continue;let g=Pn(r.input,h.kind);g&&v.push({id:`structure:join:${r.name}:${m.id}:${e}`,label:`${K(r)}: bring "${t(m)}" in line with the others`,provider:"structure",mutation:r.name,args:{[o.arg]:m.id,[g]:e},open:[],score:An,why:`every other selected node is connected to "${t(h)}"`,nodeIds:[m.id,e]})}}}let A=new Map;for(let c of d)A.set(c.kind,[...A.get(c.kind)??[],c]);for(let[c,w]of A){if(w.length<2)continue;let s=w,e=w.map(r=>r.id),a=A.size>1?`${c}:`:"",h=new Set;for(let r of s)for(let o of Object.keys(r))On.has(o)||h.add(o);let m=r=>n.schema.definitions.find(o=>o.kind===r);for(let r of[...h].sort()){let o=m(s[0].kind),k=sn(o,r).toLowerCase(),g=o?.display?.format?.[r],$=O=>{if(!g)return O;try{return String(g(JSON.parse(O)))}catch{return O}},j=s.map(O=>O[r]),u=new Map;if(j.forEach((O,R)=>{let D=JSON.stringify(O??null),M=u.get(D);M?M.push(s[R]):u.set(D,[s[R]])}),u.size===1){let O=[...u.keys()][0];if(O==="null")continue;f.push({id:`agree:${a}${r}`,text:`all ${s.length} share the ${k} ${$(O)}`,nodeIds:e});continue}if(s.length<3||u.size!==2)continue;let p=[...u.entries()].sort((O,R)=>R[1].length-O[1].length),[S,P]=p[0],[,y]=p[1];if(y.length!==1||S==="null")continue;let I=y[0],L=JSON.parse(S);f.push({id:`odd-one-out:${a}${r}`,text:`${P.length} share the ${k} ${$(S)}; "${t(I)}" does not`,nodeIds:e});for(let O of n.allMutations()){let R=O.subject;if(!R||R.kinds!=="*"&&!R.kinds.includes(I.kind))continue;let D=kn(O.input);if(!D||!(r in D))continue;let M={[R.arg]:I.id,[r]:L},C=!0;for(let[W,z]of Object.entries(D)){if(W in M||z.safeParse(void 0).success)continue;let B=I[W];if(B===void 0){C=!1;break}M[W]=B}!C||!O.input.safeParse(M).success||v.push({id:`structure:align:${O.name}:${r}:${I.id}`,label:`Align the ${k} of "${t(I)}" with the other ${P.length}`,provider:"structure",mutation:O.name,args:M,open:[],score:$n,why:`${P.length} of ${s.length} share the ${k} ${$(S)}`,nodeIds:e})}}}return{affordances:v,observations:f}}}}function In(n){if(n.length===0)return[];let[d,...t]=n;return[...d].filter(f=>t.every(v=>v.has(f))).sort()}function kn(n){return n.shape??null}function Pn(n,d){let t=kn(n);if(!t)return null;for(let[f]of Object.entries(t)){let v=on(t[f]);if(v&&(v.includes("*")||v.includes(d)))return f}return null}function jn(){return[gn(),mn(),pn(),fn()]}function Xn(n,d,t={}){let f=yn(),v=t.providers??jn(),l=d.map(i=>n.graph.getNode(i)).filter(i=>i!==void 0),A={store:n,selection:d,nodes:l,kindSelection:t.kindSelection??[],edgeSelection:t.edgeSelection??[],violations:n.violations(t.context),context:t.context??{},principal:t.principal??{kind:"human"}},c=[],w=[];for(let i of v){let b=i.derive(A);c.push(...b.affordances??[]),w.push(...b.observations??[])}let s=new Map(n.allMutations().map(i=>[i.name,i]));c.forEach((i,b)=>{let N=i.open.length>1?s.get(i.mutation):void 0;N&&(c[b]={...i,open:an(i.open,rn(n.schema,N))})});let e=new Set(n.allMutations().filter(i=>i.pinned).map(i=>i.name)),a=new Set(t.pins?.pinned??[]),h=new Set(t.pins?.unpinned??[]),m=i=>a.has(i.mutation)?"user":e.has(i.mutation)&&!h.has(i.mutation)?"declared":void 0,r=i=>{let b=m(i);return b?{...i,pinned:b}:i},o=new Map;for(let[i,b]of ln(n.log.all()))o.set(i,hn(b));let k=i=>i.pinned==="user"?0:i.pinned==="declared"?1:2,g=i=>i.score+(o.get(i.mutation)??0),$=new Map(n.allMutations().map(i=>[i.name,i])),j=new Map,u=i=>{let b=$.get(i.mutation);if(!b)return[];let N=j.get(i.mutation);N||(N=E(b.input).map(F=>F.name),j.set(i.mutation,N));let _=[];for(let F of i.batch??[i.args])for(let Y of N){let nn=F[Y]??i.args[Y];typeof nn=="string"&&_.push(nn)}return _},p=t.focus,S=4,P=i=>i.open.length>0?1:0,y=i=>{if(p===void 0)return S;let b=u(i);return b.length>0?b.includes(p)?I(i,0):S:i.nodeIds.includes(p)||i.subjectId===p?I(i,1):S},I=(i,b)=>i.provider==="invariant"?b:2+P(i),L=i=>i.setsAside?1:0,O=Nn(c).map(r),R=new Map(O.map((i,b)=>[i,b])),D=O.sort((i,b)=>{let N=Number(i.destructive??!1)-Number(b.destructive??!1);if(N!==0)return N;let _=L(i)-L(b);if(_!==0)return _;let F=y(i)-y(b);return F!==0?F:y(i)<2?R.get(i)-R.get(b):+(b.provider==="invariant")-+(i.provider==="invariant")||k(i)-k(b)||g(b)-g(i)||i.id.localeCompare(b.id)}),M=t.principal??{kind:"human"},C=[],W=[];for(let i of D){let b=n.permits({name:i.mutation,args:{...i.args,...i.batch?.[0]??{}}},M);if(b.ok)C.push(i);else{let N=Rn(n,i,M);if(N==="done")continue;N?C.push(N):W.push({...i,refusal:b.refusal})}}let z=C.map((i,b)=>({...i,rank:b})),B=W.map((i,b)=>({...i,rank:C.length+b}));return{affordances:t.limit===void 0?z:z.slice(0,t.limit),withheld:B,observations:xn(w),ms:yn()-f}}function Nn(n){let d=new Map;for(let t of n){let f=[t.mutation,JSON.stringify(t.args),JSON.stringify(t.batch??null)].join("|"),v=d.get(f);(!v||t.score>v.score)&&d.set(f,t)}return[...d.values()]}function xn(n){let d=new Map;for(let t of n)d.set(t.text,t);return[...d.values()]}function yn(){return typeof performance<"u"?performance.now():Date.now()}function Yn(n,d,t={},f={}){let v=(d.batch??[d.args]).map(A=>({name:d.mutation,args:{...d.args,...A,...t}})),l=n.allMutations().find(A=>A.name===d.mutation);return n.applyAll(v,{...l?.describe?{}:{intent:d.label},...f.author?{author:f.author}:{}})}function ne(n,d,t={},f={}){try{return n.preview({name:d.mutation,args:{...d.args,...t}})}catch(v){throw f.pressed&&dn(v,f.pressed.author?.id),v}}function Rn(n,d,t){let f=n.allMutations().find(s=>s.name===d.mutation)?.subject,v=f!==void 0&&d.args[f.arg]===void 0,l=v?d.open.find(s=>s.name===f.arg):d.open.find(s=>s.name!==f?.arg&&s.candidates);if(!l?.candidates)return;let A=s=>n.permits({name:d.mutation,args:{...d.args,...d.batch?.[0]??{},[l.name]:s}},t).ok,c=l.candidates.filter(A),w=t.id===void 0?void 0:n.graph.getNode(t.id);if(c.length===0){let s=v?f.kinds:"*";return w!==void 0&&(s==="*"||s.includes(w.kind))&&A(w.id)?"done":void 0}return c.length===1&&c[0]===t.id?{...d,args:{...d.args,[l.name]:t.id},open:d.open.filter(s=>s!==l)}:{...d,open:d.open.map(s=>s===l?{...s,candidates:c}:s)}}export{Xn as a,Yn as b,ne as c};
1
+ import{b as cn,c as un}from"./chunk.EGPCVMDU.js";import{j as x}from"./chunk.SJQPTDAT.js";import{b as Z}from"./chunk.JQ63N4MZ.js";import{Bc as Q,Hd as dn,Lc as U,ec as on,fc as E,ga as H,gb as V,la as T,ma as K,na as en,nc as rn,oa as tn,oc as an,sa as sn,ta as J,ua as G}from"./chunk.ZEZUKRC6.js";function fn(){return{name:"insight",derive({store:n,nodes:d,kindSelection:t}){let f=[],v=l=>T(n.schema.tryDefinition(l.kind),l);for(let l of d){if([...n.schema.edgeKinds].reduce((c,w)=>c+n.graph.out(l.id,w).length+n.graph.in(l.id,w).length,0)===0){f.push({id:`insight:island:${l.id}`,text:`${v(l)} is connected to nothing yet`,nodeIds:[l.id]});continue}for(let c of n.schema.edgeKinds){let w=n.graph.in(l.id,c).length;if(w<3)continue;let s=[...n.graph.allEdges()].filter(a=>a.kind===c),e=s.length;e>=4&&w/e>.6&&f.push({id:`insight:load:${l.id}:${c}`,text:`${v(l)} ${vn(n,s,c,w)}`,nodeIds:[l.id]})}}for(let l of t){if(n.graph.nodesOfKind(l).length>0)continue;let A=n.schema.definitions.filter(c=>c.kind!==l).filter(c=>Object.values(c.edges).some(w=>w.to!=="*"&&w.to.includes(l))).map(c=>c.plural??`${c.kind}s`);A.length>0&&f.push({id:`insight:gap:${l}`,text:`Nothing here yet, though ${A.join(" and ")} expect to connect to these`,nodeIds:[]})}return{observations:f}}}}function vn(n,d,t,f){let v=new Set(d.map(s=>n.graph.getNode(s.from)?.kind).filter(s=>s!==void 0)),l=v.size===1?[...v][0]:void 0,A=d.length,c=Z(n.schema,l??[...v][0]??"",t,"in"),w=s=>l?en(n.schema,l,s):String(s);return f===A?`${c}: all ${w(f)}`:`${c}: ${f} of the ${w(A)}`}function ln(n){let d=new Map;if(n.length===0)return d;let t=n.slice(-512),f=new Set;for(let l of t)l.undoes&&f.add(l.undoes);let v=n[n.length-1].seq;for(let l of t){if(!l.mutation||f.has(l.id))continue;let A=Math.pow(.5,(v-l.seq)/64);d.set(l.mutation.name,(d.get(l.mutation.name)??0)+A)}return d}function hn(n){return 8*(n/(n+1))}var bn=100;function gn(){return{name:"invariant",derive({store:n,selection:d,nodes:t,violations:f}){let v=s=>T(n.schema.tryDefinition(s.kind),s),l=new Set(d),A=f.filter(s=>s.nodeIds.some(e=>l.has(e))||s.subjectId!==void 0&&l.has(s.subjectId)),c=[],w=[];A.forEach((s,e)=>{w.push({id:`violation:${s.invariant}:${e}`,text:s.message,nodeIds:s.nodeIds}),s.repairs.forEach((a,h)=>{c.push({id:`invariant:${s.invariant}:${e}:${h}`,label:a.label,provider:"invariant",mutation:a.mutation,args:a.args??{},open:(a.missing??[]).map(m=>{let r=n.allMutations().find(g=>g.name===a.mutation);if(!r)return{name:m};let o=E(r.input).find(g=>g.name===m),k=o?o.kinds.includes("*")?n.graph.allNodes().map(g=>g.id):o.kinds.flatMap(g=>n.graph.nodesOfKind(g).map($=>$.id)):void 0;return{name:m,shape:x(r.input,m),...o?{kinds:o.kinds}:{},...k?{candidates:k}:{}}}),score:bn-h-(a.missing?.length??0),why:s.message,nodeIds:s.nodeIds,...s.subjectId===void 0?{}:{subjectId:s.subjectId}})})});for(let s of t){let e=n.allInvariants().filter(a=>{if(a.scope==="graph")return!1;let h=a.scope;return h.kind!==s.kind?!1:h.match?h.match(s):!0});e.length!==0&&(A.some(a=>a.subjectId===s.id||a.nodeIds.includes(s.id))||w.push({id:`holds:${s.id}`,text:`${v(s)} holds \u2014 nothing currently breaks ${e.length===1?"it":`any of its ${e.length} rules`}`,nodeIds:[s.id]}))}return{affordances:c,observations:w}}}}var X=40;function pn(){return{name:"schema",derive({store:n,selection:d,nodes:t,kindSelection:f,edgeSelection:v,principal:l}){let A=(e,a)=>l!==void 0&&!n.permits({name:e,args:a},l).ok,c=[];if(t.length===0&&v.length>0){for(let e of v){let a=n.graph.getNode(e.from),h=n.graph.getNode(e.to);if(!a||!h)continue;let m=un(n,e);m?.provisional&&c.push({id:`schema:edge:${Q}:${e.kind}:${e.from}:${e.to}`,label:"Keep this link",provider:"schema",mutation:Q,args:{kind:e.kind,from:e.from,to:e.to},open:[],score:64,why:cn(m),nodeIds:[e.from,e.to]});for(let r of n.allMutations()){let o=(r.connects??[]).includes(e.kind),k=(r.severs??[]).includes(e.kind);if(!o&&!k||r.derived?.relation!==void 0&&r.derived.kind!==a.kind)continue;let g={},$=[],j=E(r.input);for(let p of j){let S=p.kinds.includes("*")||p.kinds.includes(a.kind),P=p.kinds.includes("*")||p.kinds.includes(h.kind),y=S&&!j.some(I=>I!==p&&(I.kinds.includes(a.kind)||I.kinds.includes("*")));S&&!P?g[p.name]=e.from:P&&!S?g[p.name]=e.to:S&&P&&y?g[p.name]=e.from:$.push({name:p.name,kinds:p.kinds,candidates:[e.from,e.to],shape:x(r.input,p.name)})}for(let p of q(r.input,""))p in g||$.some(S=>S.name===p)||$.push({name:p,shape:x(r.input,p)});$.every(p=>p.optional===!0?!0:p.kinds!==void 0?(p.candidates?.length??0)>0:(p.candidates?.length??0)>0||p.shape!==void 0&&p.shape.type!=="unknown")&&(o&&!k&&$.length===0||c.push({id:`schema:edge:${r.name}:${e.kind}:${e.from}:${e.to}`,label:K(r),provider:"schema",mutation:r.name,args:g,open:$,...r.destructive?{destructive:!0}:{},score:(k?62:58)-$.length,why:`this line is "${Z(n.schema,n.graph.getNode(e.from)?.kind??"",e.kind,"out")}"`,nodeIds:[e.from,e.to]}))}}return{affordances:c}}if(t.length===0&&f.length>0){let e=new Set(f),a=[];for(let h of n.allMutations()){if(!(h.creates??[]).some(o=>e.has(o)))continue;let m=[];for(let o of E(h.input)){let k=o.kinds.includes("*")?n.graph.allNodes().map(g=>g.id):o.kinds.flatMap(g=>n.graph.nodesOfKind(g).map($=>$.id));m.push({name:o.name,kinds:o.kinds,candidates:k,shape:x(h.input,o.name),...o.optional?{optional:!0}:{}})}for(let o of q(h.input,""))m.some(k=>k.name===o)||m.push({name:o,shape:x(h.input,o)});if(!m.every(o=>o.optional===!0?!0:o.kinds!==void 0?(o.candidates?.length??0)>0:(o.candidates?.length??0)>0||o.shape!==void 0&&o.shape.type!=="unknown")&&!A(h.name,{})){let o=m.filter(k=>k.optional!==!0&&k.kinds!==void 0&&!k.kinds.includes("*")&&(k.candidates?.length??0)===0);if(o.length>0){let k=[...new Set(o.flatMap(g=>g.kinds??[]))].map(g=>J(G(n.schema.tryDefinition(g),g)));a.push({id:`schema:waits:${h.name}`,text:`"${h.title??h.name}" cannot begin until there is ${k.length===1?k[0]:`${k.slice(0,-1).join(", ")} and ${k[k.length-1]}`}.`,nodeIds:[]})}continue}c.push({id:`schema:add:${h.name}`,label:K(h),provider:"schema",mutation:h.name,args:{},open:m,score:X-m.length,why:`this makes ${(h.creates??[]).filter(o=>e.has(o)).map(o=>J(G(n.schema.tryDefinition(o),o))).join(", ")}`,nodeIds:[]})}return{affordances:c,observations:a}}if(t.length===0)return{};let w=new Set(t.map(e=>e.kind)),s=(e,a,h)=>{let m=[];for(let r of n.graph.allEdges()){if(!a.includes(r.kind))continue;let o=r.from===e?r.to:r.to===e?r.from:null;if(!o)continue;let k=n.graph.getNode(o);k&&(!h.includes("*")&&!h.includes(k.kind)||m.includes(o)||m.push(o))}return m};for(let e of n.allMutations()){let a=e.subject;if(!a||!(a.kinds==="*"?!0:[...w].every(u=>a.kinds.includes(u))))continue;let m=e.derived?.act;if((m==="archive"||m==="merge")&&t.some(u=>V(u))||m==="unarchive"&&!t.some(u=>V(u))||m==="leave-alone"&&t.every(u=>U(n,u.id))||m==="allow-tidying"&&!t.some(u=>U(n,u.id)))continue;let r=t.length===1?t[0].id:null,o=e.severs??[],k=e.connects??[];if(r&&o.length>0&&k.length===0&&s(r,o,["*"]).length===0)continue;let g=[];for(let u of E(e.input)){if(u.name===a.arg)continue;let p=u.kinds.includes("*")?n.graph.allNodes().map(S=>S.id):u.kinds.flatMap(S=>n.graph.nodesOfKind(S).map(P=>P.id));if(r&&k.length>0){let S=new Set(s(r,k,u.kinds));p=p.filter(P=>!S.has(P))}else r&&o.length>0&&(p=s(r,o,u.kinds));g.push({name:u.name,kinds:u.kinds,candidates:p.filter(S=>!d.includes(S)),shape:x(e.input,u.name),...u.optional?{optional:!0}:{}})}for(let u of q(e.input,a.arg))g.some(p=>p.name===u)||g.push({name:u,shape:x(e.input,u)});if(g.length===0&&r){let u=Sn(e.input,a.arg);if(u.length>0&&!wn(n,e.name,{[a.arg]:r}))for(let p of u){let S=E(e.input).find(P=>P.name===p);g.push({name:p,optional:!0,...S?{kinds:S.kinds}:{},shape:x(e.input,p)})}}if(!g.every(u=>u.optional===!0?!0:u.kinds!==void 0?(u.candidates?.length??0)>0:(u.candidates?.length??0)>0||u.shape!==void 0&&u.shape.type!=="unknown")&&!A(e.name,r?{[a.arg]:r}:{}))continue;let j=t.map(u=>({[a.arg]:u.id}));g.length===0&&!j.some(u=>n.wouldChange({name:e.name,args:u}))||c.push({id:`schema:${e.name}`,label:t.length>1?`${K(e)} (${t.length})`:K(e),provider:"schema",mutation:e.name,args:j[0]??{},open:g,...e.destructive?{destructive:!0}:{},...e.derived?.act==="archive"||e.derived?.act==="merge"||e.derived?.act==="leave-alone"||e.derived?.act==="allow-tidying"?{setsAside:!0}:{},...o.length>0||k.length>0?{ties:!0}:{},...t.length>1?{batch:j}:{},score:X-g.length,why:t.length>1?`all ${t.length} selected nodes are ${[...w].map(u=>tn(n.schema,u).toLowerCase()).join(" or ")}`:`this is ${J(G(n.schema.tryDefinition(t[0].kind),t[0].kind))}`,nodeIds:t.map(u=>u.id)})}if(t.length===1){let e=t[0];for(let a of n.allMutations()){let h=a.subject,m=a.severs??[],r=a.connects??[];if(!h||m.length===0&&r.length===0)continue;let o=h.kinds==="*"?"*":h.kinds;if(o==="*"||o.includes(e.kind))continue;let k=E(a.input),g=k.find(y=>y.name!==h.arg&&(y.kinds.includes("*")||y.kinds.includes(e.kind)));if(!g)continue;let $=o,j=$.includes("*")?n.graph.allNodes().map(y=>y.id):$.flatMap(y=>n.graph.nodesOfKind(y).map(I=>I.id)),u=new Set(s(e.id,r.length>0?r:m,$)),p=r.length>0?j.filter(y=>!u.has(y)):j.filter(y=>u.has(y));if(p.length===0)continue;let S=[{name:h.arg,kinds:$,candidates:p,shape:x(a.input,h.arg)}];for(let y of k){if(y.name===g.name||y.name===h.arg)continue;let I=y.kinds.includes("*")?n.graph.allNodes().map(L=>L.id):y.kinds.flatMap(L=>n.graph.nodesOfKind(L).map(O=>O.id));S.push({name:y.name,kinds:y.kinds,candidates:I,shape:x(a.input,y.name),...y.optional?{optional:!0}:{}})}for(let y of q(a.input,g.name))y===h.arg||S.some(I=>I.name===y)||S.push({name:y,shape:x(a.input,y)});S.every(y=>y.optional===!0?!0:y.kinds!==void 0?(y.candidates?.length??0)>0:(y.candidates?.length??0)>0||y.shape!==void 0&&y.shape.type!=="unknown")&&c.push({id:`schema:tie:${a.name}:${e.id}`,label:a.fromTheOtherEnd??K(a),provider:"schema",mutation:a.name,args:{[g.name]:e.id},open:S,ties:!0,...a.destructive?{destructive:!0}:{},score:X-S.length+2,why:`${m.length>0?"this one is on":"this one could join"} ${S[0].candidates.length===1?"it":"one of these"}`,nodeIds:[e.id]})}}return{affordances:c}}}}function Sn(n,d){let t=n.shape;return t?Object.entries(t).filter(([f,v])=>f!==d&&v.safeParse(void 0).success).map(([f])=>f):[]}function wn(n,d,t){try{return n.preview({name:d,args:t}),!0}catch{return!1}}function q(n,d){let t=n.shape;return t?Object.entries(t).filter(([f,v])=>f!==d&&!v.safeParse(void 0).success).map(([f])=>f):[]}var An=70,$n=80,On=new Set(["id","kind"]);function mn(){return{name:"structure",derive({store:n,nodes:d}){let t=c=>T(n.schema.tryDefinition(c.kind),c);if(d.length<2)return{};let f=[],v=[],l=d.map(c=>c.id);for(let c of n.schema.edgeKinds){let w=In(d.map(e=>new Set([...n.graph.out(e.id,c).map(a=>a.id),...n.graph.in(e.id,c).map(a=>a.id)])));for(let e of w){let a=n.graph.getNode(e);a&&f.push({id:`shared:${c}:${e}`,text:`all ${d.length} share "${t(a)}" (${H(c).toLowerCase()})`,nodeIds:[...l,e]})}let s=new Map;for(let e of d)for(let a of[...n.graph.out(e.id,c),...n.graph.in(e.id,c)])s.set(a.id,(s.get(a.id)??0)+1);for(let[e,a]of s){if(a!==d.length-1||d.length<3||l.includes(e))continue;let h=n.graph.getNode(e);if(!h)continue;let m=d.find(r=>![...n.graph.out(r.id,c),...n.graph.in(r.id,c)].some(o=>o.id===e));if(m&&(f.push({id:`near-shared:${c}:${e}`,text:`all but "${t(m)}" share "${t(h)}" (${H(c).toLowerCase()})`,nodeIds:[...l,e]}),!(!n.schema.edgeAllowed(c,m.kind,h.kind)&&!n.schema.edgeAllowed(c,h.kind,m.kind))))for(let r of n.allMutations()){let o=r.subject;if(!o||o.kinds!=="*"&&!o.kinds.includes(m.kind)||(r.connects!==void 0||r.severs!==void 0)&&!(r.connects??[]).includes(c))continue;let g=Pn(r.input,h.kind);g&&v.push({id:`structure:join:${r.name}:${m.id}:${e}`,label:`${K(r)}: bring "${t(m)}" in line with the others`,provider:"structure",mutation:r.name,args:{[o.arg]:m.id,[g]:e},open:[],score:An,why:`every other selected node is connected to "${t(h)}"`,nodeIds:[m.id,e]})}}}let A=new Map;for(let c of d)A.set(c.kind,[...A.get(c.kind)??[],c]);for(let[c,w]of A){if(w.length<2)continue;let s=w,e=w.map(r=>r.id),a=A.size>1?`${c}:`:"",h=new Set;for(let r of s)for(let o of Object.keys(r))On.has(o)||h.add(o);let m=r=>n.schema.definitions.find(o=>o.kind===r);for(let r of[...h].sort()){let o=m(s[0].kind),k=sn(o,r),g=o?.display?.format?.[r],$=O=>{if(!g)return O;try{return String(g(JSON.parse(O)))}catch{return O}},j=s.map(O=>O[r]),u=new Map;if(j.forEach((O,R)=>{let D=JSON.stringify(O??null),M=u.get(D);M?M.push(s[R]):u.set(D,[s[R]])}),u.size===1){let O=[...u.keys()][0];if(O==="null")continue;f.push({id:`agree:${a}${r}`,text:`all ${s.length} share the ${k} ${$(O)}`,nodeIds:e});continue}if(s.length<3||u.size!==2)continue;let p=[...u.entries()].sort((O,R)=>R[1].length-O[1].length),[S,P]=p[0],[,y]=p[1];if(y.length!==1||S==="null")continue;let I=y[0],L=JSON.parse(S);f.push({id:`odd-one-out:${a}${r}`,text:`${P.length} share the ${k} ${$(S)}; "${t(I)}" does not`,nodeIds:e});for(let O of n.allMutations()){let R=O.subject;if(!R||R.kinds!=="*"&&!R.kinds.includes(I.kind))continue;let D=kn(O.input);if(!D||!(r in D))continue;let M={[R.arg]:I.id,[r]:L},C=!0;for(let[W,z]of Object.entries(D)){if(W in M||z.safeParse(void 0).success)continue;let B=I[W];if(B===void 0){C=!1;break}M[W]=B}!C||!O.input.safeParse(M).success||v.push({id:`structure:align:${O.name}:${r}:${I.id}`,label:`Align the ${k} of "${t(I)}" with the other ${P.length}`,provider:"structure",mutation:O.name,args:M,open:[],score:$n,why:`${P.length} of ${s.length} share the ${k} ${$(S)}`,nodeIds:e})}}}return{affordances:v,observations:f}}}}function In(n){if(n.length===0)return[];let[d,...t]=n;return[...d].filter(f=>t.every(v=>v.has(f))).sort()}function kn(n){return n.shape??null}function Pn(n,d){let t=kn(n);if(!t)return null;for(let[f]of Object.entries(t)){let v=on(t[f]);if(v&&(v.includes("*")||v.includes(d)))return f}return null}function jn(){return[gn(),mn(),pn(),fn()]}function Xn(n,d,t={}){let f=yn(),v=t.providers??jn(),l=d.map(i=>n.graph.getNode(i)).filter(i=>i!==void 0),A={store:n,selection:d,nodes:l,kindSelection:t.kindSelection??[],edgeSelection:t.edgeSelection??[],violations:n.violations(t.context),context:t.context??{},principal:t.principal??{kind:"human"}},c=[],w=[];for(let i of v){let b=i.derive(A);c.push(...b.affordances??[]),w.push(...b.observations??[])}let s=new Map(n.allMutations().map(i=>[i.name,i]));c.forEach((i,b)=>{let N=i.open.length>1?s.get(i.mutation):void 0;N&&(c[b]={...i,open:an(i.open,rn(n.schema,N))})});let e=new Set(n.allMutations().filter(i=>i.pinned).map(i=>i.name)),a=new Set(t.pins?.pinned??[]),h=new Set(t.pins?.unpinned??[]),m=i=>a.has(i.mutation)?"user":e.has(i.mutation)&&!h.has(i.mutation)?"declared":void 0,r=i=>{let b=m(i);return b?{...i,pinned:b}:i},o=new Map;for(let[i,b]of ln(n.log.all()))o.set(i,hn(b));let k=i=>i.pinned==="user"?0:i.pinned==="declared"?1:2,g=i=>i.score+(o.get(i.mutation)??0),$=new Map(n.allMutations().map(i=>[i.name,i])),j=new Map,u=i=>{let b=$.get(i.mutation);if(!b)return[];let N=j.get(i.mutation);N||(N=E(b.input).map(F=>F.name),j.set(i.mutation,N));let _=[];for(let F of i.batch??[i.args])for(let Y of N){let nn=F[Y]??i.args[Y];typeof nn=="string"&&_.push(nn)}return _},p=t.focus,S=4,P=i=>i.open.length>0?1:0,y=i=>{if(p===void 0)return S;let b=u(i);return b.length>0?b.includes(p)?I(i,0):S:i.nodeIds.includes(p)||i.subjectId===p?I(i,1):S},I=(i,b)=>i.provider==="invariant"?b:2+P(i),L=i=>i.setsAside?1:0,O=Nn(c).map(r),R=new Map(O.map((i,b)=>[i,b])),D=O.sort((i,b)=>{let N=Number(i.destructive??!1)-Number(b.destructive??!1);if(N!==0)return N;let _=L(i)-L(b);if(_!==0)return _;let F=y(i)-y(b);return F!==0?F:y(i)<2?R.get(i)-R.get(b):+(b.provider==="invariant")-+(i.provider==="invariant")||k(i)-k(b)||g(b)-g(i)||i.id.localeCompare(b.id)}),M=t.principal??{kind:"human"},C=[],W=[];for(let i of D){let b=n.permits({name:i.mutation,args:{...i.args,...i.batch?.[0]??{}}},M);if(b.ok)C.push(i);else{let N=Rn(n,i,M);if(N==="done")continue;N?C.push(N):W.push({...i,refusal:b.refusal})}}let z=C.map((i,b)=>({...i,rank:b})),B=W.map((i,b)=>({...i,rank:C.length+b}));return{affordances:t.limit===void 0?z:z.slice(0,t.limit),withheld:B,observations:xn(w),ms:yn()-f}}function Nn(n){let d=new Map;for(let t of n){let f=[t.mutation,JSON.stringify(t.args),JSON.stringify(t.batch??null)].join("|"),v=d.get(f);(!v||t.score>v.score)&&d.set(f,t)}return[...d.values()]}function xn(n){let d=new Map;for(let t of n)d.set(t.text,t);return[...d.values()]}function yn(){return typeof performance<"u"?performance.now():Date.now()}function Yn(n,d,t={},f={}){let v=(d.batch??[d.args]).map(A=>({name:d.mutation,args:{...d.args,...A,...t}})),l=n.allMutations().find(A=>A.name===d.mutation);return n.applyAll(v,{...l?.describe?{}:{intent:d.label},...f.author?{author:f.author}:{}})}function ne(n,d,t={},f={}){try{return n.preview({name:d.mutation,args:{...d.args,...t}})}catch(v){throw f.pressed&&dn(v,f.pressed.author?.id),v}}function Rn(n,d,t){let f=n.allMutations().find(s=>s.name===d.mutation)?.subject,v=f!==void 0&&d.args[f.arg]===void 0,l=v?d.open.find(s=>s.name===f.arg):d.open.find(s=>s.name!==f?.arg&&s.candidates);if(!l?.candidates)return;let A=s=>n.permits({name:d.mutation,args:{...d.args,...d.batch?.[0]??{},[l.name]:s}},t).ok,c=l.candidates.filter(A),w=t.id===void 0?void 0:n.graph.getNode(t.id);if(c.length===0){let s=v?f.kinds:"*";return w!==void 0&&(s==="*"||s.includes(w.kind))&&A(w.id)?"done":void 0}return c.length===1&&c[0]===t.id?{...d,args:{...d.args,[l.name]:t.id},open:d.open.filter(s=>s!==l)}:{...d,open:d.open.map(s=>s===l?{...s,candidates:c}:s)}}export{Xn as a,Yn as b,ne as c};
@@ -0,0 +1 @@
1
+ import{E as b,R as c,S as T,U as p,V as D}from"./chunk.ZEZUKRC6.js";var S=864e5,N=/^(\d{4})-(\d{2})-(\d{2})/,s=n=>String(n).padStart(2,"0"),g=n=>new Date(n).toISOString().slice(0,10),m=n=>Date.UTC(+n.slice(0,4),+n.slice(5,7)-1,+n.slice(8,10)),W=(n,e)=>g(m(n)+e*S),M=n=>new Date(m(n)).getUTCDay();function A(n,e,t){if(!(e>=1&&e<=12&&t>=1&&t<=31))return;let r=`${String(n).padStart(4,"0")}-${s(e)}-${s(t)}`;return g(m(r))===r?r:void 0}function O(n=new Date){let e=c();return e?p(n.getTime(),e):{day:`${n.getFullYear()}-${s(n.getMonth()+1)}-${s(n.getDate())}`,minutes:n.getHours()*60+n.getMinutes()}}var $=n=>/T\d\d:\d\d(:[\d.]+)?(Z|[+-]\d\d:?\d\d)$/.test(n);function f(n){if(typeof n!="string")return;if($(n)){let r=new Date(n);return Number.isNaN(r.getTime())?void 0:O(r)}let e=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2}))?/.exec(n);if(!e||!A(Number(e[1]),Number(e[2]),Number(e[3])))return;let t=n.slice(0,10);return e[4]===void 0?{day:t}:{day:t,minutes:Number(e[4])*60+Number(e[5])}}function x(n,e){if(!e.time)return n.day;let t=n.minutes??9*60;if(!e.instant)return`${n.day}T${s(Math.floor(t/60))}:${s(t%60)}`;let r=c(),[,i,a,d]=N.exec(n.day);return(r?new Date(D(n.day,t,r)):new Date(Number(i),Number(a)-1,Number(d),Math.floor(t/60),t%60)).toISOString().replace(/\.\d{3}Z$/,"Z")}function Z(n,e=new Date){let t=T(),r=t;try{r=new Intl.DateTimeFormat(n??b,{timeZoneName:"short",timeZone:t}).formatToParts(e).find(i=>i.type==="timeZoneName")?.value??t}catch{r=t}return{zone:t,short:r}}function z(n,e,t,r){let i=f(e);if(!i)return t;let a=n===void 0?void 0:f(n),d=t===void 0?void 0:f(t),o=u=>m(u.day)+(u.minutes??0)*6e4,l=(u,h)=>{let y=o(u)+h;return{day:g(y),...r.time?{minutes:Math.round(y%S/6e4)}:{}}};return a&&d?x(l(d,o(i)-o(a)),r):d&&o(d)>=o(i)?t:r.time?x(l(i,36e5),r):t}var _=/^(start|starts|startsAt|startsOn|startAt|begins|from|opens|checkIn)$/i,w=/^(end|ends|endsAt|endsOn|endAt|until|to|finish|finishes|closes|through|checkOut)$/i;function F(n,e={}){let t=(e.start&&n.includes(e.start)?e.start:void 0)??n.find(i=>_.test(i)),r=(e.end&&n.includes(e.end)?e.end:void 0)??n.find(i=>i!==t&&w.test(i));return t&&r?{start:t,end:r}:void 0}export{S as a,m as b,W as c,M as d,A as e,O as f,$ as g,f as h,x as i,Z as j,z as k,F as l};
@@ -0,0 +1 @@
1
+ var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as U,b as V,d as b,e as B,f as C,g as W}from"./chunk.NRURQGXV.js";import{a as p,b as T,c as S,e as _}from"./chunk.BBLIT7S7.js";import{a as J,b as h,e as A}from"./chunk.AKJS2NUM.js";import{b as z}from"./chunk.5AKZROMR.js";import{a as R}from"./chunk.SDO3U72B.js";import"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var Q=R(()=>(__graviewPreload(import.meta.url,["./chunk.RSMCTI2N.js","./chunk.AJZBJBMO.js"]),import("./chunk.UJPX3BUV.js")));function te(d,e){let f=d.ownerDocument,u=f.defaultView,t=f.createElement("iframe");t.setAttribute("sandbox",T),t.setAttribute("referrerpolicy","no-referrer"),t.setAttribute("allow",""),t.setAttribute("title",e.title??e.view),t.setAttribute("data-guest-view",e.view),t.setAttribute("aria-busy","true"),t.style.border="0",t.style.width="100%",t.style.display="block",t.src=e.url;let a={applied:0,refused:0,dropped:0},P=h(e.limits),i,y,o={applied:0,refused:0,dropped:0},v=()=>{if(!i)return;let r=i.stats;a.applied+=r.applied-o.applied,a.refused+=r.refused-o.refused,a.dropped+=r.dropped-o.dropped,o={...r}},O=W(u,()=>l(),"data"),g=()=>C(()=>e.theme?.()??b(d),e.brand,O),L="",l=()=>{i&&(L=JSON.stringify(g()),i.push())},k=B(f,()=>{i&&JSON.stringify(g())!==L&&l()}),n,w=!1,D=e.pictures?z(Q,({createGuestPictures:r})=>{n=r(u,{as:"data",view:`"${e.title??e.view}"`,pictures:e.pictures,...e.limits?{limits:e.limits}:{},...e.file?{file:e.file}:{},moved:()=>{i?.push(),G&&E()}}),w&&x()}):()=>{},G=!1,c,N=()=>{!G||n?.waiting()||(clearTimeout(c),t.removeAttribute("data-guest-view-failed"),t.removeAttribute("aria-busy"),t.setAttribute("data-guest-view-drawn",""))},E=()=>{clearTimeout(c),c=setTimeout(N,250)},F=setTimeout(()=>{i||(t.removeAttribute("aria-busy"),t.setAttribute("data-guest-view-failed","silent"))},e.limits?.readyMs??8e3),H=()=>{v(),i?.dispose(),y?.close(),i=void 0,y=void 0,o={applied:0,refused:0,dropped:0}},M=r=>{if(!(r.source===null||r.source!==t.contentWindow)){if(r.origin!==S||!P.message()){a.dropped+=1;return}if(!_(r.data)||r.data.protocol!==1){a.dropped+=1;return}if(e.pictures&&!n){w=!0;return}x()}},x=()=>{w=!1,H();let r=U(),m=new MessageChannel;y=m.port1;let I=A({store:e.store,principal:e.principal,view:e.view,nonce:r,send:s=>m.port1.postMessage(s),...e.input?{input:e.input}:{},...e.reads?{reads:e.reads}:{},...n?{hand:n.hand}:{},theme:g,...e.places?{places:()=>[...new Set(e.places().map(s=>s.as))],placesShown:e.places}:{},...e.onNavigatePlace?{onNavigatePlace:e.onNavigatePlace}:{},...e.onNavigate?{onNavigate:e.onNavigate}:{},...e.onArrive?{onArrive:e.onArrive}:e.goTo?{onArrive:s=>V(e.goTo(),s)}:{},...e.onLost?{onLost:e.onLost}:{},onSize:s=>{e.onSize?e.onSize(s):t.style.height=`${s}px`,N()},...e.limits?{limits:e.limits}:{},limiter:P});i=I,m.port1.onmessage=s=>{I.receive(s.data),v()};let j={graview:"host-hello",protocol:1,nonce:r,view:e.view};t.contentWindow.postMessage(j,"*",[m.port2]),l(),G=!0,E()};return u.addEventListener("message",M),d.appendChild(t),d.removeAttribute("aria-busy"),{iframe:t,update:l,get stats(){return v(),a},dispose(){H(),clearTimeout(F),clearTimeout(c),k(),O.dispose(),D(),n?.dispose(),u.removeEventListener("message",M),t.remove()}}}export{p as GUEST_PROTOCOL,T as GUEST_SANDBOX,S as OPAQUE_ORIGIN,A as createGuestHost,h as createGuestLimiter,te as mountGuestView,J as readAcross,b as readTheme};
@@ -0,0 +1,6 @@
1
+ import{i as z,j as D,k as H}from"./chunk.AJMVRFYX.js";import{a as P,b as A,c as p,d as W}from"./chunk.Q355UPFG.js";import"./chunk.GMLONS5L.js";import"./chunk.6NG76MDA.js";import"./chunk.35KMZHB7.js";import"./chunk.IAEGJDF3.js";import"./chunk.YZPESGCP.js";import"./chunk.SY5ID44D.js";import"./chunk.GVT4UUQA.js";import"./chunk.5R744JGZ.js";import"./chunk.O2OL6RQQ.js";import"./chunk.J6HF7IRQ.js";import"./chunk.LRNFE3UK.js";import{a as C,b as O}from"./chunk.MB7LKKUD.js";import"./chunk.T2OUHRAA.js";import"./chunk.GRFD42WM.js";import"./chunk.EP6Q32WT.js";import"./chunk.QAM76AXV.js";import"./chunk.Z27NSSYL.js";import"./chunk.PZ7KY6XH.js";import"./chunk.WEMUKZKH.js";import"./chunk.T27QKVKP.js";import"./chunk.WVUJXDXZ.js";import"./chunk.DWM7AR5Y.js";import"./chunk.6KJGRM7A.js";import"./chunk.WALVW3KJ.js";import"./chunk.SNHKYH72.js";import"./chunk.UGQYMN4J.js";import"./chunk.RG5G6YQD.js";import"./chunk.MIE4TJRW.js";import"./chunk.QRQ5WPZI.js";import"./chunk.RD2FSSLV.js";import"./chunk.37RFCHSS.js";import"./chunk.SO6NT5K7.js";import"./chunk.MUSMNKE4.js";import"./chunk.SJQPTDAT.js";import"./chunk.JQ63N4MZ.js";import"./chunk.Z3O2VZAJ.js";import"./chunk.QNP5OR3P.js";import"./chunk.4W57E7AX.js";import{G as B,Va as k,W as L}from"./chunk.A5PSEU3W.js";import"./chunk.SDO3U72B.js";import{td as R}from"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import{b as E}from"./chunk.AJZBJBMO.js";var r=E(B(),1);var s=E(L(),1);function M(c){let e=document.activeElement;if(e!==null&&e!==document.body&&e!==document.documentElement&&e.isConnected)return;let n=c??document,o=n.querySelector("main")??n.querySelector("[data-graview-page]")??null,t=n.querySelector("[data-graview-page-title]")??o?.querySelector("h1, h2")??o;t instanceof HTMLElement&&(t.hasAttribute("tabindex")||t.setAttribute("tabindex","-1"),t.focus({preventScroll:!0}))}var I=1500;function N(c,e,n){let{store:o,principal:t}=c,l=z(o),g=(0,r.useMemo)(()=>P(o,t),[o,t,l]),w=(0,r.useRef)(n),[b,d]=(0,r.useState)(),[y,u]=(0,r.useState)("");(0,r.useEffect)(()=>{let a=A(o,t,w.current);w.current=o.batches().length,a&&(d({batch:a.batch,at:e,when:Date.now()}),u(""))},[o,t,l]),(0,r.useEffect)(()=>{d(a=>!a||a.at===e?a:Date.now()-a.when<I?{...a,at:e}:void 0)},[e]);let[x,i]=(0,r.useState)(null),v=(0,r.useCallback)(()=>{d(void 0),i(null)},[]),f=(0,r.useCallback)(()=>{i(null);try{let a=W(o,t);a&&u(`Took back \u201C${a.intent}\u201D`)}catch(a){i(a instanceof Error?a.message:String(a))}},[o,t]),S=g&&b?.batch===g.batch&&b.at===e?g:void 0;return{change:g,offered:S,close:v,takeBack:f,refused:x,said:y}}function ee({context:c,docked:e,at:n,since:o,compact:t=!1,className:l,size:g}){let{change:w,offered:b,close:d,takeBack:y,refused:u,said:x}=N(c,n,o),i=e?b:w,v=(0,r.useRef)(null),f=e&&(i!==void 0||u!==null);j(v,f),(0,r.useEffect)(()=>{if(!f)return;let m,h=()=>m=setTimeout(()=>v.current?.matches(":hover, :focus-within")?h():d(),1e4);return h(),()=>clearTimeout(m)},[f,i?.batch,u,d]);let S=x||(e&&i?p(i):""),a=e?{position:"fixed",inset:"auto",margin:0,padding:0,border:"none",background:"none",overflow:"visible",zIndex:R("toast"),width:"max-content",height:"auto",bottom:"calc(16px + env(safe-area-inset-bottom, 0px))",left:16,justifyItems:"start",color:"var(--graview-ink)",...f?{}:{display:"none"}}:{},T=i?(0,s.jsxs)("button",{type:"button","data-testid":"page-undo",title:`${p(i)} \u2014 \u2318Z or Ctrl+Z`,"aria-keyshortcuts":"Meta+Z Control+Z",onClick:m=>{let h=m.currentTarget.closest("[data-graview-face]");y(),requestAnimationFrame(()=>M(h))},...e?{style:U}:{className:H("graview-undo",l),...D(g),...t?{"data-compact":"","aria-label":p(i)}:{}},children:[(0,s.jsx)("span",{"aria-hidden":"true",children:"\u21B6"}),e?(0,s.jsx)("span",{style:K,children:p(i)}):(0,s.jsx)("span",{className:"graview-undo-words",children:t?"Undo":p(i)})]}):null;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{role:"status","aria-live":"polite",style:V,children:S}),(0,s.jsxs)("div",{ref:v,...e?{popover:"manual","data-graview-foot":"","data-graview-offstage":""}:{},"data-testid":e?"face-undo-dock":"page-undo-place",...e?{style:{...F,...a}}:{className:"graview-undo-place"},children:[e?null:(0,s.jsx)("style",{children:q}),e&&i?(0,s.jsxs)("div",{"data-testid":"page-undo-notice",style:Z,children:[T,(0,s.jsx)("button",{type:"button","data-testid":"page-undo-dismiss","aria-label":`Dismiss: ${p(i)}`,title:"Dismiss",onClick:m=>{let h=m.currentTarget.closest("[data-graview-face]");d(),requestAnimationFrame(()=>M(h))},style:$,children:"\xD7"})]}):T,u?(0,s.jsx)("span",{"data-testid":"page-undo-refused",role:"alert",className:"graview-undo-refused",...e?{style:{fontSize:"0.8125rem",lineHeight:1.4,color:"var(--graview-warn)",borderRadius:6,background:"var(--graview-float)",padding:"4px 8px"}}:{},children:u}):null]})]})}function j(c,e){(0,r.useLayoutEffect)(()=>{let n=c.current;if(!n||!e)return;if(typeof n.showPopover=="function"&&!k(n))try{n.showPopover()}catch{}let o=()=>n.parentElement?.closest("[data-embed-content]")??null,t=()=>{O(n,o()),dispatchEvent(new Event(C))};t(),addEventListener("resize",t),addEventListener("scroll",t,!0);let l=typeof ResizeObserver=="function"?new ResizeObserver(t):null;return l?.observe(n),()=>{if(l?.disconnect(),removeEventListener("resize",t),removeEventListener("scroll",t,!0),n.isConnected&&k(n))try{n.hidePopover()}catch{}dispatchEvent(new Event(C))}},[c,e])}var q=`:where(.graview-undo-place){display:grid;justify-items:end;gap:4px;max-width:100%;min-width:0}
2
+ :where(.graview-undo){box-sizing:border-box;display:inline-flex;align-items:center;gap:6px;min-height:var(--graview-control-height,36px);max-width:min(100%,var(--graview-undo-widest,18rem));min-width:0;padding:0 14px;border-radius:999px;border:1px solid var(--graview-edge);background:var(--graview-float);color:var(--graview-ink);font:inherit;font-size:.875rem;cursor:pointer}
3
+ :where(.graview-undo[data-size=sm]){--graview-control-height:30px}
4
+ :where(.graview-undo[data-compact]){padding:0 10px}
5
+ :where(.graview-undo-words){min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
6
+ :where(.graview-undo-refused){font-size:.8125rem;line-height:1.4;color:var(--graview-warn);border-radius:6px}`,F={display:"grid",justifyItems:"end",gap:4,maxWidth:"100%",minWidth:0},U={display:"inline-flex",alignItems:"center",gap:6,minHeight:36,maxWidth:"100%",minWidth:0,borderRadius:999,font:"inherit",fontSize:"0.875rem",cursor:"pointer",textAlign:"start",lineHeight:1.4,padding:"8px 4px 8px 14px",border:"none",background:"none",color:"inherit"},Z={display:"flex",alignItems:"center",gap:2,maxWidth:"100%",minWidth:0,paddingRight:6,borderRadius:"var(--graview-radius, 12px)",border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)"},$={flex:"0 0 auto",minWidth:28,minHeight:28,padding:0,border:"none",background:"none",boxShadow:"none",color:"var(--graview-ink-muted)",font:"inherit",fontSize:"1rem",cursor:"pointer"},K={minWidth:0,overflow:"hidden",overflowWrap:"anywhere",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:4},V={position:"absolute",width:1,height:1,margin:-1,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0};export{ee as TakeBack};
@@ -0,0 +1 @@
1
+ import{$ as z,Ac as ne,Cb as H,Cc as te,Db as U,Dc as oe,Eb as X,Ec as I,Fb as Z,Fc as R,Gc as E,Jc as P,Kd as ie,L,Mc as N,R as G,U as F,Y as T,jc as Q,ob as Y,pb as v,ra as J,wc as O,yb as q,zc as ee}from"./chunk.ZEZUKRC6.js";import{j as y}from"./chunk.FQLNBIQ5.js";var re=e=>q(e).id??e.session;function j(e,i={}){let n=O(e),o=new Map,t=i.advisory===!0;for(let s of e){if(s.vote===void 0||s.withheld||n.has(s.id)||s.vote.advisory===!0!==t)continue;let a=t?s.vote.voter:re(s.author);if(a===void 0)continue;let r=o.get(s.vote.suggestion);r||o.set(s.vote.suggestion,r=new Map),s.vote.vote===null?r.delete(a):r.set(a,s.vote.vote)}return o}function se(e){let i=0,n=0;for(let o of e?.values()??[])o==="for"?i++:n++;return{for:i,against:n}}function he(e,i,n){let o=I(i)?R(i):void 0,t=i&&(o===void 0?re(i):void 0),s=o!==void 0?n?.get(o):t!==void 0?e?.get(t):void 0,a=se(n);return{...se(e),...s!==void 0?{mine:s}:{},...a.for+a.against>0?{advisory:a}:{}}}var V=(e,i)=>e.expiresAt!==void 0&&Date.parse(e.expiresAt)<=Date.parse(i),Se=(e,i,n)=>(e??[]).some(o=>o.suggestion===i&&(o.until===void 0||Date.parse(o.until)>Date.parse(n)));function ae(e,i=()=>!0,n={}){let o=O(e),t=Ae(e),s=n.now??new Date().toISOString(),a,r;return e.filter(d=>d.suggests&&!d.withheld&&!o.has(d.id)&&t.get(d.id)!=="all"&&!V(d,s)&&!Se(n.dismissed,d.id,s)).flatMap(({id:d,batch:u,suggests:l,suggestsSaid:c,intent:g,batchIntent:p,author:S,lineage:w,at:f,expiresAt:me})=>{let B=t.get(d),M=ve(l,c,g).filter(h=>!B?.has(h.at));if(M.length===0)return[];let _=M.map(h=>h.call),W=new Set;return JSON.stringify(_.map(h=>h.args),(h,D)=>(typeof D=="string"&&i(D)&&W.add(D),D)),[{id:d,batch:u,calls:_,intent:B?M.map(h=>h.intent).join("; "):g,...p!==void 0?{headline:p}:{},items:M,author:S,...w?{lineage:w}:{},at:f,expiresAt:me,about:[...W],tally:he((a??=j(e)).get(d),n.voter,(r??=j(e,{advisory:!0})).get(d))}]})}function ve(e,i,n){let o=i&&i.length===e.length?i:void 0;return e.map((t,s)=>({at:s,call:t,intent:o?.[s]??(e.length===1?n:t.name)}))}function Ae(e){let i=new Map;for(let o of e){let t=o.lineage?.suggestion;if(t===void 0)continue;let s=o.lineage.items,a=i.get(t);if(a!=="all")if(s===void 0)i.set(t,"all");else{let r=a??new Set;for(let d of s)r.add(d);i.set(t,r)}}let n=new Map(e.filter(o=>o.suggests&&i.has(o.id)).map(o=>[o.id,o.suggests.length]));for(let[o,t]of i)t!=="all"&&n.has(o)&&t.size>=n.get(o)&&i.set(o,"all");return i}var le=e=>JSON.stringify(e,(i,n)=>n&&typeof n=="object"&&!Array.isArray(n)?Object.fromEntries(Object.entries(n).sort()):n);var we=/^(archive|unarchive|remove|leave-alone|allow-tidying)$/;function xe(e,i){let n=ie(e.name),o=i?.act(e.name),t=e.args??{},s=o?o.derived:Q(n),{id:a}=t;if(s&&typeof a=="string"){if(we.test(s.act))return[s.act,a];if(s.act==="merge")return["merge",...[a,t.into].sort()];if(s.relation)return[s.act,s.relation,a,t.to]}let r=o?.subject?.arg??"id",[d,u]=Object.keys(t).filter(l=>l!==r);return o?.connects?.length===1&&d&&!u&&i.has(t[r])&&i.has(t[d])?["connect",o.connects[0],t[r],t[d]]:[n,o?.creates?.length&&typeof a=="string"&&!i.has(a)?{...t,id:0}:t]}var A=(e,i)=>`\u2248${le(e.map(n=>xe(n,i)))}`,de=e=>`\u2248${le([["connect",e.kind,e.from,e.to]])}`;function ue(e,i,n,o){let t=C(e,n,o);return[i,...i.map(s=>[s])].map(s=>t.get(A(s,n))).find(Boolean)}function C(e,i,n){let o=O(e),t=new Map(e.map(r=>[r.id,r])),s=new Map;for(let[r,d]of Object.entries(n??{}))o.has(d.id)||s.set(r,d);let a=new Map;for(let r of e)r.lineage?.suggestion!==void 0&&r.lineage.items&&a.set(r.lineage.suggestion,[...a.get(r.lineage.suggestion)??[],...r.lineage.items]);for(let r of e){let d=!o.has(r.id)&&!r.withheld,u=r.author.kind==="human",l=r.undoes!==void 0&&d?t.get(r.undoes):void 0;if(l?.suggests&&l.author.kind===r.author.kind&&l.author.id===r.author.id)continue;let c=l?.mutation&&l.undoes===void 0&&(l.lineage||r.undoneLineage||u),g=l?.suggests?l.suggests.filter((p,S)=>!a.get(l.id)?.includes(S)):c?[l.mutation]:[];if(g.length>0)for(let p of[g,...g.map(S=>[S])])s.set(A(p,i),r);if(!(!d||!u||r.undoes!==void 0))for(let p of r.primitives)p.op==="remove-edge"?s.set(de(p.edge),r):p.op==="add-edge"&&s.delete(de(p.edge))}return s}function ge(e){return Object.fromEntries([...e].map(([i,n])=>[i,{id:n.id,at:n.at,author:n.author,...n.undoes!==void 0&&{undoes:n.undoes}}]))}function ce(e,i){return e.ops.length>0&&e.ops.every(n=>n.suggests!==void 0||n.undoes!==void 0&&i(n.undoes)?.suggests!==void 0)}var K=e=>[...e].length;function Oe(e){let i,n=0,o=0;for(let t of e.ops){let s=t.mutation?.name===Z&&t.withheld!==!0&&t.undoes===void 0?t.mutation.args:void 0;if(typeof s?.node!="string"||typeof s.field!="string"||i&&(i.node!==s.node||i.field!==s.field))return;i={node:s.node,field:s.field};for(let a of t.primitives)a.op==="splice-text"?(n+=K(a.inserted),o+=K(a.removed)):a.op==="patch-node"&&typeof a.after[s.field]=="string"&&(n+=K(a.after[s.field]))}return i&&{...i,inserted:n,removed:o}}function be(e,i,n){let o=n.getNode(e.node)?.kind,t=[...e.inserted>0||e.removed===0?[`+${e.inserted}`]:[],...e.removed>0?[`\u2212${e.removed}`]:[]];return`Wrote in ${J(o?i.tryDefinition(o):void 0,e.field)} (${t.join(" ")})`}var b=e=>JSON.stringify([e.kind,e.id??"",e.name??""]),ke=e=>e.ops.find(i=>i.lineage?.run!==void 0)?.lineage?.run;function Me(e,i=()=>{}){let n=[];for(let o of e){if(ce(o,i))continue;if(!P(o.author)){let l=Oe(o),c=n.at(-1),g=l&&c&&"batch"in c&&b(c.batch.author)===b(o.author)&&c.typed?.node===l.node&&c.typed.field===l.field?c.typed:void 0;g?n[n.length-1]={batch:o,typed:{...g,batches:[...g.batches,o],inserted:g.inserted+l.inserted,removed:g.removed+l.removed}}:n.push(l?{batch:o,typed:{batches:[o],...l}}:{batch:o});continue}let t=ke(o),s=b(o.author),a=t!==void 0?n.findIndex(l=>"digest"in l&&l.digest.run===t&&b(l.digest.author)===s):n.length-1,r=n[a],d=r!==void 0&&"digest"in r&&b(r.digest.author)===s&&r.digest.run===t?r.digest:void 0,u=[...d?.batches??[],o];d&&n.splice(a,1),n.push({digest:{author:o.author,batches:u,things:De(u),at:o.at,...t!==void 0?{run:t}:{}}})}return n}var De=e=>e.reduce((i,n)=>i+(n.undone?0:n.ops.length),0),Ie=e=>{let i=Date.parse(e);if(Number.isNaN(i))return!1;let{minutes:n}=F(i,G());return n<6*60||n>=21*60};function Re(e,i=T(new Date().toISOString())??L()){let n=T(e.at)??e.at.slice(0,10),t=e.run!==void 0&&n===i&&[e.at,...(e.batches??[]).map(a=>a.at)].every(Ie)?"overnight":n===i?"today":`on ${z(n)}`,s=e.things===1?"one thing":`${e.things} things`;return e.author?.id?.startsWith("workflow:")&&e.author.name?`${e.author.name}: ${s} ${t}`:`Tidied ${s} ${t}`}N.declined=ue;N.kept=(e,i,n)=>ge(C(e,i,n));var m=e=>e,x=(e,i)=>i===void 0?{}:{[e]:i};function tn(e,i,n){let o=y(e)?.store??e,t=m(o),s=ne(n.lineage);if(s===void 0)throw new v("A suggestion says what it is based on: { basis, confidence? }");let a=n.author??t.by;if(n.expiresAt!==void 0&&Number.isNaN(Date.parse(n.expiresAt)))throw new v(`A suggestion expires at a time: "${n.expiresAt}" is not one (an ISO time, like 2026-10-23T06:00:00Z).`);let r=t.actMeanings(),d=A(i,r),u=$(o).find(f=>A(f.calls,r)===d);if(u)return o.log.get(u.id);t.refuseDeclined(i,a);let l=t.rehearsal();l.suggesting=!0;let c=l.applying(i,{author:a,lineage:s,...x("via",n.via)});if(c.ops.length===0)return;let g=[...new Set(c.ops.flatMap(f=>f.described??[]))],p=c.ops.filter(f=>f.mutation!==null&&f.author===a),S=i.length>1&&p.length===i.length?p.map(f=>f.intent):void 0,w={id:t.nextId(),seq:o.log.length,batch:t.mintBatch("batch"),author:a,intent:c.ops.map(f=>f.intent).join("; "),...x("batchIntent",n.intent),mutation:null,primitives:[],reads:[],writes:[],...g.length>0?{described:g}:{},at:t.now(),...x("via",n.via),lineage:s,suggests:i,...x("suggestsSaid",S),...x("expiresAt",n.expiresAt)};return o.log.append(w),o.notify(Y,[w]),w}function $(e,i,n={}){let o=y(e),t=o?.store??e,s=i??o?.principal,a=(s!==void 0?t.seenBy(s):t).log.all();return ae(a,r=>t.graph.has(r),{now:m(t).now(),dismissed:n.dismissed,voter:s})}function pe(e,i,n){let o=y(e),t=o?.store??e,s=n??o?.principal??m(t).by;return i.calls.every(a=>t.permits(a,s).ok)}function fe(e,i,n,o={}){let t=y(e)?.store??e,s=o.author??m(t).by;k(t,i,s);let a=t.applyAll([{name:oe,args:{suggestion:i,vote:n}}],{...o,author:s});return n===null?a:{...a,voted:n}}function k(e,i,n){let o=$(e,n).find(s=>s.id===i),t=o?void 0:e.log.get(i);if(t?.suggests&&V(t,m(e).now()))throw new v(`That suggestion expired on ${t.expiresAt.slice(0,10)}.`);if(!o)throw new v("That suggestion is no longer waiting: it was accepted or declined, or it is not one you can see.");return o}function on(e,i,n={}){let o=y(e)?.store??e,{items:t,...s}=n,a=s.author??m(o).by,r=k(o,i,a),d=t===void 0?r.items:r.items.filter(g=>t.includes(g.at));if(t!==void 0&&(t.length===0||d.length!==new Set(t).size))throw new v("Name the changes to accept by their place among those still waiting in the suggestion.");let u={...r,calls:d.map(g=>g.call)};if(!pe(o,u,a))return fe(o,i,"for",{...s,author:a});let l=o.log.get(i)?.suggests?.length??d.length,c=d.length<l?{items:d.map(g=>g.at)}:{};return o.applyAll(u.calls,{...s,author:a,lineage:{...r.lineage,suggestion:i,...c}})}function sn(e,i,n={}){let o=y(e)?.store??e,t=n.author??m(o).by,s=k(o,i,t);if(!pe(o,s,t))return fe(o,i,"against",{...n,author:t});let a=ye(s)&&n.intent===void 0?{intent:`Declined ${$e(je(s))} proposal: ${s.intent}`}:{};return o.undo(s.batch,{...n,...a,author:t})}function rn(e,i,n={}){let o=y(e)?.store??e,t=n.author??m(o).by,s=k(o,i,t);if(s.author.kind!==t.kind||s.author.id!==t.id)throw new v("Only who made a suggestion withdraws it: a person declines it (declineSuggestion).");return o.undo(s.batch,{...n,author:t})}var Pe={kind:"system",id:"tidying",name:"Graview, tidying",automated:!0};E.op=(e,i,n,o,t,s)=>{let a=e,{suggestion:r,vote:d}=n.args,u=k(a,r,t),l=I(t)?R(t):void 0,c=d==="for"?`For: ${u.intent}`:d==="against"?`Against: ${u.intent}`:`Withdraws a vote on: ${u.intent}`;return{id:i.id,seq:a.log.length,batch:o,author:t,intent:c,mutation:n,primitives:[],reads:[],writes:[],...u.about.length>0?{described:u.about}:{},at:i.at,...s.via!==void 0?{via:s.via}:{},vote:{suggestion:r,vote:d,...l!==void 0?{advisory:!0,voter:l}:{}}}};E.accepting=(e,i)=>{let n=e,o=n.tidying?.autoAcceptAt;if(o===void 0||i.vote?.vote!=="for")return;let t=i.vote.suggestion,s=$(n).find(u=>u.id===t);if(!s)return;let r=[...j(n.log.all()).get(t)??[]].filter(([,u])=>u==="for").map(([u])=>u);if(r.length<o)return;let d=P(s.author)?s.author:Pe;return{calls:s.calls,author:d,lineage:{...s.lineage,suggestion:t,voters:r.slice(0,ee)}}};var ye=e=>e.lineage?.proposedBy!==void 0,je=e=>e.author.name??e.author.id??"Somebody",$e=e=>/s$/i.test(e)?`${e}'`:`${e}'s`;function an(e,i,n,o){let t=y(e)?.store??e,s=m(t).actMeanings(),a=A(n,s),r=$(t,i).find(u=>ye(u)&&A(u.calls,s)===a);if(r)return t.log.get(r.id);let d={calls:n.map(({name:u,args:l})=>({name:u,args:l})),...x("intent",o)};return t.applyAll([{name:te,args:d}],{author:i}).ops.find(u=>u.suggests!==void 0)}function dn(e,i,n){if(!e||!e.grants.some(t=>t.propose!==void 0))return[];let o=new Set(H(e,i,n));return n.filter(t=>!o.has(t)&&U(t).some(s=>X(e,i,t.name,s)))}export{be as a,Me as b,Re as c,tn as d,$ as e,pe as f,fe as g,on as h,sn as i,rn as j,ye as k,an as l,dn as m};
@@ -1 +1 @@
1
- import{a as I,c as x}from"./chunk.DICM56FT.js";import"./chunk.MD36ZSM5.js";import"./chunk.L6FGKJ5H.js";import{b,c as A,j as v,q as w,s as O,v as G}from"./chunk.3CJLAJXP.js";import"./chunk.SDO3U72B.js";import{Vd as k,ke as E,re as S,se as W}from"./chunk.J24YPQ5I.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var F=(e,i)=>k(e,i).slice(1);function j(e,i){let l=e.split("/").filter(Boolean);return l.length===i.length&&l.every((s,h)=>s.startsWith(":")||s==="*"||s===i[h])}var $=["problems","search","map","places"];function R(e,i,l,s,h=[]){let{schema:r}=i,o=r.kinds,f=t=>{if(t.startsWith(w))return(t.slice(w.length).split("|")[0]??"").split("+").every(V=>o.includes(V));let y=O(t);return y!==null?o.includes(y):t.startsWith("edge:")||l.graph.getNode(t)!==void 0},[p="/",u]=e.path.split("?"),n=p.split("/").filter(Boolean),m=u?`?${u}`:"",d=n.length>0&&!$.includes(n[0])?o.find(t=>F(r,t)===n[0]):void 0,c=e.path;if(n[0]==="places"&&n.length===2)`/places/${n[1]}`!==E&&!s.some(t=>t.as===decodeURIComponent(n[1]))&&(c="/");else if(d){let t=n[1]===void 0?void 0:decodeURIComponent(n[1]);c=`/${F(r,d)}${t!==void 0&&l.graph.getNode(t)?.kind===d?`/${n[1]}`:""}${m}`}else n.length>0&&n.length<=2&&!$.includes(n[0])&&!h.some(t=>j(t.path,n))&&(c="/");let g=A(e.stop),P=g.within?.view,U=P!==void 0&&!s.some(t=>t.as===P),a=g;if(U){let{view:t,...y}=g.within??{};a={...a,within:y}}if(g.focusId&&!f(g.focusId)){let t=e.kind&&o.includes(e.kind)?G(e.kind):null;a={...v(a,t),zoom:!1}}return a={...a,relation:a.relation&&(o.includes(a.relation)||r.edgeKinds.includes(a.relation))?a.relation:null,expanded:a.expanded.filter(f),pins:Object.fromEntries(Object.entries(a.pins).filter(([t])=>f(t))),...a.selection?{selection:a.selection.filter(f)}:{}},{face:e.face,path:c,stop:b(a),...e.kind?{kind:e.kind}:{}}}function B(e,i,l){let s=e.at,h=e.pages?.routes()??[];if(e.routing!=="address"||typeof window>"u")return R(s,e.app,i,l,h);let{pathname:r,search:o,hash:f}=window.location,p=W(r,e.basePath),u=I({routing:"address",...e.basePath===void 0?{}:{basePath:e.basePath},face:s.face}),n=u==="pages",m={...s,face:u,...p===null?{}:n?{path:p+o}:{stop:x(e.basePath)??s.stop}},d=R(m,e.app,i,l,h),c=n?d.path===m.path?null:S(d.path,e.basePath===void 0?{}:{basePath:e.basePath}):d.stop===b(A(m.stop))?null:r+o+d.stop;return p!==null&&c!==null&&c!==r+o+f&&window.history.replaceState(window.history.state,"",c),d}export{R as settle,B as settleAt};
1
+ import{a as I,c as x}from"./chunk.UDHPMVC4.js";import"./chunk.QNP5OR3P.js";import"./chunk.4W57E7AX.js";import{b,c as A,j as v,q as w,s as O,v as G}from"./chunk.A5PSEU3W.js";import"./chunk.SDO3U72B.js";import{Zd as k,oe as E,ve as S,we as W}from"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var F=(e,i)=>k(e,i).slice(1);function j(e,i){let l=e.split("/").filter(Boolean);return l.length===i.length&&l.every((s,h)=>s.startsWith(":")||s==="*"||s===i[h])}var $=["problems","search","map","places"];function R(e,i,l,s,h=[]){let{schema:r}=i,o=r.kinds,f=t=>{if(t.startsWith(w))return(t.slice(w.length).split("|")[0]??"").split("+").every(V=>o.includes(V));let y=O(t);return y!==null?o.includes(y):t.startsWith("edge:")||l.graph.getNode(t)!==void 0},[p="/",u]=e.path.split("?"),n=p.split("/").filter(Boolean),m=u?`?${u}`:"",d=n.length>0&&!$.includes(n[0])?o.find(t=>F(r,t)===n[0]):void 0,c=e.path;if(n[0]==="places"&&n.length===2)`/places/${n[1]}`!==E&&!s.some(t=>t.as===decodeURIComponent(n[1]))&&(c="/");else if(d){let t=n[1]===void 0?void 0:decodeURIComponent(n[1]);c=`/${F(r,d)}${t!==void 0&&l.graph.getNode(t)?.kind===d?`/${n[1]}`:""}${m}`}else n.length>0&&n.length<=2&&!$.includes(n[0])&&!h.some(t=>j(t.path,n))&&(c="/");let g=A(e.stop),P=g.within?.view,U=P!==void 0&&!s.some(t=>t.as===P),a=g;if(U){let{view:t,...y}=g.within??{};a={...a,within:y}}if(g.focusId&&!f(g.focusId)){let t=e.kind&&o.includes(e.kind)?G(e.kind):null;a={...v(a,t),zoom:!1}}return a={...a,relation:a.relation&&(o.includes(a.relation)||r.edgeKinds.includes(a.relation))?a.relation:null,expanded:a.expanded.filter(f),pins:Object.fromEntries(Object.entries(a.pins).filter(([t])=>f(t))),...a.selection?{selection:a.selection.filter(f)}:{}},{face:e.face,path:c,stop:b(a),...e.kind?{kind:e.kind}:{}}}function B(e,i,l){let s=e.at,h=e.pages?.routes()??[];if(e.routing!=="address"||typeof window>"u")return R(s,e.app,i,l,h);let{pathname:r,search:o,hash:f}=window.location,p=W(r,e.basePath),u=I({routing:"address",...e.basePath===void 0?{}:{basePath:e.basePath},face:s.face}),n=u==="pages",m={...s,face:u,...p===null?{}:n?{path:p+o}:{stop:x(e.basePath)??s.stop}},d=R(m,e.app,i,l,h),c=n?d.path===m.path?null:S(d.path,e.basePath===void 0?{}:{basePath:e.basePath}):d.stop===b(A(m.stop))?null:r+o+d.stop;return p!==null&&c!==null&&c!==r+o+f&&window.history.replaceState(window.history.state,"",c),d}export{R as settle,B as settleAt};