graview 0.1.70 → 0.1.72

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 (235) hide show
  1. package/dist/preview/chunk.2IOJNFCR.js +1 -0
  2. package/dist/preview/{chunk.I7CSRZC2.js → chunk.2Q4ZXP7P.js} +1 -1
  3. package/dist/preview/{chunk.O2XPLDMM.js → chunk.2TTKQAWQ.js} +1 -1
  4. package/dist/preview/chunk.2YSE3SQN.js +23 -0
  5. package/dist/preview/{chunk.NZFO6BM3.js → chunk.2ZPR6FRI.js} +1 -1
  6. package/dist/preview/chunk.3BE4SHZD.js +1 -0
  7. package/dist/preview/{chunk.QODVFVWE.js → chunk.43HWCHBN.js} +1 -1
  8. package/dist/preview/{chunk.QILGAV7H.js → chunk.45OLF6BK.js} +1 -1
  9. package/dist/preview/{chunk.NTAC5NNE.js → chunk.47QWCVZD.js} +1 -1
  10. package/dist/preview/{chunk.7HNMG6LG.js → chunk.4A7BRBEA.js} +1 -1
  11. package/dist/preview/chunk.4EPCI6VY.js +1 -0
  12. package/dist/preview/{chunk.OXXZGPJZ.js → chunk.4PB5UFUJ.js} +1 -1
  13. package/dist/preview/{chunk.SWY6DIE4.js → chunk.4TDYDIIM.js} +3 -3
  14. package/dist/preview/{chunk.6VG2LCES.js → chunk.4VX7GPFS.js} +1 -1
  15. package/dist/preview/{chunk.TUVPQLFL.js → chunk.523X2YEQ.js} +1 -1
  16. package/dist/preview/{chunk.CHG522KL.js → chunk.53GQQETN.js} +1 -1
  17. package/dist/preview/{chunk.NBB5ALVJ.js → chunk.5MKZTHU2.js} +1 -1
  18. package/dist/preview/chunk.5OS4SYHE.js +1 -0
  19. package/dist/preview/{chunk.ZTHZHBVN.js → chunk.5ZT4R227.js} +1 -1
  20. package/dist/preview/{chunk.RIP2SAQ5.js → chunk.65SI77M7.js} +1 -1
  21. package/dist/preview/chunk.6ESAFTWB.js +1 -0
  22. package/dist/preview/chunk.6GUIFP2A.js +1 -0
  23. package/dist/preview/{chunk.M3HLZX6Q.js → chunk.6GZYKHEN.js} +1 -1
  24. package/dist/preview/{chunk.UVMHC6VM.js → chunk.6YKKZI4H.js} +1 -1
  25. package/dist/preview/{chunk.BBLA4PSP.js → chunk.73RMM4W7.js} +1 -1
  26. package/dist/preview/chunk.7DCBIMOI.js +1 -0
  27. package/dist/preview/chunk.7JE3J7H4.js +1 -0
  28. package/dist/preview/{chunk.YTRUZ56A.js → chunk.7QGDWAHH.js} +1 -1
  29. package/dist/preview/{chunk.JEQ6CA5M.js → chunk.7VCYVCYM.js} +2 -2
  30. package/dist/preview/{chunk.X7HMTN3Z.js → chunk.A4TBVXHQ.js} +1 -1
  31. package/dist/preview/{chunk.J4NY2K2A.js → chunk.A6LJPXJ3.js} +1 -1
  32. package/dist/preview/chunk.AAPXF6NP.js +1 -0
  33. package/dist/preview/chunk.APUICV5Z.js +1 -0
  34. package/dist/preview/chunk.ASNVH2G4.js +25 -0
  35. package/dist/preview/{chunk.CM7EDQ4E.js → chunk.CJHCUHVN.js} +1 -1
  36. package/dist/preview/chunk.CUEPNS3Z.js +1 -0
  37. package/dist/preview/{chunk.U3CV227I.js → chunk.CUJRWBPX.js} +1 -1
  38. package/dist/preview/{chunk.7TZXDPPO.js → chunk.D5PW6YWF.js} +3 -3
  39. package/dist/preview/chunk.DCIYOZYP.js +1 -0
  40. package/dist/preview/chunk.DEBW4FH6.js +1 -0
  41. package/dist/preview/{chunk.MR776WQ2.js → chunk.DYPSFTRP.js} +1 -1
  42. package/dist/preview/{chunk.BBMX3IIO.js → chunk.E6QZUT4L.js} +1 -1
  43. package/dist/preview/chunk.E7QZZRAQ.js +17 -0
  44. package/dist/preview/chunk.EHCMBAZO.js +3 -0
  45. package/dist/preview/chunk.EXTD5JWD.js +1 -0
  46. package/dist/preview/{chunk.KOVTQCHX.js → chunk.EZF2T3XQ.js} +1 -1
  47. package/dist/preview/chunk.EZSST3IU.js +1 -0
  48. package/dist/preview/{chunk.DIVANC3G.js → chunk.F2BZ4SC4.js} +1 -1
  49. package/dist/preview/chunk.F2I7ERGM.js +1 -0
  50. package/dist/preview/{chunk.UWEFODVV.js → chunk.FCV3NX6L.js} +1 -1
  51. package/dist/preview/{chunk.NZ5TJKPT.js → chunk.FFTBUXKX.js} +2 -2
  52. package/dist/preview/chunk.FILBI7XA.js +1 -0
  53. package/dist/preview/{chunk.MGG5DH2S.js → chunk.FKSI5522.js} +1 -1
  54. package/dist/preview/{chunk.I3ADXJQW.js → chunk.FQ2QUDZS.js} +1 -1
  55. package/dist/preview/{chunk.A5ENJJZN.js → chunk.G2ZDDO3C.js} +1 -1
  56. package/dist/preview/{chunk.IPKODEOZ.js → chunk.GAVEWSXU.js} +1 -1
  57. package/dist/preview/chunk.GH6QX7JR.js +87 -0
  58. package/dist/preview/chunk.GMHBAS45.js +1 -0
  59. package/dist/preview/{chunk.YCMMATFK.js → chunk.GOVRX2YX.js} +1 -1
  60. package/dist/preview/chunk.GXK5PI7I.js +1 -0
  61. package/dist/preview/{chunk.RECTEAG4.js → chunk.GYP3EF6Z.js} +1 -1
  62. package/dist/preview/chunk.H2RVMT4Y.js +111 -0
  63. package/dist/preview/chunk.HCHGKI64.js +1 -0
  64. package/dist/preview/chunk.HE7SAJKZ.js +1 -0
  65. package/dist/preview/{chunk.WAIIXXVI.js → chunk.HIIYDKFC.js} +2 -2
  66. package/dist/preview/chunk.HPDUGKEF.js +32 -0
  67. package/dist/preview/{chunk.DGDOZHYK.js → chunk.HQRPOGTS.js} +1 -1
  68. package/dist/preview/chunk.HUJLELZ3.js +1 -0
  69. package/dist/preview/chunk.HVRUHRXR.js +1 -0
  70. package/dist/preview/{chunk.6KYTCEIH.js → chunk.I46VNAMS.js} +1 -1
  71. package/dist/preview/{chunk.QAERSZVB.js → chunk.ID4GOKT6.js} +1 -1
  72. package/dist/preview/{chunk.RJ7UV3XI.js → chunk.IZKCTF2R.js} +1 -1
  73. package/dist/preview/chunk.IZUAZ6EV.js +1 -0
  74. package/dist/preview/{chunk.ZIGW5VOT.js → chunk.J3CUBMUZ.js} +1 -1
  75. package/dist/preview/{chunk.3HFBHLXC.js → chunk.J4D4BIB4.js} +1 -1
  76. package/dist/preview/{chunk.IRPMGHZN.js → chunk.J7GH2CGV.js} +1 -1
  77. package/dist/preview/{chunk.SSHEFQ4R.js → chunk.JE4RBRKH.js} +1 -1
  78. package/dist/preview/{chunk.4BSEYZMS.js → chunk.JJSZLCNU.js} +1 -1
  79. package/dist/preview/{chunk.KV3N6VRG.js → chunk.JKX4J3KG.js} +1 -1
  80. package/dist/preview/{chunk.FUTSLXWN.js → chunk.JMXBMLKH.js} +1 -1
  81. package/dist/preview/chunk.JOB3EKS6.js +1 -0
  82. package/dist/preview/{chunk.5IM2X3VT.js → chunk.JP33TNCH.js} +1 -1
  83. package/dist/preview/{chunk.BZXJKWNI.js → chunk.K6EN2YR4.js} +1 -1
  84. package/dist/preview/chunk.K6YKXTKC.js +1 -0
  85. package/dist/preview/{chunk.A7JORJJL.js → chunk.KAIZDIRK.js} +1 -1
  86. package/dist/preview/{chunk.7LAXSQQY.js → chunk.KAQGSLC6.js} +3 -3
  87. package/dist/preview/{chunk.QG3LV4RH.js → chunk.KFYSKZC4.js} +1 -1
  88. package/dist/preview/{chunk.VBHV4TLG.js → chunk.KHRS2SKB.js} +1 -1
  89. package/dist/preview/chunk.KHVW6Q3T.js +1 -0
  90. package/dist/preview/chunk.KMFH26SS.js +1 -0
  91. package/dist/preview/{chunk.2T24FYAO.js → chunk.L3ST2YKI.js} +1 -1
  92. package/dist/preview/{chunk.HIJ72QX6.js → chunk.L6BLZJ6K.js} +1 -1
  93. package/dist/preview/{chunk.NCBUECIW.js → chunk.LG2BQ5LB.js} +1 -1
  94. package/dist/preview/{chunk.LZ3HO3HM.js → chunk.LLYHHG67.js} +1 -1
  95. package/dist/preview/{chunk.VKQONZKR.js → chunk.LPWANRBL.js} +1 -1
  96. package/dist/preview/{chunk.3MPLUSVY.js → chunk.LSS64NAA.js} +1 -1
  97. package/dist/preview/{chunk.SUYYDJGZ.js → chunk.MFNWHXGL.js} +1 -1
  98. package/dist/preview/{chunk.UJF6YTEO.js → chunk.MNH3WUAB.js} +1 -1
  99. package/dist/preview/chunk.MQ7AB5N4.js +1 -0
  100. package/dist/preview/{chunk.CZUUFO6A.js → chunk.MU5JK5TK.js} +1 -1
  101. package/dist/preview/{chunk.RXUL6P7Y.js → chunk.N5CACZ5F.js} +1 -1
  102. package/dist/preview/{chunk.S6IKR6RD.js → chunk.NFC2TYA6.js} +1 -1
  103. package/dist/preview/{chunk.TD2V74XU.js → chunk.NKRDVOLJ.js} +1 -1
  104. package/dist/preview/{chunk.SGYZM6ZU.js → chunk.NNK2E2EP.js} +1 -1
  105. package/dist/preview/{chunk.J65CZJIC.js → chunk.NVPKYWMF.js} +1 -1
  106. package/dist/preview/{chunk.DWMFLLJO.js → chunk.NWJ7ELHN.js} +1 -1
  107. package/dist/preview/{chunk.NKUNCQB3.js → chunk.O5P6LXHF.js} +1 -1
  108. package/dist/preview/{chunk.2MWEYNVH.js → chunk.OFK6673S.js} +1 -1
  109. package/dist/preview/{chunk.C4LC2UEU.js → chunk.OG6FEP3K.js} +1 -1
  110. package/dist/preview/{chunk.CZI6J5CE.js → chunk.OHGAZ3D5.js} +1 -1
  111. package/dist/preview/{chunk.XJ4JYROM.js → chunk.ONVYKLRX.js} +1 -1
  112. package/dist/preview/chunk.OQ3FKUP2.js +1 -0
  113. package/dist/preview/chunk.OUJV4CYS.js +1 -0
  114. package/dist/preview/{chunk.T552MHMU.js → chunk.OWHH7JDV.js} +1 -1
  115. package/dist/preview/{chunk.SCN6IYDG.js → chunk.OXDCGGZV.js} +1 -1
  116. package/dist/preview/{chunk.YIDNZTON.js → chunk.P3Z4ZCL3.js} +1 -1
  117. package/dist/preview/chunk.PF7XQ5R5.js +1 -0
  118. package/dist/preview/{chunk.FSZQTX3K.js → chunk.PGT4ZQDG.js} +4 -4
  119. package/dist/preview/chunk.PH547SON.js +1 -0
  120. package/dist/preview/chunk.PS765ODQ.js +3 -0
  121. package/dist/preview/{chunk.MZSWWMX6.js → chunk.PVAYYFT2.js} +1 -1
  122. package/dist/preview/{chunk.F5STM4DX.js → chunk.Q6WOIE5I.js} +1 -1
  123. package/dist/preview/{chunk.55C7WO4X.js → chunk.QE257AXE.js} +1 -1
  124. package/dist/preview/chunk.QKNC5OUC.js +1 -0
  125. package/dist/preview/chunk.QMGBAKX6.js +2 -0
  126. package/dist/preview/{chunk.4QBW46XV.js → chunk.QNFX5VHW.js} +1 -1
  127. package/dist/preview/chunk.QPCDAQTW.js +1 -0
  128. package/dist/preview/{chunk.TS5APXWC.js → chunk.QPTQIGLX.js} +1 -1
  129. package/dist/preview/{chunk.LZNHTROY.js → chunk.R5YGW5ZX.js} +1 -1
  130. package/dist/preview/{chunk.4VTUC5TF.js → chunk.RJ6KEVZC.js} +1 -1
  131. package/dist/preview/{chunk.6QMRDSTD.js → chunk.RKVMRP7B.js} +1 -1
  132. package/dist/preview/{chunk.YBQUP3KE.js → chunk.S7U2CHHG.js} +1 -1
  133. package/dist/preview/{chunk.CLJKQLK2.js → chunk.SD2UYSV6.js} +2 -2
  134. package/dist/preview/chunk.SI5GGFQR.js +1 -0
  135. package/dist/preview/{chunk.7QWGIGHM.js → chunk.SMF5S4DQ.js} +1 -1
  136. package/dist/preview/{chunk.LEZGBHPZ.js → chunk.SNDFIJVX.js} +1 -1
  137. package/dist/preview/{chunk.F5756PXX.js → chunk.STHWM422.js} +2 -2
  138. package/dist/preview/{chunk.JIEBGUCA.js → chunk.SV75TRCH.js} +1 -1
  139. package/dist/preview/{chunk.U2DZE7A5.js → chunk.SXGPRFA4.js} +1 -1
  140. package/dist/preview/{chunk.ZGJUCVT5.js → chunk.T3RFZ66S.js} +1 -1
  141. package/dist/preview/{chunk.I6HIVTXU.js → chunk.T6ISUVUP.js} +1 -1
  142. package/dist/preview/{chunk.R65YX332.js → chunk.TBLOBXZ2.js} +1 -1
  143. package/dist/preview/{chunk.CVVNHQPO.js → chunk.TDWJU6GW.js} +1 -1
  144. package/dist/preview/{chunk.2QALBEWP.js → chunk.THLT6NVO.js} +1 -1
  145. package/dist/preview/{chunk.7FTATAH2.js → chunk.TQCVEKPH.js} +1 -1
  146. package/dist/preview/{chunk.PAIBRJVZ.js → chunk.TQF5XCUS.js} +1 -1
  147. package/dist/preview/{chunk.F5XWYO5W.js → chunk.TRP66PHK.js} +1 -1
  148. package/dist/preview/chunk.TWXYI5AP.js +2 -0
  149. package/dist/preview/{chunk.IQCMV5WD.js → chunk.UOUQZYVD.js} +1 -1
  150. package/dist/preview/{chunk.FJXKQZZS.js → chunk.UPL3D3ZO.js} +1 -1
  151. package/dist/preview/{chunk.U5Q7EVZQ.js → chunk.UXW43HNW.js} +1 -1
  152. package/dist/preview/{chunk.ZOSTOVXR.js → chunk.V4GSVXSV.js} +1 -1
  153. package/dist/preview/chunk.VCEDSOAK.js +1 -0
  154. package/dist/preview/{chunk.4O3STSC4.js → chunk.VE4AQFLW.js} +1 -1
  155. package/dist/preview/{chunk.HMV4ILAC.js → chunk.VGQDPEB5.js} +1 -1
  156. package/dist/preview/{chunk.5A5DI36V.js → chunk.VMYXBFPE.js} +1 -1
  157. package/dist/preview/{chunk.BQWMHHAZ.js → chunk.VNI6HZEF.js} +2 -2
  158. package/dist/preview/chunk.VQRY2NQ6.js +1 -0
  159. package/dist/preview/{chunk.K6EKSURO.js → chunk.VUE6ILQV.js} +1 -1
  160. package/dist/preview/{chunk.3KF5RYPW.js → chunk.W2VSEEKX.js} +1 -1
  161. package/dist/preview/{chunk.KP7HUXH5.js → chunk.WAPY4RCS.js} +1 -1
  162. package/dist/preview/chunk.WFRSGGU5.js +1 -0
  163. package/dist/preview/{chunk.XAN7QXMQ.js → chunk.WIVNFOQR.js} +1 -1
  164. package/dist/preview/chunk.WRIBFLVG.js +1 -0
  165. package/dist/preview/{chunk.TVNY7F64.js → chunk.WWD2TS47.js} +1 -1
  166. package/dist/preview/{chunk.5W7EGQCQ.js → chunk.WWFOQDPR.js} +2 -2
  167. package/dist/preview/{chunk.FBDCHJS2.js → chunk.X45EITTK.js} +1 -1
  168. package/dist/preview/{chunk.5FQHZVE3.js → chunk.X5MCAUFX.js} +1 -1
  169. package/dist/preview/{chunk.IJVR7ZL7.js → chunk.XBWFQ54R.js} +1 -1
  170. package/dist/preview/{chunk.JPJHM62B.js → chunk.XMBGT6UT.js} +1 -1
  171. package/dist/preview/chunk.XP4IVKKR.js +1 -0
  172. package/dist/preview/chunk.XYBWBMNU.js +1 -0
  173. package/dist/preview/{chunk.MYR36HW4.js → chunk.YC2IDHQX.js} +1 -1
  174. package/dist/preview/{chunk.ZQSV5XVB.js → chunk.YCYJHPWS.js} +1 -1
  175. package/dist/preview/{chunk.BJ3G7J2Z.js → chunk.YF5GCOSZ.js} +3 -2
  176. package/dist/preview/{chunk.3I2SGKKF.js → chunk.YGGBGHZU.js} +1 -1
  177. package/dist/preview/chunk.YRC6PKXP.js +1 -0
  178. package/dist/preview/{chunk.6NYSB6OZ.js → chunk.YRN67Z5K.js} +1 -1
  179. package/dist/preview/chunk.ZDUKVXBI.js +5 -0
  180. package/dist/preview/index.html +55 -55
  181. package/dist/preview/page.js +2 -2
  182. package/package.json +6 -6
  183. package/dist/preview/chunk.2QOB62XU.js +0 -1
  184. package/dist/preview/chunk.36FKQJFM.js +0 -2
  185. package/dist/preview/chunk.3A3DCALP.js +0 -1
  186. package/dist/preview/chunk.3GPYKWAD.js +0 -1
  187. package/dist/preview/chunk.3QPMFUMV.js +0 -1
  188. package/dist/preview/chunk.3ZP6IDUC.js +0 -1
  189. package/dist/preview/chunk.53HW224Y.js +0 -1
  190. package/dist/preview/chunk.AW74DZ5V.js +0 -17
  191. package/dist/preview/chunk.C67TMA4U.js +0 -111
  192. package/dist/preview/chunk.CCCSZRKU.js +0 -1
  193. package/dist/preview/chunk.CUA7F3YJ.js +0 -25
  194. package/dist/preview/chunk.DBSSCJQM.js +0 -1
  195. package/dist/preview/chunk.DW6KXAUM.js +0 -1
  196. package/dist/preview/chunk.DWPM7AWA.js +0 -1
  197. package/dist/preview/chunk.FXCKKVT5.js +0 -1
  198. package/dist/preview/chunk.HHQUCFN4.js +0 -1
  199. package/dist/preview/chunk.HPWMCS3H.js +0 -23
  200. package/dist/preview/chunk.HRLCDBMO.js +0 -1
  201. package/dist/preview/chunk.I7ODVOO5.js +0 -1
  202. package/dist/preview/chunk.IANOWT3Z.js +0 -1
  203. package/dist/preview/chunk.IFPJPJ4M.js +0 -1
  204. package/dist/preview/chunk.IUVRJDL3.js +0 -5
  205. package/dist/preview/chunk.J4CSY2D5.js +0 -2
  206. package/dist/preview/chunk.JJIKTTXB.js +0 -1
  207. package/dist/preview/chunk.KDOJC4FX.js +0 -1
  208. package/dist/preview/chunk.KJAOJTZZ.js +0 -1
  209. package/dist/preview/chunk.KLZPUTMU.js +0 -1
  210. package/dist/preview/chunk.LQ2PDW2M.js +0 -32
  211. package/dist/preview/chunk.M7DJJRFH.js +0 -1
  212. package/dist/preview/chunk.MNWP3TPN.js +0 -1
  213. package/dist/preview/chunk.MSWOETXN.js +0 -1
  214. package/dist/preview/chunk.NILR2BWR.js +0 -1
  215. package/dist/preview/chunk.NNYKLENL.js +0 -1
  216. package/dist/preview/chunk.PYGNO2AV.js +0 -87
  217. package/dist/preview/chunk.PZHCWMKT.js +0 -1
  218. package/dist/preview/chunk.QQUZ5RTQ.js +0 -1
  219. package/dist/preview/chunk.QVID5WHS.js +0 -1
  220. package/dist/preview/chunk.RHV73CBA.js +0 -3
  221. package/dist/preview/chunk.RP6C2IUM.js +0 -1
  222. package/dist/preview/chunk.RPHZY7N4.js +0 -1
  223. package/dist/preview/chunk.RSMCTI2N.js +0 -1
  224. package/dist/preview/chunk.S4QSZRKH.js +0 -1
  225. package/dist/preview/chunk.T4QRIJE4.js +0 -1
  226. package/dist/preview/chunk.UJM5EZDM.js +0 -3
  227. package/dist/preview/chunk.UJPX3BUV.js +0 -1
  228. package/dist/preview/chunk.UYBSVE2W.js +0 -1
  229. package/dist/preview/chunk.WMZ2BINI.js +0 -1
  230. package/dist/preview/chunk.X2RHBTJI.js +0 -1
  231. package/dist/preview/chunk.X3FPVFFB.js +0 -1
  232. package/dist/preview/chunk.X4PFLIXB.js +0 -1
  233. package/dist/preview/chunk.YR7DKU5T.js +0 -1
  234. package/dist/preview/chunk.ZBK3FCVE.js +0 -1
  235. package/dist/preview/chunk.ZH5L746C.js +0 -1
