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 @@
1
+ import{a as E,b,c as w,d as V,e as _}from"./chunk.QMGBAKX6.js";import{a as R,k as d,l as S}from"./chunk.PS765ODQ.js";import{Ra as $,Sa as F}from"./chunk.ZDUKVXBI.js";var O=["card","row","page"],A=["good","warn","bad","neutral","accent"],H=["money","percent","date","time","datetime","relative","count"],T=4,I=40,L=120,B=["number","money","percent"],M=["large"],X=["card","row"],N=1e3,ye=100;function Z(e){let n=/^\s*(out|in)\(\s*['"]([A-Za-z][A-Za-z0-9_-]*)['"]\s*\)\s*$/.exec(e);return n?{edge:n[2],way:n[1]}:/^[A-Za-z][A-Za-z0-9_-]*$/.test(e)?{edge:e}:void 0}var v={title:[],headline:[],list:["sort","limit","group","empty","as"],text:["tone","lines"],badge:["tone"],field:["as","currency","label"],image:["as","label"],progress:["label"],group:["direction"],when:["show"],divider:[],figure:["as","currency","label","emphasis"]},Y=Object.keys(v),G=`{"title": "{name}"}, {"headline": "{count(all('offer'))} offers"}, {"figure": expr, "as"?: "number"|"money"|"percent", "currency"?, "label"?, "emphasis"?: "large"}, {"list": expr, "sort"?, "limit"?, "group"?, "empty"?, "as"?: "card"|"row"}, {"text": "\u2026", "tone"?, "lines"?: 0-12}, {"badge": "{status}", "tone"?}, {"field": "quote", "as"?, "currency"?, "label"?}, {"image": "photos", "as"?: "thumb"|"gallery"}, {"progress": {"value": expr, "max": expr}, "label"?}, {"group": [blocks], "direction"?: "row"|"column"}, {"when": expr, "show": [blocks]}, {"divider": true}, {"figure": true}`,q=e=>/^(image|video|file)$/.test(e?.of??e?.type??"");function he(e){return Object.fromEntries(Object.entries(e.views??{}).filter(([,n])=>!Array.isArray(n)))}function me(e){let n=e.views?.home;return Array.isArray(n)?n:void 0}var J={field:()=>!1,relation:()=>!1,figure:!1},W=e=>e.kind??"the home",m=(e,n)=>e!==void 0&&Object.hasOwn(e,n),g=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function D(e,n,t){let s=E(e);for(let a of s.unknownFunctions)t.findings.push(d("unknown-function",n,`"${a}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let a of s.names){if(t.kind===null){t.findings.push(d("view-name",n,`"${a}" names nothing here: these blocks are about no one record`,"reach records with all('<kind>'), like count(all('offer')) or first(all('party') where role == 'client').name"));continue}a==="id"||t.spec.field(a)||t.spec.relation(a)||t.findings.push(d("view-name",n,`${t.kind} has no field or relation called "${a}"`))}for(let a of s.edges)t.edges.has(a)||t.findings.push(d("view-edge",n,`"${a}" is not a relation any kind declares`));for(let a of s.sweeps)t.kinds.has(a)||t.findings.push(d("view-kind",n,`"${a}" is not a kind this document declares`))}function k(e,n,t){if(typeof e!="string"||e.length===0||e.length>2e3){t.findings.push(d("view-expression",n,`an expression is a line of the rule language, like "status == 'booked'"`));return}try{D(w(e),n,t)}catch(s){if(!(s instanceof b))throw s;t.findings.push(d("expression",n,`${s.sentence} (at character ${s.at+1})`))}}function j(e,n,t,s,a=!1){let l=s==="text";if(typeof e!="string"||e.length===0||e.length>300){t.findings.push(d("view-template",n,'a template is words with {field} in braces, like "{name}" or "{quote|money}", at most 300 characters'));return}let r;try{r=_(e)}catch(i){if(i instanceof V||i instanceof b){t.findings.push(d("template",n,i.sentence));return}throw i}for(let i of r)if(i.expr){if(D(i.expr,n,t),l&&!a&&!i.format&&i.expr.t==="ident"&&(t.slot==="card"||t.slot==="row")&&t.spec.prose?.(i.expr.name)){let o=i.expr.name;t.findings.push(S("view-whole-text",n,`${t.kind} ${t.slot} shows ${o} whole; it will be clamped. Use {${o}|excerpt} or move it to the page.`,`write {${o}|excerpt}, or {${o}|excerpt: 80} for fewer characters`))}if(s==="headline"&&!i.format&&i.expr.t==="ident"&&t.spec.prose?.(i.expr.name)){let o=i.expr.name;t.findings.push(S("view-headline-long",n,`${W(t)}${t.slot?` ${t.slot}`:""} heads it with ${o}, a long text, drawn at a headline's size; a headline is a few words.`,`say it in a text block, {"text": "{${o}}"}, or head it with {${o}|excerpt: 60}`))}}}var K=12;function Q(e,n,t){typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=K||t.findings.push(d("view-lines",n,`lines is ${JSON.stringify(e)}, and a text block's lines is a whole number from 1 to ${K}, or 0 to show it whole`,'{"text": "{awards}", "lines": 6}, or "lines": 0 for no cut at all'))}function ee(e,n,t){if(typeof e=="string"){A.includes(e)||t.findings.push(d("view-tone",n,`"${e}" is not a tone`,`use one of ${A.join(", ")}, or {"expr": "if(status == 'booked', 'good', 'neutral')"}`));return}if(g(e)&&Object.keys(e).length===1&&"expr"in e){k(e.expr,`${n}.expr`,t);return}t.findings.push(d("view-tone",n,'a tone is a word or {"expr": \u2026}',`one of ${A.join(", ")}`))}function x(e,n,t,s){if(!Array.isArray(e)){s.findings.push(d("view-shape",n,"a view is a list of blocks"));return}if(t>T){s.findings.push(d("view-depth",n,`blocks nest at most ${T} deep`,"flatten a group or a condition"));return}e.forEach((a,l)=>ne(a,`${n}.${l}`,t,s))}function ne(e,n,t,s){if(t===1&&s.count++,s.all++,!g(e)){s.findings.push(d("view-block",n,"a block is an object naming what it shows",`one of ${G}`));return}let a=Object.keys(e),l=a.filter(o=>Y.includes(o)&&!(o==="group"&&a.includes("list")));if(l.length===0){s.findings.push(d("view-block",n,`${a.length>0?a.map(o=>`"${o}"`).join(", "):"an empty object"} is not a block Graview knows`,`one of ${G}`));return}if(l.length>1){s.findings.push(d("view-block",n,`a block is one thing, and this says ${l.map(o=>`"${o}"`).join(" and ")}`,"split it into two blocks"));return}let r=l[0];for(let o of a)o!==r&&o!="key"&&!v[r].includes(o)&&s.findings.push(d("unknown-key",`${n}.${o}`,`"${o}" is not part of a ${r} block`,v[r].length>0?`a ${r} block may also say ${v[r].map(f=>`"${f}"`).join(", ")}`:`a ${r} block says nothing else`));let i=e[r];switch(r){case"title":case"headline":case"text":case"badge":j(i,`${n}.${r}`,s,r==="text"||r==="headline"?r:void 0,r==="text"&&"lines"in e),"tone"in e&&ee(e.tone,`${n}.tone`,s),r==="text"&&"lines"in e&&Q(e.lines,`${n}.lines`,s);return;case"image":case"field":{let o=r==="image";if(typeof i!="string"||!(o?s.spec.files?.(i):s.spec.field(i))){let u=typeof i=="string"&&s.spec.relation(i);s.findings.push(d(`view-${r}`,`${n}.${r}`,`${s.kind} has no ${o?"image, video or file ":""}field ${typeof i=="string"?`"${i}"`:"by that name"}`,u?`"${i}" is a relation; show it with {"text": "{${i}.name}"}`:void 0))}let f=o?["thumb","gallery"]:H;"as"in e&&!f.includes(e.as)&&s.findings.push(d("view-format",`${n}.as`,`"${String(e.as)}" is not a way to show ${o?"pictures":"a field"}`,`use one of ${f.join(", ")}`)),o||P(e,n,s,"field"),"label"in e&&se(e.label,`${n}.label`,s);return}case"progress":{!g(i)||Object.keys(i).some(o=>o!=="value"&&o!=="max")||!("value"in i)||!("max"in i)?s.findings.push(d("view-progress",`${n}.progress`,'progress is {"value": expression, "max": expression}')):(k(i.value,`${n}.progress.value`,s),k(i.max,`${n}.progress.max`,s)),"label"in e&&j(e.label,`${n}.label`,s);return}case"group":"direction"in e&&e.direction!=="row"&&e.direction!=="column"&&s.findings.push(d("view-direction",`${n}.direction`,`a group runs "row" or "column", not "${String(e.direction)}"`)),x(i,`${n}.group`,t+1,s);return;case"when":k(i,`${n}.when`,s),"show"in e?x(e.show,`${n}.show`,t+1,s):s.findings.push(d("view-when",n,'a condition says what it shows: {"when": expr, "show": [blocks]}'));return;case"figure":if(typeof i=="string")return ie(e,n,s);for(let o of["as","currency","label","emphasis"])o in e&&s.findings.push(d("unknown-key",`${n}.${o}`,`"${o}" belongs to a figure that works a number out; {"figure": true} is the kind's picture`,`write {"figure": "count(all('offer'))", "as": "number"}`));i!==!0?s.findings.push(d("view-block",`${n}.figure`,`a figure is a number worked out, {"figure": "sum(all('offer'), net)", "as": "money"}, or the kind's picture, {"figure": true}`)):s.spec.figure||s.findings.push(d("view-figure",`${n}.figure`,`${W(s)} has no figure to show`,s.kind===null?`work a number out: {"figure": "count(all('offer'))"}`:'give the kind a "figure", or leave this block out'));return;case"list":return oe(e,n,s);case"divider":i!==!0&&s.findings.push(d("view-block",`${n}.${r}`,`write {"${r}": true}`));return}}function ie(e,n,t){k(e.figure,`${n}.figure`,t),"as"in e&&!B.includes(e.as)&&t.findings.push(d("view-format",`${n}.as`,`"${String(e.as)}" is not a way to say a figure`,`use one of ${B.join(", ")}`)),P(e,n,t,"figure"),"label"in e&&j(e.label,`${n}.label`,t),"emphasis"in e&&!M.includes(e.emphasis)&&t.findings.push(d("view-emphasis",`${n}.emphasis`,`"${String(e.emphasis)}" is not how loudly a figure is said`,`use ${M.map(s=>`"${s}"`).join(", ")}, or leave it out for the figure's own size`))}function P(e,n,t,s){"currency"in e&&(typeof e.currency!="string"||!/^[A-Z]{3}$/.test(e.currency)?t.findings.push(d("view-currency",`${n}.currency`,'a currency is its three-letter code, like "USD" or "EUR"')):e.as!=="money"&&t.findings.push(d("view-currency",`${n}.currency`,`a currency belongs on a ${s} shown as money`,'add "as": "money"')))}function te(e,n){let t=[...n.kinds],s=(l,r)=>{let i=new Set;for(let o of l){let f=n.vocabulary.namesOf(o)?.targets?.(r);if(f==="*")return t;for(let u of f??[])i.add(u)}return i.size>0?[...i]:void 0},a=l=>{switch(l.t){case"ident":return l.name===R?n.kind!==null?[n.kind]:void 0:n.kind!==null&&n.spec.relation(l.name)?s([n.kind],l.name):void 0;case"member":{let r=a(l.object);return r?s(r,l.name):void 0}case"where":return a(l.set);case"call":{let r=l.args[0],i=r?.t==="lit"&&typeof r.value=="string"?r.value:void 0;if(l.fn==="all")return i!==void 0&&n.kinds.has(i)?[i]:void 0;let o=l.args.length===2&&l.args[1]?.t==="lit"&&typeof l.args[1].value=="string"?l.args[1].value:void 0;if(l.fn==="out"&&o!==void 0){let f=a(r);return f?s(f,o):void 0}if(l.fn==="out")return i!==void 0&&n.kind!==null?s([n.kind],i):void 0;if(l.fn==="in"){let f=o??i,u=o!==void 0?a(r):n.kind!==null?[n.kind]:void 0,c=f!==void 0?n.vocabulary.sources(f).filter(p=>{let y=n.vocabulary.namesOf(p)?.targets?.(f);return!u||y==="*"||u.some(h=>y?.includes(h))}):[];return c.length>0?c:void 0}if((l.fn==="sort"||l.fn==="first")&&r)return a(r);if(l.fn==="either"){let f=l.args.map(a);return f.every(u=>u!==void 0)?[...new Set(f.flatMap(u=>u??[]))]:void 0}return}default:return}};return a(e)}function z(e,n,t,s){let a;try{a=w(e)}catch(r){if(!(r instanceof b))throw r;s.findings.push(d("expression",n,`${r.sentence} (at character ${r.at+1})`));return}let l=E(a);for(let r of l.unknownFunctions)s.findings.push(d("unknown-function",n,`"${r}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let r of l.edges)s.edges.has(r)||s.findings.push(d("view-edge",n,`"${r}" is not a relation any kind declares`));if(t)for(let r of l.names)r==="id"||t.some(i=>s.vocabulary.namesOf(i)?.field(r)||s.vocabulary.namesOf(i)?.relation(r))||s.findings.push(d("view-name",n,`${t.join(" and ")} ${t.length===1?"has":"have"} no field or relation called "${r}"`))}function oe(e,n,t){let s=e.list;k(s,`${n}.list`,t);let a;if(typeof s=="string")try{a=te(w(s),t)}catch{a=void 0}let l=i=>{if(!a)return[...t.kinds].map(f=>t.vocabulary.namesOf(f)?.choices?.(i)).find(f=>f!==void 0);let o=a.map(f=>t.vocabulary.namesOf(f)?.choices?.(i));return o.every(f=>f!==void 0)?[...new Set(o.flatMap(f=>f??[]))]:void 0},r=a?a.join(" and "):"any kind";if("sort"in e){let i=e.sort;if(typeof i=="string")z(i,`${n}.sort`,a,t);else if(g(i)&&typeof i.by=="string"&&Object.keys(i).every(o=>o==="by"||o==="direction")){let o=i.direction;o!==void 0&&o!=="asc"&&o!=="desc"&&o!=="choices"?t.findings.push(d("list-sort",`${n}.sort.direction`,`a list is sorted "asc", "desc" or "choices", not "${String(o)}"`,'"choices" puts a choice field in the order its choices are declared')):o==="choices"?l(i.by)===void 0&&t.findings.push(d("list-sort",`${n}.sort.by`,`"${i.by}" is not a choice field of ${r}, so it has no declared order`,'sort by a choice field, or say "asc" or "desc"')):z(i.by,`${n}.sort.by`,a,t)}else t.findings.push(d("list-sort",`${n}.sort`,'a sort is a key, like "net", or {"by": key, "direction": "asc" | "desc" | "choices"}'))}if("limit"in e){let i=e.limit;(typeof i!="number"||!Number.isInteger(i)||i<1||i>N)&&t.findings.push(d("list-limit",`${n}.limit`,`a limit is a whole number from 1 to ${N}`))}if("group"in e){let i=e.group,o=typeof i=="string"?i:g(i)&&typeof i.by=="string"?i.by:void 0;if(!(typeof i=="string"||g(i)&&Object.keys(i).every(u=>u==="by"||u==="headings"))||o===void 0)t.findings.push(d("list-group",`${n}.group`,'a group is a choice field, like "type", or {"by": "type", "headings": {"pain": "What hurts"}} \u2014 or a relation, like "inGenre", a heading per linked record'));else{let u=l(o),c=u===void 0?Z(o):void 0,p=c!==void 0&&(c.way!==void 0?t.edges.has(c.edge):a?a.every(y=>t.vocabulary.namesOf(y)?.relation(c.edge)):t.edges.has(c.edge));if(u===void 0&&!p&&t.findings.push(d("list-group",`${n}.group`,`"${o}" is not a choice field or a relation of ${r}, so it has nothing to group by`,'group by a field whose type is enum, or by a relation of the kind listed, like "inGenre"')),g(i)&&"headings"in i){let y=i.headings;if(!g(y)||Object.values(y).some(h=>typeof h!="string"||h.length===0||h.length>80))t.findings.push(d("list-group",`${n}.group.headings`,'headings are words per choice, like {"pain": "What hurts"}, at most 80 characters each'));else if(u)for(let h of Object.keys(y))u.includes(h)||t.findings.push(d("list-group",`${n}.group.headings.${h}`,`"${h}" is not one of ${o}'s choices`,`use ${u.join(", ")}`))}}}"empty"in e&&(typeof e.empty!="string"||e.empty.length===0||e.empty.length>200)&&t.findings.push(d("list-empty",`${n}.empty`,"what an empty list says is a sentence, at most 200 characters")),"as"in e&&!X.includes(e.as)&&t.findings.push(d("list-as",`${n}.as`,`a list draws each record as its "card" or its "row", not "${String(e.as)}"`))}function se(e,n,t){(typeof e!="string"||e.length===0||e.length>60)&&t.findings.push(d("view-label",n,"a label is a few words, at most 60 characters"))}function U(e,n,t,s,a,l,r){let i={kind:null,spec:J,kinds:s,edges:a,vocabulary:t,findings:l,count:0,all:0};Array.isArray(e)&&e.length===0&&l.push(d("view-shape",n,`${r} has no blocks`,'give it one: {"headline": "\u2026"}')),x(e,n,1,i),C(i,n,r,"show less")}function C(e,n,t,s){e.count>I?e.findings.push(d("view-size",n,`${t} has ${e.count} blocks at its top; a view has at most ${I} there, a group or a condition counting as one`,`${s}, or gather some into a group`)):e.all>L&&e.findings.push(d("view-size",n,`${t} has ${e.all} blocks counting the ones inside its groups and conditions; a view has at most ${L} in all`,s))}function re(e,n,t,s,a){Array.isArray(e)&&e.forEach((l,r)=>{if(!g(l)||l.name!=="blocks"||!g(l.options)||!("blocks"in l.options))return;let i=[];U(l.options.blocks,`lenses.${r}.options.blocks`,n,t,s,i,`the lens "${String(l.title??r)}"`);for(let o of i)a.push({...o,severity:"warning"})})}function ae(e,n,t,s,a,l,r){let i=[];if(e===void 0)return i;if(!g(e))return i.push(d("view-shape",n,'views are an object of kinds, each with a "card", a "row" or a "page"')),i;for(let[o,f]of Object.entries(e)){if(o==="home"&&Array.isArray(f)){U(f,`${n}.home`,r,s,a,i,"the home");continue}let u=t(o);if(!u){i.push(d("view-kind",`${n}.${o}`,`"${o}" is not a kind this ${l} declares`));continue}if(!g(f)){i.push(d("view-shape",`${n}.${o}`,`a kind's views are {"card": [blocks], "row": [blocks], "page": [blocks]}`));continue}for(let c of Object.keys(f))O.includes(c)||i.push(d("view-slot",`${n}.${o}.${c}`,`"${c}" is not a place a view is drawn`,`use ${O.map(p=>`"${p}"`).join(", ")}`));for(let c of O){let p=f[c];if(p===void 0)continue;let y={kind:o,spec:u,kinds:s,edges:a,vocabulary:r,findings:i,count:0,all:0,slot:c};x(p,`${n}.${o}.${c}`,1,y),C(y,`${n}.${o}.${c}`,`this ${c}`,"show less, or move detail to the page")}}return i}function pe(e){let n=new Set(Object.keys(e.kinds)),t=new Set(Object.values(e.kinds).flatMap(r=>Object.keys($(r.edges)))),s=r=>{let i=m(e.kinds,r)?e.kinds[r]:void 0;return i?{field:o=>m(i.fields,o)||m(i.computed,o)||F(i.edges).has(o),relation:o=>m($(i.edges),o),figure:i.figure!==void 0,files:o=>m(i.fields,o)&&q(i.fields[o]),choices:o=>m(i.fields,o)&&i.fields[o].type==="enum"?i.fields[o].options:void 0,targets:o=>m($(i.edges),o)?i.edges[o].to:void 0,prose:o=>m(i.fields,o)&&i.fields[o].type==="text"}:void 0},a={namesOf:s,sources:r=>Object.keys(e.kinds).filter(i=>m(e.kinds[i].edges,r))},l=ae(e.views,"views",s,n,t,"document",a);return re(e.lenses,a,n,t,l),l}export{A as a,H as b,B as c,M as d,N as e,ye as f,Z as g,he as h,me as i,pe as j};
@@ -0,0 +1 @@
1
+ import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p}from"./chunk.IZKCTF2R.js";import"./chunk.G4JJXA63.js";import{a}from"./chunk.TBY5IR7C.js";import"./chunk.JP33TNCH.js";import"./chunk.BIDL7GQD.js";import"./chunk.O5P6LXHF.js";import"./chunk.ONVYKLRX.js";import"./chunk.XOZU4OFA.js";import"./chunk.53GQQETN.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.7DCBIMOI.js";import"./chunk.GXK5PI7I.js";import"./chunk.DYPSFTRP.js";import"./chunk.WVUJXDXZ.js";import"./chunk.J7GH2CGV.js";import"./chunk.SMF5S4DQ.js";import"./chunk.XP4IVKKR.js";import"./chunk.R5YGW5ZX.js";import"./chunk.QMGBAKX6.js";import"./chunk.PS765ODQ.js";import"./chunk.T3RFZ66S.js";import"./chunk.TDWJU6GW.js";import"./chunk.P3Z4ZCL3.js";import"./chunk.45OLF6BK.js";import"./chunk.T6ISUVUP.js";import"./chunk.ZDUKVXBI.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";export{j as draftAnswer,i as draftFromLens,c as draftSight,m as draftView,b as isDraftFailure,d as judgeLens,e as lensEditOf,g as lensFromSpec,a as mayChangeDeclaration,k as recipeDraft,h as recipeOfLens,n as refineDraft,p as runDraftTool,f as takeBackEditOf,l as templateDraft,o as withReaderLenses};
@@ -1 +1 @@
1
- import{Jb as a,ma as l,sa as p}from"./chunk.IUVRJDL3.js";import{c}from"./chunk.FQLNBIQ5.js";function m(e){if(e.withheld===!0||e.undoes!==void 0||e.mutation?.name!==a)return;let{node:n,field:r}=e.mutation.args??{};return typeof n=="string"&&typeof r=="string"?{node:n,field:r}:void 0}function R(e,n){return e.kind!==n.kind?!1:e.id!==void 0||n.id!==void 0?e.id===n.id&&e.onBehalfOf===n.onBehalfOf:(e.name??"")===(n.name??"")}var f=e=>{let n=0;for(let r of e)n++;return n};function k(e){if(e.length===0)return;let n=m(e[0]);if(!n)return;let r=0,o=0;for(let i of e){let d=m(i);if(!d||d.node!==n.node||d.field!==n.field)return;for(let t of i.primitives)if(t.op==="splice-text"&&t.id===n.node&&t.field===n.field)r+=f(t.inserted),o+=f(t.removed);else if(t.op==="patch-node"&&t.id===n.node&&Object.prototype.hasOwnProperty.call(t.after,n.field)){let s=t.before[n.field],u=t.after[n.field];r+=typeof u=="string"?f(u):0,o+=typeof s=="string"&&!c(s)?f(s):0}}return{...n,inserted:r,removed:o}}var T=(e,n)=>({node:e.node,field:e.field,inserted:e.inserted+n.inserted,removed:e.removed+n.removed});function y(e){return`(${[...e.inserted>0||e.removed===0?[`+${e.inserted}`]:[],...e.removed>0?[`\u2212${e.removed}`]:[]].join(" ")})`}function w(e,n,r,o=!0){let i=r?.getNode(e.node),d=i?n.tryDefinition(i.kind):void 0,t=p(d,e.field);return`Wrote in ${i&&o?`${l(d,i)}'s ${t.toLowerCase()}`:t} ${y(e)}`}export{R as a,k as b,T as c,w as d};
1
+ import{Jb as a,ma as l,sa as p}from"./chunk.ZDUKVXBI.js";import{c}from"./chunk.FQLNBIQ5.js";function m(e){if(e.withheld===!0||e.undoes!==void 0||e.mutation?.name!==a)return;let{node:n,field:r}=e.mutation.args??{};return typeof n=="string"&&typeof r=="string"?{node:n,field:r}:void 0}function R(e,n){return e.kind!==n.kind?!1:e.id!==void 0||n.id!==void 0?e.id===n.id&&e.onBehalfOf===n.onBehalfOf:(e.name??"")===(n.name??"")}var f=e=>{let n=0;for(let r of e)n++;return n};function k(e){if(e.length===0)return;let n=m(e[0]);if(!n)return;let r=0,o=0;for(let i of e){let d=m(i);if(!d||d.node!==n.node||d.field!==n.field)return;for(let t of i.primitives)if(t.op==="splice-text"&&t.id===n.node&&t.field===n.field)r+=f(t.inserted),o+=f(t.removed);else if(t.op==="patch-node"&&t.id===n.node&&Object.prototype.hasOwnProperty.call(t.after,n.field)){let s=t.before[n.field],u=t.after[n.field];r+=typeof u=="string"?f(u):0,o+=typeof s=="string"&&!c(s)?f(s):0}}return{...n,inserted:r,removed:o}}var T=(e,n)=>({node:e.node,field:e.field,inserted:e.inserted+n.inserted,removed:e.removed+n.removed});function y(e){return`(${[...e.inserted>0||e.removed===0?[`+${e.inserted}`]:[],...e.removed>0?[`\u2212${e.removed}`]:[]].join(" ")})`}function w(e,n,r,o=!0){let i=r?.getNode(e.node),d=i?n.tryDefinition(i.kind):void 0,t=p(d,e.field);return`Wrote in ${i&&o?`${l(d,i)}'s ${t.toLowerCase()}`:t} ${y(e)}`}export{R as a,k as b,T as c,w as d};
@@ -1,2 +1,2 @@
1
- import{d as S,e as w,f as I}from"./chunk.M7DJJRFH.js";import{d as k,g as h,h as b}from"./chunk.6VG2LCES.js";import"./chunk.I3ADXJQW.js";import"./chunk.BJUUSIQY.js";import"./chunk.HMV4ILAC.js";import{a as A}from"./chunk.UVMHC6VM.js";import"./chunk.XAN7QXMQ.js";import"./chunk.XJ4JYROM.js";import"./chunk.XOZU4OFA.js";import"./chunk.CHG522KL.js";import"./chunk.7QWGIGHM.js";import"./chunk.ZGJUCVT5.js";import"./chunk.CVVNHQPO.js";import"./chunk.YIDNZTON.js";import"./chunk.QILGAV7H.js";import"./chunk.I6HIVTXU.js";import"./chunk.PYGNO2AV.js";import"./chunk.3HFBHLXC.js";import{G as M,Y as f}from"./chunk.CUA7F3YJ.js";import"./chunk.SDO3U72B.js";import"./chunk.IUVRJDL3.js";import"./chunk.FQLNBIQ5.js";import{b as d}from"./chunk.AJZBJBMO.js";var n=d(M(),1);var r=d(f(),1),C="several";function T({chosen:c,acts:p,onAct:N}){let t=A(),u=(0,n.useMemo)(()=>[...c].sort(),[c]),i=u.join(`
1
+ import{d as S,e as w,f as I}from"./chunk.GMHBAS45.js";import{d as k,g as h,h as b}from"./chunk.4VX7GPFS.js";import"./chunk.FQ2QUDZS.js";import"./chunk.BJUUSIQY.js";import"./chunk.VGQDPEB5.js";import{a as A}from"./chunk.6YKKZI4H.js";import"./chunk.WIVNFOQR.js";import"./chunk.ONVYKLRX.js";import"./chunk.XOZU4OFA.js";import"./chunk.53GQQETN.js";import"./chunk.SMF5S4DQ.js";import"./chunk.T3RFZ66S.js";import"./chunk.TDWJU6GW.js";import"./chunk.P3Z4ZCL3.js";import"./chunk.45OLF6BK.js";import"./chunk.T6ISUVUP.js";import"./chunk.GH6QX7JR.js";import"./chunk.J4D4BIB4.js";import{G as M,_ as f}from"./chunk.ASNVH2G4.js";import"./chunk.SDO3U72B.js";import"./chunk.ZDUKVXBI.js";import"./chunk.FQLNBIQ5.js";import{b as d}from"./chunk.AJZBJBMO.js";var n=d(M(),1);var r=d(f(),1),C="several";function T({chosen:c,acts:p,onAct:N}){let t=A(),u=(0,n.useMemo)(()=>[...c].sort(),[c]),i=u.join(`
2
2
  `),o=(0,n.useMemo)(()=>({on:"selection",ids:u}),[i]),l=(0,n.useMemo)(()=>p.filter(e=>e.open.length===0&&!e.more&&!e.destructive),[p]),g=(0,n.useMemo)(()=>new Map(l.map(e=>[h(e.id),e])),[l]),v=S(t,o,C),[y,x]=(0,n.useState)(null);(0,n.useEffect)(()=>{if(v!==void 0)return;let e=!0;return w(t,o,{by:C,ask:()=>b(t.ai,{store:t.store,target:o,principal:t.principal,interaction:k(),places:t.places,selection:t.selection,...t.place?{place:t.place}:{},shared:l.map(a=>({id:a.id,label:a.label,mutation:a.mutation,args:a.args}))})}).then(a=>{e&&x({key:i,result:a})}),()=>{e=!1}},[i]);let s=v??(y?.key===i?y.result:void 0);if(s===void 0)return(0,r.jsx)("span",{role:"status",className:"graview-several-quiet","data-testid":"several-ai-thinking",style:{textDecoration:"none"},children:"AI: thinking\u2026"});let m=s.offers.filter(e=>e.type!=="act"||g.has(e.id));if(m.length===0)return null;let E=e=>{let a=g.get(e.id);if(a){t.desk.record({...s.interaction,outcome:"accepted",accepted:[e.id]}),N(a);return}I(t,s,e)};return(0,r.jsx)("div",{role:"group","aria-label":"Suggested by AI",className:"graview-several-acts","data-testid":"several-ai",children:m.map(e=>(0,r.jsxs)("button",{type:"button",className:"graview-several-act","data-testid":"several-ai-offer","data-ai-offer":e.id,"data-ai-offer-type":e.type,onClick:()=>E(e),children:[e.label,(0,r.jsx)("span",{style:{color:"var(--graview-ink-faint)",fontWeight:400},children:" \xB7 suggested"})]},e.id))})}export{T as SeveralAi};
@@ -1,4 +1,4 @@
1
- import{yd as e}from"./chunk.IUVRJDL3.js";var i=`
1
+ import{yd as e}from"./chunk.ZDUKVXBI.js";var i=`
2
2
  .graview-spec{display:flex;flex-direction:column;gap:6px;min-width:0;color:var(--graview-ink)}
3
3
 
4
4
  .graview-spec-row{flex-direction:row;flex-wrap:wrap;align-items:center;gap:4px 10px;box-sizing:border-box;max-width:100%;padding:5px 10px;border:1px solid var(--graview-edge);border-radius:var(--graview-radius-sm,8px);background:var(--graview-panel);font-size:.875rem}
@@ -21,7 +21,8 @@ import{yd as e}from"./chunk.IUVRJDL3.js";var i=`
21
21
  .graview-spec-row .graview-spec-text.graview-spec-meta,.graview-spec-card .graview-spec-text.graview-spec-meta{display:flex;flex:1 1 auto;-webkit-line-clamp:none;line-clamp:none;max-height:none;overflow:visible}
22
22
  [data-graview-page-main] .graview-spec-meta{font-size:var(--graview-text-small)}
23
23
  .graview-spec-chip{display:inline-flex;align-items:center;box-sizing:border-box;min-height:1.375rem;padding:0 var(--graview-space-2,8px);border-radius:var(--graview-radius-sm,6px);background:color-mix(in srgb,var(--graview-ink) 7%,transparent);color:var(--graview-ink);font-weight:500;white-space:nowrap}
24
- .graview-spec-page{padding-bottom:14px;margin-bottom:14px;border-bottom:1px solid var(--graview-edge)}
24
+
25
+ .graview-spec-page[data-graview-heads-record]{padding-bottom:14px;margin-bottom:14px;border-bottom:1px solid var(--graview-edge)}
25
26
  .graview-spec-title{font-family:var(--graview-font-display,inherit);font-weight:600;font-size:1rem;line-height:1.3;overflow-wrap:anywhere}
26
27
  .graview-spec-text{margin:0;font-size:.875rem;line-height:1.45;overflow-wrap:anywhere}
27
28
  .graview-spec-text[data-graview-tone]{color:var(--graview-spec-tone)}
@@ -1 +1 @@
1
- import{c as M}from"./chunk.DW6KXAUM.js";import{ha as b}from"./chunk.IUVRJDL3.js";var k=["owners","status","schedule","budget","places","sources","stock","votes","private","history","publishing","roster","routines","comparison"],y={owners:"people who own things",status:"a status that moves",schedule:"dates it is due by, or a schedule",budget:"money against a budget",places:"places",sources:"sources behind claims",stock:"counts in stock",votes:"votes or picks",private:"private to its owner",history:"a history, a record book",publishing:"content to publish",roster:"a roster of people",routines:"repeating routines",comparison:"a comparison to pick one from"},J={owners:"a person kind (or the people the app has), an owner link, Give it to someone, a rule that every one has somebody on it, and Who has what",status:"a status with named steps (or the one the app has), an act for each step, and a board",schedule:"a due date, Set the date, the on-time rule, and a calendar",budget:"a cost beside the money the app keeps, a budget on the kind it is grouped under, Set the budget, and the over-budget rule",places:"a place kind, a link to one, and a map of where things are",sources:"a source kind, a link from each claim to its source, and the rule that a claim names one",stock:"what is on hand and the reorder level, Count the stock, and the running-low rule",votes:"a vote on each, Vote for it, and a tally",private:"a sight that keeps each person's own records to them",history:"the record book: an era or season each belongs to, and a timeline",publishing:"a published status, Publish it, and what the public sees",roster:"a person kind with the fields a roster keeps, and the list of who is here",routines:"how often each repeats and when it was last done, Mark it done, and the overdue rule",comparison:"a side-by-side of the candidates, one chosen, and Choose it"},U=new Set(["person","people","member","user","player","guest","candidate","participant","traveler","volunteer","interviewer","interviewee","contact","trade","staff","student","employee","teammate","crew","attendee","friend","customer","client","driver","speaker","host","teacher","parent","kid","child","coach","patient","tenant","resident","neighbor","applicant","recruit","contributor","assignee","worker","collaborator","runner"]),K=new Set(["place","venue","location","room","site","building","store","warehouse","city","country","region","address","hall","stadium","office","shelf"]),z=new Set(["source","reference","citation","evidence"]),H=new Set(["season","era","period","epoch","edition","generation","age","campaign","tournament"]),ae=/owner|owned|assign|^lead$|responsible|^by$|^by-|done-?by|interviewer|reviewer|maker|author|keeper|givenby|^for-?person$/i,oe=/due|deadline|until|needed|needby|target|expires|^ends?(on|at)?$|^by$/i,de=/^(date|day|when|at|start|starts|startsat|startson|startdate|scheduled|scheduledfor|scheduledon|happens|happenson|held|heldon|from|time|exchangedate|.*date|.*day)$/i,le=/released|fixed|published|applied|checked|created|added|done|last|first|updated|seen|born|birth|founded|finished|completed|closed/i,X=/status|stage|state|phase|progress/i,W=/budget|limit|cap$|allowance/i,ce=/budget|cost|price|quote|amount|salary|fee|spend|total|paid|owed/i,pe=/^(place|location|venue|address|where|city|town)$/i,B=/reorder|onhand|instock|^stock|quantity|^qty/i,he=/^votes?$|votecount|upvotes|^score$|^points$/i,fe=/^(votes?|votesfor|votedby|voters|picks?|chooses|choices|favorites|likes)$/i,ue=/often|frequency|cadence|^every$|repeat|interval/i,ge=/^last/i,Q=/^(published|live|public)$/i,ye=/count\(.*\bwhere\b.*\)\s*<=\s*1\b/,u=e=>e.toLowerCase(),w=(e,t)=>u(e.kinds[t]?.noun??b(t)),$=(e,t)=>u(e.kinds[t]?.plural??`${w(e,t)}s`),me=e=>e.charAt(0).toUpperCase()+e.slice(1),p=(e,t)=>me($(e,t)),we=e=>/^[aeiou]/i.test(e)?"an":"a",x=(e,t="and")=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} ${t} ${e[e.length-1]}`,N=e=>new Set((e??"").split(/[^A-Za-z0-9_-]+/).filter(Boolean)),v=e=>Object.entries(e.kinds),m=(e,t)=>Object.entries(e.acts??{}).filter(([,s])=>[s.on??[]].flat().includes(t)),_=e=>Array.isArray(e.lenses)?e.lenses:[],I=e=>typeof e.title=="string"?e.title:void 0,A=e=>e.bindings&&typeof e.bindings=="object"?e.bindings:{},R=(e,t)=>Array.isArray(t)&&t.length===1&&typeof t[0]=="string"&&e.kinds[t[0]]?t[0]:void 0;function V(e,t){let s=e.kinds[t];if(!s)return!1;let r=n=>u(n).replace(/ll/g,"l");return s.people===!0||U.has(r(t))||U.has(r(w(e,t)))}var Y=(e,t)=>K.has(u(t))||K.has(w(e,t)),ke=(e,t)=>z.has(u(t))||z.has(w(e,t)),be=(e,t)=>H.has(u(t))||H.has(w(e,t)),$e=(e,t)=>(t.type==="number"||t.type==="integer")&&(t.format==="money"||ce.test(e)),j=e=>e.type==="date"||e.type==="datetime";function P(e,t,s,r,n){return _(e).filter(d=>d.name===t&&A(d)[s]?.[r]===n).map(I).filter(d=>d!==void 0)}function D(e,t,s,r){return _(e).filter(n=>n.name==="coverage"&&A(n)[s]?.kind===t&&(r===void 0||A(n).link?.edge===r)).map(I).filter(n=>n!==void 0)}function f(e,t,s){let r=new Set(t);return Object.entries(e.rules??{}).filter(([,n])=>(s===void 0||n.over==="graph"||s.includes(n.over))&&[...N(`${n.when??""} ${n.require??""} ${n.says??""}`)].some(d=>r.has(d))).map(([n])=>n)}var G=class{kinds=new Set;fields=new Set;relations=new Set;rules=new Set;lenses=new Set;acts=new Set;said;add=(t,...s)=>{for(let r of s)this[t].add(r)};say=t=>{this.said??=t};any=()=>this.kinds.size+this.fields.size+this.relations.size+this.rules.size+this.lenses.size+this.acts.size>0;asTrait=t=>({trait:t,words:y[t],said:this.said??y[t],kinds:[...this.kinds],fields:[...this.fields],relations:[...this.relations],rules:[...this.rules],lenses:[...this.lenses],acts:[...this.acts]})};function ve(e){let t;for(let[s,r]of v(e)){let n=Object.keys(r.fields).length+Object.keys(r.edges??{}).length;(!t||n>t.fields)&&(t={kind:s,fields:n})}return t?.kind}function g(e){let t=ve(e);return v(e).sort(([s],[r])=>+(r===t)-+(s===t))}function Z(e,t){let s=e.kinds[t];if(!s)return[];let r=[];for(let[n,d]of Object.entries(s.fields)){if(d.type!=="enum"||!Array.isArray(d.options)||d.options.length<2)continue;let i=m(e,t).filter(([,a])=>typeof a.sets?.[n]=="string"&&d.options.includes(a.sets[n])).map(([a])=>a);((X.test(n)||s.lifecycle?.field===n)&&i.length>=1||i.length>=2)&&r.push({field:n,options:d.options,steps:i})}return r}var ee={owners(e,t){for(let[s,r]of g(e))for(let[n,d]of Object.entries(r.edges??{})){let i=R(e,d.to);d.cardinality!=="one"||!i||!V(e,i)||!ae.test(n)||(t.add("kinds",s,i),t.add("relations",`${s}.${n}`),t.add("rules",...f(e,[n],[s,i])),t.add("lenses",...D(e,s,"rows",n)),t.add("acts",...m(e,s).filter(([,o])=>o.connects===n||o.severs===n).map(([o])=>o)),t.say(`Each ${w(e,s)} has one of the ${$(e,i)} on it (${n}).`))}},status(e,t){for(let[s]of g(e))for(let{field:r,options:n,steps:d}of Z(e,s))t.add("kinds",s),t.add("fields",`${s}.${r}`),t.add("acts",...d),t.add("rules",...f(e,[r],[s])),t.add("lenses",...P(e,"columns",s,"column",r)),t.say(`${p(e,s)} move through ${x(n.map(u))}.`)},schedule(e,t){for(let[s,r]of g(e))for(let[n,d]of Object.entries(r.fields)){if(!j(d)||le.test(n))continue;let i=P(e,"calendar",s,"start",n),o=oe.test(n);if(!o&&!de.test(n)&&i.length===0)continue;t.add("kinds",s),t.add("fields",`${s}.${n}`),t.add("lenses",...i),t.add("rules",...f(e,[n],[s])),t.add("acts",...m(e,s).filter(([,l])=>(l.writes??[]).includes(n)||l.sets?.[n]!==void 0).map(([l])=>l));let a=/date|day|when|time/i.test(n)?u(b(n)):`date (${n})`;t.say(o?`${p(e,s)} are due by a date (${n}).`:`${p(e,s)} have ${we(a)} ${a}${i.length>0?", on a calendar":""}.`)}},budget(e,t){let s=v(e).flatMap(([o,a])=>Object.entries(a.fields).filter(([l,h])=>(h.type==="number"||h.type==="integer")&&W.test(l)).map(([l])=>({kind:o,name:l})));if(s.length===0)return;let r=g(e).flatMap(([o,a])=>Object.entries(a.fields).filter(([l,h])=>$e(l,h)&&!W.test(l)).map(([l])=>({kind:o,name:l})));if(r.length===0)return;let n=[...s,...r].map(o=>o.name);for(let o of[...s,...r])t.add("kinds",o.kind),t.add("fields",`${o.kind}.${o.name}`),t.add("acts",...m(e,o.kind).filter(([,a])=>(a.writes??[]).includes(o.name)||a.sets?.[o.name]!==void 0).map(([a])=>a));t.add("rules",...f(e,n).filter(o=>s.some(a=>N(e.rules[o].require??"").has(a.name))));let d=r[0],i=s.find(o=>o.kind===d.kind)??s[0];t.say(`${p(e,d.kind)}' ${u(b(d.name))} against ${i.kind===d.kind?"each one's":`each ${w(e,i.kind)}'s`} ${u(b(i.name))}.`)},places(e,t){for(let[s,r]of g(e)){Y(e,s)&&(t.add("kinds",s),t.add("lenses",...D(e,s,"columns")));for(let[n,d]of Object.entries(r.edges??{})){let i=R(e,d.to);!i||!Y(e,i)||(t.add("kinds",s,i),t.add("relations",`${s}.${n}`),t.add("rules",...f(e,[n],[s,i])),t.say(`${p(e,s)} are at ${$(e,i)} (${n}).`))}for(let[n,d]of Object.entries(r.fields))d.type!=="place"&&!(d.type==="string"&&pe.test(n))||(t.add("kinds",s),t.add("fields",`${s}.${n}`),t.say(`${p(e,s)} say where (${n}).`))}t.any()&&!t.said&&t.say(`${x([...t.kinds].map(s=>p(e,s)))} are places.`)},sources(e,t){for(let[s,r]of g(e)){for(let[n,d]of Object.entries(r.edges??{})){let i=R(e,d.to);!i||!ke(e,i)&&!/^cite/i.test(n)||(t.add("kinds",s,i),t.add("relations",`${s}.${n}`),t.add("rules",...f(e,[n,i],[s,i])),t.add("acts",...m(e,s).filter(([,o])=>o.connects===n||o.severs===n).map(([o])=>o)),t.say(`${p(e,s)} cite ${$(e,i)} (${n}).`))}for(let[n,d]of Object.entries(r.fields))d.type!=="url"||!/^source/i.test(n)||(t.add("kinds",s),t.add("fields",`${s}.${n}`),t.add("rules",...f(e,[n],[s])),t.say(`${p(e,s)} link to their source (${n}).`))}},stock(e,t){for(let[s,r]of g(e)){let n=Object.entries(r.fields).filter(([a,l])=>(l.type==="number"||l.type==="integer")&&B.test(a)).map(([a])=>a),d=Object.keys(r.computed??{}).filter(a=>B.test(a)),i=n.some(a=>/reorder/i.test(a)),o=v(e).some(([,a])=>Object.entries(a.fields).some(([l,h])=>/^(change|delta|moved)$/i.test(l)&&(h.type==="number"||h.type==="integer")));!i&&!(d.length+n.length>0&&o)||(t.add("kinds",s),t.add("fields",...n.map(a=>`${s}.${a}`),...d.map(a=>`${s}.${a}`)),t.add("rules",...f(e,[...n,...d],[s])),t.add("acts",...m(e,s).filter(([,a])=>n.some(l=>(a.writes??[]).includes(l)||a.sets?.[l]!==void 0)).map(([a])=>a)),t.say(`${p(e,s)} have a count in stock${i?" and a reorder point":""}.`))}},votes(e,t){for(let[s,r]of g(e)){for(let[n,d]of Object.entries(r.fields)){if(d.type!=="number"&&d.type!=="integer"||!he.test(n))continue;let i=m(e,s).filter(([,o])=>o.sets?.[n]!==void 0).map(([o])=>o);i.length!==0&&(t.add("kinds",s),t.add("fields",`${s}.${n}`),t.add("acts",...i),t.add("rules",...f(e,[n],[s])),t.say(`${p(e,s)} collect votes (${n}).`))}for(let[n,d]of Object.entries(r.edges??{})){let i=R(e,d.to);!i||!fe.test(n)||(t.add("kinds",s,i),t.add("relations",`${s}.${n}`),t.add("rules",...f(e,[n],[s,i])),t.add("acts",...m(e,s).filter(([,o])=>o.connects===n||o.severs===n).map(([o])=>o)),t.say(`${p(e,s)} pick ${$(e,i)} (${n}).`))}}},private(e,t){let s=[];for(let r of e.policy?.sees??[])if(!(!r.own&&!r.via)){for(let n of r.kinds)if(e.kinds[n]&&(t.add("kinds",n),s.includes(n)||s.push(n),r.via))for(let[d,i]of v(e))i.edges?.[r.via]&&t.add("relations",`${d}.${r.via}`)}s.length>0&&t.say(`${x(s.map(r=>p(e,r)))} are seen only by whose they are.`)},history(e,t){for(let[s,r]of g(e))for(let[n,d]of Object.entries(r.edges??{})){let i=R(e,d.to);d.cardinality!=="one"||!i||!be(e,i)||!Object.entries(r.fields).some(([a,l])=>j(l)||/year|result|outcome|score|finish/i.test(a))||(t.add("kinds",s,i),t.add("relations",`${s}.${n}`),t.add("rules",...f(e,[n,i],[s,i])),t.add("lenses",...D(e,s,"rows",n),..._(e).filter(a=>a.name==="timeline"&&A(a)[s]!==void 0).map(I).filter(a=>a!==void 0)),t.say(`${p(e,s)} grouped into ${$(e,i)}, a record book.`))}},publishing(e,t){for(let[s,r]of g(e)){let n=Object.entries(r.fields).filter(([,i])=>i.type==="text").map(([i])=>i);if(n.length===0)continue;let d=Z(e,s).map(i=>i.field);for(let[i,o]of Object.entries(r.fields)){if(o.type!=="enum"||!(X.test(i)||d.includes(i))||!(o.options??[]).some(l=>Q.test(l)))continue;let a=(o.options??[]).find(l=>Q.test(l));t.add("kinds",s),t.add("fields",`${s}.${i}`,...n.map(l=>`${s}.${l}`)),t.add("acts",...m(e,s).filter(([,l])=>l.sets?.[i]===a).map(([l])=>l)),t.add("rules",...f(e,[i,...n],[s]).filter(l=>N(`${e.rules[l].when??""} ${e.rules[l].require??""}`).has(a)||n.some(h=>N(e.rules[l].require??"").has(h)))),t.say(`${p(e,s)} go from ${u(o.options[0])} to ${u(a)}, with their words.`)}}},roster(e,t){for(let[s,r]of g(e)){if(!V(e,s))continue;let n=Object.keys(r.fields);n.length<2||(t.add("kinds",s),t.add("fields",...n.map(d=>`${s}.${d}`)),t.add("lenses",...D(e,s,"columns"),...D(e,s,"rows")),t.say(`${p(e,s)}, with ${x(n.slice(1).map(d=>u(b(d))))}.`))}},routines(e,t){for(let[s,r]of g(e)){let n=Object.entries(r.fields).filter(([,a])=>j(a)&&a.repeats===!0).map(([a])=>a),d=Object.entries(r.fields).filter(([a,l])=>(l.type==="enum"||l.type==="string"||l.type==="integer"||l.type==="number")&&ue.test(a)).map(([a])=>a),i=Object.entries(r.fields).filter(([a,l])=>j(l)&&ge.test(a)).map(([a])=>a);if(n.length===0&&!(d.length>0&&i.length>0))continue;let o=[...n,...d,...i];t.add("kinds",s),t.add("fields",...o.map(a=>`${s}.${a}`)),t.add("rules",...f(e,o,[s])),t.add("lenses",...o.flatMap(a=>P(e,"calendar",s,"start",a))),t.add("acts",...m(e,s).filter(([,a])=>o.some(l=>(a.writes??[]).includes(l)||a.sets?.[l]!==void 0)).map(([a])=>a)),t.say(n.length>0?`${p(e,s)} repeat (${n[0]}).`:`${p(e,s)} come round again, each with when it was last done.`)}},comparison(e,t){for(let[s,r]of Object.entries(e.rules??{})){if(!r.require||!ye.test(r.require))continue;let n=r.over==="graph"?void 0:r.over,d=/in\('([^']+)'\)/.exec(r.require)?.[1],i=/all\('([^']+)'/.exec(r.require)?.[1],o=n?d?v(e).find(([,l])=>l.edges?.[d])?.[0]:void 0:i&&e.kinds[i]?i:void 0;if(!o&&!n)continue;let a=/==\s*'([^']+)'/.exec(r.require)?.[1];t.add("kinds",...o?[o]:[],...n?[n]:[]),t.add("rules",s),o&&a&&t.add("acts",...m(e,o).filter(([,l])=>Object.values(l.sets??{}).includes(a)).map(([l])=>l)),t.say(o&&n?`${p(e,o)} compared within each ${w(e,n)}, one ${a??"chosen"}.`:o?`${p(e,o)} compared, one ${a??"chosen"}.`:`One ${a??"chosen"} per ${w(e,n)}.`)}}};function E(e){let t=[];for(let s of k){let r=new G;ee[s](e,r),r.any()&&t.push(r.asTrait(s))}return t}function L(e,t){let s=new G;return ee[t](e,s),s.any()}var Oe=e=>Math.round(Math.max(0,Math.min(1,e))*100)/100;function q(e){return e?.type==="noul"&&Number.isFinite(e.noul)?Oe(e.noul):void 0}var Re={add:.7,drop:.7},Fe="propose_change";function Me(e){return M(e)}var De=e=>e.toLowerCase(),Te=e=>e.charAt(0).toUpperCase()+e.slice(1),O=(e,t="and")=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} ${t} ${e[e.length-1]}`,Se=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[-_]+/g," ").toLowerCase(),T=(e,t)=>{let s=e.kinds[t];return De(s?.plural??(s?.noun?`${s.noun}s`:`${Se(t)}s`))},xe=e=>k.includes(e),se=(e,t)=>k.indexOf(e)-k.indexOf(t);function je(e){let t=E(e),s=new Set(t.map(r=>r.trait));return{name:e.name,keeps:Object.keys(e.kinds).map(r=>T(e,r)),"made of":t.map(r=>r.said),lacks:k.filter(r=>!s.has(r)).map(r=>y[r])}}function Ne(e,t){let s=new Set(E(t).map(n=>n.trait)),r={};for(let n of k)s.has(n)||(r[`need:${n}`]={type:"noul",instructions:`Does what they asked for need ${y[n]}, which ${t.name} has no part for yet?`,criteria:{true:`It needs ${y[n]}: they asked for it, or what they asked for cannot be kept without it.`,false:"Not asked for, and not needed to keep what they asked for."}});for(let n of Object.keys(t.kinds)){let d=T(t,n);r[`drop:kind:${n}`]={type:"noul",instructions:`Did they ask ${t.name} to stop keeping ${d}?`,criteria:{true:`They said the ${d} go: to drop them, remove them or stop tracking them.`,false:`${Te(d)} stay: nothing they said asks for them to go.`}}}for(let n of k)s.has(n)&&(r[`drop:trait:${n}`]={type:"noul",instructions:`Did they ask ${t.name} to stop having ${y[n]}?`,criteria:{true:`They said it goes: to drop or stop ${y[n]}.`,false:"It stays: nothing they said asks for it to go."}});return{state:{said:e,app:je(t)},questions:r}}var te=/^drop:(kind|trait):(.+)$/s;function Ae(e,t={}){let s={...Re,...t},r=Object.keys(e);if(r.length===0)throw new Error("readReshape was handed no answers.");let n=r.filter(o=>!/^need:/.test(o)&&!te.test(o));if(n.length>0)throw new Error(`readReshape does not know the question ${n.map(o=>`"${o}"`).join(", ")}: it reads need:<trait>, drop:kind:<name> and drop:trait:<name>.`);let d={},i={};for(let[o,a]of Object.entries(e)){let l=te.exec(o);if(l){i[`${l[1]}:${l[2]}`]=q(a)??0;continue}let h=o.slice(5);xe(h)&&(d[h]=q(a)??0)}return{add:Object.keys(d).filter(o=>d[o]>=s.add).sort(se),drop:Object.entries(i).filter(([,o])=>o>=s.drop).map(([o])=>o.slice(o.indexOf(":")+1)),needs:d,drops:i}}function Ge(e){let{said:t,document:s}=e,r=[...new Set(e.add)].sort(se),n=[...new Set(e.drop)],d=E(s),i=r.filter(c=>!L(s,c)).map(c=>({what:"trait",name:c,words:y[c],brings:J[c]})),o=r.filter(c=>L(s,c)),a=Object.keys(s.kinds).filter(c=>n.includes(c)),l=d.filter(c=>n.includes(c.trait)&&!Object.hasOwn(s.kinds,c.trait)),h=[...a.map(c=>({what:"kind",name:c,words:T(s,c)})),...l.map(c=>({what:"trait",name:c.trait,words:y[c.trait]}))],C=Object.keys(s.kinds).filter(c=>!a.includes(c)).map(c=>({what:"kind",name:c,words:T(s,c)})),ne=[...a.map(c=>`All ${T(s,c)} records go, with their links.`),...l.flatMap(c=>{let F=[...c.fields,...c.relations];return F.length>0?[`What carries ${y[c.trait]} goes: ${O(F)}, with its values and links.`]:[]})],S=[];i.length>0&&S.push(`adds ${O(i.map(c=>c.words))}`),h.length>0&&S.push(`drops ${O(h.map(c=>c.words))}`),C.length>0&&S.push(`keeps ${O(C.map(c=>c.words))}`);let re=i.length+h.length===0?`Nothing in ${s.name} changes for that.`:`This ${O(S)}.`,ie=o.length>0?` ${s.name} already has ${O(o.map(c=>y[c]))}.`:"";return{said:t,add:i.map(c=>c.name),drop:h.map(c=>c.name),card:{said:`${re}${ie}`,adds:i,keeps:C,drops:h,breaking:ne}}}async function Ue(e){let{state:t,questions:s}=Ne(e.said,e.document),{answers:r,usage:n}=await e.decide(t,s),d=Ae(r,e.thresholds??{}),i=d.add.length+d.drop.length===0?null:Ge({said:e.said,document:e.document,add:d.add,drop:d.drop});return{proposal:i&&i.add.length+i.drop.length===0?null:i,reading:d,answers:r,usage:n}}export{Fe as a,Me as b,Ne as c,Ae as d,Ge as e,Ue as f};
1
+ import{c as M}from"./chunk.GXK5PI7I.js";import{ha as b}from"./chunk.ZDUKVXBI.js";var k=["owners","status","schedule","budget","places","sources","stock","votes","private","history","publishing","roster","routines","comparison"],y={owners:"people who own things",status:"a status that moves",schedule:"dates it is due by, or a schedule",budget:"money against a budget",places:"places",sources:"sources behind claims",stock:"counts in stock",votes:"votes or picks",private:"private to its owner",history:"a history, a record book",publishing:"content to publish",roster:"a roster of people",routines:"repeating routines",comparison:"a comparison to pick one from"},J={owners:"a person kind (or the people the app has), an owner link, Give it to someone, a rule that every one has somebody on it, and Who has what",status:"a status with named steps (or the one the app has), an act for each step, and a board",schedule:"a due date, Set the date, the on-time rule, and a calendar",budget:"a cost beside the money the app keeps, a budget on the kind it is grouped under, Set the budget, and the over-budget rule",places:"a place kind, a link to one, and a map of where things are",sources:"a source kind, a link from each claim to its source, and the rule that a claim names one",stock:"what is on hand and the reorder level, Count the stock, and the running-low rule",votes:"a vote on each, Vote for it, and a tally",private:"a sight that keeps each person's own records to them",history:"the record book: an era or season each belongs to, and a timeline",publishing:"a published status, Publish it, and what the public sees",roster:"a person kind with the fields a roster keeps, and the list of who is here",routines:"how often each repeats and when it was last done, Mark it done, and the overdue rule",comparison:"a side-by-side of the candidates, one chosen, and Choose it"},U=new Set(["person","people","member","user","player","guest","candidate","participant","traveler","volunteer","interviewer","interviewee","contact","trade","staff","student","employee","teammate","crew","attendee","friend","customer","client","driver","speaker","host","teacher","parent","kid","child","coach","patient","tenant","resident","neighbor","applicant","recruit","contributor","assignee","worker","collaborator","runner"]),K=new Set(["place","venue","location","room","site","building","store","warehouse","city","country","region","address","hall","stadium","office","shelf"]),z=new Set(["source","reference","citation","evidence"]),H=new Set(["season","era","period","epoch","edition","generation","age","campaign","tournament"]),ae=/owner|owned|assign|^lead$|responsible|^by$|^by-|done-?by|interviewer|reviewer|maker|author|keeper|givenby|^for-?person$/i,oe=/due|deadline|until|needed|needby|target|expires|^ends?(on|at)?$|^by$/i,de=/^(date|day|when|at|start|starts|startsat|startson|startdate|scheduled|scheduledfor|scheduledon|happens|happenson|held|heldon|from|time|exchangedate|.*date|.*day)$/i,le=/released|fixed|published|applied|checked|created|added|done|last|first|updated|seen|born|birth|founded|finished|completed|closed/i,X=/status|stage|state|phase|progress/i,W=/budget|limit|cap$|allowance/i,ce=/budget|cost|price|quote|amount|salary|fee|spend|total|paid|owed/i,pe=/^(place|location|venue|address|where|city|town)$/i,B=/reorder|onhand|instock|^stock|quantity|^qty/i,he=/^votes?$|votecount|upvotes|^score$|^points$/i,fe=/^(votes?|votesfor|votedby|voters|picks?|chooses|choices|favorites|likes)$/i,ue=/often|frequency|cadence|^every$|repeat|interval/i,ge=/^last/i,Q=/^(published|live|public)$/i,ye=/count\(.*\bwhere\b.*\)\s*<=\s*1\b/,u=e=>e.toLowerCase(),w=(e,t)=>u(e.kinds[t]?.noun??b(t)),$=(e,t)=>u(e.kinds[t]?.plural??`${w(e,t)}s`),me=e=>e.charAt(0).toUpperCase()+e.slice(1),p=(e,t)=>me($(e,t)),we=e=>/^[aeiou]/i.test(e)?"an":"a",x=(e,t="and")=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} ${t} ${e[e.length-1]}`,N=e=>new Set((e??"").split(/[^A-Za-z0-9_-]+/).filter(Boolean)),v=e=>Object.entries(e.kinds),m=(e,t)=>Object.entries(e.acts??{}).filter(([,s])=>[s.on??[]].flat().includes(t)),_=e=>Array.isArray(e.lenses)?e.lenses:[],I=e=>typeof e.title=="string"?e.title:void 0,A=e=>e.bindings&&typeof e.bindings=="object"?e.bindings:{},R=(e,t)=>Array.isArray(t)&&t.length===1&&typeof t[0]=="string"&&e.kinds[t[0]]?t[0]:void 0;function V(e,t){let s=e.kinds[t];if(!s)return!1;let r=n=>u(n).replace(/ll/g,"l");return s.people===!0||U.has(r(t))||U.has(r(w(e,t)))}var Y=(e,t)=>K.has(u(t))||K.has(w(e,t)),ke=(e,t)=>z.has(u(t))||z.has(w(e,t)),be=(e,t)=>H.has(u(t))||H.has(w(e,t)),$e=(e,t)=>(t.type==="number"||t.type==="integer")&&(t.format==="money"||ce.test(e)),j=e=>e.type==="date"||e.type==="datetime";function P(e,t,s,r,n){return _(e).filter(d=>d.name===t&&A(d)[s]?.[r]===n).map(I).filter(d=>d!==void 0)}function D(e,t,s,r){return _(e).filter(n=>n.name==="coverage"&&A(n)[s]?.kind===t&&(r===void 0||A(n).link?.edge===r)).map(I).filter(n=>n!==void 0)}function f(e,t,s){let r=new Set(t);return Object.entries(e.rules??{}).filter(([,n])=>(s===void 0||n.over==="graph"||s.includes(n.over))&&[...N(`${n.when??""} ${n.require??""} ${n.says??""}`)].some(d=>r.has(d))).map(([n])=>n)}var G=class{kinds=new Set;fields=new Set;relations=new Set;rules=new Set;lenses=new Set;acts=new Set;said;add=(t,...s)=>{for(let r of s)this[t].add(r)};say=t=>{this.said??=t};any=()=>this.kinds.size+this.fields.size+this.relations.size+this.rules.size+this.lenses.size+this.acts.size>0;asTrait=t=>({trait:t,words:y[t],said:this.said??y[t],kinds:[...this.kinds],fields:[...this.fields],relations:[...this.relations],rules:[...this.rules],lenses:[...this.lenses],acts:[...this.acts]})};function ve(e){let t;for(let[s,r]of v(e)){let n=Object.keys(r.fields).length+Object.keys(r.edges??{}).length;(!t||n>t.fields)&&(t={kind:s,fields:n})}return t?.kind}function g(e){let t=ve(e);return v(e).sort(([s],[r])=>+(r===t)-+(s===t))}function Z(e,t){let s=e.kinds[t];if(!s)return[];let r=[];for(let[n,d]of Object.entries(s.fields)){if(d.type!=="enum"||!Array.isArray(d.options)||d.options.length<2)continue;let i=m(e,t).filter(([,a])=>typeof a.sets?.[n]=="string"&&d.options.includes(a.sets[n])).map(([a])=>a);((X.test(n)||s.lifecycle?.field===n)&&i.length>=1||i.length>=2)&&r.push({field:n,options:d.options,steps:i})}return r}var ee={owners(e,t){for(let[s,r]of g(e))for(let[n,d]of Object.entries(r.edges??{})){let i=R(e,d.to);d.cardinality!=="one"||!i||!V(e,i)||!ae.test(n)||(t.add("kinds",s,i),t.add("relations",`${s}.${n}`),t.add("rules",...f(e,[n],[s,i])),t.add("lenses",...D(e,s,"rows",n)),t.add("acts",...m(e,s).filter(([,o])=>o.connects===n||o.severs===n).map(([o])=>o)),t.say(`Each ${w(e,s)} has one of the ${$(e,i)} on it (${n}).`))}},status(e,t){for(let[s]of g(e))for(let{field:r,options:n,steps:d}of Z(e,s))t.add("kinds",s),t.add("fields",`${s}.${r}`),t.add("acts",...d),t.add("rules",...f(e,[r],[s])),t.add("lenses",...P(e,"columns",s,"column",r)),t.say(`${p(e,s)} move through ${x(n.map(u))}.`)},schedule(e,t){for(let[s,r]of g(e))for(let[n,d]of Object.entries(r.fields)){if(!j(d)||le.test(n))continue;let i=P(e,"calendar",s,"start",n),o=oe.test(n);if(!o&&!de.test(n)&&i.length===0)continue;t.add("kinds",s),t.add("fields",`${s}.${n}`),t.add("lenses",...i),t.add("rules",...f(e,[n],[s])),t.add("acts",...m(e,s).filter(([,l])=>(l.writes??[]).includes(n)||l.sets?.[n]!==void 0).map(([l])=>l));let a=/date|day|when|time/i.test(n)?u(b(n)):`date (${n})`;t.say(o?`${p(e,s)} are due by a date (${n}).`:`${p(e,s)} have ${we(a)} ${a}${i.length>0?", on a calendar":""}.`)}},budget(e,t){let s=v(e).flatMap(([o,a])=>Object.entries(a.fields).filter(([l,h])=>(h.type==="number"||h.type==="integer")&&W.test(l)).map(([l])=>({kind:o,name:l})));if(s.length===0)return;let r=g(e).flatMap(([o,a])=>Object.entries(a.fields).filter(([l,h])=>$e(l,h)&&!W.test(l)).map(([l])=>({kind:o,name:l})));if(r.length===0)return;let n=[...s,...r].map(o=>o.name);for(let o of[...s,...r])t.add("kinds",o.kind),t.add("fields",`${o.kind}.${o.name}`),t.add("acts",...m(e,o.kind).filter(([,a])=>(a.writes??[]).includes(o.name)||a.sets?.[o.name]!==void 0).map(([a])=>a));t.add("rules",...f(e,n).filter(o=>s.some(a=>N(e.rules[o].require??"").has(a.name))));let d=r[0],i=s.find(o=>o.kind===d.kind)??s[0];t.say(`${p(e,d.kind)}' ${u(b(d.name))} against ${i.kind===d.kind?"each one's":`each ${w(e,i.kind)}'s`} ${u(b(i.name))}.`)},places(e,t){for(let[s,r]of g(e)){Y(e,s)&&(t.add("kinds",s),t.add("lenses",...D(e,s,"columns")));for(let[n,d]of Object.entries(r.edges??{})){let i=R(e,d.to);!i||!Y(e,i)||(t.add("kinds",s,i),t.add("relations",`${s}.${n}`),t.add("rules",...f(e,[n],[s,i])),t.say(`${p(e,s)} are at ${$(e,i)} (${n}).`))}for(let[n,d]of Object.entries(r.fields))d.type!=="place"&&!(d.type==="string"&&pe.test(n))||(t.add("kinds",s),t.add("fields",`${s}.${n}`),t.say(`${p(e,s)} say where (${n}).`))}t.any()&&!t.said&&t.say(`${x([...t.kinds].map(s=>p(e,s)))} are places.`)},sources(e,t){for(let[s,r]of g(e)){for(let[n,d]of Object.entries(r.edges??{})){let i=R(e,d.to);!i||!ke(e,i)&&!/^cite/i.test(n)||(t.add("kinds",s,i),t.add("relations",`${s}.${n}`),t.add("rules",...f(e,[n,i],[s,i])),t.add("acts",...m(e,s).filter(([,o])=>o.connects===n||o.severs===n).map(([o])=>o)),t.say(`${p(e,s)} cite ${$(e,i)} (${n}).`))}for(let[n,d]of Object.entries(r.fields))d.type!=="url"||!/^source/i.test(n)||(t.add("kinds",s),t.add("fields",`${s}.${n}`),t.add("rules",...f(e,[n],[s])),t.say(`${p(e,s)} link to their source (${n}).`))}},stock(e,t){for(let[s,r]of g(e)){let n=Object.entries(r.fields).filter(([a,l])=>(l.type==="number"||l.type==="integer")&&B.test(a)).map(([a])=>a),d=Object.keys(r.computed??{}).filter(a=>B.test(a)),i=n.some(a=>/reorder/i.test(a)),o=v(e).some(([,a])=>Object.entries(a.fields).some(([l,h])=>/^(change|delta|moved)$/i.test(l)&&(h.type==="number"||h.type==="integer")));!i&&!(d.length+n.length>0&&o)||(t.add("kinds",s),t.add("fields",...n.map(a=>`${s}.${a}`),...d.map(a=>`${s}.${a}`)),t.add("rules",...f(e,[...n,...d],[s])),t.add("acts",...m(e,s).filter(([,a])=>n.some(l=>(a.writes??[]).includes(l)||a.sets?.[l]!==void 0)).map(([a])=>a)),t.say(`${p(e,s)} have a count in stock${i?" and a reorder point":""}.`))}},votes(e,t){for(let[s,r]of g(e)){for(let[n,d]of Object.entries(r.fields)){if(d.type!=="number"&&d.type!=="integer"||!he.test(n))continue;let i=m(e,s).filter(([,o])=>o.sets?.[n]!==void 0).map(([o])=>o);i.length!==0&&(t.add("kinds",s),t.add("fields",`${s}.${n}`),t.add("acts",...i),t.add("rules",...f(e,[n],[s])),t.say(`${p(e,s)} collect votes (${n}).`))}for(let[n,d]of Object.entries(r.edges??{})){let i=R(e,d.to);!i||!fe.test(n)||(t.add("kinds",s,i),t.add("relations",`${s}.${n}`),t.add("rules",...f(e,[n],[s,i])),t.add("acts",...m(e,s).filter(([,o])=>o.connects===n||o.severs===n).map(([o])=>o)),t.say(`${p(e,s)} pick ${$(e,i)} (${n}).`))}}},private(e,t){let s=[];for(let r of e.policy?.sees??[])if(!(!r.own&&!r.via)){for(let n of r.kinds)if(e.kinds[n]&&(t.add("kinds",n),s.includes(n)||s.push(n),r.via))for(let[d,i]of v(e))i.edges?.[r.via]&&t.add("relations",`${d}.${r.via}`)}s.length>0&&t.say(`${x(s.map(r=>p(e,r)))} are seen only by whose they are.`)},history(e,t){for(let[s,r]of g(e))for(let[n,d]of Object.entries(r.edges??{})){let i=R(e,d.to);d.cardinality!=="one"||!i||!be(e,i)||!Object.entries(r.fields).some(([a,l])=>j(l)||/year|result|outcome|score|finish/i.test(a))||(t.add("kinds",s,i),t.add("relations",`${s}.${n}`),t.add("rules",...f(e,[n,i],[s,i])),t.add("lenses",...D(e,s,"rows",n),..._(e).filter(a=>a.name==="timeline"&&A(a)[s]!==void 0).map(I).filter(a=>a!==void 0)),t.say(`${p(e,s)} grouped into ${$(e,i)}, a record book.`))}},publishing(e,t){for(let[s,r]of g(e)){let n=Object.entries(r.fields).filter(([,i])=>i.type==="text").map(([i])=>i);if(n.length===0)continue;let d=Z(e,s).map(i=>i.field);for(let[i,o]of Object.entries(r.fields)){if(o.type!=="enum"||!(X.test(i)||d.includes(i))||!(o.options??[]).some(l=>Q.test(l)))continue;let a=(o.options??[]).find(l=>Q.test(l));t.add("kinds",s),t.add("fields",`${s}.${i}`,...n.map(l=>`${s}.${l}`)),t.add("acts",...m(e,s).filter(([,l])=>l.sets?.[i]===a).map(([l])=>l)),t.add("rules",...f(e,[i,...n],[s]).filter(l=>N(`${e.rules[l].when??""} ${e.rules[l].require??""}`).has(a)||n.some(h=>N(e.rules[l].require??"").has(h)))),t.say(`${p(e,s)} go from ${u(o.options[0])} to ${u(a)}, with their words.`)}}},roster(e,t){for(let[s,r]of g(e)){if(!V(e,s))continue;let n=Object.keys(r.fields);n.length<2||(t.add("kinds",s),t.add("fields",...n.map(d=>`${s}.${d}`)),t.add("lenses",...D(e,s,"columns"),...D(e,s,"rows")),t.say(`${p(e,s)}, with ${x(n.slice(1).map(d=>u(b(d))))}.`))}},routines(e,t){for(let[s,r]of g(e)){let n=Object.entries(r.fields).filter(([,a])=>j(a)&&a.repeats===!0).map(([a])=>a),d=Object.entries(r.fields).filter(([a,l])=>(l.type==="enum"||l.type==="string"||l.type==="integer"||l.type==="number")&&ue.test(a)).map(([a])=>a),i=Object.entries(r.fields).filter(([a,l])=>j(l)&&ge.test(a)).map(([a])=>a);if(n.length===0&&!(d.length>0&&i.length>0))continue;let o=[...n,...d,...i];t.add("kinds",s),t.add("fields",...o.map(a=>`${s}.${a}`)),t.add("rules",...f(e,o,[s])),t.add("lenses",...o.flatMap(a=>P(e,"calendar",s,"start",a))),t.add("acts",...m(e,s).filter(([,a])=>o.some(l=>(a.writes??[]).includes(l)||a.sets?.[l]!==void 0)).map(([a])=>a)),t.say(n.length>0?`${p(e,s)} repeat (${n[0]}).`:`${p(e,s)} come round again, each with when it was last done.`)}},comparison(e,t){for(let[s,r]of Object.entries(e.rules??{})){if(!r.require||!ye.test(r.require))continue;let n=r.over==="graph"?void 0:r.over,d=/in\('([^']+)'\)/.exec(r.require)?.[1],i=/all\('([^']+)'/.exec(r.require)?.[1],o=n?d?v(e).find(([,l])=>l.edges?.[d])?.[0]:void 0:i&&e.kinds[i]?i:void 0;if(!o&&!n)continue;let a=/==\s*'([^']+)'/.exec(r.require)?.[1];t.add("kinds",...o?[o]:[],...n?[n]:[]),t.add("rules",s),o&&a&&t.add("acts",...m(e,o).filter(([,l])=>Object.values(l.sets??{}).includes(a)).map(([l])=>l)),t.say(o&&n?`${p(e,o)} compared within each ${w(e,n)}, one ${a??"chosen"}.`:o?`${p(e,o)} compared, one ${a??"chosen"}.`:`One ${a??"chosen"} per ${w(e,n)}.`)}}};function E(e){let t=[];for(let s of k){let r=new G;ee[s](e,r),r.any()&&t.push(r.asTrait(s))}return t}function L(e,t){let s=new G;return ee[t](e,s),s.any()}var Oe=e=>Math.round(Math.max(0,Math.min(1,e))*100)/100;function q(e){return e?.type==="noul"&&Number.isFinite(e.noul)?Oe(e.noul):void 0}var Re={add:.7,drop:.7},Fe="propose_change";function Me(e){return M(e)}var De=e=>e.toLowerCase(),Te=e=>e.charAt(0).toUpperCase()+e.slice(1),O=(e,t="and")=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} ${t} ${e[e.length-1]}`,Se=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[-_]+/g," ").toLowerCase(),T=(e,t)=>{let s=e.kinds[t];return De(s?.plural??(s?.noun?`${s.noun}s`:`${Se(t)}s`))},xe=e=>k.includes(e),se=(e,t)=>k.indexOf(e)-k.indexOf(t);function je(e){let t=E(e),s=new Set(t.map(r=>r.trait));return{name:e.name,keeps:Object.keys(e.kinds).map(r=>T(e,r)),"made of":t.map(r=>r.said),lacks:k.filter(r=>!s.has(r)).map(r=>y[r])}}function Ne(e,t){let s=new Set(E(t).map(n=>n.trait)),r={};for(let n of k)s.has(n)||(r[`need:${n}`]={type:"noul",instructions:`Does what they asked for need ${y[n]}, which ${t.name} has no part for yet?`,criteria:{true:`It needs ${y[n]}: they asked for it, or what they asked for cannot be kept without it.`,false:"Not asked for, and not needed to keep what they asked for."}});for(let n of Object.keys(t.kinds)){let d=T(t,n);r[`drop:kind:${n}`]={type:"noul",instructions:`Did they ask ${t.name} to stop keeping ${d}?`,criteria:{true:`They said the ${d} go: to drop them, remove them or stop tracking them.`,false:`${Te(d)} stay: nothing they said asks for them to go.`}}}for(let n of k)s.has(n)&&(r[`drop:trait:${n}`]={type:"noul",instructions:`Did they ask ${t.name} to stop having ${y[n]}?`,criteria:{true:`They said it goes: to drop or stop ${y[n]}.`,false:"It stays: nothing they said asks for it to go."}});return{state:{said:e,app:je(t)},questions:r}}var te=/^drop:(kind|trait):(.+)$/s;function Ae(e,t={}){let s={...Re,...t},r=Object.keys(e);if(r.length===0)throw new Error("readReshape was handed no answers.");let n=r.filter(o=>!/^need:/.test(o)&&!te.test(o));if(n.length>0)throw new Error(`readReshape does not know the question ${n.map(o=>`"${o}"`).join(", ")}: it reads need:<trait>, drop:kind:<name> and drop:trait:<name>.`);let d={},i={};for(let[o,a]of Object.entries(e)){let l=te.exec(o);if(l){i[`${l[1]}:${l[2]}`]=q(a)??0;continue}let h=o.slice(5);xe(h)&&(d[h]=q(a)??0)}return{add:Object.keys(d).filter(o=>d[o]>=s.add).sort(se),drop:Object.entries(i).filter(([,o])=>o>=s.drop).map(([o])=>o.slice(o.indexOf(":")+1)),needs:d,drops:i}}function Ge(e){let{said:t,document:s}=e,r=[...new Set(e.add)].sort(se),n=[...new Set(e.drop)],d=E(s),i=r.filter(c=>!L(s,c)).map(c=>({what:"trait",name:c,words:y[c],brings:J[c]})),o=r.filter(c=>L(s,c)),a=Object.keys(s.kinds).filter(c=>n.includes(c)),l=d.filter(c=>n.includes(c.trait)&&!Object.hasOwn(s.kinds,c.trait)),h=[...a.map(c=>({what:"kind",name:c,words:T(s,c)})),...l.map(c=>({what:"trait",name:c.trait,words:y[c.trait]}))],C=Object.keys(s.kinds).filter(c=>!a.includes(c)).map(c=>({what:"kind",name:c,words:T(s,c)})),ne=[...a.map(c=>`All ${T(s,c)} records go, with their links.`),...l.flatMap(c=>{let F=[...c.fields,...c.relations];return F.length>0?[`What carries ${y[c.trait]} goes: ${O(F)}, with its values and links.`]:[]})],S=[];i.length>0&&S.push(`adds ${O(i.map(c=>c.words))}`),h.length>0&&S.push(`drops ${O(h.map(c=>c.words))}`),C.length>0&&S.push(`keeps ${O(C.map(c=>c.words))}`);let re=i.length+h.length===0?`Nothing in ${s.name} changes for that.`:`This ${O(S)}.`,ie=o.length>0?` ${s.name} already has ${O(o.map(c=>y[c]))}.`:"";return{said:t,add:i.map(c=>c.name),drop:h.map(c=>c.name),card:{said:`${re}${ie}`,adds:i,keeps:C,drops:h,breaking:ne}}}async function Ue(e){let{state:t,questions:s}=Ne(e.said,e.document),{answers:r,usage:n}=await e.decide(t,s),d=Ae(r,e.thresholds??{}),i=d.add.length+d.drop.length===0?null:Ge({said:e.said,document:e.document,add:d.add,drop:d.drop});return{proposal:i&&i.add.length+i.drop.length===0?null:i,reading:d,answers:r,usage:n}}export{Fe as a,Me as b,Ne as c,Ae as d,Ge as e,Ue as f};
@@ -0,0 +1 @@
1
+ var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{r as Fe}from"./chunk.PVAYYFT2.js";import{a as Je,b as Ee,f as He,g as je,l as Ie,m as ze,n as Le}from"./chunk.OXDCGGZV.js";import{a as We}from"./chunk.VGQDPEB5.js";import{e as X}from"./chunk.53GQQETN.js";import{a as j}from"./chunk.DYPSFTRP.js";import{f as $e,g as Y,i as De}from"./chunk.P3Z4ZCL3.js";import{a as be}from"./chunk.T6ISUVUP.js";import{Ha as me,Ka as K,Ma as he,Mb as ve,O as pe,Oa as ye,Pa as Z,Pd as Pe,Rd as Me,Sd as Ne,Wa as ge,Xa as we,Yb as Ae,_a as ke,a as fe,ec as Oe,fc as Re,jc as _e,mc as Te,na as G,pb as q,pc as C,tb as Se,xc as xe}from"./chunk.ZDUKVXBI.js";var E=(t,e,n)=>{(t[e]===void 0||n>t[e])&&(t[e]=n)},H=(t,e,n)=>{(t[e]===void 0||n<t[e])&&(t[e]=n)},Q=(t,e)=>{t.format=e,e.includes("int")&&(t.isInt=!0)},qe=(t,e)=>{t.mime=t.mime?t.mime.filter(n=>e.includes(n)):[...e]},Ce=(t,e)=>{t.multipleOf??=[],t.multipleOf.includes(e)||t.multipleOf.push(e)},Be=(t,e)=>(t.patterns??=new Set).add(e),gt={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 I(t){let e={},{def:n,bag:o}=t._zod,i=t._zod.traits.has("$ZodCheck")?[t,...n.checks??[]]:n.checks??[];for(let r of i){let a=r._zod.def;switch(a.check){case"greater_than":E(e,a.inclusive?"minimum":"exclusiveMinimum",a.value);break;case"less_than":H(e,a.inclusive?"maximum":"exclusiveMaximum",a.value);break;case"multiple_of":Ce(e,a.value);break;case"number_format":{Q(e,a.format);let d=gt[a.format];d&&(E(e,"minimum",d[0]),H(e,"maximum",d[1]));break}case"bigint_format":Q(e,a.format);break;case"min_length":case"min_size":E(e,"minimum",a.minimum);break;case"max_length":case"max_size":H(e,"maximum",a.maximum);break;case"length_equals":E(e,"minimum",a.length),H(e,"maximum",a.length);break;case"size_equals":E(e,"minimum",a.size),H(e,"maximum",a.size);break;case"string_format":Q(e,a.format),a.pattern&&Be(e,a.pattern),(a.format==="base64"||a.format==="base64url")&&(e.contentEncoding=a.format),(a.local||a.precision===-1)&&(e.laxFormat=!0);break;case"mime_type":qe(e,a.mime);break}}o.minimum!==void 0&&E(e,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&E(e,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&H(e,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&H(e,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&Ce(e,o.multipleOf),o.format!==void 0&&(e.format??=o.format,o.format.includes("int")&&(e.isInt=!0)),o.mime&&qe(e,o.mime);for(let r of o.patterns??[])Be(e,r);return e}var wt={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""};function L(t){let e=t._zod.def;return e.type==="pipe"&&e.in._zod.traits.has("$ZodTransform")?L(e.out):e.type==="catch"?L(e.innerType):t._zod.optin}var kt=new Set(["promise","optional","nonoptional","nullable","readonly","default","prefault","catch"]);function T(t,e=new Set){if(e.has(t))return!1;e.add(t);let n=t._zod.def,o=n.type;return o==="transform"?!0:o==="array"?T(n.element,e):o==="set"?T(n.valueType,e):o==="lazy"?T(n.getter(),e):kt.has(o)?T(n.innerType,e):o==="intersection"?T(n.left,e)||T(n.right,e):o==="record"||o==="map"?T(n.keyType,e)||T(n.valueType,e):o==="pipe"?t._zod.traits.has("$ZodCodec")||T(n.in,e)||T(n.out,e):o==="object"?Object.values(n.shape).some(i=>T(i,e)):o==="union"?n.options.some(i=>T(i,e)):o==="tuple"?n.items.some(i=>T(i,e))||(n.rest?T(n.rest,e):!1):!1}function bt(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n])=>e.indexOf(+n)===-1).map(([,n])=>n)}function Ge(t){let e=t.anyOf;if(!Array.isArray(e)||e.length===0||t.type!==void 0)return;let n=[];for(let o of e){if(!o||typeof o!="object")return;Ge(o);let i=Object.keys(o);if(i.length!==1||i[0]!=="type")return;for(let r of[o.type].flat()){if(typeof r!="string")return;n.includes(r)||n.push(r)}}delete t.anyOf,t.type=n.length===1?n[0]:n}var Ke=new Set(["type","properties","required","additionalProperties"]),Ue=t=>{let e=t.additionalProperties;return e&&typeof e=="object"&&Object.keys(e).length?e:null},Ve=(t,e)=>JSON.stringify(t)===JSON.stringify(e);function ee(t){for(let i of t){if(typeof i!="object"||i.type!=="object")return null;for(let r in i)if(!Ke.has(r))return null}let e={},n=new Set;for(let i of t){for(let r in i.properties){if(Object.prototype.hasOwnProperty.call(e,r))continue;let a=[];for(let d of t){let s=d.properties?.[r]??Ue(d);s&&!a.some(g=>Ve(g,s))&&a.push(s)}e[r]=a.length===1?a[0]:ee(a)??{allOf:a}}for(let r of i.required??[])n.add(r)}let o={type:"object",properties:e};if(n.size&&(o.required=[...n]),t.every(i=>i.additionalProperties===!1))o.additionalProperties=!1;else{let i=[];for(let r of t){let a=Ue(r);a&&!i.some(d=>Ve(d,a))&&i.push(a)}i.length===1?o.additionalProperties=i[0]:i.length>1&&(o.additionalProperties={allOf:i})}return o}function St(t){let e=t.allOf;if(!Array.isArray(e)||e.length<2)return;for(let i of Ke)if(i in t)return;let n=e.filter(i=>Array.isArray(i.oneOf)||Array.isArray(i.anyOf)),o;if(!n.length)o=ee(e);else{let i=n[0],r=Array.isArray(i.oneOf)?"oneOf":"anyOf";if(Object.keys(i).length!==1)return;let a=e.filter(s=>s!==i),d=i[r].map(s=>ee([...a,s]));if(d.some(s=>!s))return;o={[r]:d}}o&&(delete t.allOf,Object.assign(t,o))}function Ze(t){let e=t;for(let k of["anyOf","oneOf"]){let R=e[k];if(!Array.isArray(R))continue;let v=R.map(Ze);v.some((A,m)=>A!==R[m])&&(e={...e,[k]:v})}let n=[e.type].flat(),o=!n.includes("string")&&n.some(k=>k==="number"||k==="integer"),i=e.enum??(e.const!==void 0?[e.const]:void 0);if(!o&&!i?.some(k=>typeof k=="number"))return e;let{minimum:r,maximum:a,exclusiveMinimum:d,exclusiveMaximum:s,multipleOf:g,format:p,id:w,...h}=e;return h.enum?h.enum=h.enum.map(k=>typeof k=="number"?String(k):k):typeof h.const=="number"&&(h.const=String(h.const)),o&&(h.type="string",i||(h.pattern=n.includes("number")?"^-?\\d+(?:\\.\\d+)?$":"^-?\\d+$")),h}var B=class{constructor(e,n){this.override=e;this.refs=n}done=new Map;path=[];cyclic=new Map;write(e,n=!1){let o=this.refs.get(e);if(o!==void 0&&!n)return{$ref:o};if(this.path.includes(e))return this.cyclic.has(e)||this.cyclic.set(e,""),{};let i=this.done.get(e);if(i)return i;this.path.push(e);try{let r=this.written(e);return this.done.set(e,r),r}finally{this.path.pop()}}written(e){let n={},o,i=e._zod.toJSONSchema?.();i?Object.assign(n,i):o=this.process(e,n);let r=fe.get(e);if(r)for(let d of Object.keys(r))n[d]=r[d];T(e)&&(delete n.examples,delete n.default),"_prefault"in n&&(n.default??=n._prefault,delete n._prefault);let a=n;if(o){let d=this.write(o);a={...n};for(let s of Object.keys(d))s in n||(a[s]=d[s])}return this.override({zodSchema:e,jsonSchema:a}),Ge(a),e._zod.def.type==="intersection"&&St(a),a}process(e,n){let o=e._zod.def;switch(o.type){case"string":{n.type="string";let{minimum:i,maximum:r,format:a,patterns:d,contentEncoding:s,laxFormat:g}=I(e);if(typeof i=="number"&&(n.minLength=i),typeof r=="number"&&(n.maxLength=r),a&&(n.format=wt[a]??a,(n.format===""||a==="time"||g)&&delete n.format),s&&(n.contentEncoding=s),d&&d.size>0){let p=[...d];p.length===1?n.pattern=p[0].source:n.allOf=p.map(w=>({pattern:w.source}))}return}case"number":{let{minimum:i,maximum:r,multipleOf:a,exclusiveMinimum:d,exclusiveMaximum:s,isInt:g}=I(e);if(n.type=g?"integer":"number",typeof d=="number"&&d>=(i??Number.NEGATIVE_INFINITY)?n.exclusiveMinimum=d:typeof i=="number"&&(n.minimum=i),typeof s=="number"&&s<=(r??Number.POSITIVE_INFINITY)?n.exclusiveMaximum=s:typeof r=="number"&&(n.maximum=r),a){let[p,...w]=new Set(a.filter(h=>Number.isFinite(h)&&h!==0).map(Math.abs));p!==void 0&&(n.multipleOf=p),w.length&&(n.allOf=[...n.allOf??[],...w.map(h=>({multipleOf:h}))])}return}case"boolean":case"success":n.type="boolean";return;case"null":n.type="null";return;case"never":n.not={};return;case"enum":{let i=bt(o.entries);i.length===0?n.not={}:(i.every(r=>typeof r=="number")&&(n.type="number"),i.every(r=>typeof r=="string")&&(n.type="string"),n.enum=i);return}case"literal":{let i=o.values.filter(r=>r!==void 0).map(r=>typeof r=="bigint"?Number(r):r);if(o.values.length===0)n.not={};else if(i.length===1)n.type=i[0]===null?"null":typeof i[0],n.const=i[0];else if(i.length>1){for(let r of["number","string","boolean"])i.every(a=>typeof a===r)&&(n.type=r);i.every(r=>r===null)&&(n.type="null"),n.enum=i}return}case"template_literal":n.type="string",n.pattern=e._zod.pattern.source;return;case"file":{n.type="string",n.format="binary",n.contentEncoding="binary";let{minimum:i,maximum:r,mime:a}=I(e);i!==void 0&&(n.minLength=i),r!==void 0&&(n.maxLength=r),a&&(a.length===0?n.not={}:a.length===1?n.contentMediaType=a[0]:n.anyOf=a.map(d=>({contentMediaType:d})));return}case"array":{let{minimum:i,maximum:r}=I(e);typeof i=="number"&&(n.minItems=i),typeof r=="number"&&(n.maxItems=r),n.type="array",n.items=this.write(o.element);return}case"object":{let i=o.shape;n.type="object";let r={};n.properties=r;for(let d in i)Object.defineProperty(r,d,{value:this.write(i[d]),writable:!0,enumerable:!0,configurable:!0});let a=Object.keys(i).filter(d=>L(i[d])===void 0);a.length>0&&(n.required=a),o.catchall?._zod.def.type==="never"?n.additionalProperties=!1:o.catchall&&(n.additionalProperties=this.write(o.catchall));return}case"union":n[o.inclusive===!1?"oneOf":"anyOf"]=o.options.map(i=>this.write(i));return;case"intersection":{let i=d=>"allOf"in d&&Object.keys(d).length===1,r=this.write(o.left),a=this.write(o.right);n.allOf=[...i(r)?r.allOf:[r],...i(a)?a.allOf:[a]];return}case"tuple":{let i=o.items;n.type="array",n.prefixItems=i.map(s=>this.write(s)),o.rest?n.items=this.write(o.rest):n.items=!1;let r=i.length;for(;r>0&&L(i[r-1])!==void 0;)r-=1;r>0&&(n.minItems=r),o.rest||(n.maxItems=i.length);let{minimum:a,maximum:d}=I(e);typeof a=="number"&&(n.minItems=a),typeof d=="number"&&(n.maxItems=d);return}case"record":{let i=o.keyType;n.type="object";let r=I(i).patterns;if(o.mode==="loose"&&r&&r.size>0){let d=this.write(o.valueType),s={};for(let g of r)s[g.source]=d;n.patternProperties=s}else n.propertyNames=Ze(this.write(i)),n.additionalProperties=this.write(o.valueType);let a=i._zod.values;if(a&&!o.partial&&L(o.valueType)===void 0){let d=[...a].filter(s=>typeof s=="string"||typeof s=="number");d.length>0&&(n.required=d.map(String))}return}case"nullable":n.anyOf=[this.write(o.innerType),{type:"null"}];return;case"default":case"prefault":{let i=o.defaultValue,r,a=!1,d=JSON.stringify(i,(s,g)=>typeof g=="bigint"?(a=!0,null):g);return!a&&d!==void 0&&(r=JSON.parse(d)),a||(n[o.type==="default"?"default":"_prefault"]=r),o.innerType}case"catch":{try{n.default=o.catchValue(void 0)}catch{}return o.innerType}case"readonly":return n.readOnly=!0,o.innerType;case"pipe":return o.in._zod.traits.has("$ZodTransform")?o.out:o.in;case"lazy":return e._zod.innerType;case"optional":case"nonoptional":case"promise":return o.innerType;default:return}}};function Ye(t,e=()=>{}){let n=t,o=new B(e,new Map),i=o.write(n,!0);if(o.cyclic.size>0){let r=new Map,a=0,d=[];for(let g of o.cyclic.keys())if(g===n)r.set(g,"#");else{let p=`__schema${a++}`;r.set(g,`#/$defs/${p}`),d.push([g,p])}o=new B(e,r),i=o.write(n,!0);let s={};for(let[g,p]of d)s[p]=o.write(g,!0);d.length>0&&(i={...i,$defs:s})}return JSON.parse(JSON.stringify({$schema:"https://json-schema.org/draft/2020-12/schema",...i}))}function Xe(t){return Ye(t,Ot)}var vt={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string"},At={phone:"A phone number as it is written, like +1 555 123 4567 or 020 7946 0958 ext. 12.",place:"An address or a place's name, as a person would search a map for it.",duration:"A length of time in whole minutes: 90 is 1 h 30 min."};function Ot(t){me(t.zodSchema)&&(t.jsonSchema["x-graview-app-link"]=!0);let e=ye(t.zodSchema);if(e&&(t.jsonSchema.type==="string"||t.jsonSchema.type==="array")){t.jsonSchema["x-graview-linked"]={address:e.address,kinds:[...e.kinds],cardinality:e.cardinality};let s=e.kinds.join(" or "),g=`${e.cardinality==="many"?"Records":"A record"}: a ${s} in the app ${e.address}, as "${e.kinds[0]}:<id>" \u2014 an id found there with find_linked. Linking never changes that app.`,p=t.jsonSchema.description;typeof p=="string"&&p.includes(g)||(t.jsonSchema.description=`${typeof p=="string"&&p?`${p.replace(/\.?$/,".")} `:""}${g}`)}if(ke(t.zodSchema)&&(t.jsonSchema["x-graview-repeat"]=!0,!t.jsonSchema.type&&!t.jsonSchema.anyOf&&!t.jsonSchema.oneOf&&Object.assign(t.jsonSchema,Rt())),be(t.zodSchema)){t.jsonSchema.contentMediaType="text/markdown";let s=t.jsonSchema.description;typeof s=="string"&&s.endsWith("Written in Markdown.")||(t.jsonSchema.description=`${typeof s=="string"&&s?`${s.replace(/\.?$/,".")} `:""}Written in Markdown.`)}let n=Te(t.zodSchema);if(n){let s=t.jsonSchema;s["x-graview-type"]=n,n==="duration"&&(s["x-graview-unit"]="minutes"),s.description??=At[n]}let o=_e(t.zodSchema,!1);if(o){let s=$e(o);t.jsonSchema["x-graview-format"]=s.format??"unit",s.currency&&(t.jsonSchema["x-graview-currency"]=s.currency),s.unit&&s.format!=="money"&&(t.jsonSchema["x-graview-unit"]=s.unit);let g=t.jsonSchema.description;t.jsonSchema.description=typeof g=="string"&&g.length>0?`${g} ${Y(s)}`:Y(s)}let i=t.zodSchema._zod?.def;if(!i||i.type!=="string"||typeof i.format!="string"||i.format==="regex")return;let r=t.jsonSchema,a=(i.checks??[]).map(s=>s._zod?.def).filter(s=>s?.format==="regex"&&s.pattern instanceof RegExp).map(s=>s.pattern.source);delete r.pattern;let d=r.allOf;Array.isArray(d)&&d.every(s=>typeof s=="object"&&s!==null&&Object.keys(s).length===1&&"pattern"in s)&&delete r.allOf,r.format=vt[i.format]??i.format,a.length===1?r.pattern=a[0]:a.length>1&&(r.allOf=a.map(s=>({pattern:s})))}function te(t,e){let n=C(t.input),o=Xe(t.input);if(e&&o.properties){let r=a=>e.includes(a)?e.indexOf(a):e.length;o.properties=Object.fromEntries(Object.entries(o.properties).sort(([a],[d])=>r(a)-r(d)))}let i=o.properties??{};if(Oe(t)){let r=t.creates.join(" | ");i.id={type:"string",minLength:1,description:`Optional: the id for the ${r} this makes, beginning with its kind (${t.creates.map(a=>`"${a}:"`).join(" or ")}). Refused if the graph already has it; left out, one is minted from the label.`},o.properties=i}Re(t)&&(o.additionalProperties=!1);for(let r of n){let a=i[r.name];if(!a)continue;let d=r.kinds.includes("*")?"any node kind":r.kinds.join(" | ");a.description=[a.description,`Id of a node (${d}).`].filter(Boolean).join(" ")}return{name:t.name,...t.title===void 0?{}:{title:t.title},description:t.description??t.title??t.name,inputSchema:o,nodeRefs:n}}function Rt(){let t={type:"string",pattern:"^\\d{4}-\\d{2}-\\d{2}$"},e=(n,o)=>({type:"integer",minimum:n,maximum:o});return{type:"object",description:'How the date beside it repeats; the date is the first occurrence. "on" is weekdays for "week", days of the month (-1 the last) for "month".',properties:{every:{type:"string",enum:[...we]},interval:e(1,99),on:{type:"array",minItems:1,maxItems:31,items:{anyOf:[{type:"string",enum:[...ge]},e(-1,31)]}},until:t,count:e(1,1e3),except:{type:"array",maxItems:500,items:t},continues:{type:"string",maxLength:200}},required:["every"],additionalProperties:!1}}function Qe(t){let e=new Set;for(let n=t;n;n=n.onBehalfOf)n.id!==void 0&&e.add(`${n.kind}:${n.id}`);return e}function U(t,e){let n=Qe(e),o=p=>{if(p.kind==="rule")return!1;let w=Qe(p);if(w.size===0)return!1;for(let h of w)if(n.has(h))return!1;return!0},i,r=()=>{if(i)return i;i=new Map;for(let p of t.log.live()){if(p.undoes!==void 0)continue;let w=o(p.author)?p.author:void 0;for(let h of p.primitives){h.op==="remove-node"&&i.delete(h.node.id);let k=h.op==="add-node"?h.node.id:h.op==="patch-node"||h.op==="splice-text"?h.id:void 0;if(k===void 0)continue;let R=h.op==="add-node"?Object.keys(h.node):h.op==="splice-text"?[h.field]:Object.keys(h.after),v=i.get(k);(h.op==="add-node"||!v)&&i.set(k,v=new Map);for(let A of R)A==="id"||A==="kind"||(w?v.set(A,w):v.delete(A))}}return i},a=t.schema,d=new Map,s=(p,w)=>{let h=`${p}\0${w}`,k=d.get(h);if(k===void 0){let R=a.tryDefinition(p)?.fields?.shape;k=R!==void 0&&w in R&&De(R[w]).type==="text",d.set(h,k)}return k},g=p=>t.graph.getNode(p)?.kind;return{prose:s,say:p=>q(p,{graph:t.graph,schema:a}),fieldBy(p,w){let h=g(p);if(!(h===void 0||!s(h,w)))return r().get(p)?.get(w)},recordBy(p){let w=g(p),h=r().get(p);if(w===void 0||!h)return;let k;for(let[R,v]of h)s(w,R)&&(k=v);return k}}}var ne=(t,e,n)=>({untrusted:!0,authoredBy:n.say(e),text:t}),_t="the host's ranker";function et(t,e){return{...t,hits:t.hits.map(n=>{if(n.about!=="node")return n;n.why.by==="meaning"&&n.why.matched!==void 0&&(n={...n,why:{...n.why,matched:{untrusted:!0,authoredBy:_t,text:n.why.matched}}});let o=e.recordBy(n.id);if(!o)return n;let i=e.prose(n.kind,n.why.field)?e.fieldBy(n.id,n.why.field):o;return{...n,label:ne(n.label,o,e),...n.apart!==void 0?{apart:ne(n.apart,o,e)}:{},why:i?{...n.why,fragment:ne(n.why.fragment,i,e)}:n.why}})}}var ie=(t,e,n)=>({title:t,readOnlyHint:e,destructiveHint:!1,idempotentHint:n,openWorldHint:!1}),Tt={name:"subscribe",title:"Notify me when something happens",description:`Subscribe the person you act for to be told when something happens in this app \u2014 their host delivers it (an email, a push). on is one of: "act" (an act runs; give act, its declared name, and/or record), "created" (a record of kind is added), "changed" (a record of kind, or the one record, changes), "reaches" (a record of kind, or the one record, comes to satisfy condition, an expression in the app's rule language such as done == true or amount > 100). They are told only of changes someone else made, unless alsoMine is true, and only of records they may see. Returns the subscription and its sentence. Changes nothing in the app.`,inputSchema:{type:"object",properties:{on:{type:"string",enum:["act","created","changed","reaches"],description:"What to be told of."},act:{type:"string",description:"An act's declared name, for on: act."},kind:{type:"string",description:"A kind, for created, changed and reaches."},record:{type:"string",description:"One record, by id or name: for act, changed and reaches."},condition:{type:"string",description:"For reaches: what the record should come to satisfy, in the rule language (done == true)."},alsoMine:{type:"boolean",description:"Also when the person themselves made the change; false when unsaid."}},required:["on"],additionalProperties:!1},mutating:!1,annotations:ie("Notify me when something happens",!1,!1)},xt={name:"unsubscribe",title:"Stop notifying me",description:"Take away one of the person's subscriptions, by the id list_subscriptions or subscribe answered. Changes nothing in the app.",inputSchema:{type:"object",properties:{id:{type:"string",description:"The subscription's id."}},required:["id"],additionalProperties:!1},mutating:!1,annotations:ie("Stop notifying me",!1,!0)},Pt={name:"list_subscriptions",title:"What I am notified of",description:`List what the person you act for is told of in this app: each subscription's id and its sentence ("When someone else adds a task").`,inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:ie("What I am notified of",!0,!0)},oe=[Tt,xt,Pt];var it=t=>({type:"string",enum:[...t],description:"The workflow, by its name."}),tt=t=>({name:"run_workflow",title:"Run a workflow now",description:"Run one of the app's workflows now, by hand, as the app's own actor: its steps make, change, set aside or suggest what they say, as its approve setting says. With dryRun: true nothing is kept and the answer says what it would do. The first run after a workflow is added or changed is a dry run whatever you ask; run it again to keep it. A paused workflow only dry-runs. Returns the run: its outcome, what it made, changed, archived and suggested, what it held back and why.",inputSchema:{type:"object",properties:{name:it(t),dryRun:{type:"boolean",description:"Keep nothing; say what it would do. False when unsaid."}},required:["name"],additionalProperties:!1},mutating:!0,annotations:{title:"Run a workflow now",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1}}),nt=(t,e)=>({name:t?"pause_workflow":"resume_workflow",title:t?"Pause a workflow":"Resume a workflow",description:t?"Pause one of the app's workflows: it runs on no schedule and no change until it is resumed, and run_workflow only dry-runs it. Changes the app's declaration, not its records. Returns the edit that takes it back.":"Resume a paused workflow: it runs again on its schedule and the changes it waits for. Changes the app's declaration, not its records. Returns the edit that takes it back.",inputSchema:{type:"object",properties:{name:it(e)},required:["name"],additionalProperties:!1},mutating:!0,annotations:{title:t?"Pause a workflow":"Resume a workflow",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}),ot=["run_workflow","pause_workflow","resume_workflow"];function rt(t,e){return e===void 0||t.length===0?[]:e==="manage"?[tt(t),nt(!0,t),nt(!1,t)]:[tt(t)]}function Mt(t){return{run:t.id,workflow:t.workflow,outcome:t.outcome,dry:t.dry,made:t.made,changed:t.changed,archived:t.archived,suggested:t.suggested,heldBack:t.heldBack,notes:t.notes}}async function at(t,e,n){let o=n.workflows.declared(),i=o.map(w=>w.name),r=String(e.name??"");if(!i.includes(r))return{ok:!1,error:`No workflow is called "${r}". The app's workflows are: ${i.join(", ")||"none"}. Nothing was changed.`,reason:"invalid"};if(t==="run_workflow"){let w=await n.workflows.run(r,{dryRun:e.dryRun===!0,...n.principal.id!==void 0?{who:n.principal.id}:{}});return{ok:!0,data:Mt(w)}}let a=n.workflows.edit;if(!a)return{ok:!1,error:"This seat's host does not write the app's declaration, so it cannot pause or resume a workflow. Nothing was changed.",reason:"forbidden"};let d=t==="pause_workflow",s=o.find(w=>w.name===r),g=s.status;if(g==="paused"===d)return{ok:!0,data:{workflow:r,status:g,said:`\u201C${s.title}\u201D is already ${g}. Nothing was changed.`}};let p=await a({op:d?"pause-workflow":"resume-workflow",name:r});return p.ok?{ok:!0,data:{workflow:r,status:d?"paused":"active",...p.said?{said:p.said}:{},undo:{op:d?"resume-workflow":"pause-workflow",name:r}}}:{ok:!1,error:p.error}}var F=t=>{let e;return()=>e??=t().catch(n=>{throw e=void 0,n})},Nt=F(()=>(__graviewPreload(import.meta.url,["./chunk.GYP3EF6Z.js","./chunk.O5P6LXHF.js","./chunk.53GQQETN.js","./chunk.J7GH2CGV.js","./chunk.SMF5S4DQ.js","./chunk.XP4IVKKR.js","./chunk.R5YGW5ZX.js","./chunk.QMGBAKX6.js","./chunk.PS765ODQ.js","./chunk.P3Z4ZCL3.js","./chunk.45OLF6BK.js","./chunk.T6ISUVUP.js","./chunk.ZDUKVXBI.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.HUJLELZ3.js"))),$t=()=>(__graviewPreload(import.meta.url,["./chunk.DYPSFTRP.js","./chunk.R5YGW5ZX.js","./chunk.QMGBAKX6.js","./chunk.PS765ODQ.js","./chunk.ZDUKVXBI.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.MNH3WUAB.js")).catch(()=>{}),Dt=async()=>{(await $t())?.judgeWithLines()},W=F(()=>(__graviewPreload(import.meta.url,["./chunk.WVUJXDXZ.js","./chunk.J7GH2CGV.js","./chunk.SMF5S4DQ.js","./chunk.XP4IVKKR.js","./chunk.R5YGW5ZX.js","./chunk.QMGBAKX6.js","./chunk.PS765ODQ.js","./chunk.45OLF6BK.js","./chunk.T6ISUVUP.js","./chunk.ZDUKVXBI.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.W2VSEEKX.js"))),Jt=F(()=>(__graviewPreload(import.meta.url,["./chunk.IZKCTF2R.js","./chunk.G4JJXA63.js","./chunk.TBY5IR7C.js","./chunk.JP33TNCH.js","./chunk.BIDL7GQD.js","./chunk.O5P6LXHF.js","./chunk.ONVYKLRX.js","./chunk.XOZU4OFA.js","./chunk.53GQQETN.js","./chunk.Q5WEOX3Q.js","./chunk.7DCBIMOI.js","./chunk.GXK5PI7I.js","./chunk.DYPSFTRP.js","./chunk.WVUJXDXZ.js","./chunk.J7GH2CGV.js","./chunk.SMF5S4DQ.js","./chunk.XP4IVKKR.js","./chunk.R5YGW5ZX.js","./chunk.QMGBAKX6.js","./chunk.PS765ODQ.js","./chunk.T3RFZ66S.js","./chunk.TDWJU6GW.js","./chunk.P3Z4ZCL3.js","./chunk.45OLF6BK.js","./chunk.T6ISUVUP.js","./chunk.ZDUKVXBI.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.XYBWBMNU.js"))),Et=F(()=>(__graviewPreload(import.meta.url,["./chunk.JOB3EKS6.js","./chunk.GYP3EF6Z.js","./chunk.O5P6LXHF.js","./chunk.VGQDPEB5.js","./chunk.WIVNFOQR.js","./chunk.53GQQETN.js","./chunk.J7GH2CGV.js","./chunk.SMF5S4DQ.js","./chunk.XP4IVKKR.js","./chunk.R5YGW5ZX.js","./chunk.QMGBAKX6.js","./chunk.PS765ODQ.js","./chunk.T3RFZ66S.js","./chunk.TDWJU6GW.js","./chunk.P3Z4ZCL3.js","./chunk.45OLF6BK.js","./chunk.T6ISUVUP.js","./chunk.ZDUKVXBI.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.OUJV4CYS.js"))),Ht=F(()=>(__graviewPreload(import.meta.url,["./chunk.NKRDVOLJ.js","./chunk.YC2IDHQX.js","./chunk.R5YGW5ZX.js","./chunk.QMGBAKX6.js","./chunk.PS765ODQ.js","./chunk.ZDUKVXBI.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.G2ZDDO3C.js")));var jt=t=>t.definitions.some(e=>Z(e).size>0),st=t=>({value:K(t),label:t.label,...t.describe?{describe:t.describe}:{},...t.card?{card:t.card}:{},fields:t.fields,...t.app?{app:t.app}:{}});async function It(t,e,n,o){let i=String(n.relation??""),[r,a]=i.includes(".")?i.split(".",2):[void 0,i],d=t.schema.definitions.flatMap(A=>[...Z(A)].map(([m,u])=>({kind:A.kind,name:m,relation:u}))),s=d.filter(A=>A.name===a&&(r===void 0||A.kind===r));if(s.length!==1){let A=d.map(m=>`${m.kind}.${m.name}`).join(", ")||"none";return{ok:!1,error:`${s.length===0?`No relation to another app is called "${i}"`:`"${i}" names a relation of several kinds`}. The relations to other apps are: ${A}.`}}let{kind:g,name:p,relation:w}=s[0];if(!o)return{ok:!1,error:`This seat cannot read ${w.address}: its host reads no other app's records. Nothing was changed.`};let h={kind:e.kind,...e.id===void 0?{}:{id:e.id},...e.roles?{roles:e.roles}:{},...e.onBehalfOf?{onBehalfOf:e.onBehalfOf}:{}},k=typeof n.of=="string"?n.of:void 0;if(k!==void 0){let A=t.graph.getNode(k);if(!A||A.kind!==g)return{ok:!1,error:`No ${g} "${k}".`};let m=he(A[p],w),u=await Promise.all(m.map(b=>Promise.resolve().then(()=>o.resolve(b,h)).catch(()=>null)));return{ok:!0,data:{relation:`${g}.${p}`,app:w.address,records:u.map((b,S)=>b===null?{value:K(m[S]),missing:!0}:"denied"in b?{denied:!0,said:"linked record (no access)"}:st(b))},reads:[k]}}let R=typeof n.limit=="number"&&n.limit>0?Math.min(n.limit,20):20,v=await Promise.resolve().then(()=>o.find({address:w.address,kinds:w.kinds,query:String(n.query??""),limit:R},h)).catch(()=>[]);return Array.isArray(v)?{ok:!0,data:{relation:`${g}.${p}`,app:w.address,records:v.map(st),link:`edit-${g} with ${p} set to a record's value`}}:{ok:!0,data:{relation:`${g}.${p}`,app:w.address,denied:!0,said:"linked record (no access)"}}}var M=t=>({title:t,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}),dt={description:'Which records: false (the default) the live ones, true only the archived ones, "all" both. An archived record is set aside, not gone: unarchive-<kind> brings it back.',anyOf:[{type:"boolean"},{type:"string",enum:["all"]}]},re={type:"number",description:"Where the page starts; 0 when unsaid."},se=[{name:"search_graph",title:"Find by name",description:"Find things by name: records whose name or readable fields carry the words, and the kinds, places and rules the words name \u2014 each with why it matched. Reach for this before get_graph when you know what something is called. Words match the start of words, case and accents aside; key:value tokens narrow as a list's filter does (done:false, is:any for past records, kind:<kind>). Pass subject (a node id) to get the acts you may run on it as hits too. When few records match exactly, records with a near word follow \u2014 a typo, another form of the word, a meaning \u2014 each with near: true and why.matched, the record's own word that answered.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Words, with optional key:value conditions."},limit:{type:"number",description:"Most hits to return; at most 20."},subject:{type:"string",description:"A node id whose acts to include."},archived:dt},required:["query"],additionalProperties:!1},mutating:!1,annotations:M("Find by name")},{name:"get_graph",title:"Read the graph",description:"Read the graph, 25 nodes a page: their fields, the edges out of them, and how many more. Start here when you need the shape of the domain rather than one thing in it.",inputSchema:{type:"object",properties:{offset:re,archived:dt},additionalProperties:!1},mutating:!1,annotations:M("Read the graph")},{name:"get_node",title:"Read one node",description:"Read one node: its fields, its links (id, kind and label, 20 each way a page), the violations that implicate it, and its computed values: read-only fields worked out from what you can see, which no act sets. Use this to check a thing before you change it.",inputSchema:{type:"object",properties:{id:{type:"string",description:"A node's id, or its name."},offset:re},required:["id"],additionalProperties:!1},mutating:!1,annotations:M("Read one node")},{name:"get_violations",title:"List the problems",description:"List the invariant violations the graph currently has, 20 a page, with the repairs that would resolve each one. Read this before proposing work: a rule that is already broken is more urgent than anything you could add.",inputSchema:{type:"object",properties:{offset:re,context:{type:"object",description:"Evaluation context, e.g. { weekStart }."}},additionalProperties:!1},mutating:!1,annotations:M("List the problems")},{name:"get_affordances",title:"Ask what can be done",description:"Ask what can legally be done with a selection, ranked. Prefer these over composing a mutation by hand: they are derived from the schema, the invariants and the shape of the graph, so they cannot name an action that does not exist.",inputSchema:{type:"object",properties:{selection:{type:"array",items:{type:"string"},description:"Node ids."},context:{type:"object"}},required:["selection"],additionalProperties:!1},mutating:!1,annotations:M("Ask what can be done")},{name:"describe_place",title:"Say what a place shows",description:`Say what one place of the app shows you, as a person in your seat would see it: its headings, its figures as drawn, its lists with each record's title and what its card or row says, the headings a list is grouped under, what an empty list says, the forms it offers (each field in the order asked, its label, whether it must be answered, what it takes and its choices), and any block that could not be worked out. Pass a place's slug ("home", a lens's address like "the-offers", a kind's like "offers"), a record's id, or a visitor form's "forms/<name>", and width 390 for a phone. Use it after a change to check what somebody now sees, instead of guessing.`,inputSchema:{type:"object",properties:{place:{type:"string",description:`"home", a place's slug, a record's id, or "forms/<name>" for a visitor form.`},width:{type:"number",description:"The screen's width in CSS pixels; 390 is a phone, 1440 when unsaid."}},required:["place"],additionalProperties:!1},mutating:!1,annotations:M("Say what a place shows")},{name:"preview_mutation",title:"Try an act without applying it",description:"Try a mutation without applying it: get back the diff it would produce and any invariant it would break. Do this when you are unsure, rather than applying and undoing.",inputSchema:{type:"object",properties:{mutation:{type:"string"},args:{type:"object"}},required:["mutation","args"],additionalProperties:!1},mutating:!1,annotations:M("Try an act without applying it")},{name:"undo_batch",title:"Undo a batch",description:"Undo one batch of operations. Fails, naming the blocking operation, when a later operation read what it wrote.",inputSchema:{type:"object",properties:{batch:{type:"string"},include:{type:"array",items:{type:"string"}}},required:["batch"],additionalProperties:!1},mutating:!0,annotations:{title:"Undo a batch",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}},{name:"list_suggestions",title:"List what is suggested",description:"List the suggestions waiting for a person: changes the app's own actor proposed and did not make, each with its id, what it would do, who suggested it, what it was based on and how sure (0 to 1), and the votes on it (tally: for, against, and this seat's own as mine). Nothing changes until one is accepted (accept_suggestion) or declined (decline_suggestion); a declined one is never suggested again.",inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:M("List what is suggested")},{name:"accept_suggestion",title:"Accept a suggestion",description:`Make a waiting suggestion's change, as this seat, carrying what it was based on. Returns the batch (undo_batch takes it back). From a seat that may see the suggestion and may not make the change, it records this seat's vote for it instead (voted: "for"; a later vote replaces it) and the suggestion still waits for someone who may.`,inputSchema:{type:"object",properties:{suggestion:{type:"string",description:"The suggestion's id, from list_suggestions."}},required:["suggestion"],additionalProperties:!1},mutating:!0,annotations:{title:"Accept a suggestion",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1}},{name:"decline_suggestion",title:"Decline a suggestion",description:`Decline a waiting suggestion: nothing changes, the decline is kept in the log, and the same change is never suggested or made by the app's own actor again. From a seat that may not make the change, it records this seat's vote against it instead (voted: "against") and the suggestion still waits.`,inputSchema:{type:"object",properties:{suggestion:{type:"string",description:"The suggestion's id, from list_suggestions."}},required:["suggestion"],additionalProperties:!1},mutating:!0,annotations:{title:"Decline a suggestion",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}],lt={name:"act_on_several",title:"Do one act to several records",description:`Run one act on several records at once, as one change with one undo. act is the act (its tool name or its declared name), records the records it runs on (ids or names; each goes in the act's subject), args what every call shares ("Set stage to Declined" is args { stage: "declined" }). Each record is judged on its own: one this seat may not change is named with why, and the rest still apply. Returns the batch (undo_batch takes it all back), the records changed, those already so, and those refused.`,inputSchema:{type:"object",properties:{act:{type:"string",description:"The act to run on each record."},records:{type:"array",items:{type:"string"},minItems:1,maxItems:200,description:"Ids or names of the records."},args:{type:"object",description:"Arguments every call shares, besides the record."}},required:["act","records"],additionalProperties:!1},mutating:!0,annotations:{title:"Do one act to several records",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}},ue={name:"suggest_changes",title:"Suggest changes",description:"Keep calls ({ act, args }) as one suggestion a person accepts or declines, with its basis and confidence (0 to 1). Changes nothing; a declined change is refused.",inputSchema:{type:"object",properties:{calls:{type:"array",items:{type:"object"}},basis:{type:"string"},confidence:{type:"number"}},required:["calls","basis"]},mutating:!0,annotations:{title:"Suggest changes",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},ut={name:"propose_changes",title:"Propose changes for review",description:"Propose calls ({ act, args }) this seat may not run as one proposal that somebody who may run them accepts or declines, with what it is for in the person's words (intent). Changes nothing now; each call is judged as it would be for the reviewer, and an act this seat may neither run nor propose is refused. Returns the proposal's id (list_suggestions shows it waiting).",inputSchema:{type:"object",properties:{calls:{type:"array",items:{type:"object",properties:{act:{type:"string"},args:{type:"object"}},required:["act","args"]}},intent:{type:"string",description:"What the proposal is for, in words: 1 to 500 characters."}},required:["calls"],additionalProperties:!1},mutating:!0,annotations:{title:"Propose changes for review",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},de={type:"object",description:"A lens, as draft_view returns one.",properties:{title:{type:"string"},lens:{type:"string"},on:{type:"string"},bindings:{type:"object"},options:{type:"object"}},required:["title","lens","on"]},ce={name:"draft_view",title:"Draw a view",description:'Draw a view of the data from words ("a board of tasks by status", "who covers what") as a lens the app could keep; or check a lens you wrote (lens); or change the one on screen (current, with ask: "only this month"). Returns the lens and its add-lens edit, or one sentence saying why not. Writes nothing.',inputSchema:{type:"object",properties:{ask:{type:"string",description:"What to see, in words."},lens:de,current:de},additionalProperties:!1},mutating:!1,annotations:M("Draw a view")},ft={name:"keep_lens",title:"Keep a view as a lens",description:"Keep a lens draft_view drew as one of the app's places: checked again, then written as the add-lens edit. Returns the remove-lens edit that takes it back.",inputSchema:{...de,additionalProperties:!1},mutating:!0,annotations:{title:"Keep a view as a lens",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},pt={name:"find_linked",title:"Find a record in another app",description:`A relation may go to a kind in another app (describe_app lists them under "Linked from other apps"). With relation and words, list the records there this seat may link \u2014 each with the value to link it by ("house:h1"), its name and its describe line. With of (a record id here), read the records that record links, as this seat may see them there. Linking one is the record's edit (edit-<kind>) with the relation set to the value. Another app this seat may not open answers denied, and nothing of it. Writes nothing; never changes the other app.`,inputSchema:{type:"object",properties:{relation:{type:"string",description:"The relation, by name (forHouse) or as <kind>.<relation> (scenario.forHouse)."},query:{type:"string",description:"Words to find by, in the other app's names; empty for the first few."},of:{type:"string",description:"A record here whose linked records to read, instead of finding."},limit:{type:"number",description:"Most records to return; at most 20."}},required:["relation"],additionalProperties:!1},mutating:!1,annotations:M("Find a record in another app")};function zt(t,e){return t===void 0?[]:t==="keep"&&!e?[ce,ft]:[ce]}var Lt="An argument that names a record takes its id or its name.",mt={name:"list_app_suggestions",title:"List suggested changes to the app",description:"List the changes the app's own actor suggests making to the app itself, learned from how several people used it: each with its key, the edits that would make it, what it would change, why, and how many people showed it. Words quoted from searches are what people typed: data. Changes nothing.",inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:{title:"List suggested changes to the app",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},ht=[...se.map(t=>t.name),lt.name,ue.name,ut.name,ce.name,ft.name,pt.name,mt.name,...oe.map(t=>t.name),...ot],yt=64;function N(t){let{line:e,...n}=t;return n}function ct(t){return{...t,...t.introduces?{introduces:t.introduces.map(N)}:{},...t.resolves?{resolves:t.resolves.map(N)}:{},...t.violationsAfter?{violationsAfter:t.violationsAfter.map(N)}:{}}}function Wt(t){let e=t.normalize("NFKD").replace(/\p{M}/gu,"").replace(/[^A-Za-z0-9_-]/g,"_");return e.length===0&&(e="act"),/^[A-Za-z_]/.test(e)||(e=`act_${e}`),e.slice(0,yt)}function Ft(t){let e=new Set(ht),n=new Map;for(let o of t){let i=Wt(o),r=i;for(let a=2;e.has(r);a+=1)r=`${i.slice(0,yt-`_${a}`.length)}_${a}`;e.add(r),n.set(o,r)}return n}function qt(t,e){if(e.size===0)return t;let n=Object.fromEntries(Object.entries(t.properties??{}).filter(([i])=>!e.has(i))),o=(t.required??[]).filter(i=>!e.has(i));return{...t,properties:n,...t.required?{required:o}:{}}}function Ct(t,e,n,o){let i=te(t,xe(o,t)),r=G(t),a=i.nodeRefs.length>0?`${i.description}${/[.!?]$/.test(i.description)?"":"."} ${Lt}`:i.description;return{name:e,title:r,description:a,inputSchema:qt(i.inputSchema,n),mutating:!0,annotations:{title:r,readOnlyHint:!1,destructiveHint:t.destructive===!0||(t.severs?.length??0)>0,idempotentHint:t.idempotent===!0,openWorldHint:!1},act:t.name}}function le(t){if(t===null||typeof t!="object")return JSON.stringify(t)??"null";if(Array.isArray(t))return`[${t.map(le).join(",")}]`;let e=t;return`{${Object.keys(e).filter(n=>e[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${le(e[n])}`).join(",")}}`}function Bt(t){return`sha256:${Pe(le(t))}`}function Ut(t,e,n,o,i,r=!1,a=!1,d=!1,s,g=!1,p=[],w=!1){let h=Ft(t.map(v=>v.name)),k=[...zt(o,n),...r?[pt]:[],...a?oe:[],...g?[mt]:[]];return{definitions:n?[...se.filter(v=>!v.mutating),...k]:[...se,lt,...d?[ue]:[],...w?[ut]:[],...k,...p,...t.filter(v=>e.has(v.name)).map(v=>Ct(v,h.get(v.name),i(v),s))],names:h}}function Wn(t,e={}){let n=e.author??{kind:"agent"},o=t.allMutations(),i=new Set(t.permittedMutations(n).map(m=>m.name)),{definitions:r,names:a}=Ut(o,i,e.readOnly===!0,e.drafts?e.drafts.keep?"keep":"draw":void 0,m=>X(t.schema,t.policy,n,m),jt(t.schema),e.subscriptions!==void 0,ve(n),t.schema,e.learned!==void 0,rt(e.workflows?.declared().map(m=>m.name)??[],e.workflows?e.workflows.edit?"manage":"run":void 0),Le(t.policy,n,o).length>0),d=Bt(r),s={app:e.app?.brand?.locale,appTimeZone:e.app?.brand?.timeZone},g=m=>pe(s,m),p=m=>{if(!ht.includes(m)){for(let[u,b]of a)if(b===m)return u;return a.has(m)?m:Me(m,a.keys())}},w=m=>{let u=Ne(m,a.keys());return u?` Did you mean "${u}"?`:""},h=m=>{let u=r.find(S=>S.name===m)??r.find(S=>S.act===m);if(u)return u;let b=p(m);return b===void 0?void 0:r.find(S=>S.act===b)},k=(m,u)=>{let b=o.find(l=>l.name===m);if(!b)return{args:u,resolved:[]};let S={...u},c=[];for(let l of C(b.input)){let f=S[l.name];if(typeof f!="string"||f.trim()==="")continue;let y=t.resolveRef(l,f,n);if(!y.ok){let O=y.reason==="none"?` Nothing was changed. Use search_graph to look it up, then pass its id as ${l.name}.`:" Nothing was changed.";return{ok:!1,error:`${y.message}${O}`,argument:l.name,candidates:y.candidates}}y.by!=="id"&&(S[l.name]=y.id,c.push({argument:l.name,given:f,id:y.id,label:y.label}))}return{args:S,resolved:c}},R=async(m,u)=>{try{await Dt();let b=h(m);if(!b&&m===ue.name)return{ok:!1,error:"Only the app's own actor (automated: true) suggests changes.",reason:"forbidden"};if(!b){let c=p(m);if(c){let l=t.permits({name:c,args:u},n);if(!l.ok)return{ok:!1,error:l.refusal.message,reason:"forbidden"}}return{ok:!1,error:`Unknown tool "${m}".${w(m)} Available: ${r.map(l=>l.name).join(", ")}`}}if(b.mutating&&e.readOnly)return{ok:!1,error:`"${m}" changes the graph, and this seat is read-only.`,reason:"forbidden"};if(b.act!==void 0){let c=k(b.act,u);if("ok"in c)return c;let l=b.act,f=g(()=>j(t,n,t.apply({name:l,args:c.args},{...e.author?{author:e.author}:{},...V(e.via)})));return{ok:!0,data:{batch:f.batch,intent:f.intent,introduces:f.introduces.map(N),resolves:f.resolves.map(N),...c.resolved.length>0?{resolved:c.resolved}:{}},diff:f.diff}}let S=t.seenBy(n);switch(b.name){case"search_graph":{let c=typeof e.places=="function"?e.places():e.places,l=typeof u.subject=="string"?u.subject:void 0,f=Fe(S,String(u.query??""),{principal:n,rank:e.near,archived:Se(u.archived),limit:typeof u.limit=="number"&&u.limit>0?Math.min(u.limit,20):20,...c?{places:c}:{},...l?{subject:l,from:[l]}:{}}),y=f.later?await f.later:f;return{ok:!0,data:(await W()).searchRead(y,et(y,U(S,n))),reads:y.hits.flatMap(O=>O.about==="node"?[O.id]:[])}}case"get_graph":return{ok:!0,...(await W()).graphRead(S,U(S,n),u)};case"get_node":{let c=String(u.id??""),l=c,f;if(!S.graph.getNode(c)){let O=c.trim()===""?void 0:t.resolveRef({name:"id",kinds:["*"]},c,n);if(O?.ok)l=O.id,f={argument:"id",given:c,id:l,label:O.label};else return O?.reason==="ambiguous"?{ok:!1,error:O.message,argument:"id",candidates:O.candidates}:{ok:!1,error:`No node "${c}".`}}let y=(await W()).nodeRead(S,U(S,n),l,u);return{ok:!0,data:f?{...y.data,resolved:[f]}:y.data,reads:y.reads}}case"describe_place":{let c=e.app??{name:"",schema:t.schema},l=typeof u.width=="number"&&Number.isFinite(u.width)&&u.width>0?u.width:1440,{describePlace:f}=await Nt(),y=f(t,n,String(u.place??""),{app:c,width:l});if(!y.ok)return{ok:!1,error:`${y.error} The places are: ${y.places.join(", ")}.`};let O=new Set,P=z=>{for(let D of z)for(let x of D.groups??[])for(let $ of x.items)O.add($.id),P($.parts)};return P(y.description.parts),{ok:!0,data:y.description,reads:[...O]}}case"find_linked":return It(S,n,u,e.linked);case"draft_view":case"keep_lens":{let c=e.app??{name:"",schema:t.schema};return(await Jt()).runDraftTool(b.name,u,{app:c,principal:n,...e.drafts?{drafts:e.drafts}:{}})}case"get_violations":{let c=S.violations(u.context);return{ok:!0,...(await W()).violationsRead(c,u)}}case"get_affordances":{let c=u.selection??[];return{ok:!0,data:We(S,c,{...typeof e.derive=="function"?e.derive():e.derive,...e.author?{principal:e.author}:{},...u.context?{context:u.context}:{}}),reads:c.filter(f=>S.graph.has(f))}}case"preview_mutation":{let c=String(u.mutation),l=p(c)??c,f=k(l,u.args??{});if("ok"in f)return f;let y=t.missingFor({name:l,args:f.args},n);if(y)return{ok:!1,error:y.message,reason:"missing"};let O=j(t,n,t.preview({name:l,args:f.args},void 0,{author:n})),P=ct(O);return{ok:!0,data:f.resolved.length>0?{...P,resolved:f.resolved}:P}}case"act_on_several":{let c=String(u.act??""),l=p(c)??c,f=o.find(_=>_.name===l);if(!f||!i.has(l)){let _=f?t.permits({name:l,args:{}},n):void 0;return _&&!_.ok?{ok:!1,error:_.refusal.message,reason:"forbidden"}:{ok:!1,error:`There is no act "${c}" this seat may run.${w(c)} Nothing was changed.`,reason:"invalid"}}let y=f.subject;if(!y)return{ok:!1,error:`"${G(f)}" does not act on a record, so it cannot be run on several. Nothing was changed.`,reason:"invalid"};let O=Array.isArray(u.records)?u.records.filter(_=>typeof _=="string"&&_.trim()!==""):[];if(O.length===0)return{ok:!1,error:"Name at least one record. Nothing was changed.",reason:"invalid"};let P=[],z=[];for(let _ of O.slice(0,200)){let J=t.resolveRef({name:y.arg,kinds:y.kinds},_,n);if(!J.ok)return{ok:!1,error:`${J.message} Nothing was changed.`,argument:"records",candidates:J.candidates};P.push(J.id),J.by!=="id"&&z.push({argument:"records",given:_,id:J.id,label:J.label})}let D=k(l,{...u.args??{}});if("ok"in D)return D;let x=(await Et()).actOnSeveral(t,{mutation:l,subject:y.arg,args:D.args},P,{author:n,...V(e.via)}),$=x.result?j(t,n,x.result):void 0;return{ok:!0,data:{...x.batch?{batch:x.batch,intent:x.intent}:{},applied:x.applied,unchanged:x.unchanged,refused:x.refused.map(_=>({record:_.id,label:_.label,error:_.message,reason:_.reason})),...x.allOrNothing?{keptNone:!0}:{},...$?{introduces:$.introduces.map(N),resolves:$.resolves.map(N)}:{},...z.length>0||D.resolved.length>0?{resolved:[...z,...D.resolved]}:{}},...$?{diff:$.diff}:{}}}case"subscribe":case"unsubscribe":case"list_subscriptions":{let c=await(await Ht()).runSubscriptionTool(b.name,u,{store:t,principal:e.subscriber??n,app:e.app?.name??"app",subscriptions:e.subscriptions});return c.ok?{ok:!0,data:c.data}:{ok:!1,error:c.error}}case"run_workflow":case"pause_workflow":case"resume_workflow":{let c=await at(b.name,u,{principal:n,workflows:e.workflows});return c.ok?{ok:!0,data:c.data}:{ok:!1,error:c.error,...c.reason?{reason:c.reason}:{}}}case"list_app_suggestions":return{ok:!0,data:{suggestions:(await e.learned()).map(({key:l,said:f,why:y,edits:O,evidence:P})=>({key:l,said:f,why:y,edits:O,evidence:P}))}};case"list_suggestions":{let c=Ee(t,n).map(l=>{let f=q(l.author,{graph:S.graph,schema:t.schema});return{id:l.id,intent:l.intent,by:f,at:l.at,about:l.about,tally:l.tally,...Ie(l)?{proposedBy:l.lineage.proposedBy}:{},...l.lineage?{basis:{untrusted:!0,authoredBy:f,text:l.lineage.basis},...l.lineage.confidence!==void 0?{confidence:l.lineage.confidence}:{}}:{}}});return{ok:!0,data:{suggestions:c},reads:[...new Set(c.flatMap(l=>l.about))]}}case"suggest_changes":{let c=u.calls.map(f=>({name:p(f.act)??f.act,args:f.args}));return{ok:!0,data:{suggestion:Je(t,c,{author:n,lineage:{basis:u.basis,confidence:u.confidence},...V(e.via)})?.id??null}}}case"propose_changes":{let c=(u.calls??[]).map(y=>({name:p(y.act)??y.act,args:y.args??{}})),l=typeof u.intent=="string"&&u.intent.trim()!==""?u.intent.trim():void 0,f=ze(t,n,c,l);return{ok:!0,data:{proposal:f?.id??null,...f?{intent:f.intent}:{}}}}case"accept_suggestion":case"decline_suggestion":{let c=String(u.suggestion??""),l={author:n,...V(e.via)},f=b.name==="accept_suggestion"?He(t,c,l):je(t,c,l),y=j(t,n,f);return{ok:!0,data:{batch:y.batch,intent:y.intent,...f.voted?{voted:f.voted}:{},introduces:y.introduces.map(N),resolves:y.resolves.map(N)},diff:y.diff}}case"undo_batch":{let c=String(u.batch),l=u.include??[],f=S.canUndo([c,...l]);if(!f.ok)return{ok:!1,error:f.message};let y=j(t,n,t.undo([c,...l],{...e.author?{author:e.author}:{}}));return{ok:!0,data:ct(y),diff:y.diff}}default:return{ok:!1,error:`Unknown tool "${m}".`}}}catch(b){let{reason:S,wouldNeed:c}=Ae(b);return{ok:!1,error:b instanceof Error?b.message:String(b),reason:S,...c?{wouldNeed:c}:{}}}},v=new Set,A=m=>{for(let u of v)u(m)};return{definitions:r,hash:d,...e.author?{author:e.author}:{},onDiff(m){return t.subscribe(m)},onCall(m){return v.add(m),()=>v.delete(m)},async call(m,u){let b=h(m)?.mutating??!1,S={name:m,args:u,mutating:b,at:new Date().toISOString()};A({...S,phase:"running"});let c=f=>(A(f.ok?{...S,phase:"ok",...!b&&f.reads?{reads:f.reads}:{}}:{...S,phase:"failed",error:f.error}),f),l=await R(m,u);return c(l.ok&&!b?{...l,data:(await W()).withinReadChars(m,l.data)}:l)}}}function V(t){let e=typeof t=="function"?t():t;return e?{via:e}:{}}export{le as a,Wn as b};
@@ -1 +1 @@
1
- import"./chunk.WVUJXDXZ.js";import{a as F,b as K,c as pe}from"./chunk.IRPMGHZN.js";import"./chunk.7QWGIGHM.js";import"./chunk.HRLCDBMO.js";import"./chunk.LZNHTROY.js";import"./chunk.36FKQJFM.js";import"./chunk.RHV73CBA.js";import"./chunk.MIE4TJRW.js";import{o as me}from"./chunk.RP6C2IUM.js";import"./chunk.RD2FSSLV.js";import"./chunk.T552MHMU.js";import"./chunk.ZGJUCVT5.js";import"./chunk.CVVNHQPO.js";import"./chunk.YIDNZTON.js";import"./chunk.QILGAV7H.js";import"./chunk.I6HIVTXU.js";import"./chunk.PYGNO2AV.js";import"./chunk.3HFBHLXC.js";import{G as Te,N as C,T as ue,Y as ce,ga as ge,ja as he}from"./chunk.CUA7F3YJ.js";import"./chunk.SDO3U72B.js";import{Aa as W,Ba as E,Ca as se,Da as Y,sa as oe,wa as x,ya as le,yd as de}from"./chunk.IUVRJDL3.js";import"./chunk.FQLNBIQ5.js";import{b as q}from"./chunk.AJZBJBMO.js";var g=q(Te(),1);async function ye(e,t){let a=await createImageBitmap(e);try{let i=Math.min(1,t/Math.max(a.width,a.height)),r=document.createElement("canvas");r.width=Math.max(1,Math.round(a.width*i)),r.height=Math.max(1,Math.round(a.height*i));let l=r.getContext("2d");if(l===null)throw new Error("This browser will not give us a canvas to resize with.");return l.drawImage(a,0,0,r.width,r.height),r}finally{a.close()}}var n=q(ce(),1),He=2048,Ie=.85;function T(e){return e<1e3?`${e} bytes`:e<1e6?`${Math.round(e/1e3)} KB`:`${(e/1e6).toFixed(e<1e7?1:0)} MB`}function H(e){if(e.type==="application/pdf")return"PDF";let t=/\.([a-z0-9]{2,5})$/i.exec(e.name??"")?.[1];return t?t.toUpperCase():(e.type.split("/")[1]??e.type).replace(/^x-|^vnd\./,"").split(/[.+-]/)[0].toUpperCase()}function ke(e){let t=[...new Set(e.map(a=>a==="image/*"?"pictures":a==="video/*"?"videos":a==="*/*"||a==="*"?"any file":`${H({type:a})} files`))];return t.length<=1?t[0]??"no files":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function xe(e,t){if(e.length===0)return!0;let a=`${t.split("/")[0]}/*`;return e.some(i=>i==="*"||i==="*/*"||i===t||i===a)}var fe=/^image\/hei[cf]$|\.hei[cf]$/i,be=e=>fe.test(e.type)||fe.test(e.name),De={mov:"video/quicktime",mp4:"video/mp4",m4v:"video/mp4",webm:"video/webm",ogv:"video/ogg"},Be=e=>De[/\.([a-z0-9]{2,4})$/i.exec(e)?.[1]?.toLowerCase()??""];async function je(e,t,a){let i=e.name||(a.camera?"photo.jpg":"file"),r=e.type||(be({type:"",name:i})?"image/heic":Be(i)??"application/octet-stream"),l=be({type:r,name:i}),u=r.startsWith("image/")||l;if(a.image&&!u)return{refused:`\u201C${i}\u201D isn\u2019t a picture.`};if(a.video)return r.startsWith("video/")?J({blob:e,name:i,type:r},t):{refused:`\u201C${i}\u201D isn\u2019t a video.`};if(l||u&&/^image\/(jpeg|webp)$/.test(r)&&(a.camera||e.size>t.maxBytes||e.size>15e5))try{let c=await ye(e,He),b=await new Promise(m=>c.toBlob(m,"image/jpeg",Ie));if(b)return J({blob:b,name:l?i.replace(/\.hei[cf]$/i,"")+".jpg":i,type:"image/jpeg",width:c.width,height:c.height},t)}catch{if(l&&!xe(t.kinds,r))return{refused:`\u201C${i}\u201D is a HEIC photo, which this browser can\u2019t turn into a JPEG and this host doesn\u2019t take. Save it as a JPEG and try again.`}}let p={};if(u&&!l)try{let c=await createImageBitmap(e);p={width:c.width,height:c.height},c.close()}catch{}return J({blob:e,name:i,type:r,...p},t)}function J(e,t){return xe(t.kinds,e.type)?e.blob.size>t.maxBytes?{refused:`\u201C${e.name}\u201D is ${T(e.blob.size)}; this host takes files up to ${T(t.maxBytes)}.`}:e:{refused:`\u201C${e.name}\u201D is a ${H(e)} file; this host takes ${ke(t.kinds)}.`}}async function _e(e,t,a,i=!1){let r;try{r=await t.upload(e.blob,e.name)}catch(u){let s=u instanceof Error&&u.message.trim()?u.message.trim():"the host refused it";return{refused:`\u201C${e.name}\u201D wasn\u2019t kept: ${s}`}}return le(r)?a&&!W(r)?{refused:`\u201C${e.name}\u201D isn\u2019t a picture.`}:i&&!E(r)?{refused:`The host kept \u201C${e.name}\u201D as ${H(r)}, not as a video.`}:{...r,...r.width===void 0&&e.width?{width:e.width}:{},...r.height===void 0&&e.height?{height:e.height}:{}}:{refused:`The host\u2019s answer for \u201C${e.name}\u201D isn\u2019t a file a record can keep.`}}var $="var(--graview-radius, 8px)",P={color:"var(--graview-ink-muted)",fontSize:"0.8125rem"};function ee(e){let t=C(),a=ue()?.past!=null,[i,r]=(0,g.useState)(!1),l=t?.kept?ze(t,e.href):!0,[,u]=(0,g.useState)(0);return(0,g.useEffect)(()=>{if(typeof l!="object")return;let s=!0;return l.then(()=>s&&u(p=>p+1)),()=>void(s=!1)},[l]),[l===!1||a&&i,()=>r(!0)]}var Q=new WeakMap;function ze(e,t){let a=Q.get(e)?.get(t);if(a!==void 0)return a;let i;try{i=e.kept(t)}catch{return!0}if(typeof i=="boolean")return i;let r=Q.get(e)??new Map;Q.set(e,r);let l=Promise.resolve(i).then(u=>u!==!1,()=>!0);return r.set(t,l),l.then(u=>r.set(t,u)),l}function te({file:e,style:t}){return(0,n.jsx)("span",{role:"img","aria-label":`${F(e)}, removed later`,"data-graview-removed-later":e.href,style:{display:"grid",placeItems:"center",textAlign:"center",padding:4,boxSizing:"border-box",fontSize:"0.6875rem",lineHeight:1.2,color:"var(--graview-ink-muted)",border:"1px dashed var(--graview-edge-bright)",borderRadius:$,...t},children:"removed later"})}function X({file:e,size:t=56,style:a}){let i=C(),[r,l]=ee(e);return r?(0,n.jsx)(te,{file:e,style:{width:t,height:t,flex:"none",...a}}):E(e)?(0,n.jsx)(Ae,{file:e,size:t,...a?{style:a}:{},onError:l}):(0,n.jsx)("img",{onError:l,src:x(i,e.href),alt:F(e),width:t,height:t,loading:"lazy",decoding:"async","data-graview-thumb":e.href,style:{width:t,height:t,objectFit:"cover",borderRadius:$,display:"block",flex:"none",background:"var(--graview-edge)",...a}})}function Fe(e){let[t,a]=(0,g.useState)({}),i=e.duration??t.duration;return[{...i!==void 0?{duration:i}:{},width:e.width??t.width,height:e.height??t.height},u=>{let s=u.currentTarget;a({...Number.isFinite(s.duration)&&s.duration>0?{duration:s.duration}:{},...s.videoWidth>0&&s.videoHeight>0?{width:s.videoWidth,height:s.videoHeight}:{}})}]}var Ne=320,$e=(e,t)=>`${F(e)}, ${se({...t!==void 0?{duration:t}:{}})}`,Oe=(0,n.jsx)("span",{"data-graview-play-glyph":"","aria-hidden":"true",style:{position:"absolute",inset:0,display:"grid",placeItems:"center",pointerEvents:"none"},children:(0,n.jsxs)("svg",{viewBox:"0 0 24 24",width:"40%",height:"40%",style:{maxWidth:40,maxHeight:40,filter:"drop-shadow(0 1px 2px rgb(0 0 0 / 0.5))"},children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"11",fill:"rgb(0 0 0 / 0.55)"}),(0,n.jsx)("path",{d:"M9.5 7.5v9l7-4.5z",fill:"#fff"})]})});function Ae({file:e,size:t,style:a,onError:i}){let r=C(),[l,u]=Fe(e),s={width:t,height:t,objectFit:"cover",display:"block",borderRadius:$,background:"var(--graview-edge)"};return(0,n.jsxs)("span",{role:"img","aria-label":$e(e,l.duration),"data-graview-thumb":e.href,"data-graview-video-thumb":"",style:{position:"relative",display:"block",width:t,height:t,flex:"none",...a},children:[e.poster?(0,n.jsx)("img",{src:x(r,e.poster),alt:"",width:t,height:t,loading:"lazy",decoding:"async",onError:i,style:s}):(0,n.jsx)("video",{src:x(r,e.href),preload:"metadata",muted:!0,playsInline:!0,"aria-hidden":"true",tabIndex:-1,width:t,height:t,onLoadedMetadata:u,onError:i,style:s}),Oe,l.duration!==void 0?(0,n.jsx)("span",{"data-graview-video-clock":"","aria-hidden":"true",style:{position:"absolute",right:3,bottom:3,padding:"0 4px",borderRadius:4,background:"rgb(0 0 0 / 0.65)",color:"#fff",fontSize:"0.6875rem",lineHeight:"16px",fontVariantNumeric:"tabular-nums"},children:K(l.duration)}):null]})}function Ge(){let e=()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):void 0,[t,a]=(0,g.useState)(()=>e()?.matches===!0);return(0,g.useEffect)(()=>{let i=e();if(!i)return;let r=()=>a(i.matches);return r(),i.addEventListener?.("change",r),()=>i.removeEventListener?.("change",r)},[]),t}function Ue({file:e,autoplay:t=!1,cover:a=!1}){let i=C(),[r,l]=ee(e),[u,s]=Fe(e),p=Ge(),c=t&&p,b=(0,g.useRef)(null),m=(0,g.useRef)(c);if((0,g.useEffect)(()=>{let d=b.current;!d||!t||(c?d.pause():m.current&&d.play?.()?.catch?.(()=>{}),m.current=c)},[t,c]),r)return(0,n.jsx)(te,{file:e,style:{width:"100%",aspectRatio:"16 / 9"}});let v=u.width!==void 0&&u.height!==void 0,w=a?{display:"block",width:"100%",height:"100%",objectFit:"cover",background:"#000"}:{display:"block",width:"100%",maxWidth:v?Math.max(u.width,Ne):"100%",height:"auto",maxHeight:"80vh",aspectRatio:v?`${u.width} / ${u.height}`:"16 / 9",borderRadius:$,background:"#000"};return(0,n.jsxs)("figure",{"data-graview-video-figure":e.href,style:{margin:0,display:"grid",gap:4,minWidth:0,...a?{height:"100%"}:{}},children:[(0,n.jsx)("video",{ref:b,"data-graview-video":e.href,...t?{"data-graview-video-autoplay":""}:{},...a?{"data-graview-video-cover":""}:{},...c?{"data-graview-video-still":""}:{},src:x(i,e.href),...e.poster?{poster:x(i,e.poster)}:{},...t?{muted:!0,loop:!0,...c?{}:{autoPlay:!0}}:{controls:!0},preload:t&&!c?"auto":"metadata",playsInline:!0,...v?{width:u.width,height:u.height}:{},"aria-label":$e(e,u.duration),onLoadedMetadata:s,onError:l,style:w,children:e.captions?(0,n.jsx)("track",{kind:"captions",src:x(i,e.captions),srcLang:"en",label:"Captions",default:!0}):null}),t?null:(0,n.jsx)("figcaption",{"data-graview-video-said":"",style:P,children:[e.caption??e.name,...u.duration!==void 0?[K(u.duration)]:[]].join(" \xB7 ")})]})}function qe({file:e,onOpen:t}){let a=C(),[i,r]=ee(e);return i?(0,n.jsx)(te,{file:e,style:{width:"100%",aspectRatio:"1"}}):(0,n.jsx)("button",{type:"button","aria-label":`Open ${F(e)} full size`,onClick:l=>t(l.currentTarget),style:{padding:0,border:0,background:"none",cursor:"zoom-in",display:"block",width:"100%",borderRadius:$},children:(0,n.jsx)("img",{src:x(a,e.href),alt:F(e),loading:"lazy",decoding:"async",onError:r,style:{width:"100%",aspectRatio:"1",objectFit:"cover",borderRadius:$,display:"block",background:"var(--graview-edge)"}})})}function Ye({src:e,file:t}){let[a,i]=(0,g.useState)(!1);return(0,n.jsx)("object",{data:e,type:"application/pdf","aria-label":F(t),"data-graview-pdf":a?"shown":"waiting",onLoad:()=>i(!0),style:a?{width:"100%",height:420,border:"1px solid var(--graview-edge)",borderRadius:$}:{width:"100%",height:0,display:"block"}})}function Z({files:e,label:t,autoplay:a,cover:i}){let r=C(),l=d=>x(r,d.href),u=e.filter(W),s=e.filter(E),p=e.filter(d=>!W(d)&&!E(d)),[c,b]=(0,g.useState)(null),m=(0,g.useRef)(null),v=(0,g.useRef)(null);(0,g.useEffect)(()=>{let d=m.current;c!==null&&d&&!d.open&&d.showModal?.()},[c]);let w=c===null?void 0:u[c];return(0,n.jsxs)("div",{style:{display:"grid",gap:10,minWidth:0},children:[u.length>0?(0,n.jsx)("ul",{"data-graview-gallery":"","aria-label":t,style:{listStyle:"none",margin:0,padding:0,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(96px, 1fr))",gap:8},children:u.map((d,I)=>(0,n.jsx)("li",{style:{minWidth:0},children:(0,n.jsx)(qe,{file:d,onOpen:M=>{v.current=M,b(I)}})},d.href))}):null,s.length>0?(0,n.jsx)("ul",{"data-graview-videos":"","aria-label":t,style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:12},children:s.map(d=>(0,n.jsx)("li",{style:{minWidth:0},children:(0,n.jsx)(Ue,{file:d,...a?{autoplay:a}:{},...i?{cover:i}:{}})},d.href))}):null,p.length>0?(0,n.jsx)("ul",{"data-graview-documents":"",style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:10},children:p.map(d=>(0,n.jsxs)("li",{"data-graview-document":d.type,style:{display:"grid",gap:6,minWidth:0},children:[d.type==="application/pdf"?(0,n.jsx)(Ye,{src:l(d),file:d}):null,d.type==="application/pdf"?(0,n.jsxs)("span",{"data-graview-file-line":"",style:{minWidth:0,overflowWrap:"anywhere",lineHeight:1.5},children:[d.name," ",(0,n.jsxs)("span",{style:P,children:["\xB7 ",H(d)," \xB7 ",T(d.bytes)," \u2014"]})," ",(0,n.jsx)("a",{href:l(d),target:"_blank",rel:"noopener",children:"Open"})," ",(0,n.jsx)("span",{style:P,"aria-hidden":"true",children:"/"})," ",(0,n.jsx)("a",{href:l(d),download:d.name,children:"Download"})]}):(0,n.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",gap:"2px 10px",alignItems:"baseline",minWidth:0,overflowWrap:"anywhere"},children:[(0,n.jsx)("a",{href:l(d),download:d.name,children:d.name}),(0,n.jsxs)("span",{style:P,children:[H(d)," \xB7 ",T(d.bytes)]})]}),d.caption?(0,n.jsx)("span",{style:P,children:d.caption}):null]},d.href))}):null,w?(0,n.jsx)("dialog",{ref:m,"data-graview-full":w.href,"aria-label":F(w),onClose:()=>{b(null),v.current?.focus()},onClick:d=>{d.target===d.currentTarget&&d.currentTarget.close()},style:{padding:0,border:0,borderRadius:$,maxWidth:"min(96vw, 1600px)",maxHeight:"94vh",background:"var(--graview-panel)",color:"var(--graview-ink)"},children:(0,n.jsxs)("figure",{style:{margin:0,display:"grid",gap:8,padding:10},children:[(0,n.jsx)("img",{src:l(w),alt:F(w),style:{maxWidth:"100%",maxHeight:"80vh",objectFit:"contain",display:"block",margin:"0 auto"}}),(0,n.jsxs)("figcaption",{style:{display:"flex",gap:12,alignItems:"center",justifyContent:"space-between"},children:[(0,n.jsx)("span",{children:w.caption??w.name}),(0,n.jsx)("form",{method:"dialog",style:{margin:0},children:(0,n.jsx)("button",{type:"submit",autoFocus:!0,children:"Close"})})]})]})}):null]})}function Se({value:e,onChange:t,several:a,image:i,video:r=!1,label:l,thumbs:u=!0}){let s=C(),p=(0,g.useId)(),c=(0,g.useRef)(null),b=(0,g.useRef)(null),[m,v]=(0,g.useState)(null),[w,d]=(0,g.useState)(null),[I,M]=(0,g.useState)([]),[O,A]=(0,g.useState)(!1),L=i?"image/":r?"video/":void 0,R=s?L?s.kinds.filter(o=>o.startsWith(L)||o==="*"||o==="*/*"):s.kinds:[],Pe=s?s.kinds.length===0||R.length>0:!1,We=!r&&(s?s.kinds.length===0||(i?R:s.kinds).some(o=>o.startsWith("image/")||o.startsWith("*")):!1),ne=!!s&&s.maxBytes>0,D=ne&&(!L||Pe),B=i?"picture":r?"video":"file",ae=a?`${B}s`:`a ${B}`,ie=L?R.length>0?R.join(","):`${L}*`:s?.kinds.join(",")||void 0,Me=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,G=(0,g.useRef)(e);G.current=e;let re=(0,g.useRef)(null),j=(0,g.useRef)(null);(0,g.useEffect)(()=>{let o=j.current;if(!o||o.from===e)return;j.current=null;let h=re.current?.children,f=h?.[Math.min(o.at,h.length-1)];((o.what==="move"?f?.querySelector("[data-graview-file-move]"):null)??f?.querySelector("[data-graview-file-remove]")??c.current?.parentElement?.querySelector("[data-graview-file-choose]"))?.focus()});let _=async(o,h)=>{if(!s||o.length===0)return;let f=a?o:o.slice(0,1),y=[],S=[];f.length<o.length&&S.push(`${l} holds one ${B}, so ${o.slice(1).map(k=>`\u201C${k.name||"the photo"}\u201D`).join(", ")} ${o.length>2?"were":"was"} left out.`),M([]),d(null);for(let k of f){v(`Sending ${k.name||"the photo"}\u2026`);let U=await je(k,s,{image:i,video:r,camera:h==="camera"});if("refused"in U){S.push(U.refused);continue}let V=await _e(U,s,i,r);"refused"in V?S.push(V.refused):[...a?G.current:[],...y].some(Ve=>Ve.href===V.href)?S.push(`\u201C${V.name}\u201D is already here.`):y.push(V)}if(v(null),M(S),y.length!==0)try{t(a?[...G.current,...y]:y.slice(-1)),d(`Added ${y.map(k=>k.name).join(", ")}.`)}catch(k){M([...S,k instanceof Error?k.message:String(k)])}},z=(o,h,f)=>{try{j.current=f?{...f,from:e}:null,t(o),d(h)}catch(y){j.current=null,M([y instanceof Error?y.message:String(y)])}},N=o=>o?Array.from(o):[],Re=o=>{let h=N(o.clipboardData?.files);!D||h.length===0||(o.preventDefault(),_(h,"pasted"))},Le=o=>{A(!1),D&&(o.preventDefault(),_(N(o.dataTransfer?.files),"dropped"))};return(0,n.jsxs)("div",{role:"group","aria-labelledby":`${p}-label`,"data-graview-file-editor":"","data-graview-dropping":O?"":void 0,onPaste:Re,onDragOver:o=>{D&&(o.preventDefault(),A(!0))},onDragLeave:()=>A(!1),onDrop:Le,style:{display:"grid",gap:8,minWidth:0,padding:O?6:0,outline:O?"2px dashed var(--graview-accent)":"none",borderRadius:$},children:[(0,n.jsx)("span",{id:`${p}-label`,style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},children:l}),e.length>0&&(a||e.length>1)?(0,n.jsx)("ul",{ref:re,style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:6},children:e.map((o,h)=>(0,n.jsxs)("li",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap",minWidth:0},children:[u&&(W(o)||E(o))?(0,n.jsx)(X,{file:o,size:40}):null,(0,n.jsx)("span",{style:{flex:"1 1 8rem",minWidth:0,overflowWrap:"anywhere"},children:o.name}),(0,n.jsx)(we,{file:o,onCaption:f=>z(e.map((y,S)=>S===h?ve(y,f):y),f?`${o.name} now says \u201C${f}\u201D.`:`${o.name} says its name again.`)}),a&&h>0?(0,n.jsx)("button",{type:"button","data-graview-file-move":"","aria-label":`Move ${o.name} earlier`,onClick:()=>z(e.map((f,y)=>y===h-1?o:y===h?e[h-1]:f),`Moved ${o.name} earlier.`,{at:h-1,what:"move"}),children:"\u2191"}):null,a?(0,n.jsx)("button",{type:"button","data-graview-file-remove":"","aria-label":`Remove ${o.name}`,onClick:()=>z(e.filter((f,y)=>y!==h),`Removed ${o.name}.`,{at:h,what:"remove"}),children:"Remove"}):null]},`${h}:${o.href}`))}):e.length===1?(0,n.jsx)(we,{file:e[0],onCaption:o=>z([ve(e[0],o)],o?`${e[0].name} now says \u201C${o}\u201D.`:`${e[0].name} says its name again.`)}):null,D?(0,n.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:8,alignItems:"center"},children:[(0,n.jsx)("input",{ref:c,type:"file",hidden:!0,multiple:a,...ie?{accept:ie}:{},"data-graview-file-input":"","aria-label":`Choose ${ae}`,onChange:o=>{let h=N(o.currentTarget.files);o.currentTarget.value="",_(h,"picked")}}),(0,n.jsx)("button",{type:"button",disabled:m!==null,onClick:()=>c.current?.click(),"data-graview-file-choose":"",children:e.length>0&&!a?`Replace the ${B}`:`Choose ${ae}`}),We?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("input",{ref:b,type:"file",hidden:!0,accept:"image/*",capture:"environment","data-graview-photo-input":"","aria-label":"Take a photo",onChange:o=>{let h=N(o.currentTarget.files);o.currentTarget.value="",_(h,"camera")}}),Me?(0,n.jsx)("button",{type:"button",disabled:m!==null,onClick:()=>b.current?.click(),children:"Take a photo"}):null]}):null,(0,n.jsxs)("span",{style:P,"data-graview-file-takes":"",children:["or drop or paste ",a?"them":"it"," here \xB7 ",s.kinds.length>0?ke(R.length>0?R:s.kinds):"any file",", up to ",T(s.maxBytes)]})]}):(0,n.jsx)("p",{style:{...P,margin:0},"data-graview-file-none":"",children:ne?`This host doesn\u2019t take ${r?"videos":"pictures"}, so none can be added here.`:"This host doesn\u2019t take files, so none can be added here."}),(0,n.jsx)("p",{"aria-live":"polite",style:{...P,margin:0,minHeight:m||w?void 0:0},"data-graview-file-status":"",children:m??w??""}),I.length>0?(0,n.jsx)("div",{role:"alert","data-graview-file-refused":"",style:{color:"var(--graview-warn)",fontSize:"0.875rem",display:"grid",gap:2},children:I.map((o,h)=>(0,n.jsx)("p",{style:{margin:0},children:o},h))}):null]})}var ve=(e,t)=>{let{caption:a,...i}=e;return t?{...i,caption:t}:i};function we({file:e,onCaption:t}){let[a,i]=(0,g.useState)(e.caption??"");(0,g.useEffect)(()=>i(e.caption??""),[e.caption]);let r=()=>{let l=a.trim().slice(0,500);l!==(e.caption??"")&&t(l)};return(0,n.jsx)("input",{type:"text",value:a,placeholder:W(e)||E(e)?"What it shows":"What it is","aria-label":`What ${e.name} ${W(e)||E(e)?"shows":"is"}`,"data-graview-file-caption":e.href,onChange:l=>i(l.target.value),onBlur:r,onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),r())},style:{flex:"1 1 10rem",minWidth:0,font:"inherit",fontSize:"0.875rem",minHeight:24}})}function Ee({field:e,label:t,labelStyle:a,valueStyle:i,style:r,children:l}){return(0,n.jsxs)("div",{"data-graview-files":e,style:{display:"grid",gap:6,minWidth:0,gridColumn:"1 / -1",...r},children:[(0,n.jsx)("dt",{style:a,children:t}),(0,n.jsx)("dd",{style:{margin:0,minWidth:0,display:"grid",gap:10,...i},children:l})]})}function Ce(e){let{nodeId:t,field:a,label:i,files:r}=e,{fields:l,commit:u}=me(t),s=l.find(m=>m.field===a&&m.takesValue),p=s?.shape,c=p?.type==="several"?p.of:p,b=p?.type==="several";return r.length===0&&c?.type!=="file"?null:(0,n.jsxs)(Ee,{...e,children:[(0,n.jsx)(Z,{files:r,label:i}),s&&c?.type==="file"?(0,n.jsx)(Se,{value:r,thumbs:!1,several:b,image:c.image===!0,video:c.video===!0,label:i,onChange:m=>{let v=b?m:m[m.length-1];v!==void 0&&u(s,v)}}):null]})}function nt(e){switch(e.as){case"field":{if(!e.read)return(0,n.jsx)(Ce,{...e});let{autoplay:t,cover:a,...i}=e;return e.files.length>0?(0,n.jsx)(Ee,{...i,children:(0,n.jsx)(Z,{files:e.files,label:e.label,...t?{autoplay:t}:{},...a?{cover:a}:{}})}):null}case"unfilled":return(0,n.jsx)(Ke,{...e});case"thumb":return(0,n.jsx)(X,{...e});case"block":return e.files.length>0?(0,n.jsx)("span",{className:"graview-spec-image","data-graview-field":e.field,"data-graview-image":e.view,style:{display:"block",minWidth:0,...e.view==="gallery"?{position:"relative",zIndex:de.raised}:{}},children:e.view==="thumb"?(0,n.jsx)(X,{file:e.files[0],size:72}):(0,n.jsx)(Z,{files:e.files,label:e.label,...e.autoplay?{autoplay:!0}:{},...e.cover?{cover:!0}:{}})}):null;case"control":{let t=(0,n.jsx)(Se,{value:Y(e.value),several:e.several,image:e.image,video:e.video===!0,label:e.label,onChange:a=>e.onChange(e.several?a:a[a.length-1])});return e.title===void 0?t:(0,n.jsxs)("fieldset",{"data-graview-part":"group","data-graview-field":e.several?"files":"file",children:[(0,n.jsx)("legend",{"data-graview-part":"label",children:e.title}),t]})}}}function Ke({nodeId:e,skip:t,labels:a,labelStyle:i,style:r}){let{store:l}=ge(),u=he(e),s=u?l.schema.tryDefinition(u.kind):void 0,p=pe(s).filter(c=>!t.includes(c)&&!(s?.display?.hide??[]).includes(c)&&Y(u?.[c]).length===0);return p.length===0?null:(0,n.jsx)("dl",{style:{margin:0,display:"grid",gap:14,minWidth:0},children:p.map(c=>(0,n.jsx)(Ce,{nodeId:e,field:c,label:a?.[c]??oe(s,c),files:[],...i?{labelStyle:i}:{},...r?{style:r}:{}},c))})}export{Se as FilesEditor,He as SEND_EDGE,nt as drawFiles,ke as kindsWords,je as prepare,_e as send,T as sizeWords,xe as takes,H as typeWords};
1
+ import"./chunk.WVUJXDXZ.js";import{a as F,b as K,c as pe}from"./chunk.J7GH2CGV.js";import"./chunk.SMF5S4DQ.js";import"./chunk.XP4IVKKR.js";import"./chunk.R5YGW5ZX.js";import"./chunk.QMGBAKX6.js";import"./chunk.PS765ODQ.js";import"./chunk.MIE4TJRW.js";import{o as me}from"./chunk.DEBW4FH6.js";import"./chunk.RD2FSSLV.js";import"./chunk.OWHH7JDV.js";import"./chunk.T3RFZ66S.js";import"./chunk.TDWJU6GW.js";import"./chunk.P3Z4ZCL3.js";import"./chunk.45OLF6BK.js";import"./chunk.T6ISUVUP.js";import"./chunk.GH6QX7JR.js";import"./chunk.J4D4BIB4.js";import{G as Te,N as C,T as ue,_ as ce,ia as ge,la as he}from"./chunk.ASNVH2G4.js";import"./chunk.SDO3U72B.js";import{Aa as W,Ba as E,Ca as se,Da as Y,sa as oe,wa as x,ya as le,yd as de}from"./chunk.ZDUKVXBI.js";import"./chunk.FQLNBIQ5.js";import{b as q}from"./chunk.AJZBJBMO.js";var g=q(Te(),1);async function ye(e,t){let a=await createImageBitmap(e);try{let i=Math.min(1,t/Math.max(a.width,a.height)),r=document.createElement("canvas");r.width=Math.max(1,Math.round(a.width*i)),r.height=Math.max(1,Math.round(a.height*i));let l=r.getContext("2d");if(l===null)throw new Error("This browser will not give us a canvas to resize with.");return l.drawImage(a,0,0,r.width,r.height),r}finally{a.close()}}var n=q(ce(),1),He=2048,Ie=.85;function T(e){return e<1e3?`${e} bytes`:e<1e6?`${Math.round(e/1e3)} KB`:`${(e/1e6).toFixed(e<1e7?1:0)} MB`}function H(e){if(e.type==="application/pdf")return"PDF";let t=/\.([a-z0-9]{2,5})$/i.exec(e.name??"")?.[1];return t?t.toUpperCase():(e.type.split("/")[1]??e.type).replace(/^x-|^vnd\./,"").split(/[.+-]/)[0].toUpperCase()}function ke(e){let t=[...new Set(e.map(a=>a==="image/*"?"pictures":a==="video/*"?"videos":a==="*/*"||a==="*"?"any file":`${H({type:a})} files`))];return t.length<=1?t[0]??"no files":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function xe(e,t){if(e.length===0)return!0;let a=`${t.split("/")[0]}/*`;return e.some(i=>i==="*"||i==="*/*"||i===t||i===a)}var fe=/^image\/hei[cf]$|\.hei[cf]$/i,be=e=>fe.test(e.type)||fe.test(e.name),De={mov:"video/quicktime",mp4:"video/mp4",m4v:"video/mp4",webm:"video/webm",ogv:"video/ogg"},Be=e=>De[/\.([a-z0-9]{2,4})$/i.exec(e)?.[1]?.toLowerCase()??""];async function je(e,t,a){let i=e.name||(a.camera?"photo.jpg":"file"),r=e.type||(be({type:"",name:i})?"image/heic":Be(i)??"application/octet-stream"),l=be({type:r,name:i}),u=r.startsWith("image/")||l;if(a.image&&!u)return{refused:`\u201C${i}\u201D isn\u2019t a picture.`};if(a.video)return r.startsWith("video/")?J({blob:e,name:i,type:r},t):{refused:`\u201C${i}\u201D isn\u2019t a video.`};if(l||u&&/^image\/(jpeg|webp)$/.test(r)&&(a.camera||e.size>t.maxBytes||e.size>15e5))try{let c=await ye(e,He),b=await new Promise(m=>c.toBlob(m,"image/jpeg",Ie));if(b)return J({blob:b,name:l?i.replace(/\.hei[cf]$/i,"")+".jpg":i,type:"image/jpeg",width:c.width,height:c.height},t)}catch{if(l&&!xe(t.kinds,r))return{refused:`\u201C${i}\u201D is a HEIC photo, which this browser can\u2019t turn into a JPEG and this host doesn\u2019t take. Save it as a JPEG and try again.`}}let p={};if(u&&!l)try{let c=await createImageBitmap(e);p={width:c.width,height:c.height},c.close()}catch{}return J({blob:e,name:i,type:r,...p},t)}function J(e,t){return xe(t.kinds,e.type)?e.blob.size>t.maxBytes?{refused:`\u201C${e.name}\u201D is ${T(e.blob.size)}; this host takes files up to ${T(t.maxBytes)}.`}:e:{refused:`\u201C${e.name}\u201D is a ${H(e)} file; this host takes ${ke(t.kinds)}.`}}async function _e(e,t,a,i=!1){let r;try{r=await t.upload(e.blob,e.name)}catch(u){let s=u instanceof Error&&u.message.trim()?u.message.trim():"the host refused it";return{refused:`\u201C${e.name}\u201D wasn\u2019t kept: ${s}`}}return le(r)?a&&!W(r)?{refused:`\u201C${e.name}\u201D isn\u2019t a picture.`}:i&&!E(r)?{refused:`The host kept \u201C${e.name}\u201D as ${H(r)}, not as a video.`}:{...r,...r.width===void 0&&e.width?{width:e.width}:{},...r.height===void 0&&e.height?{height:e.height}:{}}:{refused:`The host\u2019s answer for \u201C${e.name}\u201D isn\u2019t a file a record can keep.`}}var $="var(--graview-radius, 8px)",P={color:"var(--graview-ink-muted)",fontSize:"0.8125rem"};function ee(e){let t=C(),a=ue()?.past!=null,[i,r]=(0,g.useState)(!1),l=t?.kept?ze(t,e.href):!0,[,u]=(0,g.useState)(0);return(0,g.useEffect)(()=>{if(typeof l!="object")return;let s=!0;return l.then(()=>s&&u(p=>p+1)),()=>void(s=!1)},[l]),[l===!1||a&&i,()=>r(!0)]}var Q=new WeakMap;function ze(e,t){let a=Q.get(e)?.get(t);if(a!==void 0)return a;let i;try{i=e.kept(t)}catch{return!0}if(typeof i=="boolean")return i;let r=Q.get(e)??new Map;Q.set(e,r);let l=Promise.resolve(i).then(u=>u!==!1,()=>!0);return r.set(t,l),l.then(u=>r.set(t,u)),l}function te({file:e,style:t}){return(0,n.jsx)("span",{role:"img","aria-label":`${F(e)}, removed later`,"data-graview-removed-later":e.href,style:{display:"grid",placeItems:"center",textAlign:"center",padding:4,boxSizing:"border-box",fontSize:"0.6875rem",lineHeight:1.2,color:"var(--graview-ink-muted)",border:"1px dashed var(--graview-edge-bright)",borderRadius:$,...t},children:"removed later"})}function X({file:e,size:t=56,style:a}){let i=C(),[r,l]=ee(e);return r?(0,n.jsx)(te,{file:e,style:{width:t,height:t,flex:"none",...a}}):E(e)?(0,n.jsx)(Ae,{file:e,size:t,...a?{style:a}:{},onError:l}):(0,n.jsx)("img",{onError:l,src:x(i,e.href),alt:F(e),width:t,height:t,loading:"lazy",decoding:"async","data-graview-thumb":e.href,style:{width:t,height:t,objectFit:"cover",borderRadius:$,display:"block",flex:"none",background:"var(--graview-edge)",...a}})}function Fe(e){let[t,a]=(0,g.useState)({}),i=e.duration??t.duration;return[{...i!==void 0?{duration:i}:{},width:e.width??t.width,height:e.height??t.height},u=>{let s=u.currentTarget;a({...Number.isFinite(s.duration)&&s.duration>0?{duration:s.duration}:{},...s.videoWidth>0&&s.videoHeight>0?{width:s.videoWidth,height:s.videoHeight}:{}})}]}var Ne=320,$e=(e,t)=>`${F(e)}, ${se({...t!==void 0?{duration:t}:{}})}`,Oe=(0,n.jsx)("span",{"data-graview-play-glyph":"","aria-hidden":"true",style:{position:"absolute",inset:0,display:"grid",placeItems:"center",pointerEvents:"none"},children:(0,n.jsxs)("svg",{viewBox:"0 0 24 24",width:"40%",height:"40%",style:{maxWidth:40,maxHeight:40,filter:"drop-shadow(0 1px 2px rgb(0 0 0 / 0.5))"},children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"11",fill:"rgb(0 0 0 / 0.55)"}),(0,n.jsx)("path",{d:"M9.5 7.5v9l7-4.5z",fill:"#fff"})]})});function Ae({file:e,size:t,style:a,onError:i}){let r=C(),[l,u]=Fe(e),s={width:t,height:t,objectFit:"cover",display:"block",borderRadius:$,background:"var(--graview-edge)"};return(0,n.jsxs)("span",{role:"img","aria-label":$e(e,l.duration),"data-graview-thumb":e.href,"data-graview-video-thumb":"",style:{position:"relative",display:"block",width:t,height:t,flex:"none",...a},children:[e.poster?(0,n.jsx)("img",{src:x(r,e.poster),alt:"",width:t,height:t,loading:"lazy",decoding:"async",onError:i,style:s}):(0,n.jsx)("video",{src:x(r,e.href),preload:"metadata",muted:!0,playsInline:!0,"aria-hidden":"true",tabIndex:-1,width:t,height:t,onLoadedMetadata:u,onError:i,style:s}),Oe,l.duration!==void 0?(0,n.jsx)("span",{"data-graview-video-clock":"","aria-hidden":"true",style:{position:"absolute",right:3,bottom:3,padding:"0 4px",borderRadius:4,background:"rgb(0 0 0 / 0.65)",color:"#fff",fontSize:"0.6875rem",lineHeight:"16px",fontVariantNumeric:"tabular-nums"},children:K(l.duration)}):null]})}function Ge(){let e=()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):void 0,[t,a]=(0,g.useState)(()=>e()?.matches===!0);return(0,g.useEffect)(()=>{let i=e();if(!i)return;let r=()=>a(i.matches);return r(),i.addEventListener?.("change",r),()=>i.removeEventListener?.("change",r)},[]),t}function Ue({file:e,autoplay:t=!1,cover:a=!1}){let i=C(),[r,l]=ee(e),[u,s]=Fe(e),p=Ge(),c=t&&p,b=(0,g.useRef)(null),m=(0,g.useRef)(c);if((0,g.useEffect)(()=>{let d=b.current;!d||!t||(c?d.pause():m.current&&d.play?.()?.catch?.(()=>{}),m.current=c)},[t,c]),r)return(0,n.jsx)(te,{file:e,style:{width:"100%",aspectRatio:"16 / 9"}});let v=u.width!==void 0&&u.height!==void 0,w=a?{display:"block",width:"100%",height:"100%",objectFit:"cover",background:"#000"}:{display:"block",width:"100%",maxWidth:v?Math.max(u.width,Ne):"100%",height:"auto",maxHeight:"80vh",aspectRatio:v?`${u.width} / ${u.height}`:"16 / 9",borderRadius:$,background:"#000"};return(0,n.jsxs)("figure",{"data-graview-video-figure":e.href,style:{margin:0,display:"grid",gap:4,minWidth:0,...a?{height:"100%"}:{}},children:[(0,n.jsx)("video",{ref:b,"data-graview-video":e.href,...t?{"data-graview-video-autoplay":""}:{},...a?{"data-graview-video-cover":""}:{},...c?{"data-graview-video-still":""}:{},src:x(i,e.href),...e.poster?{poster:x(i,e.poster)}:{},...t?{muted:!0,loop:!0,...c?{}:{autoPlay:!0}}:{controls:!0},preload:t&&!c?"auto":"metadata",playsInline:!0,...v?{width:u.width,height:u.height}:{},"aria-label":$e(e,u.duration),onLoadedMetadata:s,onError:l,style:w,children:e.captions?(0,n.jsx)("track",{kind:"captions",src:x(i,e.captions),srcLang:"en",label:"Captions",default:!0}):null}),t?null:(0,n.jsx)("figcaption",{"data-graview-video-said":"",style:P,children:[e.caption??e.name,...u.duration!==void 0?[K(u.duration)]:[]].join(" \xB7 ")})]})}function qe({file:e,onOpen:t}){let a=C(),[i,r]=ee(e);return i?(0,n.jsx)(te,{file:e,style:{width:"100%",aspectRatio:"1"}}):(0,n.jsx)("button",{type:"button","aria-label":`Open ${F(e)} full size`,onClick:l=>t(l.currentTarget),style:{padding:0,border:0,background:"none",cursor:"zoom-in",display:"block",width:"100%",borderRadius:$},children:(0,n.jsx)("img",{src:x(a,e.href),alt:F(e),loading:"lazy",decoding:"async",onError:r,style:{width:"100%",aspectRatio:"1",objectFit:"cover",borderRadius:$,display:"block",background:"var(--graview-edge)"}})})}function Ye({src:e,file:t}){let[a,i]=(0,g.useState)(!1);return(0,n.jsx)("object",{data:e,type:"application/pdf","aria-label":F(t),"data-graview-pdf":a?"shown":"waiting",onLoad:()=>i(!0),style:a?{width:"100%",height:420,border:"1px solid var(--graview-edge)",borderRadius:$}:{width:"100%",height:0,display:"block"}})}function Z({files:e,label:t,autoplay:a,cover:i}){let r=C(),l=d=>x(r,d.href),u=e.filter(W),s=e.filter(E),p=e.filter(d=>!W(d)&&!E(d)),[c,b]=(0,g.useState)(null),m=(0,g.useRef)(null),v=(0,g.useRef)(null);(0,g.useEffect)(()=>{let d=m.current;c!==null&&d&&!d.open&&d.showModal?.()},[c]);let w=c===null?void 0:u[c];return(0,n.jsxs)("div",{style:{display:"grid",gap:10,minWidth:0},children:[u.length>0?(0,n.jsx)("ul",{"data-graview-gallery":"","aria-label":t,style:{listStyle:"none",margin:0,padding:0,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(96px, 1fr))",gap:8},children:u.map((d,I)=>(0,n.jsx)("li",{style:{minWidth:0},children:(0,n.jsx)(qe,{file:d,onOpen:M=>{v.current=M,b(I)}})},d.href))}):null,s.length>0?(0,n.jsx)("ul",{"data-graview-videos":"","aria-label":t,style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:12},children:s.map(d=>(0,n.jsx)("li",{style:{minWidth:0},children:(0,n.jsx)(Ue,{file:d,...a?{autoplay:a}:{},...i?{cover:i}:{}})},d.href))}):null,p.length>0?(0,n.jsx)("ul",{"data-graview-documents":"",style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:10},children:p.map(d=>(0,n.jsxs)("li",{"data-graview-document":d.type,style:{display:"grid",gap:6,minWidth:0},children:[d.type==="application/pdf"?(0,n.jsx)(Ye,{src:l(d),file:d}):null,d.type==="application/pdf"?(0,n.jsxs)("span",{"data-graview-file-line":"",style:{minWidth:0,overflowWrap:"anywhere",lineHeight:1.5},children:[d.name," ",(0,n.jsxs)("span",{style:P,children:["\xB7 ",H(d)," \xB7 ",T(d.bytes)," \u2014"]})," ",(0,n.jsx)("a",{href:l(d),target:"_blank",rel:"noopener",children:"Open"})," ",(0,n.jsx)("span",{style:P,"aria-hidden":"true",children:"/"})," ",(0,n.jsx)("a",{href:l(d),download:d.name,children:"Download"})]}):(0,n.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",gap:"2px 10px",alignItems:"baseline",minWidth:0,overflowWrap:"anywhere"},children:[(0,n.jsx)("a",{href:l(d),download:d.name,children:d.name}),(0,n.jsxs)("span",{style:P,children:[H(d)," \xB7 ",T(d.bytes)]})]}),d.caption?(0,n.jsx)("span",{style:P,children:d.caption}):null]},d.href))}):null,w?(0,n.jsx)("dialog",{ref:m,"data-graview-full":w.href,"aria-label":F(w),onClose:()=>{b(null),v.current?.focus()},onClick:d=>{d.target===d.currentTarget&&d.currentTarget.close()},style:{padding:0,border:0,borderRadius:$,maxWidth:"min(96vw, 1600px)",maxHeight:"94vh",background:"var(--graview-panel)",color:"var(--graview-ink)"},children:(0,n.jsxs)("figure",{style:{margin:0,display:"grid",gap:8,padding:10},children:[(0,n.jsx)("img",{src:l(w),alt:F(w),style:{maxWidth:"100%",maxHeight:"80vh",objectFit:"contain",display:"block",margin:"0 auto"}}),(0,n.jsxs)("figcaption",{style:{display:"flex",gap:12,alignItems:"center",justifyContent:"space-between"},children:[(0,n.jsx)("span",{children:w.caption??w.name}),(0,n.jsx)("form",{method:"dialog",style:{margin:0},children:(0,n.jsx)("button",{type:"submit",autoFocus:!0,children:"Close"})})]})]})}):null]})}function Se({value:e,onChange:t,several:a,image:i,video:r=!1,label:l,thumbs:u=!0}){let s=C(),p=(0,g.useId)(),c=(0,g.useRef)(null),b=(0,g.useRef)(null),[m,v]=(0,g.useState)(null),[w,d]=(0,g.useState)(null),[I,M]=(0,g.useState)([]),[O,A]=(0,g.useState)(!1),L=i?"image/":r?"video/":void 0,R=s?L?s.kinds.filter(o=>o.startsWith(L)||o==="*"||o==="*/*"):s.kinds:[],Pe=s?s.kinds.length===0||R.length>0:!1,We=!r&&(s?s.kinds.length===0||(i?R:s.kinds).some(o=>o.startsWith("image/")||o.startsWith("*")):!1),ne=!!s&&s.maxBytes>0,D=ne&&(!L||Pe),B=i?"picture":r?"video":"file",ae=a?`${B}s`:`a ${B}`,ie=L?R.length>0?R.join(","):`${L}*`:s?.kinds.join(",")||void 0,Me=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,G=(0,g.useRef)(e);G.current=e;let re=(0,g.useRef)(null),j=(0,g.useRef)(null);(0,g.useEffect)(()=>{let o=j.current;if(!o||o.from===e)return;j.current=null;let h=re.current?.children,f=h?.[Math.min(o.at,h.length-1)];((o.what==="move"?f?.querySelector("[data-graview-file-move]"):null)??f?.querySelector("[data-graview-file-remove]")??c.current?.parentElement?.querySelector("[data-graview-file-choose]"))?.focus()});let _=async(o,h)=>{if(!s||o.length===0)return;let f=a?o:o.slice(0,1),y=[],S=[];f.length<o.length&&S.push(`${l} holds one ${B}, so ${o.slice(1).map(k=>`\u201C${k.name||"the photo"}\u201D`).join(", ")} ${o.length>2?"were":"was"} left out.`),M([]),d(null);for(let k of f){v(`Sending ${k.name||"the photo"}\u2026`);let U=await je(k,s,{image:i,video:r,camera:h==="camera"});if("refused"in U){S.push(U.refused);continue}let V=await _e(U,s,i,r);"refused"in V?S.push(V.refused):[...a?G.current:[],...y].some(Ve=>Ve.href===V.href)?S.push(`\u201C${V.name}\u201D is already here.`):y.push(V)}if(v(null),M(S),y.length!==0)try{t(a?[...G.current,...y]:y.slice(-1)),d(`Added ${y.map(k=>k.name).join(", ")}.`)}catch(k){M([...S,k instanceof Error?k.message:String(k)])}},z=(o,h,f)=>{try{j.current=f?{...f,from:e}:null,t(o),d(h)}catch(y){j.current=null,M([y instanceof Error?y.message:String(y)])}},N=o=>o?Array.from(o):[],Re=o=>{let h=N(o.clipboardData?.files);!D||h.length===0||(o.preventDefault(),_(h,"pasted"))},Le=o=>{A(!1),D&&(o.preventDefault(),_(N(o.dataTransfer?.files),"dropped"))};return(0,n.jsxs)("div",{role:"group","aria-labelledby":`${p}-label`,"data-graview-file-editor":"","data-graview-dropping":O?"":void 0,onPaste:Re,onDragOver:o=>{D&&(o.preventDefault(),A(!0))},onDragLeave:()=>A(!1),onDrop:Le,style:{display:"grid",gap:8,minWidth:0,padding:O?6:0,outline:O?"2px dashed var(--graview-accent)":"none",borderRadius:$},children:[(0,n.jsx)("span",{id:`${p}-label`,style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},children:l}),e.length>0&&(a||e.length>1)?(0,n.jsx)("ul",{ref:re,style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:6},children:e.map((o,h)=>(0,n.jsxs)("li",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap",minWidth:0},children:[u&&(W(o)||E(o))?(0,n.jsx)(X,{file:o,size:40}):null,(0,n.jsx)("span",{style:{flex:"1 1 8rem",minWidth:0,overflowWrap:"anywhere"},children:o.name}),(0,n.jsx)(we,{file:o,onCaption:f=>z(e.map((y,S)=>S===h?ve(y,f):y),f?`${o.name} now says \u201C${f}\u201D.`:`${o.name} says its name again.`)}),a&&h>0?(0,n.jsx)("button",{type:"button","data-graview-file-move":"","aria-label":`Move ${o.name} earlier`,onClick:()=>z(e.map((f,y)=>y===h-1?o:y===h?e[h-1]:f),`Moved ${o.name} earlier.`,{at:h-1,what:"move"}),children:"\u2191"}):null,a?(0,n.jsx)("button",{type:"button","data-graview-file-remove":"","aria-label":`Remove ${o.name}`,onClick:()=>z(e.filter((f,y)=>y!==h),`Removed ${o.name}.`,{at:h,what:"remove"}),children:"Remove"}):null]},`${h}:${o.href}`))}):e.length===1?(0,n.jsx)(we,{file:e[0],onCaption:o=>z([ve(e[0],o)],o?`${e[0].name} now says \u201C${o}\u201D.`:`${e[0].name} says its name again.`)}):null,D?(0,n.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:8,alignItems:"center"},children:[(0,n.jsx)("input",{ref:c,type:"file",hidden:!0,multiple:a,...ie?{accept:ie}:{},"data-graview-file-input":"","aria-label":`Choose ${ae}`,onChange:o=>{let h=N(o.currentTarget.files);o.currentTarget.value="",_(h,"picked")}}),(0,n.jsx)("button",{type:"button",disabled:m!==null,onClick:()=>c.current?.click(),"data-graview-file-choose":"",children:e.length>0&&!a?`Replace the ${B}`:`Choose ${ae}`}),We?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("input",{ref:b,type:"file",hidden:!0,accept:"image/*",capture:"environment","data-graview-photo-input":"","aria-label":"Take a photo",onChange:o=>{let h=N(o.currentTarget.files);o.currentTarget.value="",_(h,"camera")}}),Me?(0,n.jsx)("button",{type:"button",disabled:m!==null,onClick:()=>b.current?.click(),children:"Take a photo"}):null]}):null,(0,n.jsxs)("span",{style:P,"data-graview-file-takes":"",children:["or drop or paste ",a?"them":"it"," here \xB7 ",s.kinds.length>0?ke(R.length>0?R:s.kinds):"any file",", up to ",T(s.maxBytes)]})]}):(0,n.jsx)("p",{style:{...P,margin:0},"data-graview-file-none":"",children:ne?`This host doesn\u2019t take ${r?"videos":"pictures"}, so none can be added here.`:"This host doesn\u2019t take files, so none can be added here."}),(0,n.jsx)("p",{"aria-live":"polite",style:{...P,margin:0,minHeight:m||w?void 0:0},"data-graview-file-status":"",children:m??w??""}),I.length>0?(0,n.jsx)("div",{role:"alert","data-graview-file-refused":"",style:{color:"var(--graview-warn)",fontSize:"0.875rem",display:"grid",gap:2},children:I.map((o,h)=>(0,n.jsx)("p",{style:{margin:0},children:o},h))}):null]})}var ve=(e,t)=>{let{caption:a,...i}=e;return t?{...i,caption:t}:i};function we({file:e,onCaption:t}){let[a,i]=(0,g.useState)(e.caption??"");(0,g.useEffect)(()=>i(e.caption??""),[e.caption]);let r=()=>{let l=a.trim().slice(0,500);l!==(e.caption??"")&&t(l)};return(0,n.jsx)("input",{type:"text",value:a,placeholder:W(e)||E(e)?"What it shows":"What it is","aria-label":`What ${e.name} ${W(e)||E(e)?"shows":"is"}`,"data-graview-file-caption":e.href,onChange:l=>i(l.target.value),onBlur:r,onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),r())},style:{flex:"1 1 10rem",minWidth:0,font:"inherit",fontSize:"0.875rem",minHeight:24}})}function Ee({field:e,label:t,labelStyle:a,valueStyle:i,style:r,children:l}){return(0,n.jsxs)("div",{"data-graview-files":e,style:{display:"grid",gap:6,minWidth:0,gridColumn:"1 / -1",...r},children:[(0,n.jsx)("dt",{style:a,children:t}),(0,n.jsx)("dd",{style:{margin:0,minWidth:0,display:"grid",gap:10,...i},children:l})]})}function Ce(e){let{nodeId:t,field:a,label:i,files:r}=e,{fields:l,commit:u}=me(t),s=l.find(m=>m.field===a&&m.takesValue),p=s?.shape,c=p?.type==="several"?p.of:p,b=p?.type==="several";return r.length===0&&c?.type!=="file"?null:(0,n.jsxs)(Ee,{...e,children:[(0,n.jsx)(Z,{files:r,label:i}),s&&c?.type==="file"?(0,n.jsx)(Se,{value:r,thumbs:!1,several:b,image:c.image===!0,video:c.video===!0,label:i,onChange:m=>{let v=b?m:m[m.length-1];v!==void 0&&u(s,v)}}):null]})}function nt(e){switch(e.as){case"field":{if(!e.read)return(0,n.jsx)(Ce,{...e});let{autoplay:t,cover:a,...i}=e;return e.files.length>0?(0,n.jsx)(Ee,{...i,children:(0,n.jsx)(Z,{files:e.files,label:e.label,...t?{autoplay:t}:{},...a?{cover:a}:{}})}):null}case"unfilled":return(0,n.jsx)(Ke,{...e});case"thumb":return(0,n.jsx)(X,{...e});case"block":return e.files.length>0?(0,n.jsx)("span",{className:"graview-spec-image","data-graview-field":e.field,"data-graview-image":e.view,style:{display:"block",minWidth:0,...e.view==="gallery"?{position:"relative",zIndex:de.raised}:{}},children:e.view==="thumb"?(0,n.jsx)(X,{file:e.files[0],size:72}):(0,n.jsx)(Z,{files:e.files,label:e.label,...e.autoplay?{autoplay:!0}:{},...e.cover?{cover:!0}:{}})}):null;case"control":{let t=(0,n.jsx)(Se,{value:Y(e.value),several:e.several,image:e.image,video:e.video===!0,label:e.label,onChange:a=>e.onChange(e.several?a:a[a.length-1])});return e.title===void 0?t:(0,n.jsxs)("fieldset",{"data-graview-part":"group","data-graview-field":e.several?"files":"file",children:[(0,n.jsx)("legend",{"data-graview-part":"label",children:e.title}),t]})}}}function Ke({nodeId:e,skip:t,labels:a,labelStyle:i,style:r}){let{store:l}=ge(),u=he(e),s=u?l.schema.tryDefinition(u.kind):void 0,p=pe(s).filter(c=>!t.includes(c)&&!(s?.display?.hide??[]).includes(c)&&Y(u?.[c]).length===0);return p.length===0?null:(0,n.jsx)("dl",{style:{margin:0,display:"grid",gap:14,minWidth:0},children:p.map(c=>(0,n.jsx)(Ce,{nodeId:e,field:c,label:a?.[c]??oe(s,c),files:[],...i?{labelStyle:i}:{},...r?{style:r}:{}},c))})}export{Se as FilesEditor,He as SEND_EDGE,nt as drawFiles,ke as kindsWords,je as prepare,_e as send,T as sizeWords,xe as takes,H as typeWords};