@@ -0,0 +1,5 @@
1
+ import{a as Wr,b as le,c as tn,d as De,f as Oe,g as qr,h as rn,i as tt,j as Ct}from"./chunk.FQLNBIQ5.js";var Zt="en-US",it=/^\d{4}-\d{2}-\d{2}$/,Yr=/^\d{4}(?:-(?:0[1-9]|1[0-2]))?$/,Jr=/^\d{4}(?:-(?:0[1-9]|1[0-2])(?:-\d{2})?)?$/;function Ol(n){if(it.test(n))return{from:n,to:n};if(!Yr.test(n))return;if(n.length===4)return{from:`${n}-01-01`,to:`${n}-12-31`};let e=new Date(Date.UTC(+n.slice(0,4),+n.slice(5,7),0)).getUTCDate();return{from:`${n}-01`,to:`${n}-${String(e).padStart(2,"0")}`}}var Gt=/^\d{4}(-\d\d){2}[T ]\d\d:\d\d(:[\d.]+)?(Z|[+-][\d:]+)?$/,Rg=n=>!Number.isNaN(Date.parse(n)),te=(n,e=Date.now())=>{let t=Kt(n);return t?Xr(e,t).day:new Date(e).toISOString().slice(0,10)},Kt=n=>_n(n)??On,rt,An,ot,On;function _l(n){rt=Pn(n.reader),An=Pn(n.app),ot=_n(n.readerTimeZone),On=_n(n.appTimeZone)}function Pl(n,e){let t=[rt,An,ot,On];n.reader!==void 0&&(rt=Pn(n.reader)),n.app!==void 0&&(An=Pn(n.app)),n.readerTimeZone!==void 0&&(ot=_n(n.readerTimeZone)),n.appTimeZone!==void 0&&(On=_n(n.appTimeZone));try{return e()}finally{[rt,An,ot,On]=t}}var ss=n=>rt??Pn(n)??An??Zt,$g=n=>Pn(n)??An??Zt,Vt=n=>ot??_n(n)??On,El=n=>Vt(n)??Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",Ml=/^\s*([+\-−]|\d)/;var Hr=new Map;function _n(n){if(n&&!Hr.has(n)){let e=!1;try{new Intl.DateTimeFormat(Zt,{timeZone:n}),e=!Ml.test(n)}catch{}Hr.set(n,e)}return n&&Hr.get(n)?n:void 0}var on=new Map;function Pn(n){if(n&&!on.has(n)){let e=!1;try{e=Intl.DateTimeFormat.supportedLocalesOf(n).length>0}catch{}on.set(n,e)}return n&&on.get(n)?n:void 0}function Fe(n,e,t,r){let o=`${t=ss(t)}${r?"#":"@"}${JSON.stringify(e)}`,i=on.get(o);return i||on.set(o,i=r?new Intl.NumberFormat(t,e):new Intl.DateTimeFormat(t,e)),i.format(n).replace(/ /g," ")}var sn="UTC",Bt=n=>Date.UTC(+n.slice(0,4),+n.slice(5,7)-1,+n.slice(8,10));function Le(n,e){return Yr.test(n)?n.length===4?n:ls(n,{},e):it.test(n)?Fe(Bt(n),{year:"numeric",month:"short",day:"numeric",timeZone:sn},e):n}function Xr(n,e){let t=`wall@${e??""}`,r=on.get(t);r||on.set(t,r=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23",...e?{timeZone:e}:{}}));let o=Object.fromEntries(r.formatToParts(n).map(i=>[i.type,i.value]));return{day:`${o.year}-${o.month}-${o.day}`,minutes:Number(o.hour)%24*60+Number(o.minute)}}function as(n,e,t){let r=Date.UTC(+n.slice(0,4),+n.slice(5,7)-1,+n.slice(8,10),0,e),o=i=>{let s=Xr(i,t);return Nl(s.day,s.minutes)-Math.floor(i/6e4)*6e4};return r-o(r-o(r))}var Nl=(n,e)=>Date.UTC(+n.slice(0,4),+n.slice(5,7)-1,+n.slice(8,10),0,e),ds=n=>/[Z+-][\d:]*$/.test(n.slice(16));function cs(n,e,t,r,o=!1){if(!Gt.test(n))return n;let i=ds(n),s=Date.parse(n.replace(" ","T")+(i?"":"Z"));if(Number.isNaN(s))return n;let a=i?Vt(r):sn;return Fe(s,{...e,hour:"numeric",minute:"2-digit",...i&&o?{timeZoneName:"short"}:{},...a?{timeZone:a}:{}},t)}var Qr=(n,e,t)=>cs(n,{year:"numeric",month:"short",day:"numeric"},e,t,!0),zl=(n,e,t)=>cs(n,{},e,t);function Il(n,e){if(it.test(n))return n;if(!Gt.test(n))return;if(!ds(n))return n.slice(0,10);let t=Date.parse(n.replace(" ","T"));return Number.isNaN(t)?void 0:Xr(t,Vt(e)).day}function _e(n,e,t={maximumFractionDigits:2}){return Number.isFinite(n)?Fe(n,t,e,!0):String(n)}function Tl(n,e={},t){return it.test(n)?Fe(Bt(n),{weekday:e.weekday??"long",month:"short",day:"numeric",...e.year?{year:"numeric"}:{},timeZone:sn},t):n}function jl(n,e){return it.test(n)?Fe(Bt(n),{month:"short",day:"numeric",timeZone:sn},e):n}function ls(n,e={},t){if(!/^\d{4}-\d{2}/.test(n))return n;let r=e.year??!e.short;return Fe(Bt(`${n.slice(0,7)}-01`),{month:e.short?"short":"long",...r?{year:e.short?"2-digit":"numeric"}:{},timeZone:sn},t)}var Dl=(n,e="short",t)=>Fe(Date.UTC(1970,0,4+n),{weekday:e,timeZone:sn},t),Fl=(n,e)=>Fe(Date.UTC(1970,0,1,0,Math.round(n)),{hour:"numeric",minute:"2-digit",timeZone:sn},e),Ll=/(?<![\w-])(\d{4}-\d{2}-\d{2})(?![\w-]|:)/g;function eo(n,e){return n.includes("-")?n.replace(Ll,t=>Le(t,e)):n}var an=n=>n.charAt(0).toUpperCase()+n.slice(1),no=n=>/^.\p{Lu}/u.test(n)?n:n.charAt(0).toLowerCase()+n.slice(1),us=(n,e="and")=>n.length>1?`${n.slice(0,-1).join(", ")} ${e} ${n.at(-1)}`:n[0]??"",fs=n=>/^\S*\p{Ll}\p{Lu}|\s\p{Lu}\p{Ll}/u.test(n)?n:no(n);function B(n){let e=n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return an(e.replace(/\b[a-z]+\b/g,t=>ps.has(t)?t.toUpperCase():t.endsWith("s")&&ps.has(t.slice(0,-1))?`${t.slice(0,-1).toUpperCase()}s`:t))}var ps=new Set("id url uri api ip ioc cve cvss cwe cpe sku vat iban isbn pdf csv json html css sla kpi roi faq ssn ein vin gps sms crm erp seo utm ui ux ai dns ssl tls http https sql uuid mfa sso cto ceo cfo coo rsvp eta".split(" "));function dn(n){if(!hs(n))return B(n);let e=n.replace(/[_\s]+/g," ").trim();return an(e)}var hs=n=>/[A-Z]/.test(n)&&!/^[a-z][a-zA-Z0-9]*$/.test(n);function Pg(n){return hs(n)?dn(n):no(B(n))}function Cl(n,e){return{...e,kind:n,edges:e.edges??{}}}function to(n,e,t){let r=n?.lifecycle;if(!r)return!0;let o=e[r.field];return r.retired==="date"?typeof o!="string"||o.length===0?!0:o>=(t??te()):!r.retired.includes(o)}function V(n,e){if(n?.label)return n.label(e);let t=e.label;return typeof t=="string"&&t.length>0?t:e.id}function Zl(n){return n.title??B(n.name)}function Gl(n,e,t){let r=n.tryDefinition(e);return`${_e(t)} ${t===1?X(r,e):ue(n,e).toLowerCase()}`}function ue(n,e){return n.tryDefinition(e)?.plural??`${B(e).toLowerCase()}s`}function Kl(n,e){return an(ue(n,e))}function Vl(n,e){let t=ue(n,e);return`All ${/^[A-Z][a-z]/.test(t)?t.charAt(0).toLowerCase()+t.slice(1):t}`}function gs(n,e){let t=n?.computed&&Object.hasOwn(n.computed,e)?n.computed[e]:void 0;return n?.display?.labels?.[e]??(typeof t=="object"?t.label:void 0)??(e==="label"?"Name":B(e))}var Ut=(n,e)=>fs(gs(n,e)),Bl=/^(u[nt]i|use|usu|uti|ubiq|eu|ewe|one|once)/,Ul=/^(hour|honest|hono[ur]r?|heir)/;function ms(n){let e=B(n).toLowerCase();return Ul.test(e)?"an":Bl.test(e)?"a":/^[aeiou]/.test(e)?"an":"a"}function En(n){return`${ms(n)} ${B(n).toLowerCase()}`}function X(n,e){return n?.noun??B(e).toLowerCase()}function io(n){let e=Object.values(n).filter(r=>typeof r=="number");return Object.entries(n).filter(([r,o])=>e.indexOf(+r)===-1).map(([r,o])=>o)}function so(n,e="|"){return n.map(t=>fo(t)).join(e)}function bs(n,e){return typeof e=="bigint"?e.toString():e}var oo=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function vs(n){return new oo(n)}function ws(n){return n==null}function ao(n){let e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function ks(n,e){let t=n/e,r=Math.round(t),o=4*Number.EPSILON*Math.max(Math.abs(t),1);return Math.abs(t-r)<o?0:t-r}var ys=Symbol("evaluating");function xs(n,e,t){let r;Object.defineProperty(n,e,{get(){if(r!==ys)return r===void 0&&(r=ys,r=t()),r},set(o){Object.defineProperty(n,e,{value:o})},configurable:!0})}function qt(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function Ss(n){let e=Object.getOwnPropertyDescriptor(n,"shape");return e?.get?e.get.raw:e?.value}function co(n){return Ss(n._zod.def)??n._zod.def.shape}function Rs(n,e,t){Object.defineProperty(n,e,{get(){let r=t();return qt(this,e,r),r},enumerable:!0,configurable:!0})}function $s(n,e,t){e in n?qt(n,e,t):n[e]=t}function Wl(n,e,t,r){let o=co(e);for(let i of t){let s=Object.getOwnPropertyDescriptor(o,i);s.enumerable&&(s.get?Rs(n,i,()=>{let a=e._zod.def.shape[i];return r?r(a,i):a}):$s(n,i,r?r(s.value,i):s.value))}}function ql(n,e){for(let t of Reflect.ownKeys(e)){let r=Object.getOwnPropertyDescriptor(e,t);r.enumerable&&(r.get?Rs(n,t,()=>e[t]):$s(n,t,r.value))}}function As(...n){let e={};for(let t of n){let r=Object.getOwnPropertyDescriptors(t);Object.assign(e,r)}return Object.defineProperties({},e)}var lo="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function Wt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function uo(n){if(Wt(n)===!1)return!1;let e=n.constructor;if(e===void 0||typeof e!="function")return!0;let t=e.prototype;return!(Wt(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}var Os=new Set(["string","number","symbol"]);function at(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Mn(n,e,t){let r=new n._zod.constr(e??n._zod.def);return(!e||t?.parent)&&(r._zod.parent=n),r}function j(n){let e=n;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function fo(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function _s(n){return Object.keys(n).filter(e=>n[e]._zod.optin!==void 0&&n[e]._zod.optout==="optional")}var Ps={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Es(n,e){if(!uo(e))throw new Error("Invalid input to extend: expected a plain object");let t=n._zod.def.checks;if(t&&t.length>0){let o=co(n);for(let i of Reflect.ownKeys(e))if(Object.getOwnPropertyDescriptor(o,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Mn(n,As(n._zod.def,{shape:Hl(n,e)}))}function Hl(n,e){let t={};return Wl(t,n,Reflect.ownKeys(co(n))),ql(t,e),t}function Pe(n,e=0){if(n.aborted===!0)return!0;for(let t=e;t<n.issues.length;t++)if(n.issues[t]?.continue!==!0)return!0;return!1}function Ms(n,e=0){if(n.aborted===!0)return!0;for(let t=e;t<n.issues.length;t++)if(n.issues[t]?.continue===!1)return!0;return!1}function Ze(n,e){return e.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(n),t})}function st(n){return typeof n=="string"?n:n?.message}function po(n,e,t){var r;for(let o=e;o<n.length;o++)(r=n[o]).schema??(r.schema=t)}function Ee(n,e,t){var r;let o=n.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(r=n).schema??(r.schema=n.inst):n.schema=n.inst);let i=n.schema!==n.inst?n.schema?._zod.def?.error:void 0,s=n.message?n.message:st(n.inst?._zod.def?.error?.(n))??st(i?.(n))??st(e?.error?.(n))??st(t.customError?.(n))??st(t.localeError?.(n))??"Invalid input",a={};for(let d of Object.keys(n))d==="inst"||d==="schema"||d==="continue"||d==="input"||d==="__proto__"||(a[d]=n[d]);return a.path??(a.path=[]),a.message=s,e?.reportInput&&(a.input=n.input),a}var Yl=/[\uD800-\uDBFF]/;function ho(n){let e=n.length;if(!Yl.test(n))return e;let t=e;for(let r=0;r<e-1;r++)(n.charCodeAt(r)&64512)===55296&&(n.charCodeAt(r+1)&64512)===56320&&(t--,r++);return t}function go(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function Ns(n){let e=typeof n;switch(e){case"number":return Number.isNaN(n)?"nan":"number";case"object":{if(n===null)return"null";if(Array.isArray(n))return"array";let t=n;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&"constructor"in t&&t.constructor)return t.constructor.name}}return e}function dt(...n){let[e,t,r]=n;return typeof e=="string"?{message:e,code:"custom",input:t,inst:r}:{...e}}function zs(n,e){for(let t in e){let r=Object.getOwnPropertyDescriptor(e,t);r.get?Object.defineProperty(n,t,{...r,enumerable:!1}):Jl(n,t,r.value)}}function cn(n,e,t,r=!0){return Object.defineProperty(n,e,{configurable:!0,writable:!0,enumerable:r,value:t}),t}function mo(n,e,t){return cn(n,e,t,!1)}function Jl(n,e,t){Object.defineProperty(n,e,{configurable:!0,get(){return this==null?t:cn(this,e,t.bind(this))},set(r){cn(this,e,r)}})}function Xl(n,e){let t=Object.getPrototypeOf(n);return e in t?void 0:t}var ro,Ce=!1,Ql={configurable:!0,get(){Ce=!0}};function Q(n,e,t){let r=Object.getPrototypeOf(n._zod);if(e in r&&ro!==n._zod){ro=void 0;return}ro=n._zod,Object.defineProperty(r,e,{configurable:!0,get(){Object.defineProperty(this,e,Ql);let o=Ce;Ce=!1;try{let i=t(this);return Ce?delete this[e]:Object.defineProperty(this,e,{configurable:!0,writable:!0,value:i}),Ce=Ce||o,i}catch(i){throw delete this[e],Ce=Ce||o,i}},set(o){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:o})}})}function Is(n,e,t,r){let o=Xl(n,e);o&&Object.defineProperty(o,e,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,e,i),i.value=t(this),Object.defineProperty(this,e,i),i.value},set(i){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:r,value:i})}})}var Ts;var yo={value:void 0,enumerable:!1},js="captureStackTrace"in Error?Error:null;function eu(n){let e=js;if(e){let t=e.stackTraceLimit;if(typeof t=="number"){try{e.stackTraceLimit=0}catch{return js=null,new n}try{return new n}finally{e.stackTraceLimit=t}}}return new n}function P(n,e,t,r){let o={};function i(l){this.def=l,this.constr=p,this.traits=new Set}i.prototype=o;let s=t,a=s&&new WeakSet;function d(l,f){if(l._zod){if(l._zod.traits.has(n))return}else{yo.value=new i(f);try{Object.defineProperty(l,"_zod",yo)}finally{yo.value=void 0}}if(l._zod.traits.add(n),e(l,f),a){let h=Object.getPrototypeOf(l),v=l._zod.constr.prototype,m=h;for(;m&&m!==v;)m=Object.getPrototypeOf(m);let k=m??h;a.has(k)||(a.add(k),zs(k,s))}let g=p.prototype;for(let h in g)Object.prototype.hasOwnProperty.call(g,h)&&(h in l||(l[h]=g[h].bind(l)))}let u=r?.Parent??Object;class c extends u{}Object.defineProperty(c,"name",{value:n});function p(l){let f=r?.Parent?eu(c):this;d(f,l);let g=f._zod.deferred;if(g){for(let v of g)v();f._zod.deferred=void 0}let h=globalThis.__zod_globalConfig?.postProcessor;return h&&h(f),f}return Object.defineProperty(p,"init",{value:d}),Object.defineProperty(p,Symbol.hasInstance,{value:l=>r?.Parent&&l instanceof r.Parent?!0:l?._zod?.traits?.has(n)}),Object.defineProperty(p,"name",{value:n}),p}var Ne=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(Ts=globalThis).__zod_globalConfig??(Ts.__zod_globalConfig={});var Nn=globalThis.__zod_globalConfig;function oe(n){return n&&Object.assign(Nn,n),Nn}function nu(){let n=this._zod;return n.message??(n.message=JSON.stringify(n.def,bs,2)),n.message}function tu(n){this._zod.message=n}var ru={get:nu,set:tu,enumerable:!0,configurable:!0},vo={value:void 0,enumerable:!1},Ds=new WeakSet([Object.prototype,Error.prototype]),Fs=(n,e)=>{n.name="$ZodError",vo.value=e,Object.defineProperty(n,"issues",vo),vo.value=void 0,Object.defineProperty(n,"message",ru);let t=Object.getPrototypeOf(n);Ds.has(t)||(Ds.add(t),Object.defineProperty(t,"toString",{configurable:!0,enumerable:!1,get(){let r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},Dg=P("$ZodError",Fs),ct=P("$ZodError",Fs,void 0,{Parent:Error});var iu=n=>{let e=(t,r,o,i)=>{let s=o?{...o,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new Ne;if(a.issues.length){let d=new(i?.Err??n)(a.issues.map(u=>Ee(u,s,oe())));throw lo(d,i?.callee??e),d}return a.value};return e},wo=iu(ct),su=n=>{let e=async(t,r,o,i)=>{let s=o?{...o,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){let d=new(i?.Err??n)(a.issues.map(u=>Ee(u,s,oe())));throw lo(d,i?.callee??e),d}return a.value};return e},ko=su(ct),au=n=>(e,t,r)=>{let o=r?{...r,async:!1}:{async:!1},i=e._zod.run({value:t,issues:[]},o);if(i instanceof Promise)throw new Ne;return i.issues.length?Ls(n,i.issues,o):{success:!0,data:i.value}},xo=au(ct);function Ls(n,e,t){let r;return{success:!1,get error(){return r||(r=new n(e.map(o=>Ee(o,t,oe()))),e=void 0,t=void 0),r},set error(o){r=o,e=void 0,t=void 0}}}var du=n=>async(e,t,r)=>{let o=r?{...r,async:!0}:{async:!0},i=e._zod.run({value:t,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?Ls(n,i.issues,o):{success:!0,data:i.value}},So=du(ct);var Cs=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Zs=/^https?$/;var Gs=/^[\s\S]{0,}$/;var Ro=/^-?\d+(?:\.\d+)?$/,Ks=/^(?:true|false)$/i,Vs=/^null$/i;var ie=P("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])});var Bs=n=>{let e=n.value;return!ws(e)&&e.length!==void 0},Ht={number:"number",bigint:"bigint",object:"date"},Us=P("$ZodCheckLessThan",(n,e)=>{ie.init(n,e);let t=Ht[typeof e.value];n._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:Ht[typeof r.value]??t,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),Ws=P("$ZodCheckGreaterThan",(n,e)=>{ie.init(n,e);let t=Ht[typeof e.value];n._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:Ht[typeof r.value]??t,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),qs=P("$ZodCheckMultipleOf",(n,e)=>{ie.init(n,e),n._zod.check=t=>{if(typeof t.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof t.value=="bigint"?e.value!==BigInt(0)&&t.value%e.value===BigInt(0):ks(t.value,e.value)===0)||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:e.value,input:t.value,inst:n,continue:!e.abort})}}),Hs=P("$ZodCheckNumberFormat",(n,e)=>{ie.init(n,e),e.format=e.format||"float64";let t=e.format?.includes("int"),r=t?"int":"number",[o,i]=Ps[e.format];n._zod.check=s=>{let a=s.value;if(t){if(!Number.isInteger(a)){s.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:a,inst:n});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!e.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!e.abort});return}}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:n,continue:!e.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:n,continue:!e.abort})}});var Ys=P("$ZodCheckMaxLength",(n,e)=>{var t;ie.init(n,e),(t=n._zod.def).when??(t.when=Bs),n._zod.check=r=>{let o=r.value,i=o.length;if((typeof o=="string"&&i>e.maximum?ho(o):i)<=e.maximum)return;let a=go(o);r.issues.push({origin:a,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:n,continue:!e.abort})}}),Js=P("$ZodCheckMinLength",(n,e)=>{var t;ie.init(n,e),(t=n._zod.def).when??(t.when=Bs),n._zod.check=r=>{let o=r.value,i=o.length;if((typeof o=="string"&&i>=e.minimum&&i<e.minimum*2?ho(o):i)>=e.minimum)return;let a=go(o);r.issues.push({origin:a,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:n,continue:!e.abort})}});var Ao=P("$ZodCheckStringFormat",(n,e)=>{var t,r;ie.init(n,e),e.pattern?(t=n._zod).check??(t.check=o=>{e.pattern.lastIndex=0,!e.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:e.format,input:o.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:n,continue:!e.abort})}):(r=n._zod).check??(r.check=()=>{})}),Xs=P("$ZodCheckRegex",(n,e)=>{Ao.init(n,e),n._zod.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:e.pattern.toString(),inst:n,continue:!e.abort})}});var ea={major:4,minor:6,patch:5};var U=P("$ZodType",(n,e)=>{var t;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=ea;let r=n._zod.def.checks,o=n._zod.traits.has("$ZodCheck")?[n,...r??[]]:r?.length?[...r]:[];for(let i of o)for(let s of i._zod.onattach)s(n);if(o.length===0)(t=n._zod).deferred??(t.deferred=[]),n._zod.deferred?.push(()=>{n._zod.run=n._zod.parse});else{let i=(a,d,u)=>{if(a.memo)return a;let c=Pe(a),p;for(let l of d){if(l._zod.def.when){if(Ms(a)||!l._zod.def.when(a))continue}else if(c)continue;let f=a.issues.length,g=l._zod.check(a);if(g instanceof Promise&&u?.async===!1)throw new Ne;if(p||g instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await g,a.issues.length!==f&&(po(a.issues,f,n),c||(c=Pe(a,f)))});else{if(a.issues.length===f)continue;po(a.issues,f,n),c||(c=Pe(a,f))}}return p?p.then(()=>a):a},s=(a,d,u)=>{if(Pe(a))return a.aborted=!0,a;let c=i(d,o,u);if(c instanceof Promise){if(u.async===!1)throw new Ne;return c.then(p=>n._zod.parse(p,u))}return n._zod.parse(c,u)};n._zod.run=(a,d)=>{if(d.skipChecks)return n._zod.parse(a,d);if(d.direction==="backward"){let c=n._zod.parse({value:a.value,issues:[]},{...d,skipChecks:!0});return c instanceof Promise?c.then(p=>s(p,a,d)):s(c,a,d)}let u=n._zod.parse(a,d);if(u instanceof Promise){if(d.async===!1)throw new Ne;return u.then(c=>i(c,o,d))}return i(u,o,d)}}},{get"~standard"(){return mo(this,"~standard",lu(this))},set"~standard"(n){cn(this,"~standard",n)}}),sa=(n,e)=>n.issues.length?{issues:n.issues.map(t=>Ee(t,e,oe()))}:{value:n.value};async function cu(n,e){let t={async:!0};return sa(await n._zod.run({value:e,issues:[]},t),t)}function lu(n){return{validate:e=>{let t={async:!1};try{let r=n._zod.run({value:e,issues:[]},t);if(!(r instanceof Promise))return sa(r,t)}catch{}return cu(n,e)},vendor:"zod",version:1}}var Oo=P("$ZodString",(n,e)=>{U.init(n,e),n._zod.pattern=e.pattern??Gs,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=String(t.value)}catch{}return typeof t.value=="string"||t.issues.push({expected:"string",code:"invalid_type",input:t.value,inst:n}),t}}),Xt=P("$ZodStringFormat",(n,e)=>{Ao.init(n,e),Oo.init(n,e)});var aa=P("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=Cs),Xt.init(n,e)}),da=1,Yt=2;function uu(n){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(n):(new URL(n),!0)}catch{return!1}}function fu(n,e){return!("normalize"in e)&&!("hostname"in e)&&!("protocol"in e)?uu(n)||Yt:pu(n,e)}function pu(n,e){if(!e.normalize&&e.protocol?.source===Zs.source&&!/^https?:\/\//i.test(n))return da;try{if(typeof URL<"u"){let t=URL;if(typeof t.parse=="function")return t.parse(n)??Yt}return new URL(n)}catch{return Yt}}var hu=/[\t\n\r]/g;function na(n){return n.replace(hu,"")}function gu(n,e){return e.lastIndex=0,e.test(n.hostname)}function mu(n,e){return e.lastIndex=0,e.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol)}var ca=P("$ZodURL",(n,e)=>{Xt.init(n,e),n._zod.check=t=>{try{let r=t.value.trim(),o=fu(r,e);if(o===da){t.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:t.value,inst:n,continue:!e.abort});return}if(o===Yt){t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort});return}if(o===!0){t.value=na(r);return}e.hostname&&!gu(o,e.hostname)&&t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:t.value,inst:n,continue:!e.abort}),e.protocol&&!mu(o,e.protocol)&&t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:t.value,inst:n,continue:!e.abort}),t.value=e.normalize?o.href:na(r);return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort})}}});var _o=P("$ZodNumber",(n,e)=>{U.init(n,e),n._zod.pattern=Ro,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=Number(t.value)}catch{}let o=t.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return t;let i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return t.issues.push({expected:"number",code:"invalid_type",input:o,inst:n,...i?{received:i}:{}}),t}}),la=P("$ZodNumberFormat",(n,e)=>{Hs.init(n,e),_o.init(n,e)}),ua=P("$ZodBoolean",(n,e)=>{U.init(n,e),n._zod.pattern=Ks,n._zod.parse=(t,r)=>{if(e.coerce)try{t.value=!!t.value}catch{}let o=t.value;return typeof o=="boolean"||t.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:n}),t}});var fa=P("$ZodNull",(n,e)=>{U.init(n,e),n._zod.pattern=Vs,n._zod.values=new Set([null]),n._zod.parse=(t,r)=>{let o=t.value;return o===null||t.issues.push({expected:"null",code:"invalid_type",input:o,inst:n}),t}});var pa=P("$ZodUnknown",(n,e)=>{U.init(n,e),n._zod.parse=t=>t}),ha=P("$ZodNever",(n,e)=>{U.init(n,e),n._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:n}),t)});function ta(n,e,t){n.issues.length&&e.issues.push(...Ze(t,n.issues)),e.value[t]=n.value}var ga=P("$ZodArray",(n,e)=>{U.init(n,e);let t=Nn.memoizer;t?.attach(n),n._zod.parse=(r,o)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:n}),r;r.value=t?t.alloc(n,r,Array(i.length),o):Array(i.length);let s=[],a=o?.abortEarly;for(let d=0;d<i.length;d++){let u=i[d],c=e.element._zod.run({value:u,issues:[]},o);if(c instanceof Promise)s.push(c.then(p=>ta(p,r,d)));else if(ta(c,r,d),a&&c.issues.length!==0&&Pe(c))break}return s.length?Promise.all(s).then(()=>r):r}});function Jt(n,e,t,r,o,i){let s=t in r,a=i==="optional";if(!(!s&&a&&o==="optional")){if(n.issues.length){if(o!==void 0&&a&&!s)return;e.issues.push(...Ze(t,n.issues))}if(!s&&o===void 0){n.issues.length||e.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[t]});return}n.value===void 0?(s||o==="defaulted"&&!a)&&(e.value[t]=void 0):e.value[t]=n.value}}var yu=[];function bu(n){let e=Object.keys(n.shape),t=Object.getOwnPropertySymbols(n.shape),r=t.length?t:yu,o=r.length?[...e,...r]:e;for(let s of o)if(!n.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=_s(n.shape);return{...n,allKeys:o,symbolKeys:r,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(i)}}function vu(n,e,t,r,o,i,s){let a=[],d=o.keySet,u=o.catchall._zod,c=u.def.type,p=u.optin,l=u.optout,f=0;for(let g in e){if(s&&t.issues.length!==f){if(Pe(t,f))break;f=t.issues.length}if(d.has(g))continue;if(g==="__proto__"){c==="never"&&a.push(g);continue}if(c==="never"){a.push(g);continue}let h=u.run({value:e[g],issues:[]},r);h instanceof Promise?n.push(h.then(v=>Jt(v,t,g,e,p,l))):Jt(h,t,g,e,p,l)}return a.length&&t.issues.push({code:"unrecognized_keys",keys:a,input:e,inst:i,continue:!0}),n.length?Promise.all(n).then(()=>t):t}var ma=P("$ZodObject",(n,e)=>{U.init(n,e);let t=Object.getOwnPropertyDescriptor(e,"shape"),r=t?.get?t.get.raw:e.shape??{};if(r){let u=()=>{let c={...r};return Object.defineProperty(e,"shape",{value:c}),u.raw=c,c};u.raw=r,Object.defineProperty(e,"shape",{get:u})}let o=vs(()=>bu(e));Q(n,"propValues",u=>{let c=u.def.shape,p={};for(let l in c){let f=c[l]._zod;if(f.values){Object.prototype.hasOwnProperty.call(p,l)||qt(p,l,new Set);for(let g of f.values)p[l].add(g);f.optin!==void 0&&p[l].add(void 0)}}return p});let i=Wt,s=e.catchall,a,d=Nn.memoizer;d?.attach(n),n._zod.parse=(u,c)=>{a??(a=o.value);let p=u.value;if(!i(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:n}),u;u.value=d?d.alloc(n,u,{},c):{};let l=[],f=a.shape,g=c?.abortEarly,h=u.issues.length;for(let v of a.allKeys){if(g&&u.issues.length!==h){if(Pe(u,h))break;h=u.issues.length}if(v==="__proto__")continue;let m=f[v],k=m._zod.optin,$=m._zod.optout,w=m._zod.run({value:p[v],issues:[]},c);w instanceof Promise?l.push(w.then(O=>Jt(O,u,v,p,k,$))):Jt(w,u,v,p,k,$)}return s?vu(l,p,u,c,o.value,n,g===!0):l.length?Promise.all(l).then(()=>u):u}});function ra(n,e,t,r){for(let i of n)if(i.issues.length===0)return e.value=i.value,e;let o=n.filter(i=>!Pe(i));return o.length===1?(e.value=o[0].value,o[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:n.map(i=>i.issues.map(s=>Ee(s,r,oe())))}),e)}var ya=P("$ZodUnion",(n,e)=>{U.init(n,e),Q(n,"optin",r=>r.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),Q(n,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),Q(n,"values",r=>{if(r.def.options.every(o=>o._zod.values))return new Set(r.def.options.flatMap(o=>Array.from(o._zod.values)))}),Q(n,"pattern",r=>{if(r.def.options.every(o=>o._zod.pattern)){let o=r.def.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>ao(i.source)).join("|")})$`)}});let t=e.options.length===1?e.options[0]._zod.run:null;n._zod.parse=(r,o)=>{if(t)return t(r,o);let i=!1,s=[];for(let a of e.options){let d=a._zod.run({value:r.value,issues:[]},o);if(d instanceof Promise)s.push(d),i=!0;else{if(d.issues.length===0)return d;s.push(d)}}return i?Promise.all(s).then(a=>ra(a,r,n,o)):ra(s,r,n,o)}});var ba=P("$ZodRecord",(n,e)=>{U.init(n,e);let t=Nn.memoizer;t?.attach(n),n._zod.parse=(r,o)=>{let i=r.value;if(!uo(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),r;let s=[],a=e.keyType._zod.values;if(a&&!e.partial){r.value=t?t.alloc(n,r,{},o):{};let d=new Set;for(let c of a)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){if(d.add(typeof c=="number"?c.toString():c),c==="__proto__")continue;let p=e.keyType._zod.run({value:c,issues:[]},o);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(p.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map(g=>Ee(g,o,oe())),input:c,path:[c],inst:n});continue}let l=p.value;if(l==="__proto__")continue;let f=e.valueType._zod.run({value:i[c],issues:[]},o);f instanceof Promise?s.push(f.then(g=>{g.issues.length&&r.issues.push(...Ze(c,g.issues)),r.value[l]=g.value})):(f.issues.length&&r.issues.push(...Ze(c,f.issues)),r.value[l]=f.value)}let u;for(let c in i)if(!d.has(c))if(e.mode==="loose"){if(c==="__proto__")continue;r.value[c]=i[c]}else u=u??[],u.push(c);u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:u,continue:!0})}else{r.value=t?t.alloc(n,r,{},o):{};let d;for(let u of Reflect.ownKeys(i)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,u))continue;let c=e.keyType._zod.run({value:u,issues:[]},o);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&Ro.test(u)&&c.issues.length){let g=e.keyType._zod.run({value:Number(u),issues:[]},o);if(g instanceof Promise)throw new Error("Async schemas not supported in object keys currently");g.issues.length===0&&(c=g)}if(c.issues.length){e.mode==="loose"?r.value[u]=i[u]:a?(d=d??[],d.push(u)):r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(g=>Ee(g,o,oe())),input:u,path:[u],inst:n});continue}let l=c.value;if(l==="__proto__")continue;let f=e.valueType._zod.run({value:i[u],issues:[]},o);f instanceof Promise?s.push(f.then(g=>{g.issues.length&&r.issues.push(...Ze(u,g.issues)),r.value[l]=g.value})):(f.issues.length&&r.issues.push(...Ze(u,f.issues)),r.value[l]=f.value)}d&&d.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:d,continue:!0})}return s.length?Promise.all(s).then(()=>r):r}});var va=P("$ZodEnum",(n,e)=>{U.init(n,e);let t=io(e.entries),r=new Set(t);n._zod.values=r,Q(n,"pattern",o=>{let i=io(o.def.entries).filter(s=>Os.has(typeof s));return new RegExp(i.length?`^(${i.map(s=>at(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),n._zod.parse=(o,i)=>{let s=o.value;return r.has(s)||o.issues.push({code:"invalid_value",values:t,input:s,inst:n}),o}}),wa=P("$ZodLiteral",(n,e)=>{U.init(n,e);let t=new Set(e.values);n._zod.values=t,Q(n,"pattern",r=>{let o=r.def.values;return new RegExp(o.length?`^(${o.map(i=>typeof i=="string"?at(i):i?at(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$")}),n._zod.parse=(r,o)=>{let i=r.value;return t.has(i)||r.issues.push({code:"invalid_value",values:e.values,input:i,inst:n}),r}});function oa(n,e){return n.value=e.issues.length?void 0:e.value,n}var ka=P("$ZodOptional",(n,e)=>{U.init(n,e),Q(n,"optin",t=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),n._zod.optout="optional",Q(n,"values",t=>{let r=t.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),Q(n,"pattern",t=>{let r=t.def.innerType._zod.pattern;return r?new RegExp(`^(${ao(r.source)})?$`):void 0}),n._zod.parse=(t,r)=>{if(t.value===void 0){if(e.innerType._zod.optin!=="defaulted")return t;let o=e.innerType._zod.run({value:t.value,issues:[]},r);return o instanceof Promise?o.then(i=>oa(t,i)):oa(t,o)}return e.innerType._zod.run(t,r)}});var xa=P("$ZodLazy",(n,e)=>{U.init(n,e),xs(n._zod,"innerType",()=>{let t=e;return t._cachedInner||(t._cachedInner=e.getter()),t._cachedInner}),Q(n,"pattern",t=>t.innerType?._zod?.pattern),Q(n,"propValues",t=>t.innerType?._zod?.propValues),Q(n,"optin",t=>t.innerType?._zod?.optin??void 0),Q(n,"optout",t=>t.innerType?._zod?.optout??void 0),n._zod.parse=(t,r)=>n._zod.innerType._zod.run(t,r)}),Sa=P("$ZodCustom",(n,e)=>{ie.init(n,e),U.init(n,e),n._zod.parse=(t,r)=>t,n._zod.check=t=>{let r=t.value,o=e.fn(r);if(o instanceof Promise)return o.then(i=>ia(i,t,r,n));ia(o,t,r,n)}});function ia(n,e,t,r){if(!n){let o={code:"custom",input:t,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),e.issues.push(dt(o))}}var wu=()=>{let n={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function e(i){return n[i]??null}let t={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(i,s){return i==="number"&&typeof s=="number"&&!Number.isFinite(s)?String(s):r[i]??i}return i=>{switch(i.code){case"invalid_type":{let s=o(i.expected),a=Ns(i.input),d=o(a,i.input);return`Invalid input: expected ${s}, received ${d}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${fo(i.values[0])}`:`Invalid option: expected one of ${so(i.values,"|")}`;case"too_big":{let s=i.exact?"exactly ":i.inclusive?"<=":"<",a=e(i.origin);return a?`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{let s=i.exact?"exactly ":i.inclusive?">=":">",a=e(i.origin);return a?`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${a.unit}`:`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${t[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${so(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return i.options&&Array.isArray(i.options)&&i.options.length>0?`Invalid discriminator value. Expected ${i.options.map(a=>`'${a}'`).join(" | ")}`:i.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function Ra(){return{localeError:wu()}}var $a;var Po=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let o={...r,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Aa(){return new Po}($a=globalThis).__zod_globalRegistry??($a.__zod_globalRegistry=Aa());var zn=globalThis.__zod_globalRegistry;function Oa(n){return n.checks&&(n.checks=[...n.checks]),n}function _a(n,e){return new n(Oa({type:"string",...j(e)}))}function Pa(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...j(e)})}function Ea(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...j(e)})}function Ma(n,e){return new n(Oa({type:"number",checks:[],...j(e)}))}function Na(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...j(e)})}function za(n,e){return new n({type:"boolean",...j(e)})}function Ia(n,e){return new n({type:"null",...j(e)})}function Ta(n){return new n({type:"unknown"})}function ja(n,e){return new n({type:"never",...j(e)})}function Da(n,e){return new Us({check:"less_than",...j(e),value:n,inclusive:!0})}function Fa(n,e){return new Ws({check:"greater_than",...j(e),value:n,inclusive:!0})}function Ru(n,e){return new qs({check:"multiple_of",...j(e),value:n})}function Eo(n,e){return new Ys({check:"max_length",...j(e),maximum:n})}function lt(n,e){return new Js({check:"min_length",...j(e),minimum:n})}function ut(n,e){return new Xs({check:"string_format",format:"regex",...j(e),pattern:n})}function La(n,e,t){return new n({type:"custom",check:"custom",fn:e,...j(t)})}function Ca(n,e){let t=$u(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(dt(o,r.value,t._zod.def));else{let i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),r.issues.push(dt(i))}},n(r.value,r)),e);return t}function $u(n,e){let t=new ie({check:"custom",...j(e)});return t._zod.check=n,t}function Za(n){let e=new ie({check:"describe"});return e._zod.onattach=[t=>{let r=zn.get(t)??{};zn.add(t,{...r,description:n})}],e._zod.check=()=>{},e}var ee=P("ZodMiniType",(n,e)=>{if(!n._zod)throw new Error("Uninitialized schema in ZodMiniType.");U.init(n,e),n.def=e,n.type=e.type},{get with(){return this.check},set with(n){cn(this,"with",n)},parse(n,e){return wo(this,n,e,{callee:this.parse})},parseAsync(n,e){return ko(this,n,e,{callee:this.parseAsync})},safeParse(n,e){return xo(this,n,e)},safeParseAsync(n,e){return So(this,n,e)},check(...n){let e=this.def;return this.clone({...e,checks:[...e.checks??[],...n.map(t=>typeof t=="function"?{_zod:{check:t,def:{check:"custom"},onattach:[]}}:t)]},{parent:!0})},clone(n,e){return Mn(this,n,e)},brand(){return this},register(n,e){return n.add(this,e),this},apply(n,...e){return e.length===0?n(this):n(this,...e)}}),Ka=P("ZodMiniString",(n,e)=>{Oo.init(n,e),ee.init(n,e)});function L(n){return _a(Ka,n)}var Va=P("ZodMiniStringFormat",(n,e)=>{Xt.init(n,e),Ka.init(n,e)}),_u=P("ZodMiniEmail",(n,e)=>{aa.init(n,e),Va.init(n,e)});function Lb(n){return Pa(_u,n)}var Pu=P("ZodMiniURL",(n,e)=>{ca.init(n,e),Va.init(n,e)});function Cb(n){return Ea(Pu,n)}var Ba=P("ZodMiniNumber",(n,e)=>{_o.init(n,e),ee.init(n,e)});function ln(n){return Ma(Ba,n)}var Eu=P("ZodMiniNumberFormat",(n,e)=>{la.init(n,e),Ba.init(n,e)});function Zb(n){return Na(Eu,n)}var Mu=P("ZodMiniBoolean",(n,e)=>{ua.init(n,e),ee.init(n,e)});function Gb(n){return za(Mu,n)}var Nu=P("ZodMiniNull",(n,e)=>{fa.init(n,e),ee.init(n,e)});function Ua(n){return Ia(Nu,n)}var zu=P("ZodMiniUnknown",(n,e)=>{pa.init(n,e),ee.init(n,e)});function ft(){return Ta(zu)}var Iu=P("ZodMiniNever",(n,e)=>{ha.init(n,e),ee.init(n,e)});function Tu(n){return ja(Iu,n)}var ju=P("ZodMiniArray",(n,e)=>{ga.init(n,e),ee.init(n,e)});function Wa(n,e){return new ju({type:"array",element:n,...j(e)})}var Mo=P("ZodMiniObject",(n,e)=>{ma.init(n,e),ee.init(n,e),Is(n,"shape",t=>t._zod.def.shape,!1)});function se(n,e){let t={type:"object",shape:n??{},...j(e)};return new Mo(t)}function In(n,e){return new Mo({type:"object",shape:n,catchall:Tu(),...j(e)})}function Kb(n,e){return new Mo({type:"object",shape:n,catchall:ft(),...j(e)})}function qa(n,e){return Es(n,e)}var Du=P("ZodMiniUnion",(n,e)=>{ya.init(n,e),ee.init(n,e)});function Ha(n,e){return new Du({type:"union",options:n,...j(e)})}var Ga=P("ZodMiniRecord",(n,e)=>{ba.init(n,e),ee.init(n,e)});function Vb(n,e,t){return!e||!e._zod?new Ga({type:"record",keyType:L(),valueType:n,...j(e)}):new Ga({type:"record",keyType:n,valueType:e,...j(t)})}var Fu=P("ZodMiniEnum",(n,e)=>{va.init(n,e),ee.init(n,e),n.options=[...n._zod.values]});function Ya(n,e){let t=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new Fu({type:"enum",entries:t,...j(e)})}var Lu=P("ZodMiniLiteral",(n,e)=>{wa.init(n,e),ee.init(n,e)});function pt(n,e){return new Lu({type:"literal",values:Array.isArray(n)?n:[n],...j(e)})}var Cu=P("ZodMiniOptional",(n,e)=>{ka.init(n,e),ee.init(n,e)});function W(n){return new Cu({type:"optional",innerType:n})}var Zu=P("ZodMiniLazy",(n,e)=>{xa.init(n,e),ee.init(n,e)});function Bb(n){return new Zu({type:"lazy",getter:n})}var Gu=P("ZodMiniCustom",(n,e)=>{Sa.init(n,e),ee.init(n,e)});function Qt(n,e={}){return La(Gu,n,e)}function Ub(n,e){return Ca(n,e)}var Wb=Za;oe().localeError||oe(Ra());var C=n=>typeof n=="object"&&n!==null?n._zod?.def:void 0,Ku=n=>{if(typeof n!="object"||n===null||!("_zod"in n))return;let e=zn.get(n)?.description;return typeof e=="string"?e:void 0};var Vu=(n,e)=>n?.src?.(e)??e,er=n=>typeof n=="string"&&n.length<2049&&/^(?![^/?#]*:|\/\/)(?!(?:.*\/)?\.\.?(?:[/?#]|$))(?!.*%2e)[^\\\s]+$/i.test(n),No=(n,e=1)=>e>0&&n===void 0||Number.isInteger(n)&&n>=e;function zo(n){let e=n??{};return er(e.href)&&typeof e.name=="string"&&/^.{1,255}$/s.test(e.name)&&/^[\w.+-]{1,60}\/[\w.+-]{1,60}$/.test(e.type)&&No(e.bytes,0)&&No(e.width)&&No(e.height)&&(e.caption===void 0||typeof e.caption=="string"&&e.caption.length<501)&&(e.poster===void 0||er(e.poster))&&(e.captions===void 0||er(e.captions))&&(e.duration===void 0||typeof e.duration=="number"&&Number.isFinite(e.duration)&&e.duration>0)&&(e.at===void 0||Ja(e.at)!==void 0)}function Ja(n){return typeof n=="string"&&n.length<41&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d{1,9})?)?(Z|[+-]\d{2}:?\d{2})$/.test(n)&&Number.isFinite(Date.parse(n))?n:void 0}var Xa=n=>n.type.startsWith("image/"),Qa=n=>n.type.startsWith("video/");function Bu(n){let e=n.duration===void 0?0:Math.round(n.duration);if(e<1)return"a video";if(e<60)return`a ${e}-second video`;let t=Math.round(e/60);return t<60?`a ${t}-minute video`:`a ${Math.floor(t/60)}-hour${t%60>0?` ${t%60}-minute`:""} video`}var Uu=(n,e)=>e==="image"?Xa(n):e==="video"?Qa(n):!0,Wu=n=>`${n==="image"?"an image":n==="video"?"a video":"a file"} the host stored, at a path on this host`,ht=n=>(Array.isArray(n)?n:[n]).filter(zo),ed=Symbol.for("@graview/core:file"),qu=(n,e)=>(Object.defineProperty(C(n),ed,{value:e,enumerable:!0}),n);function nd(n){let e=C(n);return e?.[ed]??(e?.innerType?nd(e.innerType):void 0)}var Hu=()=>({href:L(),name:L(),type:L(),bytes:ln(),width:W(ln()),height:W(ln()),caption:W(L()),poster:W(L()),duration:W(ln()),captions:W(L()),at:W(L())});function qv(n){return qu(se(Hu()).check(Qt(e=>zo(e)&&Uu(e,n),Wu(n))),n)}var nr=/^(?:https?:\/\/[^\s<>"'`\\]+|@?[A-Za-z0-9][\w.~-]*(?:\/[\w.~-]+)*)$/,tr=n=>typeof n=="string"&&n.length<501&&nr.test(n);var td=n=>typeof n=="object"&&n!==null?n._zod?.def:void 0,Yu=/^@(?:https?:\/\/[^\s<>"'`\\#?]+|[A-Za-z0-9][\w.~-]*(?:\/[\w.~-]+)*)\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;function rd(n){if(typeof n!="string"||!n.startsWith("@")||!Yu.test(n))return;let e=n.lastIndexOf("/"),t=n.slice(0,e),r=n.slice(e+1),o=/^@https?:\/\//.test(t)||!t.includes("/")?t.slice(1):t;return tr(o)?{address:o,kind:r}:void 0}var Ju=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*:\S[^\n]{0,199}$/,Xu=n=>`${n.kind}:${n.id}`;function od(n,e){if(typeof n!="string"||!Ju.test(n))return;let t=n.indexOf(":"),r=n.slice(0,t);return e.kinds.includes(r)?{address:e.address,kind:r,id:n.slice(t+1)}:void 0}function Qu(n,e){return(Array.isArray(n)?n:n==null?[]:[n]).flatMap(r=>{let o=od(r,e);return o?[o]:[]})}var id=Symbol.for("@graview/core:linked"),Xv=(n,e)=>(Object.defineProperty(td(n),id,{value:e,enumerable:!0}),n);function gt(n){let e=td(n);return e?e[id]??gt(e.innerType):void 0}function ef(n){let e=n?.fields?.shape??{},t=new Map;for(let[r,o]of Object.entries(e)){let i=gt(o);i&&t.set(r,i)}return t}function nf(n){if(n.to==="*"||n.to.length===0)return;let e=n.to.map(rd);if(e.some(r=>!r))return;let t=e[0].address;if(!e.some(r=>r.address!==t))return{address:t,kinds:[...new Set(e.map(r=>r.kind))],cardinality:n.cardinality??"many",...n.description?{description:n.description}:{}}}var tf=n=>n.to!=="*"&&n.to.some(e=>typeof e=="string"&&e.startsWith("@"));function Qv(n){return Object.fromEntries(Object.entries(n??{}).filter(([,e])=>!tf(e)))}function ew(n){let e=new Map;for(let[t,r]of Object.entries(n??{})){let o=nf(r);o&&e.set(t,o)}return e}var Io=new WeakMap;function rf(n,e){e?Io.set(n,e):Io.delete(n)}var sd=n=>Io.get(n);var rr=["sun","mon","tue","wed","thu","fri","sat"],of=["day","week","month","year"],jn=n=>`${n}Repeat`,yt=n=>n.endsWith("Repeat")&&n.length>6?n.slice(0,-6):void 0,cd=/^\d{4}-\d{2}-\d{2}$/,ld=Symbol.for("@graview/core:repeat");function or(n){let e=C(n);return!!e&&(e[ld]===1||or(e.innerType))}var sf=n=>(Object.defineProperty(C(n),ld,{value:1,enumerable:!0}),n),To=(n,e,t)=>n===void 0||Number.isInteger(n)&&n>=e&&n<=t,ad=(n,e)=>n===void 0||Array.isArray(n)&&n.length<=e&&n.every(t=>typeof t=="string"&&cd.test(t)),af=["every","interval","on","until","count","except","continues"],ud=n=>Dn(n)&&Object.keys(n).every(e=>af.includes(e))&&To(n.interval,1,99)&&To(n.count,1,1e3)&&ad(n.until===void 0?void 0:[n.until],1)&&ad(n.except,500)&&(n.continues===void 0||typeof n.continues=="string"&&n.continues.length<=200)&&(n.on===void 0||Array.isArray(n.on)&&n.on.length>0&&n.on.length<=31&&n.on.every(e=>n.every==="week"?rr.includes(e):n.every==="month"&&e!==0&&To(e,-1,31))),rw=()=>sf(ft().check(Qt(n=>n===null||ud(n),"how a date repeats, or null"))),mt=n=>Date.UTC(+n.slice(0,4),+n.slice(5,7)-1,+n.slice(8,10)),fd=n=>new Date(n).toISOString().slice(0,10),jo=(n,e)=>fd(mt(n)+e*864e5),dd=(n,e,t)=>{let r=new Date(Date.UTC(n,e+1,0)).getUTCDate();return fd(Date.UTC(n,e,t<0||t>r?r:t))},Dn=n=>typeof n=="object"&&n!==null&&of.includes(n.every);function Tn(n,e,t={}){let r=n.slice(0,10),o=n.slice(10),i=[];if(!cd.test(r))return i;let s=Math.max(1,e.interval??1),a=e.every,d=t.from&&t.from>r?t.from.slice(0,10):r,u=[e.until,t.to?.slice(0,10)].filter(Boolean).sort()[0],c=t.limit??1e3,p=new Set(e.except??[]),l=+r.slice(0,4),f=+r.slice(5,7)-1,g=+r.slice(8,10),h=jo(r,-new Date(mt(r)).getUTCDay()),v=(e.on?.length?e.on:[a==="week"?rr[new Date(mt(r)).getUTCDay()]:g]).map(O=>typeof O=="string"?rr.indexOf(O):O),m=a==="day"?1:a==="week"?7:0,k=(+d.slice(0,4)-l)*12+(+d.slice(5,7)-1-f),$=e.count?0:Math.max(0,Math.floor((m?(mt(d)-mt(m===7?h:r))/864e5/m:a==="month"?k:k/12)/s)-1),w=0;for(let O=0;O<5e4&&i.length<c;O++,$++){let A=$*s,y=a==="day"?[jo(r,A)]:a==="week"?v.map(b=>jo(h,A*7+b)):a==="month"?v.map(b=>dd(l,f+A,b)):[dd(l+A,f,g)];for(let b of[...new Set(y)].sort())if(!(b<r)&&(u&&b>u||e.count&&w>=e.count||(w++,b>=d&&!p.has(b)&&i.push(b+o),i.length>=c)))return i}return i}function pd(n,e,t){if(!Dn(e)||typeof n!="string")return n;let r=Tn(n,e,{from:t,limit:1})[0];if(r)return r;let o=e.until||e.count?Tn(n,e):[];return o[o.length-1]??n}function df(n,e,t){let r=n[e],o=n[jn(e)];return typeof r=="string"&&Dn(o)?pd(r,o,t):r}var bt=(n,e)=>n==="*"||n.includes(e);function z(n){let e=n.onBehalfOf;if(!e)return n;let t=e.roles??[],r=n.roles===void 0?t:n.roles.filter(o=>t.includes(o));return{...n,...e.id!==void 0?{id:e.id}:{},roles:r}}var cf=/^[\w-]{1,64}$/,lf=200;function pe(n){let e=n.onBehalfOf??n,t=e.profile;if(!t||e.kind!=="human"||e.id===void 0||e.id.includes("~")||e.shared||typeof t.id!="string"||!cf.test(t.id)||typeof t.name!="string")return;let r=t.name.trim().slice(0,lf);return/[^\s\p{Z}\p{Cf}\p{Cc}]/u.test(r)?{id:t.id,name:r}:void 0}function fn(n){let e=n.onBehalfOf&&fn(n.onBehalfOf);if(!n.profile&&e===n.onBehalfOf)return n;let{profile:t,...r}=n,o=e?void 0:pe(n);return{...r,...e?{onBehalfOf:e}:{},...o?{profile:o}:{}}}var gd=(n,e)=>`${n}~${e.id}`;function we(n){let e=z(n).id;if(e===void 0||e.includes("~"))return;let t=pe(n);return t?gd(e,t):e}function sr(n,e){return n.definitions.some(t=>t.people)?we(e):z(e).id}function un(n,e){if(e===void 0)return!1;let t=z(n).id;return t===void 0||t.includes("~")?!1:e===t||e.includes("~")&&e===we(n)}var ar=n=>{if(n.mutation!==null||n.primitives.length!==1||!pe(n.author))return!1;let[e]=n.primitives;return e.op==="add-node"&&e.node.id===we(n.author)},D=n=>n.kind==="system"&&n.onBehalfOf===void 0,be=(n,e)=>n.roles==="*"||(e.roles??[]).some(t=>n.roles.includes(t));function ir(n){return us(n.map(e=>En(B(e).toLowerCase())),"or")}function ve(n,e,t,r,o,i,s={},a,d,u){if(!n)return{ok:!0};if(D(e))return{ok:!0};if(e=z(e),o!==void 0){if(ve(n,e,t,r,void 0,i).ok)return{ok:!0};let f=!1;if(o.some(m=>ve(n,e,m,r,void 0,i).ok)){if(!d||i===void 0||e.id!==void 0&&d()===e.id||!u&&n.grants.some(m=>m.roles!=="*"&&be(m,e)&&o.some(k=>bt(m.mutations,k))))return{ok:!0};f=!0}let g=f?[t]:[t,...o],h=[...new Set(g.flatMap(m=>Do(n,m,r)))].sort(),v=(f?"only on what you made; ":"")+(h.length===0?o.length===0?"no declared act creates or changes it, so no role can":"no role can":`${ir(h)} can`);return{ok:!1,refusal:{mutation:t,...r===void 0?{}:{kind:r},wouldNeed:h,message:hd(n,g,r,v,s)}}}let c=!1;for(let f of n.grants)if(be(f,e)&&bt(f.mutations,t)&&!(f.kinds!==void 0&&f.kinds!=="*"&&(r===void 0||!f.kinds.includes(r)))&&!(f.self&&!un(e,i))){if(f.ownEnd){let g=a?.()??[];if(!g.length||g.some(h=>!un(e,h))){c=!0;continue}}return{ok:!0}}let p=Do(n,t,r),l=c?"only on your own end of the link":p.length===0?"no role can":`${ir(p)} can`;return{ok:!1,refusal:{mutation:t,...r===void 0?{}:{kind:r},wouldNeed:p,message:hd(n,[t],r,l,s)}}}function hd(n,e,t,r,o){let i=[...new Set(e.flatMap(a=>md(n,a,t)))],s=o.act?.(e[0]);return`Not permitted: ${s?`\u201C${s}\u201D`:e[0]}${t?` on ${En(o.noun?.(t)??t)}`:""} \u2014 ${r}.`+(i.length>0?` ${i.join(" ")}`:"")}function md(n,e,t){return[...new Set(yd(n,e,t).flatMap(r=>r.describe||[]))]}var yd=(n,e,t)=>n.grants.filter(r=>bt(r.mutations,e)&&(t===void 0||bt(r.kinds??"*",t)));function Do(n,e,t){let r=yd(n,e,t);return r.some(o=>o.roles==="*")?[]:[...new Set(r.flatMap(o=>o.roles))].sort()}function Fo(n,e,t){return n?t.filter(r=>{let o=z(e).id;return Lo(r).some(i=>ve(n,e,r.name,i,void 0,o,void 0,()=>[o??[]].flat()).ok)}):t}var Lo=n=>n.subject&&n.subject.kinds!=="*"?n.subject.kinds:[void 0];function Co(n,e,t,r){if(!n||D(e))return!1;let o=z(e);return n.grants.some(i=>i.propose!==void 0&&be(i,o)&&bt(i.propose,t)&&(i.kinds===void 0||i.kinds==="*"||r!==void 0&&i.kinds.includes(r)))}var dr=["human","visitor","agent","rule","system"],uf=new Set(dr);function Zo(n){return uf.has(n?.kind)?n.kind:"system"}function Fn(n,e){if(n.onBehalfOf){let{onBehalfOf:a,...d}=n;return`${Fn(d,e)}, for ${Fn(a,e)}`}let t=n.profile&&pe(n);if(t){let{profile:a,...d}=n,u=Fn(d,e);return u==="somebody"?t.name:`${t.name} (${u})`}let r=Zo(n);if(n.id===void 0)return n.name??(r==="agent"?"an agent":r==="visitor"?"a visitor":r);let o=e.graph.getNode(n.id);if(o)return V(e.schema.tryDefinition(o.kind),o);let i=e.seats?.find(a=>a.principal.id===n.id);if(i)return i.label;let s=e.people?.find(a=>a.id===n.id&&(a.kind===void 0||a.kind===n.kind));return s?s.name:n.name?n.name:/(^|:)migration$/.test(n.id)?"the upgrade":n.id.startsWith("form:")?"a visitor via a form":/[:_/]/.test(n.id)?{human:"somebody",visitor:"a visitor",agent:"an agent",rule:"a rule",system:"the system"}[r]:n.id}var ke="$archived",xe=n=>n?.[ke]===!0,pw=(n,e=!1)=>e==="all"||xe(n)===e,Go=n=>n===!0||n==="true"?!0:n==="all"?"all":!1,vt="$leftAlone",cr=new Set([ke,vt]);var Ln="0.1.72";var ge=class extends Error{constructor(t,r){super(r?`${t}
2
+ \u2192 ${r}`:t);this.hint=r;this.name="SchemaError"}};function ff(n,e){let t=n,r=new Map;for(let a of t){if(r.has(a.kind))throw new ge(`Duplicate node kind "${a.kind}"`,"Each kind may be declared once; merge the two defineNode calls.");r.set(a.kind,a)}let o=new Map;for(let a of t)for(let[d,u]of Object.entries(a.edges)){if(u.to!=="*"){for(let p of u.to)if(!r.has(p))throw new ge(`Edge "${d}" on "${a.kind}" points at undeclared kind "${p}"`,`Declared kinds: ${[...r.keys()].join(", ")}`)}let c=o.get(d);c?c.from.push(a.kind):o.set(d,{from:[a.kind],decl:u})}let i=new Map;for(let[a,{from:d,decl:u}]of o){let c=d.map(p=>r.get(p).edges[a].to);i.set(a,{kind:a,from:d,to:c.includes("*")?"*":[...new Set(c.flat())],cardinality:u.cardinality??"many",...u.description===void 0?{}:{description:u.description}})}let s=new Map;for(let a of t)s.set(a.kind,qa(a.fields,{id:L().check(lt(1)),kind:pt(a.kind)}));return{definitions:t,computed:e,kinds:t.map(a=>a.kind),edgeKinds:[...i.keys()],definition(a){let d=r.get(a);if(!d)throw new ge(`Unknown node kind "${String(a)}"`,`Declared kinds: ${[...r.keys()].join(", ")}`);return d},tryDefinition(a){return r.get(a)},edge(a){return i.get(a)},edgeAllowed(a,d,u){let c=r.get(d)?.edges[a];return c?c.to==="*"||c.to.includes(u):!1},parseNode(a){let d=a?.kind;if(typeof d!="string")throw new ge("Node is missing a `kind`");let u=s.get(d);if(!u)throw new ge(`Unknown node kind "${d}"`,`Declared kinds: ${[...r.keys()].join(", ")}`);let c={},p={};for(let[f,g]of Object.entries(a))cr.has(f)?g===!0&&(p[f]=!0):c[f]=g;let l=u.parse(c);return Object.keys(p).length>0?{...l,...p}:l},__node:void 0}}var he={snapshot:2,op:3},pn=class extends Error{constructor(t,r,o,i,s){super(s!==void 0?`This ${t} holds a ${s} that @graview ${Ln} does not know: upgrade the framework to read it.`:`This ${t} is in a newer format (${r}${i?`, written by @graview ${i}`:""}) than @graview ${Ln} reads (${o}). `+(t==="snapshot"?"Refold it from the log, or upgrade the framework.":"Upgrade the framework to read it."));this.what=t;this.found=r;this.supported=o;this.writtenBy=i;this.unknown=s;this.name="NewerFormatError"}},Ko=["add-node","remove-node","patch-node","add-edge","remove-edge","splice-text"],pf=new Set(Ko);function Vo(n){throw new pn("op",he.op+1,he.op,void 0,`primitive "${n?.op}"`)}var Bo=new Set;function Uo(n){for(let e in n){let t=n[e]?.$type;if(t!==void 0&&!Bo.has(t))throw new pn("op",he.op+1,he.op,void 0,`value type "${t}" in "${e}"`)}}function Wo(n){for(let e of n.primitives)pf.has(e?.op)||Vo(e)}function F(n){return`${n.kind}\0${n.from}\0${n.to}`}var Cn={addedNodes:[],removedNodes:[],changedNodes:[],addedEdges:[],removedEdges:[],touched:[]};function qo(n){return n.addedNodes.length===0&&n.removedNodes.length===0&&n.changedNodes.length===0&&n.addedEdges.length===0&&n.removedEdges.length===0}function hf(n,e){let t=new Set([...Object.keys(n),...Object.keys(e)]),r=[];for(let o of t){let i=n[o],s=e[o];JSON.stringify(i)!==JSON.stringify(s)&&r.push(o)}return r.sort()}function ze(n,e){let t=new Map(n.nodes.map(l=>[l.id,l])),r=new Map(e.nodes.map(l=>[l.id,l])),o=e.nodes.filter(l=>!t.has(l.id)),i=n.nodes.filter(l=>!r.has(l.id)),s=[];for(let l of n.nodes){let f=r.get(l.id);if(!f||f===l)continue;let g=hf(l,f);g.length>0&&s.push({before:l,after:f,fields:g})}let a=new Map(n.edges.map(l=>[F(l),l])),d=new Map(e.edges.map(l=>[F(l),l])),u=e.edges.filter(l=>!a.has(F(l))),c=n.edges.filter(l=>!d.has(F(l))),p=new Set;for(let l of o)p.add(l.id);for(let l of i)p.add(l.id);for(let l of s)p.add(l.after.id);for(let l of[...u,...c])p.add(l.from),p.add(l.to);return{addedNodes:o,removedNodes:i,changedNodes:s,addedEdges:u,removedEdges:c,touched:[...p].sort()}}function Ge(n,e,t){let r=new Set(t.flatMap(i=>i.op==="patch-node"||i.op==="splice-text"?[i.id]:"node"in i?[i.node.id]:[i.edge.from,i.edge.to]));if(r.size===0)return Cn;let o=i=>({nodes:i.nodes.filter(s=>r.has(s.id)),edges:i.edges.filter(s=>r.has(s.from)||r.has(s.to))});return ze(o(n),o(e))}var lr={idLength:200,dataLength:4096,sameKindPerPair:1};function bd({id:n,data:e}){if(n!==void 0&&!(typeof n=="string"&&n.length<=lr.idLength&&/^[^\s\p{Cc}]+$/u.test(n)))return`A link's id is 1\u2013${lr.idLength} characters with no space`;if(e!==void 0&&!(e&&typeof e=="object"&&!Array.isArray(e)&&JSON.stringify(e).length<=lr.dataLength))return`A link's data is a JSON object of at most ${lr.dataLength} characters`}function gf(n){let e=n?.issues;return!Array.isArray(e)||e.length===0?n instanceof Error?n.message:String(n):e.map(t=>{let r=t.path?.length?B(String(t.path.at(-1))):null,o=t.message??"is not what the declaration allows";return r?`${r}: ${o}`:o}).join("; ")}var N=class extends Error{constructor(t,r){super(r?`${t}
3
+ ${r}`:t);this.hint=r;this.name="GraphError"}},Jo="That link is not there to take away.",Ke={remove:"That record is not there to remove.",change:"That record is not there to change.",link:"A link names a record that is not there.",mergeInto:"The record to merge into is not there."},q=class extends N{constructor(t,r){super(r);this.id=t;this.name="MissingRecordError"}};function ur(n,e){try{n.parseNode(e);return}catch(t){if(t instanceof ge)throw t;let r=t.issues??[];return{fields:new Set(r.flatMap(i=>i.code==="unrecognized_keys"&&i.keys?[...i.keys]:typeof i.path?.[0]=="string"?[i.path[0]]:[""])),error:t}}}var Ho="n\0",Yo="e\0",H=class n{constructor(e,t={}){this.schema=e;this.validate=t.validate??!0}nodes=new Map;edges=new Map;linkIds=new Map;outIndex=new Map;inIndex=new Map;rank=0;ranks=new Map;lapsed=new Map;reordered=!1;counts=new Map;archived=new Set;listeners=new Set;validate;static from(e,t,r={}){let o=new n(e,r);return o.load(t),o}load(e){let t=this.snapshot();this.restore(e);let r=ze(t,this.snapshot());return this.emit(r),r}getNode(e){return this.nodes.get(e)}has(e){return this.nodes.has(e)}allNodes(e){return this.reach([...this.nodes.values()],e,this.held)}count(e,t){return t||this.archived.size?this.nodesOfKind(e,t).length:this.counts.get(e)??0}allEdges(e){return this.reach([...this.edges.values()],e,t=>this.archived.has(t.from)||this.archived.has(t.to))}nodesOfKind(e,t){return this.allNodes(t).filter(r=>r.kind===e)}edgesOfKind(e,t){return this.allEdges(t).filter(r=>r.kind===e)}out(e,t,r){return this.reach(this.resolve(this.outIndex.get(e),t,"to"),r,this.held)}in(e,t,r){return this.reach(this.resolve(this.inIndex.get(e),t,"from"),r,this.held)}neighbors(e,t){let r=new Map;for(let o of[...this.out(e,void 0,t),...this.in(e,void 0,t)])r.set(o.id,o);return[...r.values()]}isArchived(e){return this.archived.has(e)}outEdges(e,t){return this.edgesFrom(this.outIndex.get(e),t)}inEdges(e,t){return this.edgesFrom(this.inIndex.get(e),t)}linkById(e){return this.edges.get(this.linkIds.get(e))}snapshot(){return{nodes:[...this.nodes.values()],edges:[...this.edges.values()]}}get size(){return{nodes:this.nodes.size,edges:this.edges.size}}applyPrimitives(e,t={}){let r=this.snapshot();try{for(let i of e)this.applyOne(i,t.restoring===!0,t.inPlace===!0);this.settleOrder()}catch(i){throw this.restore(r),i}let o=Ge(r,this.snapshot(),e);return this.emit(o),o}preview(e,t={}){return n.from(this.schema,this.snapshot(),{validate:this.validate}).applyPrimitives(e,t)}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}restore(e){let t=new Map([...this.lapsed,...this.ranks]);for(let o of[this.nodes,this.edges,this.linkIds,this.outIndex,this.inIndex,this.ranks,this.lapsed,this.counts,this.archived])o.clear();this.reordered=!1;for(let o of e.nodes)this.insertNode(o,!0);for(let o of e.edges)this.insertEdge(o,!0);let r=[...this.ranks.keys()];if(r.every((o,i)=>t.get(o)>(o[0]===r[i-1]?.[0]?t.get(r[i-1]):0))){for(let[o,i]of t)(this.ranks.has(o)?this.ranks:this.lapsed).set(o,i);for(;this.lapsed.size>4096;)this.lapsed.delete(this.lapsed.keys().next().value)}}tally(e,t){this.counts.set(e,(this.counts.get(e)??0)+t)}place(e,t){let r=t?this.lapsed.get(e):void 0;if(r===void 0){this.ranks.set(e,++this.rank);return}this.ranks.set(e,r),this.lapsed.delete(e),this.reordered=!0}lapse(e){let t=this.ranks.get(e);t!==void 0&&(this.ranks.delete(e),this.lapsed.set(e,t),this.lapsed.size>4096&&this.lapsed.delete(this.lapsed.keys().next().value))}settleOrder(){if(!this.reordered)return;this.reordered=!1;let e=o=>(i,s)=>this.ranks.get(o+i[0])-this.ranks.get(o+s[0]),t=[...this.nodes.entries()].sort(e(Ho));this.nodes.clear();for(let[o,i]of t)this.nodes.set(o,i);let r=[...this.edges.entries()].sort(e(Yo));this.edges.clear();for(let[o,i]of r)this.edges.set(o,i)}emit(e){if(!(e.addedNodes.length===0&&e.removedNodes.length===0&&e.changedNodes.length===0&&e.addedEdges.length===0&&e.removedEdges.length===0))for(let t of this.listeners)t(e)}applyOne(e,t,r){switch(e.op){case"add-node":Uo(e.node),this.insertNode(e.node,t,r);return;case"remove-node":{let o=e.node.id,i=this.nodes.get(o);if(!i)throw new q(o,Ke.remove);for(let s of[...this.outEdges(o),...this.inEdges(o)])this.deleteEdge(s);this.tally(i.kind,-1),this.archived.delete(o),this.nodes.delete(o),this.lapse(Ho+o),this.outIndex.delete(o),this.inIndex.delete(o);return}case"patch-node":{let o=this.nodes.get(e.id);if(!o)throw new q(e.id,Ke.change);Uo(e.after);let i={...o};for(let[a,d]of Object.entries(e.after))tn(d)?delete i[a]:i[a]=d;let s=t?i:this.checkPatch(o,i,Object.keys(e.after));this.nodes.set(e.id,s),this.archived[xe(s)?"add":"delete"](e.id),s.kind!==o.kind&&(this.tally(o.kind,-1),this.tally(s.kind,1));return}case"splice-text":{let o=this.nodes.get(e.id);if(!o)throw new q(e.id,Ke.change);let i=o[e.field],s;try{typeof i=="string"&&e.field!=="id"&&e.field!=="kind"&&(s=Wr(i,e))}catch{}if(s===void 0)throw new N(`Cannot splice ${e.id}.${e.field}: it does not hold ${JSON.stringify(e.removed)} at ${e.at}`,"A corrupt op: the text it was made against is not the text the log folds to.");let a={...o,[e.field]:s};this.nodes.set(e.id,t?a:this.checkPatch(o,a,[e.field]));return}case"add-edge":this.insertEdge(e.edge,t,r);return;case"remove-edge":{let o=e.edge.id===void 0?e.edge:this.linkById(e.edge.id);if(!o||!this.edges.has(F(o)))throw new q(e.edge.id??F(e.edge),Jo);this.deleteEdge(o);return}default:Vo(e)}}check(e){if(!this.validate)return e;try{return this.schema.parseNode(e)}catch(t){throw this.refusal(e,t)}}checkPatch(e,t,r){if(!this.validate)return t;let o=this.schema.tryDefinition(String(t.kind))?.fields?.shape;if(!o)return this.check(t);for(let a of r){if(a==="id"||a==="kind"||cr.has(a))continue;let d=o[a];if(!d){delete t[a];continue}let u=d.safeParse(t[a]);u.success&&(u.data===void 0?delete t[a]:t[a]=u.data)}let i=ur(this.schema,t);if(i===void 0)return t;let s=ur(this.schema,e)?.fields??new Set;if([...i.fields].some(a=>r.includes(a)||!s.has(a)))throw this.refusal(t,i.error);return t}refusal(e,t){if(t instanceof ge)return t;{let r=e?.id??"?",o=e?.kind??"?",i=this.schema.tryDefinition(o),s=i&&e&&typeof e=="object"?V(i,e):r;return new N(`${s} does not match what ${o} declares`,gf(t))}}insertNode(e,t,r=!1){if(this.nodes.has(e.id))throw new N(`Duplicate node id "${e.id}"`);this.nodes.set(e.id,t?e:this.check(e)),xe(e)&&this.archived.add(e.id),this.tally(e.kind,1),this.place(Ho+e.id,r)}insertEdge(e,t,r=!1){let o=this.nodes.get(e.from),i=this.nodes.get(e.to);if(!o||!i){let a=o?e.to:e.from;throw new q(a,Ke.link)}if(this.validate&&!t&&!this.schema.edgeAllowed(e.kind,o.kind,i.kind)){let a=this.schema.edge(e.kind),d=a?[o.kind,...a.from].filter((u,c,p)=>a.from.includes(u)&&p.indexOf(u)===c):[];throw new N(`Edge "${e.kind}" is not declared from ${o.kind} to ${i.kind}`,a?`Declared: ${d.map(u=>`${u} -> ${[this.schema.tryDefinition(u).edges[e.kind].to].flat().join("|")}`).join("; ")}`:`No edge kind "${e.kind}" is declared in this schema`)}let s=F(e);if(!t&&(e.id!==void 0||e.data!==void 0)){let a=this.edges.get(s),d=bd(e)??(a&&e.id!==void 0&&a.id!==e.id?`A second "${e.kind}" link between two records is not allowed yet`:(this.linkIds.get(e.id)??s)!==s?`Link id "${e.id}" is already taken`:void 0);if(d)throw new N(d)}this.edges.has(s)||(this.edges.set(s,e),e.id!==void 0&&this.linkIds.set(e.id,s),this.place(Yo+s,r),this.index(this.outIndex,e.from,s),this.index(this.inIndex,e.to,s))}deleteEdge(e){let t=F(e),r=this.edges.get(t)?.id;r!==void 0&&this.linkIds.delete(r),this.edges.delete(t),this.lapse(Yo+t),this.outIndex.get(e.from)?.delete(t),this.inIndex.get(e.to)?.delete(t)}index(e,t,r){(e.get(t)??e.set(t,new Set).get(t)).add(r)}edgesFrom(e,t){if(!e)return[];let r=[];for(let o of e){let i=this.edges.get(o);i&&(t===void 0||i.kind===t)&&r.push(i)}return r}resolve(e,t,r){let o=[];for(let i of this.edgesFrom(e,t)){let s=this.nodes.get(i[r]);s&&o.push(s)}return o}held=e=>this.archived.has(e.id);reach(e,t,r){let o=t?.archived??!1;return o==="all"||!o&&!this.archived.size?e:e.filter(i=>r(i)===o)}};var fr=class extends Error{constructor(t,r){super(`No invariant registered under "${t}" (required by node "${r}")`);this.invariant=t;this.nodeId=r;this.name="UnregisteredInvariantError"}};function mf(n,e){return{...e,name:n}}var pr=class extends Error{constructor(e){super(e),this.name="RuleBudgetError"}};function vd(n,e,t){try{return e().map(r=>r.status?r:{...r,status:"violated"})}catch(r){let o=r instanceof pr,i=r instanceof Error?r.message:String(r),s=n.label??n.name.replace(/-/g," ");return[{invariant:n.name,status:o?"over-budget":"could-not-judge",...t!==void 0?{subjectId:t}:{},label:s,message:`${s} could not be judged: ${i}`,nodeIds:t!==void 0?[t]:[],repairs:[]}]}}function Zn(n,e,t={}){let r=t.context??{},o=t.today===void 0?{}:{today:t.today},i=t.onUnregistered??"skip",s=new Set(e.map(l=>l.name)),a=[];for(let l of e)l.scope==="graph"&&a.push(...vd(l,()=>l.evaluate({graph:n,subject:void 0,context:r,...o}),void 0));let d=e.filter(l=>l.scope!=="graph"),u=new Map;for(let l of d){let f=l.scope.kind,g=u.get(f);g?g.push(l):u.set(f,[l])}for(let l of n.allNodes()){let f=n.schema.tryDefinition(l.kind),g=f?.requiresInvariant?.(l)??null;if(t.subjectFilter&&!t.subjectFilter(l,r))continue;if(g!==null&&!s.has(g)){if(i==="throw")throw new fr(g,l.id);continue}let h=!to(f,l,t.today);for(let v of u.get(l.kind)??[]){if(h&&v.judgesPast!==!0)continue;let m=v.scope.match;m&&!m(l)||a.push(...vd(v,()=>v.evaluate({graph:n,subject:l,context:r,...o}),l.id))}}let c=new Set,p=a.filter(l=>{let f=`${l.message}|${[...l.nodeIds].sort().join(",")}`;return c.has(f)?!1:(c.add(f),!0)}).map(l=>{let f=eo(l.message);return f===l.message?l:{...l,message:f}});return Xo?Xo(n,e,p,t.today):p}var Xo;function jw(n){Xo=n}function yf(n,e){let t=new Set(e);return n.filter(r=>r.nodeIds.some(o=>t.has(o))||r.subjectId!==void 0&&t.has(r.subjectId))}function bf(n){let e=new Set(n.map(r=>r.invariant)).size;if(e===0)return"All rules hold";let t=`${e} ${e===1?"rule":"rules"} broken`;return n.length>e?`${t} in ${n.length} places`:t}var hr="type-text",ae={};function wt(n){return n?.automated===!0&&n.kind!=="human"&&n.kind!=="rule"}function Qo(n){return wt(n)&&n?.tidying===!0}function Gw(n,e){return n.lineage?.stopsKind!==!0||n.undoes===void 0||n.mutation!==null||n.primitives.length>0?!1:e===void 0||e.suggests!==void 0&&Qo(e.author)&&e.lineage?.proposedBy===void 0}var kd=n=>n?.[vt]===!0,vf=(n,e)=>kd(("graph"in n?n.graph:n).getNode(e));function wd(n,e,t){let r=n.tryDefinition(e);return t===void 0?r?.tidying:r?.edges?.[t]?.tidying}var de=globalThis[Symbol.for("@graview/core:declines")]??={};function xd(n,e,t,r,o={}){let i=o.declaration!==!1,s=(a,d)=>`${r} may not ${a}: ${d}.`;for(let a of t){let d="edge"in a?a.edge:void 0,u=(d?[d.from,d.to]:["id"in a?a.id:a.node.id]).map(c=>e.getNode(c)??("node"in a?a.node:void 0));for(let c of u){if(!c)continue;if(kd(c))return s(`change \u201C${V(n.tryDefinition(c.kind),c)}\u201D`,"a person said to leave it alone");if(!i)continue;let p=wd(n,c.kind);if(p==="never")return s(`change ${ue(n,c.kind)} on its own`,"the app says they are never tidied");if(d&&p==="no-links")return s(`link or unlink ${ue(n,c.kind)} on its own`,"the app says they are never linked automatically")}if(d&&i&&u[0]&&wd(n,u[0].kind,d.kind)==="never")return s(`${a.op==="add-edge"?"make":"break"} a \u201C${d.kind}\u201D link on its own`,"the app says that relation is never tidied")}}var ne=class extends Error{constructor(t,r="refused"){super(t);this.sentence=t;this.reason=r;this.name="ActRefusal"}};var gr="publish",ei=n=>n?.mode==="on-publish",ni=(n,e,t)=>ei(n)&&!D(e)&&(t==="published"||!(z(e).roles??[]).some(r=>n.working.includes(r))),J=globalThis[Symbol.for("@graview/core:publishing")]??={};J.input=()=>se({through:W(ln())});var kt=class{constructor(e,t,r){this.present=e;this.timeline=t;this.unversioned=r}nodes=new Map;edges=new Map;touching=new Map;seq=Number.MAX_SAFE_INTEGER;wrote=new Map;begin(e){this.seq=e,this.wrote.clear()}writerOf(e){return t=>{let r=`${e}\0${t}`;return this.wrote.has(r)?this.wrote.get(r):this.timeline?.writers?.writerAt(e,t,this.seq)}}note(e,t){let r=e.op==="add-node"?e.node.id:e.op==="patch-node"||e.op==="splice-text"?e.id:"";if(r===""||this.unversioned?.has(r))return;let o=e.op==="add-node"?Object.keys(e.node):e.op==="splice-text"?[e.field]:Object.keys(e.after);for(let i of o)i!=="id"&&i!=="kind"&&this.wrote.set(`${r}\0${i}`,t(r,i))}node(e){return this.nodes.has(e)?this.nodes.get(e)??void 0:this.present.getNode(e)}setNode(e,t){this.nodes.set(e,t)}setEdge(e,t){let r=F(e);this.edges.set(r,t?e:null);for(let o of[e.from,e.to]){let i=this.touching.get(o);i||this.touching.set(o,i=new Set),i.add(r)}}incident(e){let t=new Map;for(let r of[...this.present.outEdges(e),...this.present.inEdges(e)]){let o=F(r);this.edges.has(o)||t.set(o,r)}for(let r of this.touching.get(e)??[]){let o=this.edges.get(r);o&&t.set(r,o)}return[...t.values()]}undo(e){switch(e.op){case"add-node":this.setNode(e.node.id,null);return;case"remove-node":this.setNode(e.node.id,e.node);return;case"patch-node":{if(this.unversioned?.has(e.id))return;let t=this.node(e.id);if(!t)return;this.setNode(e.id,Sd(t,e.before));return}case"splice-text":{let t=this.unversioned?.has(e.id)?void 0:this.node(e.id);t&&this.setNode(e.id,qr(t,e,!0));return}case"add-edge":this.setEdge(e.edge,!1);return;case"remove-edge":this.setEdge(e.edge,!0);return}}apply(e){switch(e.op){case"add-node":this.setNode(e.node.id,e.node);return;case"remove-node":for(let t of this.incident(e.node.id))this.setEdge(t,!1);this.setNode(e.node.id,null);return;case"patch-node":{if(this.unversioned?.has(e.id))return;let t=this.node(e.id);if(!t)return;this.setNode(e.id,Sd(t,e.after));return}case"splice-text":{let t=this.unversioned?.has(e.id)?void 0:this.node(e.id);t&&this.setNode(e.id,qr(t,e));return}case"add-edge":this.setEdge(e.edge,!0);return;case"remove-edge":this.setEdge(e.edge,!1);return}}};function Sd(n,e){let t={...n};for(let[r,o]of Object.entries(e))tn(o)?delete t[r]:t[r]=o;return t}var wf=n=>n.op==="add-node"||n.op==="remove-node"?n.node.id:n.op==="patch-node"||n.op==="splice-text"?n.id:void 0;function ti(n,e,t,r){let o=c=>{let p=e.node(c);return p?t.served(p,e.writerOf(c))!==void 0:t.sees?.(c)??!1},i=wf(n);if(i===void 0){let c=n.edge,p=t.edgeClean(c)&&o(c.from)&&o(c.to);return e.apply(n),{primitives:p?[n]:[],faithful:!0}}let s=e.node(i),a=s?t.served(s,e.writerOf(i)):void 0;e.apply(n),e.note(n,r);let d=e.node(i),u=d?t.served(d,e.writerOf(i)):void 0;if(!a&&!u)return{primitives:[],faithful:!1};if(!a&&u){let c=e.incident(i).filter(l=>t.edgeClean(l)&&o(l.from===i?l.to:l.from)).map(l=>({op:"add-edge",edge:l})),p=n.op==="add-node"&&u===n.node&&c.length===0;return{primitives:p?[n]:[{op:"add-node",node:u},...c],faithful:p}}if(a&&!u){let c=n.op==="remove-node"&&a===s;return{primitives:c?[n]:[{op:"remove-node",node:a}],faithful:c}}if(n.op==="patch-node"){let c=(l,f)=>g=>g in l==(f!==void 0&&g in f);if(Object.keys(n.after).every(l=>c(a,s)(l)&&c(u,d)(l)))return{primitives:[n],faithful:!0};let p=l=>Object.fromEntries(Object.keys(n.after).map(f=>[f,f in l?l[f]:le]));return{primitives:[{op:"patch-node",id:i,before:p(a),after:p(u)}],faithful:!1}}if(n.op==="splice-text"){let c=n.field;if(a[c]===s[c]&&u[c]===d[c])return{primitives:[n],faithful:!0};let p=l=>({[c]:c in l?l[c]:le});return{primitives:[{op:"patch-node",id:i,before:p(a),after:p(u)}],faithful:!1}}return{primitives:[{op:"remove-node",node:a},{op:"add-node",node:u}],faithful:!1}}function Rd(n,e,t){if(n.length===0)return[];let r=e.log.all(),o=r[0]?.seq??0,i=n.every(l=>r[l.seq-o]?.id===l.id),s=new kt(e.present,e);if(!i)return s.begin(e.log.length??o+r.length),n.map(l=>{let f=z(l.author).id,g=l.primitives.map(h=>ti(h,s,t,()=>f));return{op:l,primitives:g.flatMap(h=>h.primitives),faithful:g.every(h=>h.faithful)}});let a=new Set(n.map(l=>l.seq)),d=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY;for(let l of a)l<d&&(d=l),l>u&&(u=l);d-=o,u-=o;let c=kf(r,d,e.present,t),p=c?new kt(e.present,e,c.unversioned):s;for(let l=r.length-1;l>=d;l--){let f=r[l].primitives;for(let g=f.length-1;g>=0;g--)p.undo(f[g])}return xf(n,r,d,u,a,p,c?.judge??t,e)}function kf(n,e,t,r){let{sees:o,names:i}=r;if(!o||!i)return;let s=new Set,a=new Set,d=new Set,u=(p,l)=>{s.has(p)||a.has(p)||(o(p)?i(l)?(a.add(p),d.delete(p)):d.add(p):(s.add(p),d.delete(p)))};for(let p=e;p<n.length;p++)for(let l of n[p].primitives)l.op==="add-node"||l.op==="remove-node"?u(l.node.id,l.node):l.op==="patch-node"?(u(l.id,l.before),u(l.id,l.after)):l.op==="splice-text"&&(u(l.id,{}),s.has(l.id)||(a.add(l.id),d.delete(l.id)));for(let p of d){let l=t.getNode(p);l&&i(l)&&(d.delete(p),a.add(p))}return{unversioned:new Set([...d,...s]),judge:{...r,served:(p,l)=>d.has(p.id)?p:s.has(p.id)?void 0:r.served(p,l)}}}function xf(n,e,t,r,o,i,s,a){let d=new Map;for(let u=t;u<=r;u++){let c=e[u];if(i.begin(c.seq),!o.has(c.seq)){for(let f of c.primitives)i.apply(f);continue}let p=(f,g)=>a.writers?.writerAt(f,g,c.seq+1),l=c.primitives.map(f=>ti(f,i,s,p));d.set(c.seq,{op:c,primitives:l.flatMap(f=>f.primitives),faithful:l.every(f=>f.faithful)})}return n.map(u=>d.get(u.seq))}function Yw(n,e,t,r){let o=new kt(e.present,e);return o.begin(e.log.length??e.log.all().length),n.flatMap(i=>ti(i,o,t,()=>r).primitives)}var Ad="A change you cannot see",Od={kind:"system",id:"withheld",name:"Someone"};function Gn(n){return n.withheld===!0}var xt=Oe,_d=(n,e)=>Object.entries(n).some(([t,r])=>t!=="id"&&t!=="kind"&&Z(r,e));function Pd(n){if(typeof n!="function")return n;let e=n,t=r=>e(r.id)&&!_d(r,e)?r:void 0;return{sees:e,shows:e,served:t,servedWith:t,optional:()=>!1,kindOf:()=>{}}}function Z(n,e){if(typeof n=="string")return!e(n);if(n===null||typeof n!="object")return!1;if(Array.isArray(n)){for(let t=0;t<n.length;t++)if(Z(n[t],e))return!0;return!1}for(let t in n)if(Object.hasOwn(n,t)&&(!e(t)||Z(n[t],e)))return!0;return!1}function Ed(n,e){let t=r=>!e(r);return n.primitives.some(r=>xt(r).some(t))||[...n.writes,...n.reads].some(t)||n.mutation!==null&&Z(n.mutation.args,e)}function Sf(n,e){if(xt(n).every(e.shows))switch(n.op){case"add-node":{let t=e.served(n.node);return t?t===n.node?n:{op:"add-node",node:t}:void 0}case"remove-node":{let t=n.node;return _d(t,e.sees)?{op:"remove-node",node:Object.fromEntries(Object.entries(t).filter(([r,o])=>r==="id"||r==="kind"||!Z(o,e.sees)))}:n}case"patch-node":{let t=e.kindOf(n.id),r={};for(let[i,s]of Object.entries(n.after))if(!Z(s,e.sees))r[i]=s;else if(t!==void 0&&e.optional(t,i))r[i]=le;else return;let o=Object.fromEntries(Object.entries(n.before).filter(([,i])=>!Z(i,e.sees)));return{op:"patch-node",id:n.id,before:o,after:r}}case"add-edge":case"remove-edge":return Z(n.edge,e.sees)?void 0:n;case"splice-text":return Z(n.removed,e.sees)||Z(n.inserted,e.sees)?void 0:n}}function mr(n,e,t){let r=Pd(e),o=i=>r.shows(i)&&Nd(r,i);return{id:n.id,seq:n.seq,batch:n.batch,author:Od,intent:Ad,mutation:null,primitives:t??n.primitives.flatMap(i=>{let s=Sf(i,r);return s?[s]:[]}),reads:n.reads.filter(o),writes:n.writes.filter(o),at:n.at,...n.undoes!==void 0?{undoes:n.undoes}:{},withheld:!0}}function Kn(n,e){let t=Pd(e);if(t.hides?.()===!1)return[...n];let r=t.pin?.()??t;return Rf(Md(n,r),r)}function Rf(n,e){let t,r=o=>{let i=e.timeline?.log.all();if(!i)return!1;t??=new Map(i.map(s=>[s.id,s]));for(let s=o.undoes;s!==void 0;){let a=t.get(s);if(!a||Md([a],e)[0].withheld)return!0;s=a.undoes}return!1};return n.map(o=>o.undoes===void 0||o.withheld||de.liftTold?.(o,e)||!r(o)?o:mr(o,e,o.primitives))}function Md(n,e){if(e.redact)return e.redact(n);if(e.timeline){let t={served:(r,o)=>e.servedWith(r,o),edgeClean:r=>!Z(r,e.sees),sees:e.sees,names:r=>Z(r,e.sees)};return Rd(n,e.timeline,t).map(({op:r,primitives:o,faithful:i})=>(!r.withheld&&i?$d(r,e,o):void 0)??mr(r,e,o))}return n.map(t=>(!t.withheld&&!Ed(t,e.shows)?$d(t,e):void 0)??mr(t,e))}function $d(n,e,t){let r=n.inverse??n.primitives;if(t&&t.length<n.primitives.length){if(!t.length)return;r=r.filter(h=>xt(h).every(e.shows));let{inverse:f,...g}=n;n={...g,primitives:t}}let o=f=>e.sees(f)&&Nd(e,f),i=n.reads.filter(o),s=new Set(n.primitives.flatMap(xt)),a=n.writes.filter(f=>o(f)||e.sees(f)&&s.has(f)),d=i.length===n.reads.length&&a.length===n.writes.length?n:{...n,reads:i,writes:a},u=e.actor!==void 0&&z(n.author).id===e.actor;if(!u&&n.described?.some(f=>!e.sees(f)))return;if(!Z(n,e.sees))return d;let c=new Set,p=f=>{if(typeof f=="string")c.add(f);else if(Array.isArray(f))for(let g of f)p(g);else if(f!==null&&typeof f=="object")for(let[g,h]of Object.entries(f))c.add(g),p(h)};t&&p(t);let l=f=>e.sees(f)||c.has(f);if(!Z(r,l))return u&&n.mutation&&p(n.mutation.args),Z({...d,primitives:[],inverse:[]},u?l:e.sees)?void 0:d}function Nd(n,e){return n.timeline===void 0||n.kindOf(e)!==void 0}var hn=class extends N{constructor(t){super(t.message);this.check=t;this.name="UndoBlockedError"}get blockedBy(){return this.check.blockedBy}};function St(n,e){let t=new Set(e),r=n.undoneIds(),o=n.all().filter(h=>t.has(h.batch)&&!r.has(h.id)&&!ar(h)),i=[...n.epochs()].reverse().find(h=>h.horizon);if(i){let h=new Set(n.all().map(m=>m.batch)),v=e.filter(m=>!h.has(m));if(v.length>0)return{ok:!1,ops:o,blockedBy:[],includeBatches:[],reason:"missing",message:`Cannot undo ${v.map(m=>`batch ${m}`).join(", ")}: it is not after the undo horizon at op ${i.seq}${i.at?` (${i.at})`:""}. What was done before the horizon is archived, and undo does not reach behind it.`}}if(o.length===0)return{ok:!1,ops:o,blockedBy:[],includeBatches:[],reason:"missing",message:e.length===0?"No batch given to undo":`Nothing live to undo in ${e.join(", ")} \u2014 already undone, or never applied`};if(o.some(Gn))return{ok:!1,ops:o,blockedBy:[],includeBatches:[],reason:"forbidden",message:o.every(Gn)?"Cannot undo a change you cannot see: only somebody who can see it can take it back.":"Cannot undo this here: part of it is a change you cannot see, and only somebody who can see it can take it back."};if(o.some(h=>h.enabledModules!==void 0))return{ok:!1,ops:o,blockedBy:[],includeBatches:[],message:"Cannot undo turning a module off or on: it is changed by turning the module the other way."};if(o.some(h=>h.sentOut!==void 0))return{ok:!1,ops:o,blockedBy:[],includeBatches:[],message:o.every(h=>h.sentOut===void 0||h.sentOut.refused)?"Nothing to take back: nothing went out.":"Nothing to take back: an invitation already went out. Change the guests here, and the next pass sends that."};let s=i&&o.some(h=>h.publishedThrough!==void 0)?J.undo?.(n,o,i):void 0;if(s)return{ok:!1,ops:o,blockedBy:[],includeBatches:[],message:s};let a=new Set;for(let h of o)for(let v of h.writes)a.add(v);let d=Math.min(...o.map(h=>h.seq)),u=n.epochs().find(h=>h.change!==void 0&&h.seq>d);if(u){let h=o.find(v=>v.seq<u.seq);return{ok:!1,ops:o,blockedBy:[],includeBatches:[],message:`Cannot undo "${h.intent}": ${h.intent===u.change?"it changed the declaration":`it was done before the declaration changed (${u.change})`}, and undo does not reach back across that change.`}}let c=new Map(n.all().map(h=>[h.id,h.seq])),p=o.flatMap(h=>h.primitives),l=[];for(let h of n.all()){if(h.seq<=d||t.has(h.batch)||r.has(h.id)||h.undoes!==void 0&&(c.get(h.undoes)??-1)>d)continue;let v=ae.aside?.(p,h);if(v===!0)continue;let m=[...new Set([...h.reads.filter(k=>a.has(k)),...v??[]])];m.length>0&&l.push({op:h,overlap:m})}if(l.length===0)return{ok:!0,ops:o};let f=l.filter(h=>!Gn(h.op)).map(h=>`"${h.op.intent}" (op ${h.op.id}, read ${h.overlap.join(", ")})`).join("; ");if(l.some(h=>Gn(h.op)))return{ok:!1,ops:o,blockedBy:l,includeBatches:[],message:`Cannot undo on its own \u2014 ${f?`a later operation depends on it: ${f}; and `:""}a later change you cannot see depends on it, which only somebody who can see it can take back.`};let g=[...new Set(l.map(h=>h.op.batch))];return{ok:!1,ops:o,blockedBy:l,includeBatches:g,message:`Cannot undo on its own \u2014 a later operation depends on it: ${f}. Include ${g.map(h=>`batch ${h}`).join(", ")} to undo them together.`}}function zd(n,e){return e?ri(e,n).flatMap(t=>[...t.primitives]):[...n].sort((t,r)=>r.seq-t.seq).flatMap(t=>rn(t))}function ri(n,e){return ae.undone?ae.undone(n,e):[...e].sort((t,r)=>r.seq-t.seq).map(t=>({op:t,primitives:rn(t)}))}var Ve=class extends Error{refusal;constructor(e){super(e.message),this.name="PermissionDeniedError",this.refusal=e}};function $f(n){let e=n instanceof Error?n.message:String(n);if(n instanceof Ve){let t=n.refusal.wouldNeed;return{reason:"forbidden",sentence:e,...t.length>0?{wouldNeed:[...t]}:{}}}return n instanceof q?{reason:"missing",sentence:e}:n instanceof ne?{reason:n.reason,sentence:n.sentence}:n instanceof hn?{reason:n.check.reason??"invalid",sentence:e}:{reason:"invalid",sentence:e}}var Se=class extends N{constructor(t,r){super(`Invalid arguments for mutation "${t}"`,r.map(o=>`${o.path.map(String).join(".")||"(root)"}: ${o.message}`).join("; "));this.mutation=t;this.issues=r;this.name="InvalidArguments"}};var Af=["edit","remove","archive","unarchive","merge","leave-alone","allow-tidying"];var bk=n=>Af.map(e=>`${e}-${n}`);function vk(n){let e=/^(edit|remove|archive|unarchive|merge|leave-alone|allow-tidying|skip|detach|split)-(.+)$/.exec(n);return e?{act:e[1],kind:e[2]}:void 0}var oi=["connect","disconnect"],Td=n=>n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),ii=(n,e,t)=>`${n}-${e}-${Td(t)}`;function wk(n,e){let t=/^(connect|disconnect)-(.+)$/.exec(n);if(t){for(let[r,o]of e)if(t[2].startsWith(`${r}-`)){for(let i of o)if(t[2]===`${r}-${Td(i)}`)return{act:t[1],kind:r,relation:i}}}}var kk=n=>[...n].flatMap(([e,t])=>[...t].flatMap(r=>oi.map(o=>ii(o,e,r)))),Id=n=>`${/^[aeiou]/i.test(n)?"an":"a"} ${n}`;function jd(n,e){let t=e.also?` (${e.also})`:"";return{title:`${e.one?`${n==="connect"?"Set":"Clear"} the ${e.to}`:`${n==="connect"?"Link":"Unlink"} ${Id(e.to)}`}${t}`,fromTheOtherEnd:`${n==="connect"?"Link":"Unlink"} ${Id(e.from)}${t}`}}function Dd(n,e,t,r){if(t.cardinality!=="one"||t.to==="*"||t.to.length!==1||t.to[0]!==n)return;let o=t.description?.trim().replace(/\.$/,"");return o&&/^the\s+\S/i.test(o)&&!/[.;:!?,()]/.test(o)&&o.split(/\s+/).length<=8?{to:o.replace(/^the\s+/i,"")}:{also:r(e)}}var gn="vote-suggestion",Fd="Sign in to vote on this suggestion.";function Rt(n){return n?n.shared===!0||n.kind==="visitor"?!0:Rt(n.onBehalfOf):!1}function yr(n){if(!n)return;if(n.shared!==!0&&n.kind!=="visitor")return yr(n.onBehalfOf);let e=n.visitorKey??(n.shared===!0?void 0:n.id);return e||void 0}function Ld(){return{name:gn,title:"Vote on a suggestion",input:se({suggestion:L(),vote:Ha([pt("for"),pt("against"),Ua()])}),apply(){}}}var br=globalThis[Symbol.for("@graview/core:voting")]??={};function Of(n,e){if(!e||n.length===0)return null;let t=e.roles,r=o=>t?o.wouldNeed.some(i=>t.includes(i)):o.wouldNeed.length>0;return n.every(({refusal:o})=>r(o))?e:null}function _f(n,e){let t=o=>o?._zod?.def,r={};for(let o of new Set(e)){let i=n.tryDefinition(o),s=i?.fields?.shape??{};for(let[a,d]of Object.entries(s)){let u=t(d);for(let p=0;p<6&&u?.innerType!==void 0&&u.type!=="enum";p++)u=t(u.innerType);if(u?.type==="array"&&(u=t(u.element)),u?.type!=="enum"||!u.entries)continue;let c=i?.display?.format?.[a];(r[o]??={})[a]=Object.fromEntries(Object.values(u.entries).map(p=>[String(p),c?c(p):dn(String(p))]))}}return r}var vr={scene:0,overview:10,rail:20,popover:30,dialog:40,toast:50},Pf={plots:0,stage:1,tag:2,ties:2,lines:3,tieLabels:4,occupants:6,seatMarks:7,zoom:8,card:10,opened:11},Ef={under:0,raised:1,over:2},si=n=>`--graview-layer-${n}`,Mf=n=>`var(${si(n)}, ${vr[n]})`;function Nf(){return Object.keys(vr).map(n=>` ${si(n)}: ${vr[n]};`).join(`
4
+ `)}function zf(n){let e=n.onBehalfOf??n;return{kind:e.kind,...e.id!==void 0?{id:e.id}:{},...e.name!==void 0?{name:e.name}:{},...e.roles!==void 0?{roles:e.roles}:{}}}function Cd(){return`sub_${(globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`).replace(/-/g,"").slice(0,20)}`}function Zd(n){return{...n,id:n.id??Cd(),at:n.at??new Date().toISOString()}}function If(n=[]){let e=[...n],t=new Set,r=()=>{for(let o of t)o()};return{list:o=>o===void 0?e:e.filter(i=>i.who.id===o),add(o){let i=Zd(o);return e=[...e.filter(s=>s.id!==i.id),i],r(),i},remove(o){let i=e.length;e=e.filter(a=>a.id!==o);let s=e.length<i;return s&&r(),s},onChange(o){return t.add(o),()=>t.delete(o)}}}var Tf=n=>`Op "${n.id}" has seq ${n.seq}, so the log begins at seq ${n.seq}: a log that begins past 0 begins at its undo horizon, and none was given (a checkpoint epoch, or { horizon })`,Vn=class n{ops=[];marks=[];start=0;get length(){return this.start+this.ops.length}get horizon(){return this.start}all(){return this.ops}opsFrom(e){return this.ops.slice(Math.max(0,e-this.start))}append(e){if(e.seq!==this.length)throw new Error(this.length===0&&e.seq>0?Tf(e):`Op "${e.id}" has seq ${e.seq} but the log is ${this.length} long`);Wo(e),this.ops.push(tt(e))}static from(e,t=[],r={}){let o=new n,i=[...t].reverse().find(d=>d.horizon),s=r.horizon??i?.seq??0;if(!Number.isInteger(s)||s<0)throw new Error(`A log cannot begin at seq ${s}`);if(i&&r.horizon!==void 0&&i.seq!==r.horizon)throw new Error(`A log said to begin at seq ${r.horizon} has its checkpoint at seq ${i.seq}`);let a=e[0];if(a&&s>0&&a.seq!==s)throw new Error(`A log compacted at seq ${s} begins with op "${a.id}" at seq ${a.seq}`);o.start=s;for(let d of e)o.append(d);for(let d of t)o.markEpoch(d);return o}replace(e,t=[],r={}){let o=n.from(e,t,r);this.ops=o.ops,this.marks=o.marks,this.start=o.start}epochs(){return this.marks}horizonEpoch(){for(let e=this.marks.length-1;e>=0;e--)if(this.marks[e].horizon)return this.marks[e]}lastEpoch(){return this.marks.at(-1)}markEpoch(e){if(!Number.isInteger(e.seq)||e.seq<0||e.seq>this.length)throw new Error(`An epoch at seq ${e.seq} starts past the end of a log ${this.length} long`);if(e.seq<this.start)throw new Error(`An epoch at seq ${e.seq} is behind the horizon at seq ${this.start}: it went to the archive with the ops before it`);let t=this.lastEpoch();if(t&&e.seq<t.seq)throw new Error(`An epoch at seq ${e.seq} comes before the last one, at seq ${t.seq}`);this.marks.push(e)}truncate(e){if(!Number.isInteger(e)||e<this.start||e>this.length)throw new Error(`Cannot cut a log ${this.length} long back to ${e}`);let t=this.lastEpoch();if(t&&t.seq>e)throw new Error(`Cannot cut the log back to ${e}: an epoch begins at seq ${t.seq}`);return this.ops.splice(e-this.start)}checkpointAt(e,t,r={}){if(!Number.isInteger(t)||t<this.start||t>this.length)throw new Error(`No checkpoint at seq ${t}: this log holds seqs ${this.start} to ${this.length}`);let o=[...this.marks].reverse().find(a=>a.seq<=t);if(o?.seq===t)return{...o,horizon:!0};let i=this.fold(e,{...r,...o?{from:o}:{},to:t}).snapshot(),s=this.ops[t-1-this.start]?.at??o?.at;return{seq:t,base:i,...o?.version!==void 0?{version:o.version}:{},...s!==void 0?{at:s}:{},horizon:!0}}compact(e){if(!Number.isInteger(e.seq)||e.seq<this.start||e.seq>this.length)throw new Error(`Cannot compact at seq ${e.seq}: this log holds seqs ${this.start} to ${this.length}`);let t=this.ops.slice(0,e.seq-this.start),r=this.marks.filter(o=>o.seq<e.seq);return this.ops=this.ops.slice(e.seq-this.start),this.marks=[{...e,horizon:!0},...this.marks.filter(o=>o.seq>e.seq)],this.start=e.seq,{ops:t,epochs:r}}get(e){return this.ops.find(t=>t.id===e)}live(){let e=this.undoneIds();return this.ops.filter(t=>!e.has(t.id))}undoneIds(){return $t(this.ops)}opsInBatch(e){return this.ops.filter(t=>t.batch===e)}batches(){return ai(this.ops,this.undoneIds())}fold(e,t={}){let r=t.from?.seq??0;if(r<this.start)throw new Error(t.from?`An epoch at seq ${r} is behind the horizon at seq ${this.start}: fold from the checkpoint`:`A log compacted at seq ${this.start} does not fold from empty: fold from its checkpoint`);let o=t.from?.base??{nodes:[],edges:[]},i=H.from(e,o,t.validate!==void 0?{validate:t.validate}:{}),s=t.to??this.length;for(let a of this.ops.slice(r-this.start,Math.max(0,s-this.start)))jf(i,a);return i}toJSON(){return[...this.ops]}};function jf(n,e){if(e.undoes!==void 0){n.applyPrimitives(e.primitives,{restoring:!0});return}try{n.applyPrimitives(e.primitives)}catch{n.applyPrimitives(e.primitives,{restoring:!0})}}function $t(n){let e=new Map;for(let r of n){if(!r.undoes)continue;let o=e.get(r.undoes);o?o.push(r.id):e.set(r.undoes,[r.id])}let t=new Map;for(let r=n.length-1;r>=0;r--){let o=n[r],i=e.get(o.id)??[];t.set(o.id,!i.some(s=>t.get(s)===!0))}return new Set(n.filter(r=>t.get(r.id)===!1).map(r=>r.id))}function Df(n){let e=[...new Set(n.map(t=>t.intent))];return e.length<=3?e.join("; "):`${e.slice(0,2).join("; ")}; and ${e.length-2} more`}function ai(n,e){let t=[],r=new Map;for(let o of n){let i=r.get(o.batch);i?i.push(o):(r.set(o.batch,[o]),t.push(o.batch))}return t.map(o=>{let i=r.get(o)??[],s=i[0],a=i.length>1?i.filter(d=>!ar(d)):i;return{id:o,author:s.author,intent:s.batchIntent??Df(a),at:s.at,...s.lineage?{lineage:s.lineage}:{},ops:i,undone:a.every(d=>e.has(d.id))}})}var di=(n,e)=>`${n}\0${e}`,Gd=new WeakMap;function Ff(n,e){let t=new Map;for(let[o,i]of Object.entries(e??{}))for(let[s,a]of Object.entries(i))t.set(di(o,s),[{seq:n-1,by:a}]);return{base:n,end:n,read:[],fields:t,written:[],seqOf:new Map,writers:{writerAt:(o,i,s)=>{let a=t.get(di(o,i));if(!a)return;let d=0,u=a.length;for(;d<u;){let c=d+u>>1;a[c].seq<s?d=c+1:u=c}return d===0?void 0:a[d-1].by}}}}function Lf(n){if(n.op==="add-node")return[n.node.id,Object.keys(n.node).filter(e=>e!=="id"&&e!=="kind")];if(n.op==="patch-node")return[n.id,Object.keys(n.after).filter(e=>!tn(n.after[e]))];if(n.op==="splice-text")return[n.id,[n.field]]}function Cf(n,e){let t=n.end,r=z(e.author).id,o=e.undoes!==void 0?n.seqOf.get(e.undoes):void 0,i=[];for(let s of e.primitives){let a=Lf(s);if(!a)continue;let[d,u]=a;for(let c of u){let p=e.undoes===void 0?r:o!==void 0?n.writers.writerAt(d,c,o):void 0,l=di(d,c),f=n.fields.get(l);f||n.fields.set(l,f=[]),f.push({seq:t,by:p}),i.push(l)}}n.written.push({seq:t,keys:i}),n.seqOf.set(e.id,t),n.read.push(e),n.end++}function Zf(n,e){for(;n.written.length>0&&n.written.at(-1).seq>=e;){let{keys:t}=n.written.pop();for(let r of t)n.fields.get(r)?.pop()}for(let t of n.read.slice(e-n.base))n.seqOf.delete(t.id);n.read.length=e-n.base,n.end=e}function At(n){let e=n.all(),t=typeof n.length=="number"?n.length:e.length,r=t-e.length,o=Gd.get(n);if(o&&o.base<=r&&r<=o.end){let i=Math.min(o.end,t);for(;i>r&&e[i-1-r]!==o.read[i-1-o.base];)i--;i===r&&r>o.base&&i<o.end?o=void 0:(i<o.end&&Zf(o,i),r>o.base&&(o.read=o.read.slice(r-o.base),o.base=r))}else o=void 0;o||Gd.set(n,o=Ff(r,r>0?[...n.epochs?.()??[]].reverse().find(i=>i.horizon)?.writers:void 0));for(let i=o.end;i<t;i++)Cf(o,e[i-r]);return o.writers}function Kd(n,e,t,r){let o=At(n),i={};for(let s of t)for(let a in s){if(!Object.hasOwn(s,a)||a==="id"||a==="kind"||!r(s[a]))continue;let d=o.writerAt(s.id,a,e);d!==void 0&&((i[s.id]??={})[a]=d)}return i}var mn={served:new WeakSet},Ot=n=>n.fields!==void 0||(n.hide?.length??0)>0,Vd=(n,e,t)=>(n??[]).some(r=>r.kinds.includes(e)&&(r.hide?.includes(t)===!0||r.fields!==void 0&&!r.fields.includes(t))),Bd=(n,e,t,r)=>Object.entries(t).some(([o,i])=>typeof i=="string"&&i.trim()!==""&&n.includes(i.trim())&&r(e,o)),Ie=n=>mn.on===!0||mn.served.has(n);var ci=new WeakMap;function Gf(n,e){let t=new Map(Object.entries(e?.removed??{})),r=new Map(Object.entries(e?.creators??{})),o=n===0||e?.removed!==void 0;return{base:n,end:n,read:[],kinds:t,creators:r,entries:[],records:{kindOf:i=>t.get(i),creatorOf:i=>r.get(i),knowsAll:o}}}function Kf(n,e){let t=n.end;for(let r of e.primitives){if(r.op!=="add-node"&&r.op!=="remove-node")continue;let{id:o,kind:i}=r.node;if(n.kinds.has(o)||(n.kinds.set(o,i),n.entries.push({seq:t,id:o,creator:!1})),r.op!=="add-node"||n.creators.has(o)||e.undoes!==void 0)continue;let s=z(e.author).id;s!==void 0&&(n.creators.set(o,s),n.entries.push({seq:t,id:o,creator:!0}))}n.read.push(e),n.end++}function Vf(n,e){for(;n.entries.length>0&&n.entries.at(-1).seq>=e;){let t=n.entries.pop();(t.creator?n.creators:n.kinds).delete(t.id)}n.read.length=e-n.base,n.end=e}function ce(n){let e=n.all(),t=typeof n.length=="number"?n.length:e.length,r=t-e.length,o=ci.get(n);if(o&&o.base<=r&&r<=o.end){let i=Math.min(o.end,t);for(;i>r&&e[i-1-r]!==o.read[i-1-o.base];)i--;i===r&&r>o.base&&i<o.end?o=void 0:(i<o.end&&Vf(o,i),r>o.base&&(o.read=o.read.slice(r-o.base),o.base=r))}else o=void 0;o||ci.set(n,o=Gf(r,r>0?Bf(n,r):void 0));for(let i=o.end;i<t;i++)Kf(o,e[i-r]);return o.records}function Bf(n,e){let t=[...n.epochs?.()??[]].reverse().find(r=>r.horizon);return t?.seq===e?t:void 0}function Ud(n,e,t){ce(n);let r=ci.get(n),o=[new Set,new Set];for(let a=r.entries.length-1;a>=0&&r.entries[a].seq>=e;a--)o[+r.entries[a].creator].add(r.entries[a].id);let i={},s={};for(let[a,d]of r.creators)o[1].has(a)||(i[a]=d);for(let[a,d]of r.kinds)!o[0].has(a)&&!t(a)&&(s[a]=d);return r.records.knowsAll?{creators:i,removed:s}:{creators:i}}function Be(n,e,t,r,o,i=mn.on===!0){if(!n?.sees?.length||D(e))return!0;let s=n.sees.filter(a=>a.kinds.includes(t.kind)&&(i||!Ot(a)));return s.length===0?!1:(e=z(e),s.some(a=>{if(!be(a,e))return!1;if(!a.own&&!a.via)return!0;let d=e.id;if(d===void 0)return!1;let u=c=>un(e,c.id);return a.via?r.out(t.id,a.via).some(u)||r.in(t.id,a.via).some(u):u(t)||r.out(t.id).some(u)||r.in(t.id).some(u)||o?.creatorOf(t.id)===d}))}var qd=Symbol.for("@graview/core:node-ref"),Wd=n=>typeof n=="object"&&n!==null?n[qd]:void 0;function Ue(n="*"){return Uf(L().check(lt(1)),n)}function Uf(n,e){let t=Object.freeze(e==="*"?["*"]:[...e]),r=o=>{o&&Object.defineProperty(o,qd,{value:t,enumerable:!0,configurable:!0})};return r(n),r(C(n)),n}function _t(n){if(typeof n!="object"||n===null)return;let e=Wd(n);if(e)return e;let t=C(n),r=Wd(t);if(r)return r;let o=t?.innerType;return o?_t(o):void 0}function Pt(n){let e=n.shape;if(!e)return[];let t=[];for(let[r,o]of Object.entries(e)){let i=_t(o);i&&t.push({name:r,kinds:i,optional:o.safeParse(void 0).success})}return t}var ui=new Set;function wr(n,e){return D(e)?ui:n.modules?.disabledKinds??ui}function We(n,e){return D(e)?!1:(n.policy?.sees?.length??0)>0||wr(n,e).size>0}function Xd(n,e){if(!We(n,e))return()=>!0;let t=n.modules?.disabledKinds??ui,r=n.policy?.sees??[],o=z(e),i=Ie(n),s=c=>!t.has(c)&&(r.length===0||r.some(p=>p.kinds.includes(c)&&be(p,o)&&!p.own&&!p.via&&(i||!Ot(p)))),a=n.schema.kinds.every(s),d=c=>s(c)&&Wf(n.schema,c).every(p=>p.every(l=>l==="*"?a:s(l))),u=a&&n.schema.kinds.every(d);return c=>u||c!==void 0&&d(c)}function Bn(n,e){return t=>{let r=wr(n,e);if(!n.policy?.sees?.length&&r.size===0)return!0;let o=ce(n.log),i=n.graph.getNode(t);if(i)return!r.has(i.kind)&&Be(n.policy,e,i,n.graph,o,Ie(n));let s=o.kindOf(t)??Qd(n,o,t);return s===void 0?!0:!r.has(s)&&Be(n.policy,e,{id:t,kind:s},{out:()=>[],in:()=>[]},o,Ie(n))}}function Wf(n,e){let t=n?.tryDefinition?.(e)?.fields?.shape??{};return Object.values(t).flatMap(r=>{let o=_t(r);return o&&r.safeParse?.(void 0).success===!1?[o]:[]})}var qf={out:()=>[],in:()=>[]};function Qd(n,e,t){if(e.knowsAll||mn.served.has(n))return;let r=t.indexOf(":");if(r<=0)return;let o=t.slice(0,r);return n.schema?.tryDefinition(o)?o:void 0}function Hf(n,e,t=new Map,r){let o=wr(n,e);if(!n.policy?.sees?.length&&o.size===0)return()=>!0;let i=ce(n.log);return s=>{let a=t.get(s);if(a!==void 0)return a;let d,u=n.graph.getNode(s);if(u)d=!o.has(u.kind)&&Be(n.policy,e,u,n.graph,i,Ie(n));else{let c=i.kindOf(s)??Qd(n,i,s);if(c===void 0)return r?.add(s),!0;d=!o.has(c)&&Be(n.policy,e,{id:s,kind:c},qf,i,Ie(n))}return t.set(s,d),d}}function Yf(n){let e=new Map;return(t,r)=>{let o=`${t}\0${r}`,i=e.get(o);if(i===void 0){let s=n?.tryDefinition(t)?.fields?.shape,a=s?.[r];i=s!==void 0&&(a===void 0||a.safeParse?.(void 0).success===!0),e.set(o,i)}return i}}function kr(n,e){return ec(n,e).lens}var fi=()=>({judged:new Map,shown:new Map});function ec(n,e){let t=Yf(n.schema),r=D(e)?void 0:z(e).id,o=()=>n.log.length??n.log.all().length,i=new WeakMap,s=n.graph,a=(c,p,l,f,g)=>{let h=(b,R)=>{if(!c(b.id))return;let S;for(let E in b)if(!(!Object.hasOwn(b,E)||E==="id"||E==="kind"||!Z(b[E],c))&&!(r!==void 0&&R(E)===r)){if(!t(b.kind,E))return;(S??=[]).push(E)}if(!S)return b;let x=S.join("\0"),_=i.get(b);if(_?.without===x)return _.node;let M=Object.fromEntries(Object.entries(b).filter(([E])=>!S.includes(E)));return i.set(b,{without:x,node:M}),M},v=b=>{let R=l();return h(b,S=>p().writerAt(b.id,S,R))},m=new WeakMap,k=g?b=>{let R=m.get(b);return R||m.set(b,R={node:v(b)}),R.node}:v,$=b=>{if(!c(b))return!1;let R=s.getNode(b);return R===void 0||k(R)!==void 0},w=g?.shown??new Map,O=g?b=>{let R=w.get(b);return R===void 0&&w.set(b,R=$(b)),R}:$,A=s.outEdges&&s.inEdges?{present:{getNode:b=>s.getNode(b),outEdges:b=>s.outEdges(b),inEdges:b=>s.inEdges(b)},log:n.log,get writers(){return p()}}:void 0,y={sees:c,shows:O,served:k,servedWith:h,optional:t,kindOf:f,...r!==void 0?{actor:r}:{},...A?{timeline:A}:{},hides:()=>We(n,e),pin:g?()=>y:()=>d(fi())};return mn.lens?.(y,n,e)??y};function d(c){let p,l=o(),f=ce(n.log);return a(Hf(n,e,c.judged,c.unnamed),()=>p??=At(n.log),()=>l,g=>s.getNode(g)?.kind??f.kindOf(g),c)}return{lens:a(Bn(n,e),()=>At(n.log),o,c=>s.getNode(c)?.kind??ce(n.log).kindOf(c)),pinWith:d}}var Hd=new WeakMap,Yd=new WeakMap,Jf=n=>{let e=new Set;for(let t of n)for(let r of t.primitives)r.op==="add-node"||r.op==="remove-node"?e.add(r.node.id):r.op==="patch-node"||r.op==="splice-text"?e.add(r.id):(e.add(r.edge.from),e.add(r.edge.to));return e};function nc(n,e){if(!We(n,e))return n.log.all();let t=n.log.all(),r=n.log.length??t.length,o=r-t.length,i=[...wr(n,e)].sort().join("\0"),s=tc(e),a=Hd.get(n.log);a||Hd.set(n.log,a=new Map);let d=a.get(s),{pinWith:u}=ec(n,e),c=Yd.get(n.log);c||Yd.set(n.log,c=new Set);let p=d!==void 0&&d.horizon===o&&d.off===i&&d.length<=r&&(d.length===o||t[d.length-1-o]===d.last);if(d&&p){if(d.length===r)return d.ops;let g=t.slice(d.length-o),h=u(fi()),v=!0,m=Jf(g);for(let k of m){let $=d.judgments.judged.get(k),w=d.judgments.shown.get(k);if($!==void 0&&h.sees(k)!==$||w!==void 0&&h.shows(k)!==w){v=!1;break}}if(v){for(let k of m)if(c.has(k)){v=!1;break}}if(v){let k=[...d.ops,...Kn(g,u(d.judgments))],$={horizon:o,off:i,length:r,last:t.at(-1),ops:k,judgments:d.judgments};return a.set(s,$),k}}let l={...fi(),unnamed:c},f=Kn(t,u(l));return a.set(s,{horizon:o,off:i,length:r,last:t.at(-1),ops:f,judgments:l}),f}function Xf(n,e,t){return(t.subjectId===void 0||!e(t.subjectId)||n.shows(t.subjectId))&&t.nodeIds.every(r=>!e(r)||n.shows(r))&&!Z(t,n.sees)}function pi(n,e){return{all:()=>n,undoneIds:()=>$t(n),epochs:e}}var Jd=new WeakMap;function tc(n){let e=D(n)?n:z(n);return`${n.kind}|${e.id??""}|${(e.roles??[]).join(",")}|${n.onBehalfOf?`for:${n.id??""}`:""}${pe(n)?`|as:${we(n)}`:""}`}var rc=(n,e)=>`${tc(n)}@${e}`,li=(n,e)=>{let t=Reflect.get(n,e,n);return typeof t=="function"?t.bind(n):t},Qf=Symbol.for("@graview/core:seat");function Re(n,e,t={}){if(ni(n.publishing,e,t.as)){if(J.served)return J.served(n,e);throw new Error("Load @graview/core/publishing to serve a reader of an app that publishes.")}return ic(n,e)}var ep=()=>J.served!==void 0;function oc(n){let e=Jd.get(n);return e||Jd.set(n,e=new Map),e}function ic(n,e){if(!We(n,e))return n;let t=rc(e,"head"),r=oc(n),o=r.get(t);if(o)return o;let i=n.graph,s=kr(n,e),a=w=>{let O=S=>S===void 0?void 0:w.served(S),A=S=>O(S)!==void 0,y=S=>A(i.getNode(S));return{served:O,seenNode:A,seenId:y,seenEdge:S=>y(S.from)&&y(S.to)&&!Z(S,w.sees),servedAll:S=>S.flatMap(x=>O(x)??[])}},{served:d,seenId:u}=a(s),c=()=>a(s.pin?.()??s),p=(w,O)=>{let A=At(n.log),y=s.pin?.()??s,b=w.nodes.flatMap(S=>y.servedWith(S,x=>A.writerAt(S.id,x,O))??[]),R=new Set(b.map(S=>S.id));return{nodes:b,edges:w.edges.filter(S=>R.has(S.from)&&R.has(S.to)&&!Z(S,y.sees))}},l=w=>{let{removed:O,writers:A,published:y,declines:b,...R}=w,S=p(w.base,w.seq);if(!w.creators)return{...R,base:S};let x=new Set(S.nodes.map(M=>M.id)),_=Object.fromEntries(Object.entries(w.creators).filter(([M,E])=>x.has(M)&&!Z(E,s.sees)));return{...R,base:S,creators:_}},f=w=>w&&l(w),g=()=>nc(n,e),h=()=>pi(g(),()=>n.log.epochs()),v=new Proxy(i,{get(w,O){switch(O){case"getNode":return A=>d(w.getNode(A));case"has":return u;case"allNodes":case"nodesOfKind":return(...A)=>c().servedAll(w[O](...A));case"count":return(...A)=>c().servedAll(w.nodesOfKind(...A)).length;case"allEdges":case"edgesOfKind":case"outEdges":case"inEdges":return(...A)=>w[O](...A).filter(c().seenEdge);case"out":case"in":case"neighbors":return(A,...y)=>{let b=c();return b.seenId(A)?b.servedAll(w[O](A,...y)):[]};case"snapshot":return()=>{let A=w.snapshot(),y=c();return{...A,nodes:y.servedAll(A.nodes),edges:A.edges.filter(y.seenEdge)}};case"size":{let A=c();return{nodes:A.servedAll(w.allNodes({archived:"all"})).length,edges:w.allEdges({archived:"all"}).filter(A.seenEdge).length}}default:return li(w,O)}}}),m=()=>{let w=g();return ai(w,$t(w))},k=new Proxy(n.log,{get(w,O){switch(O){case"all":case"toJSON":return()=>[...g()];case"epochs":return()=>w.epochs().map(l);case"lastEpoch":return()=>f(w.lastEpoch());case"horizonEpoch":return()=>f(w.horizonEpoch());case"live":return()=>{let A=g(),y=$t(A);return A.filter(b=>!y.has(b.id))};case"get":return A=>g().find(y=>y.id===A);case"opsInBatch":return A=>g().filter(y=>y.batch===A);case"batches":return m;default:return li(w,O)}}}),$=new Proxy(n,{get(w,O){switch(O){case Qf:return{store:w,principal:e};case"graph":return v;case"log":return k;case"snapshot":return v.snapshot;case"batches":return m;case"canUndo":return A=>St(h(),typeof A=="string"?[A]:A);case"violations":return A=>w.violations(A,v).filter(y=>Xf(s,b=>i.has(b),y));case"findings":return()=>w.findings().filter(A=>(A.id.includes("->")?A.id.split("->").map((b,R)=>R===0?b.slice(b.indexOf(":")+1):b):[A.id]).every(b=>!i.has(b)||u(b))&&!Z(A,s.sees));case"wouldChange":return A=>w.wouldChange(A,e);case"preview":return(A,y,b)=>w.preview(A,y,{author:e,...b});case"seenBy":return(A,y)=>Re(w,A,y);case"seenFor":return e;case"servedSeq":return w.servedSeq;case"checkpoint":return A=>f(w.checkpoint(A));default:return li(w,O)}}});return r.set(t,$),$}J.kit={seatView:ic,viewsOf:oc,viewKey:rc,diff:ze,reads:ni};var hi=new Set;function gi(n,e){if(!n||e===void 0)return{enabled:new Set(Object.keys(n??{})),disabledKinds:hi,disabledMutations:hi,disabledInvariants:hi,administered:sc(n,new Set(Object.keys(n??{})))};let t=new Set,r=a=>{if(!(t.has(a)||!(a in n))){t.add(a);for(let d of n[a]?.requires??[])r(d)}};for(let a of e)r(a);for(let[a,d]of Object.entries(n))d.required&&r(a);let o=new Set,i=new Set,s=new Set;for(let[a,d]of Object.entries(n))if(!t.has(a)){for(let u of d.kinds??[])o.add(u);for(let u of d.mutations??[])i.add(u);for(let u of d.invariants??[])s.add(u)}for(let a of t){let d=n[a];for(let u of d?.kinds??[])o.delete(u);for(let u of d?.mutations??[])i.delete(u);for(let u of d?.invariants??[])s.delete(u)}return{enabled:t,disabledKinds:o,disabledMutations:i,disabledInvariants:s,administered:sc(n,t)}}function sc(n,e){let t=new Map;for(let[r,o]of Object.entries(n??{}))e.has(r)&&o.visibility==="admin"&&t.set(r,o);return t}var ac=new WeakMap;function yi(n){let e=ac.get(n);if(e)return e;let t=new Map,r=new Map;for(let o of n.definitions){let i=o.derives;i&&(r.set(o.kind,i),t.set(i.from,[...t.get(i.from)??[],[o.kind,i]]))}return ac.set(n,e={bySource:t,byKind:r}),e}var Un=n=>yi(n).byKind.size>0;function dc(n,e,t){let r={archived:"all"};return(e.sourceEnd==="to"?n.out(t,e.via,r):n.in(t,e.via,r)).filter(o=>o.kind===e.from)}function np(n,e,t,r){let o={archived:"all"};return(t.sourceEnd==="to"?n.in(r,t.via,o):n.out(r,t.via,o)).filter(i=>i.kind===e)}var cc=(n,e)=>JSON.stringify(n??null)===JSON.stringify(e??null);function mi(n,e){let t={},r={};for(let[o,i]of Object.entries(e)){let s=n[o];cc(s,i)||(t[o]=s,r[o]=i)}return Object.keys(r).length>0?{op:"patch-node",id:n.id,before:t,after:r}:void 0}function xr(n,e,t,r={}){let{bySource:o,byKind:i}=yi(n);if(i.size===0)return[];let s=[],a=h=>{h&&(e.applyPrimitives([h]),s.push(h))},d=h=>e.getNode(h)?.kind,u=new Map,c=(h,v=!1)=>u.set(h,(u.get(h)??!1)||v),p=new Set(t.flatMap(h=>h.op==="remove-node"?[h.node.id]:[])),l=new Map,f=new Map;for(let h of t)if(h.op==="patch-node"&&i.has(d(h.id)??"")&&f.set(h.id,new Set([...f.get(h.id)??[],...Object.keys(h.after)])),h.op==="add-node"&&o.has(h.node.kind))c(h.node.id);else if(h.op==="patch-node"){let v=d(h.id);v&&o.has(v)&&(c(h.id,ke in h.after),l.set(h.id,new Set([...l.get(h.id)??[],...Object.keys(h.after)])))}else if(h.op==="add-edge"){let v=e.getNode(h.edge.from),m=e.getNode(h.edge.to);for(let[k,$]of[[v,m],[m,v]]){let w=$?i.get($.kind):void 0;k&&w&&w.via===h.edge.kind&&w.from===k.kind&&c(k.id)}}else if(h.op==="remove-edge"&&(p.has(h.edge.from)||p.has(h.edge.to))){let v=p.has(h.edge.from)?h.edge.from:h.edge.to,m=e.getNode(v===h.edge.from?h.edge.to:h.edge.from),k=m?i.get(m.kind):void 0,$=t.find(w=>w.op==="remove-node"&&w.node.id===v)?.node.kind;m&&k&&k.via===h.edge.kind&&k.from===$&&!xe(m)&&a(mi(m,{[ke]:!0}))}for(let h of t){if(h.op!=="patch-node")continue;let v=e.getNode(h.id),m=v?i.get(v.kind):void 0;if(!v||!m)continue;let k=Object.keys(h.after).filter(y=>Object.hasOwn(m.back,y));if(k.length===0)continue;let $=dc(e,m,v.id);if($.length!==1)continue;let w=$[0],O={};for(let y of k){let b=m.back[y];if(l.get(w.id)?.has(b))continue;let R=v[y];n.tryDefinition(w.kind)?.fixed?.[b]===void 0&&(r.mayWriteBack&&!r.mayWriteBack(w,b,R)||(O[b]=R))}let A=mi(w,O);A&&(a(A),c(w.id))}let g=new Set;for(let[h,v]of u){if(g.has(h))continue;g.add(h);let m=e.getNode(h);if(m)for(let[k,$]of o.get(m.kind)??[])for(let w of np(e,k,$,m.id)){let O={...$.values(e,m,w)};if(!l.has(m.id))for(let y of f.get(w.id)??[])delete O[y];v&&(O[ke]=xe(m)?!0:void 0);let A=mi(w,O);A&&(a(A),o.has(k)&&u.set(w.id,v))}}return s}function lc(n,e,t){let{byKind:r}=yi(n);if(r.size===0)return[];let o=[];for(let i of t){let s=r.get(i.kind);if(!s)continue;let a=dc(e,s,i.id);if(a.length===1)for(let[d,u]of Object.entries(s.values(e,a[0],i))){let c=i[d];cc(c,u)||o.push({id:i.id,source:a[0].id,field:d,holds:c,follows:u})}}return o}function uc(n){return n.normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase().trim().replace(/\s+/g," ")}var Et=class{constructor(e){this.graph=e;for(let t of e.allNodes({archived:"all"}))this.file(t);e.subscribe(t=>this.follow(t))}kinds=new Map;filed=new Map;labelOf(e){return this.filed.get(e)?.label}lookup(e,t){let r=uc(t);if(r.length===0)return{exact:[],prefix:[]};let o=e.includes("*")?[...this.kinds.values()]:e.flatMap(a=>this.kinds.get(a)??[]),i=[],s=[];for(let a of o)for(let d=bi(a.sorted,r);d<a.sorted.length&&a.sorted[d].startsWith(r);d+=1){let u=[...a.ids.get(a.sorted[d])??[]];s.push(...u),a.sorted[d]===r&&i.push(...u)}return{exact:i,prefix:s}}follow(e){for(let t of e.removedNodes)this.unfile(t.id);for(let t of e.changedNodes)this.unfile(t.after.id),this.file(t.after);for(let t of e.addedNodes)this.file(t)}file(e){let t=V(this.graph.schema.tryDefinition(e.kind),e),r=uc(t);this.filed.set(e.id,{kind:e.kind,key:r,label:t});let o=this.kinds.get(e.kind);o||this.kinds.set(e.kind,o={ids:new Map,sorted:[]});let i=o.ids.get(r);i?i.add(e.id):(o.ids.set(r,new Set([e.id])),o.sorted.splice(bi(o.sorted,r),0,r))}unfile(e){let t=this.filed.get(e);if(!t)return;this.filed.delete(e);let r=this.kinds.get(t.kind),o=r?.ids.get(t.key);if(!r||!o||(o.delete(e),o.size>0))return;r.ids.delete(t.key);let i=bi(r.sorted,t.key);r.sorted[i]===t.key&&r.sorted.splice(i,1)}};function bi(n,e){let t=0,r=n.length;for(;t<r;){let o=t+r>>>1;n[o]<e?t=o+1:r=o}return t}function tp(n,e){return e.includes("*")?"record":e.map(t=>X(n.tryDefinition(t),t)).join(" or ")}function fc(n,e,t,r){let o=tp(n,e.kinds);if(r.length===0)return{ok:!1,reason:"none",candidates:r,message:`There is no ${o} called "${t}".`};let i=r.slice(0,10).map(a=>`${a.label} (${a.id})`),s=r.length>i.length?`, and ${r.length-i.length} more`:"";return{ok:!1,reason:"ambiguous",candidates:r,message:`"${t}" names more than one ${o}: ${i.join(", ")}${s}. Pass the id of the one you mean as ${e.name}.`}}function vi(n){if(n===null||typeof n!="object")return JSON.stringify(n)??"null";if(Array.isArray(n))return`[${n.map(r=>r===void 0?"null":vi(r)).join(",")}]`;let e=n;return`{${Object.keys(e).filter(r=>e[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${vi(e[r])}`).join(",")}}`}var pc=(n,e)=>n.key<e.key?-1:n.key>e.key?1:0;function rp(n){let e=n.nodes.map(r=>({key:r.id,value:r})).sort(pc),t=n.edges.map(r=>({key:F(r),value:{kind:r.kind,from:r.from,to:r.to,id:r.id,data:r.data}})).sort(pc);return vi({nodes:e.map(r=>r.value),edges:t.map(r=>r.value)})}function Wn(n){return`sha256:${gc(rp(n))}`}function hc(n,e,t,r={}){let o=r.validate??!0,i=r.base??{nodes:[],edges:[]},s=Wn(t),a=H.from(n,i,{validate:o});for(let[h,v]of e.entries())try{a.applyPrimitives(v.primitives)}catch(m){let k=e[h-1];return{ok:!1,expected:Wn(a.snapshot()),actual:s,...k?{divergedAfter:k.id}:{},reason:`The log does not fold: op "${v.id}" (${v.intent}) could not be applied. ${m instanceof Error?m.message:String(m)}`}}let d=Wn(a.snapshot());if(d===s)return{ok:!0,hash:s};let u=h=>{let v=H.from(n,i,{validate:o});for(let m=0;m<=h;m++)v.applyPrimitives(e[m].primitives);return Wn(v.snapshot())},c=h=>{try{let v=H.from(n,t,{validate:o});for(let m=e.length-1;m>h;m--)v.applyPrimitives(rn(e[m]));return Wn(v.snapshot())}catch{return}},p=h=>{let v=c(h);return v!==void 0&&v!==u(h)},l=-1,f=e.length-1;for(;l<f;){let h=Math.floor((l+f)/2);p(h)?f=h:l=h+1}let g=f>=0?e[f]:void 0;return{ok:!1,expected:d,actual:s,...g?{divergedAfter:g.id}:{},reason:g?`The graph and the fold of its log part after op "${g.id}" (${g.intent}).`:"The graph and the fold of its log disagree before any op: the base it folds from does not match."}}var op=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ip=new TextEncoder,sp=new Uint32Array(64),ap=new Uint32Array(8),Sr=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function gc(n){let e=ip.encode(n),t=e.length*8,r=new Uint8Array(e.length+9+63>>6<<6);r.set(e),r[e.length]=128;let o=new DataView(r.buffer);o.setUint32(r.length-8,Math.floor(t/2**32)),o.setUint32(r.length-4,t>>>0);let i=ap;i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225;let s=sp;for(let d=0;d<r.length;d+=64){for(let m=0;m<16;m++)s[m]=o.getUint32(d+m*4);for(let m=16;m<64;m++){let k=s[m-15],$=s[m-2],w=(k>>>7|k<<25)^(k>>>18|k<<14)^k>>>3,O=($>>>17|$<<15)^($>>>19|$<<13)^$>>>10;s[m]=s[m-16]+w+s[m-7]+O>>>0}let u=i[0],c=i[1],p=i[2],l=i[3],f=i[4],g=i[5],h=i[6],v=i[7];for(let m=0;m<64;m++){let k=(f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7),$=f&g^~f&h,w=v+k+$+op[m]+s[m]>>>0,O=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),A=u&c^u&p^c&p,y=O+A>>>0;v=h,h=g,g=f,f=l+w>>>0,l=p,p=c,c=u,u=w+y>>>0}i[0]=i[0]+u>>>0,i[1]=i[1]+c>>>0,i[2]=i[2]+p>>>0,i[3]=i[3]+l>>>0,i[4]=i[4]+f>>>0,i[5]=i[5]+g>>>0,i[6]=i[6]+h>>>0,i[7]=i[7]+v>>>0}let a="";for(let d=0;d<8;d++){let u=i[d];a+=Sr[u>>>24]+Sr[u>>>16&255]+Sr[u>>>8&255]+Sr[u&255]}return a}var Mt=class{constructor(e){this.inner=e}seen=new Set;reads(){return[...this.seen]}markAll(e){for(let t of e)this.seen.add(t.id);return e}markEdges(e){for(let t of e)this.seen.add(t.from),this.seen.add(t.to);return e}getNode(e){return this.seen.add(e),this.inner.getNode(e)}has(e){return this.seen.add(e),this.inner.has(e)}allNodes(e){return this.markAll(this.inner.allNodes(e))}allEdges(e){return this.markEdges(this.inner.allEdges(e))}nodesOfKind(e,t){return this.markAll(this.inner.nodesOfKind(e,t))}edgesOfKind(e,t){return this.markEdges(this.inner.edgesOfKind(e,t))}out(e,t,r){return this.seen.add(e),this.markAll(this.inner.out(e,t,r))}in(e,t,r){return this.seen.add(e),this.markAll(this.inner.in(e,t,r))}neighbors(e,t){return this.seen.add(e),this.markAll(this.inner.neighbors(e,t))}};function dp(n,e){return{...e,name:n}}function ki(n){if(!n.creates?.length)return!1;let e=n.input.shape;return e===void 0||!("id"in e)}function vc(n){let e=n.input,t=e._zod?.def;if(t?.type!=="object"||t.catchall!==void 0||!e.shape)return;let r=Object.keys(e.shape);return ki(n)?[...r,"id"]:r}var mc=(n,e,t={})=>{let r=n.filter(s=>t[s]?.length),o=n.filter(s=>!t[s]?.length);return`${[...o.length>0?[`does not take ${o.map(s=>`"${s}"`).join(", ")}`]:[],...r.map(s=>`${s} is set by ${t[s].join(" or ")}`)].join("; ")}; it takes ${e.length>0?e.map(s=>`"${s}"`).join(", "):"nothing"}`};function cp(n){let e=n?._zod?.def;for(let t=0;e?.innerType&&t<8;t++)e=e.innerType._zod?.def;return e}var lp=/^-?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/;function wc(n,e){let t=n?.shape;if(!t||typeof e!="object"||e===null||Array.isArray(e))return e;let r;for(let[o,i]of Object.entries(e)){if(typeof i!="string"||!lp.test(i)||cp(t[o])?.type!=="number")continue;let s=Number(i);Number.isFinite(s)&&(r??={...e},r[o]=s)}return r??e}var kc=n=>typeof n=="string"&&n.length<=200&&/^[^\s\p{Cc}]+$/u.test(n);function wi(n,e){if(!e&&n.includes("~"))throw new N("An id cannot hold a ~","Leave id out and let the act mint one, or ask for one without it.")}function up(n,e){if(typeof n!="object"||n===null)return;let t=n.id;if(t!==void 0){if(!kc(t))throw new N("An id is 1\u2013200 characters with no space",`Got ${JSON.stringify(t)}.`);return wi(t,e),t}}function fp(n){let{id:e,...t}=n;return t}function yc(n){return n.normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"")||"item"}function xi(n){let e=2166136261;for(let t=0;t<n.length;t++)e=Math.imul(e^n.charCodeAt(t),16777619);return(e>>>0).toString(36).padStart(7,"0")}function pp(n,e){if(e.limited&&e.me===void 0)return bc(n,e.held);let t=e.limited?`${n}.${xi(e.me)}`:n,r=t;for(let o=2;e.seen(r);o++)r=`${t}-${o}`;return e.held(r)?bc(t,e.held):r}function bc(n,e){let t;do t=`${n}-${Math.floor(Math.random()*36**6).toString(36).padStart(6,"0")}`;while(e(t));return t}function yn(n,e,t,r={}){let o=ki(e)?up(t,r.hostsOwn):void 0,i=wc(e.input,o===void 0?t:fp(t)),s=vc(e);if(s&&typeof i=="object"&&i!==null&&!Array.isArray(i)){let y=Object.keys(i).filter(b=>!s.includes(b)&&i[b]!==void 0);if(y.length>0)throw new Se(e.name,[{path:[],message:mc(y,s,e.writtenBy)}])}let a=e.clearable&&typeof i=="object"&&i!==null&&!Array.isArray(i)?e.clearable.filter(y=>i[y]===null):[],d=e.input.safeParse(a.length>0?Object.fromEntries(Object.entries(i).filter(([y])=>!a.includes(y))):i);if(d.success)for(let y of a)d.data[y]=null;if(!d.success){let y=Object.keys(e.input.shape??{});throw new Se(e.name,d.error.issues.map(b=>b.code==="unrecognized_keys"&&y.length>0?{...b,message:mc(b.keys,y,e.writtenBy)}:b))}let u=d.data,c=new Mt(r.seen??n),p=[],l=new Set,f=r.me===void 0?void 0:`.${xi(r.me)}`,g=y=>!r.seesInFull||r.seesInFull()||f!==void 0&&new RegExp(`\\${f}(-[0-9a-z]+)?$`).test(y),h=y=>c.has(y)||n.has(y)||l.has(y)||r.everHeld?.(y)===!0,v,m=y=>{let b=new Set([...n.outEdges(y),...n.inEdges(y)]);for(let R of b)c.getNode(R.from),c.getNode(R.to),p.push({op:"remove-edge",edge:R});return b},k={graph:c,schema:n.schema,get me(){if(r.noRecord||r.selfUnseen&&e.doneAsMe)throw new ne(`"${e.title??e.name}" is done as you, and you have no record here`);return r.me},emit(y){y.op==="add-node"&&wi(y.node.id,r.hostsOwn),p.push(y)},addNode(y){wi(y.id,r.hostsOwn),p.push({op:"add-node",node:y})},removeNode(y){let b=c.getNode(y)&&n.getNode(y);if(!b)throw new q(y,Ke.remove);m(y),p.push({op:"remove-node",node:b})},patchNode(y,b){let R=c.getNode(y)&&n.getNode(y);if(!R)throw new q(y,Ke.change);let S={},x={};for(let[_,M]of Object.entries(b)){let E=R[_];JSON.stringify(E)===JSON.stringify(M)&&!r.keepUnchanged?.(M,_,R)||(S[_]=E,x[_]=M)}Object.keys(x).length!==0&&p.push({op:"patch-node",id:y,before:S,after:x})},archiveNode:y=>k.patchNode(y,{[ke]:!0}),unarchiveNode:y=>k.patchNode(y,{[ke]:void 0}),mergeNode(y,b){let R=c.getNode(b)&&n.getNode(b);if(!R)throw new q(b,Ke.mergeInto);if(y===b||xe(R))throw new N(y===b?"Cannot merge a record into itself":"Cannot merge into an archived record");let S=new Set([...n.outEdges(b),...n.inEdges(b)].map(F));for(let x of m(y)){let _={...x,from:x.from===y?b:x.from,to:x.to===y?b:x.to};_.from!==_.to&&!S.has(F(_))&&(S.add(F(_)),p.push({op:"add-edge",edge:_}))}k.archiveNode(y),v=b},addEdge(y){p.push({op:"add-edge",edge:y})},removeEdge(y){p.push({op:"remove-edge",edge:y.id!==void 0&&n.linkById(y.id)||y})},setSingleSource(y,b,R){n.inEdges(b,y).some(S=>S.from===R)||p.push({op:"add-edge",edge:{kind:y,from:R,to:b}});for(let S of n.inEdges(b,y))c.getNode(S.from),S.from!==R&&p.push({op:"remove-edge",edge:S})},freshId(y,b,R){if(o!==void 0&&!l.has(o)){if(b&&!o.startsWith(`${b}:`)){let re=o.includes(":")?o.slice(o.indexOf(":")+1):o;throw new N(`Id "${o}" does not say its kind: ask for "${b}:${re||o}"`,`Every ${b} id starts "${b}:", the ones "${e.name}" mints and the ones a caller asks for alike, so a later call names it as it names the rest.`)}if(!g(o))throw new N(`"${e.name}" makes its own id here`,`Leave id out${f?`, or end it "${f}"`:""}.`);if(h(o))throw new N(`Id "${o}" is already taken`,`"${e.name}" was asked to make a node with that id, and the graph has or had one. Pick another, or leave id out and let the act mint one.`);return l.add(o),o}let S=r.hint;if(o===void 0&&!l.size&&kc(S)&&!S.includes("~")&&(!b||S.startsWith(`${b}:`))&&g(S)&&!h(S))return l.add(S),S;b&&r.keeps&&[u,R??{}].some(re=>Bd(y,b,re,r.keeps))&&(y=b);let x=b?`${b}:${yc(y)}`:yc(y),_=r.seesInFull!==void 0&&!r.seesInFull(b),E=pp(x,{seen:re=>(r.seen?r.seen.has(re):n.has(re))||l.has(re)||!_&&r.everHeld?.(re)===!0,held:h,limited:_,me:r.me});return l.add(E),E}};if(e.apply(k,u),o!==void 0&&!l.has(o))throw new N(`"${e.name}" did not make a record with id "${o}": it names what it makes itself`);let $=r.check?.(p,e),w=new Set(p.flatMap(Oe)),O=new Mt(r.seen??n),A=e.describe?.(u,O)??`${e.name}(${Object.entries(u).map(([y,b])=>`${y}=${JSON.stringify(b)}`).join(", ")})`;return{primitives:p,reads:[...new Set([...c.reads(),...O.reads()])],...e.describe?{described:[...O.reads(),...$??[]]}:{},writes:[...w],intent:A,...v!==void 0?{mergedInto:v}:{},...l.size>0?{firstMinted:l.values().next().value}:{}}}function Si(n,e,t,r,o,i){if(typeof r!="string"||typeof o!="string")return n.allowedOn===void 0;if(n.allowedOn)return n.allowedOn(t,r);let s=n.subject?.arg??"id",a=n.input.shape??{},d=t.getNode(r)?.[o],u={[s]:r,...o!==s&&o in a&&d!==void 0&&d!==null?{[o]:d}:{}},c=n.input.safeParse?.(u),p=c?.success?c.data:u,l=()=>{},f={graph:t,schema:e,me:i,addNode:l,removeNode:l,patchNode:l,archiveNode:l,unarchiveNode:l,mergeNode:l,addEdge:l,removeEdge:l,setSingleSource:l,freshId:(g,h)=>`${h?`${h}:`:""}${g}`,emit:l};try{n.apply(f,p)}catch(g){let h=g;return!(h?.name==="ActRefusal"&&h.reason!=="invalid")}return!0}var Nt=n=>n.trim().replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").replace(/-+/g,"-").toLowerCase();function Rr(n,e){let t=Nt(n),r=[...e];if(r.includes(n))return n;let o=r.filter(i=>Nt(i)===t);return o.length===1?o[0]:void 0}function hp(n,e){let t=Array.from({length:e.length+1},(r,o)=>o);for(let r=1;r<=n.length;r+=1){let o=[r];for(let i=1;i<=e.length;i+=1)o[i]=Math.min(t[i]+1,o[i-1]+1,t[i-1]+(n[r-1]===e[i-1]?0:1));t=o}return t[e.length]}function Ri(n,e){let t=[...e],r=Rr(n,t);if(r)return r;let o=Nt(n);if(o==="")return;let i,s=!1;for(let a of t){let d=hp(o,Nt(a));d>Math.max(2,Math.floor(Math.max(o.length,a.length)/3))||(!i||d<i.far?(i={act:a,far:d},s=!1):d===i.far&&(s=!0))}return i&&!s?i.act:void 0}var xc=Symbol.for("@graview/core:amount"),vx=(n,e)=>(Object.defineProperty(C(n),xc,{value:e,enumerable:!0}),n);function $i(n,e=!0){let t=C(n);return t?.[xc]??(e&&t?.innerType?$i(t.innerType):void 0)}function Sc(n,e={},t){let r=t===0?Math.round(n):Math.round(n*100)/100,o=Number.isInteger(r),i={maximumFractionDigits:o?0:2,minimumFractionDigits:o?0:2};try{return _e(r,e.locale,e.currency?{style:"currency",currency:e.currency,...i}:i)}catch{return _e(r,e.locale,i)}}function Rc(n,{format:e,unit:t,currency:r,locale:o,places:i}){let s=/^[A-Z]{3}$/.test(t??"");return e==="money"||!e&&s?Sc(n,{...o?{locale:o}:{},...(s?t:r)?{currency:s?t:r}:{}},i):e==="percent"?_e(n,o,{style:"percent",maximumFractionDigits:0}):_e(n,o)+(t?` ${t}`:"")}var gp=Symbol.for("@graview/core:typed-field");function Ai(n){let e=C(n);return e?e[gp]??Ai(e.innerType):void 0}var mp=/^[("'“‘]*(?:(?:[a-z]{1,3}\.){2,}|(?:dr|mr|mrs|ms|mx|st|mt|vs|jr|sr|prof|no|fig|approx)\.)$/i;function yp(n){for(let e of n.matchAll(/[.!?](?=\s|$)/g)){let t=n.slice(0,e.index+1),r=/\S+$/.exec(t)?.[0]??"";if(!(e[0]==="."&&mp.test(r))&&!(t.split(" ").length<3&&e.index+1<n.length))return t}}function $c(n,e=140){let t=n.replace(/^[#>\s]+|\*\*|`|\](\([^)\s]*\))?|\[/gm,"").replace(/\s+/g," ").trim(),r=yp(t);return r&&r.length<=e?r:t.length<=e?t:`${(t.slice(0,e+1).replace(/\s+\S*$/,"")||t.slice(0,e)).replace(/[\s,;:.—-]+$/,"")}\u2026`}function Oi(n){let e=n.fields.shape;return Object.keys(e).flatMap(t=>{let r=or(e[t])?yt(t):void 0;return r&&e[r]?[r]:[]})}var bp=[["skip","Skip this one","Leave one day out of the series; the rest stay as they are.","Skip {} on "],["detach","Change just this one","Make one day of the series a record of its own, to change apart from the rest.","Change {} only on "],["split","Change from here","End the series the day before, and start it again from that day with what changes.","Change {} from "]];function Ac(n,e){let t=new Set(e.map(o=>o.name)),r=[];for(let o of n.definitions){let i=Oi(o);if(i.length===0)continue;let s=o.kind,a=o.fields.shape,d=zt(n,e).get(s),u=new Set(o.keptInStep??[]),c=g=>(d?.get(g)?.length??0)>0&&!u.has(g),p=qe(o).filter(g=>!c(g)),l=Object.fromEntries(qe(o).filter(c).map(g=>[g,d.get(g)])),f=g=>V(o,g);for(let[g,h,v,m]of bp){let k=`${g}-${s}`;t.has(k)||r.push({name:k,derived:{kind:s,act:g},title:h,description:v,subject:{kinds:[s],arg:"id"},writes:i.map(jn),...g==="skip"?{}:{creates:[s],...Object.keys(l).length>0?{writtenBy:l}:{}},input:In({id:Ue([s]),on:L().check(ut(/^\d{4}-\d{2}-\d{2}$/,"a day, like 2026-10-21")),...i.length>1?{field:W(Ya(i))}:{},...g==="skip"?{}:Object.fromEntries(p.map($=>[$,W(a[$])]))}),describe:($,w)=>m.replace("{}",f(w.getNode(String($.id))??{id:$.id}))+Le(String($.on)),apply($,w){let O=$.graph.getNode(String(w.id)),A=String(w.field??i[0]),y=O?.[A],b=O?.[jn(A)],R=String(w.on);if(typeof y!="string"||!Dn(b))throw new ne(`${f(O??{id:w.id})} does not repeat`,"refused");let S=Tn(y,b,{from:R,to:R})[0];if(!S)throw new ne(`${f(O)} does not fall on ${Le(R)}`,"refused");let x=String(O.id),_=Object.fromEntries(p.filter(G=>w[G]!==void 0).map(G=>[G,w[G]])),M=jn(A),E=G=>{let ye=Object.fromEntries(Object.entries({...O,...G,..._}).filter(([K,nn])=>nn!=null&&K!=="id")),nt=$.freshId(f(ye),s,ye);$.addNode({...ye,id:nt,kind:s});for(let K of Object.keys(o.edges??{}))for(let nn of $.graph.out(x,K))$.addEdge({kind:K,from:nt,to:nn.id})};if(g!=="split"){$.patchNode(x,{[M]:{...b,except:[...new Set([...b.except??[],R])].sort()}}),g==="detach"&&E({[A]:S,[M]:null});return}if(Object.keys(_).length===0)throw new ne(`Nothing to change: give ${f(O)} from ${Le(R)} something new`,"invalid");if(R<=y.slice(0,10))return $.patchNode(x,_);let re=new Date(Date.parse(`${R}T00:00:00Z`)-864e5).toISOString().slice(0,10),Qn=b.count?Tn(y,{...b,except:[]},{to:re}).length:0,{count:Sn,except:en,...Rn}=b,et=G=>en?.some(G)?{except:en.filter(G)}:{};$.patchNode(x,{[M]:{...Rn,until:re,...et(G=>G<R),...Sn?{count:Qn}:{}}}),E({[A]:S,[M]:{...Rn,...et(G=>G>=R),...Sn?{count:Sn-Qn}:{},continues:x}})}})}}return r}function Oc(n,e,t,r){if(n==="detach")return!0;if(n!=="split"||typeof e.on!="string")return!1;let o=t?.[String(e.field??r[0])];return typeof o!="string"||e.on>o.slice(0,10)}function _c(n,e){let t=new Set(e.map(a=>a.name)),r=e.filter(a=>!a.derived&&!a.creates?.length),o=(a,d,u,c)=>r.some(p=>{if(!(p[a]??[]).includes(u))return!1;let l=p.subject?.kinds;return l===void 0||l==="*"||l.includes(d)||c.to==="*"||l.some(f=>c.to.includes(f))}),i=[],s=(a,d)=>{let u=a.getNode(String(d));return u?V(n.tryDefinition(u.kind),u):String(d)};for(let a of n.definitions){let d=a.kind,u=Object.entries(a.edges??{}),c=p=>p.to==="*"?"record":p.to.map(l=>X(n.tryDefinition(l),l)).join(" or ");for(let[p,l]of u){let f=c(l),g=l.cardinality==="one",h=u.some(([w,O])=>w!==p&&c(O)===f),v=w=>B(w).toLowerCase(),m=Dd(d,p,l,v),k={to:m&&"to"in m?m.to:f,from:X(a,d),one:g,also:m&&"also"in m?m.also:h&&!m?v(p):void 0},$=k.from;for(let w of oi){let O=ii(w,d,p);if(t.has(O)||l.acts==="none"||(w==="connect"?o("connects",d,p,l):o("severs",d,p,l)||l.appendOnly))continue;let{title:A,fromTheOtherEnd:y}=jd(w,k),b=l.description?`: ${l.description.replace(/\.$/,"")}`:"";i.push({name:O,derived:{kind:d,act:w,relation:p},title:A,fromTheOtherEnd:y,description:w==="connect"?`Link this ${$} to ${/^[aeiou]/i.test(f)?"an":"a"} ${f}${b}.${g?" It has one, so this replaces the one it has.":""}`:`Take away the link between this ${$} and ${/^[aeiou]/i.test(f)?"an":"a"} ${f}${b}. Undo puts it back.`,subject:{kinds:[d],arg:"id"},...w==="connect"?{connects:[p]}:{severs:[p],destructive:!0},idempotent:!0,input:In({id:Ue([d]),to:Ue(l.to==="*"?"*":l.to)}),describe:(R,S)=>w==="disconnect"?`Unlink ${s(S,R.id)} from ${s(S,R.to)}`:g?`Set the ${f} of ${s(S,R.id)} to ${s(S,R.to)}`:`Link ${s(S,R.id)} to ${s(S,R.to)}`,apply(R,S){let x=String(S.id),_=String(S.to);for(let E of[x,_])if(!R.graph.getNode(E))throw new ne(`there is no record "${E}"`,"invalid");let M=R.graph.out(x,p).some(E=>E.id===_);if(w==="disconnect"){if(!M)throw new ne(`${s(R.graph,x)} is not linked to ${s(R.graph,_)}`,"invalid");R.removeEdge({kind:p,from:x,to:_});return}if(g)for(let E of R.graph.out(x,p))E.id!==_&&R.removeEdge({kind:p,from:x,to:E.id});M||R.addEdge({kind:p,from:x,to:_})}})}}}return i}function vp(n){let e=new Set(n.declared),t=[...new Set([...(n.paged??[]).filter(o=>e.has(o)),...n.declared])],r=(n.naming??[]).filter(o=>e.has(o));return[...new Set([...r,...t.filter(n.must),...t])]}var _i=n=>`\xA7${n}\xA7`;function wp(n,e){if(n.label)try{let r={id:_i(e.length),kind:n.kind};e.forEach((s,a)=>r[s]=_i(a));let o=String(n.label(r)),i=e.map((s,a)=>[s,o.indexOf(_i(a))]).filter(([,s])=>s>=0);if(i.length>0)return i.sort((s,a)=>s[1]-a[1]).map(([s])=>s)}catch{}let t=["name","title","label"].find(r=>e.includes(r));return t?[t]:[]}var Pc=new WeakMap;function $r(n){let e=Pc.get(n);if(e)return e;let t=n.fields.shape??{},r=Object.keys(t),o=n.display?.page,i=vp({declared:r,paged:[...o?.fields??[],...(o?.groups??[]).flatMap(s=>s.fields)],must:s=>t[s]?.safeParse?.(void 0).success===!1&&!Object.hasOwn(n.defaults??{},s),naming:wp(n,r)});return Pc.set(n,i),i}function kp(n,e){let t=e.subject?.kinds,r=e.creates?.[0]??e.derived?.kind??(t!==void 0&&t!=="*"&&t.length===1?t[0]:void 0);return r===void 0?void 0:n.tryDefinition(r)}function xp(n,e){let t=Object.keys(e.input?.shape??{}),r=n?kp(n,e):void 0;if(!r)return t;let o=$r(r),i=d=>d!==e.subject?.arg&&o.includes(d),s=t.filter(i).sort((d,u)=>o.indexOf(d)-o.indexOf(u)),a=0;return t.map(d=>i(d)?s[a++]:d)}function Pi(n,e,t=r=>r.name){let r=o=>{let i=e.indexOf(t(o));return i<0?e.length:i};return[...n].sort((o,i)=>r(o)-r(i))}function qe(n){let e=n.fields.shape;return Object.keys(e).filter(t=>!(t in(n.fixed??{})))}function Ei(n,e){let t=e.subject;return t?t.kinds==="*"?n.kinds:t.kinds:[]}function Mi(n,e){let t=n.subject;if(!t||!n.writes&&n.creates?.length)return[];let r=new Set(Object.keys(e.fields.shape));if(n.writes)return n.writes.filter(s=>r.has(s));let o=n.input.shape??{},i=new Set(Pt(n.input).map(s=>s.name));return Object.keys(o).filter(s=>s!==t.arg&&r.has(s)&&!i.has(s))}function zt(n,e){let t=new Map,r=(o,i,s)=>{let a=t.get(o)??new Map;a.get(i)?.includes(s)||(a.set(i,[...a.get(i)??[],s]),t.set(o,a))};for(let o of e){for(let i of Ei(n,o)){let s=n.tryDefinition(i);if(s)for(let a of Mi(o,s))r(i,a,o.name)}for(let[i,s]of Object.entries(o.writesOther??{})){let a=n.tryDefinition(i)?.fields.shape;if(a)for(let d of s)d in a&&r(i,d,o.name)}}return t}function Mc(n,e,t){let r=n.tryDefinition(t);if(!r)return[];let o=zt(n,e).get(t);return qe(r).filter(i=>!o?.has(i))}var Ar=n=>`edit-${n}`;function Or(n,e,t){let r=n.tryDefinition(t);if(!r)return[];let o=new Set;for(let i of e)i.derived||((i.creates??[]).includes(t)&&o.add(i.name),Ei(n,i).includes(t)&&Mi(i,r).length>0&&o.add(i.name));return[...o]}function Nc(n,e){let t=new Set(e.map(o=>o.name)),r=[];for(let o of n.definitions){let i=o.kind,s=Ar(i);if(t.has(s))continue;let a=new Set((o.keptInStep??[]).filter(h=>qe(o).includes(h))),d=Mc(n,e,i),u=Pi(qe(o).filter(h=>d.includes(h)||a.has(h)),$r(o),h=>h);if(u.length===0)continue;let c=zt(n,e).get(i),p=Object.fromEntries(qe(o).flatMap(h=>!u.includes(h)&&c?.get(h)?.length?[[h,c.get(h)]]:[])),l=o.fields.shape,f=X(o,i),g=u.map(h=>Ut(o,h));r.push({name:s,derived:{kind:i,act:"edit"},idempotent:!0,title:`Change the ${f}`,description:`Change what was set when this ${f} was made: ${g.join(", ")}.`,subject:{kinds:[i],arg:"id"},writes:u,...Object.keys(p).length>0?{writtenBy:p}:{},...u.some(h=>Ec(l[h]))?{clearable:u.filter(h=>Ec(l[h]))}:{},input:In({id:Ue([i]),...Object.fromEntries(u.map(h=>[h,W($p(l[h]))]))}),describe:(h,v)=>Sp(o,l,u,h,v),apply(h,v){let m={};for(let k of u){let $=v[k];$===null?m[k]=void 0:$!==void 0&&(m[k]=$)}if(Object.keys(m).length===0)throw new ne(`Nothing to change \u2014 give at least one of ${g.join(", ")} a value.`,"invalid");h.patchNode(v.id,m)}})}return r}function Sp(n,e,t,r,o){let i=o.getNode(r.id),s=i?V(n,i):"a record",a=t.filter(d=>r[d]!==void 0).map((d,u)=>{let c=r[d],p=yt(d),l=p!==void 0&&p in e;return`the ${Ut(n,l?p:d)}${u===0?` of ${s}`:""} to ${l?c?`repeat ${Rp(c)}`:"stop repeating":zc(n,e[d],d,c)}`});return a.length===0?`Changed nothing on ${s}`:`Changed ${a.length>1?`${a.slice(0,-1).join(", ")} and ${a.at(-1)}`:a[0]}`}var Rp=n=>`every ${(n.interval??1)>1?`${n.interval} ${n.every}s`:n.every}`;function zc(n,e,t,r){if(r===null||r===""||Array.isArray(r)&&r.length===0)return"nothing";let o=n.display?.format?.[t];try{if(o)return String(o(r))}catch{}if(ht(r).length>0)return ht(r).map(i=>i.name).join(", ");if(gt(e))return Array.isArray(r)&&r.length>1?`${r.length} linked records`:"a linked record";if(Array.isArray(r))return r.map(i=>zc(n,e,t,i)).join(", ");if(typeof r=="boolean")return r?"yes":"no";if(typeof r=="number"){let i=$i(e);return i?Rc(r,i):Ai(e)==="duration"?`${r>=60?`${Math.floor(r/60)} h `:""}${r%60||r<60?`${r%60} min`:""}`.trim():String(r)}if(typeof r!="string")return"a new value";if(Jr.test(r))return Le(r);if(Gt.test(r))return Qr(r);for(let i=C(e);i;i=C(i.innerType))if(i.type==="enum")return dn(r);return`\u201C${$c(r,60)}\u201D`}function Ec(n){return n._zod?.def?.type==="optional"}function $p(n){let e=n;for(let t=0;t<4;t++){let r=e._zod?.def;if((r?.type==="default"||r?.type==="prefault")&&r.innerType)e=r.innerType;else break}return e}function _r(n,e){return n.filter(t=>!t.derived&&(t.creates??[]).includes(e)).map(t=>t.name)}function Pr(n,e,t){if(!t.derived)return;let r=t.derived.act;return r==="edit"||r==="skip"||r==="detach"||r==="split"||r==="connect"||r==="disconnect"?Or(n,e,t.derived.kind):_r(e,t.derived.kind)}function Ap(n,e){let t=new Set(e.map(o=>o.name)),r=[];for(let o of n.definitions){let i=o.kind,s=X(o,i),a=(u,c)=>{let p=u.getNode(String(c));return p?V(o,p):String(c)},d=Ue([i]);for(let[u,c,p,l]of[["remove","Remove",`Remove the ${s}`,`Take this ${s} out of the graph, with every tie it has. Undo puts it back.`],["archive","Archive",`Archive the ${s}`,`Set this ${s} aside, with its ties and history kept.`],["unarchive","Bring back","Bring it back",`Bring this archived ${s} back.`],["merge","Merge",`Merge into another ${s}`,`The other takes this ${s}'s ties, and this one is archived.`],["leave-alone","Leave alone","Leave this one alone",`Nothing automated changes this ${s}: tidying passes it by until you allow it again.`],["allow-tidying","Allow tidying of","Allow tidying again",`Let tidying change this ${s} again.`]]){let f=`${u}-${i}`,g=u==="leave-alone"||u==="allow-tidying";t.has(f)||!g&&u!=="remove"&&o.archives===!1||g&&o.tidying==="never"||r.push({name:f,derived:{kind:i,act:u},title:p,description:l,subject:{kinds:[i],arg:"id"},...u==="remove"?{destructive:!0}:{},idempotent:!0,input:se(u==="merge"?{id:d,into:d}:{id:d}),describe:(h,v)=>{let m=u==="remove"&&v.getNode(String(h.id)),k=m?new Set(Object.values(m).flatMap(O=>ht(O).map(A=>A.href))).size:0,$=u==="merge"&&a(v,h.id)===a(v,h.into),w=O=>$?`${a(v,O)} (${String(O)})`:a(v,O);return`${c} ${w(h.id)}${u==="merge"?` into ${w(h.into)}`:""}${k?` and its ${k} file${k>1?"s":""}`:""}`},apply:g?(h,v)=>h.patchNode(String(v.id),{[vt]:u==="leave-alone"?!0:void 0}):(h,v)=>h[`${u}Node`](v.id,v.into)})}}return r}function Ni(n,e){return[...Nc(n,e),...Ap(n,e),...Ac(n,e),..._c(n,e)]}var Op=n=>({$made:n}),Er=n=>typeof n=="object"&&n!==null&&Object.keys(n).join()==="$made"&&Number.isInteger(n.$made)&&n.$made>=0,_p=(n,e)=>Object.fromEntries(Object.entries(n.args??{}).map(([t,r])=>[t,Array.isArray(r)?r.map(e):e(r)])),zi=n=>Object.values(n.args??{}).some(e=>Er(e)||Array.isArray(e)&&e.some(Er)),Ic=(n,e,t)=>({...n,args:_p(n,r=>{if(!Er(r))return r;let o=r.$made<t?e[r.$made]:void 0;if(o===void 0)throw new Error(`\u201C${n.name}\u201D names the record call ${r.$made+1} makes, and no call before it made that record.`);return o})});var Pp=500,Ep=120,Mp=50,Np=200,zp=500,Ip=200,Tc=4e3,Tp=["model","suggestion","interaction","actor","run","proposedBy"],Ii=n=>typeof n=="string"&&n.length>0&&n.length<=Ep,jp=n=>typeof n=="string"&&n.length<=240&&n.lastIndexOf("#")>0&&n.lastIndexOf("#")<n.length-1,Dp=n=>{let e=JSON.stringify(n);return e===void 0?void 0:JSON.parse(e)};function bn(n,e=!1){if(n===void 0)return;let t=n&&typeof n=="object"&&!Array.isArray(n)?n:{};if(t.liftedStop!==void 0)throw new N("Only the store says it lift a stop: undo the stop's batch.");if(t.stopsKind!==void 0&&!e)throw new N("Saying not to suggest something is an undo of the suggestion, not a change of its own.");let r=typeof t.basis=="string"?t.basis.trim():"",o={basis:r},i=r!==""&&r.length<=Pp;for(let s of Object.keys(t)){let a=t[s];s==="basis"||a===void 0||(s==="model"&&typeof a=="string"&&(a=a.trim()),s==="confidence"?i&&=typeof a=="number"&&a>=0&&a<=1:Tp.includes(s)?i&&=Ii(a):s==="evidence"?i&&=Array.isArray(a)&&a.length<=Mp&&a.every(Ii):s==="read"?i&&=Array.isArray(a)&&a.length<=Np&&a.every(jp):s==="items"?i&&=Array.isArray(a)&&a.length>0&&a.length<=zp&&a.every(d=>Number.isInteger(d)&&d>=0):s==="stopsKind"?i&&=a===!0:s==="voters"?i&&=Array.isArray(a)&&a.length<=Ip&&a.every(Ii):i&&=s!=="__proto__"&&s!=="constructor"&&s!=="prototype"&&(a=Dp(a))!==void 0,i&&(o[s]=a))}if(!i)throw new N("A lineage is { basis: 1 to 500 characters, confidence?: 0 to 1, model?, suggestion?, interaction?, actor?, run?, proposedBy?: 1 to 120 characters, evidence?: up to 50 ids, read?: up to 200 <id>#<field>, voters?: up to 200 ids, items?: up to 500 places }");if(JSON.stringify(o).length>Tc)throw new N(`A lineage is at most ${Tc} characters written out.`);return o}var qn="keep-link";function jc(n){let e=(t,r)=>{let o=t.getNode(r);return o?V(n.tryDefinition(o.kind),o):r};return{name:qn,title:"Keep this link",input:se({kind:L(),from:L(),to:L()}),describe:(t,r)=>`Keep the link from ${e(r,t.from)} to ${e(r,t.to)}`,apply(t,r){let{kind:o,from:i,to:s}=r;if(!t.graph.getNode(i)||!t.graph.getNode(s)){let d=F({kind:o,from:i,to:s});throw new q(d,Jo)}let a=t.graph.edgesOfKind(o,{archived:"all"}).find(d=>d.from===i&&d.to===s)??{kind:o,from:i,to:s};t.removeEdge(a),t.addEdge(a)}}}var Ti=(n,e)=>[...n].filter(t=>!t.derived&&t.name!==qn&&typeof e=="string"&&(t.connects?.includes(e)||t.severs?.includes(e))).map(t=>t.name);var It="propose-changes",ji=500;function Dc(){return{name:It,title:"Propose changes",input:se({calls:Wa(se({name:L(),args:ft()})),intent:W(L())}),apply(){}}}var Fc=["kind-unknown","node-shape","edge-dangling","edge-disallowed","rule-error","rule-budget","derived-out-of-step"];function Lc(n,e){let t=ur(n,e);return t&&[...t.fields].filter(Boolean)}function Fp(n,e,t){return n.tryDefinition(e)?.fields?.shape?.[t]}function Hn(n,e){try{return V(n.tryDefinition(e.kind),e)}catch{return typeof e.label=="string"?e.label:"A record"}}var Lp=n=>`${n.kind}:${n.from}->${n.to}`,Mr=(n,e)=>n<e?-1:n>e?1:0;function Cc(n,e,t={}){let{schema:r}=n,o=[],i=new Map;for(let l of e.nodes)i.has(l.id)||i.set(l.id,l);let s=l=>e.edges.filter(f=>f.from===l||f.to===l),a=l=>({action:"drop",primitives:[...s(l.id).filter(f=>i.has(f.from)&&i.has(f.to)).map(f=>({op:"remove-edge",edge:f})),{op:"remove-node",node:l}]}),d=new Set;for(let l of[...i.values()].sort((f,g)=>Mr(f.id,g.id))){if(!r.tryDefinition(l.kind)){d.add(l.id),o.push({code:"kind-unknown",id:l.id,message:`${Hn(r,l)} is a kind of record this app no longer has`,repair:a(l)});continue}let f=Lc(r,l);if(f===void 0)continue;let g=Hn(r,l),h=new Map,v=f.length>0;for(let m of f){if(m==="id"||m==="kind"){v=!1;continue}let k=Fp(r,l.kind,m),$=k?k.safeParse(void 0):{success:!0,data:void 0},w=r.tryDefinition(l.kind)?.defaults;!$.success&&k&&w&&Object.hasOwn(w,m)&&($=k.safeParse(w[m])),$.success?$.data===void 0?h.set(m,{action:"clear",value:le}):h.set(m,{action:"coerce",value:$.data}):v=!1}if(v){let m={...l};for(let[k,$]of h)$.value===le?delete m[k]:m[k]=$.value;Lc(r,m)!==void 0&&(v=!1)}if(f.length===0){o.push({code:"node-shape",id:l.id,message:`${g} does not fit what ${l.kind} declares`,repair:a(l)});continue}for(let m of f){let k=h.get(m),$=v&&k?{action:k.action,primitives:[{op:"patch-node",id:l.id,before:{[m]:l[m]===void 0?le:l[m]},after:{[m]:k.value}}]}:a(l);o.push({code:"node-shape",id:l.id,detail:m,message:`${g}: ${B(m)} does not fit what ${l.kind} declares`,repair:$})}}let u=new Set,c=[];for(let l of[...e.edges].sort((f,g)=>Mr(F(f),F(g)))){if(u.has(F(l)))continue;u.add(F(l));let f=Lp(l),g=i.get(l.from),h=i.get(l.to);if(!g||!h){o.push({code:"edge-dangling",id:f,message:"A link points at a record that is not there",repair:{action:"drop",primitives:[{op:"remove-edge",edge:l}]}});continue}c.push(l),!(d.has(g.id)||d.has(h.id))&&(r.edgeAllowed(l.kind,g.kind,h.kind)||o.push({code:"edge-disallowed",id:f,message:`${Hn(r,g)} \u2192 ${Hn(r,h)}: this app does not allow that link between them`,repair:{action:"drop",primitives:[{op:"remove-edge",edge:l}]}}))}let p=n.invariants??[];if(p.length>0){let l=H.from(r,{nodes:[...i.values()],edges:c},{validate:!1}),f=new Set,g;try{g=Zn(l,p,t.invariantOptions??{})}catch{g=[{invariant:"rules",status:"could-not-judge",label:"The rules",message:"The rules could not be judged",nodeIds:[],repairs:[]}]}for(let h of g){let v=h.status==="could-not-judge"?"rule-error":h.status==="over-budget"?"rule-budget":void 0;if(!v)continue;let m=h.subjectId??h.invariant,k=`${v}|${m}|${h.invariant}`;f.has(k)||(f.add(k),o.push({code:v,id:m,detail:h.invariant,message:h.message}))}}if(Un(r)){let l=H.from(r,{nodes:[...i.values()].filter(f=>!d.has(f.id)),edges:c},{validate:!1});for(let f of lc(r,l,i.values())){let g=i.get(f.id),h=i.get(f.source);o.push({code:"derived-out-of-step",id:f.id,detail:f.field,message:`${Hn(r,g)}: ${B(f.field)} says ${JSON.stringify(f.holds??null)}, and it follows ${Hn(r,h)}, which works it out as ${JSON.stringify(f.follows??null)}`,repair:{action:"coerce",primitives:[{op:"patch-node",id:f.id,before:{[f.field]:f.holds===void 0?le:f.holds},after:{[f.field]:f.follows===void 0?le:f.follows}}]}})}}return o.sort((l,f)=>Fc.indexOf(l.code)-Fc.indexOf(f.code)||Mr(l.id,f.id)||Mr(l.detail??"",f.detail??""))}var Tt=()=>globalThis.__graviewWatch;function Zc(n){Tt()?.store?.(n)}function Nr(n){n!==void 0&&Tt()?.learn?.({ids:[n],words:[]})}function Gc(n,e){Tt()?.refused?.({...n,...e===void 0?{}:{author:e}})}function Di(n,e){let t=Tt();if(!t?.refusedInput)return;let r=n.issues.map(o=>`${o.path.map(String).join(".")}: ${o.message}`).join("; ");t.refusedInput({mutation:n.mutation,message:r,...e===void 0?{}:{author:e}})}function Cp(n,e){n instanceof Se&&Di(n,e)}function Zp(n,e,t){Tt()?.seat?.(n,e,t)}function Li(n,e){if(typeof n=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(n))return n;let t=new Date(n).getTime();if(Number.isNaN(t))throw new Error(`Not a day: ${String(n)}`);return te(e,t)}var Fi=15*6e4;function Kc(n=Date.now(),e){let t=new Date(n).getTime(),r=Kt(e),o=te(r,t),i=new Date(Date.parse(`${o}T00:00:00Z`));if(i.setUTCDate(i.getUTCDate()+1),!r)return i.getTime()-t;let s=as(i.toISOString().slice(0,10),0,r);for(;te(r,s)===o;)s+=Fi;for(;te(r,s-Fi)!==o;)s-=Fi;return s-t}function Gp(n,e){let t,r=()=>{t=setTimeout(()=>{let o=n.tick(new Date);r(),e?.(o)},Kc(Date.now(),n.timeZone)+1e3),t.unref?.()};return r(),()=>clearTimeout(t)}function Ci(n){let e=(n?.published?.length??0)>0;return{framework:Ln,formats:{...he,snapshot:e?2:1}}}var Ir=class extends N{constructor(e){super(`This is the app as it stood${e.at?` at ${e.at}`:" at the start"}: the past is read, never changed`),this.name="PastError"}},zr="preview",I=(n,e)=>e===void 0?{}:{[n]:e},He={kind:"human"},Vc={kind:"system"},Wc={kind:"system",id:"modules",name:"Modules"},Bc=n=>n.mutation===null&&n.undoes===void 0;function Zi(n,e){return`${n.invariant}|${n.subjectId??""}|${n.line||e?.has(n.invariant)?n.label:n.message}`}var Kp=new Set(["remove","archive","unarchive","merge"]),Vp={has:()=>!0},qc=n=>new Set(n.filter(e=>e.shape).map(e=>e.name));function Hc(n,e,t){let r=qc(n),o=p=>Zi(p,r),i=new Set(e.map(o)),s=new Set(t.map(o)),a=t.filter(p=>!i.has(o(p))),d=e.filter(p=>!s.has(o(p)));if(a.length===0||d.length===0)return{introduces:a,resolves:d};let u=p=>p.subjectId&&Zi(p,Vp),c=d.map(u);return{introduces:a.filter(p=>{let l=u(p)?c.indexOf(u(p)):-1;return l<0||(c[l]=null,!1)}),resolves:d.filter((p,l)=>c[l]!==null)}}var Yn=class extends Error{constructor(t,r){super(`Op "${t.id}" (${t.intent}) could not be applied: ${r instanceof Error?r.message:String(r)}`,{cause:r});this.op=t;this.name="ReceiveError"}},Tr=class extends N{constructor(t,r){let o=Ri(t,r);super(`Unknown mutation "${t}"${o?` \u2014 did you mean "${o}"?`:""}`,`Registered: ${r.join(", ")||"(none)"}`);this.mutation=t;this.name="UnknownMutationError",this.nearest=o}nearest},Uc=n=>new Map(n.map(e=>[e.id,e.batch]));function Bp(){let n=globalThis.crypto,e=new Uint8Array(6);if(n?.getRandomValues)n.getRandomValues(e);else for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256);return[...e].map(t=>t.toString(36).padStart(2,"0")).join("")}var Gi=class n{schema;graph;log;mutations=new Map;keeper;typer;voter;proposer;invariants;invariantOptions;policy;publishing;tidying;votes;intelligence;may=new Map;by;declaredModules;startingModules;projected;nextId;now;validate;mintBatch;batchTag;counter=0;opCount=0;quiet=0;rehearsing=!1;suggesting=!1;proposing=!1;ticked;timeZone;past;pastEvery;told=0;listeners=new Set;constructor(e){this.pastEvery=Math.max(1,e.pastEvery??64),this.past=e.past,this.schema=e.schema,this.invariants=e.invariants??[],this.invariantOptions=e.invariantOptions??{},this.timeZone=e.timeZone,this.timeZone&&(this.ticked={day:te(this.timeZone),on:te(this.timeZone)}),this.policy=e.policy,this.publishing=e.publishing,this.tidying=e.tidying,this.votes=e.votes,this.by=e.principal??He,this.intelligence=e.intelligence??[];for(let i of e.intelligence??[])i.may&&this.may.set(i.name,new Set(i.may));this.declaredModules=e.modules,this.startingModules=e.enabledModules,this.nextId=e.ids??(()=>`op${++this.opCount}`),this.now=e.now??(()=>new Date().toISOString()),this.validate=e.validate??!0;let t=Bp();this.batchTag=e.batchIds?void 0:t,this.mintBatch=e.batchIds??(i=>`${i}:${t}:${++this.counter}`);for(let i of e.past?[]:e.mutations??[]){if(this.mutations.has(i.name))throw new N(`Duplicate mutation "${i.name}"`);this.mutations.set(i.name,i)}for(let i of e.past?[]:Ni(e.schema,e.mutations??[]))this.mutations.set(i.name,i);!e.past&&!this.mutations.has(qn)&&(this.keeper=jc(e.schema),this.mutations.set(qn,this.keeper)),!e.past&&!this.mutations.has(gn)&&(this.voter=Ld(),this.mutations.set(gn,this.voter)),!e.past&&!this.mutations.has(It)&&(this.proposer=Dc(),this.mutations.set(It,this.proposer));let r=I("horizon",e.horizon),o={validate:this.validate};if(e.log){this.log=Vn.from(e.log,e.epochs,r);let i=this.log.lastEpoch();this.graph=e.snapshot?H.from(e.schema,e.snapshot,o):this.log.fold(e.schema,{...o,...i?{from:i}:{}})}else this.log=Vn.from([],e.epochs??(e.snapshot?[{seq:e.horizon??0,base:e.snapshot}]:[]),r),this.graph=H.from(e.schema,e.snapshot??{nodes:[],edges:[]},o);e.past||(this.countPastTheLog(),Zc(this))}stillNow(){if(this.past)throw new Ir(this.past)}countPastTheLog(){this.countPast(this.log.all())}countPast(e){let t=r=>{let o=/(\d+)$/.exec(r);return o?Number(o[1]):0};for(let r of e)this.counter=Math.max(this.counter,t(r.batch)),this.opCount=Math.max(this.opCount,t(r.id));this.log.horizon>0&&(this.opCount=Math.max(this.opCount,this.log.length))}get servedSeq(){return this.log.length}get publishedSeq(){return J.seq?.(this)}get publisher(){return J.act?.(this,this.mutations)}get modules(){let e=this.log.all(),t=e.at(-1)?.id,r=this.projected;if(r&&r.length===e.length&&r.last===t)return r.projection;let o,i=0;r&&r.length<=e.length&&(r.length===0||e[r.length-1]?.id===r.last)&&(o=r.said,i=r.length);for(let a=e.length-1;a>=i;a--){let d=e[a].enabledModules;if(d!==void 0){o=d;break}}o??=this.log.horizonEpoch()?.enabledModules;let s=r&&o===r.said?r.projection:gi(this.declaredModules,o??this.startingModules);return this.projected={projection:s,length:e.length,last:t,said:o},s}setEnabledModules(e,t={}){this.stillNow();let r=this.modules.enabled,o=gi(this.declaredModules,e).enabled,i=[...r].filter(c=>!o.has(c)),s=[...o].filter(c=>!r.has(c));if(i.length===0&&s.length===0)return;let a=c=>c.map(p=>{let l=this.declaredModules?.[p]?.kinds??[];return l.length>0?l.map(f=>ue(this.schema,f)).join(", "):p}).join(", "),d=[i.length>0?`Turn off ${a(i)}`:"",s.length>0?`turn on ${a(s)}`:""].filter(Boolean).join("; "),u={id:this.nextId(),seq:this.log.length,batch:t.batch??this.mintBatch("batch"),author:Wc,intent:an(d),mutation:null,primitives:[],reads:[],writes:[],at:this.now(),...I("via",t.via),enabledModules:[...o].sort()};return this.log.append(u),this.notify(Cn,[u]),u}mutation(e){let t=this.mutations.get(this.spelled(e))??(e===gr?this.publisher:void 0);if(!t)throw new Tr(e,[...this.mutations.keys()]);if(this.mutationDisabled(t))throw new N(`Mutation "${e}" belongs to a module this workspace has turned off`,`Enabled modules: ${[...this.modules.enabled].join(", ")||"(none)"}`);return t}spelled(e){return e===hr&&!this.typer&&ae.typeText&&!this.past&&!this.mutations.has(e)&&this.mutations.set(e,this.typer=ae.typeText(this)),this.mutations.has(e)?e:Rr(e,this.mutations.keys())??e}spelledCall(e){let t=this.spelled(e.name);return t===e.name?e:{...e,name:t}}mutationDisabled(e){return this.modules.disabledMutations.has(e.name)?!0:e.derived!==void 0&&this.modules.disabledKinds.has(e.derived.kind)}allMutations(){return[...this.mutations.values(),...this.publisher?[this.publisher]:[]].filter(e=>e!==this.keeper&&e!==this.typer&&e!==this.voter&&e!==this.proposer&&!this.mutationDisabled(e))}viaOf(e,t,r){if(e!==void 0&&e===this.keeper){let o=Ti(this.mutations.values(),t?.args.kind);if(o.length>0)return o;let i=[...this.mutations.values()];return[...new Set(i.filter(s=>s.derived?.relation===t?.args.kind).flatMap(s=>Pr(this.schema,i,s)??[]))]}if(e!==void 0&&e===this.typer){let o=r===void 0||D(r)?this.graph:Re(this,r).graph,i=s=>!this.mutationDisabled(s)&&Si(s,this.schema,o,t?.args.node,t?.args.field,r&&sr(this.schema,r));return ae.via(this.schema,[...this.mutations.values()],this.subjectKindOf(t,r),t?.args.field,i)}if(e?.derived)return Pr(this.schema,[...this.mutations.values()],e)}moved(e,t){return Hc(this.allInvariants(),e,t)}allInvariants(){return this.invariants.filter(e=>this.invariantEnabled(e))}invariantEnabled(e){if(this.modules.disabledInvariants.has(e.name))return!1;if(e.scope!=="graph"){let t=e.scope.kind;if(this.modules.disabledKinds.has(t))return!1}return!0}writesBack(e){if(this.policy)return(t,r,o)=>{try{return this.permits({name:`edit-${t.kind}`,args:{id:t.id,[r]:o}},e).ok}catch{return!1}}}permits(e,t=He){let r=this.judged(e,t);if(r.ok&&this.personFor(t)&&this.policy?.grants.some(o=>o.ownEnd))try{this.rehearsal().applying([e],{author:t})}catch(o){if(o instanceof Ve)return{ok:!1,refusal:o.refusal}}return r}judged(e,t,r=!1){if(e=this.spelledCall(e),this.past)return{ok:!1,refusal:{mutation:e.name,wouldNeed:[],message:"Nothing changes while you look back."}};let o=this.refusesAgent(e,t)??this.namesTurnedOff(e,t);if(o)return{ok:!1,refusal:o};let i=this.mutations.get(e.name)??(e.name===gr?this.publisher:void 0),s=i&&!r&&this.noOneToBe(i,t);if(s)return{ok:!1,refusal:s};if(i&&i===this.publisher)return J.verdict(this,t);if(i&&i===this.voter)return Rt(t)&&(this.votes?.advisory!=="visitors"||yr(t)===void 0)?{ok:!1,refusal:{mutation:e.name,wouldNeed:[],message:Fd}}:{ok:!0};if(i&&i===this.proposer)return this.permitsProposal(e,t);let a=i!==void 0&&i===this.keeper&&Ti(this.mutations.values(),e.args.kind).length===0,d=a?e.args.from:i?.subject&&e.args[i.subject.arg],u=this.subjectKindOf(e,t),c=ve(this.policy,t,e.name,u,this.viaOf(i,e,t),typeof d=="string"?d:void 0,this.words,()=>{let p=this.namedIn(e,!1);try{for(let l of yn(this.graph,i,e.args,this.sighted(t)).primitives)"edge"in l&&!un(t,l.edge.from)&&!un(t,l.edge.to)&&p.push(l.edge.to)}catch{}return p},i!==void 0&&(i.derived!==void 0||i===this.typer||a)?()=>this.madeBy(i,e,d):void 0,i?.derived!==void 0&&Kp.has(i.derived.act));if(c.ok&&i?.writesLinked&&typeof d=="string"){let p=this.refusesLinked(i,d,t);if(p)return p}return!c.ok||!i?.derived||!this.repeatMakes(i,e,d,t)?c:ve(this.policy,t,e.name,u,_r([...this.mutations.values()],i.derived.kind),typeof d=="string"?d:void 0,this.words)}mayPropose(e,t=He){if(!this.policy||this.past||Rt(t))return!1;e=this.spelledCall(e);let r=this.mutations.get(e.name);return!r||r===this.proposer||r===this.voter||this.refusesAgent(e,t)||this.namesTurnedOff(e,t)?!1:!this.permits(e,t).ok&&Co(this.policy,t,e.name,this.subjectKindOf(e,t))}proposal(e,t,r,o){let{calls:i,intent:s}=e.args;if(i.length===0||i.length>ji||i.some(f=>!f.args||typeof f.args!="object"||Array.isArray(f.args)))throw new N(`A proposal holds 1 to ${ji} changes, each an act's name and its arguments.`);let a=z(r).id??r.session;if(a===void 0)throw new N("A proposal is somebody's: sign in to propose a change.");let d=bn({basis:(s??`Proposed by ${r.name??a}`).slice(0,500),proposedBy:a.slice(0,120)}),u=this.rehearsal();u.proposing=!0;let c=u.applying(i,{author:r,lineage:d,...I("via",o)});if(c.ops.length===0)return;let p=[...new Set(c.ops.flatMap(f=>f.described??[]))],l=c.ops.filter(f=>f.mutation!==null&&f.author===r);return{id:this.nextId(),seq:this.log.length,batch:t,author:r,intent:c.ops.map(f=>f.intent).join("; "),...I("batchIntent",s),mutation:null,primitives:[],reads:[],writes:[],...p.length>0?{described:p}:{},at:this.now(),...I("via",o),lineage:d,suggests:i,...I("suggestsSaid",i.length>1&&l.length===i.length?l.map(f=>f.intent):void 0)}}permitsProposal(e,t){let r=i=>({ok:!1,refusal:{mutation:e.name,wouldNeed:[],message:i}});if(Rt(t))return r("Sign in to propose a change.");let o=Array.isArray(e.args.calls)?e.args.calls:[];for(let i of o){if(typeof i?.name!="string")continue;let s=this.permits(i,t);if(!(s.ok||this.mayPropose(i,t)))return r(`Not permitted to propose this: ${s.refusal.message.replace(/^Not permitted: /,"")}`)}return{ok:!0}}refusesLinked(e,t,r){let o=D(r)?this.graph:Re(this,r).graph,i=o.getNode(t);if(!i)return;let s=[...this.mutations.values()];for(let a of Object.keys(e.writesLinked??{})){let u=this.schema.tryDefinition(i.kind)?.edges?.[a]!==void 0?o.out(i.id,a):o.in(i.id,a);for(let c of u){let p=Ar(c.kind),l=this.mutations.get(p),f=l?this.permits({name:p,args:{[l.subject?.arg??"id"]:c.id}},r):ve(this.policy,r,p,c.kind,Or(this.schema,s,c.kind),c.id,this.words);if(f.ok)continue;let g=this.words.act?.(e.name)??e.name,h=(this.labels??=new Et(this.graph)).labelOf(c.id)??c.id,v=this.words.noun?.(c.kind)??c.kind;return{ok:!1,refusal:{mutation:e.name,kind:i.kind,wouldNeed:f.refusal.wouldNeed,message:`Not permitted: \u201C${g}\u201D would change \u201C${h}\u201D, ${/^[aeiou]/i.test(v)?"an":"a"} ${v} that is not yours to change. ${f.refusal.message}`}}}}}repeatMakes(e,t,r,o){let i=e.derived.act;if(i!=="detach"&&i!=="split")return!1;let s=this.schema.tryDefinition(e.derived.kind);if(!s)return!1;let a=typeof r=="string"?(D(o)?this.graph:Re(this,o).graph).getNode(r):void 0;return Oc(i,t.args,a,Oi(s))}madeBy(e,t,r){let o=ce(this.log),i=o.creatorOf(r),s=t.args.into;if(!(e.derived?.act==="merge"&&typeof s=="string"&&o.creatorOf(s)!==i))return i}namedIn(e,t=!0){let r=this.mutations.get(e.name);if(!r)return[];let o=r.subject?.arg;return[...t&&o?[e.args[o]]:[],...Pt(r.input).flatMap(s=>s.name===o?[]:[e.args[s.name]])].flat().filter(s=>typeof s=="string")}refuse(e,t,r=!this.rehearsing){throw r&&Gc(e,t),new Ve(e)}get words(){return{act:e=>this.mutations.get(e)?.title,noun:e=>X(this.schema.tryDefinition(e),e)}}refusesAgent(e,t){if(t.kind!=="agent"||t.id===void 0)return;let r=this.may.get(t.id);if(!r||r.has(e.name))return;let o=s=>`\u201C${this.mutations.get(s)?.title??s}\u201D`,i=[...r].map(o);return{mutation:e.name,message:`${t.id} may not ${o(e.name)} here: it was declared able to ${i.length===0?"do nothing else":i.join(", ")}.`,wouldNeed:[]}}namesTurnedOff(e,t=Vc){let r=this.modules.disabledKinds;if(r.size===0||!D(t))return;let o=this.mutations.get(e.name);if(!(!o||!this.namedIn(e).some(i=>r.has(this.graph.getNode(i)?.kind))))return{mutation:e.name,message:`\u201C${o.title??e.name}\u201D names a record of a module this workspace has turned off.`,wouldNeed:[]}}sighted(e){let t={me:e&&sr(this.schema,e),everHeld:o=>ce(this.log).kindOf(o)!==void 0,keeps:(o,i)=>Vd(this.policy?.sees,o,i),...e&&this.hasNoRecord(e,!1)?{noRecord:!0}:{},...e&&!this.hasNoRecord(e,!1)&&this.hasNoRecord(e)?{selfUnseen:!0}:{},...e&&D(e)?{hostsOwn:!0}:{}};if(e===void 0||!We(this,e))return t;let r=Bn(this,e);return{...t,seen:Re(this,e).graph,keepUnchanged:o=>Z(o,r),seesInFull:Xd(this,e)}}collaborative(e,t){return ae.collaborative?.(this.schema,this.graph.getNode(e)?.kind,t)??!1}asSplices(e,t){return ae.asSplices?ae.asSplices(this,e,t):e}missingFor(e,t=He){e=this.spelledCall(e);let r=this.mutations.get(e.name),o=new Set(this.namedIn(e));if(!r||o.size===0)return;let i=Re(this,t).graph;for(let s of o)if(!i.has(s))return new q(s,`\u201C${r.title??e.name}\u201D names a record that is not there.`)}mayAdminister(e,t=He){let r=this.modules.administered.get(e);return r?(r.mutations??[]).some(o=>{let i=this.mutations.get(o);return!!i&&Lo(i).some(s=>ve(this.policy,t,o,s,this.viaOf(i)).ok)}):!1}seenBy(e,t){return Re(this,e,t)}sees(e,t){return this.graph.has(t)&&Bn(this,e)(t)}labels;resolveRef(e,t,r=He){let o=(this.policy?.sees?.length??0)>0,i=l=>!o||this.sees(r,l),s=this.graph.getNode(t);if(this.labels??=new Et(this.graph),s&&i(t))return{ok:!0,id:t,label:this.labels.labelOf(t)??t,by:"id"};let a=this.labels.lookup(e.kinds,t),d=l=>{let f=l.filter(g=>!this.graph.isArchived(g));return f.length?f:l},u=d(a.exact.filter(i)),c=u.length>0,p=(c?u:d(a.prefix.filter(i))).map(l=>({id:l,kind:this.graph.getNode(l).kind,label:this.labels.labelOf(l)??l})).sort((l,f)=>l.label<f.label?-1:l.label>f.label?1:l.id<f.id?-1:1);return p.length===1?{ok:!0,id:p[0].id,label:p[0].label,by:c?"label":"prefix"}:fc(this.schema,e,t,p)}kindsKeptFrom(e=He){let t=new Set;for(let[o,i]of this.modules.administered)if(!this.mayAdminister(o,e))for(let s of i.kinds??[])t.add(s);let r=this.policy?.sees??[];if(r.length>0&&!D(e)){let o=new Set(this.permittedMutations(e).flatMap(s=>s.creates??[])),i=Ie(this);for(let s of this.schema.kinds)!r.some(d=>d.kinds.includes(s)&&be(d,e)&&(!d.own&&!d.via||e.id!==void 0)&&(i||!Ot(d)))&&!o.has(s)&&t.add(s)}return t}permittedMutations(e=He){let t=this.allMutations(),r=Fo(this.policy,e,t.filter(a=>!a.derived&&a!==this.publisher)),o=this.publisher&&J.verdict(this,e).ok?[this.publisher]:[],i=t.filter(a=>a.derived!==void 0&&ve(this.policy,e,a.name,a.derived.kind,this.viaOf(a),z(e).id).ok);return[...r,...o,...i].filter(a=>!this.noOneToBe(a,e))}subjectKindOf(e,t=Vc){let o=this.mutations.get(e.name)?.subject;if(!o)return;let i=e.args[o.arg];if(typeof i!="string")return o.kinds!=="*"&&o.kinds.length===1?o.kinds[0]:void 0;if(!(!D(t)&&!Re(this,t).graph.has(i)))return this.graph.getNode(i)?.kind}today(){return this.pinned()??(this.ticked&&this.ticked.on===te(this.timeZone)?this.ticked.day:void 0)??(this.timeZone?te(this.timeZone):void 0)}pinned(){let e=this.invariantOptions.context,t=this.invariantOptions.today??e?.today;return typeof t=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t)?t:void 0}judging(e){let t=this.today(),r=sd(this.graph),o=e??this.invariantOptions.context,i=r&&!(o&&"linked"in o)?{...o,linked:r}:e,s=i??o,a=this.timeZone&&t!==void 0&&e===void 0&&!(s&&"today"in s)?{...s,today:t}:i;return{...this.invariantOptions,...a===void 0?{}:{context:a},...t===void 0?{}:{today:t}}}tick(e=new Date){let t=this.pinned();if(t!==void 0)return{day:t,was:t,appeared:[],cleared:[]};let r=Li(e,this.timeZone),o=te(this.timeZone);this.ticked&&(this.ticked={day:this.ticked.day,on:o});let i=this.today(),s=this.violations();this.ticked={day:r,on:o};let a=this.moved(s,this.violations());if(r!==i&&(this.told+=1),r!==i&&!this.rehearsing&&this.quiet===0)for(let d of this.listeners)d(Cn,[]);return{day:r,...i===void 0?{}:{was:i},appeared:a.introduces,cleared:a.resolves}}reread(){if(this.told+=1,!(this.rehearsing||this.quiet>0))for(let e of this.listeners)e(Cn,[])}violations(e,t=this.graph){return Zn(t,this.allInvariants(),this.judging(e)).map(r=>this.asking(r))}required=new Map;asking(e){if(!e.repairs.some(o=>o.missing===void 0))return e;let t=!1,r=e.repairs.map(o=>{if(o.missing!==void 0)return o;let i=this.requiredOf(o.mutation).filter(s=>o.args?.[s]===void 0);return i.length===0?o:(t=!0,{...o,missing:i})});return t?{...e,repairs:r}:e}requiredOf(e){let t=this.required.get(e);if(t)return t;let r=this.mutations.get(e)?.input?.shape??{},o=Object.entries(r).filter(([,i])=>typeof i?.safeParse=="function"&&!i.safeParse(void 0).success).map(([i])=>i);return this.required.set(e,o),o}wouldChange(e,t){try{return yn(this.graph,this.mutation(e.name),e.args,this.sighted(t)).primitives.length>0}catch{return!0}}wouldDo(e,t=this.by){let r=fn(t),o=this.personFor(r);return o?this.withPersonMade(r,o.id).compiledEach(e,r):this.compiledEach(e,r)}withPersonMade(e,t){let r=JSON.stringify([this.version,this.log.length,z(e).id,t,pe(e)?.name]);if(this.personMade?.key===r)return this.personMade.twin;let o=this.rehearsal(),i=o.personToMake(e,zr,{});return i&&(o.graph.applyPrimitives(i.primitives),o.log.append(i)),this.personMade={key:r,twin:o},o}personMade;compiledEach(e,t){let r=this.sighted(t);return e.map(o=>{try{return yn(this.graph,this.mutation(o.name),o.args,r).primitives.length>0?"changes":"nothing"}catch(i){return{refused:i}}})}get version(){return this.told}preview(e,t,r={}){e=this.spelledCall(e);let o=this.mutation(e.name),i=yn(this.graph,o,e.args,this.sighted(r.author)),s=this.asSplices(i.primitives),a=[];if(Un(this.schema)){let d=H.from(this.schema,this.graph.snapshot());d.applyPrimitives(s),a=xr(this.schema,d,s,{mayWriteBack:this.writesBack(r.author??this.by)})}return this.previewPrimitives([...s,...a],{reads:i.reads,writes:i.writes,intent:i.intent,context:t})}previewAll(e,t={}){let{context:r,...o}=t;return{...this.rehearsal().applying(e,o,r),kept:!1}}rehearsal(){let e=Object.assign(Object.create(n.prototype),this),t=0;Object.assign(e,{graph:H.from(this.schema,this.graph.snapshot(),{validate:this.validate}),log:Vn.from(this.log.all(),this.log.epochs(),{horizon:this.log.horizon}),listeners:new Set,labels:void 0,nextId:()=>`${zr}:${++t}`,mintBatch:()=>zr,rehearsing:!0,personMade:void 0});let r=this.typer&&ae.typeText(e);return Object.assign(e,{typer:r,mutations:r?new Map(this.mutations).set(hr,r):new Map(this.mutations)}),e}wouldKeep(e,t,r){try{return this.rehearsal().applying(e,{author:t,lineage:r}),!0}catch{return!1}}previewPrimitives(e,t){let r=this.violations(t.context),o=H.from(this.schema,this.graph.snapshot()),i=o.applyPrimitives(e,{restoring:t.restoring===!0}),s=Zn(o,this.allInvariants(),this.judging(t.context));return{diff:i,primitives:e,reads:t.reads,writes:t.writes,intent:t.intent,...this.moved(r,s),violationsAfter:s}}apply(e,t={}){return this.applyAll([e],t)}applyAll(e,t={}){return this.applying(e,t)}applying(e,t,r){let o=e.map(x=>this.spelledCall(x));this.stillNow();let i=t.batch??this.mintBatch("batch"),s=fn(t.author??this.by),a=bn(t.lineage),d=[],u=[],c=new Set,p=new Set,l=[],f=this.violations(r),g=this.graph.snapshot(),h=this.log.length,v=(x,_=s)=>{let M=this.voter!==void 0&&this.mutations.get(x.name)===this.voter,E=this.policy||this.publisher&&x.name===gr||M||this.mutations.get(x.name)===this.proposer?this.judged(x,_):void 0;E&&!E.ok&&!(this.proposing&&this.mayPropose(x,_))&&this.refuse(E.refusal,_.id)},m=(x,_=s)=>{let M=this.refusesAgent(x,_)??this.namesTurnedOff(x,_);M&&this.refuse(M,_.id)},k=o.map(zi);o.forEach((x,_)=>k[_]||v(x)),o.forEach((x,_)=>k[_]||m(x));let $=o.map(x=>({sent:x,as:s,lineage:a,decided:!1}));wt(s)&&this.refuseDeclined(o,s),Qo(s)&&this.refuseStopped(o,s,this.suggesting),this.rehearsing||Nr(s.id);let O=[],A=[],y=new Map,b=x=>typeof x=="string"?y.get(x)??x:Array.isArray(x)?x.map(b):x;try{let x=this.personToMake(s,i,t);x&&(this.graph.applyPrimitives(x.primitives),this.log.append(x),d.push(x),u.push(...x.primitives),p.add(x.writes[0]));for(let _=0;_<$.length;_++){let{sent:M,as:E,lineage:re,decided:Qn}=$[_],Sn=_<k.length?k[_]:zi(M),{mintedHint:en,...Rn}=M,et=y.size?{...Rn,args:Object.fromEntries(Object.entries(Rn.args).map(([T,Ae])=>[T,b(Ae)]))}:Rn,G=Sn?Ic(et,O,_):et;(Sn||Qn||x)&&(v(G,E),m(G,E));let ye=this.mutation(G.name);if(ye===this.publisher){let T=J.op(this,{id:this.nextId(),at:this.now()},G,i,E,t);d.push(T),l.push(T.intent);continue}if(ye===this.voter){if(!br.op)throw new N("Load @graview/core/tidying to vote on a suggestion.");let T=br.op(this,{id:this.nextId(),at:this.now()},G,i,E,t);this.log.append(T),d.push(T),l.push(T.intent);let Ae=br.accepting?.(this,T);if(Ae&&this.wouldKeep(Ae.calls,Ae.author,Ae.lineage))for(let Al of Ae.calls)$.push({sent:Al,as:Ae.author,lineage:bn(Ae.lineage),decided:!0});continue}if(ye===this.proposer){let T=this.proposal(G,i,E,t.via);if(!T)continue;this.log.append(T),d.push(T),l.push(T.intent);continue}let nt=this.missingFor(G,E);if(nt)throw nt;let K;try{K=yn(this.graph,ye,G.args,{...this.sighted(E),hint:en})}catch(T){throw T instanceof Se&&!this.rehearsing&&Di(T,E.id),T}if(en!==void 0&&K.firstMinted!==void 0&&K.firstMinted!==en&&y.set(en,K.firstMinted),wt(E)){let T=xd(this.schema,this.graph,K.primitives,this.authorName(E),{declaration:!this.suggesting&&!Qn});T&&this.refuse({mutation:G.name,message:T,wouldNeed:[]},E.id)}if(K.primitives.length===0)continue;A[_]=K.firstMinted;let nn=this.asSplices(K.primitives,t.base).map(De);this.graph.applyPrimitives(nn);let Ur=Un(this.schema)?xr(this.schema,this.graph,nn,{mayWriteBack:this.writesBack(E)}).map(De):[];O[_]=K.primitives.find(T=>T.op==="add-node")?.node.id;let $n={id:this.nextId(),seq:this.log.length,batch:i,author:E,intent:ye.describe!==void 0?K.intent:t.intent??K.intent,...I("batchIntent",t.intent),mutation:G,primitives:[...nn,...Ur],reads:K.reads,writes:Ur.length>0?[...new Set([...K.writes,...Ur.flatMap(Oe)])]:K.writes,...ye.describe!==void 0&&K.described&&K.described.length>0?{described:K.described}:{},...I("mergedInto",K.mergedInto),at:this.now(),...I("via",t.via),...I("lineage",re)};this.log.append($n),d.push($n),u.push(...$n.primitives);for(let T of $n.reads)c.add(T);for(let T of $n.writes)p.add(T);l.push($n.intent)}x&&d.length===1&&(this.putBack(g,h),d.length=0,u.length=0,p.clear())}catch(x){throw this.putBack(g,h),x}let R=Ge(g,this.graph.snapshot(),u);this.admitted(t,d,u,R,g,h);let S=this.violations(r);return this.notify(R,d),{batch:i,ops:d,...A.length>0?{minted:A}:{},diff:R,primitives:u,reads:[...c],writes:[...p],intent:t.intent??l.join("; "),...this.moved(f,S),violationsAfter:S}}receive(e,t={}){this.stillNow();let r=new Set(this.log.all().map(d=>d.id)),o=e.filter(d=>!r.has(d.id));if(o.length===0)return[];let i=this.graph.snapshot(),s=[];if(!t.applied)for(let d of o)try{this.graph.applyPrimitives(d.primitives,{restoring:d.undoes!==void 0})}catch(u){throw this.graph.load(i),new Yn(d,u)}let a=this.log.length;for(let[d,u]of o.entries()){let c=tt({...u,seq:a+d});this.log.append(c),s.push(c)}return this.countPast(s),this.notify(Ge(i,this.graph.snapshot(),o.flatMap(d=>d.primitives)),s),s}append(e,t={}){if(this.stillNow(),e.length===0)return[];let r=new Set(this.log.all().map(a=>a.id)),o,i=e.map((a,d)=>{let u=a.primitives.map(De),c={id:a.id??this.nextId(),seq:this.log.length+d,batch:a.batch??t.batch??(o??=this.mintBatch("batch")),author:a.author,intent:a.intent,...I("batchIntent",a.batchIntent),mutation:a.mutation??null,primitives:u,reads:a.reads??[],writes:a.writes??[...new Set(u.flatMap(Oe))],at:a.at??this.now(),...I("undoes",a.undoes),...I("via",a.via),...I("lineage",bn(a.lineage)),...I("described",a.described),...I("sentOut",a.sentOut)};if(r.has(c.id))throw new N(`Op "${c.id}" (${c.intent}) is already in the log`,"A host-made op needs an id of its own; leave `id` out and the store mints one.");return r.add(c.id),c}),s=this.graph.snapshot();for(let a of i)try{this.graph.applyPrimitives(a.primitives,{restoring:a.undoes!==void 0})}catch(d){throw this.graph.load(s),new Yn(a,d)}for(let a of i)this.log.append(a);this.countPast(i);for(let a of i)Nr(a.author.id);return this.notify(Ge(s,this.graph.snapshot(),i.flatMap(a=>a.primitives)),i),i}applyPrimitives(e,t={}){this.stillNow();let r=t.batch??this.mintBatch("batch"),o=fn(t.author??this.by),i=this.violations(),s=this.graph.snapshot(),a=t.intent??"Apply a change",d=bn(t.lineage),u=this.asSplices(e,t.base).map(De);this.graph.applyPrimitives(u);let c=u;try{Un(this.schema)&&(c=[...u,...xr(this.schema,this.graph,u,{mayWriteBack:this.writesBack(o)}).map(De)])}catch(g){throw this.putBack(s,this.log.length),g}let p=[];if(c.length>0){let g={id:this.nextId(),seq:this.log.length,batch:r,author:o,intent:a,mutation:null,primitives:c,reads:[],writes:[...new Set(c.flatMap(Oe))],at:this.now(),...I("via",t.via),...I("lineage",d)};this.log.append(g),p.push(g),Nr(o.id)}let l=this.violations(),f=Ge(s,this.graph.snapshot(),c);return this.notify(f,p),{batch:r,ops:p,diff:f,primitives:c,reads:[],writes:p[0]?.writes??[],intent:a,...this.moved(i,l),violationsAfter:l}}findings(){return Cc({schema:this.schema,invariants:this.allInvariants()},this.graph.snapshot(),{invariantOptions:this.invariantOptions})}batches(){return this.log.batches()}canUndo(e){return St(this.log,typeof e=="string"?[e]:e)}previewUndo(e,t){let r=this.canUndo(e);if(!r.ok)return{ok:!1,check:r};let o=zd(r.ops,this.log.all()),i=new Set;for(let s of r.ops)for(let a of s.writes)i.add(a);return{ok:!0,check:r,...this.previewPrimitives(o,{reads:[...new Set(r.ops.flatMap(s=>[...s.reads]))],writes:[...i],intent:`Undo: ${r.ops.map(s=>s.intent).join("; ")}`,restoring:r.ops.every(Bc),...t===void 0?{}:{context:t}})}}stopsServed;undo(e,t={}){return this.undoing(e,t)}undoing(e,t){this.stillNow();let r=typeof e=="string"?[e]:e,o=fn(t.author??this.by),i=de.lift?.(this,r,t,o);if(i)return i;let s=(this.policy?.sees?.length??0)>0&&!D(o);if(s){let m=St(pi(Kn(this.log.all(),kr(this,o)),()=>this.log.epochs()),r);if(!m.ok)throw new hn(m)}let a=this.canUndo(r);if(!a.ok)throw new hn(s?{ok:!1,ops:[],blockedBy:[],includeBatches:[],message:"Cannot undo on its own \u2014 a later change you cannot see depends on it, which only somebody who can see it can take back."}:a);let d=t.batch??this.mintBatch("undo"),u=bn(t.lineage,!0),c=this.undoRefusal(a.ops,o);if(c&&this.refuse(c,o.id,!0),u?.stopsKind===!0){let m=de.stopRefusal?de.stopRefusal(this,a.ops,o):"This store cannot be told not to suggest something.";m&&this.refuse({mutation:"undo",wouldNeed:[],message:m},o.id,!0)}let p=this.graph.snapshot(),l=this.violations(),f=[],g=this.log.length;for(let{op:m,primitives:k}of ri(this.log.all(),a.ops)){let $={id:this.nextId(),seq:this.log.length,batch:d,author:o,intent:`Undo: ${m.intent}`,...I("batchIntent",t.intent),mutation:null,primitives:k,reads:m.reads,writes:m.writes,at:this.now(),undoes:m.id,...I("via",t.via),...I("lineage",u),...I("undoneLineage",m.lineage)};this.graph.applyPrimitives($.primitives,{restoring:Bc(m)}),this.log.append($),f.push($)}let h=Ge(p,this.graph.snapshot(),f.flatMap(m=>[...m.primitives]));this.admitted(t,f,f.flatMap(m=>[...m.primitives]),h,p,g);let v=this.violations();return this.notify(h,f),{batch:d,ops:f,diff:h,primitives:f.flatMap(m=>[...m.primitives]),reads:[...new Set(f.flatMap(m=>[...m.reads]))],writes:[...new Set(f.flatMap(m=>[...m.writes]))],intent:t.intent??f.map(m=>m.intent).join("; "),...this.moved(l,v),violationsAfter:v}}mayUndo(e,t=this.by){let r=de.liftRefusal?.(this,typeof e=="string"?[e]:e,t);if(r)return r.refusal?{ok:!1,refusal:r.refusal}:{ok:!0};let o=this.canUndo(e);if(!o.ok)return{ok:!1,check:o};let i=this.undoRefusal(o.ops,t);return i?{ok:!1,refusal:i}:{ok:!0}}undoRefusal(e,t){let r=de.undoRefusal?de.undoRefusal(this,e,t):e.some(o=>o.undoes!==void 0&&o.mutation===null&&(o.lineage?.stopsKind||o.lineage?.liftedStop))?{mutation:"undo",wouldNeed:[],message:"This cannot be taken back here yet."}:void 0;if(r)return r;if(this.policy||this.publisher)for(let o of e){let i=this.rootOf(o),s=z(i.author).id;if(i.vote!==void 0){if(i.vote.advisory&&!D(t)&&yr(t)!==i.vote.voter&&!(this.policy&&this.grantsEveryAct(t)))return{mutation:"undo",wouldNeed:[],message:`Not permitted to undo "${o.intent}": only whoever voted takes their vote back.`};if(this.policy&&!D(t)&&s!==z(t).id&&!this.grantsEveryAct(t))return{mutation:"undo",wouldNeed:[],message:`Not permitted to undo "${o.intent}": only whoever voted takes their vote back.`};continue}if(i.suggests&&!D(t)&&(i.author.kind!==t.kind||i.author.id!==t.id)){let u=i.suggests.map(c=>this.permits(c,t)).find(c=>!c.ok);if(u&&!u.ok)return{...u.refusal,message:this.suggestionWaits(o,u.refusal,t)};continue}if(!i.mutation){if(i.primitives.length===0)continue;if(this.policy&&!D(t)&&s!==z(t).id&&!this.grantsEveryAct(t))return{mutation:"undo",wouldNeed:[],message:`Not permitted to undo "${o.intent}": no act made it, so only whoever did may take it back.`};continue}let a=u=>JSON.stringify(u).includes(JSON.stringify(we(i.author))),d=s!==void 0&&s!==z(t).id&&!D(t)&&!a(i.mutation.args)&&a(i.primitives)?{ok:!1,refusal:{mutation:i.mutation.name,wouldNeed:[],message:"it was done as somebody else."}}:this.judged(i.mutation,t,!0);if(!d.ok)return{...d.refusal,message:`Not permitted to undo "${o.intent}": ${d.refusal.message}`}}}suggestionWaits(e,t,r){if(t.wouldNeed.length===0||t.wouldNeed.some(s=>r.roles?.includes(s)))return t.message;let o=`That suggestion waits for ${ir(t.wouldNeed)} to decide.`;return this.mutations.has(gn)&&this.permits({name:gn,args:{suggestion:e.id,vote:"for"}},r).ok?`${o} You can vote on it, but not take it back.`:`${o} You cannot take it back.`}rootOf(e){let t=e;for(let r=t.undoes===void 0?void 0:this.log.get(t.undoes);r!==void 0;r=t.undoes===void 0?void 0:this.log.get(t.undoes))t=r;return t}personFor(e){let t=pe(e),r=we(e);if(!t||r===void 0)return;let o=this.schema.definitions.find(c=>c.people);if(!o||this.graph.has(r)||ce(this.log).kindOf(r)!==void 0)return;let i=o.fields,s=i.shape??{},a=Object.keys(s).filter(c=>s[c].safeParse("x").success&&!s[c].safeParse(1).success),d=a.includes("name")?"name":a.find(c=>!s[c].safeParse(void 0).success)??a[0],u={...o.defaults,id:r,kind:o.kind,...d?{[d]:t.name}:{}};return i.safeParse(u).success?{id:r,name:t.name,node:u}:void 0}hasNoRecord(e,t=!0){let r=this.schema.definitions.find(d=>d.people);if(!r)return!1;let o=d=>t&&!this.seesOwnPerson(e,d);if(z(e).id===void 0)return o({id:"",kind:r.kind});let i=we(e);if(i===void 0)return!0;let s=this.graph.getNode(i)?.kind;if(s!==void 0&&this.schema.tryDefinition(s)?.people)return o({id:i,kind:s});if(!pe(e))return!1;let a=this.personFor(e);return!a||o({id:a.id,kind:a.node.kind})}seesOwnPerson(e,t){return We(this,e)?this.modules.disabledKinds.has(t.kind)&&!D(e)?!1:this.graph.has(t.id)?Bn(this,e)(t.id):Be(this.policy,e,t,{out:()=>[],in:()=>[]},ce(this.log),Ie(this)):!0}noOneToBe(e,t){if(!(!e.doneAsMe||!this.hasNoRecord(t)))return{mutation:e.name,wouldNeed:[],message:`"${e.title??e.name}" is done as you, and you have no record here`}}personToMake(e,t,r){let o=this.personFor(e);if(o)return{id:this.nextId(),seq:this.log.length,batch:t,author:e,intent:`${o.name} joins`,mutation:null,primitives:[De({op:"add-node",node:o.node})],reads:[],writes:[o.id],at:this.now(),...I("via",r.via)}}grantsEveryAct(e){let t=z(e);return(this.policy?.grants??[]).some(r=>be(r,t)&&r.mutations==="*"&&(r.kinds===void 0||r.kinds==="*")&&!r.self&&!r.ownEnd)}authorName(e){return Fn(e,{graph:this.graph,schema:this.schema})}actMeanings(){return{act:e=>this.mutations.get(this.spelled(e)),has:e=>this.graph.has(e)}}refuseStopped(e,t,r){let o=s=>de.stopped?.(this.log.all(),s,this.actMeanings(),this.log.horizonEpoch()?.declines),i=r?o(e):e.map(s=>o([s])).find(Boolean);i&&this.refuse({mutation:e[0].name,message:`${this.authorName(t)} may not suggest this kind of thing: a person said not to on ${i.at.slice(0,10)}.`,wouldNeed:[]},t.id)}refuseDeclined(e,t){let r=de.declined?.(this.log.all(),e,this.actMeanings(),this.log.horizonEpoch()?.declines);r&&this.refuse({mutation:e[0].name,message:`${this.authorName(t)} may not make this again: a person declined it on ${r.at.slice(0,10)}.`,wouldNeed:[]},t.id)}putBack(e,t){this.graph.load(e),this.log.length>t&&this.log.truncate(t)}admitted(e,t,r,o,i,s){if(!e.admit||t.length===0)return;let a=this.graph.size;try{e.admit({ops:t,primitives:r,added:{nodes:o.addedNodes.length,edges:o.addedEdges.length},removed:{nodes:o.removedNodes.length,edges:o.removedEdges.length},changed:{nodes:o.changedNodes.length},nodesAfter:a.nodes,edgesAfter:a.edges})}catch(d){throw this.putBack(i,s),d}}redo(e,t={}){return this.undo(e,t)}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(e,t){if(this.told+=1,this.personMade=void 0,!(this.quiet>0)&&!(t.length===0&&qo(e)))for(let r of this.listeners)r(e,t)}rebase(e){this.stillNow();let t=new Set([...e.pending,...e.drop??[]]),r=this.log.all(),o=r.findIndex(h=>t.has(h.batch)),i=r.slice(o<0?r.length:o),s=this.log.horizon+(o<0?r.length:o),a=i.find(h=>!t.has(h.batch));if(a)throw new N(`Cannot rebase: op "${a.id}" (${a.intent}) comes after a pending batch and is neither pending nor dropped`,"While anything is pending, land the server's ops through rebase, so the log stays confirmed ops then pending ones.");let d=this.log.lastEpoch();if(d&&d.seq>s)throw new N(`Cannot rebase across an epoch: one begins at seq ${d.seq}, after pending op "${i[0].id}"`);let u=this.graph.snapshot(),c=[],p=[],l=[];this.quiet++;try{for(let k of[...i].reverse())this.graph.applyPrimitives(rn(k),{restoring:!0,inPlace:!0});this.log.truncate(s);let h=new Set(this.log.all().map(k=>k.id));for(let k of e.confirmed){if(h.has(k.id))continue;try{this.graph.applyPrimitives(k.primitives,{restoring:k.undoes!==void 0})}catch(w){throw new Yn(k,w)}let $=tt({...k,seq:this.log.length});this.log.append($),h.add(k.id),c.push($)}this.countPast(c);let v=ae.carried?.(i,c,e.pending),m=Uc(i);for(let k of e.pending){let $=i.filter(w=>w.batch===k);if($.length!==0)try{p.push(...this.replay(k,$,v?.get(k),m))}catch(w){l.push({batch:k,error:w})}}}catch(h){this.log.truncate(s);for(let v of i)this.log.append(v);throw this.graph.load(u),h}finally{this.quiet--}let f=ze(u,this.graph.snapshot()),g=[...c,...p];return this.notify(f,g),{diff:f,confirmed:c,pending:p,refused:l}}adopt(e){this.stillNow();let t=new Set(e.drop??[]),r=(e.pending??[]).filter(f=>!t.has(f)),o=this.log.all(),i=this.graph.snapshot(),s={ops:[...o],epochs:[...this.log.epochs()],horizon:this.log.horizon},a=new Set(o.map(f=>f.id)),d=new Map(r.map(f=>[f,o.filter(g=>g.batch===f)]));if(e.log.length>0)this.log.replace(e.log,e.epochs,I("horizon",e.horizon));else{let f=e.horizon??0;this.log.replace([],e.epochs??[{seq:f,base:e.snapshot}],{horizon:f})}let u=[],c=[];this.quiet++;try{this.graph.load(e.snapshot),this.projected=void 0,this.countPastTheLog();for(let f of r){let g=d.get(f)??[];if(g.length!==0)try{u.push(...this.replay(f,g,void 0,Uc(o)))}catch(h){c.push({batch:f,error:h})}}}catch(f){throw this.log.replace(s.ops,s.epochs,{horizon:s.horizon}),this.graph.load(i),this.projected=void 0,f}finally{this.quiet--}let p=this.log.all().filter(f=>!a.has(f.id)&&!u.includes(f)),l=ze(i,this.graph.snapshot());return this.notify(l,[...p,...u]),{diff:l,adopted:p,pending:u,refused:c}}replay(e,t,r,o=new Map){let i=t[0],s={author:i.author,batch:e,...I("intent",i.batchIntent),...I("via",i.via),...I("lineage",i.lineage)};if(i.undoes!==void 0){let a=t.map(u=>this.log.get(u.undoes??"")?.batch??o.get(u.undoes??"")),d=t.find((u,c)=>a[c]===void 0||!this.log.all().some(p=>p.batch===a[c]));if(d)throw new N(`What "${d.intent}" took back is no longer in the log`);return this.undoing([...new Set(a)],s).ops}return r?this.applying(r,s).ops:t.every(a=>a.mutation!==null)?this.applying(t.map(a=>a.mutation),s).ops:this.append(t.map(({seq:a,...d})=>d))}snapshot(){return this.graph.snapshot()}verify(){let e=this.log.lastEpoch();return hc(this.schema,this.log.opsFrom(e?.seq??0),this.graph.snapshot(),{validate:this.validate,...e?{base:e.base}:{}})}checkpoint(e={}){let t=this.log.all(),r;if(e.seq!==void 0)r=e.seq;else{let c=this.log.length-(e.keepOps??1e3),l=Date.parse(e.now??this.now())-(e.keepDays??90)*864e5,f=t.find(h=>Date.parse(h.at)>l),g=f?f.seq:this.log.length;r=Math.min(c,g)}let o=ei(this.publishing)&&this.publishedSeq===void 0?[0]:[],i=[...e.pins??[],...o].filter(c=>Number.isInteger(c));i.length>0&&(r=Math.min(r,...i));let s=e.format??he.snapshot;if(!Number.isInteger(s)||s<1||s>he.snapshot)throw new RangeError(`Cannot write a checkpoint in snapshot format ${String(s)}: this build writes formats 1 to ${he.snapshot}.`);let a=c=>{let p=Math.min(Math.max(c,this.log.horizon),this.log.length);for(;p>this.log.horizon&&p<this.log.length&&t[p-this.log.horizon].batch===t[p-1-this.log.horizon].batch;)p--;return p};if(r=a(r),r<=this.log.horizon)return;let d=this.verify();if(!d.ok)throw new N(`Cannot compact a store that does not verify: ${d.reason}`);let u=this.checkpointWithPublished(r);for(;Ci(u).formats.snapshot>s;){if(r=a(Math.min(...u.published.map(c=>c.seq))),r<=this.log.horizon)return;u=this.checkpointWithPublished(r)}return u}checkpointWithPublished(e){let t=this.log.horizonEpoch()?.published??[],r=(J.behind?.(this,e)??[]).flatMap(o=>o>=this.log.horizon?[this.epochAt(o)]:t.filter(i=>i.seq===o));return{...this.epochAt(e),...r.length>0&&{published:r}}}epochAt(e){let t=this.log.all(),{creators:r,removed:o,writers:i,published:s,declines:a,...d}=this.log.checkpointAt(this.schema,e,{validate:this.validate}),u=new Set(d.base.nodes.map(m=>m.id)),{creators:c,removed:p}=Ud(this.log,e,m=>u.has(m)),l=ce(this.log),f=Kd(this.log,e,d.base.nodes,m=>Z(m,k=>!u.has(k)&&l.kindOf(k)===void 0)),g=m=>m&&Object.keys(m).length>0,h=this.log.horizonEpoch()?.declines,v=de.kept?de.kept(t,this.actMeanings(),h):h;return{...d,...g(c)&&{creators:c},...p&&{removed:p},...g(f)&&{writers:f},...g(v)&&{declines:v},...I("enabledModules",t.slice(0,e-this.log.horizon).reverse().find(m=>m.enabledModules)?.enabledModules??this.log.horizonEpoch()?.enabledModules),...I("publishedThrough",J.seq?.(this,e))}}compact(e){return this.stillNow(),this.log.compact(e)}};var Up=n=>`lens:${n}`,Wp={hidden:[],removed:[],may:{views:!1,lenses:!1}};function qp(n,e,t){return n.name!==void 0&&e.may.views?"view":n.declared&&e.may.lenses&&t.lens?"lens":null}var Yc=["full","summary","glyph"],jt="view:",Vi=(n,e)=>n.as===e.as&&(n.over??[n.kind]).includes(e.kind),Hp=n=>n.filter((e,t)=>!n.slice(0,t).some(r=>Vi(r,e))),Yp=n=>n.filter(e=>!e.hidden);function Te(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function Dt(n,e){return`/${Te(n.tryDefinition(e)?.plural??`${e}s`)}`}function Jp(n,e,t){return`${Dt(n,e)}/${encodeURIComponent(t)}`}function Xp(n,e){return`/places/${encodeURIComponent(n)}${e?`?of=${encodeURIComponent(e)}`:""}`}function Jc(n,e){return e.some(t=>t.as===n.as&&!Vi(n,t))}function Qp(n,e,t){return Jc(n,e)?`${n.title} \xB7 ${(t.tryDefinition(n.kind)?.plural??`${n.kind}s`).toLowerCase()}`:n.title}var vn=(n,e,t="")=>`${n}|${e.cardinality}|${e.fidelity}|${t}`;function Ki(n){switch(n){case"full":return["full","summary","glyph"];case"summary":return["summary","full","glyph"];case"glyph":return["glyph","summary","full"]}}function eh(n){let e=new Map,t=[],r=[],o,i=[],s={arrange(a){return a!==void 0&&(o=a),s},arrangement:()=>o,home(a,d){return a!==void 0&&i.push({view:a,...d?.name!==void 0?{name:d.name}:{}}),s},homeView:()=>i.at(-1)?.view,homes:()=>i,register(a,d,u,c){let p={...c?.over?.[1]?{over:c.over}:{},...c?.hidden?{hidden:!0}:{},...c?.name?{name:c.name}:{},...c?.declared?{declared:!0}:{}},l={kind:a,cardinality:d.cardinality,fidelity:d.fidelity,view:u,...c?.title?{title:c.title}:{},...c?.across?{across:c.across}:{},...c?.beside?{beside:!0}:{},...p};if(r.push(l),!c?.beside&&!p.hidden&&e.set(vn(a,d),l),c?.title){let f=Te(c.title);e.set(vn(a,d,f),l),d.cardinality==="many"&&!t.some(g=>g.kind===a&&g.as===f)&&t.push({kind:a,title:c.title,as:f,...c.across?{across:c.across}:{},...p,...c.lens?{lens:c.lens}:{},...c.reads?.length?{reads:c.reads}:{}})}return s},places:()=>t,forget(a,d){for(let c of Yc)e.delete(vn(a,{cardinality:"many",fidelity:c},d));let u=t.findIndex(c=>c.kind===a&&c.as===d);return u>=0&&t.splice(u,1),s},lookup(a,d){return e.get(vn(a,d))?.view},resolve(a,d,u){if(u)for(let c of Ki(d.fidelity)){let p=e.get(vn(a,{cardinality:d.cardinality,fidelity:c},u));if(p)return p}for(let c of Ki(d.fidelity)){let p=e.get(vn(a,{cardinality:d.cardinality,fidelity:c}));if(p)return p}if(d.cardinality==="one")for(let c of Ki(d.fidelity)){let p=e.get(vn(a,{cardinality:"many",fidelity:c}));if(p)return p}},registrations:()=>r,all(){return[...e.values()]},kindsWithViews(){return[...new Set([...e.values()].map(a=>a.kind))]}};return s}var nh=["day","week","month","year","decade"];function Xc(n){let e={};n.q&&n.q.trim().length>0&&(e.query=n.q);let t=Go(n.archived);if(t&&(e.archived=t),n.sort){let[r,o]=n.sort.split(":");r&&(e.sort={by:r,direction:o==="desc"?"desc":"asc"})}if(n.filter){let r=[];for(let o of n.filter.split(",")){let i=o.indexOf(":");i<=0||r.push({key:o.slice(0,i),value:o.slice(i+1)})}r.length>0&&(e.filter=r)}if(n.group){let[r,o]=n.group.split(":");r&&(e.group={by:r,...nh.includes(o)?{bucket:o}:{}})}return e}function Bi(n){if(typeof n=="string"&&n.length>0)return{by:n,direction:"asc"};if(typeof n!="object"||n===null)return;let{by:e,direction:t}=n;if(!(typeof e!="string"||e.length===0))return{by:e,direction:t==="desc"?"desc":"asc"}}function jr(n,e,t){let r=Bi(n);if(!r)return'an order is a field, like "released", or { "by": "released", "direction": "asc" | "desc" }';let o=typeof n=="object"&&n!==null?n.direction:void 0;if(o!==void 0&&o!=="asc"&&o!=="desc")return`an order runs "asc" or "desc", not "${String(o)}"`;if(r.by!=="label"&&!e.includes(r.by))return`${t} has no field "${r.by}" to order by (it has ${e.length>0?e.map(i=>`"${i}"`).join(", "):"none"}, and "label", its name)`}function th(n,e,t){let r=Bi(e);if(!r)return n;let o=r.direction==="desc"?-1:1;return n.map((i,s)=>({item:i,at:s,value:t(i,r.by)})).sort((i,s)=>{let a=(i.value===void 0||i.value===null||i.value===""?1:0)-(s.value===void 0||s.value===null||s.value===""?1:0);if(a!==0)return a;if(i.value===s.value||i.value===void 0||i.value===null)return i.at-s.at;let d=typeof i.value=="number"&&typeof s.value=="number"?i.value-s.value:String(i.value).localeCompare(String(s.value),void 0,{numeric:!0});return d===0?i.at-s.at:d*o}).map(i=>i.item)}var Ft={timeline:{binds:"fields",requiredRoles:["start","end"],options:["columns","extent","tick","minWindow","arranging"]},calendar:{binds:"fields",requiredRoles:["start"],options:["today","range","weekStartsOn","perCell","horizon","arranging","search","filters"]},coverage:{binds:"entities",requiredRoles:["rows","columns","link"],options:["rowRef","rowGroup","groupOrder","requiredGroups","requiredVia","badge","columnGroup","sort","columnSort","search","filters"]},board:{binds:"entities",requiredRoles:["slots","x","y","fill"],options:["fillFrom","slotCode","zones","aspect","emptyLabel","pickTarget","arranging","arrange"]},plan:{binds:"entities",requiredRoles:["regions","outline"],options:["hues","aspect","undrawnLabel","strayLabel","draw","place","help"]},reach:{binds:"nothing",requiredRoles:[],options:[]},blocks:{binds:"nothing",requiredRoles:[],options:["blocks"]},columns:{binds:"fields",requiredRoles:["column"],options:["sort","search","filters","move","collapsed","cap","hidden"]}},rh=["start","end"],oh=20,nl=Object.keys(Ft),ih=(n,e,t,r=Ft[n].options)=>({message:`The ${n} lens takes no option "${e}", so "${t}" ignores it.`,fix:r.length?`Use one of: ${r.join(", ")}.`:`The ${n} lens takes no options; drop it.`}),tl=n=>Object.hasOwn(Ft,n);function Ui(n,e,t){let r=n[e],o=Array.isArray(r)?r.filter(i=>typeof i=="string"&&t(i)):[];o.length>0?n[e]=o:delete n[e]}var Jn=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function sh(n,e,t){let r=n.tryDefinition(e)?.fields.shape,o=C(r?.[t]);for(;o&&(o.type==="optional"||o.type==="default"||o.type==="nullable"||o.type==="prefault");)o=C(o.innerType);return o?.type==="number"}var Qc=(n,e="start",t="end")=>`A timeline lays out spans by number \u2014 minutes of a day, 0 to 1440 \u2014 across columns: "bindings": { "${n}": { "start": "<a number field>", "end": "<a number field>", "column": "<a choice field, like a weekday>" } }, or "options": { "columns": ["mon", "tue", \u2026] }. For spans of dates, draw a calendar: "lens": "calendar", "bindings": { "${n}": { "start": "${e}", "end": "${t}" } }, "options": { "range": "month" }.`;function el(n,e,t){let r=n.tryDefinition(e)?.fields.shape,o=C(r?.[t]);for(;o&&(o.type==="optional"||o.type==="default"||o.type==="nullable"||o.type==="prefault");)o=C(o.innerType);return o?.type!=="enum"?[]:(o.entries?Object.values(o.entries):o.values??[]).filter(s=>typeof s=="string")}function ah(n){let e=[],t=[],r=[],o=new Set(n.schema.kinds),i=new Set;for(let d of o)for(let u of Object.keys(n.schema.tryDefinition(d)?.edges??{}))i.add(u);let s=d=>Object.keys(n.schema.tryDefinition(d)?.fields.shape??{}),a=new Map;return(n.lenses??[]).forEach((d,u)=>{let c=`lenses.${u}`,p=typeof d.title=="string"&&d.title.trim().length>0?d.title.trim():void 0,l=(y,b)=>{t.push({index:u,name:d.name,...p?{title:p}:{},why:y}),b&&r.push({severity:"warning",...b})};if(!tl(d.name)){p?l(`"${d.name}" is not a lens this framework draws`,{code:"lens-not-shipped",path:`${c}.name`,message:`"${p}" names the lens "${d.name}", which the framework does not ship, so nothing draws it.`,fix:`Name one of ${nl.join(", ")} \u2014 or register the view yourself and drop the title.`}):l("it is a lens this app wrote, drawn by the app's own views");return}if(!p)return l("it has no title, so it is bindings the checker holds and no place");let f=Ft[d.name],g=Jn(d.options)?d.options:{};if(d.options!==void 0&&!Jn(d.options))return l("its options are not an object",{code:"lens-options-not-an-object",path:`${c}.options`,message:`"${p}" has options that are not an object.`,fix:'Write them as { "<option>": <value> }, or drop them.'});for(let y of Object.keys(g))f.options.includes(y)||r.push({severity:"warning",code:"lens-option-unknown",path:`${c}.options.${y}`,...ih(d.name,y,p,f.options)});let h={};for(let y of f.options)g[y]!==void 0&&(h[y]=g[y]);d.arrangedBy&&(h.arrangedBy=Xc(d.arrangedBy));let v=Jn(d.bindings)?d.bindings:{},m=[],k,$=(y,b,R)=>l(b,{code:"lens-cannot-draw",path:y,message:`"${p}" cannot draw: ${b}.`,fix:R});if(f.binds==="fields"){let y=Object.keys(v).filter(R=>Jn(v[R])),b=y.filter(R=>!o.has(R));if(y.length===0)return $(`${c}.bindings`,"it binds no kind",`Bind a kind's fields: "bindings": { "<kind>": { ${f.requiredRoles.map(R=>`"${R}": "<field>"`).join(", ")} } }.`);if(b.length>0)return;if(h.bindings=v,m=y,d.name==="timeline"){for(let S of y){let x=v[S];for(let _ of rh){let M=x[_];if(!(typeof M!="string"||!s(S).includes(M))&&!sh(n.schema,S,M))return $(`${c}.bindings.${S}.${_}`,`its ${_} "${M}" is not a number, and a timeline's axis is`,Qc(S,String(x.start??"start"),String(x.end??"end")))}}let R=g.columns;if(Array.isArray(R))h.columns=R.map(S=>typeof S=="string"?{id:S,label:S}:S);else{let S=y.flatMap(_=>{let M=v[_],E=typeof M.column=="string"?M.column:typeof M.columns=="string"?M.columns:void 0;return E?el(n.schema,_,E):[]}),x=[...new Set(S)];if(x.length===0)return $(`${c}.options.columns`,"it has no columns \u2014 no option names them and no `column` role is bound to a field of set values",Qc(y[0]));h.columns=x.map(_=>({id:_,label:_.toUpperCase()}))}h.extent===void 0&&(h.extent=1440)}if(d.name==="columns"){if(h.sort!==void 0){let S=y.map(x=>jr(h.sort,s(x),x)).find(Boolean);S&&(r.push({severity:"warning",code:"lens-sort",path:`${c}.options.sort`,message:`"${p}" cannot order its cards: ${S}.`,fix:'Write { "by": "<a field>", "direction": "asc" }, or drop it.'}),delete h.sort)}let R=new Set;for(let S of y){let x=v[S].column;if(typeof x!="string"||!s(S).includes(x))return;let _=el(n.schema,S,x);if(_.length===0)return $(`${c}.bindings.${S}.column`,`its column field "${x}" is not a choice`,`Bind "column" to a choice field of ${S}, like a status.`);for(let M of _)R.add(M)}typeof h.move!="boolean"&&delete h.move,Number.isInteger(h.cap)&&h.cap>=1&&h.cap<=500||delete h.cap;for(let S of["collapsed","hidden"])Ui(h,S,x=>R.has(x))}if(d.name==="calendar"&&h.today!==void 0&&!(typeof h.today=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(h.today)))return $(`${c}.options.today`,"its today is not a date",'Write it as "YYYY-MM-DD", or leave it out and the calendar opens on the day it is drawn.');if(d.name==="calendar"&&h.horizon!==void 0){let R=h.horizon,S=M=>M===void 0||Number.isInteger(M)&&M>=1&&M<=9999,x=typeof R=="number"?{years:R,title:"Years"}:R;Jn(x)&&Number.isInteger(x.years)&&x.years>=1&&x.years<=200&&typeof x.title=="string"&&x.title.trim().length>0&&S(x.from)&&S(x.to)&&Object.keys(x).every(M=>["years","title","from","to"].includes(M))&&!(typeof x.from=="number"&&typeof x.to=="number"&&x.to<x.from)?h.horizon=x:(delete h.horizon,r.push({severity:"warning",code:"lens-horizon",path:`${c}.options.horizon`,message:`"${p}" has a horizon that is not a span of years, so it offers no span of years.`,fix:'Write { "years": 30, "title": "The career" } \u2014 "from" and "to" (years, like 1962 and 2023) only to pin its ends, which otherwise reach the first and last of its records.'}))}if(d.name==="calendar"&&h.range!==void 0&&!["day","week","month","quarter","year","years","agenda"].includes(h.range))return $(`${c}.options.range`,`its range "${String(h.range)}" is not one a calendar opens at`,"Use one of: day, week, month, quarter, year, agenda.")}else if(f.binds==="entities"){let y=S=>{let x=v[S];if(Jn(x)){if(typeof x.kind=="string")return x.kind;if(typeof x.edge=="string")return x.edge;if(Array.isArray(x.path))return{path:x.path};if(typeof x.field=="string")return x.field}};for(let S of f.requiredRoles)if(y(S)===void 0)return;let b=d.name==="coverage"?"rows":d.name==="board"?"slots":"regions",R=y(b);if(!o.has(R))return;if(d.name==="coverage"){let S=y("columns");if(!o.has(S))return;let x=y("link");if(typeof x=="string"&&!i.has(x))return;Object.assign(h,{rows:R,columns:S,link:x}),S!==R&&(k=S);for(let[_,M]of[["sort",R],["columnSort",S]]){if(h[_]===void 0)continue;let E=jr(h[_],s(M),M);E&&(r.push({severity:"warning",code:"lens-sort",path:`${c}.options.${_}`,message:`"${p}" cannot order its ${_==="sort"?"rows":"columns"}: ${E}.`,fix:`Write { "by": "<a field of ${M}>", "direction": "asc" }, or drop it.`}),delete h[_])}}else if(d.name==="board"){Object.assign(h,{slots:R,x:y("x"),y:y("y"),fill:y("fill")});for(let S of["x","y"])if(!s(R).includes(h[S]))return}else{Object.assign(h,{regions:R,outline:y("outline")});for(let S of["markers","at","within","nests","regionKind","markerKind"]){let x=y(S);typeof x=="string"&&(h[S]=x)}}m=[R]}else if(d.name==="blocks"){if(!d.on)return $(`${c}.on`,"it does not say which kind it stands on",'Say "on": "<the kind it is a place of>".');if(!Array.isArray(h.blocks)||h.blocks.length===0)return $(`${c}.options.blocks`,"it has no blocks to draw",`Say "options": { "blocks": [{ "headline": "\u2026" }, { "list": "all('<kind>')", "as": "card" }] }.`)}else{let y=["user","person","member"].find(b=>o.has(b));if(!d.on&&!y)return $(`${c}.on`,"it does not say which kind it stands on",'Say "on": "<the kind whose records are the people>".');m=y?[y]:[]}if(d.on!==void 0){if(typeof d.on!="string"||!o.has(d.on))return $(`${c}.on`,`it stands on "${String(d.on)}", which is not a kind`,`Use one of: ${[...o].join(", ")}.`);if(m=[d.on],d.name==="coverage"){let y=[h.rows,h.columns].find(b=>b!==d.on);k=typeof y=="string"?y:void 0}}let w=typeof h.rows=="string"?h.rows:m[0];if(w!==void 0){let y=["label",...s(w)],b=new Set(["is",...y,...Object.keys(n.schema.tryDefinition(w)?.edges??{})]);Ui(h,"search",R=>y.includes(R)),Ui(h,"filters",R=>b.has(R.split(".")[0]))}let O=Te(p);if(O.length===0)return $(`${c}.title`,"its title has no letters or digits to make an address of","Give it a title a person would say.");for(let y of m){let b=`${y}|${O}`;if(a.has(b))return l(`another lens on ${y} is already called "${p}"`,{code:"lens-title-taken",path:`${c}.title`,message:`"${p}" is the title of lenses.${a.get(b)} too, on the same kind, so one address would name two pictures.`,fix:"Give each its own title."})}for(let y of m)a.set(`${y}|${O}`,u);let A=d.create;A!==void 0&&typeof A!="boolean"&&r.push({severity:"warning",code:"lens-create",path:`${c}.create`,message:`"${p}" says create ${JSON.stringify(A)}, which is neither true nor false, so its page keeps the forms that begin its kind.`,fix:'Say "create": false to leave them off, or drop it.'}),e.push({index:u,lens:d.name,title:p,as:O,kinds:m,...k?{across:k}:{},options:h,...d.hidden===!0?{hidden:!0}:{},...A===!1?{create:!1}:{}})}),{drawn:e,undrawn:t,findings:r}}var dh=6;function ch(n,e,t=[]){let r=n.kinds,o=s=>Object.values(n.tryDefinition(s)?.edges??{}).map(a=>(a.to==="*"?r:a.to).filter(d=>d!==s)),i=new Set(r.flatMap(s=>o(s).flat()));return new Set([...e?.hide??[],...t,...r.filter(s=>!i.has(s)&&o(s).length>0&&o(s).every(a=>a.length>=2))])}function lh(n,e,t){if(!n?.primary)return;let r=new Set(n.primary.map(Te));return{kinds:new Set(e.kinds.filter(o=>r.has(Te(o))||r.has(Dt(e,o).slice(1)))),places:new Set(t.filter(o=>r.has(o.as)||r.has(Te(o.title))||o.name!==void 0&&n.primary.includes(jt+o.name)).map(o=>`${o.kind}|${o.as}`))}}var uh="home",rl="overview",fh=`/places/${rl}`;function ph(n){let e=n?.scene?.trim();return e||"Scene"}function hh(n){let e=n?.pages?.trim();return e||"Pages"}function gh(n,e){if(!e||e.length===0)return n;let t=e.filter(r=>n.includes(r));return[...new Set(t),...n.filter(r=>!t.includes(r))]}function ol(n){return n.startsWith(jt)&&n.slice(jt.length).trim()||void 0}function mh(n,e,t){let r=[],o=new Set;for(let i of e??[]){let s=ol(i),a=s===void 0?void 0:t.find(d=>d.name===s&&n.includes(d.kind));a?r.some(d=>d.view===a)||r.push({kind:a.kind,view:a}):s===void 0&&n.includes(i)&&!o.has(i)&&(o.add(i),r.push({kind:i}))}for(let i of n)o.has(i)||r.push({kind:i});return r}function yh(n,e,t){if(n===void 0)return;let r=n.trim();if(r==="")return;if(r.toLowerCase()==="home"||r==="/")return{to:"home"};let o=Te(r),i=t.find(d=>d.title===r||jt+d.name===r)??t.find(d=>d.as===o);if(i)return{to:"place",place:i};let s=e.kinds,a=s.find(d=>d===r)??s.find(d=>Dt(e,d).slice(1)===o);return a?{to:"kind",kind:a}:void 0}function Wi(n){let e=(n??"").replace(/\/+$/,"");return e===""?"":e.startsWith("/")?e:`/${e}`}function bh(n,e={}){let t=typeof n=="string"?n:n.address,r=Wi(e.basePath),o=t.startsWith("/")?t:`/${t}`;return r===""?o:o==="/"?r:o.startsWith("/?")||o.startsWith("/#")?`${r}${o.slice(1)}`:`${r}${o}`}function vh(n,e){let t=Wi(e);if(t==="")return n.startsWith("/")?n:`/${n}`;if(!n.toLowerCase().startsWith(t.toLowerCase()))return null;let r=n.slice(t.length);return r===""||r==="/"?"/":r.startsWith("/")?r:null}var Dr=2500,wh=Dr*4;function kh(n){let e=n.name??"";return e&&n.onBehalfOfName?`${e}, for ${n.onBehalfOfName}`:e}function qi(n,e,t=Dr){return n.held==="socket"?!0:n.until!==void 0?e<Date.parse(n.until):e-Date.parse(n.at)<t}var M0=new Set(dr);function xh(n){return`${n.kind}:${n.id??""}:${n.session??""}`}function Sh(n,e,t,r=Dr,o){let i=new Map;for(let[s,a]of n)qi(a,t,r)&&i.set(s,a);for(let s of e){if(!qi(s,t,r)){i.delete(s.participant);continue}let a=i.get(s.participant);(!a||Date.parse(a.at)<=Date.parse(s.at))&&i.set(s.participant,s)}return o!==void 0&&i.delete(o),i}function Rh(n,e){return!n||!e?n===e:n.participant===e.participant&&n.kind===e.kind&&n.name===e.name&&n.onBehalfOf===e.onBehalfOf&&n.onBehalfOfName===e.onBehalfOfName&&n.until===e.until&&n.held===e.held&&n.hue===e.hue&&n.stop===e.stop&&(n.over??null)===(e.over??null)&&(n.robot?.at??null)===(e.robot?.at??null)&&(n.robot?.mode??null)===(e.robot?.mode??null)&&JSON.stringify(n.caret)===JSON.stringify(e.caret)}var il=Symbol.for("@graview/core:app-link"),$h=n=>(Object.defineProperty(C(n),il,{value:1,enumerable:!0}),n);function sl(n){let e=C(n);return!!e&&(e[il]===1||sl(e.innerType))}var T0=()=>$h(L().check(Eo(500),ut(nr,"another app's address")));var Fr=(n,e)=>`${e.kind}\0${e.id??""}\0${n.address}\0${n.kind}\0${n.id}`;function Ah(n,e,t=()=>{}){let r=new Map,o=new Map,i=s=>{let a=Fr(s,e),d=r.get(a);return d||(d=Promise.resolve().then(()=>n.resolve(s,e)).then(u=>Oh(u)?u:null,()=>null).then(u=>(r.get(a)===d&&(o.set(a,u),t(s)),u)),r.set(a,d)),d};return{read(s){let a=Fr(s,e);if(o.has(a)){let d=o.get(a);return d===null?{unread:!0}:"denied"in d?{denied:!0}:{record:d}}return i(s),{unread:!0}},ask:i,answered:s=>o.get(Fr(s,e)),forget(s){if(!s){r.clear(),o.clear();return}let a=Fr(s,e);r.delete(a),o.delete(a)}}}function Oh(n){if(n===null)return!0;if(typeof n!="object"||n===void 0)return!1;if(n.denied===!0)return!0;let e=n;return typeof e.label=="string"&&typeof e.id=="string"&&typeof e.kind=="string"&&typeof e.fields=="object"&&e.fields!==null}var _h=1;var Lr=(n,e)=>`${n}\0${e}`;function Yi(n){return n.op==="add-node"?Object.keys(n.node).filter(e=>e!=="id"&&e!=="kind").map(e=>[n.node.id,e]):n.op==="patch-node"?Object.keys(n.after).map(e=>[n.id,e]):n.op==="splice-text"?[[n.id,n.field]]:[]}var Hi=class n{revs=new Map;floor;constructor(e=0){this.floor=Math.max(0,Math.floor(e))-1}static of(e,t={}){let r=new n(t.horizon);return r.note(e),r}note(e){for(let t of e)for(let r of t.primitives)for(let[o,i]of Yi(r)){let s=Lr(o,i);(this.revs.get(s)??this.floor)<t.seq&&this.revs.set(s,t.seq)}}of(e,t){return this.revs.get(Lr(e,t))??this.floor}baseFor(e,t=new Set,r){let o=new Set,i=new Map;for(let s of e)for(let a of s.primitives)if(a.op==="add-node"&&o.add(a.node.id),!(a.op!=="patch-node"||o.has(a.id)||t.has(a.id)))for(let d of Object.keys(a.after)){let u=Lr(a.id,d);t.has(u)||i.has(u)||r?.(a.id,d)||i.set(u,{node:a.id,field:d,rev:this.of(a.id,d)})}return[...i.values()]}stale(e){return e.filter(t=>this.of(t.node,t.field)>t.rev)}};function Ph(n){let e=new Set;for(let t of n)for(let r of t.primitives){r.op==="add-node"&&e.add(r.node.id);for(let[o,i]of Yi(r))e.add(Lr(o,i))}return e}var Z0=Symbol.for("@graview/core:collaborative"),G0=n=>typeof n=="object"&&n!==null?n._zod?.def:void 0;var Eh=/^#([0-9a-f]{3,8})$/i,Mh=/(rgba?|hsla?)\(([^)]+)\)/gi;function Nh(n){let e=Eh.exec(n.trim());if(!e)return null;let t=e[1];if((t.length===3||t.length===4)&&(t=[...t].map(i=>i+i).join("")),t.length!==6&&t.length!==8)return null;let r=Number.parseInt(t.slice(0,6),16),o=t.length===8?Number.parseInt(t.slice(6,8),16)/255:1;return{r:r>>16&255,g:r>>8&255,b:r&255,a:o}}function zh(n){let e=n.slice(0,n.indexOf("(")).toLowerCase(),r=n.slice(n.indexOf("(")+1,n.lastIndexOf(")")).split(/[,\s/]+/).filter(Boolean).map(d=>d.endsWith("%")?Number.parseFloat(d)/100:Number.parseFloat(d));if(r.some(Number.isNaN))return null;if(e.startsWith("rgb")){let[d,u,c,p]=r;return d===void 0||u===void 0||c===void 0?null:{r:d,g:u,b:c,a:p??1}}let[o,i,s,a]=r;return o===void 0||i===void 0||s===void 0?null:{...al(o,i>1?i/100:i,s>1?s/100:s),a:a??1}}function wn(n){let e=n.r/255,t=n.g/255,r=n.b/255,o=Math.max(e,t,r),i=Math.min(e,t,r),s=(o+i)/2;if(o===i)return{h:0,s:0,l:s};let a=o-i,d=a/(1-Math.abs(2*s-1));return{h:((o===e?60*((t-r)/a%6):o===t?60*((r-e)/a+2):60*((e-t)/a+4))+360)%360,s:d,l:s}}function je(n,e,t){return{...al(n,e,t),a:1}}function al(n,e,t){let r=(1-Math.abs(2*t-1))*e,o=(n%360+360)%360/60,i=r*(1-Math.abs(o%2-1)),[s,a,d]=o<1?[r,i,0]:o<2?[i,r,0]:o<3?[0,r,i]:o<4?[0,i,r]:o<5?[i,0,r]:[r,0,i],u=t-r/2;return{r:Math.round((s+u)*255),g:Math.round((a+u)*255),b:Math.round((d+u)*255)}}function Y(n){let e=[];for(let t of n.matchAll(Mh)){let r=zh(t[0]);r&&e.push(r)}for(let t of n.matchAll(/#[0-9a-fA-F]{3,8}\b/g)){let r=Nh(t[0]);r&&e.push(r)}return e}function Ye(n,e){let t=n.a+e.a*(1-n.a);if(t===0)return{r:0,g:0,b:0,a:0};let r=(o,i)=>(o*n.a+i*e.a*(1-n.a))/t;return{r:r(n.r,e.r),g:r(n.g,e.g),b:r(n.b,e.b),a:t}}function Ji(n){let e=n/255;return e<=.03928?e/12.92:((e+.055)/1.055)**2.4}function Xi(n){return .2126*Ji(n.r)+.7152*Ji(n.g)+.0722*Ji(n.b)}function me(n,e){let[t,r]=[Xi(n),Xi(e)].sort((o,i)=>i-o);return(t+.05)/(r+.05)}function Cr(n){return me({r:255,g:255,b:255,a:1},n)>me({r:0,g:0,b:0,a:1},n)}var Zr=(n,e)=>`rgba(${Math.round(n.r)}, ${Math.round(n.g)}, ${Math.round(n.b)}, ${e})`,dl={r:0,g:0,b:0,a:1},Gr={r:255,g:255,b:255,a:1};function Kr(n){let e=Y(n.accent)[0];if(!e)return{ok:!1,missing:["accent"],why:`"${n.accent}" is not a color this can read. Use a hex, rgb() or hsl() value.`};let t={},r=new Set,o=[],i=wn(e);for(let s of["dark","light"]){let a=n.base[s],d=Y(a.ground)[0]??(s==="dark"?dl:Gr),u=Ye(Y(a.panel)[0]??Gr,d),c=Dh(i,[u,d],s,4.5);c?Math.abs(c.l-i.l)>jh&&(r.add(`accent (${s})`),o.push(`reaching 4.5:1 on the ${s} panel would move the accent's lightness by ${Math.round(Math.abs(c.l-i.l)*100)} points, which is far enough that it stops being the same color \u2014 supply one for ${s}`)):(r.add(`accent (${s})`),o.push(`no lightness of this hue clears 4.5:1 as text on the ${s} panel, so ${s} needs an accent of its own`));let p=c??i,l=je(p.h,p.s,p.l),f=n.accentInk?.[s]??(me(Gr,l)>=me(dl,l)?"#ffffff":"#000000"),g=me(Y(f)[0]??Gr,l);g+.005<4.5&&(r.add(`accentInk (${s})`),o.push(`neither black nor white clears 4.5:1 on the accent (best ${g.toFixed(2)}:1), so text on a filled button has to be given`)),t[s]={...a,accent:Zr(l,1),accentDim:Zr(l,s==="dark"?.35:.22),accentInk:f,glow:Zr(l,s==="dark"?.28:.1),edgeBright:Zr(l,Qi(l,u,s==="dark"?.55:.42,3)),...n.warn?.[s]?{warn:n.warn[s]}:{}};let h=Y(t[s].warn)[0];h&&Th(wn(h).h,p.h)<25&&(r.add(`warn (${s})`),o.push(`the warning color shares the accent's hue in ${s}, so "something is broken" looks like "this is selected"`))}return r.size>0?{ok:!1,missing:[...r].sort(),why:o.join("; ")}:{ok:!0,schemes:t}}function Qi(n,e,t,r){for(let o=Math.round(t*100);o<=100;o++){let i=o/100;if(me(Ye({...n,a:i},e),e)>=r)return i}return 1}function Th(n,e){let t=Math.abs(n-e)%360;return t>180?360-t:t}var jh=.3;function Dh(n,e,t,r){let o=t==="dark";for(let i=0;i<=100;i++){let s=o?n.l+i/100:n.l-i/100,a=o?n.l-i/100:n.l+i/100;for(let d of[s,a])if(!(d<0||d>1)&&e.every(u=>me(je(n.h,n.s,d),u)>=r))return{...n,l:d}}return null}function Fh(n,e){let t=e?.[n];if(t!==void 0)return(t%360+360)%360;let r=2166136261;for(let o=0;o<n.length;o++)r^=n.charCodeAt(o),r=Math.imul(r,16777619);return(r>>>0)%360}var kn=Object.freeze({navy:"#001769",turquoise:"#00e5b9",paper:"#f7f7f2",ink:"#18213a",muted:"#586174"}),es="Montserrat",ns=Object.freeze({display:550,body:450,label:600}),ts=Object.freeze({display:600,body:400,label:600}),Lh="-0.025em",Ch=Object.freeze({minWidth:140,clearSpace:.5,microMax:24,regularMin:32,microBelow:28});var cl={ground:"#0a0f1f",groundDeep:"#060914",wash:"none",panel:"rgba(19, 27, 52, 0.96)",panelMuted:"rgba(14, 21, 42, 0.94)",panelWarning:"rgba(48, 33, 18, 0.95)",edge:"rgba(164, 178, 222, 0.18)",edgeBright:"rgba(154, 171, 255, 0.6)",ink:"#eef0f6",inkMuted:"#aab2c6",inkFaint:"#97a0b6",accent:"#9aabff",accentDim:"rgba(154, 171, 255, 0.32)",accentInk:kn.navy,warn:"#f0a868",good:"#8fdcaa",bad:"#ffa3a3",glow:"rgba(154, 171, 255, 0.18)",bar:"rgba(10, 15, 31, 0.96)",float:"rgba(16, 23, 45, 0.98)",liftLow:"0 14px 36px -22px #000",liftHigh:"0 28px 64px -30px #000",tintAlpha:.2,tintLightness:52,gridAlpha:.35},ll={ground:kn.paper,groundDeep:"#efefe8",wash:"none",panel:"#ffffff",panelMuted:"#fafaf6",panelWarning:"#fdf4ea",edge:"rgba(24, 33, 58, 0.12)",edgeBright:"rgba(0, 23, 105, 0.6)",ink:kn.ink,inkMuted:kn.muted,inkFaint:"#626b7d",accent:kn.navy,accentDim:"rgba(0, 23, 105, 0.16)",accentInk:"#ffffff",warn:"#9a5312",good:"#1b6436",bad:"#a1232d",glow:"rgba(0, 23, 105, 0.08)",bar:"rgba(255, 255, 255, 0.96)",float:"#ffffff",liftLow:"0 1px 2px rgba(24,33,58,0.06), 0 8px 24px -12px rgba(24,33,58,0.16)",liftHigh:"0 2px 6px rgba(24,33,58,0.08), 0 24px 56px -24px rgba(24,33,58,0.26)",tintAlpha:.16,tintLightness:46,gridAlpha:.5},Je={dark:cl,light:ll};var Xe=Object.freeze({radius:8,density:1,radiusSmall:.72,radiusSmallFloor:2,pad:15,padSmall:10,gap:7}),xn=Object.freeze({body:`"${es}", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif`,mono:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'});function Zh(n){let e=n?.shape?.radius??Xe.radius,t=n?.shape?.density??Xe.density;return Object.freeze({radius:e,radiusSmall:Math.max(Xe.radiusSmallFloor,Math.round(e*Xe.radiusSmall)),pad:Math.round(Xe.pad*t),padSmall:Math.round(Xe.padSmall*t),gap:Math.round(Xe.gap*t)})}function Gh(n){let e=n?.typography?.body??xn.body,t=n?.typography?.display??e,o=e===xn.body&&t===xn.body?ns:ts,i=n?.typography?.weights;return Object.freeze({body:e,display:t,mono:n?.typography?.mono??xn.mono,weights:Object.freeze({display:i?.display??o.display,body:i?.body??o.body,label:i?.label??o.label})})}var J0=Object.freeze({light:Object.freeze({roof:Object.freeze({saturation:48,lightness:82}),right:Object.freeze({saturation:40,lightness:66}),left:Object.freeze({saturation:34,lightness:55}),roofEdge:"rgba(255,255,255,0.75)",plot:Object.freeze({saturation:45,lightness:58,alpha:.12}),plotEdge:Object.freeze({saturation:40,lightness:48,alpha:.55})}),dark:Object.freeze({roof:Object.freeze({saturation:42,lightness:32}),right:Object.freeze({saturation:40,lightness:21}),left:Object.freeze({saturation:38,lightness:13}),roofEdge:"rgba(255,255,255,0.14)",plot:Object.freeze({saturation:45,lightness:48,alpha:.2}),plotEdge:Object.freeze({saturation:40,lightness:62,alpha:.55})})});var Kh=64*1024;function fl(n){return/^\s*(<\?xml[^>]*>\s*)?(<!--[\s\S]*?-->\s*)*(<!DOCTYPE svg[^>]*>\s*)?<svg[\s>/]/i.test(n)}var pl="http://www.w3.org/2000/svg",Vh=["http://www.w3.org/1999/xhtml","http://www.w3.org/1998/Math/MathML",pl],Bh=new Set("svg g defs symbol use title desc path rect circle ellipse line polyline polygon text tspan textPath linearGradient radialGradient stop pattern clipPath mask marker image filter feBlend feColorMatrix feComponentTransfer feComposite feDropShadow feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feMerge feMergeNode feMorphology feOffset feTile feTurbulence".split(" ")),Uh=new Set(["title","desc"]),Lt="it embeds a page or media",Wh={script:"it has a script in it",foreignobject:"it embeds HTML (foreignObject)",iframe:Lt,embed:Lt,object:Lt,audio:Lt,video:Lt,style:"it has a style sheet in it; a mark is styled by its attributes",a:"it links to something (an <a> element)"},qh={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};function Hh(n){let e=!1,t=n.replace(/&(#x[0-9a-f]+|#[0-9]+|[a-z][a-z0-9]*);?/gi,(r,o)=>{if(o[0]==="#"){let s=o[1]==="x"||o[1]==="X"?parseInt(o.slice(2),16):parseInt(o.slice(1),10);return s>0&&s<=1114111?String.fromCodePoint(s):"\uFFFD"}let i=qh[o.toLowerCase()];return i===void 0&&(e=!0),i??""});return e?null:t}function Yh(n){if(/\\|@|expression\s*\(|(?:image-set|cross-fade|image|element|src)\s*\(/i.test(n))return!1;for(let[,e]of n.matchAll(/url\s*\(\s*["']?\s*([^)]*)/gi))if(!e.startsWith("#"))return!1;return!0}function Jh(n,e,t){let r=Hh(t);if(r===null)return"it declares XML entities";let o=(e.includes(":")?e.slice(e.indexOf(":")+1):e).toLowerCase();if(o.startsWith("on"))return"it has an event handler (an on\u2026 attribute)";if(e==="xml:base")return"it loads or links to something outside itself";if(e==="xmlns")return r===pl?null:"it changes what its elements are (another xmlns)";if(e.startsWith("xmlns:"))return Vh.includes(r)?"it changes what its elements are (another xmlns)":null;if(o==="href"||o==="src"){let i=r.replace(/[\u0000- ]+/g,"");return i.startsWith("#")||n==="image"&&/^data:image\/(png|jpe?g|gif|webp|avif);/i.test(i)?null:"it loads or links to something outside itself"}return Yh(r)?null:o==="style"?"its style loads something outside itself":"it loads or links to something outside itself"}var ul=/^\s+([A-Za-z_][A-Za-z0-9_.:-]*)\s*=\s*(?:"([^"<]*)"|'([^'<]*)')/;function hl(n){if(/<!ENTITY/i.test(n))return"it declares XML entities";if(/<!\[CDATA\[/i.test(n))return"it has a CDATA section, which the page and the picture read differently";let e=[],t=!1,r=/^\s*(<\?xml\s[^?<>]*\?>)?/.exec(n)[0].length;for(;r<n.length;){let o=n.slice(r),i=/^[^<]+/.exec(o);if(i){if(e.length===0&&i[0].trim()!=="")return"it is not one SVG: there is text outside it";r+=i[0].length;continue}if(o.startsWith("<!--")){let f=o.indexOf("-->",4);if(f<0)return"it has a comment that never ends";let g=o.slice(4,f);if(/^-?>/.test(g)||g.includes("--")||g.includes("<!")||g.endsWith("-"))return"it has a comment the page and the picture read differently";r+=f+3;continue}if(/^<!DOCTYPE/i.test(o)){let f=/^<!DOCTYPE\s+svg\b[^<>[\]]*>/i.exec(o);if(!f||e.length>0||t)return"it declares XML entities";r+=f[0].length;continue}let s=/^<\/([A-Za-z][A-Za-z0-9_.:-]*)\s*>/.exec(o);if(s){if(e.pop()!==s[1])return`it is not one SVG: </${s[1]}> closes what is not open`;e.length===0&&(t=!0),r+=s[0].length;continue}let a=/^<([A-Za-z][A-Za-z0-9_.:-]*)/.exec(o);if(!a)return"it is not one SVG: it has markup a picture cannot hold";let d=a[1],u=Wh[d.toLowerCase()];if(u)return u;if(t)return`it is not one SVG: <${d}> comes after it ends`;if(e.length===0&&d!=="svg")return"it is not one SVG";if(d.includes(":"))return`it has an element of another kind (<${d}>)`;if(!Bh.has(d))return`it has a <${d}> element, which a picture does not need`;let c=e[e.length-1];if(c&&Uh.has(c))return`it has an element inside a <${c}>, which the page reads as HTML`;let p=a[0].length;for(let f=ul.exec(o.slice(p));f;f=ul.exec(o.slice(p))){let g=Jh(d,f[1],f[2]??f[3]??"");if(g)return g;p+=f[0].length}let l=/^\s*(\/?)>/.exec(o.slice(p));if(!l)return/(?:^|[\s/"'])on[a-z]+\s*=/i.test(o.slice(p,p+400))?"it has an event handler (an on\u2026 attribute)":`it is not one SVG: <${d}>'s attributes are not each quoted and apart`;l[1]!=="/"?e.push(d):e.length===0&&(t=!0),r+=p+l[0].length}return e.length>0?`it is not one SVG: <${e[e.length-1]}> is never closed`:t?null:"it is not one SVG"}function gl(n){if(n){if(!fl(n)){if(/^\s*</.test(n))return;let e=/^\s*([a-z][a-z0-9+.-]*):/i.exec(n)?.[1]?.toLowerCase();return e===void 0||e==="http"||e==="https"||e==="data"&&/^\s*data:image\//i.test(n)?n:void 0}return hl(n)===null?`data:image/svg+xml,${encodeURIComponent(n.trim())}`:void 0}}var Vr;function Xh(){if(Vr===void 0)try{Vr=new RegExp("^\\p{RGI_Emoji}$","v")}catch{Vr=null}return Vr}function Qh(n){return/\p{Extended_Pictographic}|\p{Regional_Indicator}|⃣/u.test(n)}function rs(n){if(typeof n!="string"||n.trim()==="")return"it is empty; give one emoji, like \u{1F3E1}";let e=[...new Intl.Segmenter("en",{granularity:"grapheme"}).segment(n)].map(o=>o.segment),t=e.filter(Qh).length;if(t===0)return"it is not an emoji; give one emoji, like \u{1F3E1}";if(e.length>1)return t===e.length?`it is ${e.length} emoji, and a mark is one`:"it has other characters beside the emoji; give the emoji alone";let r=Xh();return r&&!r.test(n)?"it is not one of the standard emoji every emoji set draws":null}function os(n){return typeof n=="object"&&n!==null&&typeof n.emoji=="string"?n.emoji:void 0}function ml(n){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text x="50" y="50" dy=".35em" font-size="88" text-anchor="middle">${n}</text></svg>`}function eg(n){let e=n?.favicon;if(typeof e=="object"&&e!==null){let t=os(e);return t!==void 0&&rs(t)===null?`data:image/svg+xml,${encodeURIComponent(ml(t))}`:void 0}return gl(e)}function ng(n){let e=n?.logo;return typeof e=="string"?e===""?void 0:{light:e}:e&&typeof e.light=="string"&&e.light!==""?e:void 0}function tg(n,e){if(e==="dark")return"dark";let t=n?.schemes?.light?.ground,r=t?Y(t)[0]:void 0;return r&&Cr(r)?"dark":"light"}function rg(n){if(n?.logo)return;let e=os(n?.favicon);return e!==void 0&&rs(e)===null?e:void 0}var yl="/graview/assets/";function og(n,e){return n&&e!==void 0&&e.startsWith(yl)?n(e):e}var bl={"system-sans":'ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',"system-serif":'ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, Cambria, "Times New Roman", serif',"system-mono":xn.mono},ig=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","-apple-system","BlinkMacSystemFont"],vl=["Georgia","Times New Roman","Times","Iowan Old Style","Palatino","Palatino Linotype","Charter","Cambria","Baskerville","Optima","Helvetica","Helvetica Neue","Arial","Verdana","Segoe UI","Roboto","Avenir","Avenir Next","Gill Sans","Menlo","Monaco","Consolas","SF Mono","SFMono-Regular","Courier New"];var sg=n=>new Set(n.map(e=>e.toLowerCase()));function ag(n){return sg([...ig,...vl]).has(n.toLowerCase())||n.toLowerCase().startsWith("ui-")}function dg(n){return bl[n]??n}function tR(n){if(/url\(|@import|[;{}<>\\]|\/\*|[\u0000-\u001f\u007f]/i.test(n))return"it is not a list of font names; a document names a face, never where one comes from";for(let e of n.split(",")){let t=e.trim();if(/^(?:"\s|'\s)|\s["']$|\s\s/.test(t))return`${t} has whitespace in its name other than single spaces between words`;if(!(/^"[^"']*"$/.test(t)||/^'[^"']*'$/.test(t))&&/["']/.test(t))return`${t} is not quoted in one pair; write a face as Georgia or "Times New Roman"`}return null}var wl={r:255,g:255,b:255,a:1},cg={r:0,g:0,b:0,a:1},Xn=n=>`#${[n.r,n.g,n.b].map(e=>Math.round(Math.max(0,Math.min(255,e))).toString(16).padStart(2,"0")).join("")}`,Qe=(n,e)=>`rgba(${Math.round(n.r)}, ${Math.round(n.g)}, ${Math.round(n.b)}, ${e})`,is=(n,e,t)=>({r:n.r+(e.r-n.r)*t,g:n.g+(e.g-n.g)*t,b:n.b+(e.b-n.b)*t,a:1});function lg(n){return typeof n=="string"?{light:n}:{...n.light?{light:n.light}:{},...n.dark?{dark:n.dark}:{}}}function ug(n){let e=Y(n)[0];if(!e)return;let{h:t,s:r}=wn(e);return Xn(je(t,Math.min(r,.45),.08))}function xl(n,e){let t=Y(n.edgeBright)[0];return Qe(t,Qi({...t,a:1},e,t.a,3))}function fg(n,e,t){let{h:r,s:o}=wn(t),i=is(t,wl,.8);return{...n,ground:e,groundDeep:Xn(is(t,cg,.04)),panel:Xn(i),panelMuted:Xn(is(t,wl,.55)),edge:Qe(je(r,Math.min(o,.5),.14),.14),edgeBright:xl(n,i),bar:Qe(i,.96),float:Xn(i)}}function kl(n,e,t){let{h:r,s:o,l:i}=wn(t),s=a=>je(r,o,Math.min(1,i+a));return{...n,ground:e,groundDeep:Xn(je(r,o,i*.6)),panel:Qe(s(.07),.96),panelMuted:Qe(s(.035),.94),edge:Qe(je(r,Math.min(o,.45),.75),.18),edgeBright:xl(n,Ye({...s(.07),a:.96},t)),bar:Qe(t,.96),float:Qe(s(.05),.98)}}function Sl(n){if(n===void 0)return Je;let e=lg(n),t=e.dark??(e.light?ug(e.light):void 0),r=e.light?Y(e.light)[0]:void 0,o=t?Y(t)[0]:void 0;return{light:r?Cr(r)?kl(Je.dark,e.light,r):fg(Je.light,e.light,r):Je.light,dark:o?kl(Je.dark,t,o):Je.dark}}var pg=[["ink","ink",["ground","panel","panelMuted","panelWarning","float","bar"],4.5],["inkMuted","muted ink",["ground","panel","panelMuted","float","bar"],4.5],["inkFaint","faint ink",["panel","panelMuted","float"],4.5],["accent","the accent",["ground","panel","float"],4.5],["warn","the warning color",["panel","panelWarning","float"],4.5],["good","the good status",["ground","panel"],4.5],["bad","the bad status",["ground","panel"],4.5],["edgeBright","the lit edge",["panel"],3]],hg={panel:"a card",panelMuted:"a receded card",panelWarning:"a flagged card",float:"a floating sheet",bar:"the bar"};function aR(n,e){for(let t of["light","dark"]){let r={...n[t],...t==="light"&&e?{accent:e}:{}},o=Y(r.ground)[0];for(let[i,s,a,d]of pg)for(let u of a){let c=u==="ground"?[o]:Y(String(r[u])).map(p=>Ye(p,o));for(let p of c){let l=Ye(Y(String(r[i]))[0],p),f=me(l,p);if(f<d)return{scheme:t,what:s,text:l,ground:o,...u==="ground"?{}:{card:p,surface:hg[u]},ratio:f,requires:d}}}}return null}function uR(n,e){let t=Sl(e),r=Kr({accent:n,base:t});return r.ok||!r.missing.every(o=>o.startsWith("warn"))?r:Kr({accent:n,base:t,warn:{light:t.light.bad,dark:t.dark.bad}})}function gg(n,e,t){if(t.rows===0)return;let r=ue(n,e.rows).toLowerCase(),o=ue(n,e.columns).toLowerCase(),i=e.rows===e.columns,s=i?`link ${r} to each other`:`link ${r} to ${o}`;if(t.columns===0)return`No ${o} yet: ${s}.`;if(t.cells>0||typeof e.link=="object"&&e.link!==null)return;let a=X(n.tryDefinition(e.rows),e.rows);return i?`No ${a} is linked to another yet: ${s}.`:`No ${a} is linked to ${En(X(n.tryDefinition(e.columns),e.columns))} yet: ${s}.`}var $e={connectors:{all:{route:"curve",visible:!0},byEdge:{}},captions:{visible:!0},grid:{visible:!0,size:64},lattice:{visible:!0,size:46},tags:{visible:!0},emphasis:{rest:.34,dim:.12},marks:{flag:"\u26A0"}};function mg(n){return n?{connectors:{all:{...$e.connectors.all,...n.connectors?.all??{}},byEdge:{...$e.connectors.byEdge,...n.connectors?.byEdge??{}}},captions:{...$e.captions,...n.captions??{}},grid:{...$e.grid,...n.grid??{}},lattice:{...$e.lattice,...n.lattice??{}},tags:{...$e.tags,...n.tags??{}},emphasis:{...$e.emphasis,...n.emphasis??{}},marks:{...$e.marks,...n.marks??{}}}:$e}function yg(n,e){return{...n.connectors.all,...n.connectors.byEdge[e]??{}}}function bg(n){return[` --graview-kit-grid: ${n.grid.visible?1:0};`,` --graview-kit-grid-size: ${n.grid.size}px;`,` --graview-kit-lattice: ${n.lattice.visible?1:0};`,` --graview-kit-lattice-size: ${n.lattice.size}px;`,` --graview-kit-tags: ${n.tags.visible?"inline-flex":"none"};`,` --graview-kit-captions: ${n.captions.visible?"block":"none"};`,` --graview-kit-rest: ${n.emphasis.rest};`,` --graview-kit-dim: ${n.emphasis.dim};`,` --graview-kit-flag: "${n.marks.flag.replace(/"/g,"'")}";`].join(`
5
+ `)}var Rl=n=>n?.kind==="visitor"||n?.onBehalfOf?.kind==="visitor",Br=new WeakMap;function vg(n,e){e?Br.set(n,e):Br.delete(n)}function wg(n,e,t){if(!n||Rl(t))return;let r=Br.get(n)??Br.get(Ct(n)?.store??{});if(r)try{r(e,t)}catch{}}function kg(n,e,t){let r=new Set([e]);for(let[o,i]of t.entries()){let s=n.edge(i);if(!s)return{ok:!1,at:o};let a=s.from,d=s.to==="*"?n.kinds:s.to,u=new Set;for(let c of r){if(a.includes(c))for(let p of d)u.add(p);if(s.to==="*"||d.includes(c))for(let p of a)u.add(p)}if(u.size===0)return{ok:!1,at:o};r=u}return{ok:!0,reached:r}}var $l="graview:fresh";function xg(n,e){let t=new URL(n),r="1";try{let o=Array.from(crypto.getRandomValues(new Uint8Array(16)),i=>i.toString(16).padStart(2,"0")).join("");(e??globalThis.sessionStorage).setItem($l,o),r=o}catch{}return t.searchParams.set("fresh",r),t.toString()}function Sg(n){let e=Ct(n)?.store??n;return n.log.all().some(t=>(t.suggests!==void 0||t.lineage?.stopsKind===!0||t.lineage?.liftedStop===!0)&&!t.withheld)||(e.stopsServed?.stops.length??0)>0||(e.stopsServed?.kinds.length??0)>0?!0:Object.values(e.log.horizonEpoch()?.declines??{}).some(t=>t.stop!==void 0)}export{zn as a,Da as b,Fa as c,Ru as d,Eo as e,lt as f,ut as g,L as h,Lb as i,Cb as j,ln as k,Zb as l,Gb as m,Ua as n,ft as o,Wa as p,se as q,In as r,Kb as s,Ha as t,Vb as u,Ya as v,pt as w,W as x,Bb as y,Qt as z,Ub as A,Wb as B,C,Ku as D,Zt as E,it as F,Yr as G,Jr as H,Ol as I,Gt as J,Rg as K,te as L,Kt as M,_l as N,Pl as O,ss as P,$g as Q,Vt as R,El as S,Le as T,Xr as U,as as V,Qr as W,zl as X,Il as Y,_e as Z,Tl as _,jl as $,ls as aa,Dl as ba,Fl as ca,an as da,no as ea,us as fa,fs as ga,B as ha,dn as ia,Pg as ja,Cl as ka,to as la,V as ma,Zl as na,Gl as oa,ue as pa,Kl as qa,Vl as ra,gs as sa,Ut as ta,En as ua,X as va,Vu as wa,er as xa,zo as ya,Ja as za,Xa as Aa,Qa as Ba,Bu as Ca,ht as Da,nd as Ea,qv as Fa,tr as Ga,sl as Ha,T0 as Ia,Yu as Ja,Xu as Ka,od as La,Qu as Ma,Xv as Na,gt as Oa,ef as Pa,tf as Qa,Qv as Ra,ew as Sa,rf as Ta,sd as Ua,Ah as Va,rr as Wa,of as Xa,jn as Ya,yt as Za,or as _a,rw as $a,Dn as ab,Tn as bb,pd as cb,df as db,Zo as eb,z as fb,pe as gb,we as hb,sr as ib,D as jb,be as kb,ve as lb,Fo as mb,Lo as nb,Co as ob,Fn as pb,ke as qb,xe as rb,pw as sb,Go as tb,cr as ub,ff as vb,Ln as wb,he as xb,F as yb,Cn as zb,N as Ab,q as Bb,H as Cb,mf as Db,pr as Eb,jw as Fb,yf as Gb,bf as Hb,_h as Ib,hr as Jb,ae as Kb,Yw as Lb,wt as Mb,Qo as Nb,Gw as Ob,kd as Pb,vf as Qb,de as Rb,Ad as Sb,Gn as Tb,Z as Ub,Kn as Vb,Ve as Wb,ne as Xb,$f as Yb,Se as Zb,mn as _b,Ot as $b,Vd as ac,Bd as bc,ce as cc,dp as dc,ki as ec,vc as fc,yn as gc,Si as hc,vx as ic,$i as jc,Sc as kc,Rc as lc,Ai as mc,Ue as nc,_t as oc,Pt as pc,yp as qc,$c as rc,bk as sc,vk as tc,wk as uc,kk as vc,vp as wc,xp as xc,Pi as yc,Ei as zc,Mi as Ac,zt as Bc,Nc as Cc,Pr as Dc,Op as Ec,Er as Fc,$t as Gc,Hi as Hc,Ph as Ic,Ip as Jc,bn as Kc,qn as Lc,It as Mc,gn as Nc,Rt as Oc,yr as Pc,br as Qc,Z0 as Rc,G0 as Sc,Of as Tc,Y as Uc,Ye as Vc,me as Wc,Fh as Xc,es as Yc,Lh as Zc,Je as _c,xn as $c,Zh as ad,Gh as bd,fl as cd,hl as dd,gl as ed,eg as fd,ng as gd,tg as hd,rg as id,og as jd,ag as kd,dg as ld,tR as md,Sl as nd,aR as od,uR as pd,Bi as qd,th as rd,gg as sd,_f as td,mg as ud,yg as vd,bg as wd,Pf as xd,Ef as yd,Mf as zd,Nf as Ad,At as Bd,We as Cd,Bn as Dd,kr as Ed,Re as Fd,ep as Gd,zf as Hd,If as Id,Rl as Jd,vg as Kd,wg as Ld,kg as Md,Cp as Nd,Zp as Od,gc as Pd,Nt as Qd,Rr as Rd,Ri as Sd,Gp as Td,Hc as Ud,Yn as Vd,Gi as Wd,Up as Xd,Wp as Yd,qp as Zd,Yc as _d,Vi as $d,Hp as ae,Yp as be,Te as ce,Dt as de,Jp as ee,Xp as fe,Jc as ge,Qp as he,eh as ie,Xc as je,Ft as ke,oh as le,nl as me,tl as ne,ah as oe,dh as pe,ch as qe,lh as re,uh as se,rl as te,fh as ue,ph as ve,hh as we,gh as xe,mh as ye,yh as ze,Wi as Ae,bh as Be,vh as Ce,wh as De,kh as Ee,xh as Fe,Sh as Ge,Rh as He,xg as Ie,Sg as Je};