graview 0.1.60 → 0.1.62

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 (228) hide show
  1. package/dist/index.d.ts.map +1 -1
  2. package/dist/index.js +5 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/preview/{chunk.QDSEVPF3.js → chunk.22BZU7ME.js} +1 -1
  5. package/dist/preview/chunk.2AT3GRXM.js +1 -0
  6. package/dist/preview/chunk.2B6P4GPS.js +1 -0
  7. package/dist/preview/chunk.2GEJNG2U.js +1 -0
  8. package/dist/preview/{chunk.7N32AVIJ.js → chunk.2N4Z5K5S.js} +1 -1
  9. package/dist/preview/{chunk.NHUQ2N6J.js → chunk.3FON2Y72.js} +1 -1
  10. package/dist/preview/chunk.3L37FY3G.js +4 -0
  11. package/dist/preview/{chunk.ZYM2SSGW.js → chunk.4HEFUOLV.js} +1 -1
  12. package/dist/preview/chunk.4HRYB7HF.js +1 -0
  13. package/dist/preview/{chunk.YZ7FUKAL.js → chunk.4TX6VCBT.js} +1 -1
  14. package/dist/preview/{chunk.IGJZ4UH3.js → chunk.5HGD6OWL.js} +2 -2
  15. package/dist/preview/{chunk.2USDHXB4.js → chunk.5J3O2FVG.js} +1 -1
  16. package/dist/preview/{chunk.H45Q3O4F.js → chunk.5MZYCELA.js} +1 -1
  17. package/dist/preview/{chunk.SRVQJZRT.js → chunk.5ODHHH35.js} +1 -1
  18. package/dist/preview/{chunk.HDUO2USQ.js → chunk.5STU3KYG.js} +1 -1
  19. package/dist/preview/{chunk.TFWIG6LL.js → chunk.5YAOKOGV.js} +1 -1
  20. package/dist/preview/{chunk.BQIHNT7C.js → chunk.66P5IDTH.js} +1 -1
  21. package/dist/preview/{chunk.M4UD4ARP.js → chunk.6AKW7TXM.js} +1 -1
  22. package/dist/preview/{chunk.URWAFZHF.js → chunk.6JO5HQDR.js} +1 -1
  23. package/dist/preview/{chunk.HUJ6YTWE.js → chunk.75GVFX7L.js} +1 -1
  24. package/dist/preview/{chunk.A3ZXDG6V.js → chunk.7KVUUEZA.js} +1 -1
  25. package/dist/preview/{chunk.FFTYMBBT.js → chunk.7M4HNKDR.js} +1 -1
  26. package/dist/preview/chunk.7OBIBPYH.js +1 -0
  27. package/dist/preview/chunk.7V56P2A7.js +1 -0
  28. package/dist/preview/chunk.7XLS6XTY.js +1 -0
  29. package/dist/preview/chunk.7YOAW7ED.js +1 -0
  30. package/dist/preview/{chunk.FBJARKDT.js → chunk.A3OL2BI2.js} +1 -1
  31. package/dist/preview/{chunk.NGTRL5U4.js → chunk.A3ZC2JBO.js} +1 -1
  32. package/dist/preview/{chunk.A5PDXNY6.js → chunk.ACTXR2MI.js} +1 -1
  33. package/dist/preview/chunk.AFNSAQEQ.js +1 -0
  34. package/dist/preview/chunk.AI34V6WV.js +74 -0
  35. package/dist/preview/{chunk.3XGA65Y3.js → chunk.AJSUHPBE.js} +1 -1
  36. package/dist/preview/chunk.AQRB7LDA.js +1 -0
  37. package/dist/preview/{chunk.GNBIVVL3.js → chunk.B23WZQXQ.js} +1 -1
  38. package/dist/preview/chunk.BIDL7GQD.js +0 -0
  39. package/dist/preview/chunk.BLUKSGI4.js +1 -0
  40. package/dist/preview/chunk.BZMQDEIY.js +1 -0
  41. package/dist/preview/chunk.CAKFNKN5.js +1 -0
  42. package/dist/preview/chunk.CGALLZ54.js +1 -0
  43. package/dist/preview/{chunk.LSY256J4.js → chunk.CHHYIMB7.js} +1 -1
  44. package/dist/preview/chunk.CXDGE5ZS.js +1 -0
  45. package/dist/preview/{chunk.CC5BJH5A.js → chunk.CY3ELWCM.js} +1 -1
  46. package/dist/preview/chunk.DC35FJAB.js +1 -0
  47. package/dist/preview/{chunk.AVBTPSQF.js → chunk.DD2NKFDX.js} +1 -1
  48. package/dist/preview/{chunk.6HF6POIX.js → chunk.DDO3GLEJ.js} +1 -1
  49. package/dist/preview/{chunk.TLJOZSDD.js → chunk.DDUCIUVW.js} +1 -1
  50. package/dist/preview/chunk.DEAP3H2L.js +1 -0
  51. package/dist/preview/chunk.DHJ3FQTR.js +1 -0
  52. package/dist/preview/{chunk.P6RORYOT.js → chunk.DNVWSWL2.js} +1 -1
  53. package/dist/preview/chunk.DPEIT3TW.js +1 -0
  54. package/dist/preview/chunk.DVSTLVIH.js +15 -0
  55. package/dist/preview/chunk.DZZL5IDD.js +5 -0
  56. package/dist/preview/{chunk.IGVASEZU.js → chunk.ELOFPE25.js} +1 -1
  57. package/dist/preview/{chunk.MVWC3VR3.js → chunk.ELTV44HU.js} +2 -2
  58. package/dist/preview/chunk.EVBCEEQ4.js +1 -0
  59. package/dist/preview/{chunk.TKVLNBRD.js → chunk.F7YXLYLX.js} +1 -1
  60. package/dist/preview/{chunk.DCHQHKSA.js → chunk.FULEUL34.js} +1 -1
  61. package/dist/preview/{chunk.VNDKKTED.js → chunk.G4ULQK64.js} +14 -14
  62. package/dist/preview/{chunk.Y7G3OGDE.js → chunk.GX4G4BX3.js} +1 -1
  63. package/dist/preview/chunk.H24OC6OE.js +1 -0
  64. package/dist/preview/chunk.H5S7OL2U.js +1 -0
  65. package/dist/preview/chunk.H73ZPYUX.js +1 -0
  66. package/dist/preview/{chunk.GTKJJYQH.js → chunk.H7N7WN4U.js} +1 -1
  67. package/dist/preview/chunk.HANJZ6FA.js +1 -0
  68. package/dist/preview/chunk.HIMQ65QT.js +1 -0
  69. package/dist/preview/chunk.I77ZGIFE.js +1 -0
  70. package/dist/preview/{chunk.MJVYWLQQ.js → chunk.ILIIBSGA.js} +1 -1
  71. package/dist/preview/chunk.IQ3PRWGO.js +104 -0
  72. package/dist/preview/{chunk.NC7FXY2H.js → chunk.IQMD7DG3.js} +1 -1
  73. package/dist/preview/chunk.IQPILSV3.js +18 -0
  74. package/dist/preview/chunk.IYBEXENQ.js +1 -0
  75. package/dist/preview/{chunk.ULL6ZIJJ.js → chunk.J7Q2WAF4.js} +1 -1
  76. package/dist/preview/{chunk.TLWT67ON.js → chunk.JT3MFPRD.js} +1 -1
  77. package/dist/preview/chunk.JYFZCJ4N.js +2 -0
  78. package/dist/preview/chunk.K2HDEL7I.js +1 -0
  79. package/dist/preview/chunk.KDXU5DT3.js +1 -0
  80. package/dist/preview/chunk.KL7E4YHJ.js +1 -0
  81. package/dist/preview/{chunk.FRYBMS3W.js → chunk.KMV6PJFL.js} +1 -1
  82. package/dist/preview/{chunk.RXYNW5QB.js → chunk.L3WTKQQL.js} +1 -1
  83. package/dist/preview/chunk.LAYQ5PFS.js +1 -0
  84. package/dist/preview/{chunk.KBVTLNS5.js → chunk.LGRLVJGS.js} +3 -3
  85. package/dist/preview/chunk.LTZUF5VG.js +1 -0
  86. package/dist/preview/{chunk.OLFJH4RK.js → chunk.M4AYA2PL.js} +1 -1
  87. package/dist/preview/chunk.M7RESZB6.js +25 -0
  88. package/dist/preview/{chunk.WXUFATY5.js → chunk.MAKODQO3.js} +1 -1
  89. package/dist/preview/{chunk.F6V7RWDK.js → chunk.MDEX6ZVE.js} +1 -1
  90. package/dist/preview/chunk.MGALQLRW.js +1 -0
  91. package/dist/preview/{chunk.7OPM55I2.js → chunk.MYNMBOLD.js} +1 -1
  92. package/dist/preview/chunk.N6EJXXQK.js +2 -0
  93. package/dist/preview/chunk.NAD7ZXYP.js +1 -0
  94. package/dist/preview/chunk.NHTGAP3G.js +3 -0
  95. package/dist/preview/{chunk.5IEFTFKQ.js → chunk.NJSK3UO2.js} +1 -1
  96. package/dist/preview/{chunk.VFOON3Z3.js → chunk.NOGGSLVG.js} +1 -1
  97. package/dist/preview/chunk.NUWDMH47.js +1 -0
  98. package/dist/preview/chunk.NUYA4BWI.js +1 -0
  99. package/dist/preview/{chunk.VUBNBTJP.js → chunk.O2BHPYA4.js} +2 -2
  100. package/dist/preview/chunk.O75HWF3F.js +1 -0
  101. package/dist/preview/chunk.OFWNMTGB.js +21 -0
  102. package/dist/preview/chunk.OKZT2QBM.js +2 -0
  103. package/dist/preview/{chunk.EL5ICOOM.js → chunk.OUDATENL.js} +1 -1
  104. package/dist/preview/chunk.OUPURRDE.js +1 -0
  105. package/dist/preview/{chunk.Y5C4RXG7.js → chunk.OWOOKLIU.js} +2 -1
  106. package/dist/preview/{chunk.PI44XMY2.js → chunk.OWT3VVOT.js} +1 -1
  107. package/dist/preview/{chunk.VDMDPZ6U.js → chunk.PCDUV3WP.js} +1 -1
  108. package/dist/preview/chunk.PD2DECOP.js +1 -0
  109. package/dist/preview/{chunk.ZXOT3IXJ.js → chunk.PKWQKFPE.js} +1 -1
  110. package/dist/preview/{chunk.ENL2JJ47.js → chunk.PLTH2LW5.js} +1 -1
  111. package/dist/preview/{chunk.ZP5RT2EK.js → chunk.PZQNR4KZ.js} +1 -1
  112. package/dist/preview/chunk.Q5WEOX3Q.js +1 -0
  113. package/dist/preview/chunk.QDWSU47A.js +1 -0
  114. package/dist/preview/{chunk.VADQ7ZGA.js → chunk.QGU5QTR6.js} +1 -1
  115. package/dist/preview/chunk.QHY5NVYH.js +1 -0
  116. package/dist/preview/{chunk.6ZQAR5ZA.js → chunk.QIPASE42.js} +1 -1
  117. package/dist/preview/{chunk.7MHCGVGM.js → chunk.RD2X25XB.js} +1 -1
  118. package/dist/preview/chunk.RMR24LFJ.js +4 -0
  119. package/dist/preview/chunk.ROZTJ6IY.js +6 -0
  120. package/dist/preview/{chunk.RQOX5YDW.js → chunk.RPDH32XV.js} +1 -1
  121. package/dist/preview/chunk.RRKI24WY.js +1 -0
  122. package/dist/preview/{chunk.HDP3PS7N.js → chunk.RYRQ66JN.js} +1 -1
  123. package/dist/preview/chunk.SEHRPTNA.js +7 -0
  124. package/dist/preview/chunk.SGCW2XRC.js +1 -0
  125. package/dist/preview/{chunk.JPONLMU7.js → chunk.SS7234R6.js} +1 -1
  126. package/dist/preview/{chunk.BXDM3UMN.js → chunk.SVPKUWZU.js} +1 -1
  127. package/dist/preview/{chunk.LQVAABPS.js → chunk.SWMDFXUX.js} +1 -1
  128. package/dist/preview/{chunk.6WHAWOO7.js → chunk.T3UQ7ZQK.js} +1 -1
  129. package/dist/preview/chunk.T6PU3NKP.js +1 -0
  130. package/dist/preview/{chunk.6C2MHWSX.js → chunk.T6WHGKWR.js} +1 -1
  131. package/dist/preview/{chunk.QBLKTFF4.js → chunk.THVC2BEC.js} +1 -1
  132. package/dist/preview/{chunk.KDRLUBVF.js → chunk.TIALD6SC.js} +1 -1
  133. package/dist/preview/{chunk.Z2ERZ4S6.js → chunk.TM4EPUNO.js} +1 -1
  134. package/dist/preview/chunk.U5P23GO7.js +1 -0
  135. package/dist/preview/chunk.U6ZRJKVM.js +1 -0
  136. package/dist/preview/chunk.UFDJXQQQ.js +32 -0
  137. package/dist/preview/{chunk.IOK4GVJC.js → chunk.UKQUUPKE.js} +1 -1
  138. package/dist/preview/{chunk.TAT2IQUR.js → chunk.UQQKDBIH.js} +1 -1
  139. package/dist/preview/{chunk.QHDCTAD7.js → chunk.UVA7AALY.js} +1 -1
  140. package/dist/preview/chunk.UXMPFPFH.js +20 -0
  141. package/dist/preview/chunk.VACKSKGJ.js +1 -0
  142. package/dist/preview/{chunk.3UOKUF5Z.js → chunk.VC3V7HLL.js} +1 -1
  143. package/dist/preview/chunk.VIH5AX7S.js +5 -0
  144. package/dist/preview/{chunk.4LR64TPU.js → chunk.VJBBVLGZ.js} +1 -1
  145. package/dist/preview/chunk.VN23AGIY.js +1 -0
  146. package/dist/preview/{chunk.VZJWJ5XM.js → chunk.W4BKYSZX.js} +1 -1
  147. package/dist/preview/{chunk.CQT3W2SF.js → chunk.WEOVK2T4.js} +1 -1
  148. package/dist/preview/chunk.WKI5INH7.js +1 -0
  149. package/dist/preview/chunk.WPXPVD33.js +88 -0
  150. package/dist/preview/chunk.X6KYRBL6.js +1 -0
  151. package/dist/preview/chunk.Y2YYH3JN.js +1 -0
  152. package/dist/preview/chunk.Y4FZKUOK.js +1 -0
  153. package/dist/preview/chunk.Y4S7CDRB.js +1 -0
  154. package/dist/preview/{chunk.YFSBVZTG.js → chunk.YP2QSPXU.js} +1 -1
  155. package/dist/preview/{chunk.VWJGQDCE.js → chunk.Z2TDZSMN.js} +1 -1
  156. package/dist/preview/chunk.ZN3PUM2I.js +1 -0
  157. package/dist/preview/index.html +53 -51
  158. package/dist/preview/page.js +2 -2
  159. package/dist/preview/splash.js +57 -0
  160. package/package.json +6 -6
  161. package/dist/preview/chunk.2K4TT2BV.js +0 -1
  162. package/dist/preview/chunk.37TVS7CA.js +0 -1
  163. package/dist/preview/chunk.3IZ3ABII.js +0 -1
  164. package/dist/preview/chunk.3MOJF7BA.js +0 -1
  165. package/dist/preview/chunk.3V4WP7RY.js +0 -18
  166. package/dist/preview/chunk.3ZT5WQYL.js +0 -1
  167. package/dist/preview/chunk.4MP72LPR.js +0 -25
  168. package/dist/preview/chunk.4TCKEG6I.js +0 -1
  169. package/dist/preview/chunk.5DD62IOW.js +0 -21
  170. package/dist/preview/chunk.5YOLUDVO.js +0 -1
  171. package/dist/preview/chunk.644FUGSX.js +0 -1
  172. package/dist/preview/chunk.67U6M7OV.js +0 -1
  173. package/dist/preview/chunk.7TFLRR7D.js +0 -1
  174. package/dist/preview/chunk.7VKSXGTX.js +0 -1
  175. package/dist/preview/chunk.BF6S5UE4.js +0 -1
  176. package/dist/preview/chunk.BLPYNNR4.js +0 -1
  177. package/dist/preview/chunk.BRT27WON.js +0 -1
  178. package/dist/preview/chunk.BYKD5RLA.js +0 -1
  179. package/dist/preview/chunk.C7OLSEWK.js +0 -1
  180. package/dist/preview/chunk.CFKZXLXS.js +0 -1
  181. package/dist/preview/chunk.CMN6BBAD.js +0 -1
  182. package/dist/preview/chunk.D7YSL3NK.js +0 -2
  183. package/dist/preview/chunk.EQXB7LKI.js +0 -1
  184. package/dist/preview/chunk.ERFT54HT.js +0 -1
  185. package/dist/preview/chunk.FLUK3UXF.js +0 -1
  186. package/dist/preview/chunk.G3R4BTI7.js +0 -1
  187. package/dist/preview/chunk.G4YJPKRG.js +0 -5
  188. package/dist/preview/chunk.GLWSVSQL.js +0 -1
  189. package/dist/preview/chunk.I4XQBQRC.js +0 -1
  190. package/dist/preview/chunk.IBOKXVWN.js +0 -1
  191. package/dist/preview/chunk.IHBUBZQT.js +0 -2
  192. package/dist/preview/chunk.JEYQBH33.js +0 -32
  193. package/dist/preview/chunk.JJGCTGWA.js +0 -1
  194. package/dist/preview/chunk.KGW75Z5L.js +0 -3
  195. package/dist/preview/chunk.KI37ZEV3.js +0 -1
  196. package/dist/preview/chunk.KNYLY7MH.js +0 -1
  197. package/dist/preview/chunk.L6AWE76F.js +0 -1
  198. package/dist/preview/chunk.LGEA5257.js +0 -6
  199. package/dist/preview/chunk.LLYRFVIN.js +0 -104
  200. package/dist/preview/chunk.LZIBQ3VX.js +0 -1
  201. package/dist/preview/chunk.MDJWK5W2.js +0 -1
  202. package/dist/preview/chunk.MSWWWLEA.js +0 -1
  203. package/dist/preview/chunk.PFSYXD6Q.js +0 -1
  204. package/dist/preview/chunk.PHC2MI4C.js +0 -1
  205. package/dist/preview/chunk.PHJ6WPWH.js +0 -1
  206. package/dist/preview/chunk.PNW5K7BW.js +0 -1
  207. package/dist/preview/chunk.PXQVXBNG.js +0 -1
  208. package/dist/preview/chunk.QFUMFQJU.js +0 -1
  209. package/dist/preview/chunk.QI4SLPQ4.js +0 -4
  210. package/dist/preview/chunk.QUJS63OJ.js +0 -13
  211. package/dist/preview/chunk.SB2PZKN5.js +0 -88
  212. package/dist/preview/chunk.T7LQD67N.js +0 -20
  213. package/dist/preview/chunk.TY4GQJKC.js +0 -1
  214. package/dist/preview/chunk.UDCDK7XJ.js +0 -4
  215. package/dist/preview/chunk.UITT6JWW.js +0 -2
  216. package/dist/preview/chunk.UJTE7UAP.js +0 -1
  217. package/dist/preview/chunk.UQWTZJBV.js +0 -1
  218. package/dist/preview/chunk.VMV464JK.js +0 -1
  219. package/dist/preview/chunk.VSCIXAHN.js +0 -5
  220. package/dist/preview/chunk.W3W54DSX.js +0 -1
  221. package/dist/preview/chunk.WC3DENU4.js +0 -67
  222. package/dist/preview/chunk.WQ6RCEUQ.js +0 -1
  223. package/dist/preview/chunk.X6A4VSSD.js +0 -1
  224. package/dist/preview/chunk.XGASJAV2.js +0 -7
  225. package/dist/preview/chunk.XR6YR6RV.js +0 -1
  226. package/dist/preview/chunk.XZPKBHJT.js +0 -1
  227. package/dist/preview/chunk.YEBGI6ED.js +0 -1
  228. package/dist/preview/chunk.YH63KQ2G.js +0 -1
@@ -0,0 +1,4 @@
1
+ var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as Dt,f as ut,g as Sn}from"./chunk.KMV6PJFL.js";import{h as mi}from"./chunk.NAD7ZXYP.js";import{e as fi,q as Xn,r as pi}from"./chunk.2GEJNG2U.js";import{b as Mn}from"./chunk.22BZU7ME.js";import{a as Be,b as Vr,c as Zt,d as gi,e as Gr}from"./chunk.2N4Z5K5S.js";import{a as hi}from"./chunk.M4AYA2PL.js";import{a as li,b as ci,c as ui}from"./chunk.PZQNR4KZ.js";import{b as ti,d as ni}from"./chunk.W4BKYSZX.js";import{a as ri,b as Dr,c as $r,f as Fr,g as Wr,h as jr,i as oi,j as Xt,k as qt,o as Ht,p as Qt,q as si,r as di}from"./chunk.UKQUUPKE.js";import{A as Jo,f as Go,g as Kt,h as zo,i as Yo,j as _o,k as Ko,m as Un,n as vn,o as kn,p as Ut,q as Hr,v as Uo,w as Xo,x as qo,y as Qo,z as Zo}from"./chunk.OJGHDWI6.js";import{a as ii,b as ai}from"./chunk.DDUCIUVW.js";import{c as ei}from"./chunk.ACTXR2MI.js";import{$ as Kn,A as ct,B as Pr,C as xn,G as Re,Ia as bn,K as xt,Na as Cr,Oa as Ir,Pa as Bt,Ra as Nr,T as Me,V as _n,Va as Br,W as Lr,_ as Tr,a as Sr,aa as It,b as Mr,ba as me,c as Er,d as Ho,da as Nt,e as Do,f as zn,h as Tt,ia as Fo,j as yt,ja as Wo,k as Rr,l as Yn,m as yn,ma as _t,oa as jo,p as Or,r as Se,s as Le,t as $o,u as wn,ua as Vo,v as Te,w as Ct,x as wt,y as Ar}from"./chunk.M7RESZB6.js";import{a as Yt}from"./chunk.SDO3U72B.js";import{Hc as gn,Kd as kr,Md as Co,ae as Io,de as No,ga as Vn,gd as Fe,ia as Lo,ja as Gt,ke as Bo,la as zt,ma as Lt,na as Gn,ra as To}from"./chunk.DZZL5IDD.js";import{b as re}from"./chunk.AJZBJBMO.js";var qn=re(Re(),1);var yi=re(Me(),1);function Qn(e){let t=(0,qn.useRef)(e);t.current=e;let n=(0,qn.useRef)(null),o=(0,qn.useRef)(new Map),r=n.current;if(r&&(r.outer===e||us(r.outer,e)))return r.outer=e,r.inner;let s=ut(e.view,null),i=(c,d,a)=>{let u=o.current.get(c);return u&&u.made===d?u.call:(o.current.set(c,{made:d,call:a}),a)},l=Object.fromEntries(Object.entries(e).map(([c,d])=>[c,c==="view"?s:c==="setView"?i(c,d,cs(t)):typeof d=="function"?i(c,d,(...a)=>t.current[c](...a)):d]));return n.current={outer:e,inner:l},l}function cs(e){return t=>e.current.setView(typeof t=="function"?t:n=>t.pan===void 0&&n.pan?{...t,pan:n.pan}:t)}function us(e,t){let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let o of n){if(o==="view"||o==="movedByHand")continue;let r=e[o],s=t[o];if(r!==s&&!(typeof r=="function"&&typeof s=="function"))return!1}return zr(e.view,t.view)}function zr(e,t){if(e===t)return!0;let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let o of n)if(o!=="pan"&&e[o]!==t[o])return!1;return!0}function hs({children:e}){let t=Qn(me());return(0,yi.jsx)(_n.Provider,{value:t,children:e})}var wi={width:1200,height:760,focusSize:{width:1200,height:420},relationSize:{width:240,height:140},contextSize:{width:300,height:104},gap:16,unit:16};var xi=(e,t)=>e?`${e.edgeKind}|${e.direction}`:`raised|${t}`,$t=(e,t,n)=>`${Pr}${e}|${t}|${n}`;function Zn(e,t){let n=e.map(()=>0),o=e.map((i,l)=>({size:i,index:l})).sort((i,l)=>i.size-l.size||i.index-l.index),r=Math.max(t,e.length),s=e.length;for(let{size:i,index:l}of o){let c=Math.max(1,Math.floor(r/s));n[l]=Math.min(i,c),r-=n[l],s-=1}return n}function _r(e){return xi(e.via,e.node.kind)}function Jt(e,t,n=[]){let o=[],r=0;return e.forEach((s,i)=>{if(s<=0)return;let l=Math.min(t,Math.max(1,n[i]??1)),c=Math.max(s,l);if(o.length>0&&s<=t&&c<=r){o[o.length-1].push({run:i,cards:s,slots:c}),r-=c;return}let d=s,a=!0;for(;d>0;){let u=Math.min(t,d),h=a?Math.max(u,l):u;o.push([{run:i,cards:u,slots:h}]),d-=u,r=t-h,a=!1}}),o}function Kr(e,t,n,o=[]){let r=Zn(e,t*n);for(;Jt(r,t,o).length>n;){let s=-1;if(r.forEach((i,l)=>{i>1&&(s<0||i>r[s])&&(s=l)}),s<0)break;r[s]=r[s]-1}return r}function fs(e,t,n){let o=r=>[t.chosen?.has(r.id)?0:1,t.hits?.has(r.id)?0:1,t.flagged?.has(r.id)?0:1,-(t.touched?.get(r.id)??0),-n.neighbors(r.id).length];return e.map((r,s)=>({node:r,index:s,key:o(r)})).sort((r,s)=>{for(let i=0;i<r.key.length;i++)if(r.key[i]!==s.key[i])return r.key[i]-s.key[i];return r.index-s.index}).map(r=>r.node)}var ps=5,ms=(e,t)=>{for(let n=0;n<e.length;n++)if(e[n]!==t[n])return e[n]<t[n];return!1};function bi(e,t,n){if(e.length===0||t<2)return;let o=e[0].kind,r={schema:n.schema,graph:n.graph,...n.today?{today:n.today}:{}},s=[];for(let l of fi(n.schema,o).groups)if(l.key!==n.exclude)if(l.buckets)for(let c of["decade","year","month"])s.push({by:l.key,bucket:c});else s.push({by:l.key});let i;return s.forEach((l,c)=>{let a=mi(e,{group:l},r).groups;if(a.length<2||a.length>t)return;let h=a.filter(x=>x.key!=="").reduce((x,f)=>x+f.nodes.length,0)/e.length;if(h<.5||a.some(x=>x.nodes.length>e.length*.75))return;let m=[-Math.round(h*100),Math.abs(a.length-ps),c];(!i||ms(m,i.score))&&(i={grouping:{by:l.by,...l.bucket?{bucket:l.bucket}:{},groups:a},score:m})}),i?.grouping}function Ur(e,t){let n=f=>({id:f.node.id,kind:f.node.kind,node:f.node,...f.via?{via:f.via}:{}});if(e.length<=t.budget)return e.map(n);let o={...t.relevance,chosen:new Set([...t.relevance?.chosen??[],...t.selection??[]])},r=new Map;for(let f of e){let g=xi(f.via,f.node.kind),v=r.get(g);v?v.push(f):r.set(g,[f])}let s=[...r.entries()].map(([f,g])=>({key:f,run:g,via:g[0].via,kinds:[...new Set(g.map(v=>v.node.kind))],members:[],whole:!1,extra:0})),i=Zn(s.map(f=>f.run.length),t.budget);s.forEach((f,g)=>f.whole=f.run.length<=i[g]);let l=s.filter(f=>!f.whole),c=s.filter(f=>f.whole).reduce((f,g)=>f+g.run.length,0),d=Math.max(l.length,t.budget-c);for(let f of l){f.members=fs(f.run.map(v=>v.node),o,t.graph);let g=d-(l.length-1);f.kinds.length>1&&f.kinds.length<=g?f.byKind=!0:f.kinds.length===1&&(f.grouping=bi(f.members,g,{schema:t.schema,graph:t.graph,...f.via?{exclude:f.via.edgeKind}:{},...t.today?{today:t.today}:{}}))}let a=f=>f.byKind?f.kinds.length:f.grouping?f.grouping.groups.length:1;for(;l.reduce((f,g)=>f+a(g),0)>d;){let f=[...l].filter(g=>a(g)>1).sort((g,v)=>a(v)-a(g))[0];if(!f)break;f.grouping=void 0,f.byKind=!1}d-=l.reduce((f,g)=>f+a(g),0);let u=f=>f.byKind?f.kinds.some(g=>t.expanded.has($t(g,f.key,"kind"))):f.grouping?.groups.some(g=>t.expanded.has($t(f.kinds[0],f.key,Yr(f.grouping,g.key)))),h=l.filter(f=>!f.grouping&&!f.byKind?!0:u(f)),m=Zn(h.map(f=>f.members.length),Math.max(0,d));h.forEach((f,g)=>f.extra=d>0?m[g]:0);let x=[];for(let f of s){let{key:g,via:v}=f;if(f.whole){x.push(...f.run.map(n));continue}let k=y=>({id:y.id,kind:y.kind,node:y,...v?{via:v}:{}}),w=new Map(f.run.map((y,S)=>[y.node.id,S])),O=(y,S,P)=>{let A=[...y.slice(0,S)].sort((te,C)=>w.get(te.id)-w.get(C.id));x.push(...A.map(k));let W=y.slice(S);if(W.length===0)return;let K=W[0].kind;x.push({id:$t(K,g,P?`more:${P}`:"more"),kind:K,...v?{via:v}:{},aggregate:{kind:K,memberIds:W.map(te=>te.id),label:S>0?`${W.length} more ${t.plural(K).toLowerCase()}`:`${W.length} ${t.plural(K).toLowerCase()}`,opens:{in:"picture",focus:Te(K),within:P?{filter:P}:{}}}})},G=v&&t.focusId?`${v.edgeKind}:${t.focusId}`:void 0;if(f.byKind){let y=f.kinds.find(S=>t.expanded.has($t(S,g,"kind")));for(let S of f.kinds){let P=f.members.filter(A=>A.kind===S);if(S===y){let A=f.extra+1;P.length<=A?x.push(...P.map(k)):O(P,A-1,G);continue}x.push({id:$t(S,g,"kind"),kind:S,...v?{via:v}:{},aggregate:{kind:S,memberIds:P.map(A=>A.id),label:t.plural(S),opens:{in:"place"}}})}continue}let D=f.grouping;if(!D){O(f.members,f.extra,G);continue}let X=f.kinds[0],j=D.groups.find(y=>t.expanded.has($t(X,g,Yr(D,y.key))));for(let y of D.groups){if(y===j){let S=f.members.filter(A=>y.nodes.includes(A)),P=f.extra+1;if(S.length<=P)x.push(...S.map(k));else{let A=y.key!==""&&!y.key.includes(",")&&!D.bucket,W=[G,A?`${D.by}:${y.key}`:void 0].filter(Boolean).join(",")||void 0;O(S,P-1,W)}continue}x.push({id:$t(X,g,Yr(D,y.key)),kind:X,...v?{via:v}:{},aggregate:{kind:X,memberIds:f.members.filter(S=>y.nodes.includes(S)).map(S=>S.id),label:y.label.charAt(0).toUpperCase()+y.label.slice(1),opens:{in:"place"}}})}}return x}var Yr=(e,t)=>`${e.by}${e.bucket?`:${e.bucket}`:""}=${t||"none"}`;var Jn=300,vi=12,en=8,Xr=19;var er=(e,t=1)=>(e.length*8.4+16)*t;function En(e){return e.description??`${e.direction==="in"?"\u2190":"\u2192"} ${Vn(e.edgeKind).toLowerCase()}`}function qr(e,t,n=1){let o=l=>er(l,n),r=new Map;for(let l of e){let c=r.get(l.key);c?c.push(l):r.set(l.key,[l])}let s=[...r.values()].map(l=>{let c=Math.min(...l.map(a=>a.top)),d=l.filter(a=>a.top-c<=vi);return{key:l[0].key,text:l[0].text,left:Math.min(...d.map(a=>a.left)),right:Math.max(...d.map(a=>a.right)),top:c}});s.sort((l,c)=>l.top-c.top||l.left-c.left);let i=s.map(l=>{let c=Math.max(l.right-l.left,Math.min(Jn,o(l.text))),d=(l.left+l.right)/2;return{left:d-c/2,right:d+c/2}});return s.map((l,c)=>{let d=s.map((w,O)=>({other:w,at:O})).filter(({other:w})=>w!==l&&Math.abs(w.top-l.top)<=vi),a=d.filter(({other:w})=>w.right<=l.left).map(({other:w,at:O})=>i[O].right+en<=(w.right+l.left)/2?i[O].right+en:(w.right+l.left+en)/2),u=d.filter(({other:w})=>w.left>=l.right).map(({other:w,at:O})=>i[O].left-en>=(l.right+w.left)/2?i[O].left-en:(l.right+w.left-en)/2),h=Math.max(t.left,...a),m=Math.min(t.right,...u),x=l.right-l.left,f=i[c].right-i[c].left,g=Math.max(x,Math.min(f,m-h)),v=(l.left+l.right)/2,k=x>=g?l.left:Math.max(h,Math.min(v-g/2,m-g));return{key:l.key,text:l.text,left:k,width:g,top:l.top}})}function Si(e,t,n,o,r=1){let s=l=>String(l).length*7.4,i=e.length*8.6+6+s(t)+14+(n>0?22+s(n):0);return{width:Math.max(i,o?184:0)*r,height:(o?38:22)*r,short:{width:i*r,height:22*r}}}function Ft(e,t,n=6){return e.x<t.x+t.width+n&&t.x<e.x+e.width+n&&e.y<t.y+t.height+n&&t.y<e.y+e.height+n}var Qr=(e,t,n,o)=>{let r=Math.max(e.x,Math.min(t.x,e.x+e.width)),s=Math.max(e.y,Math.min(t.y,e.y+e.height));return Math.abs(r-t.x)/n+Math.abs(s-t.y)/o<.92},Rn=4,ki=.45;function Zr(e,t,n,o={},r={}){let s={};for(let b of e)s[b.kind]=b.count;let i={x:(o.left??0)+8,y:(o.top??0)+8,width:n.width-(o.left??0)-(o.right??0)-16,height:n.height-(o.top??0)-(o.bottom??0)-16},l=r.avoid??[],c=r.tilt??.5,d=b=>b.nameplate??{width:120,height:34,short:{width:90,height:20}},a=b=>e.map(E=>{let T=b.get(E.kind);return{card:E,plot:T,center:Zt(T.col+T.side/2,T.row+T.side/2,1,c)}}),u=(b,E)=>{let T=1/0,M=-1/0,B=1/0,L=-1/0;for(let{card:F,plot:Z,center:_}of b){let z=_.x*E,ee=_.y*E,q=Z.side*E/2,he=F.opened>0?d(F).width:d(F).short.width;T=Math.min(T,z-Math.max(q+(F.count>12?30:0),he/2)),M=Math.max(M,z+Math.max(q,he/2)),B=Math.min(B,ee-q*c-E*ki),L=Math.max(L,ee+q*c+Rn+d(F).short.height)}return{minX:T,maxX:M,minY:B,maxY:L}},h=b=>{let E=4,T=160;for(let M=0;M<24;M++){let B=(E+T)/2,L=u(b,B);L.maxX-L.minX<=i.width&&L.maxY-L.minY<=i.height?E=B:T=B}return E},m=b=>{let E={...r.order?{order:r.order}:{},counts:s,...r.plots?{plots:r.plots}:{},pitch:b},T=Vr(t,E),M=Vr(t,{...E,upright:!0}),B=h(a(T)),L=h(a(M)),F=n.height>n.width&&L>=B?M:T;return{map:F,fitted:F===M?L:B}},x=[],f=new Map,g=0,v=(b,E={x:0,y:0})=>{let T=u(x,b),M=i.x+i.width/2-(T.minX+T.maxX)/2+E.x,B=i.y+i.height/2-(T.minY+T.maxY)/2+E.y;return{originX:M,originY:B,cell:b}},k=b=>{let{originX:E,originY:T,cell:M}=b,B=x.map(({center:Z})=>Z.y),L=Math.max(...B),F=Math.min(...B);return x.map(({card:Z,plot:_,center:z})=>{let ee=E+z.x*M,q=T+z.y*M,he=_.side*M/2,ce=he*c,He=L===F?.5:(z.y-F)/(L-F);return{card:Z,plot:_,x:ee,y:q,halfW:he,halfH:ce,depth:1-He*.65}})},w=(b,E=!0)=>{let T=[];return[...b].sort((B,L)=>(L.card.weight??L.card.count)-(B.card.weight??B.card.count)||e.indexOf(B.card)-e.indexOf(L.card)).filter(B=>[d(B.card),d(B.card).short].some(L=>{let F=D(B,L),Z=(!E||F.x>=0&&F.y>=0&&F.x+F.width<=n.width&&F.y+F.height<=n.height)&&!T.some(_=>Ft(F,_,4))&&!b.some(_=>_!==B&&Qr(F,_,_.halfW,_.halfH))&&!l.some(_=>Ft(F,_,0));return Z&&T.push(F),Z})).length},O=b=>b.card.marquee?{x:b.x-b.card.marquee.width/2,y:b.y+b.halfH+Rn+d(b.card).height,width:b.card.marquee.width,height:b.card.marquee.height}:null,G=(b,E,T)=>T.some(M=>{if(M===E)return!1;let B=O(M);return B!==null&&Ft(b,B,4)}),D=(b,E,T="under")=>T==="aside"?{x:b.x+b.halfW+Rn,y:b.y-E.height/2,width:E.width,height:E.height}:T==="above"?{x:b.x-E.width/2,y:b.y-b.halfH-Rn-ki*S.cell-E.height,width:E.width,height:E.height}:{x:b.x-E.width/2,y:b.y+b.halfH+Rn,width:E.width,height:E.height},X=b=>b.some(E=>l.some(T=>Qr(T,E,E.halfW,E.halfH)||Ft(T,D(E,d(E.card).short),0))),j=b=>b.every(E=>{let T=D(E,d(E.card).short);return E.x-E.halfW>=0&&E.x+E.halfW<=n.width&&E.y-E.halfH>=0&&T.x>=0&&T.x+T.width<=n.width&&T.y+T.height<=n.height}),y={pitch:Be,said:-1};for(let b of[Be,Be+1,Be+2,Be+3,Be+5,Be+7]){({map:f,fitted:g}=m(b)),x=a(f);let E=w(k(v(g)));if(E>y.said&&(y={pitch:b,said:E}),E===e.length)break}(y.pitch!==Be+7||y.said!==e.length)&&({map:f,fitted:g}=m(y.pitch),x=a(f));let S=v(g);if(l.length>0&&X(k(S))){let b;for(let E=1;E>=.3&&!b;E-=.05){let T=g*E,M=Math.max(...l.map(L=>L.width))/2+T,B=Math.max(...l.map(L=>L.height))/2+T/2;for(let L of[0,.5,.75,1,1.25]){for(let[F,Z]of[[1,0],[-1,0],[0,1],[0,-1],[1,1],[-1,1],[1,-1],[-1,-1]]){let _=v(T,{x:F*M*L,y:Z*B*L}),z=k(_);if(!X(z)&&j(z)){b=_;break}if(L===0)break}if(b)break}}b&&(S=b)}let P=(b,E)=>{let T={x:n.width/2,y:n.height/2};return{cell:b.cell*E,originX:T.x+(b.originX-T.x)*E,originY:T.y+(b.originY-T.y)*E}},A=1;if(w(k(S))<e.length){let b={said:w(k(S),!1),area:1/0,pitch:-1,by:1},E={map:f,shape:x,fitted:g,where:S};for(let M of[Be,Be+1,Be+2,Be+3,Be+5,Be+7]){({map:f,fitted:g}=m(M)),x=a(f);let B=v(g);for(let L=1;L<=3.001;L+=.1){let F=w(k(P(B,L)),!1),Z=u(x,g*L),_=(Z.maxX-Z.minX)*(Z.maxY-Z.minY);if((F>b.said||F===b.said&&_<b.area)&&(b={said:F,area:_,pitch:M,by:L}),F===e.length)break}}b.pitch<0?{map:f,shape:x,fitted:g,where:S}=E:({map:f,fitted:g}=m(b.pitch),x=a(f),A=b.by,S=P(v(g),A));let T=k(S).filter(M=>r.keep?.includes(M.card.kind));if(T.length>0){let M=T.flatMap(z=>[{x:z.x-z.halfW,y:z.y-z.halfH,width:z.halfW*2,height:z.halfH*2},D(z,d(z.card))]),B=Math.min(...M.map(z=>z.x)),L=Math.max(...M.map(z=>z.x+z.width)),F=Math.min(...M.map(z=>z.y)),Z=Math.max(...M.map(z=>z.y+z.height)),_=(z,ee,q)=>ee-z>q-16?q/2-(z+ee)/2:z<8?8-z:ee>q-8?q-8-ee:0;S={...S,originX:S.originX+_(B,L,n.width),originY:S.originY+_(F,Z,n.height)}}}let W=r.zoom&&r.zoom!==1?r.zoom:1;W!==1&&(S=P(S,W));let K=k(S),te=[],C=new Map,H=new Map,N=[...K].sort((b,E)=>(E.card.weight??E.card.count)-(b.card.weight??b.card.count)||e.indexOf(b.card)-e.indexOf(E.card));for(let b of N){let E=[["full",d(b.card),"under"],["short",d(b.card).short,"under"]],T="none",M=b===N[0],B=(F,Z)=>E.filter(([_])=>_.startsWith(Z)).map(([_,z,ee])=>[_,z,ee,F]),L=M?[...B(!1,"full"),...B(!1,"short"),...B(!0,"full"),...B(!0,"short")]:E.map(([F,Z,_])=>[F,Z,_,!1]);for(let[F,Z,_,z]of L){let ee=D(b,Z,_);if((W!==1||A!==1||ee.x>=0&&ee.y>=0&&ee.x+ee.width<=n.width&&ee.y+ee.height<=n.height)&&!te.some(ce=>Ft(ee,ce,4))&&(z||!K.some(ce=>ce!==b&&Qr(ee,ce,ce.halfW,ce.halfH)))&&!G(ee,b,K)&&!l.some(ce=>Ft(ee,ce,0))){T=F,te.push(ee),H.set(b.card.id,ee);break}}C.set(b.card.id,T)}let Q=K.map(b=>({id:b.card.id,x:b.x-b.halfW,y:b.y-b.halfH,width:b.halfW*2,height:b.halfH*2+(b.card.opened>0?Math.max(b.card.openedMin??0,b.card.opened):0),depth:b.depth,plot:b.plot,nameplate:C.get(b.card.id)??"none"})),R=u(x,S.cell),$={cell:S.cell,originX:S.originX,originY:S.originY,pan:r.pan??{x:0,y:0},extent:{x:S.originX+R.minX,y:S.originY+R.minY,width:R.maxX-R.minX,height:R.maxY-R.minY},openedShare:1,...c!==.5?{tilt:c}:{},...H.size>0?{nameplates:K.flatMap(b=>{let E=H.get(b.card.id);return E?[{id:b.card.id,x:E.x-(b.x-b.halfW),y:E.y-(b.y-b.halfH),width:E.width,height:E.height}]:[]})}:{},...K.some(b=>b.card.marquee)?{showings:K.flatMap(b=>{let E=O(b);return E?[{id:b.card.id,x:E.x-(b.x-b.halfW),y:E.y-(b.y-b.halfH),width:E.width,height:E.height}]:[]})}:{}};return{placed:Q,frame:$,map:f}}function bt(e){let{width:t,height:n}=e.visible??e,o={x:t*.45,y:n*.45};if(!e.city)return o;let{extent:r}=e.city,s=24;return{x:Math.max(o.x,r.x+r.width-t+s,-r.x+s),y:Math.max(o.y,r.y+r.height-n+s,-r.y+s)}}var tr=48;function Jr(e){if(!e.city)return[];let{width:t,height:n}=e.visible??e,o=[];for(let r of e.nodes){if(!r.id.startsWith("kind:")||Math.round(r.plane)!==2)continue;let s=r.x+r.width/2,i=r.y+r.height/2,l=s<0?"left":s>t?"right":i<0?"top":i>n?"bottom":null;if(!l)continue;let c=l==="left"||l==="right",d=c?Math.max(0,Math.min(n,i)):Math.max(0,Math.min(t,s)),a=(m,x)=>m<x/4?x/4-m:m>x*3/4?x*3/4-m:0,u=(m,x)=>m<tr?tr-m:m>x-tr?x-tr-m:0,h=c?{x:a(s,t),y:u(i,n)}:{x:u(s,t),y:a(i,n)};o.push({id:r.id,kind:r.id.slice(5),side:l,along:d,by:h})}return o}function eo(e,t,n,o,r){return{x:e.x+(n.x-e.x-t.x-o.x)*(1-r),y:e.y+(n.y-e.y-t.y-o.y)*(1-r)}}var gs={rankOf:()=>{},parentOf:()=>{}};function Mi(e,t){if(t.size===0)return gs;let n=e.kinds,o=new Map,r=(d,a)=>{d!==a&&((o.get(d)??o.set(d,new Set).get(d)).add(a),(o.get(a)??o.set(a,new Set).get(a)).add(d))};for(let d of n){let a=e.tryDefinition(d);if(a)for(let u of Object.values(a.edges??{})){let h=u.to==="*"?n:u.to;for(let m of h)r(d,m)}}let s=new Map,i=new Map,l=[...t].filter(d=>n.includes(d));for(let d of l)s.set(d,0);let c=0;for(;l.length>0;){c+=1;let d=[];for(let a of[...l].sort((u,h)=>n.indexOf(u)-n.indexOf(h)))for(let u of[...o.get(a)??[]].sort((h,m)=>n.indexOf(h)-n.indexOf(m)))s.has(u)||(s.set(u,c),c===2&&i.set(u,a),d.push(u));l=d}return{rankOf:d=>{let a=s.get(d);if(a!==0)return a===1?"primary":"secondary"},parentOf:d=>i.get(d)}}function Ei(e,t,n,o,r={}){if(n){let s=new Map;for(let i of e.allEdges()){if(o&&i.kind!==o)continue;let l=i.from===n.id?i.to:i.to===n.id?i.from:null;if(l===null||l===n.id)continue;let c=e.getNode(l);if(!c||s.has(l))continue;let d=i.from===n.id?"out":"in",a=d==="out"?n.kind:c.kind,u=ys(t,a,i.kind,d);s.set(l,{node:c,via:{edgeKind:i.kind,direction:d,...u?{description:u}:{}}})}if(s.size>0){let i=l=>`${l.via.edgeKind}|${l.via.description??""}`;return[...s.values()].sort((l,c)=>(i(l)<i(c)?-1:i(l)>i(c)?1:0)||ct(l.node,c.node))}}if(n){let s=r[n.id]??[],i=new Set,l=[];for(let c of s){if(c===n.id||i.has(c))continue;let d=e.getNode(c);d&&(o&&o!=="judges"&&d.kind!==o||(i.add(c),l.push({node:d,via:{edgeKind:"judges",direction:"out",description:"what it finds wrong"}})))}if(l.length>0)return l.sort((c,d)=>ct(c.node,d.node))}return o?e.allNodes().filter(s=>s.kind===o).sort(ct).map(s=>({node:s})):[]}function ys(e,t,n,o){let s=e.tryDefinition(t)?.edges?.[n];return o==="out"?s?.description:s?.inverse}function Ri(e,t,n){let o=new Map,r=[...t.values()].sort((d,a)=>d.plane-a.plane);for(let d of r)for(let a of d.aggregate?.memberIds??[])!t.has(a)&&!o.has(a)&&o.set(a,d.id);let s=d=>t.get(d)??t.get(o.get(d)??""),i=new Map,l=new Map,c=new Map;for(let d of e.allEdges()){let a=s(d.from),u=s(d.to);if(!a||!u||a.id===u.id&&!(n.overview&&a.aggregate&&a.plane===2))continue;let h=`${d.kind}:${a.id}:${u.id}`,m=i.get(h);if(m){let x=`${d.from}
2
+ ${d.to}`,f=l.get(h);if(f.has(x))continue;if(f.add(x),c.get(h).push({from:d.from,to:d.to}),m.single){let{single:g,...v}=m;i.set(h,v)}continue}l.set(h,new Set([`${d.from}
3
+ ${d.to}`])),c.set(h,[{from:d.from,to:d.to}]),i.set(h,{id:h,kind:d.kind,from:a.id,to:u.id,edges:[{from:d.from,to:d.to}],single:{from:d.from,to:d.to},...a.id===u.id?{loop:!0}:{},x1:a.x+a.width/2,y1:a.y+a.height/2,x2:u.x+u.width/2,y2:u.y+u.height/2})}return[...i.values()].map(d=>({...d,edges:c.get(d.id)})).sort(ct)}var Ai=.85,Oi=60,to=160;function ws(e,t,n,o,r,s=Ai){let i=e*t.width+Math.max(0,e-1)*n,l=Math.max(n,(o-i)/2);return Array.from({length:e},(c,d)=>({x:l+d*(t.width+n),y:r,depth:s}))}function nr(e,t,n,o={}){let r={...wi,...o},s=Math.max(8,r.unit??16)/16,i=r.inset?.left??0,l=n.overview?Math.max(0,r.dock?.right??0):0,c=n.overview?Math.max(0,r.dock?.bottom??0):0,d=r.width-l-i-(r.inset?.right??0),a=[],u=new Map,h=p=>n.past===!0||Lo(t.tryDefinition(p.kind),p,r.today),m=new Set(o.hiddenKinds??[]),x=p=>!m.has(p.kind),f=n.focusId?wt(n.focusId).filter(p=>t.tryDefinition(p)!==void 0).filter(p=>!m.has(p)):[];n.focusId&&wt(n.focusId).length>0&&f.length===0&&(n={...n,focusId:null});let g=n.focusId?e.getNode(n.focusId):void 0;g&&!x(g)&&(n={...n,focusId:null},f=[]);let v=f.length>0?[...e.allNodes()].filter(p=>f.includes(p.kind)).sort(ct):[],k=v.filter(x).filter(h),w=v.length-k.length,O=n.focusId&&f.length===0?e.getNode(n.focusId):void 0,G=n.zoom===!0&&!n.overview&&n.focusId!==null,D=Math.max(56,r.height*.062),X=Math.min(r.height*.895,r.height-D),j=G?O!==void 0?{focusY:r.height*.03,focusH:r.height*.58,relationY:r.height*.645,relationH:r.height*.2,contextY:X,contextH:D}:{focusY:r.height*.03,focusH:r.height*.71,relationY:r.height*.765,relationH:r.height*.1,contextY:X,contextH:D}:O===void 0?{focusY:r.height*.045,focusH:r.height*.62,relationY:r.height*.68,relationH:r.height*.2,contextY:r.height*.918,contextH:r.height*.082}:(()=>{let p=r.height,V=p*.04,Y=Math.max(p*.42,Math.min(p*.56,300)),oe=V+Y+p*.06;return{focusY:V,focusH:Y,relationY:oe,relationH:Math.max(p*.12,p*.878-p*.068-oe),contextY:p*.878,contextH:p*.092}})(),y=Math.min(r.headroom??0,j.focusY+j.focusH*.2),S=y>j.focusY?{...j,focusY:y,focusH:j.focusH-(y-j.focusY)}:j,P=p=>Math.min(r.gap*p,Math.round(d*.1)),A=G?Math.min(880,d-P(5)):Math.min(700,d-P(6)),W=G?d-P(5):Math.min(r.focusSize.width,d-P(6)),K=(p,V,Y)=>({width:p===0?V:Math.min(V,(d-r.gap*(p+1))/p),height:Y}),te=(p,V,Y)=>{let oe=K(p,V,Y),ke=Math.min(V,to*s,d-r.gap*2);return oe.width>=ke?oe:{width:ke,height:Y}},C=p=>Math.max(1,Math.floor((d-r.gap)/(Math.min(p,to*s,d-r.gap*2)+r.gap))),H=new Set(n.expanded),N=n.overview?[]:Ei(e,t,O,n.relation,r.judged).filter(p=>x(p.node)).filter(p=>h(p.node)),Q=n.overview?0:Math.max(0,Oi*s-S.contextH),R=N.length>0?S.focusH:S.contextY-S.focusY-r.gap*2-Q,$=W,b=r.height,E=Math.min(d*.5/$,r.height*.48/b),T=$*E,M=b*E,B=new Set(o.plainGroups??[]),L=n.overview&&!O&&f.length>0&&n.focusId!==null,F=L&&f.length>0&&f.every(p=>B.has(p));if(L)for(let p of f)F&&o.besideTheMap!==!0?H.add(Se(p)):H.delete(Se(p));let Z=L&&!F&&f.length===1?f[0]:void 0,_=Z!==void 0&&(o.screens?.[Z]?.length??0)>0,z,ee=n.overview===!0&&O!==void 0&&o.besideTheMap===!0;n.overview&&(O||f.length>0)&&n.focusId&&!F&&!_&&!(L&&o.besideTheMap===!0)&&!ee?(z={x:i+(d-T)/2,y:r.height*.53-M/2,width:T,height:M},mn({id:n.focusId,kind:O?O.kind:f[0],plane:0,x:z.x,y:z.y,width:T,height:M,natural:{width:$,height:b},...O?{}:{aggregate:{kind:f.join("+"),memberIds:k.map(p=>p.id),label:o.plurals?.[n.focusId]??f.map(p=>Lt(t,p)).join(" and "),...w>0?{retired:w}:{}}}})):n.overview||(O?mn({id:O.id,kind:O.kind,plane:0,x:i+(d-A)/2,y:S.focusY,width:A,height:R}):f.length>0&&n.focusId&&mn({id:n.focusId,kind:f[0],plane:0,x:i+(d-W)/2,y:S.focusY,width:W,height:R,aggregate:{kind:f.join("+"),memberIds:k.map(p=>p.id),label:o.plurals?.[n.focusId]??f.map(p=>Lt(t,p)).join(" and "),...w>0?{retired:w}:{}}}));let q=26,he=52,ce=22,He=Math.round(r.relationSize.width*.75),Ee=Math.max(1,Math.floor((d-r.gap)/(He+r.gap))),Ae=r.unit/16,De=new Map;for(let p of N){let V=_r(p),Y=De.get(V);Y?Y.push(p):De.set(V,[p])}let Ce=[...De.values()],ie=Ce.length>1,ve=Math.max(r.gap,ce*Ae),Ze=ie?ve:r.gap,Et=Math.max(2,Math.floor((S.relationH+Ze)/(q*Ae+Ze))),ne=Math.min(r.relationSize.width,(d-r.gap*(Ee+1))/Ee)+r.gap,rt=Ce.map(p=>{let V=p[0].via;return!ie||!V?1:Math.ceil((Math.min(Jn*Ae,er(En(V),Ae))+r.gap)/ne)}),$e=Ce.map(p=>p.length),Rt=Jt($e,Ee,rt),Ve=N.length>Ee*Et||Rt.length>Et,Ot={schema:t,graph:e,focusId:O?.id,expanded:H,...r.relevance?{relevance:r.relevance}:{},...n.selection?{selection:n.selection}:{},plural:p=>Lt(t,p),...r.today?{today:r.today}:{}},Ue=Ve||ie?ve:r.gap,Je,Pe;if(!Ve)Je=Ce.flat().map(p=>({id:p.node.id,kind:p.node.kind,node:p.node,...p.via?{via:p.via}:{}})),Pe=Rt;else{let p=Math.max(1,Math.floor((S.relationH+Ue)/(he*Ae+Ue))),Y=Jt($e.map(()=>1),Ee,rt).length<=p?rt:[],oe=Kr($e,Ee,p,Y),ke=Ce.map((pe,Oe)=>Ur(pe,{...Ot,budget:oe[Oe]}));Je=ke.flat(),Pe=Jt(ke.map(pe=>pe.length),Ee,Y)}let Ie=Pe.length,ft=Ie===1?S.relationH:(S.relationH-Ue*(Ie-1))/Ie,Xe=K(Math.max(...Pe.map(p=>p.reduce((V,Y)=>V+Y.slots,0)),1),Je.length<=2?Math.round(r.relationSize.width*1.35):r.relationSize.width,ft),pt=[];{let p=Xe.width+r.gap,V=[],Y=0,oe=new Map;for(let pe of Pe.flat())oe.set(pe.run,(oe.get(pe.run)??0)+pe.cards);for(let pe=0;pe<Ce.length;pe++)V[pe]=Y,Y+=oe.get(pe)??0;let ke=Ce.map(()=>0);Pe.forEach((pe,Oe)=>{let lt=pe.reduce((gt,br)=>gt+br.slots,0),Wn=lt*Xe.width+Math.max(0,lt-1)*r.gap,jn=i+Math.max(r.gap,(d-Wn)/2),ss=S.relationY+Oe*(ft+Ue);for(let gt of pe){let br=gt.slots*p-r.gap,ds=gt.cards*p-r.gap,ls=jn+(br-ds)/2;for(let vr=0;vr<gt.cards;vr++)pt[V[gt.run]+ke[gt.run]++]={x:ls+vr*p,y:ss};jn+=gt.slots*p}})}Je.forEach((p,V)=>{let Y=pt[V];mn({id:p.id,kind:p.kind,plane:1,x:Y.x,y:Y.y,width:Xe.width,height:Xe.height,...p.via?{via:p.via}:{},...p.aggregate?{aggregate:p.aggregate}:{},...Ve&&!p.aggregate?{compact:!0}:{}})});let an=new Set(u.keys());for(let p of k)an.add(p.id);let dt=new Map;for(let p of e.allNodes()){let V=dt.get(p.kind);V?V.push(p):dt.set(p.kind,[p])}let ae=new Set(f.length>0?f:O?[O.kind]:[]),ye=[];for(let p of t.kinds){if(m.has(p))continue;let V=dt.get(p)??[],Y=V.filter(h);ye.push({id:Se(p),kind:p,members:Y.sort(ct),retired:V.length-Y.length,...ae.has(p)?{focused:!0}:{}})}for(let p of ye)p.kind===n.relation&&(p.raised=!0);ye.sort(ct);let Ge=Mi(t,ae),mt=!n.overview&&t.kinds.some(p=>Ge.rankOf(p)==="primary"),qe=[];for(let p of ye)if(!n.overview&&H.has(p.id)&&p.members.length>0)for(let V of p.members)qe.push({id:V.id,kind:V.kind});else{let V=mt?Ge.rankOf(p.kind):void 0,Y=V==="secondary"?Ge.parentOf(p.kind):void 0;qe.push({id:p.id,kind:p.kind,...p.raised?{raised:!0}:{},...p.focused?{focused:!0}:{},...n.overview&&H.has(p.id)?{opened:!0}:{},...V?{rank:V}:{},...Y&&!H.has(Se(Y))?{nestedUnder:Se(Y)}:{},aggregate:{kind:p.kind,memberIds:p.members.map(oe=>oe.id),label:o.plurals?.[p.kind]??Lt(t,p.kind),...p.retired>0?{retired:p.retired}:{}}})}let At=2;if(qe.length<=C((G?240:r.contextSize.width)*s))for(let p of qe)delete p.nestedUnder;let dn=new Map;for(let p of qe){if(p.nestedUnder===void 0)continue;let V=dn.get(p.nestedUnder)??0;V>=At?delete p.nestedUnder:dn.set(p.nestedUnder,V+1)}let ln=qe.filter(p=>p.nestedUnder!==void 0),Ne=qe.filter(p=>p.nestedUnder===void 0),cn=C((G?240:r.contextSize.width)*s),un=!n.overview&&Ne.length>cn,gr=Math.max(0,cn-1),Nn=p=>p.focused?0:p.raised?1:2,Vt=new Set([...Ne].map((p,V)=>({item:p,at:V})).sort((p,V)=>Nn(p.item)-Nn(V.item)||p.at-V.at).slice(0,gr).map(({item:p})=>p.id)),Pt=new Set(un?Ne.filter(p=>!Vt.has(p.id)).map(p=>p.id):[]),I=ln.filter(p=>!Pt.has(p.nestedUnder)),fe=ln.filter(p=>Pt.has(p.nestedUnder)),we=un?[...Ne.filter(p=>Vt.has(p.id)),{id:$o,kind:"",beyond:[...Ne.filter(p=>Pt.has(p.id)),...fe].map(p=>p.kind)}]:Ne,be=n.overview?{width:Math.min(220,d/6.5),height:Math.min(92,r.height*.125)}:te(we.length,(G?240:r.contextSize.width)*s,S.contextH),ot=r.relevance?.flagged,hn=(p,V)=>{let Y=Gr(t,p);if(!Y)return{};let oe=Y.values.map(()=>0),ke=0;for(let pe of V){let Oe=Y.values.indexOf(e.getNode(pe)?.[Y.field]);Oe<0?ke++:oe[Oe]++}return{states:{field:Y.field,values:[...Y.values.map((pe,Oe)=>({value:pe,tier:Y.tiers[Oe],count:oe[Oe]})),...ke>0?[{value:null,tier:"waiting",count:ke}]:[]]}}},ze=n.overview?Zr(we.map(p=>{let V=p.aggregate?.memberIds??[],Y=ot?V.filter(oe=>ot.has(oe)).length:0;return{id:p.id,kind:p.kind,count:V.length,opened:H.has(p.id)?qt(Xt(V.length))*s:0,openedMin:H.has(p.id)?qt(Math.min(jr,Xt(V.length)))*s:0,nameplate:Si(p.aggregate?.label??Lt(t,p.kind),V.length,Y,Gr(t,p.kind)!==void 0,s),weight:Y*1e3+V.length,...f.includes(p.kind)&&(o.screens?.[p.kind]?.length??0)>0?{marquee:{width:$r+12,height:Fr(o.screens[p.kind].map(oe=>oe.title),$r,o.nameWidth)+8}}:{}}}),t,{width:r.width-l,height:r.height-c},r.chrome?{...r.inset,right:Math.min(r.inset?.right??0,8)}:r.inset??{},{...r.cityOrder?{order:r.cityOrder}:{},...r.plots?{plots:r.plots}:{},...o.cityZoom&&o.cityZoom!==1?{zoom:o.cityZoom}:{},keep:[...n.selection??[],...n.focusId?[n.focusId]:[]].flatMap(p=>p.startsWith("kind:")?[p.slice(5)]:p.startsWith("aggregate:")&&!p.includes("|")?[p.slice(10)]:ee&&p===O?.id?[O.kind]:[]),...o.tilt!==void 0?{tilt:o.tilt}:{},pan:{x:n.pan?.x??0,y:n.pan?.y??0},...z||r.chrome?.length?{avoid:[...z?[z]:[],...r.chrome??[]]}:{}}):null,fn=new Map(ze?.placed.map(p=>[p.id,p.plot])??[]),Bn=new Map(ze?.placed.map(p=>[p.id,p.nameplate])??[]),pn=ze?ze.placed.map(({x:p,y:V,depth:Y,width:oe,height:ke})=>({x:p,y:V,depth:Y,width:oe,height:ke})):ws(we.length,be,r.gap,d,S.contextY,G?.97:Ai).map(p=>({...p,x:p.x+i})),Hn=.74,Dn=.8,is=52*s,as=86*s,yr=(p,V)=>Math.min(1,p+(1-p)*V),wr=new Map;we.forEach((p,V)=>{let Y=pn[V],oe=Y.width??be.width,ke=Y.height??be.height,pe=p.rank==="secondary"?Hn:1,Oe=ze?oe:Math.max(Math.min(oe,to*s),oe*pe),lt=ze?ke:Math.max(Oi*s,ke*pe);wr.set(p.id,{x:Y.x+(oe-Oe)/2,y:Y.y+(ke-lt),depth:p.rank==="secondary"?yr(Y.depth,.5):Y.depth,width:Oe,height:lt})});let $n=[],Fn=pn[pn.length-1],xr=new Map;for(let p of I)xr.set(p.nestedUnder,(xr.get(p.nestedUnder)??0)+1);let Po=new Map;for(let p of I){let V=wr.get(p.nestedUnder);if(V){let Y=xr.get(p.nestedUnder)??1,oe=Po.get(p.nestedUnder)??0;Po.set(p.nestedUnder,oe+1);let ke=.98,pe=be.width*Dn,Oe=Math.max(as,Math.min(pe,V.width/(ke*(Y-1)+1))),lt=Math.max(is,be.height*Dn*(Oe/pe)),Wn=Oe*ke,jn=(Y-1)*Wn+Oe;$n.push({...p,x:V.x+(V.width-jn)/2+oe*Wn,y:Math.max(0,V.y-lt+Math.min(lt*.5,16)),width:Oe,height:lt,depth:yr(V.depth,.8)})}else if(Fn){let Y=be.width*Dn,oe=be.height*Dn;$n.push({...p,x:Fn.x,y:Fn.y,width:Y,height:oe,depth:yr(Fn.depth??1,.8)})}}for(let p of we)$n.push({...p,...wr.get(p.id)});return $n.forEach(p=>{mn({id:p.id,kind:p.kind,plane:2,x:p.x,y:p.y,width:p.width,height:p.height,...p.aggregate?{aggregate:p.aggregate}:{},...p.raised?{raised:!0}:{},...p.focused?{focused:!0}:{},...p.opened?{opened:!0}:{},...p.opened?{openedRows:Math.max(1,Math.floor((Math.max(qt(Math.min(jr,Xt(p.aggregate?.memberIds.length??0))),qt(Xt(p.aggregate?.memberIds.length??0))*(ze?.frame.openedShare??1))-oi)/Wr))}:{},...p.rank?{rank:p.rank}:{},...p.nestedUnder?{nestedUnder:p.nestedUnder}:{},...p.beyond?{beyond:p.beyond}:{},...fn.has(p.id)?{plot:fn.get(p.id)}:{},...Bn.has(p.id)?{nameplate:Bn.get(p.id)}:{},...ze&&p.aggregate?hn(p.kind,p.aggregate.memberIds):{},depth:p.depth})}),{nodes:a,connectors:Ri(e,u,n),width:r.width,height:r.height,...ze?{city:ze.frame}:{},...n.pan&&(n.pan.x!==0||n.pan.y!==0)?{pan:{x:n.pan.x,y:n.pan.y}}:{},...l>0||c>0?{visible:{width:r.width-l,height:r.height-c}}:{}};function mn(p){let V=n.overview&&Le(p.id)!==null?void 0:n.pins[p.id],Y=V?{...p,x:V.x,y:V.y,pinned:!0}:{...p,pinned:!1},oe=n.pan?{...Y,x:Y.x+n.pan.x,y:Y.y+n.pan.y}:Y;a.push(oe),u.set(oe.id,oe)}}function no(e,t,n){let o=e.nodes.find(l=>l.id===t);if(!o||o.screenOf!==void 0)return null;let r={...o,x:n.x,y:n.y,pinned:!0},s=r.x+r.width/2,i=r.y+r.height/2;return{...e,nodes:e.nodes.map(l=>l.id===t?r:l),connectors:e.connectors.map(l=>l.from===t?{...l,x1:s,y1:i}:l.to===t?{...l,x2:s,y2:i}:l)}}function ro(e,t){return t.x===0&&t.y===0?e:{...e,nodes:e.nodes.map(n=>({...n,x:n.x+t.x,y:n.y+t.y})),connectors:e.connectors.map(n=>({...n,x1:n.x1+t.x,y1:n.y1+t.y,x2:n.x2+t.x,y2:n.y2+t.y})),...e.city?{city:{...e.city,pan:{x:t.x,y:t.y}}}:{},pan:{x:t.x,y:t.y}}}var ge=(e,t,n)=>e+(t-e)*n;function Pi(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}var Li=new WeakMap;function xs(e){let t=Li.get(e);if(t)return t;let n=new Map,o=new Map;for(let r of e.nodes){n.set(r.id,r);for(let s of r.aggregate?.memberIds??[]){let i=o.get(s);i?i.push(r):o.set(s,[r])}}return t={byId:n,groupsOf:o},Li.set(e,t),t}var Ti=new WeakMap;function Ci(e,t){let n=Ti.get(t);if(n||Ti.set(t,n=new WeakMap),n.has(e))return n.get(e);let o=bs(e,t);return n.set(e,o),o}function bs(e,t){let{byId:n,groupsOf:o}=xs(t);if(e.screenOf!==void 0){let i=n.get(Se(e.screenOf));if(i)return{...e,x:i.x,y:i.y,width:i.width,height:i.height}}if(Ct(e.id)||Le(e.id)!==null){let i=(e.aggregate?.memberIds??[]).map(a=>n.get(a)).filter(a=>a!==void 0);if(i.length===0)return null;let l=i.map(Pi),c=l.reduce((a,u)=>a+u.x,0)/l.length,d=l.reduce((a,u)=>a+u.y,0)/l.length;return{...e,x:c-e.width/2,y:d-e.height/2}}let r=o.get(e.id)?.find(i=>i.id===Se(e.kind)||i.id===Te(e.kind));if(!r)return null;let s=Pi(r);return{...e,x:s.x-e.width/2,y:s.y-e.height/2}}function it(e,t,n){let o=Math.max(0,Math.min(1,n)),r=new Map(e.nodes.map(a=>[a.id,a])),s=new Map(t.nodes.map(a=>[a.id,a])),i=[];for(let[a,u]of r){let h=s.get(a);if(h){i.push(oo(u,h,o,1));continue}let m=Ci(u,t)??u;i.push(oo(u,m,o,1-o))}for(let[a,u]of s){if(r.has(a))continue;let h=Ci(u,e)??u;i.push(oo(h,u,o,o))}let l=new Map(e.connectors.map(a=>[a.id,a])),c=new Map(t.connectors.map(a=>[a.id,a])),d=[];for(let[a,u]of l){let h=c.get(a);d.push(h?{...vs(u,h,o),opacity:1}:{...u,opacity:1-o})}for(let[a,u]of c)l.has(a)||d.push({...u,opacity:o});return{nodes:i.filter(a=>a.opacity>0).sort((a,u)=>a.id<u.id?-1:a.id>u.id?1:0),connectors:d.filter(a=>a.opacity>0).sort((a,u)=>a.id<u.id?-1:a.id>u.id?1:0),width:ge(e.width,t.width,o),height:ge(e.height,t.height,o),t:o,...Ii(e.city,t.city,o)?{city:Ii(e.city,t.city,o)}:{},...e.pan||t.pan?{pan:{x:ge(e.pan?.x??0,t.pan?.x??0,o),y:ge(e.pan?.y??0,t.pan?.y??0,o)}}:{}}}function Ii(e,t,n){return e?t?{cell:ge(e.cell,t.cell,n),...e.tilt!==void 0||t.tilt!==void 0?{tilt:ge(e.tilt??.5,t.tilt??.5,n)}:{},originX:ge(e.originX,t.originX,n),originY:ge(e.originY,t.originY,n),pan:{x:ge(e.pan.x,t.pan.x,n),y:ge(e.pan.y,t.pan.y,n)},extent:{x:ge(e.extent.x,t.extent.x,n),y:ge(e.extent.y,t.extent.y,n),width:ge(e.extent.width,t.extent.width,n),height:ge(e.extent.height,t.extent.height,n)}}:e:t}function oo(e,t,n,o){return{id:t.id,kind:t.kind,plane:ge(e.plane,t.plane,n),x:ge(e.x,t.x,n),y:ge(e.y,t.y,n),width:ge(e.width,t.width,n),height:ge(e.height,t.height,n),pinned:t.pinned,opacity:o,...t.aggregate?{aggregate:t.aggregate}:{},...t.via?{via:t.via}:{},...t.raised?{raised:!0}:{},...t.focused?{focused:!0}:{},...t.opened?{opened:!0}:{},...t.openedRows!==void 0?{openedRows:t.openedRows}:{},...t.compact?{compact:!0}:{},...t.rank?{rank:t.rank}:{},...t.nestedUnder?{nestedUnder:t.nestedUnder}:{},...t.beyond?{beyond:t.beyond}:{},...t.plot?{plot:t.plot}:{},...t.nameplate?{nameplate:t.nameplate}:{},...t.states?{states:t.states}:{},...t.screenOf?{screenOf:t.screenOf}:{},...t.depth===void 0?{}:{depth:ge(e.depth??1,t.depth,n)},...t.natural?{natural:t.natural}:{}}}function vs(e,t,n){return{...t,x1:ge(e.x1,t.x1,n),y1:ge(e.y1,t.y1,n),x2:ge(e.x2,t.x2,n),y2:ge(e.y2,t.y2,n)}}function rr(e){let t=Math.max(0,Math.min(1,e));return t<.5?4*t*t*t:1-(-2*t+2)**3/2}function ks(e,t){let n=[];for(let r=0;r<e.length;r+=1){let s=e[r],i=e[(r+1)%e.length];if(s.y===i.y)continue;let l=Math.min(s.y,i.y),c=Math.max(s.y,i.y);t<l||t>=c||n.push(s.x+(t-s.y)/(i.y-s.y)*(i.x-s.x))}n.sort((r,s)=>r-s);let o={x0:0,x1:0};for(let r=0;r+1<n.length;r+=2){let s={x0:n[r],x1:n[r+1]};s.x1-s.x0>o.x1-o.x0&&(o=s)}return o}function Ss(e){let t=1/0,n=-1/0;for(let o of e)o.y<t&&(t=o.y),o.y>n&&(n=o.y);return{top:t,bottom:n}}function Ms(e){let t=0;for(let n=0;n<e.length;n+=1){let o=e[n],r=e[(n+1)%e.length];t+=o.x*r.y-r.x*o.y}return Math.abs(t)/2}function Es(e){let t=0,n=0,o=0;for(let r=0;r<e.length;r+=1){let s=e[r],i=e[(r+1)%e.length],l=s.x*i.y-i.x*s.y;t+=l,n+=(s.x+i.x)*l,o+=(s.y+i.y)*l}if(Math.abs(t)<1e-9){let r=e.reduce((s,i)=>({x:s.x+i.x,y:s.y+i.y}),{x:0,y:0});return{x:r.x/e.length,y:r.y/e.length}}return{x:n/(3*t),y:o/(3*t)}}function Rs(e,t){let{room:n,height:o,size:r,floor:s,measure:i=Dr,lines:l=2}=t,c=(f,g)=>f.every(v=>i(v,g)<=n)&&f.length*g*1.15<=o;if(c([e],r))return{lines:[e],fontSize:r,whole:!0};let d=e.split(/\s+/);if(l>1&&d.length>1){let f=1,g=1/0,v=0;for(let w=0;w<d.length-1;w+=1){v+=d[w].length+1;let O=Math.abs(v-e.length/2);O<g&&(g=O,f=w+1)}let k=[d.slice(0,f).join(" "),d.slice(f).join(" ")];if(c(k,r))return{lines:k,fontSize:r,whole:!0};for(let w=r;w>=s;w-=r*.06)if(c(k,w))return{lines:k,fontSize:w,whole:!0}}for(let f=r;f>=s;f-=r*.06)if(c([e],f))return{lines:[e],fontSize:f,whole:!0};let a=i(e,s)/Math.max(1,e.length),u=Math.floor(n/a)-1;if(u<4||s*1.15>o)return null;let h=e.slice(0,u),m=h.lastIndexOf(" ");return{lines:[`${m>3?h.slice(0,m):h}\u2026`],fontSize:s,whole:!1}}var Os=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1;var U=re(Re(),1);var io=re(Re(),1),As=500,Ps=10;function Ni(e){return e instanceof HTMLElement?e.isContentEditable||e.tagName==="TEXTAREA"||e.tagName==="SELECT"?!0:e.tagName==="INPUT"&&!["button","submit","reset","checkbox","radio","image","file","color","range"].includes(e.type):!1}function Ls(e){let t=typeof getSelection=="function"?getSelection():null;return t!==null&&!t.isCollapsed&&t.containsNode(e,!0)}function Ts(e){return e.closest("[data-graview-pick]")?.getAttribute("data-graview-pick")??e.closest("[data-graview-view]")?.getAttribute("data-graview-view")??void 0}function Bi({swallow:e,setMenuAt:t,setSelection:n}){let o=(0,io.useRef)(0),r=(0,io.useRef)(null),s=()=>{r.current&&clearTimeout(r.current.timer),r.current=null},i=(l,c,d)=>{let a=Ts(l);a&&n([a]),t(a?{x:c,y:d,on:a}:{x:c,y:d})};return{onContextMenu:l=>{let c=l.target;l.shiftKey||Ni(c)||Ls(c)||(l.preventDefault(),!c.closest("[data-graview-popover], [data-graview-offstage]")&&(Date.now()-o.current<700||i(c,l.clientX,l.clientY)))},onPointerDown:l=>{if(s(),l.pointerType==="mouse"||!l.isPrimary)return;let c=l.target;if(Ni(c)||c.closest("[data-graview-popover], [data-graview-offstage], button, a, input, select, textarea"))return;let{clientX:d,clientY:a}=l;r.current={x:d,y:a,timer:setTimeout(()=>{r.current=null,o.current=Date.now(),e.current=!0,setTimeout(()=>e.current=!1,700),i(c,d,a)},As)}},onPointerMove:l=>{let c=r.current;c&&Math.hypot(l.clientX-c.x,l.clientY-c.y)>Ps&&s()},onPointerUp:s}}var vt=re(Re(),1);function Hi(e){let[t,n]=(0,vt.useState)(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(e).matches);return(0,vt.useEffect)(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;let o=window.matchMedia(e),r=()=>n(o.matches);return r(),o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[e]),t}function Cs(){let e=()=>typeof document>"u"?null:document.documentElement.getAttribute("data-graview-motion"),[t,n]=(0,vt.useState)(e);return(0,vt.useEffect)(()=>{if(typeof document>"u"||typeof MutationObserver>"u")return;let o=new MutationObserver(()=>n(e()));return o.observe(document.documentElement,{attributes:!0,attributeFilter:["data-graview-motion"]}),n(e()),()=>o.disconnect()},[]),t}function Di(e){let t=Hi("(prefers-reduced-motion: reduce)"),n=Hi("(prefers-reduced-transparency: reduce)"),o=Cs();return Zo({off:!e,reducedMotion:o==="reduce"||o!=="full"&&t,reducedTransparency:n})}var Is=Uo*1.5,Ns=30;function $i(e,t){let[n,o]=(0,vt.useState)(!1),r=e&&!n;return(0,vt.useEffect)(()=>{if(!r||!t||typeof requestAnimationFrame>"u")return;let s=[],i=0,l=0,c=d=>{if(i>0&&s.push(d-i),i=d,s.length>=Ns){if(!Jo(s,Is)){o(!0);return}s.length=0}l=requestAnimationFrame(c)};return l=requestAnimationFrame(c),()=>cancelAnimationFrame(l)},[r,t]),r}var We=re(Re(),1);var Bs=520;function Hs(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Fi(e,t={}){let n=t.duration??Bs,o=(t.enabled??!0)&&!Hs(),r=t.settle??!0,s=(0,We.useRef)(e),[,i]=(0,We.useState)(()=>it(e,e,1)),l=(0,We.useRef)(null);l.current??=it(e,e,1);let c=(0,We.useRef)(null),d=(0,We.useRef)(null);!o&&d.current!==e&&(d.current=e,l.current=it(e,e,1)),o&&(d.current=null);let a=(0,We.useRef)(null);return(0,We.useEffect)(()=>{if(!o||typeof requestAnimationFrame>"u"){if(s.current=e,d.current!==e){let k=it(e,e,1);l.current=k,i(k)}if(typeof requestAnimationFrame>"u"||!r)return;let v=requestAnimationFrame(()=>{let k=it(e,e,1);l.current=k,i(k)});return()=>cancelAnimationFrame(v)}if(s.current===e&&l.current.t>=1){if(!r)return;let v=requestAnimationFrame(()=>{let k=it(e,e,1);l.current=k,i(k)});return()=>cancelAnimationFrame(v)}let u=performance.now(),m=a.current!==null&&l.current.t<1&&u-a.current<n?a.current:u;a.current=m;let x=rr(Math.min(1,(u-m)/n)),f=s.current,g=v=>{let k=Math.min(1,(v-m)/n),w=x>=1?1:(rr(k)-x)/(1-x),O=it(f,e,Math.max(0,w));l.current=O,i(O),k<1?c.current=requestAnimationFrame(g):(a.current=null,s.current=e,c.current=requestAnimationFrame(()=>{let G=it(e,e,1);l.current=G,i(G),c.current=null}))};return c.current=requestAnimationFrame(g),()=>{c.current!==null&&cancelAnimationFrame(c.current);let v=l.current;s.current={...e,...v.city?{city:v.city}:{},pan:v.pan??{x:0,y:0},nodes:v.nodes.map(k=>({...k,plane:Math.round(k.plane)})),connectors:v.connectors}}},[e,n,o,r]),l.current}function Wi(e=1100){let{store:t}=me(),[n,o]=(0,We.useState)(()=>new Set);return(0,We.useEffect)(()=>{let r=null,s=t.subscribe(i=>{o(new Set(i.touched)),r&&clearTimeout(r),r=setTimeout(()=>o(new Set),e)});return()=>{s(),r&&clearTimeout(r)}},[t,e]),n}var Ds={marks:new Map,acts:[]};function ji(e=4e3){let{store:t}=me(),[n,o]=(0,We.useState)(Ds);return(0,We.useEffect)(()=>{let r=null,s=t.subscribe((i,l)=>{o(c=>{let d=new Map(c.marks),a=[...c.acts];for(let u of l){if(u.undoes!==void 0){let x=a.find(g=>g.batch===u.undoes||g.wrote.length>0),f=a.filter(g=>u.writes.some(v=>g.wrote.includes(v)));for(let g of f.length>0?f:x?[x]:[]){for(let v of g.wrote)d.delete(v);a=a.filter(v=>v.batch!==g.batch)}continue}if(u.author.kind!=="agent")continue;let h=u.author.id??"the seat";for(let x of u.writes)d.set(x,h);a.find(x=>x.batch===u.batch)?a=a.map(x=>x.batch===u.batch?{...x,wrote:[...new Set([...x.wrote,...u.writes])]}:x):a=[{batch:u.batch,who:h,intent:u.batchIntent??u.intent,at:u.at,wrote:[...u.writes]},...a].slice(0,12)}return d.size===c.marks.size&&a===c.acts&&d.size===0?c:{marks:d,acts:a}}),r&&clearTimeout(r),r=setTimeout(()=>o(c=>c.marks.size===0?c:{...c,marks:new Map}),e)});return()=>{s(),r&&clearTimeout(r)}},[t,e]),n}var Wt=re(Me(),1),et=16;function Vi({marks:e,questions:t=[],whereIs:n,stageRef:o,width:r,height:s}){if(e.size===0&&t.length===0)return null;let i=o.current,l=i?.getBoundingClientRect()??null,c=[];for(let[a,u]of e){let h=null;if(i&&l&&typeof CSS<"u"){let g=i.querySelector(`[data-graview-pick="${CSS.escape(a)}"]`)?.getBoundingClientRect();g&&g.width>0&&g.height>0&&(h={x:g.left-l.left,y:g.top-l.top,width:g.width,height:g.height})}if(h??=n(a),!h)continue;let m=Math.min(Math.max(h.x+h.width-et/2,et/2),r-et/2),x=Math.min(Math.max(h.y-et/4,et/2),s-et/2);c.push({id:a,who:u,x:m,y:x})}let d=[];for(let a of t){let u=n(a.id);u&&d.push({...a,x:Math.min(Math.max(u.x+u.width/2,et),r-et),y:Math.min(Math.max(u.y-et/2,et),s-et)})}return c.length===0&&d.length===0?null:(0,Wt.jsxs)("div",{className:"graview-seat-marks","data-testid":"seat-marks","data-graview-seat-marks":c.length,children:[c.map(({id:a,who:u,x:h,y:m})=>(0,Wt.jsx)("span",{className:"graview-seat-mark","data-testid":"seat-mark","data-graview-seat-mark":a,"data-graview-seat-who":u,title:`${u} just changed this`,"aria-hidden":"true",style:{left:h,top:m,"--graview-hue":gn(u)},children:"\u25C6"},a)),d.map(a=>(0,Wt.jsxs)("span",{className:"graview-seat-asking","data-testid":"seat-question","data-graview-seat-asking":a.id,title:a.asks,style:{left:a.x,top:a.y},children:[(0,Wt.jsx)("span",{"aria-hidden":"true",children:"?"}),(0,Wt.jsx)("span",{className:"graview-seat-asking-said",children:a.asks})]},`asking:${a.id}`))]})}var J=re(Me(),1);function $s({hue:e,mode:t}){let n=t==="docked";return(0,J.jsxs)("svg",{viewBox:"0 0 32 38","aria-hidden":"true",children:[(0,J.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round",strokeLinecap:"round",children:[(0,J.jsx)("line",{x1:"16",y1:"3.5",x2:"16",y2:"7"}),(0,J.jsx)("circle",{cx:"16",cy:"2.6",r:"1.5",fill:"none"}),(0,J.jsx)("path",{d:"M8 16 V12.5 C8 8.5 11.5 7 16 7 C20.5 7 24 8.5 24 12.5 V16 Z",fill:"currentColor",fillOpacity:"0.1"}),t==="refused"?(0,J.jsx)("line",{x1:"11",y1:"12.5",x2:"21",y2:"12.5",strokeWidth:"2"}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)("rect",{x:"10.2",y:"10.2",width:"11.6",height:"4.6",rx:"2.3",fill:"currentColor",fillOpacity:"0.14",strokeWidth:"1"}),(0,J.jsx)("circle",{cx:"13.4",cy:"12.5",r:"1.25",fill:"currentColor",stroke:"none",opacity:n?.45:1}),(0,J.jsx)("circle",{cx:"18.6",cy:"12.5",r:"1.25",fill:"currentColor",stroke:"none",opacity:n?.45:1}),t==="reading"?(0,J.jsx)("line",{x1:"10.2",y1:"12.5",x2:"21.8",y2:"12.5",strokeWidth:"0.8",opacity:"0.7"}):null]}),(0,J.jsx)("line",{x1:"16",y1:"16",x2:"16",y2:"18.5"}),(0,J.jsx)("polygon",{points:"16,18.5 24,22.5 16,26.5 8,22.5",fill:"currentColor",fillOpacity:"0.22"}),(0,J.jsx)("polygon",{points:"8,22.5 16,26.5 16,33.5 8,29.5",fill:"currentColor",fillOpacity:"0.08"}),(0,J.jsx)("polygon",{points:"24,22.5 16,26.5 16,33.5 24,29.5",fill:"currentColor",fillOpacity:"0.3"}),t==="writing"?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)("polyline",{points:"24,24 28.5,20.5"}),(0,J.jsx)("line",{x1:"27.5",y1:"19",x2:"30",y2:"21.5",strokeWidth:"1.8"})]}):(0,J.jsx)("line",{x1:"24",y1:"24",x2:"26.5",y2:"29"}),(0,J.jsx)("line",{x1:"8",y1:"24",x2:"5.5",y2:"29"}),(0,J.jsx)("path",{d:"M9.5 33.5 v2.2 h4"}),(0,J.jsx)("path",{d:"M22.5 33.5 v2.2 h-4"})]}),(0,J.jsx)("title",{children:`robot, ${t}`})]})}function Fs({hue:e}){return(0,J.jsxs)("svg",{viewBox:"0 0 22 24","aria-hidden":"true",style:{color:`hsl(${Math.round(e)} 50% 48%)`},children:[(0,J.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round",strokeLinecap:"round",children:[(0,J.jsx)("circle",{cx:"11",cy:"6",r:"4.2"}),(0,J.jsx)("path",{d:"M3 23 C3 15.5 6 13 11 13 C16 13 19 15.5 19 23"})]}),(0,J.jsx)("title",{children:"somebody"})]})}function Gi({width:e,whereIs:t}){let{who:n,following:o,follow:r}=me(),s=si([...n.values()],t,e);return s.length===0?null:(0,J.jsx)("div",{className:"graview-occupants","data-testid":"occupants","data-graview-occupants":s.length,children:s.map((i,l)=>{if(i.kind==="over")return(0,J.jsx)("div",{className:"graview-presence-over","data-testid":"presence-over","data-graview-over-by":i.presence.participant,style:{left:i.box.x-3,top:i.box.y-3,width:i.box.width+6,height:i.box.height+6,"--graview-hue":i.presence.hue}},`over:${i.presence.participant}`);if(i.kind==="count")return(0,J.jsxs)("span",{className:"graview-figure-count","data-testid":"presence-count","data-graview-at":i.at,style:{left:i.point.x,top:i.point.y},title:`${i.n} more here`,children:["+",i.n]},`count:${i.at}:${l}`);let c=i.presence.hue,d=Bo(i.presence)||"somebody";if(i.kind==="edge")return(0,J.jsxs)("button",{type:"button",className:"graview-figure-edge","data-testid":"presence-edge","data-graview-person":i.presence.participant,style:{right:`calc(${Math.max(8,e-i.point.x)}px + var(--graview-dock, 0px))`,top:i.point.y},onClick:()=>r(i.presence.participant),"aria-label":`${d} is somewhere else \u2014 press to go where they are`,children:["\u2192 ",d]},`edge:${i.presence.participant}`);if(i.kind==="robot")return(0,J.jsxs)("div",{className:"graview-figure","data-graview-figure":`theirs:${i.presence.participant}`,"data-graview-theirs":"","data-graview-mode":i.mode,"data-graview-at":i.presence.robot?.at??"",style:{transform:`translate(${i.point.x.toFixed(1)}px, ${i.point.y.toFixed(1)}px)`,"--graview-hue":c},children:[(0,J.jsx)("span",{className:"graview-figure-body",role:"img","aria-label":`${d}'s agent \u2014 ${i.mode}`,style:{cursor:"default"},children:(0,J.jsx)($s,{hue:c,mode:i.mode})}),(0,J.jsxs)("span",{className:"graview-figure-name",children:[d,"'s agent"]})]},`robot:${i.presence.participant}`);let a=o?.participant===i.presence.participant;return(0,J.jsxs)("div",{className:"graview-figure","data-graview-figure":i.presence.participant,"data-graview-person":"","data-graview-at":i.at,"data-graview-audience":i.audience?"":void 0,"data-graview-followed":a?"":void 0,style:{transform:`translate(${i.point.x.toFixed(1)}px, ${i.point.y.toFixed(1)}px)`,"--graview-hue":c},children:[(0,J.jsx)("button",{type:"button",className:"graview-figure-body","aria-label":`${d} is here${a?". Press to stop following":". Press to go where they go"}`,"aria-pressed":a,onClick:u=>{u.stopPropagation(),r(a?null:i.presence.participant)},onPointerDown:u=>u.stopPropagation(),children:(0,J.jsx)(Fs,{hue:c})}),(0,J.jsx)("span",{className:"graview-figure-name",children:d})]},`person:${i.presence.participant}`)})})}var ir=re(Re(),1),Pn=re(Me(),1),zi={left:"\u2190",right:"\u2192",top:"\u2191",bottom:"\u2193"},ao=36,An=56;function Yi({result:e,schema:t,chrome:n=[],onGo:o}){let r=Jr(e);if(r.length===0)return null;let s=a=>(a??[]).flatMap(u=>{let h=e.nodes.find(m=>m.id===u.id);return h?[{left:h.x+u.x,top:h.y+u.y,right:h.x+u.x+u.width,bottom:h.y+u.y+u.height}]:[]}),i=s(e.city?.showings),l=s(e.city?.nameplates),c=[...i,...l,...n.map(a=>({left:a.x,top:a.y,right:a.x+a.width,bottom:a.y+a.height}))],d=[];for(let a of["left","right","top","bottom"]){let u=e.visible??e,h=a==="left"||a==="right"?u.height:u.width,m=a==="left"||a==="right",x=a==="bottom"?Vs:a==="top"?An:Gs+An/2,f=-1/0,g=[],v=r.filter(k=>k.side===a).sort((k,w)=>k.along-w.along);for(let k of v){let w=Gn(t,k.kind),O=Ws(w),G=m?or:O/2,D=h-x-(m?0:G),X=Math.max(An,k.along,f+G+js);if(X>D)continue;let{at:j,inset:y}=zs([...c,...g],a,X,O,u,h);if(j>D+.5)continue;f=j+G,g.push(_i(a,j,O,u,y));let S=a==="left"?{left:y,top:j,transform:"translateY(-50%)"}:a==="right"?{right:`calc(${y}px + var(--graview-dock, 0px))`,top:j,transform:"translateY(-50%)"}:a==="top"?{top:y,left:j,transform:"translateX(-50%)"}:{bottom:`calc(${y}px + var(--graview-scene-foot, var(--graview-sheet, 0px)))`,left:j,transform:"translateX(-50%)"};d.push((0,Pn.jsx)("button",{type:"button",className:"graview-edge-sign","data-graview-past-edge":k.id,"aria-label":`${w}, past the ${a} edge \u2014 bring it into view`,title:`${w} is past the ${a} edge`,tabIndex:-1,onPointerDown:P=>P.stopPropagation(),onClick:P=>{P.stopPropagation(),o(k.by)},style:{...Ys,...S},children:a==="right"||a==="bottom"?`${w} ${zi[a]}`:`${zi[a]} ${w}`},k.id))}}return(0,Pn.jsx)(Pn.Fragment,{children:d})}var Ws=e=>(e.length+2)*7.4+22,or=ao/2,On=6,js=6,Vs=236,Gs=56;function _i(e,t,n,o,r=On){return e==="left"||e==="right"?{left:e==="left"?r:o.width-r-n,right:e==="left"?r+n:o.width-r,top:t-or,bottom:t+or}:{left:t-n/2,right:t+n/2,top:e==="top"?r:o.height-r-ao,bottom:e==="top"?r+ao:o.height-r}}function zs(e,t,n,o,r,s){let i=t==="left"||t==="right",l=f=>_i(t,f,o,r),c=f=>e.find(g=>{let v=l(f);return v.left<g.right&&g.left<v.right&&v.top<g.bottom&&g.top<v.bottom}),d=c(n);if(!d)return{at:n,inset:On};let a=i?or:o/2,u=f=>{let g=n;for(let v=0;v<12;v++){let k=c(g);if(!k)return g;if(g=f>0?(i?k.bottom:k.right)+a+4:(i?k.top:k.left)-a-4,g>s-An||g<An)return null}return null},h=u(1);if(h!==null)return{at:h,inset:On};let m=u(-1);if(m!==null)return{at:m,inset:On};let x=t==="left"?d.right:t==="right"?r.width-d.left:t==="top"?d.bottom:r.height-d.top;return{at:n,inset:Math.max(On,x+4)}}var Ys={position:"absolute",zIndex:Fe.lines,minHeight:28,maxWidth:"40%",padding:"3px 10px",font:"inherit",fontSize:"0.75rem",letterSpacing:"0.04em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:"var(--graview-ink)",background:"var(--graview-panel)",border:"1px solid var(--graview-edge)",borderRadius:6,boxShadow:"0 2px 8px rgb(0 0 0 / 0.12)",cursor:"pointer"};function Ki(e){let[t,n]=(0,ir.useState)(null);return(0,ir.useLayoutEffect)(()=>{let o=e.current,r=null;for(let l=o?.parentElement??null,c=0;l&&!r&&c<4;l=l.parentElement,c++)r=l.querySelector(":scope > [data-graview-scene-trail]");if(!o||!r)return;let s=()=>{let l=o.getBoundingClientRect(),c=r.getBoundingClientRect(),d=c.width>0&&c.height>0?{x:c.left-l.left,y:c.top-l.top,width:c.width,height:c.height}:null;n(a=>a===d||a&&d&&a.x===d.x&&a.y===d.y&&a.width===d.width&&a.height===d.height?a:d)};if(s(),typeof ResizeObserver>"u")return;let i=new ResizeObserver(s);return i.observe(r),()=>i.disconnect()},[e]),t}var kt=re(Re(),1),_s=180;function Ui({view:e,result:t,frame:n,panned:o,closer:r,screenId:s,setCamera:i}){let l=(0,kt.useRef)(new Map),c=Math.round((t.nodes.find(u=>u.id===s)?.height??0)/16),d=(0,kt.useRef)(e.overview??!1),a=(0,kt.useRef)(null);if((0,kt.useEffect)(()=>{if(!e.overview||!s||!t.city){if(d.current&&!e.overview)return;i(D=>D.x===0&&D.y===0?D:{x:0,y:0});return}let u=t.nodes.find(D=>D.id===s);if(!u)return;let h=r>1&&u.screenOf?t.nodes.find(D=>D.id===Se(u.screenOf)):void 0,m=h?{x:Math.min(u.x,h.x),y:Math.min(u.y,h.y),width:Math.max(u.x+u.width,h.x+h.width)-Math.min(u.x,h.x),height:Math.max(u.y+u.height,h.y+h.height)-Math.min(u.y,h.y)}:u;if(m.x>=0&&m.y>=0&&m.x+m.width<=t.width&&m.y+m.height<=t.height&&!h)return;let f=24,g=(D,X,j)=>D<f?f-D:D+X>j-f?j-f-(D+X):0,v=bt(t),k=e.pan??{x:0,y:0},w=h?o.x+(t.width/2-(m.x+m.width/2)):o.x+g(m.x,m.width,t.width),O=t.height/2-(m.y+m.height/2),G=h?o.y+(u.y+O<f?f-u.y:O):o.y+g(m.y,m.height,t.height);i({x:(h?w:Math.max(-v.x,Math.min(v.x,w)))-k.x,y:(h?G:Math.max(-v.y,Math.min(v.y,G)))-k.y})},[s,e.overview,r,e.within?.view,c]),n.city){let u=new Map;for(let h of n.nodes){if(!h.plot||Math.round(h.plane)!==2)continue;let m=Zt(h.plot.col+h.plot.side/2,h.plot.row+h.plot.side/2,n.city.cell,n.city.tilt);u.set(h.id,{x:n.city.originX+o.x+m.x,y:n.city.originY+o.y+m.y})}l.current=u}return(0,kt.useEffect)(()=>{let u=e.overview??!1,h=d.current&&!u;if(d.current=u,u&&a.current&&(clearTimeout(a.current),a.current=null),!h)return;let m=e.focusId?wt(e.focusId)[0]:void 0,x=m?l.current.get(Se(m)):void 0,f=t.nodes.find(g=>g.id===e.focusId);if(!x||!f){i({x:0,y:0});return}i({x:x.x-(f.x+f.width/2),y:x.y-(f.y+f.height/2)}),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,i({x:0,y:0})},_s)},[e.overview]),(0,kt.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]),{gliding:()=>a.current!==null}}var sr=re(Re(),1),ar="[data-graview-view]";function Ks(e,t){let n=null;for(let o=e?.closest(ar)??null;o&&t.contains(o);o=o.parentElement?.closest(ar)??null)n=o;return n}function Xi(e,t){let n=e.getBoundingClientRect();return{left:n.left,top:n.top,right:n.right-t.right,bottom:n.bottom-t.bottom,box:n}}function qi(e,t,n){let o=(0,sr.useRef)({dock:t,reveal:n});o.current={dock:t,reveal:n},(0,sr.useEffect)(()=>{let r=e.current;if(!r)return;let s=c=>{let{dock:d}=o.current;if(c.key!=="Tab"||c.defaultPrevented||d.right<=0&&d.bottom<=0)return;let a=Xi(r,d),u=[];for(let h of r.querySelectorAll(ar)){if(h.parentElement?.closest(ar)||h.inert||h.contains(document.activeElement))continue;let m=h.getBoundingClientRect(),x=Math.max(m.left,a.box.left),f=Math.min(m.right,a.box.right),g=Math.max(m.top,a.box.top),v=Math.min(m.bottom,a.box.bottom);f<=x||v<=g||!(d.right>0&&x>=a.right-1||d.bottom>0&&g>=a.bottom-1)||(h.inert=!0,u.push(h))}u.length!==0&&setTimeout(()=>{for(let h of u)h.inert=!1},0)},i=c=>{let d=c.target,a=Ks(d,r);if(!a)return;let u=!0;try{u=d?.matches(":focus-visible")??!0}catch{}requestAnimationFrame(()=>{for(let h=a.parentElement;h;h=h===r?null:h.parentElement)h.scrollTop!==0&&(h.scrollTop=0),h.scrollLeft!==0&&(h.scrollLeft=0);u&&a.isConnected&&l(a)})},l=c=>{let d=Xi(r,o.current.dock),a=c.getBoundingClientRect(),u=12,h=(f,g,v,k)=>k-v>g-f-2*u||v<f+u?f+u-v:k>g-u?g-u-k:0,m=h(d.left,d.right,a.left,a.right),x=h(d.top,d.bottom,a.top,a.bottom);(Math.abs(m)>=1||Math.abs(x)>=1)&&o.current.reveal(Math.round(m),Math.round(x))};return document.addEventListener("keydown",s,!0),r.addEventListener("focusin",i),()=>{document.removeEventListener("keydown",s,!0),r.removeEventListener("focusin",i)}},[e])}var de=re(Re(),1);function Zi(){let e=(0,de.useRef)(null),[t,n]=(0,de.useState)({right:0,bottom:0});return(0,de.useLayoutEffect)(()=>{let o=e.current;if(!o)return;let r=()=>{let i=o.getBoundingClientRect(),l={right:Math.round(i.width),bottom:Math.round(i.height)};n(c=>c.right===l.right&&c.bottom===l.bottom?c:l)};if(r(),typeof ResizeObserver>"u")return;let s=new ResizeObserver(r);return s.observe(o),()=>s.disconnect()},[]),{probe:e,dock:t}}function Ji(){let[e,t]=(0,de.useState)(null),n=(0,de.useRef)(null),o=(0,de.useRef)(0),r=(0,de.useCallback)(i=>{n.current=i,o.current===0&&(o.current=requestAnimationFrame(()=>{o.current=0,t(n.current)}))},[]),s=(0,de.useCallback)(()=>{o.current!==0&&cancelAnimationFrame(o.current),o.current=0;let i=n.current;return n.current=null,i&&t(null),i},[]);return{held:e,place:r,release:s}}function ea({stage:e,pan:t,setView:n,settled:o}){let r=(0,de.useRef)({x:0,y:0}),s=(0,de.useRef)(0),i=(0,de.useRef)(!1),l=(0,de.useRef)(o);l.current=o;let c=(0,de.useCallback)(()=>[...e.current?.querySelectorAll("[data-graview-world]")??[]],[e]),d=(0,de.useCallback)(({x:f,y:g})=>{let v=f===0&&g===0?"":`translate3d(${f}px, ${g}px, 0)`;for(let k of c())k.style.transform=v;Qi(e.current,f,g)},[c,e]),a=(0,de.useCallback)(()=>{s.current===0&&(s.current=requestAnimationFrame(()=>{s.current=0,d(r.current)}))},[d]),u=(0,de.useCallback)(()=>{i.current=!1;for(let f of c())f.style.transform="";Qi(e.current,0,0),l.current()},[c,e]),h=(0,de.useCallback)((f,g)=>{r.current={x:f.x-g.x,y:f.y-g.y},a()},[a]),m=(0,de.useCallback)(()=>{let{x:f,y:g}=r.current;return f===0&&g===0?!1:(s.current!==0&&cancelAnimationFrame(s.current),s.current=0,d({x:f,y:g}),r.current={x:0,y:0},i.current=!0,n(v=>{let k=v.pan??{x:0,y:0};return ut(v,{x:k.x+f,y:k.y+g})}),window.setTimeout(()=>{i.current&&u()},300),!0)},[n,u,d]);(0,de.useLayoutEffect)(()=>{i.current&&u()},[t,u]);let x=(0,de.useCallback)(()=>r.current,[]);return{shiftTo:h,settle:m,settling:i,offset:x}}function Qi(e,t,n){for(let o of e?.querySelectorAll(":scope > .graview-lattice, :scope > .graview-measure")??[]){if(t===0&&n===0){o.style.removeProperty("--graview-hand-x"),o.style.removeProperty("--graview-hand-y");continue}o.style.setProperty("--graview-hand-x",`${t}px`),o.style.setProperty("--graview-hand-y",`${n}px`)}}var Us=4;function ta({view:e,panned:t,limit:n,panWithin:o,moveByTransform:r,setView:s,setDragging:i,noteMoved:l,shift:c,district:d}){let a=(0,de.useRef)(!1),u=(0,de.useRef)(null),h=v=>{let k=e.pan??{x:0,y:0};u.current={kind:"pan",fromX:v.clientX,fromY:v.clientY,baseX:k.x,baseY:k.y,moved:!1}};return{onGroundDown:v=>{v.button===0&&(v.target.closest("[data-graview-view]")||h(v))},onCardDown:(v,k)=>{if(k.button===0){if(v.screenOf!==void 0&&!k.target.closest("[data-graview-grip]")){h(k);return}if(e.overview&&Le(v.id)!==null){h(k);return}u.current={kind:"card",id:v.id,fromX:k.clientX,fromY:k.clientY,baseX:v.x-t.x,baseY:v.y-t.y,moved:!1}}},onDragMove:v=>{let k=u.current;if(!k)return;let w=v.clientX-k.fromX,O=v.clientY-k.fromY;if(!k.moved){if(Math.hypot(w,O)<Us)return;k.moved=!0,i(!0),v.currentTarget.setPointerCapture(v.pointerId)}if(k.kind==="pan"){let G=o(n(),{x:k.baseX+w,y:k.baseY+O});r?c.shiftTo(G,e.pan??{x:0,y:0}):s(D=>ut(D,G))}else k.id&&d.place({id:k.id,x:k.baseX+w,y:k.baseY+O})},onDragUp:()=>{c.settle();let v=d.release();v&&s(k=>Sn(k,v.id,{x:v.x,y:v.y})),u.current?.moved&&(a.current=!0,setTimeout(()=>a.current=!1,0),l()),u.current=null,!c.settling.current&&i(!1)},swallow:a}}function na({stage:e,view:t,setView:n}){let o=(0,de.useRef)({view:t,charge:0,coolUntil:0,lastScale:1});o.current.view=t;let r=(0,de.useRef)(()=>{}),s=(0,de.useRef)(()=>{});return(0,de.useEffect)(()=>{let i=e.current;if(!i)return;let l=(u,h)=>{let m=o.current;if(h<m.coolUntil)return;let x=m.view.overview??!1;u!==x&&(m.coolUntil=h+600,m.charge=0,n(yn(m.view,u)))},c=u=>{let h=o.current,m=h.view.overview??!1;if(u.ctrlKey){if(u.preventDefault(),!m){if(h.charge+=u.deltaY,Math.abs(h.charge)<60)return;h.charge>0?l(!0,performance.now()):h.charge=0;return}r.current(Math.exp(-u.deltaY*.004),u.clientX,u.clientY);return}!m||u.target?.closest("[data-graview-view], .graview-scroll, [data-graview-overlay], .graview-zoom")||(u.preventDefault(),s.current(-u.deltaX,-u.deltaY))},d=u=>{u.preventDefault(),o.current.lastScale=1},a=u=>{u.preventDefault();let h=o.current,m=u.scale??1;if(!(h.view.overview??!1)){m<.72&&l(!0,performance.now());return}let x=m/(h.lastScale||1);h.lastScale=m;let f=u;r.current(x,f.clientX,f.clientY)};return i.addEventListener("wheel",c,{passive:!1}),i.addEventListener("gesturestart",d),i.addEventListener("gesturechange",a),()=>{i.removeEventListener("wheel",c),i.removeEventListener("gesturestart",d),i.removeEventListener("gesturechange",a)}},[n,e]),{zoomAbout:r,panBy:s}}var ra={directed:"You",autonomous:"An agent","co-edited":"You and an agent",rule:"A rule"};function so(e,t){let n=new Set(e.map(r=>r.id)),o=new Set;for(let r of t){if(n.has(r)){o.add(r);continue}let s=e.find(i=>i.aggregate?.memberIds.includes(r));s&&o.add(s.id)}return o}function lo(e){return e.emphasized?e.stressed?.95:.08:e.anyChosen?e.mine?.9:.12:e.touches?Math.max(.34,.9-.09*Math.max(0,(e.siblings??1)-1)):.12}function co(e){return e.edgeChosen?.9:e.lit?.78:e.own*(e.anyLit?e.kit.dim:e.kit.rest)}function at(e,t){if(!e)return null;let n=Math.max(0,Math.min(2,Math.floor(e.plane))),o=Math.max(0,Math.min(2,Math.ceil(e.plane))),{scale:r}=n===o?Kt(n,t):zo(Kt(n,t),Kt(o,t),e.plane-n);return{x:e.x,y:e.y,width:e.width*r,height:e.height*r}}function tn(e,t){if(typeof getComputedStyle>"u"||getComputedStyle(e).visibility==="hidden")return null;let n=-1/0,o=-1/0,r=1/0,s=1/0,i=e.getBoundingClientRect();n=Math.max(n,i.left),o=Math.max(o,i.top),r=Math.min(r,i.right),s=Math.min(s,i.bottom);let l=e.parentElement;for(;l&&l!==t;){let d=getComputedStyle(l);if(d.overflowX!=="visible"||d.overflowY!=="visible"){let a=l.getBoundingClientRect();d.overflowX!=="visible"&&(n=Math.max(n,a.left),r=Math.min(r,a.right)),d.overflowY!=="visible"&&(o=Math.max(o,a.top),s=Math.min(s,a.bottom))}l=l.parentElement}if(r-n<=2||s-o<=2)return null;let c=t.getBoundingClientRect();return{x:n-c.left,y:o-c.top,width:r-n,height:s-o}}function je(e,t,n,o=!1){if(!e||typeof document>"u")return null;let r=e.querySelector(`[data-graview-view="${CSS.escape(t)}"]`);return r?tn(uo(r,n,o),e):null}function uo(e,t=!1,n=!1){return(t?e.querySelector(".graview-kind-block"):null)??e.querySelector('[data-graview-primitive="panel"], .graview-kind-face, .graview-kind-card')??(n?null:e.querySelector(':scope > [data-graview-primitive="chip"]'))??e}function dr(e,t,n,o,r){let s=d=>e.nodes.find(a=>a.id===d);if(r.startsWith("screen:")){let d=e.nodes.find(a=>a.id===Se(r.slice(7)));return d?je(t,d.id,!0)??at(d,n):null}let i=s(r),l=Le(r);if(!i&&l!==null&&(i=s(Te(l))),!i&&Ct(r)){let[d]=wt(r);d&&(i=s(Se(d)))}if(!i){let d=o.places().find(a=>a.as===r);d&&(i=s(Te(d.kind))??s(Se(d.kind)))}if(i||(i=[...e.nodes].filter(d=>d.aggregate?.memberIds.includes(r)).sort((d,a)=>d.plane-a.plane)[0]),!i)return null;let c=e.city!==void 0;return je(t,i.id,c&&i.aggregate!==void 0&&Math.round(i.plane)===2)??at(i,n)}var st=re(Re(),1);var _e=re(Re(),1);var Ye=re(Me(),1);function sa({title:e,name:t,path:n,maxHeight:o,children:r}){let s=(0,_e.useContext)(Wo),[i,l]=(0,_e.useState)(void 0),[c,d]=(0,_e.useState)(void 0),[a,u]=(0,_e.useState)(void 0),[h,m]=(0,_e.useState)(!1),[x,f]=(0,_e.useState)(!1),g=(0,_e.useRef)(null),v=(0,_e.useRef)(null);(0,_e.useLayoutEffect)(()=>{let S=g.current,P=v.current;if(!S||!P||typeof ResizeObserver>"u")return;let A=()=>{u(S.clientHeight),d(P.offsetHeight||void 0)};A();let W=new ResizeObserver(A);return W.observe(S),W.observe(P),()=>W.disconnect()},[]);let k=Math.max(i??0,c??0)||void 0,w=!h&&k!==void 0&&a!==void 0&&k>a+1,O=s&&n?n:void 0,G=O&&s?.href?s.href(O):void 0,D=S=>S.stopPropagation(),X=S=>{D(S),!(G&&(S.metaKey||S.ctrlKey||S.shiftKey||S.button!==0))&&(S.preventDefault(),O&&s?.open(O))},j=G?{href:G}:{role:"link",tabIndex:0},y={onPointerDown:D,onDoubleClick:D,onKeyDown:S=>{S.key!=="Enter"&&S.key!==" "||(D(S),S.key==="Enter"&&S.currentTarget.tagName==="A"&&!S.currentTarget.hasAttribute("href")&&(S.preventDefault(),S.currentTarget.click()))}};return(0,Ye.jsxs)("section",{"data-graview-preview":t,"aria-label":e,...h?{"data-graview-expanded":"","data-graview-overlay":""}:{},onKeyDown:h?S=>{S.key==="Escape"&&(S.stopPropagation(),m(!1))}:void 0,style:{...Xs,...h?qs:{}},children:[(0,Ye.jsxs)("div",{style:Qs,children:[(0,Ye.jsx)("strong",{style:Zs,children:e}),O?(0,Ye.jsx)("a",{"data-graview-preview-open":"",...j,"aria-label":`Open ${e}`,style:oa,...y,onClick:X,children:"Open"}):w||h?(0,Ye.jsx)("button",{type:"button","data-graview-preview-expand":"","aria-expanded":h,"aria-label":`${h?"Collapse":"Expand"} ${e}`,style:{...oa,...ia},...y,onClick:S=>{D(S),m(P=>!P)},children:h?"Collapse":"Expand"}):null]}),(0,Ye.jsxs)("div",{ref:g,"data-graview-preview-body":"",...i!==void 0?{"data-graview-content-height":i}:{},...w?{"data-graview-more":""}:{},onFocus:()=>f(!0),onBlur:()=>f(!1),style:{...Js,...o!==void 0&&!h?{maxHeight:o}:{},...x?{overflowClipMargin:4}:{}},children:[(0,Ye.jsx)("div",{ref:v,"data-graview-preview-drawn":"",style:ed,children:(0,Ye.jsx)(Fo.Provider,{value:l,children:r})}),w?(0,Ye.jsx)("div",{"aria-hidden":"true","data-graview-preview-fade":"",style:td}):null,w?O?(0,Ye.jsx)("a",{"data-graview-preview-more":"",...j,"aria-label":`More of ${e}`,style:aa,...y,onClick:X,children:"More"}):(0,Ye.jsx)("button",{type:"button","data-graview-preview-more":"","aria-label":`More of ${e}`,style:{...aa,...ia},...y,onClick:S=>{D(S),m(!0)},children:"More"}):null]})]})}var Xs={display:"flex",flexDirection:"column",gap:"var(--graview-gap, 7px)",width:"100%",maxHeight:"100%",minHeight:0,padding:"var(--graview-pad, 15px)",boxSizing:"border-box",borderRadius:"var(--graview-radius, 12px)",border:"1px solid var(--graview-edge, #e4e0d8)",boxShadow:"var(--graview-lift-low)",background:"var(--graview-panel, #ffffff)",color:"var(--graview-ink, #1a1a1a)",overflow:"hidden"},qs={maxHeight:"none",position:"absolute",top:0,left:0,right:0,width:"auto"},Qs={display:"flex",alignItems:"baseline",flexWrap:"wrap",gap:8,minWidth:0,flex:"0 0 auto"},Zs={fontFamily:"var(--graview-font-display, inherit)",fontSize:"0.9375rem",lineHeight:1.25,fontWeight:560,letterSpacing:"0.005em",minWidth:0,overflowWrap:"anywhere"},oa={marginLeft:"auto",fontSize:"0.8125rem",fontWeight:560,color:"var(--graview-accent, #2f6f5e)",textDecoration:"none",textUnderlineOffset:"0.2em"},ia={font:"inherit",fontSize:"0.8125rem",fontWeight:560,background:"none",border:0,padding:0,cursor:"pointer"},Js={position:"relative",flex:"0 1 auto",minHeight:0,overflowX:"visible",overflowY:"clip",minWidth:0},ed={display:"flow-root",minWidth:0},td={position:"absolute",left:0,right:0,bottom:0,height:64,pointerEvents:"none",background:"linear-gradient(to bottom, transparent, var(--graview-panel, #ffffff) 66%)"},aa={position:"absolute",right:0,bottom:0,lineHeight:1.5,fontSize:"0.8125rem",fontWeight:560,color:"var(--graview-accent, #2f6f5e)",textDecoration:"none",textUnderlineOffset:"0.2em"};var se=re(Me(),1),la=(0,st.memo)(function({kinds:t}){let{store:n}=me(),{view:o,go:r}=Ir(),s=(0,st.useRef)(null),i=Br("districts",{align:"start"}),l=i.open,c=m=>Gn(n.schema,m),d=m=>n.graph.allNodes().filter(x=>x.kind===m).length,a=m=>!o.overview&&o.focusId===Te(m),u=t.filter(m=>!a(m)),h=m=>{i.setOpen(!1);let x=s.current?.querySelector(".graview-beyond-more")??null;a(m)||r(yt(o,Te(m))),x?.focus({preventScroll:!0});let f=`[data-graview-view="${Te(m)}"][tabindex], [data-graview-view="${Se(m)}"][tabindex]`,g=40,v=()=>{let k=document.querySelector(f);k?k.focus({preventScroll:!0}):--g>0&&requestAnimationFrame(v)};requestAnimationFrame(v)};return(0,se.jsxs)("div",{ref:s,className:"graview-beyond","data-graview-beyond":t.length,"data-graview-beyond-open":l?"":void 0,children:[(0,se.jsxs)("button",{type:"button",className:"graview-beyond-more","data-testid":"beyond-more",...i.trigger,"aria-haspopup":"menu",title:`${u.length} more district${u.length===1?"":"s"} \u2014 press to see them`,onPointerDown:m=>m.stopPropagation(),onClick:m=>{m.stopPropagation(),i.toggle()},children:[(0,se.jsxs)("span",{className:"graview-beyond-count",children:["+",u.length]}),(0,se.jsx)("span",{className:"graview-beyond-word",children:"more"}),(0,se.jsx)("span",{className:"graview-beyond-chevron","aria-hidden":"true",children:l?"\u25BE":"\u25B4"})]}),l?(0,se.jsx)("ul",{...i.pane,className:"graview-beyond-list",role:"menu","aria-label":"The other districts","data-testid":"beyond-list",style:Nr,onPointerDown:m=>m.stopPropagation(),children:t.map(m=>(0,se.jsx)("li",{role:"none",children:(0,se.jsxs)("button",{type:"button",role:"menuitem","data-graview-pick":Se(m),"aria-current":a(m)?"location":void 0,title:a(m)?`${c(m)} \u2014 where you are`:`Go to ${c(m)}`,onPointerDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),h(m)},children:[(0,se.jsx)("span",{className:"graview-beyond-name",children:c(m)}),(0,se.jsx)("span",{className:"graview-beyond-tally",children:a(m)?"here":d(m)})]})},m))}):null]})},(e,t)=>e.kinds.length===t.kinds.length&&e.kinds.every((n,o)=>n===t.kinds[o]));function ca(e,t){if(e===t)return!0;let n=Object.keys(e);return n.length!==Object.keys(t).length?!1:n.every(o=>o==="x"||o==="y"||fo(e[o],t[o]))}function fo(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t)||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==Array.prototype)return!1;if(Array.isArray(e)){let r=t;if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(!fo(e[s],r[s]))return!1;return!0}let o=Object.keys(e);return o.length!==Object.keys(t).length?!1:o.every(r=>fo(e[r],t[r]))}var ua=(0,st.memo)(ha,(e,t)=>e.mode===t.mode&&e.selected===t.selected&&e.fidelity===t.fidelity&&ca(e.node,t.node));function ha({node:e,mode:t,selected:n,fidelity:o}){let{store:r,views:s,view:i}=me(),l=Nt(),c=ai(),d=ii(),a=e.aggregate||Ct(e.id)||Le(e.id)!==null?"many":"one",u={cardinality:a,fidelity:o??Go[rd(e.plane)].fidelity},h=a==="many"&&e.id===i.focusId?i.within?.view:void 0,m=s.resolve(e.kind,u,h),x=m?.view,f=s.resolve(e.kind,{cardinality:"many",fidelity:"full"})?.view,g=f!==void 0&&f.generic!==!0,v=e.aggregate?.memberIds,k=(0,st.useMemo)(()=>(v??[]).map(j=>r.graph.getNode(j)).filter(j=>j!==void 0),[v,r,l]),w={...e.aggregate?{nodes:k,label:m?.title??e.aggregate.label}:{node:r.graph.getNode(e.id)},fidelity:u.fidelity,cardinality:u.cardinality,mode:t,selected:n,implicated:c,flagged:d,...e.raised?{raised:!0}:{},...e.focused?{focused:!0}:{},...e.opened?{opened:!0}:{},...e.openedRows!==void 0?{openedRows:e.openedRows}:{},...e.plot?{plot:e.plot}:{},...e.nameplate?{nameplate:e.nameplate}:{},...e.states?{states:e.states}:{},...e.aggregate?.retired?{retired:e.aggregate.retired}:{},...e.rank?{rank:e.rank}:{},...e.nestedUnder?{nestedUnder:e.nestedUnder}:{},...g?{hasOwnView:!0}:{}};if(!x)return(0,se.jsx)(od,{node:e,props:w});let O=Vo(x),G=!e.aggregate&&w.node?w.node:void 0,D=O?G?{title:Gt(r.schema.tryDefinition(G.kind),G),name:G.id,path:Co(r.schema,G.kind,G.id)}:{title:w.label??e.kind,name:m?.title?kr(m.title):"",path:m?.title?`/places/${kr(m.title)}`:void 0}:void 0,X=[e.id,m?.title??"",u.fidelity,u.cardinality,t,n,e.raised??!1,e.focused??!1,e.opened??!1,e.openedRows??"",e.rank??"",e.nestedUnder??"",e.plot?`${e.plot.col},${e.plot.row},${e.plot.side}`:"",e.nameplate??"",e.states?e.states.values.map(j=>j.count).join(","):"",e.aggregate?ho(e.aggregate.memberIds):"",e.aggregate?.retired??"",c?ho(c):"",d?ho(d):"",g].join("|");return(0,se.jsx)(Lr,{mode:t,children:(0,se.jsx)(di,{kind:w.label??e.kind,...m?.title?{view:m.title}:{},children:(0,se.jsx)(nd,{signature:X,graph:l,draw:()=>O&&D?(0,se.jsx)(sa,{...D,maxHeight:O.maxHeight,children:(0,se.jsx)(x,{...w})}):(0,se.jsx)(x,{...w})})},`${e.id}|${m?.title??""}`)})}var nd=(0,st.memo)(function({draw:t}){return(0,se.jsx)(se.Fragment,{children:t()})},(e,t)=>e.signature===t.signature&&e.graph===t.graph);function rd(e){return Math.max(0,Math.min(2,Math.round(e)))}function od({node:e,props:t}){return(0,se.jsxs)("div",{style:{padding:8,font:"13px/1.4 system-ui",overflow:"hidden"},children:[(0,se.jsx)("strong",{children:t.label??e.kind}),t.nodes?(0,se.jsxs)("div",{children:[t.nodes.length," items"]}):(0,se.jsx)("div",{children:e.id})]})}var fa=(0,st.memo)(function({node:t}){let{store:n}=me(),o=It(),r=t.aggregate,s=r.opens,i=r.memberIds.length,l=zt(n.schema,r.kind,i),c=r.memberIds.slice(0,3).map(h=>{let m=n.graph.getNode(h),x=m?n.schema.tryDefinition(m.kind):void 0;return m?x?.label?x.label(m):String(m.label??h):h}),d=r.memberIds,a=(0,st.useMemo)(()=>{let h=o?Kn(o):null;return h?d.filter(m=>h.has(m)).length:0},[o,d]),u=s.in==="picture";return(0,se.jsxs)("div",{className:"graview-band-group","data-graview-band":s.in,"data-graview-band-count":i,"data-graview-emphasis":o?a>0?"lit":"dimmed":void 0,title:u?`${r.label} \u2014 press twice to see them all, arranged`:`${r.label}: ${l} \u2014 press twice to open`,children:[(0,se.jsxs)("span",{className:"graview-band-group-head",children:[(0,se.jsx)("span",{className:"graview-band-group-name",children:r.label}),(0,se.jsx)("span",{className:"graview-band-group-open","aria-hidden":"true",children:u?"\u2197":"\u25BE"})]}),(0,se.jsxs)("span",{className:"graview-band-group-names",children:[u?null:(0,se.jsxs)("span",{className:"graview-band-group-count",children:[l,a>0?` \xB7 ${a} match`:""," \xB7 "]}),c.join(" \xB7 "),i>c.length?" \u2026":""]})]})},(e,t)=>ca(e.node,t.node)),da=new WeakMap;function ho(e){let t=da.get(e);if(t!==void 0)return t;let n=2166136261;for(let r of e){for(let s=0;s<r.length;s++)n=Math.imul(n^r.charCodeAt(s),16777619);n=Math.imul(n^44,16777619)}let o=`${e.length}:${(n>>>0).toString(36)}`;return da.set(e,o),o}var St=re(Re(),1);function po(e,t,n){let o=e.aggregate?[...e.aggregate.memberIds]:[e.id];return n?o.every(s=>t.includes(s))?t.filter(s=>!o.includes(s)):[...t,...o.filter(s=>!t.includes(s))]:o}function pa(){let[e,t]=(0,St.useState)(16);return(0,St.useEffect)(()=>{if(typeof window>"u")return;let n=document.documentElement,o=()=>{let s=parseFloat(getComputedStyle(n).fontSize);Number.isFinite(s)&&t(i=>Math.abs(i-s)<.5?i:s)};o();let r=new MutationObserver(o);return r.observe(n,{attributes:!0,attributeFilter:["style"]}),window.addEventListener("resize",o),()=>{r.disconnect(),window.removeEventListener("resize",o)}},[]),e}function ma(e){let[t,n]=(0,St.useState)(null);return(0,St.useLayoutEffect)(()=>{let o=e.current?.getBoundingClientRect();!o||o.width===0||o.height===0||n(r=>r??{width:Math.round(o.width),height:Math.round(o.height)})},[e]),(0,St.useEffect)(()=>{let o=e.current;if(!o||typeof ResizeObserver>"u")return;let r=l=>{!l||l.width===0||l.height===0||n(c=>{let d={width:Math.round(l.width),height:Math.round(l.height)};return c&&c.width===d.width&&c.height===d.height?c:d})},s=new ResizeObserver(l=>r(l[0]?.contentRect)),i=()=>r(o.getBoundingClientRect());return s.observe(o),addEventListener("resize",i),()=>{s.disconnect(),removeEventListener("resize",i)}},[e]),t}function mo(e,t){if(t==="dark")return`0 ${(10*e).toFixed(1)}px ${(34*e).toFixed(1)}px rgba(0,0,0,${(e+.12).toFixed(2)})`;let n=`0 ${(1+2*e).toFixed(1)}px ${(2+5*e).toFixed(1)}px rgba(20,30,32,${(.03+.06*e).toFixed(3)})`,o=`0 ${(6+26*e).toFixed(1)}px ${(18+60*e).toFixed(1)}px -${(10+10*e).toFixed(1)}px rgba(20,30,32,${(.1+.3*e).toFixed(3)})`;return`${n}, ${o}`}function ga(e){return`matrix3d(${e.join(",")})`}var ue=re(Re(),1);var go=(e,t)=>t.some(n=>e.x>n.x&&e.x<n.x+n.width&&e.y>n.y&&e.y<n.y+n.height);function yo(e,t){let n=[],o=[];for(let s=0;s<e.length-1;s++){let i=e[s],l=e[s+1],c=!go(i,t);c&&o.length===0&&o.push(i);for(let d=1;d<=48;d++){let a=d/48,u={x:i.x+(l.x-i.x)*a,y:i.y+(l.y-i.y)*a},h=!go(u,t);if(h===c)continue;let m=(d-1)/48,x=a;for(let v=0;v<10;v++){let k=(m+x)/2,w={x:i.x+(l.x-i.x)*k,y:i.y+(l.y-i.y)*k};!go(w,t)===c?m=k:x=k}let f=(m+x)/2,g={x:i.x+(l.x-i.x)*f,y:i.y+(l.y-i.y)*f};h?o=[g]:(o.push(g),o.length>=2&&n.push(o),o=[]),c=h}c&&o.push(l)}return o.length>=2&&n.push(o),n}function Ln(e,t){let n=Math.abs(t.x-e.x);if(Math.abs(t.y-e.y)>n){if(n<2)return[e,t];let s=(e.y+t.y)/2;return[e,{x:e.x,y:s},{x:t.x,y:s},t]}let r=(e.x+t.x)/2;return Math.abs(t.x-e.x)<2?[e,t]:[e,{x:r,y:e.y},{x:r,y:t.y},t]}var Qe=e=>Math.round(e*100)/100,Mt=e=>e.map(t=>t.map((n,o)=>`${o===0?"M":"L"} ${Qe(n.x)} ${Qe(n.y)}`).join(" ")).join(" ");function wo(e,t){if(e.length<3)return Mt([e]);let n=[`M ${Qe(e[0].x)} ${Qe(e[0].y)}`];for(let r=1;r<e.length-1;r++){let s=e[r-1],i=e[r],l=e[r+1],c=Math.hypot(i.x-s.x,i.y-s.y),d=Math.hypot(l.x-i.x,l.y-i.y),a=Math.min(t,c/2,d/2),u={x:i.x+(s.x-i.x)/(c||1)*a,y:i.y+(s.y-i.y)/(c||1)*a},h={x:i.x+(l.x-i.x)/(d||1)*a,y:i.y+(l.y-i.y)/(d||1)*a};n.push(`L ${Qe(u.x)} ${Qe(u.y)} Q ${Qe(i.x)} ${Qe(i.y)} ${Qe(h.x)} ${Qe(h.y)}`)}let o=e[e.length-1];return n.push(`L ${Qe(o.x)} ${Qe(o.y)}`),n.join(" ")}function ya(e,t){return t==="orthogonal"?Mt([e]):wo(e,10)}function wa(e,t,n){if(e==="orthogonal"){let l=Ln(t.p0,t.p1),c=l.slice(1).map((u,h)=>Math.hypot(u.x-l[h].x,u.y-l[h].y)),d=c.reduce((u,h)=>u+h,0)||1,a=n*d;for(let u=0;u<c.length;u++){let h=c[u];if(a<=h||u===c.length-1){let m=h===0?0:Math.min(1,a/h),x=l[u],f=l[u+1];return{x:x.x+(f.x-x.x)*m,y:x.y+(f.y-x.y)*m}}a-=h}return t.p1}let o=e==="straight"?{x:(t.p0.x+t.p1.x)/2,y:(t.p0.y+t.p1.y)/2}:t.c,r=(1-n)*(1-n),s=2*(1-n)*n,i=n*n;return{x:r*t.p0.x+s*o.x+i*t.p1.x,y:r*t.p0.y+s*o.y+i*t.p1.y}}function lr(e,t){return e!=="straight"?t:{...t,c:{x:(t.p0.x+t.p1.x)/2,y:(t.p0.y+t.p1.y)/2}}}function xa(e,t){let n=t.x-e.x,o=t.y-e.y,r=(n/2+o)/2,s=(o-n/2)/2;if(Math.abs(r)<1||Math.abs(s)<1)return[e,t];let i={x:e.x+2*r,y:e.y+r};return[e,i,t]}function ba(e){let t=[...e].sort((o,r)=>o.y-r.y||o.x-r.x),n=[];for(let o of t){let r=n.find(s=>o.y<s.bottom+3&&o.y+o.height>s.top-3);r?(r.boxes.push(o),r.top=Math.min(r.top,o.y),r.bottom=Math.max(r.bottom,o.y+o.height)):n.push({top:o.y,bottom:o.y+o.height,boxes:[o]})}for(let o of n)o.boxes.sort((r,s)=>r.x-s.x);return n.sort((o,r)=>o.top-r.top)}var Tn=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,bo=(e,t)=>e.findIndex(n=>n.boxes.some(o=>Tn(o,t)));function va(e,t,n){return t<0?e[0].top-12*2:n>=e.length?e[e.length-1].bottom+12*2:(e[t].bottom+e[n].top)/2}function ko(e,t){let n=[{from:-1/0,to:1/0}];for(let s of e){let i=[],l=-1/0;for(let d of s.boxes)i.push({from:l,to:d.x-12}),l=Math.max(l,d.x+d.width+12);i.push({from:l,to:1/0});let c=[];for(let d of n)for(let a of i){let u=Math.max(d.from,a.from),h=Math.min(d.to,a.to);h-u>=0&&c.push({from:u,to:h})}n=c}let o=t,r=1/0;for(let s of n){let i=Math.min(Math.max(t,s.from),s.to),l=s.from===-1/0||s.to===1/0,c=Math.abs(i-t)+(l?60:0);c<r&&(r=c,o=i)}return o}var tt=e=>({x:e.x,y:-(e.y+e.height),width:e.width,height:e.height}),cr=e=>e.map(t=>({x:t.x,y:-t.y}));function vo(e){let t=(o,r)=>Math.abs(o-r)<.5,n=e.filter((o,r)=>r===0||!(t(o.x,e[r-1].x)&&t(o.y,e[r-1].y)));return n.filter((o,r)=>{let s=n[r-1],i=n[r+1];return!s||!i||!(t(s.x,o.x)&&t(o.x,i.x)||t(s.y,o.y)&&t(o.y,i.y))})}function So(e,t,n){let o=e.boxes.filter(d=>!Tn(d,t)&&d.y+d.height<=t.y+1&&d.x<t.x+t.width&&d.x+d.width>t.x),r=[{from:t.x+6,to:t.x+t.width-6}];for(let d of o)r=r.flatMap(a=>[{from:a.from,to:Math.min(a.to,d.x-12/2)},{from:Math.max(a.from,d.x+d.width+12/2),to:a.to}]).filter(a=>a.to>=a.from);let s=null;for(let d of r){let a=Math.min(Math.max(n,d.from),d.to);(s===null||Math.abs(a-n)<Math.abs(s-n))&&(s=a)}if(s!==null)return{x:s,tail:[{x:s,y:t.y}]};let i=n<t.x+t.width/2,l=ko([e],i?t.x-12:t.x+t.width+12),c=t.y+t.height/2;return{x:l,tail:[{x:l,y:c},{x:l<t.x?t.x:t.x+t.width,y:c}]}}function xo(e,t,n){let o=So({top:-e.bottom,bottom:-e.top,boxes:e.boxes.map(tt)},tt(t),n);return{x:o.x,head:cr(o.tail).reverse()}}function ka(e,t,n,o){let r=t;for(;r>o&&!e[r-1].boxes.some(s=>n>s.x-12/2&&n<s.x+s.width+12/2);)r--;return r}var Sa=(e,t)=>(e%3-1)*Math.max(0,Math.min(4,t/2-3));function Ma(e,t,n,o,r,s,i,l){let c=f=>f<0?e[0].top-n:e[f+1].top-e[f].bottom,d=f=>(f<0?(n+e[0].top)/2:va(e,f,f+1))+Sa(l,c(f)),a=So(e[s],r,i),u=ka(e,s,a.x,t+1),h=d(t);if(u===t+1)return vo([...o.head,{x:o.x,y:h},{x:a.x,y:h},...a.tail]);let m=ko(e.slice(t+1,u),a.x),x=d(u-1);return vo([...o.head,{x:o.x,y:h},{x:m,y:h},{x:m,y:x},{x:a.x,y:x},...a.tail])}function nn(e,t,n,o=0){let r=ba(n.some(a=>Tn(a,e))&&n.some(a=>Tn(a,t))?n:[...n,e,t]),s=bo(r,e),i=bo(r,t),l=e.x+e.width/2,c=t.x+t.width/2;if(s===i){if(!(s<r.length-1||r.length===1))return cr(nn(tt(e),tt(t),n.map(tt),o));let u=va(r,s,s+1)+Sa(o,s<r.length-1?r[s+1].top-r[s].bottom:2*12),h=xo(r[s],e,c),m=xo(r[s],t,l);return vo([...h.head,{x:h.x,y:u},{x:m.x,y:u},...[...m.head].reverse()])}if(i<s)return cr(nn(tt(e),tt(t),n.map(tt),o));let d=xo(r[s],e,c);return Ma(r,s,r[s].bottom,d,t,i,l,o)}function Mo(e,t,n,o=0){if(t.y+t.height<=e.y){let m=Mo(tt(e),tt(t),n.map(tt),o);return m?cr(m):null}let r=e.y+e.height;if(t.y<r)return null;let s=ba([...n.filter(m=>m.y>=r&&!Tn(m,t)),t]),i=bo(s,t),l=t.x+t.width/2,c=So(s[i],t,l),d=ka(s,i,c.x,0),a=d===0?c.x:ko(s.slice(0,d),c.x),u=Math.min(12,e.width/2),h=Math.min(Math.max(a,e.x+u),e.x+e.width-u);return Ma(s,-1,r,{x:h,head:[{x:h,y:r}]},t,i,l,o)}function Ea(e,t=16){let n=new Map;for(let r of e){let s=r.a<r.b?`${r.a}\0${r.b}`:`${r.b}\0${r.a}`,i=n.get(s);i?i.push(r.key):n.set(s,[r.key])}let o=new Map;for(let r of n.values())r.forEach((s,i)=>o.set(s,(i-(r.length-1)/2)*t));return o}var Ke=re(Me(),1);function Ro(e,t,n,o){let r=[];for(let s of e.querySelectorAll("[data-graview-relation] > span")){let i=s.getBoundingClientRect();if(i.width<=0||i.height<=0)continue;let l=i.top-t.top,c=s.parentElement?.getAttribute("data-graview-relation"),d=1/0;for(let a of n){if(Math.round(a.plane)!==1||!a.via||`${a.via.edgeKind}|${a.via.direction}`!==c)continue;let u=o(a.id);u&&u.y>=l+i.height-1&&(d=Math.min(d,u.y))}r.push({x:i.left-t.left,y:l,width:i.width,height:d-l<=i.height*4?d-l:i.height})}return r}function hr(e,t){let n=Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x),o=Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y);if(n>0&&o>0)return null;let r=n>.5*Math.min(e.width,t.width),s=!r&&o>.5*Math.min(e.height,t.height);if(r){let x={x:e.x+e.width,y:e.y+e.height/2},f={x:t.x+t.width,y:t.y+t.height/2};return{from:x,to:f,control:{x:Math.max(x.x,f.x)+18,y:(x.y+f.y)/2},mode:"stacked"}}if(s){let x={x:e.x+e.width/2,y:e.y},f={x:t.x+t.width/2,y:t.y};return{from:x,to:f,control:{x:(x.x+f.x)/2,y:Math.min(x.y,f.y)-18},mode:"abreast"}}let i={x:t.x+t.width/2,y:t.y+t.height/2},l={x:e.x+e.width/2,y:e.y+e.height/2},c=ur(e,i),d=ur(t,l),a=Math.hypot(d.x-c.x,d.y-c.y);if(a<8)return null;let u=Math.min(36,a*.12),h=-(d.y-c.y)/a,m=(d.x-c.x)/a;return{from:c,to:d,control:{x:(c.x+d.x)/2+h*u,y:(c.y+d.y)/2+m*u},mode:"direct"}}function ur(e,t){let n=e.x+e.width/2,o=e.y+e.height/2,r=t.x-n,s=t.y-o;if(r===0&&s===0)return{x:n,y:o};let i=r===0?1/0:e.width/2/Math.abs(r),l=s===0?1/0:e.height/2/Math.abs(s),c=Math.min(i,l),d=Math.max(0,c*.98);return{x:n+r*d,y:o+s*d}}function id(e,t,n){let o=t.get(e.from),r=t.get(e.to);if(!o||!r)return!1;if(n)return!0;let s=Math.round(o.plane)===1||Math.round(r.plane)===1,i=l=>!!l.aggregate&&Math.round(l.plane)===2;return s&&!i(o)&&!i(r)}var Oa=e=>({clips:new Map,members:new Map,marks:new Map,...e?{owed:e}:{}});function Aa(e,t){let n=Oa();for(let[o,r]of t){let s=e.querySelector(`[data-graview-view="${CSS.escape(o)}"]`);if(s!==null){for(let i of r)if(rn(e,s,i,n).length>0)return!0}}return!1}function Pa(e,t){let n=t.marks.get(e);if(n)return n;n=new Map;for(let o of e.querySelectorAll("[data-graview-pick], [data-graview-slot]"))for(let r of new Set([o.getAttribute("data-graview-pick"),o.getAttribute("data-graview-slot")])){if(r===null)continue;let s=n.get(r);s?s.push(o):n.set(r,[o])}return t.marks.set(e,n),n}function ad(e,t){let n=t.clips.get(e);if(n===void 0){let o=getComputedStyle(e);n=o.overflow!=="visible"||o.overflowX!=="visible"||o.overflowY!=="visible"?e.getBoundingClientRect():null,t.clips.set(e,n)}return n}function sd(e,t,n){let o=e.parentElement;for(;o!==null;){let r=ad(o,n);if(r&&!(t.right>r.left+1&&t.left<r.right-1&&t.bottom>r.top+1&&t.top<r.bottom-1))return!1;if(o.hasAttribute("data-graview-view"))break;o=o.parentElement}return!0}function rn(e,t,n,o){if(!e||!t||typeof document>"u")return[];let r=o.members.get(t);r||o.members.set(t,r=new Map);let s=r.get(n);if(s)return s;let i=e.getBoundingClientRect(),l=[];for(let d of Pa(t,o).get(n)??[]){if(d.closest("[data-graview-offstage]"))continue;let a=d.getBoundingClientRect();a.width<=2||a.height<=2||sd(d,a,o)&&l.push({x:a.left-i.left,y:a.top-i.top,width:a.width,height:a.height})}l.sort((d,a)=>d.width*d.height-a.width*a.height),r.set(n,l);let c=t.getAttribute("data-graview-view");return l.length===0&&o.owed&&c!==null&&o.owed.set(c,(o.owed.get(c)??new Set).add(n)),l}function fr(e,t,n,o,r,s){let i=new Map(e.map(w=>[w.id,w])),l=Oa(s),c=new Map,d=w=>{if(!n||typeof document>"u")return null;let O=c.get(w);return O===void 0&&(O=n.querySelector(`[data-graview-view="${CSS.escape(w)}"]`),c.set(w,O)),O},a=new Map;for(let w of e){let O=je(n,w.id,o)??at(w,r);O&&a.set(w.id,O)}let u=new Map;if(n&&typeof document<"u"){let w=n.getBoundingClientRect();for(let O of n.querySelectorAll("[data-graview-pick], [data-graview-slot]")){if(O.closest("[data-graview-offstage]"))continue;let G=O.getAttribute("data-graview-pick")??O.getAttribute("data-graview-slot");if(G===null)continue;let D=O.getBoundingClientRect();if(D.width<=2||D.height<=2||D.width>w.width*.6&&D.height>w.height*.6)continue;let X=u.get(G),j={x:D.left-w.left,y:D.top-w.top,width:D.width,height:D.height};X?X.push(j):u.set(G,[j])}}let h=(w,O)=>{let G=[];for(let[D,X]of a)D!==w&&D!==O&&G.push(X);for(let[D,X]of u)D!==w&&D!==O&&G.push(...X);return G},m=w=>Math.round(i.get(w)?.plane??-1)===1,x=[];for(let w of e){let O=a.get(w.id);O&&Math.round(w.plane)===1&&x.push(O)}if(!o&&n&&typeof document<"u"){let w=n.getBoundingClientRect();x.push(...Ro(n,w,e,O=>a.get(O)))}let f=(w,O)=>!o&&m(w)&&m(O)?x:void 0,g=o?void 0:e.find(w=>Math.round(w.plane)===0&&!w.aggregate),v=(w,O,G,D)=>{if(!g)return{};let X=w.to===g.id&&G===g.id;if(!X&&!(w.from===g.id&&O===g.id))return{};let j=X?w.from:w.to,y=a.get(g.id),S=a.get(j);if(j===g.id||!m(j)||!y||!S)return{};let P=d(g.id),A=te=>P!==null&&Pa(P,l).get(te)?.some(C=>!C.closest("[data-graview-offstage]"))===!0,W=D.map(te=>te.from===g.id?te.to:te.from),K=W.length>0&&W.every(A);return{band:x,tie:{card:y,chip:S,cardIsTo:X,toward:j,holds:i.get(j)?.aggregate?.memberIds??[j]},...K?{said:W}:{}}},k=[];for(let w of t){if(!id(w,i,o))continue;let O=a.get(w.from),G=a.get(w.to);if(!O||!G)continue;let D=h(w.from,w.to),X=w.edges,j=o&&X.some(P=>P.from!==w.from&&rn(n,d(w.from),P.from,l).length>0||P.to!==w.to&&rn(n,d(w.to),P.to,l).length>0),y=f(w.from,w.to);if(o&&!j||w.loop||X.length===0){k.push({key:w.id,connector:w,edges:X,fromBox:O,toBox:G,fromAnchor:w.from,toAnchor:w.to,obstacles:D,hosts:[],...y?{band:y}:{},...v(w,w.from,w.to,X)});continue}let S=new Map;for(let P of X){let A=P.from===w.from?[]:rn(n,d(w.from),P.from,l),W=P.to===w.to?[]:rn(n,d(w.to),P.to,l),K=[w.from,w.to].find(M=>Math.round(i.get(M)?.plane??-1)===0);if(!o&&K!==void 0&&(K===w.from?P.from!==w.from:P.to!==w.to)&&rn(n,d(K),K===w.from?P.to:P.from,l).length>0)continue;let te=K!==void 0?i.get(K):void 0;if(!o&&te?.aggregate&&n&&(K===w.from?P.from!==w.from&&A.length===0:P.to!==w.to&&W.length===0))continue;let C=A.length>0?P.from:w.from,H=W.length>0?P.to:w.to,N=`${w.id}|${C}|${H}`,Q=S.get(N);if(Q){Q.edges.push(P);continue}let R=A.length>0?A:[O],$=W.length>0?W:[G],b=R[0],E=$[0],T=1/0;for(let M of R)for(let B of $){let L=Math.hypot(M.x+M.width/2-(B.x+B.width/2),M.y+M.height/2-(B.y+B.height/2));L<T&&(T=L,b=M,E=B)}S.set(N,{edges:[P],fromBox:b,toBox:E,fromAnchor:C,toAnchor:H})}for(let[P,A]of S)k.push({key:P,connector:w,obstacles:D,hosts:[...A.fromAnchor!==w.from?[O]:[],...A.toAnchor!==w.to?[G]:[]],...y?{band:y}:{},...A,...v(w,A.fromAnchor,A.toAnchor,A.edges)})}return k}function La(e,t,n){let o=new Map(t.map(i=>[i.id,i])),r=new Map;for(let i of n){let l=o.get(i.id);l&&(l.x!==i.x||l.y!==i.y)&&r.set(i.id,{x:i.x-l.x,y:i.y-l.y})}if(r.size===0)return[...e];let s=(i,l)=>{let c=r.get(l);return c?{...i,x:i.x+c.x,y:i.y+c.y}:i};return e.map(i=>{let{from:l,to:c}=i.connector;if(!r.has(l)&&!r.has(c))return i;let d=s(i.fromBox,l),a=s(i.toBox,c),u=i.tie&&{...i.tie,card:s(i.tie.card,i.tie.cardIsTo?c:l),chip:s(i.tie.chip,i.tie.toward)},h=m=>m===i.fromBox?d:m===i.toBox?a:i.tie&&m===i.tie.chip?u.chip:m;return{...i,fromBox:d,toBox:a,...u?{tie:u}:{},...i.band?{band:i.band.map(h)}:{}}})}function Eo(e,t){let n=(1-t)*(1-t),o=2*(1-t)*t,r=t*t;return{x:n*e.p0.x+o*e.c.x+r*e.p1.x,y:n*e.p0.y+o*e.c.y+r*e.p1.y}}function Ra(e,t,n){let o=(1-t)*(1-n),r=(1-t)*n+t*(1-n),s=t*n;return{p0:Eo(e,t),c:{x:o*e.p0.x+r*e.c.x+s*e.p1.x,y:o*e.p0.y+r*e.c.y+s*e.p1.y},p1:Eo(e,n)}}function Cn(e,t){let n=d=>t.some(a=>d.x>a.x&&d.x<a.x+a.width&&d.y>a.y&&d.y<a.y+a.height),o=d=>!n(Eo(e,d)),s=(d,a,u)=>{for(let h=0;h<10;h++){let m=(d+a)/2;o(m)===u?d=m:a=m}return(d+a)/2},i=[],l=null,c=o(0);c&&(l=0);for(let d=1;d<=64;d++){let a=d/64,u=o(a);if(u===c)continue;let h=s((d-1)/64,a,c);u?l=h:l!==null&&(h-l>.001&&i.push(Ra(e,l,h)),l=null),c=u}return l!==null&&1-l>.001&&i.push(Ra(e,l,1)),i}function Ta({strands:e,result:t,scheme:n,overview:o,selection:r,emphasis:s,stageRef:i,liveOf:l,onPickEdge:c,provisional:d,pointed:a=null}){let u=Ht(),h=new Set(t.nodes.filter(y=>y.plot!==void 0&&Math.round(y.plane)===2).map(y=>y.id)),m=y=>o&&t.city!==void 0&&h.has(y.from)&&h.has(y.to),x=so(t.nodes,r),f=y=>x.size===0||x.has(y.from)||x.has(y.to),g=new Set(r.filter(y=>Tt(y)===null)),v=o?t.nodes.find(y=>Math.round(y.plane)===0):void 0,k=v?je(i.current,v.id,!1)??at(v,n):null;if(e.length===0)return null;let w=y=>y.edges.some(S=>g.has(S.from)||g.has(S.to)),O=g.size>0&&e.some(w),G=new Map;for(let y of e)G.set(y.connector.id,(G.get(y.connector.id)??0)+1);let D=Ea(e.map(y=>({key:y.key,a:y.fromAnchor,b:y.toAnchor}))),X=new Set,j=e.map((y,S)=>{let{connector:P,fromBox:A,toBox:W}=y,K={x:A.x+A.width/2,y:A.y+A.height/2},te={x:W.x+W.width/2,y:W.y+W.height/2},C=o?ur(A,te):K,H=o?ur(W,K):te,N=P.loop===!0,{connector:Q,style:R}=Qt(u,P.kind);if(!Q.visible)return null;let $=N?Math.max(22,Math.min(A.width,A.height)*.3):0,b=N?{x:K.x+A.width*.22,y:K.y-A.height/2-$+7}:C,E=(C.x+H.x)/2,T=(C.y+H.y)/2,M=Math.hypot(H.x-C.x,H.y-C.y),B=Math.min(o?40:90,M*(o?.09:.16)),L=0,F=0;if(M>0){L=-(H.y-C.y)/M,F=(H.x-C.x)/M;let ae=E-t.width/2,ye=T-t.height/2;if(k&&!N){let Ge=k.x+k.width/2,mt=k.y+k.height/2;ae=E-Ge,ye=T-mt;let qe=Math.abs(L*(Ge-C.x)+F*(mt-C.y)),At=Math.hypot(k.width/2,k.height/2)*.85+24,sn=((Ge-C.x)*(H.x-C.x)+(mt-C.y)*(H.y-C.y))/(M*M);qe<At&&sn>.1&&sn<.9&&(B=Math.min(180,Math.max(B,(At-qe)*2)))}L*ae+F*ye<0&&(L=-L,F=-F)}B+=2*(D.get(y.key)??0);let Z=lr(Q.route,{p0:C,c:{x:E+L*B,y:T+F*B},p1:H}),_=m(P),z=Q.route==="orthogonal"||_,ee=(ae,ye)=>_?xa(ae,ye):Ln(ae,ye),q=!N&&y.tie?Mo(y.tie.card,y.tie.chip,y.band??[],S):null,he=q?y.tie.cardIsTo?q.reverse():q:!N&&y.band?nn(A,W,y.band,S):null,ce=N||z||he?[]:Cn(Z,[A,W,...y.obstacles]),He=he?[he]:!N&&z?yo(ee(C,H),[A,W,...y.obstacles]):[];if(!N&&ce.length===0&&He.length===0)return null;let Ee=He[He.length-1],Ae=z||he?He[0]?.[0]:ce[0]?.p0,De=z||he?Ee?.[Ee.length-1]:ce[ce.length-1]?.p1,Ce=ae=>ae.map(ye=>`M ${ye.p0.x} ${ye.p0.y} Q ${ye.c.x} ${ye.c.y} ${ye.p1.x} ${ye.p1.y}`).join(" "),ie=`M ${b.x-$} ${b.y} A ${$} ${$} 0 1 1 ${b.x+$} ${b.y} A ${$} ${$} 0 0 1 ${b.x-$} ${b.y}`,ve=N?ie:he?ya(he,Q.route):z?Mt(He):Ce(ce),Ze=ae=>({x:ae.x-8,y:ae.y-8,width:ae.width+16,height:ae.height+16}),Et=[A,W,...y.hosts,...y.obstacles].map(Ze),ne=N?ie:he?Mt(He):z?Mt(yo(ee(C,H),Et)):Ce(Cn(Z,Et)),rt=y.edges.length===1?y.edges[0]:null,$e=rt?Dt(P.kind,rt.from,rt.to):null,Rt=$e!==null&&r.includes($e),Ve=$e!==null?d?.get($e):void 0,Ot=y.edges.some(ae=>g.has(ae.from)||g.has(ae.to)),Ue=y.tie?.toward??"",Je=y.tie!==void 0&&(a!==null&&(Ue===a||y.tie.holds.includes(a)||y.said?.includes(a)===!0)||g.has(Ue))&&!X.has(Ue);Je&&X.add(Ue);let Pe=!o&&g.size>0&&Ot||Je,Ie=s!==null&&P.kind===s||Rt,ft=l?.(P)!==void 0;if(o&&!ft||!o&&!ft&&g.size>0&&!Ot&&!Ie&&!Je||y.said!==void 0&&!Je&&!y.said.some(ae=>g.has(ae))&&!Ie)return null;let Xe=o?lo({emphasized:s!==null,stressed:Ie,anyChosen:O,mine:Ot,touches:f(P),siblings:G.get(P.id)??1}):co({edgeChosen:Rt,lit:Pe,anyLit:O||s!==null,own:R.opacity,kit:u.emphasis}),pt=Pe&&Ae&&De?y.tie?y.tie.cardIsTo?Ae:De:y.edges.some(ae=>g.has(ae.from))?De:Ae:null,an=(0,Ke.jsxs)("g",{children:[(0,Ke.jsx)("path",{"data-graview-connector":P.kind,"data-graview-edges":y.edges.length,"data-graview-from":y.fromAnchor,"data-graview-to":y.toAnchor,"data-graview-lit":Pe||void 0,"data-graview-activity":l?.(P)?.manner,"data-graview-provisional":Ve!==void 0||void 0,opacity:Xe*(P.opacity??1)*(Ve!==void 0?kn:1),d:ve,fill:"none",stroke:Ut(R),strokeWidth:(Pe?Math.max(1.6,Hr(R,o)):Hr(R,o))+(Ie?.6:0),strokeDasharray:Ve!==void 0?vn:Un[R.pattern],strokeLinecap:"round"}),pt?(0,Ke.jsx)("circle",{cx:pt.x,cy:pt.y,r:2.6,fill:Ut(R),opacity:Xe}):null,N&&o?(0,Ke.jsx)("text",{x:b.x,y:b.y-$-5,textAnchor:"middle",opacity:Xe,style:{font:"9px var(--graview-font-body, system-ui)",letterSpacing:"0.09em",textTransform:"uppercase",fill:"var(--graview-ink-faint)"},children:Vn(P.kind).toLowerCase()}):null]},y.key),dt=null;return $e&&c&&!N&&Xe>=.2&&(dt=(0,Ke.jsx)("path",{"data-graview-edge":$e,className:"graview-edge-hit",d:ne,fill:"none",pathLength:1,strokeDasharray:"0.86",strokeDashoffset:-.07,stroke:"transparent",strokeWidth:14,style:{pointerEvents:"stroke",cursor:"pointer"},onClick:ae=>{ae.stopPropagation(),c($e,{x:ae.clientX,y:ae.clientY})},onContextMenu:ae=>{ae.preventDefault(),ae.stopPropagation(),c($e,{x:ae.clientX,y:ae.clientY})},children:Ve!==void 0?(0,Ke.jsx)("title",{children:Ve}):null},`hit:${y.key}`)),{key:y.key,line:an,hit:dt}});return(0,Ke.jsxs)(Ke.Fragment,{children:[(0,Ke.jsx)("svg",{"aria-hidden":"true","data-graview-world":"",width:t.width,height:t.height,style:{position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:Fe.ties},children:j.map(y=>y?.line)}),j.some(y=>y?.hit)?(0,Ke.jsx)("svg",{"data-graview-world":"",width:t.width,height:t.height,style:{position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:Fe.tieLabels},children:j.map(y=>y?.hit)}):null]})}function Ca(e,t,n){if(t.size===0||typeof MutationObserver>"u")return()=>{};let o=0,r=()=>{o=0,Aa(e,t)&&n()},s=()=>{o===0&&(o=requestAnimationFrame(r))},i=({target:c})=>{for(let d=c instanceof Element?c:c.parentElement;d&&d!==e;d=d.parentElement)if(t.has(d.getAttribute("data-graview-view")??""))return!0;return!1},l=new MutationObserver(c=>{c.some(i)&&s()});return l.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-graview-pick","data-graview-slot","data-graview-offstage"]}),s(),()=>{l.disconnect(),cancelAnimationFrame(o)}}function pr(e){return e<640?{left:8,right:56}:{left:8,right:Math.round(Math.min(128,e*.107))}}function dd(e){return Math.min(260,16+e.length*6.6)}var In=(e,t)=>Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));function Na(e,t,n){let o=new Map;for(let i of e){let l=o.get(i.said);l?l.push(i):o.set(i.said,[i])}let r=[],s=[];for(let[i,l]of o){let c=l[0],d=dd(i),{end:a,far:u}=c,h=g=>Math.max(0,Math.min(n.width-d,g)),m=[{x:h(a.x-d/2),y:u.y-22-6,width:d,height:22},{x:h(a.x-d/2),y:u.y+u.height+6,width:d,height:22},{x:u.x+u.width+6,y:a.y-22/2,width:d,height:22},{x:u.x-d-6,y:a.y-22/2,width:d,height:22}],x=m[0],f=1/0;for(let g of m){let k=g.x<0||g.y<0||g.x+g.width>n.width||g.y+g.height>n.height?1e9:0;for(let w of t)k+=In(g,w.title)*100+In(g,w.box);for(let w of r)k+=In(g,w)*100;if(k<f&&(f=k,x=g),k===0)break}r.push(x),s.push({said:i,keys:l.map(g=>g.key),...x})}return s}var Ia=(e,t,n=2)=>t.x>=e.x-n&&t.x<=e.x+e.width+n&&t.y>=e.y-n&&t.y<=e.y+e.height+n;function Oo(e,t){let n=new Set;for(let o of e)(t.edgeId&&o.edgeId===t.edgeId||t.point&&(Ia(o.fromBox,t.point)||Ia(o.toBox,t.point))||t.ids?.some(r=>o.ids.includes(r))||t.box&&(In(t.box,o.fromBox)>0||In(t.box,o.toBox)>0))&&n.add(o.key);return n}var xe=re(Me(),1);function Da(e){let t=ni(e);return t.length>0?new Map(t.map(n=>[Dt(n.edge.kind,n.edge.from,n.edge.to),ti(n)])):void 0}function $a({frame:e,width:t,height:n,scheme:o,overview:r,selection:s,emphasis:i,stageRef:l,store:c,graphNodes:d,onPickEdge:a,liveOf:u,holding:h=!1,provisional:m,focusId:x=null,beside:f=!1}){let[g,v]=(0,ue.useState)(0),[k,w]=(0,ue.useState)(null),O=e.t<1,G=(0,ue.useRef)(""),D=(0,ue.useRef)([]),X=(0,ue.useRef)(new Map),j=()=>[...l.current?.querySelectorAll("[data-graview-relation] > span")??[]].map(C=>{let H=C.getBoundingClientRect();return`${Math.round(H.left)},${Math.round(H.top)},${Math.round(H.width)}`}).join(" ");(0,ue.useLayoutEffect)(()=>{if(O||h)return;G.current=j(),D.current=e.nodes;let C=new Map;w(fr(e.nodes,e.connectors,l.current,r,o,C)),X.current=C},[e,O,h,s,r,d,o,g,l]),(0,ue.useEffect)(()=>{let C=l.current;if(!(O||h||C===null))return Ca(C,X.current,()=>v(H=>H+1))},[k,O,h,l]),(0,ue.useEffect)(()=>{if(O||h||r||typeof requestAnimationFrame>"u")return;let C=requestAnimationFrame(()=>{j()!==G.current&&v(H=>H+1)});return()=>cancelAnimationFrame(C)},[k]);let y=e.nodes.map(C=>C.id).join(`
4
+ `);(0,ue.useLayoutEffect)(()=>{let C=l.current;if(C===null||typeof window>"u")return;let H=0,N=()=>{H===0&&(H=requestAnimationFrame(()=>{H=0,v(R=>R+1)}))};C.addEventListener("scroll",N,{capture:!0,passive:!0}),window.addEventListener("resize",N,{passive:!0});let Q=typeof ResizeObserver>"u"?null:new ResizeObserver(N);if(Q){Q.observe(C);for(let R of C.querySelectorAll("[data-graview-view]"))Q.observe(R)}return()=>{H!==0&&cancelAnimationFrame(H),C.removeEventListener("scroll",N,{capture:!0}),window.removeEventListener("resize",N),Q?.disconnect()}},[l,y]);let S=(0,ue.useRef)(new WeakMap);(0,ue.useEffect)(()=>{let C=l.current;if(O||h||C===null||typeof ResizeObserver>"u")return;let H=0,N=new ResizeObserver(Q=>{let R=!1;for(let{target:$,contentRect:b}of Q){let E=`${Math.round(b.width)}x${Math.round(b.height)}`;S.current.has($)&&S.current.get($)!==E&&(R=!0),S.current.set($,E)}R&&H===0&&(H=requestAnimationFrame(()=>{H=0,v($=>$+1)}))});for(let Q of C.querySelectorAll("[data-graview-view]")){let R=uo(Q);R!==Q&&N.observe(R)}return()=>{H!==0&&cancelAnimationFrame(H),N.disconnect()}},[k,O,h,l]);let[P,A]=(0,ue.useState)(null),W=(k??[]).some(C=>C.tie!==void 0);if((0,ue.useEffect)(()=>{let C=l.current;if(!W||C===null)return;let H=Q=>{let R=Q.target?.closest?.("[data-graview-pick], [data-graview-view]");A(R?.getAttribute("data-graview-pick")??R?.getAttribute("data-graview-view")??null)},N=()=>A(null);return C.addEventListener("pointerover",H),C.addEventListener("focusin",H),C.addEventListener("pointerleave",N),C.addEventListener("focusout",N),()=>{C.removeEventListener("pointerover",H),C.removeEventListener("focusin",H),C.removeEventListener("pointerleave",N),C.removeEventListener("focusout",N)}},[W,l]),O)return null;let K=(k&&h?La(k,D.current,e.nodes):k)??fr(e.nodes,e.connectors,null,r,o),te=new Set;for(let C of K){if(C.edges.length===1){let H=C.edges[0];te.add(`${C.connector.kind}|${H.from}|${H.to}`);continue}for(let H of C.edges)(C.connector.from===H.from||C.connector.to===H.to)&&te.add(`${C.connector.kind}|${H.from}|${H.to}`)}return(0,xe.jsxs)(xe.Fragment,{children:[(0,xe.jsx)(Ta,{strands:K,result:e,scheme:o,overview:r,selection:s,emphasis:i,stageRef:l,onPickEdge:a,liveOf:u,pointed:P,...m?{provisional:m}:{}}),r&&Mn(s,{overview:r,focusId:x,beside:f},C=>c.graph.getNode(C)?.kind).records.length>0?(0,xe.jsx)(ue.Suspense,{fallback:null,children:(0,xe.jsx)(cd,{frame:e,width:t,height:n,stageRef:l,tick:g,store:c,graphVersion:d,selection:s,view:{overview:r,focusId:x,beside:f},rulers:m?{...Ba,unsureOf:(C,H,N)=>m.get(Dt(C,H,N))}:Ba})}):null,r?null:(0,xe.jsx)(hd,{...m?{provisional:m}:{},stageRef:l,nodes:e.nodes,scheme:o,selection:s,store:c,graphNodes:d,overview:r,width:t,height:n,onPickEdge:a,alreadyDrawn:te,tick:g})]})}var Ba={visibleRect:tn,clipQuadratic:Cn,unsureDash:vn,unsureOpacity:kn},ld=bn(Yt(()=>(__graviewPreload(import.meta.url,["./chunk.22BZU7ME.js","./chunk.NUYA4BWI.js","./chunk.OKZT2QBM.js","./chunk.ACTXR2MI.js","./chunk.M7RESZB6.js","./chunk.SDO3U72B.js","./chunk.DZZL5IDD.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.MYNMBOLD.js")))),cd=ld.part((e,t)=>(0,xe.jsx)(e.RecordLinks,{...t}),{what:"The links",quiet:!0}),ud=44;function hd({stageRef:e,nodes:t,scheme:n,selection:o,store:r,graphNodes:s,overview:i,width:l,height:c,onPickEdge:d,alreadyDrawn:a,tick:u,provisional:h}){let m=Ht(),x=(0,ue.useMemo)(()=>{if(o.length===0||o.length>4)return[];let y=new Set(o),S=[];for(let A of o){let W=Tt(A);W&&S.push({kind:W.kind,self:W.from,other:W.to})}for(let A of r.graph.allEdges()){let W=y.has(A.from)?A.from:y.has(A.to)?A.to:null;if(!W)continue;let K=W===A.from?A.to:A.from;y.has(K)||S.push({kind:A.kind,self:W,other:K})}if(S.length<=14)return S;let P=new Set(t.map(A=>A.id));return S.map((A,W)=>({tie:A,index:W,real:P.has(A.other)?0:1})).sort((A,W)=>A.real-W.real||A.index-W.index).slice(0,14).map(({tie:A})=>A)},[r,o,s,t]),f=()=>{if(x.length===0||typeof document>"u")return[];let y=e.current?.getBoundingClientRect();if(!y)return[];let S=[...e.current?.querySelectorAll("[data-graview-joins]")??[]].find(R=>{if(R.closest("[data-graview-offstage]"))return!1;try{let $=JSON.parse(R.getAttribute("data-graview-joins")??"[]");return $.length===o.length&&$.every(b=>o.includes(b))}catch{return!1}});if(S){let R=tn(S,e.current);if(!R)return[];let $=[];for(let b of o){let E=t.find(L=>L.id===b);if(!E)continue;let T=je(e.current,E.id,i)??at(E,n),M=T?hr(R,T):null;if(!T||!M)continue;let B=[...r.graph.allEdges()].find(L=>L.from===b&&o.includes(L.to)||L.to===b&&o.includes(L.from));$.push({key:`join:${b}`,self:b,other:"",others:1,kind:B?.kind??"",endX:M.to.x,endY:M.to.y,...M,fromBox:R,toBox:T,proxy:!1,edgeId:B?Dt(B.kind,B.from,B.to):null})}return $}let P=(R,$)=>{let b=e.current?.querySelectorAll(`[data-graview-pick="${CSS.escape(R)}"], [data-graview-slot="${CSS.escape(R)}"]`),E=[];for(let T of b??[]){if(T.closest("[data-graview-offstage]")||$(T)||T.closest("[data-graview-mark]"))continue;let M=tn(T,e.current);M&&E.push(M)}return E.sort((T,M)=>T.width*T.height-M.width*M.height)},A=R=>t.find($=>$.id===R)??t.find($=>$.aggregate?.memberIds.includes(R)),W=R=>`[data-graview-pick="${CSS.escape(R)}"], [data-graview-slot="${CSS.escape(R)}"]`,K=(R,$)=>{let b=e.current;if(!b)return!1;for(let E of b.querySelectorAll("[data-graview-view]")){let T=E.querySelector(W(R));if(T===null||T.closest("[data-graview-offstage]"))continue;let M=E.querySelector(W($));if(M!==null&&!M.closest("[data-graview-offstage]"))return!0}return!1},te=[];if(!i&&e.current){for(let $ of t){if(Math.round($.plane)!==1)continue;let b=je(e.current,$.id,!1);b&&te.push(b)}let R=e.current;te.push(...Ro(R,y,t,$=>je(R,$,!1)))}let C=new Map,H=[];for(let R of x){if(K(R.self,R.other))continue;let $=A(R.self),b=$?e.current?.querySelector(`[data-graview-view="${CSS.escape($.id)}"]`):null,E=!i&&$?.id===R.self&&Math.round($.plane)===1?je(e.current,$.id,!1):null,T=E?[E]:P(R.self,()=>!1);if(!(T.length>0)&&$){let ie=je(e.current,$.id,!1)??at($,n);ie&&T.push(ie)}let B=t.find(ie=>ie.id===R.other),L=[],F=!1;if(B){let ie=je(e.current,B.id,i)??at(B,n);ie&&L.push(ie)}else if(L.push(...P(R.other,ie=>b?b.contains(ie):!1)),L.length===0){let ie=A(R.other);if(ie&&(!$||ie.id!==$.id)){let ve=je(e.current,ie.id,i)??at(ie,n);ve&&(L.push(ve),F=!0)}}if(T.length===0||L.length===0||F&&i)continue;let Z=T[0],_=L[0],z=1/0;for(let ie of T)for(let ve of L){let Ze=Math.hypot(ie.x+ie.width/2-(ve.x+ve.width/2),ie.y+ie.height/2-(ve.y+ve.height/2));Ze<z&&(z=Ze,Z=ie,_=ve)}if(a?.has(`${R.kind}|${R.self}|${R.other}`)||a?.has(`${R.kind}|${R.other}|${R.self}`))continue;let ee=`${R.kind}:${Math.round(Z.x)},${Math.round(Z.y)}:${Math.round(_.x)},${Math.round(_.y)}`,q=C.get(ee);if(q){q.others+=1;continue}let he=hr(Z,_);if(!he)continue;let{from:ce,control:He}=he,Ee=E&&Z===E?nn(Z,_,te,H.length):void 0,Ae=Ee?Ee[Ee.length-1]:he.to,De=[...r.graph.allEdges()].find(ie=>ie.kind===R.kind&&(ie.from===R.self&&ie.to===R.other||ie.from===R.other&&ie.to===R.self)),Ce={key:`${R.kind}:${R.self}:${R.other}`,self:R.self,other:R.other,others:1,kind:R.kind,endX:Ae.x,endY:Ae.y,from:ce,to:Ae,control:He,fromBox:Z,toBox:_,...Ee?{points:Ee}:{},proxy:F,edgeId:De?Dt(De.kind,De.from,De.to):null};C.set(ee,Ce),H.push(Ce)}let N=i?void 0:t.find(R=>Math.round(R.plane)===0&&!R.aggregate),Q=R=>{let $=t.find(b=>b.id===R.other)??t.find(b=>b.aggregate?.memberIds.includes(R.other));return $!==void 0&&Math.round($.plane)===1&&$.via?.edgeKind===R.kind};for(let R of H){if(N&&(R.self!==N.id||Q(R)))continue;let $=[...r.graph.allEdges()].find(L=>L.kind===R.kind&&(L.from===R.self&&L.to===R.other||L.from===R.other&&L.to===R.self)),b=r.graph.getNode(R.self),E=r.graph.getNode(R.other);if(!$||!b||!E)continue;let T=$.from===R.self?"out":"in",M=ei(r.schema,T==="out"?b.kind:E.kind,R.kind,T),B=R.proxy?(T==="out"?r.graph.out(R.self,R.kind):r.graph.in(R.self,R.kind)).filter(L=>L.kind===E.kind).length:1;R.said=R.proxy?`${M}: ${zt(r.schema,E.kind,Math.max(B,R.others))}`:`${M}: ${Gt(r.schema.tryDefinition(E.kind),E)}`}return H},[g,v]=(0,ue.useState)([]),[k,w]=(0,ue.useState)([]);(0,ue.useLayoutEffect)(()=>{let y=f();v(y),w(y.some(S=>S.said)?O(y):[])},[x,t,i,n,l,c,a,u,e]);let O=y=>{let S=e.current;if(!S)return[];let P=[];for(let A of S.querySelectorAll("[data-graview-view]")){let W=[...A.children].find(te=>!te.classList.contains("graview-kind-tag")),K=W?tn(W,S):null;K&&P.push({box:K,title:{...K,height:Math.min(K.height,ud)}})}return Na(y.flatMap(A=>A.said?[{key:A.key,said:A.said,end:{x:A.endX,y:A.endY},far:A.toBox}]:[]),P,{width:l,height:c})},[G,D]=(0,ue.useState)(()=>new Set),X=(0,ue.useRef)([]);X.current=g.map(y=>({key:y.key,fromBox:y.fromBox,toBox:y.toBox,ids:[y.self,y.other],edgeId:y.edgeId}));let j=k.length>0;return(0,ue.useEffect)(()=>{let y=e.current;if(!y||!j)return;let S=N=>D(Q=>Q.size===N.size&&[...N].every(R=>Q.has(R))?Q:N),P=0,A=null,W=()=>{if(P=0,!A)return;let N=y.getBoundingClientRect(),Q=A.target instanceof Element?A.target:null;S(Oo(X.current,{point:{x:A.clientX-N.left,y:A.clientY-N.top},edgeId:Q?.closest("[data-graview-edge]")?.getAttribute("data-graview-edge")??null}))},K=N=>{A=N,P||(P=requestAnimationFrame(W))},te=()=>{A=null,S(new Set)},C=N=>{let Q=N.target instanceof Element?N.target:null;if(!Q)return;let R=y.getBoundingClientRect(),$=Q.getBoundingClientRect(),b=Q.closest("[data-graview-pick]")?.getAttribute("data-graview-pick")??Q.closest("[data-graview-view]")?.getAttribute("data-graview-view");S(Oo(X.current,{...b?{ids:[b]}:{},box:{x:$.left-R.left,y:$.top-R.top,width:$.width,height:$.height}}))},H=N=>{N.relatedTarget instanceof Node&&y.contains(N.relatedTarget)||S(new Set)};return y.addEventListener("pointermove",K,{passive:!0}),y.addEventListener("pointerleave",te),y.addEventListener("focusin",C),y.addEventListener("focusout",H),()=>{P&&cancelAnimationFrame(P),y.removeEventListener("pointermove",K),y.removeEventListener("pointerleave",te),y.removeEventListener("focusin",C),y.removeEventListener("focusout",H)}},[e,j]),g.length===0?null:(0,xe.jsxs)(xe.Fragment,{children:[(0,xe.jsx)("svg",{"aria-hidden":g.some(y=>y.edgeId)?void 0:!0,"data-graview-ties":g.length,"data-graview-world":"",width:l,height:c,style:{position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:Fe.lines},children:g.map(y=>{let{connector:S,style:P}=Qt(m,y.kind);if(!S.visible)return null;let A=y.edgeId?h?.get(y.edgeId):void 0,W={p0:y.from,c:y.control,p1:y.to},K=y.points?wo(y.points,10):S.route==="orthogonal"?Mt([Ln(y.from,y.to)]):(({p0:C,c:H,p1:N})=>`M ${C.x} ${C.y} Q ${H.x} ${H.y} ${N.x} ${N.y}`)(lr(S.route,W)),te=null;if(y.edgeId&&d&&!y.proxy){let C=(N,Q)=>Q.x>=N.x&&Q.x<=N.x+N.width&&Q.y>=N.y&&Q.y<=N.y+N.height,H=y.points?[...y.points]:[];for(let N=0;N<=(y.points?-1:40);N++){let Q=wa(S.route,W,N/40);C(y.fromBox,Q)||C(y.toBox,Q)||H.push(Q)}H.length>=2&&(te=(0,xe.jsx)("path",{"data-graview-edge":y.edgeId,className:"graview-edge-hit",d:`M ${H[0].x} ${H[0].y} ${H.slice(1).map(N=>`L ${N.x} ${N.y}`).join(" ")}`,fill:"none",pathLength:1,strokeDasharray:"0.86",strokeDashoffset:-.07,stroke:"transparent",strokeWidth:14,style:{pointerEvents:"stroke",cursor:"pointer"},onClick:N=>{N.stopPropagation(),d(y.edgeId,{x:N.clientX,y:N.clientY})},onContextMenu:N=>{N.preventDefault(),N.stopPropagation(),d(y.edgeId,{x:N.clientX,y:N.clientY})},children:A!==void 0?(0,xe.jsx)("title",{children:A}):null}))}return(0,xe.jsxs)("g",{opacity:(y.proxy?.32:.72)*(A!==void 0?kn:1),children:[(0,xe.jsx)("path",{"data-graview-tie":y.kind,"data-graview-tie-proxy":y.proxy||void 0,"data-graview-provisional":A!==void 0||void 0,d:K,fill:"none",stroke:Ut(P),strokeWidth:y.proxy?1.1:1.6,strokeDasharray:A!==void 0?vn:Un[P.pattern],strokeLinecap:"round"}),(0,xe.jsx)("circle",{cx:y.endX,cy:y.endY,r:y.proxy?2:2.6,fill:Ut(P)}),te]},y.key)})}),(0,xe.jsx)("div",{"aria-hidden":"true","data-graview-world":"",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:Fe.tieLabels},children:k.map(y=>{let S=g.find(P=>P.key===y.keys[0]);return(0,xe.jsx)("span",{className:"graview-record-link-said","data-graview-link-said":S?.kind,"data-graview-lands":S?.proxy?"district":"record","data-graview-said-for":y.keys.length,"data-graview-tie-said":y.keys.some(P=>G.has(P))?"shown":"waiting",style:{position:"absolute",left:y.x,top:y.y,transform:`translateX(min(0px, calc(${Math.round(l-y.x-8)}px - 100%)))`},children:y.said},y.said)})})]})}function Ha(){return typeof document>"u"?1:parseFloat(getComputedStyle(document.documentElement).fontSize)/16||1}function Fa({nodes:e,scheme:t,width:n,stageRef:o,moving:r=!1,holding:s=!1}){let i=Ht(),[l,c]=(0,ue.useState)([]);(0,ue.useLayoutEffect)(()=>{r||s||c(d())},[e,r,s,t,n,o]);function d(){let u=[],h=[];for(let g of e){if(!g.via||Math.round(g.plane)!==1)continue;let v=je(o.current,g.id,!1,!0),{scale:k}=Kt(1,t);u.push({key:`${g.via.edgeKind}|${g.via.direction}`,text:En(g.via),left:v?.x??g.x,right:v?v.x+v.width:g.x+g.width*k,top:v?.y??g.y}),h.push(Math.round(g.y))}let m=new Map;u.forEach((g,v)=>m.set(h[v],Math.min(m.get(h[v])??1/0,g.top)));let x=u.map((g,v)=>({...g,top:m.get(h[v])??g.top})),f=pr(n);return qr(x,{left:f.left,right:n-f.right},Ha())}if(l.length===0||!i.captions.visible||r)return null;let a=Xr*Ha();return(0,xe.jsx)("div",{"aria-hidden":"true",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:Fe.lines},children:l.map(u=>{let{left:h,width:m}=u;return(0,xe.jsx)("div",{"data-graview-relation":u.key,title:u.text,style:{position:"absolute",left:h,width:m,textAlign:"center",top:Math.max(0,u.top-a),fontSize:"0.75rem",letterSpacing:"0.09em",textTransform:"uppercase",color:"var(--graview-ink-faint)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(0,xe.jsx)("span",{style:{background:"var(--graview-ground)",padding:"1px 7px",borderRadius:4},children:u.text})},u.key)})})}var jt=re(Re(),1);var pd=new Set;function ja(e,t,n,o,r,s,i=0,l=0){let{store:c,views:d,hiddenKinds:a}=me(),u=It(),h=(0,jt.useContext)(_t),m=Cr(),x=(0,jt.useMemo)(()=>{let v={};for(let k of m){if(k.subjectId===void 0)continue;let w=v[k.subjectId]??=[];for(let O of k.nodeIds)O!==k.subjectId&&!w.includes(O)&&w.push(O)}return v},[m]),f=(0,jt.useMemo)(()=>({flagged:new Set(m.flatMap(v=>v.nodeIds)),touched:Xn(c.log.all())}),[m,c,s]),g=(0,jt.useMemo)(()=>({hits:u?Kn(u):pd,...f}),[u,f]);return(0,jt.useMemo)(()=>({...e,cityZoom:o,...h?{besideTheMap:!0}:{},...a.size>0?{hiddenKinds:[...a].sort()}:{},...Object.keys(x).length>0?{judged:x}:{},relevance:g,inset:{...pr((t?.width??1200)-r.right),top:8,bottom:0},chrome:[{x:(t?.width??1200)-r.right-176,y:0,width:176,height:100},md(t,r)],...r.right>0||r.bottom>0?{dock:r}:{},...i>0?{headroom:i}:{},unit:n,plainGroups:c.schema.kinds.filter(v=>jo(d.lookup(v,{cardinality:"many",fidelity:"full"}))),cityOrder:No(hi({name:"scene",schema:c.schema,mutations:c.allMutations().filter(v=>!v.derived)}).order.map(v=>v.kind),d.arrangement?.()?.order),screens:d.places().reduce((v,k)=>((v[k.kind]??=[]).push({as:k.as,title:k.title,...k.across?{across:k.across}:{}}),v),{}),...t?{width:t.width,height:Math.max(0,t.height-Math.max(64,l))}:{}}),[e,t,n,c,d,a,x,g,o,h,r.right,r.bottom,i,l])}var Wa=224;function md(e,t){let n=e?.width??1200,o=e?.height??800,r=58;return{x:n-t.right-Wa,y:o-t.bottom-r,width:Wa,height:r}}var ht=re(Re(),1);var Va=re(Re(),1);function mr(e){let t=e?.closest?.("[data-graview-pick]")?.getAttribute("data-graview-joins");if(!t)return null;try{let n=JSON.parse(t);return Array.isArray(n)&&n.length>0&&n.every(o=>typeof o=="string")?n:null}catch{return null}}function Ga(e){(0,Va.useEffect)(()=>{let t=e.current;if(!t)return;let n=()=>{for(let s of t.querySelectorAll("[data-graview-pick]"))s.getAttribute("tabindex")===null&&s.setAttribute("tabindex","0"),s.getAttribute("role")===null&&yd(s)&&s.setAttribute("role","button")};if(n(),typeof MutationObserver>"u")return;let o=0,r=new MutationObserver(()=>{o===0&&(o=typeof requestAnimationFrame>"u"?0:requestAnimationFrame(()=>{o=0,n()}),o===0&&n())});return r.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-graview-pick"]}),()=>{r.disconnect(),o!==0&&cancelAnimationFrame(o)}},[e])}var gd=new Set(["div","span","p","figure","img","td","output","b","i","em","strong","small","canvas","g","polygon","circle","rect","path","ellipse","polyline","line","use"]);function yd(e){return gd.has(e.localName.toLowerCase())}var on=re(Me(),1);function za({node:e,useDom:t,blur:n,touched:o,frontY:r,centerY:s,screen:i,onDrawnHeight:l,crowded:c,activity:d,scheme:a,canvasWidth:u,canvasHeight:h,selected:m,onSelect:x,onPick:f,onTravel:g,onMenu:v,selection:k,onJackIn:w,onDragStart:O,onDragMove:G,onDragEnd:D,swallowClick:X,children:j}){let{brand:y,store:S,actsDoor:P}=me(),A=e.beyond?`${e.beyond.length} more district${e.beyond.length===1?"":"s"}`:e.aggregate?.opens?.in==="place"?`${e.aggregate.label}, ${zt(S.schema,e.aggregate.kind,e.aggregate.memberIds.length)}`:e.aggregate?e.aggregate.label:(()=>{let M=S.graph.getNode(e.id);return M?Gt(S.schema.tryDefinition(e.kind),M):e.id})(),[W,K]=(0,ht.useState)(null),te=Math.round(e.plane)===0&&!e.aggregate;(0,ht.useLayoutEffect)(()=>{if(!te)return;let M=R.current;if(!M)return;let B=()=>{let F=[...M.children].find(q=>q.dataset.graviewKindtag===void 0);if(!F)return;let Z=M.getBoundingClientRect(),_=F.getBoundingClientRect(),z=M.offsetWidth>0?Z.width/M.offsetWidth:1,ee={top:Math.round((_.top-Z.top)/z)-9,right:Math.round((Z.right-_.right)/z)+14};K(q=>q&&q.top===ee.top&&q.right===ee.right?q:ee)};if(typeof ResizeObserver>"u"){B();return}let L=new ResizeObserver(B);L.observe(M);for(let F of M.children)L.observe(F);return()=>L.disconnect()},[te,e.id]);let C=_o({plane:e.plane,...e.depth!==void 0?{depth:e.depth}:{},onPlot:r!==void 0},a),H=C.style,N=Yo(H,e.x,e.y,u,h),Q=n?C.blur:0,R=(0,ht.useRef)(null);Ga(R);let $=e.natural,b=$?Math.min(e.width/$.width,e.height/$.height):1,E=(0,ht.useRef)(null);(0,ht.useEffect)(()=>{if(!i||!l)return;let M=E.current;if(!M||typeof ResizeObserver>"u")return;let B=()=>{let z=0,ee=0;for(let q of M.children)if(!(!(q instanceof HTMLElement)||q.classList.contains("graview-screen-fullscreen"))){z=Math.max(z,q.offsetTop+q.offsetHeight);for(let he of[q,...q.querySelectorAll("*")]){let ce=getComputedStyle(he).overflowY;(ce==="auto"||ce==="scroll")&&(ee+=he.scrollHeight-he.clientHeight)}}l(z+ee)},L=0,F=()=>{L||(L=requestAnimationFrame(()=>{L=0,B()}))};B();let Z=new ResizeObserver(F);Z.observe(M);for(let z of M.children)Z.observe(z);let _=new MutationObserver(F);return _.observe(M,{childList:!0,subtree:!0,characterData:!0,attributes:!0}),()=>{L&&cancelAnimationFrame(L),Z.disconnect(),_.disconnect(),l(void 0)}},[i,l,e.id]);let T=t?{transform:ga(N),transformOrigin:"0 0",filter:Q>0?`blur(${Q}px)`:void 0,opacity:Ko(H)*(e.opacity??1),"--graview-lift-low":mo(H.shadow,a),...r!==void 0?{"--graview-front-y":`${r.toFixed(1)}px`}:{},...s!==void 0?{"--graview-center-y":`${s.toFixed(1)}px`}:{}}:{"--graview-lift-low":mo(H.shadow,a)};return(0,on.jsxs)("div",{ref:R,"data-graview-view":e.id,...t?{}:{drawable:""},"data-graview-plane":Math.round(e.plane),"data-graview-selected":m||void 0,"data-graview-touched":o||void 0,"data-graview-plot":r!==void 0?"":void 0,"data-graview-screen":i?"":void 0,"data-graview-record-focus":Math.round(e.plane)===0&&!e.aggregate&&!$&&!i?"":void 0,"data-graview-nested":e.nestedUnder??void 0,"data-graview-crowded":c||void 0,"data-graview-pinned":e.pinned||void 0,"data-graview-activity":d?d.manner:void 0,"data-graview-wrote":d?.wrote||void 0,"data-graview-read":d&&!d.wrote?!0:void 0,"data-graview-broke":d?.broke||void 0,title:d?`${ra[d.manner]} ${d.wrote?"changed this":"read this"}: ${d.intent}`:e.aggregate&&Math.round(e.plane)!==0?`Open ${e.aggregate.label}`:void 0,role:"group","aria-label":A,"aria-keyshortcuts":P&&!e.beyond?P.key:void 0,tabIndex:0,onPointerDown:O,onPointerMove:G,onPointerUp:D,onPointerCancel:D,onClick:M=>{if(X.current)return;let B=M.target?.closest("input, textarea, select, button, a[href], [contenteditable='true']");if(B&&!B.hasAttribute("data-graview-pick"))return;let L=M.metaKey||M.shiftKey,F=xt(M.target);if(F&&F!==e.id){M.stopPropagation(),f(F,L,mr(M.target)??void 0);return}x(L)},onKeyDown:M=>{if(P&&!e.beyond&&M.key.toLowerCase()===P.key.toLowerCase()&&!M.metaKey&&!M.ctrlKey&&!M.altKey&&!M.target?.closest("input, textarea, select, [contenteditable='true']")){M.preventDefault(),M.stopPropagation();let _=xt(M.target)??e.id;k.includes(_)||f(_,!1),P.open(M.target instanceof HTMLElement?M.target:M.currentTarget);return}if(M.key!=="Enter"&&M.key!==" "||M.target?.closest("input, textarea, select, button, [contenteditable='true']"))return;let L=xt(M.target);if(M.preventDefault(),M.stopPropagation(),!L||L===e.id){k.length===1&&k[0]===e.id&&!M.metaKey&&!M.shiftKey?w():x(M.metaKey||M.shiftKey);return}let F=mr(M.target);(F?k.length===F.length&&F.every(_=>k.includes(_)):k.length===1&&k[0]===L)&&!M.metaKey&&!M.shiftKey?g(L):f(L,M.metaKey||M.shiftKey,F??void 0)},onContextMenu:M=>{let B=xt(M.target);M.preventDefault(),M.stopPropagation();let L=B&&B!==e.id?B:e.id;f(L,!1,(L===B?mr(M.target):null)??void 0),v({x:M.clientX,y:M.clientY,on:L})},onDoubleClick:M=>{let B=xt(M.target);if(B&&B!==e.id){M.stopPropagation(),g(B);return}w()},style:{position:"absolute",...t?{}:{pointerEvents:"none"},zIndex:e.opened?Fe.opened:Fe.card-Math.round(e.plane),left:t?0:Math.round(e.x),top:t?0:Math.round(e.y),width:Math.round(e.width),height:Math.round(e.height),boxSizing:"border-box",display:"flex",flexDirection:"column",justifyContent:"center",...T},children:[$?(0,on.jsx)("div",{ref:E,"data-graview-natural":`${Math.round($.width)}x${Math.round($.height)}`,style:{position:"absolute",left:"50%",top:"50%",width:$.width,height:$.height,transform:`translate(-50%, -50%) scale(${b})`,transformOrigin:"50% 50%",display:"flex",flexDirection:"column"},children:j}):j,Math.round(e.plane)===0&&!e.aggregate?(0,on.jsxs)("span",{"data-graview-kindtag":"",className:"graview-kind-tag","aria-hidden":"true",style:{...W??{},"--graview-hue":Math.round(gn(e.kind,y?.accents))},children:[(0,on.jsx)("span",{style:{width:9,height:6,clipPath:"polygon(50% 0, 100% 50%, 50% 100%, 0 50%)",flex:"0 0 auto",background:`hsl(${Math.round(gn(e.kind,y?.accents))} 55% var(--graview-tint-lightness) / 0.9)`}}),To(S.schema.tryDefinition(e.kind),e.kind)]}):null]})}var le=re(Me(),1);Tr({search:pi,touchWeights:Xn});var wd=e=>e?{activity:e}:{},xd=e=>`${Math.round(e.x)} ${Math.round(e.y)}`,Ya=e=>e.stopPropagation(),Xa=.6,qa=3,bd=80,_a=e=>Math.round(e.plane)===1&&(e.compact===!0||e.width<175||e.height<bd);function vd(e){let[t,n]=(0,U.useState)(1),o=(0,U.useRef)(1);return(0,U.useEffect)(()=>{e||(o.current=1,n(1))},[e]),[t,o,n]}function kd(e){let[t,n]=(0,U.useState)({x:0,y:0}),o=(0,U.useMemo)(()=>({x:(e.pan?.x??0)+t.x,y:(e.pan?.y??0)+t.y}),[e.pan,t]),r=(0,U.useMemo)(()=>t.x===0&&t.y===0?e:ut(e,o),[e,t,o]),s=(0,U.useRef)(t);s.current=t;let i=(0,U.useCallback)((l,c)=>{let d=s.current,a=(u,h,m)=>Math.max(Math.min(-u,h),Math.min(Math.max(u,h),m+h))-h;return{x:a(l.x,d.x,c.x),y:a(l.y,d.y,c.y)}},[]);return[o,r,i,s,n]}function Sd(e,t,n,o,r,s){let i=n!==null&&!t.overview,l=i?null:n,c=(0,U.useRef)(t);zr(c.current,t)||(c.current=t);let d=c.current,a=(0,U.useMemo)(()=>{let x=d.pan?{...d,pan:void 0}:d;return l?Sn(x,l.id,{x:l.x,y:l.y}):x},[d,l]),u=(0,U.useMemo)(()=>nr(e.graph,e.schema,a,o),[e,a,o,r]),h=(0,U.useMemo)(()=>n&&i?no(u,n.id,{x:n.x,y:n.y})??nr(e.graph,e.schema,Sn(a,n.id,{x:n.x,y:n.y}),o):u,[u,n,i,e,a,o]);return[(0,U.useMemo)(()=>ro(h,s??{x:0,y:0}),[h,s]),i]}function Md(e,t){let n=(0,U.useRef)(!1),o=(0,U.useRef)(!1),r=(0,U.useRef)(null),s=(0,U.useRef)(!1),i=(0,U.useCallback)(()=>{Ed(e.current,{dragging:n.current,steering:o.current}),t.set(n.current||o.current||s.current)},[e,t]),l=(0,U.useCallback)(u=>{n.current!==u&&(n.current=u,i())},[i]),c=(0,U.useRef)(()=>!1),d=(0,U.useCallback)(()=>{o.current||(o.current=!0,i()),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{r.current=null,!c.current()&&(o.current=!1,i())},160)},[i]),a=(0,U.useCallback)(()=>{n.current=!1,o.current=!1,i()},[i]);return{dragging:n,steering:o,tweening:s,setDragging:l,steer:d,settleLive:c,settled:a}}function Ed(e,{dragging:t,steering:n}){e&&(t||n?e.setAttribute("data-graview-hand",t?"drag":"wheel"):e.removeAttribute("data-graview-hand"),e.style.cursor=t?"grabbing":"grab",e.style.userSelect=t?"none":"")}function Rd(e){let t=(0,U.useRef)(!1),n=e!==null&&!t.current;return(0,U.useEffect)(()=>{e!==null&&(t.current=!0)},[e]),n}function Od({registerScene:e,scheme:t,views:n},o,r){let s=(0,U.useRef)(o);s.current=o,(0,U.useEffect)(()=>(e({whereIs:i=>dr(s.current,r.current,t,n,i)}),()=>e(null)),[e,t,n])}function Ad(e,t){(0,U.useEffect)(()=>{let n;return e.onActive(o=>{let r=t.current;if(!r)return;let s=c=>{let d=r.getBoundingClientRect();e.set({x:c.clientX-d.left,y:c.clientY-d.top})},i=c=>{c.buttons===0&&s(c)},l=()=>e.set(null);o?(r.addEventListener("pointermove",i),r.addEventListener("pointerup",s),r.addEventListener("pointerleave",l),n=()=>{r.removeEventListener("pointermove",i),r.removeEventListener("pointerup",s),r.removeEventListener("pointerleave",l)}):(n?.(),n=void 0)})},[e])}function Pd(e,t,n,o,r,s,i,l){(0,U.useEffect)(()=>{let c=t.current;if(!c||!e)return;let d=new Set;for(let u of n.nodes)(o.has(u.id)||u.aggregate?.memberIds.some(h=>o.has(h)))&&d.add(u.id);let a=e({canvas:c,layout:n,dirty:d,hostOf:u=>(c.parentElement??c).querySelector(`[data-graview-view="${CSS.escape(u)}"]`),drawOnDom:r,blur:s,scheme:i,fallBack:l});return()=>{a?.()}},[e,n,o,r,s,i,l])}var Ld=Yt(()=>(__graviewPreload(import.meta.url,["./chunk.OJGHDWI6.js","./chunk.DZZL5IDD.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.DNVWSWL2.js")));function Td(e,t){let[n]=(0,U.useState)(()=>{let a=Xo();return t?e==="dom"||e==="auto"&&a==="dom"?"dom":"gpu":Qo(e,{operator:a,present:qo()})}),[o,r]=(0,U.useState)(!1),s=(0,U.useCallback)(()=>r(!0),[]),[i,l]=(0,U.useState)(null),c=n==="gpu"&&!t&&!o&&i===null;return(0,U.useEffect)(()=>{if(!c)return;let a=!0;return Ld().then(u=>{a&&l(()=>u.attachGpu())},()=>{a&&r(!0)}),()=>{a=!1}},[c]),{attach:(n==="gpu"&&!o?t??i:null)??null,fallBack:s}}function Cd(){let[e,t]=(0,U.useState)(()=>new Set),n=(0,U.useCallback)(o=>{t(r=>r.size===o.size&&[...o].every(s=>r.has(s))?r:new Set(o))},[]);return[e,n]}function Id(){let e=ri();return t=>{let n=t?e.get(t.id):void 0,o=t?.aggregate?.memberIds??[];if(!n&&o.length===0)return;let r=n,s=n?.wrote??!1,i=n?.read??!1,l=n?.broke??!1;for(let c of o){let d=e.get(c);d&&(s||=d.wrote,i||=d.read,l||=d.broke,(!r||d.at>r.at||d.at===r.at&&d.wrote&&!r.wrote)&&(r=d))}return r?{...r,wrote:s,read:i,broke:l}:void 0}}var Ka=(e,t)=>e.includes(t)?e.filter(n=>n!==t):[...e,t];function Nd(){let{views:e,view:t,setView:n,setSelection:o}=me(),r=It(),s=(0,U.useContext)(_t),i=l=>{if(Le(l.id)===null&&!l.aggregate)return!1;let c=e.resolve(l.kind,{cardinality:"many",fidelity:"full"})?.view;return c!==void 0&&c.generic!==!0};return l=>({onSelect:c=>{if(xn(l.id)){o(a=>c?Ka(a,l.id):[l.id]);return}let d=l.aggregate?wn(l.id):[];if(t.overview){o(a=>c?[...new Set([...a,l.id])]:[l.id]);return}if(d.length===1&&!c&&Math.round(l.plane)!==0){let a=d[0];n(u=>Rr(u,u.relation===a?null:a));return}o(a=>po(l,a,c))},onPick:(c,d,a)=>o(u=>a?d?[...new Set([...u,...a])]:[...a]:d?Ka(u,c):[c]),onTravel:c=>{n(d=>({...yt(d,c),relation:null})),o([c])},onJackIn:()=>{let c=l.aggregate?.opens;if(c){c.in==="place"?n(u=>Or(u,l.id)):n(u=>Object.entries(c.within).reduce((h,[m,x])=>Yn(h,m,x),yt(yn(u,!1),c.focus))),o([]);return}let d=Le(l.id),a=d!==null&&(r?.byKind[d]??0)>0;if(s&&d!==null&&t.overview&&!i(l)&&!(a&&t.q)){n(u=>Yn({...yt(u,`aggregate:${d}`),relation:null},"view",null)),o([]);return}n(u=>Ar(u,l.id,{ownPicture:i(l),...a&&u.q?{carry:u.q}:{}})),o(l.aggregate?[]:[l.id])}})}var Bd=bn(Yt(()=>(__graviewPreload(import.meta.url,["./chunk.HJCQ6I3S.js","./chunk.22BZU7ME.js","./chunk.TKUNRFDE.js","./chunk.2N4Z5K5S.js","./chunk.NUYA4BWI.js","./chunk.OKZT2QBM.js","./chunk.ACTXR2MI.js","./chunk.M7RESZB6.js","./chunk.SDO3U72B.js","./chunk.DZZL5IDD.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.CHHYIMB7.js")))),Hd=Bd.part((e,t)=>(0,le.jsx)(e.Ribbons,{...t}),{what:"The relations",quiet:!0}),Ua="graview:map-from-above";function Dd(){let[e,t]=(0,U.useState)(()=>{try{return globalThis.localStorage?.getItem(Ua)==="1"}catch{return!1}}),n=(0,U.useCallback)(o=>{t(o);try{globalThis.localStorage?.setItem(Ua,o?"1":"0")}catch{}},[]);return[e,n]}var $d=bn(Yt(()=>(__graviewPreload(import.meta.url,["./chunk.TKUNRFDE.js","./chunk.2N4Z5K5S.js","./chunk.DDUCIUVW.js","./chunk.M7RESZB6.js","./chunk.SDO3U72B.js","./chunk.DZZL5IDD.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.J7Q2WAF4.js")))),Fd=$d.part((e,t)=>(0,le.jsx)(e.Plots,{...t}),{quiet:!0});function Wd({zoom:e,zoomBy:t,above:n,setAbove:o}){let r=(s,i,l,c)=>(0,le.jsx)("button",{type:"button",className:"graview-zoom-button","data-testid":`zoom-${s}`,"aria-label":`Zoom ${s}`,title:`Zoom ${s} \u2014 or pinch, or ctrl+wheel`,disabled:c,onClick:()=>t(l),children:i});return(0,le.jsxs)("div",{className:"graview-zoom","data-graview-foot":"",role:"group","aria-label":"Zoom",onPointerDown:Ya,onClick:Ya,children:[r("out","\u2212",1/1.25,e<=Xa+1e-6),(0,le.jsxs)("span",{className:"graview-zoom-level","data-testid":"zoom-level","aria-live":"polite",children:[Math.round(e*100),"%"]}),r("in","+",1.25,e>=qa-1e-6),(0,le.jsx)("button",{type:"button",className:"graview-zoom-button graview-zoom-above","data-testid":"from-above","aria-pressed":n,title:n?"See the city at an angle again":"See the city from straight above",onClick:()=>o(!n),children:"From above"})]})}function jd({options:e,renderer:t="auto",attachRenderer:n,blur:o=!0,className:r,style:s,animate:i=!0,children:l}){let c=me(),{store:d,scheme:a,views:u,view:h,setView:m,selection:x,setSelection:f,setMenuAt:g,emphasis:v,brand:k,noteMoved:w,robots:O,motion:G}=c,D=(0,U.useContext)(_t),X=(0,U.useRef)(null),j=(0,U.useRef)(null),y=ma(j),S=pa(),{zoomAbout:P,panBy:A}=na({stage:j,view:h,setView:m}),W=Nt(),K=1,[te,C,H]=vd(h.overview),[N,Q]=Dd(),R=(0,U.useMemo)(()=>N?{...e,tilt:gi}:e,[e,N]),{probe:$,dock:b}=Zi(),E=!h.overview&&(h.zoom||h.past||h.relation)?Math.ceil(14+34*S/16+6):0,T=ja(R,y,S,K*te,b,W,E,h.overview?0:b.bottom),M=Ki(j),[B,L,F,Z,_]=kd(h),z=(0,U.useMemo)(()=>new Set(Object.keys(h.pins).filter(I=>Le(I)===null)),[h.pins]),ee=Ji(),[q,he]=Sd(d,h,ee.held,T,W,L.pan),ce=Md(j,G),{setDragging:He,steer:Ee,settleLive:Ae,settled:De}=ce,Ce=ce.dragging.current||ce.steering.current,ie=Rd(y),ve=ea({stage:j,pan:h.pan,setView:m,settled:De}),Ze=(0,U.useRef)(!1);ve.settling.current||(Ze.current=!1);let Et=ve.settling.current&&!Ze.current,ne=Fi(q,{enabled:i&&!Ce&&y!==null&&!ie,settle:!Et});ce.tweening.current=ne.t<1,(0,U.useEffect)(()=>G.set(ce.dragging.current||ce.steering.current||ne.t<1),[G,ne]);let rt=Wi(),$e=ji(),Rt=Ui({view:h,result:q,frame:ne,panned:B,closer:K,screenId:null,setCamera:_});Od(c,ne,j),Ad(c.pointer,j);let[Ve,Ot]=Cd(),{attach:Ue,fallBack:Je}=Td(t,n),Pe=Di(o);Pd(Ue,X,ne,rt,Ot,Pe,a,Je);let Ie=Ue===null,ft=$i(Pe&&Ie,ne.t<1),Xe=Id();Ae.current=ve.settle;let{onGroundDown:pt,onCardDown:an,onDragMove:dt,onDragUp:ae,swallow:ye}=ta({view:h,panned:B,limit:()=>bt(q),panWithin:F,moveByTransform:!0,setView:m,setDragging:He,noteMoved:w,shift:ve,district:ee}),Ge=Bi({swallow:ye,setMenuAt:g,setSelection:f});P.current=(I,fe,we)=>{if(!h.overview)return;Ae.current();let be=C.current,ot=Math.max(Xa,Math.min(qa,be*I));if(Math.abs(ot-be)<1e-4)return;C.current=ot,Ze.current=!0,Ee(),H(ot);let hn=j.current?.getBoundingClientRect(),ze=q.visible??q,fn={x:ze.width/2,y:ze.height/2},Bn=hn&&fe!==void 0&&we!==void 0?{x:fe-hn.left,y:we-hn.top}:fn,pn=ot/be;m(Hn=>ut(Hn,eo(Hn.pan??{x:0,y:0},Z.current,Bn,fn,pn))),w()};let mt=(I,fe,we=bt(q))=>m(be=>ut(be,F(we,{x:(be.pan?.x??0)+I,y:(be.pan?.y??0)+fe})));qi(j,b,(I,fe)=>mt(I,fe)),A.current=(I,fe)=>{Ee();let we=bt(q),be=h.pan??{x:0,y:0},ot=ve.offset();ve.shiftTo(F(we,{x:be.x+ot.x+I,y:be.y+ot.y+fe}),be),w()};let qe=Nd(),At=Ht(),sn=(0,U.useCallback)(I=>Qt(At,I).connector.visible,[At]),dn=I=>Xe(ne.nodes.find(fe=>fe.id===I)),ln=(I,fe,we,be)=>I.originY+B.y+Zt(we.col+we.side/be,we.row+we.side/be,I.cell,I.tilt).y-fe.y,Ne={width:q.width,height:q.height},cn={position:"relative",zIndex:Fe.stage,...Ne},un=I=>dr(ne,j.current,a,u,I),gr=I=>Ie||Ve.has(I),Nn=Qn(c),Vt=I=>(0,le.jsx)(_n.Provider,{value:Nn,children:I}),Pt=ne.nodes.filter(I=>I.screenOf===void 0).map(I=>(0,le.jsx)(za,{node:I,crowded:_a(I),useDom:gr(I.id),blur:ft||!Ie&&Pe,...I.plot&&ne.city&&Math.round(I.plane)===2?{frontY:ln(ne.city,I,I.plot,1),centerY:ln(ne.city,I,I.plot,2)}:{},touched:rt.has(I.id),...wd(Xe(I)),scheme:a,canvasWidth:q.width,canvasHeight:q.height,selected:x.includes(I.id),...qe(I),onMenu:g,selection:x,onDragStart:fe=>an(I,fe),onDragMove:dt,onDragEnd:ae,swallowClick:ye,children:I.beyond?(0,le.jsx)(la,{kinds:I.beyond}):I.aggregate?.opens?(0,le.jsx)(fa,{node:I}):(0,le.jsx)(ua,{node:I,mode:"scene",selected:x.includes(I.id),..._a(I)?{fidelity:"glyph"}:{}})},I.id));return(0,le.jsxs)("div",{ref:j,className:`graview-ground${r?` ${r}`:""}`,"data-graview-altitude":h.overview?"":void 0,"data-graview-reach":ne.city?xd(bt(q)):void 0,"data-graview-settled":ne.t>=1&&!Rt.gliding()?"":void 0,"data-graview-box":y?`${y.width}x${y.height}`:void 0,"data-graview-renderer":Ie?"dom":"gpu","data-graview-blur":(Ie?ft:Pe)?"":void 0,onPointerDown:I=>{Ge.onPointerDown(I),pt(I)},onPointerMove:I=>{Ge.onPointerMove(I),dt(I)},onPointerUp:()=>{Ge.onPointerUp(),ae()},onPointerCancel:()=>{Ge.onPointerUp(),ae()},onContextMenu:Ge.onContextMenu,onClick:I=>{ye.current||I.target.closest("[data-graview-view], button, aside, section[aria-label], [data-graview-offstage], a, input, select")||(f([]),g(null))},style:{position:"relative",width:"100%",height:"100%",cursor:"grab",touchAction:"none","--graview-altitude":h.overview?1:0,...ne.city?{"--graview-lattice-cell":`${ne.city.cell.toFixed(2)}px`,"--graview-lattice-tilt":(ne.city.tilt??.5).toFixed(3),"--graview-lattice-x":`${(ne.city.originX+ne.city.pan.x).toFixed(1)}px`,"--graview-lattice-y":`${(ne.city.originY+ne.city.pan.y).toFixed(1)}px`}:{},overflow:"hidden",...s},children:[(0,le.jsx)("div",{className:"graview-measure","aria-hidden":"true",style:{"--graview-world-x":`${(ne.pan?.x??0).toFixed(1)}px`,"--graview-world-y":`${(ne.pan?.y??0).toFixed(1)}px`}}),h.overview&&ne.city?(0,le.jsx)(U.Suspense,{fallback:null,children:(0,le.jsx)(Hd,{frame:ne,...Ne,pan:ne.city.pan,store:d,graphVersion:W,selection:x,view:{overview:h.overview,focusId:h.focusId,beside:D},emphasis:v,hiddenKinds:c.hiddenKinds,drawn:sn})}):null,(0,le.jsx)("div",{ref:$,"aria-hidden":"true",style:{position:"absolute",top:0,right:0,width:"var(--graview-dock, 0px)",height:"var(--graview-sheet, 0px)",visibility:"hidden",pointerEvents:"none"}}),ne.city?(0,le.jsx)(U.Suspense,{fallback:null,children:(0,le.jsx)(Fd,{frame:ne,...Ne,pan:ne.city?ne.city.pan:B,brand:k,pinned:z,close:K*te>1.2,swallowed:ye,...h.overview?{chosen:Mn(x,{overview:h.overview,focusId:h.focusId,beside:D},I=>d.graph.getNode(I)?.kind).records}:{},onFocus:I=>{let fe=Le(I);fe!==null&&m(we=>yt(we,Te(fe)))}})}):null,Ie?(0,le.jsx)("div",{"data-graview-stage":"dom","data-graview-world":"",style:{...cn,overflow:"hidden"},children:Vt(Pt)}):(0,le.jsxs)("div",{"data-graview-world":"",style:cn,children:[(0,le.jsx)("div",{"data-graview-stage":"dom","data-graview-under-canvas":"",style:{position:"absolute",left:0,top:0,...Ne,overflow:"hidden"},children:Vt(Pt.filter(I=>Ve.has(String(I.key))))}),(0,le.jsx)("canvas",{ref:X,"data-graview-stage":"gpu",content:"drawable",layoutsubtree:"",...Ne,style:{display:"block",position:"relative",...Ne},children:Vt(Pt.filter(I=>!Ve.has(String(I.key))))})]}),h.overview?(0,le.jsx)(Yi,{result:q,schema:d.schema,chrome:M?[...T.chrome??[],M]:T.chrome??[],onGo:I=>{mt(I.x,I.y),w()}}):null,h.overview?(0,le.jsx)(Wd,{zoom:te,zoomBy:I=>P.current(I),above:N,setAbove:Q}):null,(0,le.jsx)($a,{frame:ne,focusId:h.focusId,beside:D,holding:he,...Ne,scheme:a,overview:!!h.overview,selection:x,emphasis:v,stageRef:j,store:d,graphNodes:W,...(I=>I?{provisional:I}:{})(Da(d)),onPickEdge:(I,fe)=>{ye.current||(f([I]),g(fe?{...fe,on:I}:null))},liveOf:I=>{let fe=dn(I.from),we=dn(I.to);return fe?.wrote&&we?.wrote?fe.at>we.at?fe:we:void 0}}),(0,le.jsx)(Gi,{width:q.width,whereIs:un}),(0,le.jsx)(Vi,{marks:$e.marks,questions:[...O.values()].filter(I=>I.mode==="asking"&&I.at!==null&&I.say).map(I=>({id:I.at,who:I.who,asks:I.say})),whereIs:un,stageRef:j,...Ne}),(0,le.jsx)(Fa,{nodes:ne.nodes,moving:ne.t<1,holding:he,scheme:a,width:q.width,stageRef:j}),l,(0,le.jsx)("div",{className:"graview-lattice","aria-hidden":"true"})]})}var nt=re(Re(),1);function Vd(){return es(),null}var Ja=()=>window.location.pathname.endsWith(Io),Qa=()=>(Ja()?Ho:Er)(window.location.hash),Gd=e=>(Ja()?Do:Mr)(e);function es(){let{view:e,setView:t,views:n,principal:o}=me(),r=JSON.stringify(o),s=(0,nt.useCallback)(a=>{let u=a.within?.view;if(u===void 0||a.focusId)return a;let h=n.places().find(m=>m.as===u);return h?{...a,focusId:Te(h.kind)}:a},[n]),i=(0,nt.useRef)(!1);(0,nt.useEffect)(()=>{if(typeof window>"u")return;let a=s(Qa());!zn(a,Sr)&&!zn(a,e)&&(i.current=!0,t(a))},[]),(0,nt.useEffect)(()=>{if(typeof window>"u")return;let a=()=>t(s(Qa()));return window.addEventListener("popstate",a),window.addEventListener("hashchange",a),()=>{window.removeEventListener("popstate",a),window.removeEventListener("hashchange",a)}},[t,s]);let l=(0,nt.useRef)(!1),c=(0,nt.useRef)(null),d=(0,nt.useRef)(r);(0,nt.useEffect)(()=>{if(typeof window>"u")return;if(i.current){i.current=!1;return}let a=d.current!==r;d.current=r;let u=Gd(e),h=u||`${window.location.pathname}${window.location.search}`;if((window.location.hash||(window.location.href.includes("#")?"#":""))===u){l.current=!0,c.current=e;return}if(!l.current){l.current=!0,c.current=e,window.history.replaceState({graview:Bt.at},"",h);return}if(a||ts(c.current,e)){window.history.replaceState({graview:Bt.at},"",h),c.current=e;return}c.current=e,window.history.pushState({graview:++Bt.at},"",h),Bt.depth=Bt.at,Bt.tell()},[e,r])}function ts(e,t){return e?e.focusId===t.focusId&&e.relation===t.relation&&(e.overview??!1)===(t.overview??!1)&&(e.zoom??!1)===(t.zoom??!1)&&(e.past??!1)===(t.past??!1)&&e.expanded.join(",")===t.expanded.join(",")&&(e.shown??[]).join(",")===(t.shown??[]).join(",")&&zd(e.within,t.within):!1}function zd(e,t){let n=o=>Object.entries(o??{}).sort(([r],[s])=>r.localeCompare(s)).map(([r,s])=>`${r}=${s}`).join("&");return n(Za(e))===n(Za(t))}function Za(e){if(!e||!("q"in e))return e;let{q:t,...n}=e;return n}var Ao=re(Re(),1);var ns=new WeakMap,Yd=64,rs=new WeakMap,_d=0,Kd=e=>{if(e===void 0)return 0;let t=rs.get(e);return t===void 0&&rs.set(e,t=_d+=1),t};function os(e,t,n,o={}){let r=()=>{let d=[...new Set(t.flatMap(u=>wn(u)))],a=t.map(u=>Tt(u)).filter(u=>u!==null);return li(e,t,{...n.principal?{principal:n.principal}:{},kindSelection:d,edgeSelection:a,...n.providers?{providers:n.providers}:{},...n.pins?{pins:n.pins}:{},...n.focus!==void 0?{focus:n.focus}:{},...o})};if(Object.keys(o).length>0)return r();let s=ns.get(e);if(!s){let d={kept:new Map,at:e.log.length};ns.set(e,s=d),e.subscribe(()=>d.kept.clear())}s.at!==e.log.length&&(s.kept.clear(),s.at=e.log.length);let i=JSON.stringify([t,n.principal??null,Kd(n.providers),n.pins??null,n.focus??null]),l=s.kept.get(i);if(l)return l;let c=r();return s.kept.set(i,c),s.kept.size>Yd&&s.kept.delete(s.kept.keys().next().value),c}function Ud(e,t,n={}){return os(e,t,n)}function Xd(e={}){let{store:t,selection:n,principal:o,providers:r}=me(),{about:s,principal:i=o,providers:l=r,pins:c,focus:d,...a}=e,u=s??n,h=Nt();return(0,Ao.useMemo)(()=>os(t,u,{principal:i,providers:l,pins:c,focus:d},a),[t,u,e,h,i,l])}function qd(){let{store:e,principal:t}=me();return(0,Ao.useMemo)(()=>({preview:(n,o)=>ui(e,n,o??{},{pressed:t?{author:t}:{}}),apply:(n,o)=>ci(e,n,o??{},{author:t})}),[e,t])}export{ks as a,Ss as b,Ms as c,Es as d,Rs as e,Os as f,hs as g,jd as h,Vd as i,Ud as j,Xd as k,qd as l};
@@ -0,0 +1,6 @@
1
+ import{a as k}from"./chunk.G4JJXA63.js";import{a as Q}from"./chunk.H5S7OL2U.js";import{a as Z}from"./chunk.T6WHGKWR.js";import{a as Y}from"./chunk.ZN3PUM2I.js";import{c as V}from"./chunk.OWT3VVOT.js";import{Sd as P,Ud as H,Vd as T,Wd as U,vb as z,wb as B}from"./chunk.DZZL5IDD.js";var N=n=>"failed"in n;function fn(n,e){let s=n.schema.kinds,t=n.policy?.sees;if(!t?.length||B(e))return{kinds:s};let o=z(e).roles??[],r=new Set(t.filter(i=>i.roles==="*"||o.some(a=>i.roles.includes(a))).flatMap(i=>i.kinds));return{kinds:s.filter(i=>r.has(i))}}function O(n,e){if(!e)return n;let s=new Set(e.kinds.filter(r=>n.tryDefinition(r)!==void 0));if(s.size===n.kinds.length)return n;let t=new Map,o=r=>{if(s.has(r)){if(!t.has(r)){let i=n.tryDefinition(r),a=Object.fromEntries(Object.entries(i?.edges??{}).flatMap(([l,d])=>{if(d.to==="*")return[[l,d]];let c=d.to.filter(u=>s.has(u));return c.length>0?[[l,{...d,to:c}]]:[]}));t.set(r,{...i,edges:a})}return t.get(r)}};return{...n,definitions:n.definitions.filter(r=>s.has(r.kind)),kinds:n.kinds.filter(r=>s.has(r)),tryDefinition:o,definition:r=>{let i=o(r);if(!i)throw new Error(`Unknown node kind "${r}"`);return i}}}var gn=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),m=n=>gn(n).replace(/[-_]+/g," ").trim();function j(n){let e=[];for(let t of n.kinds){let o=n.tryDefinition(t);if(!o)continue;let r=o.display?.labels??{},i=Object.entries(o.fields?.shape??{}).filter(([d])=>d!=="id"&&d!=="kind").map(([d,c])=>{let u=Y(c);return{name:d,type:u?.type==="enum"&&u.multiple?"list":u?.type,...u?.options?{options:u.options}:{},words:(r[d]??m(d)).toLowerCase()}}),a=Object.entries(o.edges??{}).map(([d,c])=>({name:d,from:t,to:c.to==="*"?n.kinds.filter(u=>u!==t):c.to,words:m(d)})),l=(o.plural??`${m(t)}s`).toLowerCase();e.push({kind:t,plural:l,noun:(o.noun??m(t)).toLowerCase(),fields:i,roles:o.fieldRoles??{},edges:a})}let s=new Map(e.map(t=>[t.kind,t]));return{schema:n,kinds:e,info:t=>s.get(t)}}var $=(n,e)=>e===void 0?void 0:n.fields.find(s=>s.name===e),R=n=>n?.type==="date"||n?.type==="datetime",K=n=>n?.type==="number"||n?.type==="integer"||n?.type==="duration",sn=n=>` ${n.toLowerCase().replace(/[“”"’‘]/g,"'").replace(/[^\p{L}\p{N}' -]+/gu," ").replace(/\s+/g," ").trim()} `,A=(n,e)=>n.includes(` ${e} `),L=n=>n.endsWith("ies")?`${n.slice(0,-3)}y`:n.endsWith("ses")?n.slice(0,-2):n.endsWith("s")?n.slice(0,-1):n;function yn(n,e){let s=[];for(let t of e.kinds){let o=new Set([t.plural,t.noun,`${t.noun}s`,m(t.kind),`${m(t.kind)}s`]),r=-1;for(let i of o){let a=n.indexOf(` ${i} `);a>=0&&(r<0||a<r)&&(r=a)}r>=0&&s.push({info:t,at:r})}return s.sort((t,o)=>t.at-o.at).map(t=>t.info)}function I(n,e,s){let t=e.trim().toLowerCase();if(t.length===0)return;let o=n.fields.filter(r=>!s||s(r));return o.find(r=>r.words===t||m(r.name)===t||r.name.toLowerCase()===t)??o.find(r=>r.words===L(t)||m(r.name)===L(t))??o.find(r=>t.split(" ").some(i=>i.length>2&&(r.words.split(" ").includes(i)||r.words.split(" ").includes(L(i)))))}function rn(n,e,s){let t=e.trim().toLowerCase();if(t.length!==0)return n.edges.find(o=>o.words===t||o.name.toLowerCase()===t)??n.edges.find(o=>o.to.some(r=>{let i=s.info(r);return i!==void 0&&(i.noun===L(t)||i.plural===t||m(r)===L(t))}))??n.edges.find(o=>t.split(" ").some(r=>r.length>2&&o.words.split(" ").includes(r)))}function W(n){return/ (?:grouped |group |split |sorted |organi[sz]ed )?by ([\p{L}\p{N}' -]+?)(?= (?:and|with|for|in|on|only|where|from|this|that|as|sorted|grouped) |\s*$)/u.exec(n)?.[1]?.trim()}var bn=/\bwho\b.*\b(covers?|cover|tends?|owns?|handles?|does|works? on|looks? after|is on|is assigned|staffs?|runs?)\b|\bcoverage\b|\bmatrix\b|\bwho covers\b/,mn=/\bcalendar\b|\bmonth\b|\bagenda\b|\bschedule\b|\bdue\b|\bdeadlines?\b|\bdates?\b|\bwhen\b/,hn=/\btimeline\b|\bover time\b|\bgantt\b|\bspans?\b|\bweek\b/,pn=/\bboard\b|\bkanban\b|\bcolumns?\b|\bpipeline\b|\bstages?\b|\bstatus\b/,wn=/\blaid out\b|\blayout\b|\bseating\b|\bwhere (?:they|it|each) (?:sits?|lies?|stands?)\b|\bfloor\b/,kn=/\bplan\b|\bmap\b|\bregions?\b/,$n=/\blist\b|\btable\b|\bgroup(?:ed)? by\b|\bsort(?:ed)? by\b|\bonly\b|\bjust the\b/;function Sn(n){let e=[];return/\blist\b|\btable\b/.test(n)&&e.push("blocks"),bn.test(n)&&e.push("coverage"),wn.test(n)&&e.push("board"),(/\bfloor plan\b/.test(n)||kn.test(n))&&e.push("plan"),hn.test(n)&&e.push("timeline"),mn.test(n)&&e.push("calendar"),pn.test(n)&&e.push("columns"),$n.test(n)&&!e.includes("blocks")&&e.push("blocks"),e.length===0&&W(n)&&e.push("columns"),e}var on=n=>{let e=s=>s?` and not ${s}`:"";if(/\boverdue\b|\blate\b|\bpast due\b/.test(n))return{cond:(s,t)=>`days(today(), ${s}) < 0${e(t)}`,says:s=>`overdue by ${s.words}`};if(/\btoday\b/.test(n))return{range:"day",cond:s=>`days(today(), ${s}) == 0`,says:s=>`with ${s.words} today`};if(/\bthis week\b|\bnext 7 days\b|\bnext week\b/.test(n))return{range:"week",cond:s=>`days(today(), ${s}) >= 0 and days(today(), ${s}) <= 6`,says:s=>`with ${s.words} in the next week`};if(/\bthis month\b|\bnext 30 days\b|\bnext month\b/.test(n))return{range:"month",cond:s=>`days(today(), ${s}) >= 0 and days(today(), ${s}) <= 30`,says:s=>`with ${s.words} in the next month`};if(/\blast month\b|\bpast month\b/.test(n))return{range:"month",cond:s=>`days(today(), ${s}) >= -30 and days(today(), ${s}) <= 0`,says:s=>`with ${s.words} in the last month`};if(/\bthis year\b/.test(n))return{range:"year",cond:s=>`days(today(), ${s}) >= 0 and days(today(), ${s}) <= 365`,says:s=>`with ${s.words} in the next year`};if(/\bquarter\b/.test(n))return{range:"quarter",cond:s=>`days(today(), ${s}) >= 0 and days(today(), ${s}) <= 91`,says:s=>`with ${s.words} in the next quarter`}},_=n=>{if(/\bagenda\b|\bin order\b/.test(n))return"agenda";if(/\btoday\b|\bday\b/.test(n))return"day";if(/\bweek\b/.test(n))return"week";if(/\bquarter\b/.test(n))return"quarter";if(/\byears\b/.test(n))return"years";if(/\byear\b/.test(n))return"year";if(/\bmonth\b/.test(n))return"month"},X=/^(user|person|people|member|staff|gardener|volunteer|owner|agent|employee|worker|team|player|customer|client|contact|party|attendee|guest)s?$/,x=class extends Error{},h=n=>{throw new x(n)};function Dn(n,e){let s=n.fields.filter(r=>r.type==="enum");if(e){let r=I(n,e);if(r&&r.type==="enum")return r;r&&h(`${n.plural}' ${r.words} is not a choice, so it has no columns`)}let t=$(n,n.roles.status??n.roles.column);if(t?.type==="enum")return t;let o=s.find(r=>/^(status|stage|state|phase)$/.test(r.name));return o||(s[0]?s[0]:h(`${n.plural} have no choice field to put in columns`))}function nn(n,e){let s=n.fields.filter(R),t=l=>{let d=$(n,n.roles[l]);return R(d)?d:void 0},r=s.find(l=>A(e,l.words)||A(e,m(l.name)))??t("start")??s.find(l=>/^(due|date|on|at|start|starts|begins|from|sown|when)/i.test(l.name))??s[0];if(!r)return h(`no date field on ${n.plural}`);let i=t("end")??s.find(l=>l!==r&&/^(end|ends|until|to|finish|finished|harvested|due|closes|through)/i.test(l.name)),a=n.fields.find(l=>l.type==="boolean"&&/^(done|finished|complete|completed|closed)$/.test(l.name));return{start:r,...i&&i!==r?{end:i}:{},...a?{done:a}:{}}}function an(n){let e=$(n,n.roles.start),s=$(n,n.roles.end),t=$(n,n.roles.column??n.roles.day??n.roles.columns);if(K(e)&&K(s)&&t?.type==="enum")return{start:e,end:s,column:t}}function vn(n,e,s,t){let o=[];for(let i of n.kinds)for(let a of i.edges)for(let l of a.to){let d=n.info(l);if(!d||d.kind===i.kind)continue;let c=0;e.includes(i)&&(c+=4),e.includes(d)&&(c+=4),(X.test(d.kind)||X.test(d.noun))&&(c+=3),t&&(a.words.includes(t)||d.noun===L(t))&&(c+=5),a.words.split(" ").some(u=>u.length>2&&s.includes(` ${u}`))&&(c+=2),o.push({rows:i,across:d,link:a,score:c})}let r=o.sort((i,a)=>a.score-i.score)[0];return r||h(e[0]?`${e[0].plural} are joined to nothing else, so there is no who-covers-what to draw`:"nothing here is joined to anything else, so there is no who-covers-what to draw")}function dn(n,e,s,t,o){let r=W(t);switch(n){case"columns":{if(r){let i=I(e,r);if(!i||i.type!=="enum"){let a=rn(e,r,s);if(a){let l=s.info(a.to[0]);return{lens:"coverage",kind:e.kind,across:l.kind,link:a.name}}}}return{lens:"columns",kind:e.kind,column:Dn(e,r).name}}case"calendar":{let i=nn(e,t),a=_(t);return{lens:"calendar",kind:e.kind,start:i.start.name,...i.end?{end:i.end.name}:{},...i.done?{done:i.done.name}:{},...a?{range:a}:{}}}case"timeline":{let i=an(e);if(i&&!/\bdates?\b|\bdue\b|\bdeadlines?\b|\bmonths?\b|\byears?\b/.test(t))return{lens:"timeline",kind:e.kind,start:i.start.name,end:i.end.name,column:i.column.name};let a=nn(e,t);return{lens:"calendar",kind:e.kind,start:a.start.name,...a.end?{end:a.end.name}:{},...a.done?{done:a.done.name}:{},range:_(t)??"quarter"}}case"coverage":{let i=vn(s,o,t,r);return{lens:"coverage",kind:i.rows.kind,across:i.across.kind,link:i.link.name}}case"board":{let i=$(e,e.roles.x)??e.fields.find(c=>c.name==="x"),a=$(e,e.roles.y)??e.fields.find(c=>c.name==="y");if(!K(i)||!K(a))return h(`${e.plural} have no x and y to be laid out by`);let d=s.kinds.flatMap(c=>c.edges.filter(u=>u.to.includes(e.kind)&&c.kind!==e.kind))[0]??e.edges[0];return d?{lens:"board",kind:e.kind,x:i.name,y:a.name,fill:d.name,...d.from!==e.kind?{fillFrom:"occupant"}:{}}:h(`nothing is joined to ${e.plural} to fill them`)}case"plan":{let i=$(e,e.roles.outline)??e.fields.find(a=>a.name==="outline");return i?{lens:"plan",kind:e.kind,outline:i.name}:h(`${e.plural} have no outline to draw a plan from`)}case"blocks":{let i={lens:"blocks",kind:e.kind,as:/\bcards?\b/.test(t)?"card":"row"},a=/ group(?:ed)? by ([\p{L}\p{N} -]+?)(?= (?:and|only|sorted|with)|\s*$)/u.exec(t)?.[1]??(r&&!/ sort(?:ed)? by /.test(t)?r:void 0);if(a){let c=I(e,a);if(!c||c.type!=="enum")return h(c?`${e.plural}' ${c.words} is not a choice, so they cannot be grouped by it`:`${e.plural} have nothing called ${a} to group by`);i.group=c.name}let l=/ sort(?:ed)? by ([\p{L}\p{N} -]+?)(?= (?:and|only|grouped|with)|\s*$)/u.exec(t)?.[1];if(l){let c=I(e,l);if(!c)return h(`${e.plural} have nothing called ${l} to sort by`);i.sort={by:c.name,.../\b(newest|latest|desc|descending|most)\b/.test(t)?{direction:"desc"}:{}}}let d=q(e,t);return d.length>0&&(i.where=d),i}}}function q(n,e){let s=[],t=on(e);if(t){let o=n.fields.filter(R),r=$(n,n.roles.start),i=o.find(l=>A(e,l.words))??(R(r)?r:void 0)??o[0];(!i||!R(i))&&h(`no date field on ${n.plural}`);let a=n.fields.find(l=>l.type==="boolean"&&/^(done|finished|complete|completed|closed)$/.test(l.name));s.push({expr:t.cond(i.name,/\boverdue\b|\blate\b|\bpast due\b/.test(e)?a?.name:void 0),says:t.says(i)})}if(/\bonly\b|\bjust\b|\bthat are\b|\bwhich are\b/.test(e)){for(let o of n.fields){if(o.type!=="enum")continue;let r=o.options?.find(i=>A(e,i.toLowerCase())||A(e,m(i)));r&&s.push({expr:`${o.name} == '${r.replace(/'/g,"")}'`,says:`that are ${m(r)}`})}if(/\bnot done\b|\bundone\b|\bunfinished\b|\bopen ones\b|\bstill to do\b/.test(e)){let o=n.fields.find(r=>r.type==="boolean"&&/^(done|finished|complete|completed)$/.test(r.name));o&&s.push({expr:`not ${o.name}`,says:`not ${o.words}`})}}return s}var J={columns:"A board",calendar:"A calendar",timeline:"A timeline",coverage:"A grid",board:"A layout",plan:"A plan",blocks:"A list",reach:"A picture"};function Rn(n,e){let s=e.info(n.kind),t=o=>o?$(s,o)?.words??m(o):"";switch(n.lens){case"columns":return{title:`${k(s.plural)} by ${t(n.column)}`,detail:`of ${s.plural} by ${t(n.column)}`};case"calendar":{let o=n.range??"month";if(o==="agenda")return{title:`${k(s.plural)} in date order`,detail:`of ${s.plural} in order of ${t(n.start)}`};let r=o==="years"?"year":o;return{title:`${k(s.plural)} by ${r}`,detail:`of ${s.plural} by ${t(n.start)}, a ${r} at a time`}}case"timeline":return{title:`${k(s.plural)} over the ${t(n.column)}`,detail:`of ${s.plural} from ${t(n.start)} to ${t(n.end)}, by ${t(n.column)}`};case"coverage":{let o=e.info(n.across);return{title:`${k(s.plural)} by ${o.noun}`,detail:`of which ${o.noun} covers which ${s.noun}`}}case"board":return{title:`${k(s.plural)} where they stand`,detail:`of ${s.plural} where they stand`};case"plan":return{title:`${k(s.plural)} on a plan`,detail:`of ${s.plural}`};default:{let o=[n.where?.map(r=>r.says).join(" and "),n.group?`by ${t(n.group)}`:void 0,n.sort?`in order of ${t(n.sort.by)}`:void 0].filter(r=>!!r);return{title:[k(s.plural),...o].join(" "),detail:[`of ${s.plural}`,...o].join(" ")}}}}function An(n,e){let s={title:e,on:n.kind};switch(n.lens){case"columns":return{name:"columns",...s,bindings:{[n.kind]:{column:n.column}}};case"calendar":return{name:"calendar",...s,bindings:{[n.kind]:{start:n.start,...n.end?{end:n.end}:{},...n.done?{done:n.done}:{}}},...n.range?{options:{range:n.range}}:{}};case"timeline":return{name:"timeline",...s,bindings:{[n.kind]:{start:n.start,end:n.end,column:n.column}}};case"coverage":return{name:"coverage",...s,bindings:{rows:{kind:n.kind},columns:{kind:n.across},link:{edge:n.link}}};case"board":return{name:"board",...s,bindings:{slots:{kind:n.kind},x:{field:n.x,on:"slots"},y:{field:n.y,on:"slots"},fill:{edge:n.fill}},...n.fillFrom?{options:{fillFrom:n.fillFrom}}:{}};case"plan":return{name:"plan",...s,bindings:{regions:{kind:n.kind},outline:{field:n.outline,on:"regions"}}};default:{let t=n.where?.length?` where ${n.where.map(r=>n.where.length>1?`(${r.expr})`:r.expr).join(" and ")}`:"",o={list:`all('${n.kind}')${t}`,as:n.as??"row"};return n.group&&(o.group=n.group),n.sort&&(o.sort=n.sort.direction?{by:n.sort.by,direction:n.sort.direction}:n.sort.by),o.empty="Nothing here yet.",{name:"blocks",...s,options:{blocks:[o]}}}}}function F(n,e){let{app:s}=e,t=r=>r.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,""),o=new Set(["home","overview",...Q(s,e.views?{views:e.views}:{}).map(r=>r.slug),...(s.lenses??[]).flatMap(r=>r.title?[t(r.title)]:[])]);if(!o.has(t(n)))return n;for(let r=2;;r++)if(!o.has(t(`${n} ${r}`)))return`${n} ${r}`}var en={title:[],headline:[],text:["tone"],figure:["as","currency","label"],list:["sort","limit","group","empty","as"],progress:["label"],group:["direction"],when:["show"],divider:[]};function Ln(n,e){if(!Array.isArray(e)||e.length===0)return"it has no blocks to draw";if(e.length>40)return"it has more blocks than a place draws";let s=(i,a)=>{if(typeof i!="string"||i.trim()==="")return`its ${a} says nothing`;try{return V(i)}catch(l){return`its ${a} does not read: ${l instanceof Error?l.message.replace(/ \(at character.*$/,""):String(l)}`}},t=i=>{if(i.t==="where")return t(i.set);if(i.t==="call"&&i.fn==="all"){let a=i.args[0];return a?.t==="lit"&&typeof a.value=="string"?n.info(a.value)??null:void 0}},o=(i,a)=>{switch(i.t){case"lit":return;case"ident":return a&&!a.fields.some(l=>l.name===i.name)&&!a.edges.some(l=>l.name===i.name)?`${a.plural} have nothing called ${i.name}`:void 0;case"member":return o(i.object,a);case"list":return i.items.map(l=>o(l,a)).find(Boolean);case"unary":return o(i.operand,a);case"binary":return o(i.left,a)??o(i.right,a);case"where":{let l=t(i.set);return l===null?"Nothing by that name here":o(i.set,a)??o(i.filter,l??void 0)}case"call":return i.fn==="all"?t(i)===null?"Nothing by that name here":void 0:i.args.map(l=>o(l,a)).find(Boolean)}},r=(i,a)=>{if(a>4)return"its blocks nest deeper than a place draws";for(let l of i){if(!w(l))return"a block is not an object";let d=Object.keys(en).find(g=>g in l);if(!d)return`"${Object.keys(l)[0]??""}" is not a block a place draws`;let c=Object.keys(l).find(g=>g!==d&&g!=="key"&&!en[d].includes(g));if(c)return`a ${d} block takes no "${c}"`;let u=l[d];if(d==="list"||d==="figure"||d==="when"){if(d==="figure"&&u===!0)continue;let g=s(u,d);if(typeof g=="string")return g;let b=o(g,void 0);if(b)return b;if(d==="list"){let f=t(g);if(f==null)return f===null?"Nothing by that name here":"its list does not say which records it lists, like all('task')";for(let y of["group","sort"]){let p=l[y],S=typeof p=="string"?p:w(p)&&typeof p.by=="string"?p.by:void 0;if(p===void 0)continue;let D=S?f.fields.find(un=>un.name===S):void 0;if(!D)return`${f.plural} have nothing called ${String(S??p)} to ${y} by`;if(y==="group"&&D.type!=="enum")return`${f.plural}' ${D.words} is not a choice, so they cannot be grouped by it`}}if(d==="when"){let f=l.show;if(!Array.isArray(f))return"a when block shows a list of blocks";let y=r(f,a+1);if(y)return y}}else if(d==="group"){if(!Array.isArray(u))return"a group block holds a list of blocks";let g=r(u,a+1);if(g)return g}else{if(d!=="divider"&&typeof u!="string")return`a ${d} block says words`;if(typeof u=="string")for(let g of u.matchAll(/\{([^{}]*)\}/g)){let b=g[1].split(/\|(?![|])/)[0],f=s(b,`${d}'s braces`);if(typeof f=="string")return f;let y=o(f,void 0);if(y)return y}}}};return r(e,1)}function E(n,e,s){let t=O(n.schema,s),o=f=>({ok:!1,failed:`Couldn't draw that: ${f.replace(/\.$/,"")}.`});if(!T(e.name)||e.name==="reach")return o(`"${String(e.name)}" is not a picture the seat can draw; it draws ${H.filter(f=>f!=="reach").join(", ")}`);if(typeof e.title!="string"||e.title.trim().length===0||e.title.length>80)return o("it needs a title of a few words");if(typeof e.on!="string"||!t.tryDefinition(e.on))return o("Nothing by that name here");let r=P[e.name],i=e.bindings??{};if(r.binds==="fields")for(let[f,y]of Object.entries(i)){if(!t.tryDefinition(f))return o("Nothing by that name here");let p=Object.keys(t.tryDefinition(f).fields?.shape??{});for(let[S,D]of Object.entries(y??{}))if(typeof D!="string"||!p.includes(D))return o(`${m(f)} has no field "${String(D)}" for its ${S}`);for(let S of r.requiredRoles)if(!(S in(y??{})))return o(`a ${e.name} needs ${m(f)}'s ${S}`)}else if(r.binds==="entities")for(let f of r.requiredRoles){let y=i[f];if(!y)return o(`a ${e.name} needs its ${f}`);if(typeof y.kind=="string"&&!t.tryDefinition(y.kind))return o("Nothing by that name here")}let a={...n,schema:t,lenses:[...n.lenses??[],e]},l=a.lenses.length-1,d=U(a),c=`lenses.${l}`,u=d.findings.find(f=>f.path===c||f.path.startsWith(`${c}.`));if(u)return o(u.message.replace(/^"[^"]*" /,"it "));let g=d.undrawn.find(f=>f.index===l);if(g)return o(g.why);let b=d.drawn.find(f=>f.index===l);if(!b)return o("its bindings name something the app does not have");if(b.as==="overview")return o(`"${e.title}" is the scene's own address; give it another title`);if(e.name==="blocks"){let f=Ln(j(t),e.options?.blocks);if(f)return o(f)}return{ok:!0,drawn:b}}function G(n){return{op:"add-lens",title:n.title,lens:n.name,on:n.on,...n.bindings?{bindings:n.bindings}:{},...n.options?{options:n.options}:{}}}function In(n){return{op:"remove-lens",title:n.title,on:n.on}}var w=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function ln(n){let e=w(n)?n:{},s=String(e.lens??e.name??""),t=e.bindings,o=typeof e.on=="string"?e.on:w(t)&&P[s]?.binds==="fields"?Object.keys(t)[0]??"":"";return{name:s,title:typeof e.title=="string"?e.title.trim():"",on:o,...w(t)?{bindings:t}:{},...w(e.options)?{options:e.options}:{}}}function On(n){let e=o=>w(n.bindings?.[o])?n.bindings[o]:{},s=o=>typeof o=="string"?o:void 0,t=e(n.on);switch(n.name){case"columns":return s(t.column)?{lens:"columns",kind:n.on,column:t.column}:void 0;case"calendar":{let o=s(n.options?.range);return s(t.start)?{lens:"calendar",kind:n.on,start:t.start,...s(t.end)?{end:t.end}:{},...s(t.done)?{done:t.done}:{},...o?{range:o}:{}}:void 0}case"timeline":return s(t.start)&&s(t.end)&&s(t.column)?{lens:"timeline",kind:n.on,start:t.start,end:t.end,column:t.column}:void 0;case"coverage":{let o=w(n.bindings?.columns)?s(n.bindings.columns.kind):void 0,r=w(n.bindings?.link)?s(n.bindings.link.edge):void 0;return o&&r?{lens:"coverage",kind:n.on,across:o,link:r}:void 0}case"blocks":{let o=n.options?.blocks;if(!Array.isArray(o)||o.length!==1||!w(o[0]))return;let r=o[0],i=new RegExp(`^all\\('${n.on}'\\)(?: where (.+))?$`).exec(String(r.list??""));if(!i)return;let a=r.sort;return{lens:"blocks",kind:n.on,as:r.as==="card"?"card":"row",...typeof r.group=="string"?{group:r.group}:{},...typeof a=="string"?{sort:{by:a}}:w(a)&&typeof a.by=="string"?{sort:{by:a.by,...a.direction==="desc"?{direction:"desc"}:{}}}:{},...i[1]?{where:[{expr:i[1],says:"as asked"}]}:{}}}default:return}}function M(n,e,s,t,o){let r=j(O(n.schema,t)).info(e.on),i=On(e);return{title:e.title,said:`${J[e.name]??"A picture"} of ${r?.plural??m(e.on)}.`,kind:e.on,lens:e,drawn:s,edit:G(e),by:o,asks:[],...i?{recipe:i}:{}}}function tn(n){return{title:n.title,said:n.said,lens:{title:n.lens.title,lens:n.lens.name,on:n.lens.on,...n.lens.bindings?{bindings:n.lens.bindings}:{},...n.lens.options?{options:n.lens.options}:{}},edit:n.edit,by:n.by,check:"It draws, and graview check would take it."}}function C(n,e,s,t,o){let r=Rn(n,e),i=n.title??o??F(r.title,s),a=An(n,i),l=E(s.app,a,s.sight);return l.ok?{title:i,said:`${J[n.lens]} ${r.detail}.`,kind:n.kind,lens:a,drawn:l.drawn,edit:G(a),by:"template",asks:t,recipe:n}:{failed:l.failed,...s.lastGood?{lastGood:s.lastGood}:{}}}function Jn(n,e){let s=j(O(e.app.schema,e.sight)),t=s.info(n.kind);if(!t)return{failed:"Couldn't draw that: Nothing by that name here."};let o=n.lens==="blocks"&&!n.group&&!n.sort&&!n.where?.length&&n.title===void 0;return C(o?{...n,title:F(`Every ${t.noun}`,e)}:n,s,e,[])}function jn(n,e,s,t){if(s.length>0)return s;let o=i=>{switch(n){case"columns":return i.fields.some(a=>a.type==="enum");case"calendar":return i.fields.some(R);case"timeline":return an(i)!==void 0||i.fields.some(R);case"coverage":return i.edges.some(a=>a.to.some(l=>l!==i.kind));case"board":return i.fields.some(a=>a.name==="x")&&i.fields.some(a=>a.name==="y");case"plan":return i.fields.some(a=>a.name==="outline")||i.roles.outline!==void 0;default:return!0}};return[...e.kinds.filter(o)].sort((i,a)=>Number(a.fields.some(l=>A(t,l.words)))-Number(i.fields.some(l=>A(t,l.words))))}function Nn(n,e){let s=j(O(e.app.schema,e.sight)),t=sn(n),o=Sn(t);if(o.length===0)return;let r=yn(t,s),i;for(let a of o){let l=a==="coverage"?[r[0]??s.kinds[0]].filter(d=>!!d):jn(a,s,r,t);for(let d of l)try{let c=dn(a,d,s,t,r),u=C(c,s,e,[n]);if(!N(u))return u;i??=u.failed}catch(c){if(!(c instanceof x))throw c;i??=`Couldn't draw that: ${c.message}.`}l.length===0&&r.length===0&&(i??=`Couldn't draw that: nothing here has what ${J[a].toLowerCase()} needs.`)}return{failed:i??"Couldn't draw that: Nothing by that name here.",...e.lastGood?{lastGood:e.lastGood}:{}}}async function xn(n,e){let s=e.lastGood?{lastGood:e.lastGood}:{};if(n.trim().length===0)return{failed:"Say what you would like to see, like \u201Ca board of tasks by status\u201D.",...s};let t=Nn(n,e);if(t&&!N(t))return t;if(!e.complete)return t??{failed:"Couldn't draw that: drawing freely needs AI, which isn't on here. Ask for a board, a calendar, a timeline, a list or who covers what.",...s};let o=await cn(n,e,void 0);return N(o)&&t?t:o}async function En(n,e,s){let t={lastGood:n},o={...s,lastGood:n},r=j(O(s.app.schema,s.sight)),i=sn(e),a=r.info(n.kind),l=[...n.asks,e];if(!a)return{failed:"Couldn't change that: Nothing by that name here.",...t};let d=n.recipe,c=/^ (?:call|name|title) (?:it|this)? ?(.+?) $/.exec(i)??/ (?:call|name) it (.+?) $/.exec(i);try{if(c){let b=e.replace(/^.*?\b(?:call|name|title)\b\s*(?:it|this)?\s*/i,"").replace(/^["“']|["”']$/g,"").trim();if(b.length===0)return{failed:"Couldn't change that: say what to call it.",...t};let f={...n.lens,title:F(b,s)},y=E(s.app,f,s.sight);return y.ok?{...n,title:f.title,lens:f,drawn:y.drawn,edit:G(f),asks:l,...d?{recipe:{...d,title:f.title}}:{}}:{failed:y.failed,...t}}let g=/ as (?:a |an )?(board|kanban|calendar|timeline|list|table|cards|rows|grid|plan|layout)\b/.exec(i);if(g){let b=g[1]==="board"||g[1]==="kanban"?"columns":g[1]==="calendar"?"calendar":g[1]==="timeline"?"timeline":g[1]==="grid"?"coverage":g[1]==="plan"?"plan":g[1]==="layout"?"board":"blocks",f=dn(b,a,r,i,[a]),y=g[1]==="cards"?"card":g[1]==="rows"?"row":void 0,p=b==="blocks"&&d?.lens==="blocks"?{...d,...y?{as:y}:{}}:b==="blocks"&&d?.lens==="columns"?{...f,group:d.column,...y?{as:y}:{}}:f;return C(v(p),r,o,l)}if(d){let b=Kn(d,a,r,i);if(b)return C(b,r,o,l)}}catch(g){if(!(g instanceof x))throw g;return{failed:`Couldn't change that: ${g.message}.`,...t}}if(!s.complete)return{failed:"Couldn't change that: changing it freely needs AI, which isn't on here. Try \u201Cgroup by status\u201D, \u201Conly this month\u201D or \u201Cas a calendar\u201D.",...t};let u=await cn(e,o,n);return N(u)?u:{...u,asks:l}}var v=n=>{let{title:e,...s}=n;return s};function Kn(n,e,s,t){let o=/ (?:group(?:ed)?|split|organi[sz]ed?|put them|columns) by ([\p{L}\p{N} -]+?)(?= (?:and|only|with)|\s*$)/u.exec(t)?.[1]??(/^ by /.test(t)?W(t):void 0);if(o){let d=I(e,o);if(d?.type==="enum")return n.lens==="blocks"?{...v(n),group:d.name}:{lens:"columns",kind:n.kind,column:d.name};let c=rn(e,o,s);return c?{lens:"coverage",kind:n.kind,across:c.to[0],link:c.name}:h(d?`${e.plural}' ${d.words} is not a choice, so they cannot be grouped by it`:`${e.plural} have nothing called ${o} to group by`)}let r=/ (?:sort(?:ed)?|order(?:ed)?) by ([\p{L}\p{N} -]+?)(?= (?:and|only|with)|\s*$)/u.exec(t)?.[1];if(r){let d=I(e,r);return d?{...n.lens==="blocks"?v(n):{lens:"blocks",kind:n.kind,as:"row",...n.lens==="columns"?{group:n.column}:{}},sort:{by:d.name,.../\b(newest|latest|desc|descending|most)\b/.test(t)?{direction:"desc"}:{}}}:h(`${e.plural} have nothing called ${r} to sort by`)}if(/\b(?:all of them|everything|show all|clear the filter|no filter|without the filter)\b/.test(t)){if(n.lens!=="blocks"||!n.where)return h("it already shows all of them");let{where:d,...c}=v(n);return c}let i=on(t);if(i&&n.lens==="calendar"&&i.range)return{...v(n),range:i.range};if(i&&n.lens==="calendar"&&!i.range)return{lens:"blocks",kind:n.kind,as:"row",sort:{by:n.start},where:q(e,t)};let a=q(e,t);if(a.length>0){let d=n.lens==="blocks"?v(n):{lens:"blocks",kind:n.kind,as:"row",...n.lens==="columns"?{group:n.column}:{}};return{...d,where:[...d.where??[],...a]}}let l=n.lens==="calendar"?_(t):void 0;if(l)return{...v(n),range:l}}function Cn(n){return n.kinds.map(e=>{let s=e.fields.map(r=>`${r.name} (${r.type??"value"}${r.options?`: ${r.options.join(" | ")}`:""})`).join(", "),t=e.edges.map(r=>`${r.name} \u2192 ${r.to.join(" | ")}`).join(", "),o=Object.entries(e.roles).map(([r,i])=>`${r}=${i}`).join(", ");return`- ${e.kind} ("${e.plural}"): ${s}${t?`; relations: ${t}`:""}${o?`; roles: ${o}`:""}`}).join(`
2
+ `)}var Fn=['columns \u2014 a board, records in columns by one choice field: {"lens": "columns", "on": K, "bindings": {K: {"column": "<enum field>"}}}','calendar \u2014 records on a calendar by a date: {"lens": "calendar", "on": K, "bindings": {K: {"start": "<date field>", "end"?: "<date field>", "done"?: "<boolean field>"}}, "options": {"range"?: "day" | "week" | "month" | "quarter" | "year" | "agenda"}}','timeline \u2014 minutes of a day in columns: {"lens": "timeline", "on": K, "bindings": {K: {"start": "<number field>", "end": "<number field>", "column": "<enum field>"}}}','coverage \u2014 who covers what, a grid of two kinds joined by a relation: {"lens": "coverage", "on": K, "bindings": {"rows": {"kind": K}, "columns": {"kind": J}, "link": {"edge": "<relation of K to J>"}}}',`blocks \u2014 anything else, as blocks: {"lens": "blocks", "on": K, "options": {"blocks": [{"headline": "words"}, {"list": "all('K') where <condition>", "group"?: "<enum field>", "sort"?: "<field>" | {"by": "<field>", "direction": "desc"}, "as"?: "row" | "card", "empty"?: "words"}, {"figure": "count(all('K'))", "label": "words"}]}}. Conditions read a record's own fields: status == 'open', not done, days(today(), due) <= 7.`].join(`
3
+ `);function Gn(n,e,s){return["You draw a view of an app's data as JSON \u2014 never code. The app's kinds, their fields (with types) and relations:",Cn(e),"","The lenses you may use (prefer the first four; use blocks only when none of them fits):",Fn,"",s?`The view on screen now:
4
+ ${JSON.stringify(s.lens)}
5
+ Change it as asked, and keep everything not asked about.`:"",`Asked: ${JSON.stringify(n)}`,'Answer with ONE JSON object: {"title": "<a few words, like Deliverables by status>", "lens": \u2026, "on": \u2026, "bindings"?: \u2026, "options"?: \u2026}. Name only the kinds, fields and relations listed above. If it cannot be drawn from them, answer {"failed": "<one sentence saying why>"}.'].filter(t=>t!=="").join(`
6
+ `)}async function cn(n,e,s){let t=e.lastGood?{lastGood:e.lastGood}:{},o=j(O(e.app.schema,e.sight)),r;try{r=(await e.complete({prompt:Gn(n,o,s)})).text}catch{return{failed:"Couldn't draw that: the model did not answer.",...t}}let i=Z(r);if(typeof i!="object"||i===null||Array.isArray(i))return{failed:"Couldn't draw that: the model's answer was not a view.",...t};let a=i;if(typeof a.failed=="string")return{failed:`Couldn't draw that: ${a.failed.replace(/^Couldn't draw that:\s*/i,"").replace(/\.$/,"")}.`,...t};let l=ln(a);if(!T(l.name))return{failed:`Couldn't draw that: "${l.name}" is not a picture the seat can draw.`,...t};let d=l.title?l.title.slice(0,80):s?.title??k(n.trim()).slice(0,80),c={...l,title:s&&s.title===d?d:F(d,e)},u=E(e.app,c,e.sight);return u.ok?{...M(e.app,c,u.drawn,e.sight,"model"),asks:[n]}:{failed:u.failed,...t}}function zn(n,e,s){let t=[...n.lenses??[]];for(let o of e){let r={name:o.lens,title:o.title,on:o.on,...o.bindings?{bindings:o.bindings}:{},...o.options?{options:o.options}:{}};if(t.some(a=>a.title===r.title))continue;E({...n,lenses:t},r,s).ok&&(t=[...t,r])}return t.length===(n.lenses??[]).length?n:{...n,lenses:t}}async function Bn(n,e,s){let{app:t,drafts:o}=s,r=fn(t,s.principal),i=c=>{let u=ln(c);return{lens:u,verdict:E(t,u,r)}};if(n==="keep_lens"){let{lens:c,verdict:u}=i(e);if(!u.ok)return{ok:!1,error:u.failed,reason:"invalid"};if(!o?.keep)return{ok:!1,error:"This app's declaration cannot be written from here."};let g=G(c),b=await o.keep(g);return b.ok?{ok:!0,data:{kept:g,said:b.said??`Adds \u201C${g.title}\u201D to the places.`,undo:In(g)}}:{ok:!1,error:b.error}}if(e.lens!==void 0){let{lens:c,verdict:u}=i(e.lens);return u.ok?{ok:!0,data:tn(M(t,c,u.drawn,r,"model"))}:{ok:!1,error:u.failed,reason:"invalid"}}let a={app:t,sight:r,...o?.complete?{complete:o.complete}:{},...o?.views?{views:o.views}:{}},l=String(e.ask??""),d;if(e.current!==void 0){let{lens:c,verdict:u}=i(e.current);if(!u.ok)return{ok:!1,error:u.failed,reason:"invalid"};d=await En(M(t,c,u.drawn,r,"model"),l,a)}else d=await xn(l,a);return N(d)?{ok:!1,error:d.failed,reason:"invalid"}:{ok:!0,data:tn(d)}}export{N as a,fn as b,E as c,G as d,In as e,ln as f,On as g,M as h,tn as i,Jn as j,Nn as k,xn as l,En as m,zn as n,Bn as o};
@@ -1 +1 @@
1
- import{ga as l,ma as p,vb as a}from"./chunk.VSCIXAHN.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{ja as l,pa as p,zb as a}from"./chunk.DZZL5IDD.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};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk.Y4FZKUOK.js";import"./chunk.TIALD6SC.js";import"./chunk.QHY5NVYH.js";import"./chunk.U6ZRJKVM.js";import"./chunk.PLTH2LW5.js";import"./chunk.66P5IDTH.js";import"./chunk.AJSUHPBE.js";import"./chunk.KDXU5DT3.js";import"./chunk.W4BKYSZX.js";import{b as n}from"./chunk.7XLS6XTY.js";import"./chunk.U5P23GO7.js";import"./chunk.5STU3KYG.js";import"./chunk.GZHZLJBF.js";import"./chunk.UKQUUPKE.js";import"./chunk.OJGHDWI6.js";import"./chunk.DDUCIUVW.js";import"./chunk.NUYA4BWI.js";import"./chunk.OKZT2QBM.js";import"./chunk.ACTXR2MI.js";import"./chunk.AI34V6WV.js";import"./chunk.G4ULQK64.js";import{T as i}from"./chunk.M7RESZB6.js";import"./chunk.SDO3U72B.js";import"./chunk.DZZL5IDD.js";import"./chunk.FQLNBIQ5.js";import{b as o}from"./chunk.AJZBJBMO.js";var e=o(i(),1);function m({entries:d,style:l,headingStyle:p,className:r}){return(0,e.jsxs)("section",{...r?{className:r}:{},"data-testid":"record-ai","aria-label":"What AI did here",style:{display:"grid",gap:10,...l},children:[(0,e.jsx)("h2",{style:p??{margin:0,fontSize:"1rem"},children:"What AI did here"}),(0,e.jsx)("ol",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8,fontSize:"0.875rem"},children:d.slice(0,8).map(t=>(0,e.jsx)(n,{entry:t,undo:s=>(0,e.jsx)(a,{batch:s})},t.id))})]})}export{m as RecordInteractions};
@@ -1 +1 @@
1
- import"./chunk.WC3DENU4.js";import"./chunk.VNDKKTED.js";import{G as W,T as x}from"./chunk.4MP72LPR.js";import"./chunk.SDO3U72B.js";import"./chunk.VSCIXAHN.js";import"./chunk.FQLNBIQ5.js";import{b as D}from"./chunk.AJZBJBMO.js";var g=D(W(),1);var o=D(x(),1),v=864e5,l=t=>Date.UTC(+t.slice(0,4),+t.slice(5,7)-1,+t.slice(8,10)),I=t=>new Date(t).toISOString().slice(0,10),s=(t,i)=>I(l(t)+i*v),m=(t,i)=>{let a=new Date(l(t)),u=a.getUTCMonth()+i,d=Date.UTC(a.getUTCFullYear(),u,1),w=new Date(Date.UTC(a.getUTCFullYear(),u+1,0)).getUTCDate();return I(d+(Math.min(a.getUTCDate(),w)-1)*v)};function p(t,i,a){try{return new Intl.DateTimeFormat(t??"en-US",{...i,timeZone:"UTC"}).format(a)}catch{return new Intl.DateTimeFormat("en-US",{...i,timeZone:"UTC"}).format(a)}}function F(t){try{let i=new Intl.Locale(t??"en-US"),a=i.getWeekInfo?.().firstDay??i.weekInfo?.firstDay;if(a!==void 0)return a%7}catch{return 0}return/^en-US|^en$|-(US|CA|JP|BR|IL|MX|PH)$/.test(t??"en-US")?0:1}function H({id:t,label:i,selected:a,today:u,locale:d,onPick:w,onClose:T}){let[r,f]=(0,g.useState)(a??u),U=(0,g.useRef)(null),y=F(d),b=`${r.slice(0,7)}-01`,M=(new Date(l(b)).getUTCDay()-y+7)%7,P=s(b,-M),A=Array.from({length:6},(e,n)=>Array.from({length:7},(S,c)=>s(P,n*7+c))),$=p(d,{month:"long",year:"numeric"},l(b)),h=(0,g.useRef)(!0);(0,g.useEffect)(()=>{h.current&&U.current?.querySelector(`[data-day="${r}"]`)?.focus(),h.current=!1},[r]);let E=e=>{let n={ArrowLeft:()=>s(r,-1),ArrowRight:()=>s(r,1),ArrowUp:()=>s(r,-7),ArrowDown:()=>s(r,7),PageUp:()=>m(r,e.shiftKey?-12:-1),PageDown:()=>m(r,e.shiftKey?12:1),Home:()=>s(r,-((new Date(l(r)).getUTCDay()-y+7)%7)),End:()=>s(r,6-(new Date(l(r)).getUTCDay()-y+7)%7)};n[e.key]?(e.preventDefault(),h.current=!0,f(n[e.key]())):e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),T())},R=Array.from({length:7},(e,n)=>l("1970-01-04")+(y+n)%7*v),C={minWidth:32,minHeight:32,padding:"0 8px",borderRadius:6};return(0,o.jsxs)("div",{id:t,role:"group","aria-label":`Pick a date for ${i}`,"data-graview-part":"when-month",onKeyDown:e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),T())},style:{flexBasis:"100%",width:"min(100%, 20rem)",boxSizing:"border-box",padding:8,border:"1px solid var(--graview-edge)",borderRadius:8,background:"var(--graview-panel)",color:"var(--graview-ink)"},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6,marginBottom:6},children:[(0,o.jsx)("button",{type:"button","aria-label":"Previous month",onClick:()=>f(m(r,-1)),style:C,children:"\u2039"}),(0,o.jsx)("span",{id:`${t}-title`,"aria-live":"polite",style:{fontWeight:600,fontSize:"0.875rem"},children:$}),(0,o.jsx)("button",{type:"button","aria-label":"Next month",onClick:()=>f(m(r,1)),style:C,children:"\u203A"})]}),(0,o.jsxs)("table",{ref:U,role:"grid","aria-labelledby":`${t}-title`,onKeyDown:E,style:{width:"100%",borderCollapse:"collapse",tableLayout:"fixed",fontSize:"0.8125rem"},children:[(0,o.jsx)("thead",{children:(0,o.jsx)("tr",{children:R.map(e=>(0,o.jsx)("th",{scope:"col",abbr:p(d,{weekday:"long"},e),style:{fontWeight:500,color:"var(--graview-ink-faint)",padding:"2px 0"},children:p(d,{weekday:"narrow"},e)},e))})}),(0,o.jsx)("tbody",{children:A.map(e=>(0,o.jsx)("tr",{children:e.map(n=>{let S=n.slice(0,7)===b.slice(0,7),c=n===a,k=n===u;return(0,o.jsx)("td",{role:"gridcell","aria-selected":c||void 0,style:{padding:1,textAlign:"center"},children:(0,o.jsx)("button",{type:"button","data-day":n,tabIndex:n===r?0:-1,"aria-label":`${p(d,{weekday:"long",year:"numeric",month:"long",day:"numeric"},l(n))}${k?", today":""}${c?", selected":""}`,...k?{"aria-current":"date"}:{},onClick:()=>w(n),onFocus:()=>n!==r&&f(n),style:{width:"100%",minHeight:36,padding:0,borderRadius:6,border:k?"1px solid var(--graview-accent)":"1px solid transparent",background:c?"var(--graview-accent)":"transparent",color:c?"var(--graview-accent-ink)":S?"var(--graview-ink)":"var(--graview-ink-faint)",fontWeight:c?600:400},children:Number(n.slice(8,10))})},n)})},e[0]))})]})]})}export{H as WhenMonth};
1
+ import"./chunk.AI34V6WV.js";import"./chunk.G4ULQK64.js";import{G as W,T as x}from"./chunk.M7RESZB6.js";import"./chunk.SDO3U72B.js";import"./chunk.DZZL5IDD.js";import"./chunk.FQLNBIQ5.js";import{b as D}from"./chunk.AJZBJBMO.js";var g=D(W(),1);var o=D(x(),1),v=864e5,l=t=>Date.UTC(+t.slice(0,4),+t.slice(5,7)-1,+t.slice(8,10)),I=t=>new Date(t).toISOString().slice(0,10),s=(t,i)=>I(l(t)+i*v),m=(t,i)=>{let a=new Date(l(t)),u=a.getUTCMonth()+i,d=Date.UTC(a.getUTCFullYear(),u,1),w=new Date(Date.UTC(a.getUTCFullYear(),u+1,0)).getUTCDate();return I(d+(Math.min(a.getUTCDate(),w)-1)*v)};function p(t,i,a){try{return new Intl.DateTimeFormat(t??"en-US",{...i,timeZone:"UTC"}).format(a)}catch{return new Intl.DateTimeFormat("en-US",{...i,timeZone:"UTC"}).format(a)}}function F(t){try{let i=new Intl.Locale(t??"en-US"),a=i.getWeekInfo?.().firstDay??i.weekInfo?.firstDay;if(a!==void 0)return a%7}catch{return 0}return/^en-US|^en$|-(US|CA|JP|BR|IL|MX|PH)$/.test(t??"en-US")?0:1}function H({id:t,label:i,selected:a,today:u,locale:d,onPick:w,onClose:T}){let[r,f]=(0,g.useState)(a??u),U=(0,g.useRef)(null),y=F(d),b=`${r.slice(0,7)}-01`,M=(new Date(l(b)).getUTCDay()-y+7)%7,P=s(b,-M),A=Array.from({length:6},(e,n)=>Array.from({length:7},(S,c)=>s(P,n*7+c))),$=p(d,{month:"long",year:"numeric"},l(b)),h=(0,g.useRef)(!0);(0,g.useEffect)(()=>{h.current&&U.current?.querySelector(`[data-day="${r}"]`)?.focus(),h.current=!1},[r]);let E=e=>{let n={ArrowLeft:()=>s(r,-1),ArrowRight:()=>s(r,1),ArrowUp:()=>s(r,-7),ArrowDown:()=>s(r,7),PageUp:()=>m(r,e.shiftKey?-12:-1),PageDown:()=>m(r,e.shiftKey?12:1),Home:()=>s(r,-((new Date(l(r)).getUTCDay()-y+7)%7)),End:()=>s(r,6-(new Date(l(r)).getUTCDay()-y+7)%7)};n[e.key]?(e.preventDefault(),h.current=!0,f(n[e.key]())):e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),T())},R=Array.from({length:7},(e,n)=>l("1970-01-04")+(y+n)%7*v),C={minWidth:32,minHeight:32,padding:"0 8px",borderRadius:6};return(0,o.jsxs)("div",{id:t,role:"group","aria-label":`Pick a date for ${i}`,"data-graview-part":"when-month",onKeyDown:e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),T())},style:{flexBasis:"100%",width:"min(100%, 20rem)",boxSizing:"border-box",padding:8,border:"1px solid var(--graview-edge)",borderRadius:8,background:"var(--graview-panel)",color:"var(--graview-ink)"},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6,marginBottom:6},children:[(0,o.jsx)("button",{type:"button","aria-label":"Previous month",onClick:()=>f(m(r,-1)),style:C,children:"\u2039"}),(0,o.jsx)("span",{id:`${t}-title`,"aria-live":"polite",style:{fontWeight:600,fontSize:"0.875rem"},children:$}),(0,o.jsx)("button",{type:"button","aria-label":"Next month",onClick:()=>f(m(r,1)),style:C,children:"\u203A"})]}),(0,o.jsxs)("table",{ref:U,role:"grid","aria-labelledby":`${t}-title`,onKeyDown:E,style:{width:"100%",borderCollapse:"collapse",tableLayout:"fixed",fontSize:"0.8125rem"},children:[(0,o.jsx)("thead",{children:(0,o.jsx)("tr",{children:R.map(e=>(0,o.jsx)("th",{scope:"col",abbr:p(d,{weekday:"long"},e),style:{fontWeight:500,color:"var(--graview-ink-faint)",padding:"2px 0"},children:p(d,{weekday:"narrow"},e)},e))})}),(0,o.jsx)("tbody",{children:A.map(e=>(0,o.jsx)("tr",{children:e.map(n=>{let S=n.slice(0,7)===b.slice(0,7),c=n===a,k=n===u;return(0,o.jsx)("td",{role:"gridcell","aria-selected":c||void 0,style:{padding:1,textAlign:"center"},children:(0,o.jsx)("button",{type:"button","data-day":n,tabIndex:n===r?0:-1,"aria-label":`${p(d,{weekday:"long",year:"numeric",month:"long",day:"numeric"},l(n))}${k?", today":""}${c?", selected":""}`,...k?{"aria-current":"date"}:{},onClick:()=>w(n),onFocus:()=>n!==r&&f(n),style:{width:"100%",minHeight:36,padding:0,borderRadius:6,border:k?"1px solid var(--graview-accent)":"1px solid transparent",background:c?"var(--graview-accent)":"transparent",color:c?"var(--graview-accent-ink)":S?"var(--graview-ink)":"var(--graview-ink-faint)",fontWeight:c?600:400},children:Number(n.slice(8,10))})},n)})},e[0]))})]})]})}export{H as WhenMonth};
@@ -0,0 +1,7 @@
1
+ import{n as K}from"./chunk.AI34V6WV.js";import"./chunk.G4ULQK64.js";import{G as R,T as x,ba as N,ca as $}from"./chunk.M7RESZB6.js";import"./chunk.SDO3U72B.js";import{Dd as v,Ed as b,Fd as f,Ld as h,Nd as k,na as g}from"./chunk.DZZL5IDD.js";import"./chunk.FQLNBIQ5.js";import{b as w}from"./chunk.AJZBJBMO.js";var u=w(R(),1);var o=w(x(),1),E=()=>()=>{};function C(e){let n=(0,u.useMemo)(()=>e?.onChange?i=>e.onChange(i):E,[e]),t=()=>e?.current()??b;return(0,u.useSyncExternalStore)(n,t,t)}var D=(e,n)=>e.lens?n.may.lenses:n.may.views;async function p(e,n,t){try{return await n(),!0}catch(i){let r=i?.code,d=typeof r=="string"?r:void 0;return e?.notify({kind:"toast",tone:"bad",sentence:i instanceof Error&&i.message?i.message:t,...d?{code:d}:{}}),!1}}function H(e,n,t,i,r){let d=e.name;return p(r,()=>n==="view"&&d!==void 0?i?t.hide(d):t.show(d):t.lens?.({op:"set-lens-hidden",title:e.title,on:e.kind,hidden:i}),i?`\u201C${e.title}\u201D could not be hidden.`:`\u201C${e.title}\u201D could not be shown.`)}function L(e,n,t,i,r){return p(r,()=>t.lens?.({op:"set-lens-hidden",title:e,hidden:i}),i?`\u201C${n}\u201D could not be hidden.`:`\u201C${n}\u201D could not be shown.`)}function V(e,n,t){return p(t,()=>n.restore(e.name),`\u201C${e.title}\u201D could not be restored.`)}async function A(e,n,t,i){let r=n==="view"&&e.name!==void 0?e.name:v(e.title),d=await p(i,()=>n==="view"&&e.name!==void 0?t.remove(e.name,{title:e.title,kind:e.kind}):t.lens?.({op:"remove-lens",title:e.title,on:e.kind}),`\u201C${e.title}\u201D could not be deleted.`);return d&&i?.notify({kind:"toast",id:`deleted-view-${r}`,sentence:`Deleted \u201C${e.title}\u201D. It is under Recently deleted in the places for ${30} days.`,action:{label:"Restore",onSelect:()=>void V({name:r,title:e.title},t,i)}}),d}function G(){let e=$(),n=e?.keptViews,t=C(n),i=e?.views;return(0,u.useMemo)(()=>{if(!n||!i)return null;let r=s=>f(s,t,n),d=new Set,c=i.places().filter(s=>{if(!s.hidden||r(s)===null)return!1;let m=`${s.name??""}|${s.title}`;return d.has(m)?!1:(d.add(m),!0)}),l=e?.store.schema,y=t.may.lenses&&n.lens&&l?(i.arrangement?.()?.hide??[]).filter(s=>l.tryDefinition(s)!==void 0).map(s=>({kind:s,title:g(l,s),path:h(l,s)})):[];return{keeper:n,hidden:c,lists:y,removed:t.removed.filter(s=>D(s,t)),how:r}},[n,t,i,e?.store.schema])}function T(e,n){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(n??"en-US",{month:"short",day:"numeric"})}var I=`.graview-bar-list li.graview-bar-tidied{display:flex;align-items:flex-start;gap:8px;padding:0 0 0 2px}
2
+ .graview-bar-tidied>.graview-bar-item,.graview-bar-gone{flex:1 1 auto;min-width:0}
3
+ .graview-bar-gone{display:grid;gap:1px;padding:7px 8px;font-size:.875rem;line-height:1.3;overflow-wrap:anywhere;color:var(--graview-ink-muted)}
4
+ .graview-bar-gone small{font-size:.75rem}
5
+ .graview-bar-tidy{flex:0 0 auto;margin:3px 2px;padding:4px 10px;border:1px solid var(--graview-edge);border-radius:6px;background:none;font:inherit;font-size:.8125rem;color:var(--graview-ink);cursor:pointer}
6
+ .graview-bar-tidy:hover{background:color-mix(in srgb,var(--graview-ink) 7%,transparent)}
7
+ .graview-bar-tidy:focus-visible{outline:2px solid var(--graview-accent);outline-offset:1px}`;function P({place:e,scene:n,reach:t,done:i}){if(n)return(0,o.jsx)("span",{className:"graview-bar-gone",children:e.title});let r="as"in e?{key:`place:${e.kind}:${e.as}`,label:e.title,path:k(e.as),group:"pictures",kind:e.kind}:{key:`kind:${e.kind}`,label:e.title,path:e.path,group:"lists",kind:e.kind},d=t.href?.(r.path);return(0,o.jsx)(d!==void 0?"a":"button",{className:"graview-bar-item","data-testid":"app-view-hidden-place",...d!==void 0?{href:d}:{type:"button"},onClick:l=>{i(),!(!t.go||d!==void 0&&(l.button!==0||l.metaKey||l.ctrlKey||l.shiftKey||l.altKey))&&(l.preventDefault(),t.go(r))},children:e.title})}function M({id:e,scene:n,reach:t,done:i}){let r=G(),{locale:d}=N(),c=(0,u.useContext)(K);if(!r||r.hidden.length===0&&r.lists.length===0&&r.removed.length===0)return null;let{keeper:l,hidden:y,lists:s,removed:m,how:S}=r;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("style",{children:I}),y.length>0||s.length>0?(0,o.jsxs)("div",{role:"group","aria-labelledby":`${e}-hidden`,"data-place-group":"hidden",children:[(0,o.jsx)("p",{id:`${e}-hidden`,children:"Hidden"}),(0,o.jsxs)("ul",{children:[s.map(a=>(0,o.jsxs)("li",{className:"graview-bar-tidied",children:[(0,o.jsx)(P,{place:a,scene:n,reach:t,done:i}),(0,o.jsx)("button",{type:"button",className:"graview-bar-tidy","data-testid":"app-list-show","data-kind":a.kind,"aria-label":`Show \u201C${a.title}\u201D`,onClick:()=>void L(a.kind,a.title,l,!1,c),children:"Show"})]},`kind:${a.kind}`)),y.map(a=>(0,o.jsxs)("li",{className:"graview-bar-tidied",children:[(0,o.jsx)(P,{place:a,scene:n,reach:t,done:i}),(0,o.jsx)("button",{type:"button",className:"graview-bar-tidy","data-testid":"app-view-show","data-view":a.name??a.title,"aria-label":`Show \u201C${a.title}\u201D`,onClick:()=>void H(a,S(a),l,!1,c),children:"Show"})]},`${a.kind}:${a.as}`))]})]}):null,m.length>0?(0,o.jsxs)("div",{role:"group","aria-labelledby":`${e}-removed`,"data-place-group":"removed",children:[(0,o.jsx)("p",{id:`${e}-removed`,children:"Recently deleted"}),(0,o.jsx)("ul",{children:m.map(a=>(0,o.jsxs)("li",{className:"graview-bar-tidied",children:[(0,o.jsxs)("span",{className:"graview-bar-gone",children:[(0,o.jsx)("span",{children:a.title}),(0,o.jsxs)("small",{children:["until ",T(a.until,d)]})]}),(0,o.jsx)("button",{type:"button",className:"graview-bar-tidy","data-testid":"app-view-restore","data-view":a.name,"aria-label":`Restore \u201C${a.title}\u201D`,onClick:()=>void V(a,l,c),children:"Restore"})]},a.name))})]}):null]})}export{M as TidyGroups,A as remove,V as restore,H as setHidden,L as setListHidden,C as useKeptViewsState,G as useTidied};
@@ -0,0 +1 @@
1
+ import{a as I}from"./chunk.ZN3PUM2I.js";import{a as ie,b as de,c as se,d as le,e as V,f as L,g as ue}from"./chunk.QIPASE42.js";import{a as ye}from"./chunk.EVBCEEQ4.js";import{c as T,e as ae,f as fe}from"./chunk.OWT3VVOT.js";import{a as j,b as ee,c as ne,d as re,f as E,m as te,n as b,o as oe,p as B,q as P}from"./chunk.NHTGAP3G.js";import{b as x,d as pe,e as me,g as ce,i as ge,j as he,k as be}from"./chunk.ACTXR2MI.js";import{Aa as M,C as v,Ia as Y,L as H,Vb as q,W as K,Wb as Q,Xb as C,Z as F,da as J,ja as X,pa as N,ra as Z,wa as G,xa as A,ya as z,za as O}from"./chunk.DZZL5IDD.js";var we=e=>e.caption?.trim()||e.name,_=e=>A(e)?`${we(e)}, ${z(e)}`:we(e);function tn(e){let n=Math.max(0,Math.round(e)),t=a=>String(a).padStart(2,"0"),r=Math.floor(n/3600),o=Math.floor(n%3600/60);return r>0?`${r}:${t(o)}:${t(n%60)}`:`${o}:${t(n%60)}`}function ve(e){let n=e?.fields?.shape??{};return Object.keys(n).filter(t=>{let r=v(n[t]);for(;r?.innerType;)r=v(r.innerType);return M(n[t])!==void 0||r?.type==="array"&&M(r.element)!==void 0})}function on(e,n){for(let t of ve(n)){let r=O(e[t]).find(o=>G(o)||A(o));if(r)return r}}var k=e=>{try{return e()}catch{return null}},Te=e=>typeof e=="string"&&ie.includes(e);function Fe(e){if(e!==void 0)return Te(e)?e:e&&typeof e=="object"&&typeof e.expr=="string"?{expr:k(()=>T(e.expr))}:"neutral"}var Ne=4;function Me(e){let n=typeof e.list=="string"?k(()=>T(e.list)):null,t=e.sort,r=typeof t=="string"?t:t&&typeof t=="object"&&typeof t.by=="string"?t.by:void 0,o=t&&typeof t=="object"?t.direction:void 0,a=n,d;if(n&&r!==void 0)if(o==="choices")d=r;else{let y=k(()=>T(r));a=y?{t:"call",fn:"sort",args:[n,y,{t:"lit",value:o==="desc"?"desc":"asc",at:0}],at:0}:null}let l=typeof e.limit=="number"&&Number.isInteger(e.limit)&&e.limit>=1?Math.min(e.limit,V):void 0,i=e.group,s=typeof i=="string"?i:i&&typeof i=="object"&&typeof i.by=="string"?i.by:void 0,f=i&&typeof i=="object"&&i.headings&&typeof i.headings=="object"?i.headings:{};return{t:"list",source:a,...d?{choiceOrder:d}:{},...l?{limit:l}:{},...s?{group:{by:s,headings:Object.fromEntries(Object.entries(f).filter(y=>typeof y[1]=="string"))}}:{},...typeof e.empty=="string"?{empty:e.empty}:{},as:e.as==="card"?"card":"row"}}function Se(e,n=1,t=""){if(!Array.isArray(e)||n>Ne)return[];let r={};return e.flatMap(o=>{if(!o||typeof o!="object"||Array.isArray(o))return[];let a=o,d=p=>typeof p=="string"?k(()=>ae(p)):null,l=p=>typeof p=="string"?k(()=>T(p)):null,i=Fe(a.tone),s=typeof a.label=="string"?a.label:void 0,f=p=>Object.hasOwn(a,p),y=typeof a.currency=="string"&&/^[A-Z]{3}$/.test(a.currency)?a.currency:void 0,u=f("list")?"list":f("headline")?"headline":typeof a.figure=="string"?"number":Ce.find(f);if(!u)return[];let m=r[u]=(r[u]??0)+1,c=a.key,R=typeof c=="string"&&c?c:`${t}${u}.${m}`;return[{...(()=>{switch(u){case"list":return Me(a);case"number":{let p=se.includes(a.as)?a.as:void 0,W=le.includes(a.emphasis)?a.emphasis:void 0;return{t:u,value:l(a.figure),...p?{as:p}:{},...y?{currency:y}:{},...s?{label:d(s)}:{},...W?{emphasis:W}:{}}}case"headline":case"title":return{t:u,parts:d(a[u])};case"text":{let p=a.lines;return{t:u,parts:d(a[u]),...i?{tone:i}:{},...typeof p=="number"&&Number.isInteger(p)&&p>=0?{lines:p}:{}}}case"badge":return{t:u,parts:d(a[u]),...i?{tone:i}:{}};case"field":{let p=de.includes(a.as)?a.as:void 0;return{t:u,field:String(a.field),...p?{as:p}:{},...y?{currency:y}:{},...s?{label:s}:{}}}case"image":return{t:u,field:String(a.image),as:a.as==="gallery"?"gallery":"thumb",...s?{label:s}:{}};case"progress":{let p=a.progress??{};return{t:u,value:l(p.value),max:l(p.max),...s?{label:d(s)}:{}}}case"group":return{t:u,blocks:Se(a.group,n+1,`${R}.`),direction:a.direction==="row"?"row":"column"};case"when":return{t:u,when:l(a.when),show:Se(a.show,n+1,`${R}.`)};default:return{t:u}}})(),key:R}]})}var Ce=["title","text","badge","field","image","progress","group","when","divider","figure"],g="\u2014",Ve=500;function w(e,n){if(!e)return{ok:!1,problem:"an expression that does not parse"};try{return{ok:!0,value:E(e,{graph:n.graph??te,subject:n.node,kinds:n.kinds,today:n.today,budget:n.budget??Ve})}}catch(t){return{ok:!1,problem:t instanceof Error?t.message:String(t)}}}var Le=(e,n,t)=>!e.format&&e.expr?.t==="ident"&&typeof t=="string"&&n.fields[e.expr.name]?.format==="markdown";function S(e,n,t){if(!e)return{text:g,problem:"a template that does not parse"};let r,o;return{text:e.map(d=>{if(d.text!==void 0)return d.text;let l=w(d.expr??null,n);if(!l.ok)return r??=`{${d.source??""}}: ${l.problem}`,g;if(Le(d,n,l.value))return n.glance?pe(l.value,{markdown:!0}):t&&e.length===1?(o=!0,l.value):me(l.value);let i=!d.format&&d.expr?.t==="ident"&&typeof l.value=="number"?Ge(n,d.expr.name):void 0;return oe(d,i?C(l.value,i):b(l.value,d.format,n.today,d.formatArgs,n.money,P(n.schema)))}).join(""),...r?{problem:r}:{},...o?{markdown:o}:{}}}var Ie=" \xB7 ";function _e(e,n){if(!e||!n.node)return;let t=[[]];for(let d of e){if(d.text===void 0){t[t.length-1].push(d);continue}d.text.split(Ie).forEach((i,s)=>{s>0&&t.push([]),i!==""&&t[t.length-1].push({text:i})})}if(t.length<2)return;let r=d=>{let[l]=d;if(!(d.length!==1||!l||l.format||l.expr?.t!=="ident"))return n.fields[l.expr.name]?.type==="enum"?l.expr.name:void 0},o=0,a=t.flatMap(d=>{let l=r(d);if(l){let s=Object.hasOwn(n.node,l)?n.node[l]:void 0;return s==null||s===""?[]:(o++,[{text:x(n.definition,l,s),field:l}])}let i=S(d,n).text.trim();return i===""||i===g?[]:[{text:i}]});return o>0?a:void 0}function Re(e,n){if(e===void 0)return;if(typeof e=="string")return e;let t=w(e.expr,n);return t.ok&&Te(t.value)?t.value:"neutral"}function De(e){if(typeof e=="string")try{let n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"?n.href:void 0}catch{return}}var xe=(e,n)=>{let t=e.fields[n]?.type;return t==="phone"||t==="place"||t==="duration"?t:ge(e.definition,n)},Ge=(e,n)=>q(e.definition?.fields?.shape?.[n])??ce(e.definition,n);function $e(e,n,t,r,o){if(n==null||n==="")return g;if(typeof n=="boolean")return n?"yes":"no";if(r)return b(n,r,t.today,[],o?{...t.money,currency:o}:t.money);let a=t.fields[e];if(t.definition?.display?.format?.[e])return x(t.definition,e,n);let d=he(xe(t,e),n,t.money?.locale);if(d!==void 0)return d;if(a?.type==="date")return b(n,"date",t.today,[],t.money);if(a?.type==="datetime"&&typeof n=="string")return K(n,t.money?.locale,t.money?.timeZone);if(a?.type==="enum"&&(typeof n=="string"||Array.isArray(n)))return x(t.definition,e,n);let l=typeof n=="number"?Ge(t,e):void 0;if(l)return C(n,l);if(typeof n=="number")return F(n,t.money?.locale,{});let i=O(n);return i[0]?i.map(_).join(", "):Array.isArray(n)?n.map(s=>String(s)).join(", "):typeof n=="object"?g:String(n)}function Ue(e,n,t,r,o){return typeof e!="number"?String(e):n==="money"?Q(e,t?{...o,currency:t}:o):n==="percent"?b(e,n,r,[],o):F(e,o?.locale)}var h=(e,n)=>n?{...e,problem:n}:e;function ke(e){return e.firstHeading===void 0?e:{...e,firstHeading:void 0}}function We(e,n,t){switch(e.t){case"title":{let r=S(e.parts,n);return h({t:"title",text:r.text},r.problem)}case"text":{let r=S(e.parts,n,!0),o=Re(e.tone,n),a=n.glance&&!r.problem?_e(e.parts,n):void 0;return h({t:"text",text:r.text,...o?{tone:o}:{},...e.lines!==void 0?{lines:e.lines}:{},...r.markdown?{markdown:r.markdown}:{},...a?{runs:a}:{}},r.problem)}case"badge":{let r=S(e.parts,n);return h({t:"badge",text:r.text,tone:Re(e.tone,n)??"neutral"},r.problem)}case"field":{let r=e.label??N(n.definition,e.field);if(!n.node)return{t:"field",field:e.field,label:r,text:g,problem:`"${e.field}" names a field, and these blocks are about no one record`};let o=e.as===void 0?n.kinds.get(n.node.kind)?.linked?.get(e.field):void 0;if(o){let y=Y(Object.hasOwn(n.node,e.field)?n.node[e.field]:void 0,o);return{t:"field",field:e.field,label:r,text:y.length>0?"linked record":g,...y.length>0?{linked:{relation:o,refs:y}}:{}}}let a=n.kinds.get(n.node.kind)?.computed?.has(e.field),d,l;if(a){let y=w({t:"ident",name:e.field,at:0},n);y.ok?d=y.value!==null&&typeof y.value=="object"?b(y.value,void 0,n.today,[],n.money,P(n.schema)):y.value:l=y.problem}else d=Object.hasOwn(n.node,e.field)?n.node[e.field]:void 0;let i=e.as!==void 0?void 0:n.fields[e.field]?.type==="url"?De(d):be(xe(n,e.field),d),s=k(()=>$e(e.field,d,n,e.as,e.currency))??g,f=n.fields[e.field]?.type==="app-link"&&e.as===void 0&&typeof d=="string"?d:void 0;return h({t:"field",field:e.field,label:r,text:s,...i?{href:i}:{},...f?{app:f}:{}},l)}case"image":{let r=O(n.node&&Object.hasOwn(n.node,e.field)?n.node[e.field]:null),o=e.as==="gallery"?r:r.filter(a=>G(a)||A(a)).slice(0,1);return{t:"image",field:e.field,label:e.label??N(n.definition,e.field),as:e.as,files:o,text:o.map(_).join(", ")||g}}case"progress":{let r=w(e.value,n),o=w(e.max,n),a=e.label?S(e.label,n):{text:"Progress"},d=e.label?B(e.label,a.text):a.text,l=r.ok?o.ok?a.problem:o.problem:r.problem;return r.ok&&o.ok&&typeof r.value=="number"&&typeof o.value=="number"&&Number.isFinite(r.value)&&Number.isFinite(o.value)&&o.value>0?h({t:"progress",label:d,value:r.value,max:o.value,text:`${b(r.value,void 0,n.today)} of ${b(o.value,void 0,n.today)}`},l):h({t:"progress",label:d,text:g},l)}case"group":return{t:"group",direction:e.direction,blocks:Ae(e.blocks,ke(n))};case"when":{let r=w(e.when,n),o=r.ok&&r.value===!0;return h({t:"when",shown:o,blocks:o?Ae(e.show,ke(n)):[]},r.ok?void 0:r.problem)}case"divider":return{t:"divider"};case"figure":return{t:"figure"};case"headline":{let r=S(e.parts,n),o=Math.min(6,Math.max(1,(t?n.firstHeading:void 0)??n.heading??3));return h({t:"headline",level:o,text:e.parts?B(e.parts,r.text):r.text},r.problem)}case"number":{let r=w(e.value,n),o=!r.ok||r.value===null||typeof r.value=="object"?g:Ue(r.value,e.as,e.currency,n.today,n.money),a=e.label?S(e.label,n):void 0;return h({t:"number",text:o,...a&&e.label?{label:B(e.label,a.text)}:{},...e.emphasis?{emphasis:e.emphasis}:{}},r.ok?a?.problem:r.problem)}case"list":return Ke(e,n)}}function Ae(e,n){let t=e.findIndex(r=>r.t==="headline");return e.map((r,o)=>({...We(r,n,o===t),key:r.key}))}function Oe(e,n){let t=n.trim().toLowerCase();return e.some(r=>{switch(r.t){case"title":case"headline":return r.text.trim()!=="";case"text":case"badge":return t!==""&&r.text.toLowerCase().includes(t);case"group":return Oe(r.blocks,n);case"when":return r.shown&&Oe(r.blocks,n);default:return!1}})}var He=new Set(["every","some","sum","min","max","sort"]);function jn(e,n){let t=new Set,r=new Set,o=i=>{if(i)switch(i.t){case"ident":t.add(i.name);return;case"list":i.items.forEach(o);return;case"member":return o(i.object);case"unary":return o(i.operand);case"binary":return o(i.left),o(i.right);case"where":return o(i.set);case"call":i.args.forEach((s,f)=>{f===1&&He.has(i.fn)||o(s)});return;default:return}},a=i=>{for(let s of i??[])o(s.expr)},d=(i,s)=>{i.forEach((f,y)=>{let u=s[y];if(u)switch(f.t){case"field":case"image":t.add(f.field);return;case"title":case"text":case"badge":case"headline":a(f.parts);return;case"number":o(f.value),a(f.label);return;case"progress":o(f.value),o(f.max);return;case"group":u.t==="group"&&d(f.blocks,u.blocks);return;case"when":u.t==="when"&&u.shown&&d(f.show,u.blocks);return;case"list":if(u.t==="list")for(let m of u.members)r.add(m.id);return;default:return}})};d(e,n);let l=n[0];return{fields:t,records:r,...e[0]?.t==="title"&&l?.t==="title"?{title:l.text}:{}}}function Ke(e,n){let t=Math.min(6,(n.heading??3)+1),r=w(e.source,n);if(!r.ok)return{t:"list",as:e.as,failed:!0,members:[],headingLevel:t,more:0,problem:r.problem};let o=r.value,a=o instanceof j?o.nodes:o!==null&&typeof o=="object"&&!Array.isArray(o)?[o]:[];e.choiceOrder&&n.schema&&(a=Je(a,e.choiceOrder,n.schema));let d=a.length,l=a.slice(0,e.limit??V),i=l.slice(0,L),s=l.slice(L),f=(e.limit===void 0?d:l.length)-i.length,y=c=>e.group&&n.schema&&c.length>0?Xe(c,e.group,n.schema,n.graph):void 0,u=y(i),m=s.length>0?y(l):void 0;return{t:"list",as:e.as,failed:!1,members:i,...s.length>0?{rest:s}:{},...u?{groups:u}:{},...m?{everyGroup:m}:{},headingLevel:t,...i.length===0&&e.empty?{empty:e.empty}:{},more:f,total:d}}function D(e,n,t){let r=e.tryDefinition(n)?.fields?.shape,o=r&&Object.hasOwn(r,t)?I(r[t]):void 0;return o?.type==="enum"?o.options??[]:[]}var $=(e,n)=>Object.hasOwn(e,n)?e[n]:void 0;function Je(e,n,t){let r=o=>{let a=D(t,o.kind,n).indexOf(String($(o,n)));return a<0?Number.MAX_SAFE_INTEGER:a};return e.map((o,a)=>({node:o,i:a,rank:r(o)})).sort((o,a)=>o.rank-a.rank||o.i-a.i).map(o=>o.node)}function Xe(e,n,t,r){let o=e.some(i=>D(t,i.kind,n.by).length>0)?void 0:ue(n.by);if(o&&r)return Ze(e,o,n.headings,t,r);let a=[];for(let i of e)for(let s of D(t,i.kind,n.by))a.includes(s)||a.push(s);let d=[];for(let i of a){let s=e.filter(y=>$(y,n.by)===i);if(s.length===0)continue;let f=t.tryDefinition(s[0].kind);d.push({value:i,heading:n.headings[i]??J(x(f,n.by,i)),members:s})}let l=e.filter(i=>!a.includes(String($(i,n.by))));return l.length>0&&d.push({value:null,members:l}),d}function Ze(e,n,t,r,o){let a=u=>n.way??(Object.hasOwn(r.tryDefinition(u.kind)?.edges??{},n.edge)?"out":"in"),d=new Map,l=[],i=P(r),s;for(let u of e){let m=a(u)==="out"?o.out(u.id,n.edge):o.in(u.id,n.edge);m.length===0&&l.push(u);for(let c of m){s??=c.kind;let R=d.get(c.id)??{node:c,members:[]};R.members.push(u),d.set(c.id,R)}}let f=[...d.values()].map(({node:u,members:m})=>({value:u.id,heading:t[u.id]??i(u),members:m})).sort((u,m)=>u.heading.localeCompare(m.heading,void 0,{numeric:!0}));!s&&e[0]&&a(e[0])==="out"&&(s=(r.tryDefinition(e[0].kind)?.edges??{})[n.edge]?.to?.[0]);let y=s&&s!=="*"?Z(r.tryDefinition(s),s):void 0;return l.length>0&&f.push({value:null,...y?{heading:`No ${y}`}:{},members:l}),f}function je(e){return e.t==="list"||e.t==="headline"||e.t==="number"||e.t==="image"&&e.as==="gallery"?!0:e.t==="group"?e.blocks.some(je):e.t==="when"?e.show.some(je):!1}function Ee(e,n){let t=e.tryDefinition(n)?.fields?.shape??{},r={};for(let[o,a]of Object.entries(t)){let d=I(a);d&&(r[o]=d)}return r}var Be=new WeakMap;function U(e){let n=Be.get(e);return n||Be.set(e,n=ye(e)),n}function ze(e,n,t,r={}){let o=U(e),a={},d={},l=i=>{if(i instanceof j)return i.nodes.map(s=>l(s));if(Array.isArray(i))return i.map(s=>l(s));if(i!==null&&typeof i=="object"){let s=i;return{id:s.id,kind:s.kind,label:X(e.tryDefinition(s.kind),s)}}return i};for(let[i,s]of o.get(t?t.kind:ne)?.computed??[])try{let f=[],y=E(s,{graph:n,subject:t,kinds:o,...r.today?{today:r.today}:{},...r.budget?{budget:r.budget}:{},...r.linked?{linked:r.linked}:{},onUnread:u=>f.push(u)});f.length>0&&(y===null||y instanceof j&&y.nodes.length===0)?d[i]=ee(f[0]):a[i]=l(y)}catch(f){if(!(f instanceof re))throw f;d[i]=f.sentence}return{values:a,refused:d}}function Pn(e,n,t){let{values:r}=ze(e,n,t);if(Object.keys(r).length===0)return t;let o=a=>Array.isArray(a)?a.map(o):a!==null&&typeof a=="object"?a.label:a;return{...t,...Object.fromEntries(Object.entries(r).map(([a,d])=>[a,o(d)]))}}function vn(e,n){return[...fe(e.tryDefinition(n)).keys()]}var Ye=500,qe=2e4,Pe=new WeakMap;function Qe(e,n){let t=Pe.get(e);t||Pe.set(e,t=new Map);let r=t.get(n);return r||t.set(n,r=Ee(e,n)),r}function Vn(e,n,t,r={}){if(n&&typeof e.seenBy!="function")throw new TypeError("blockContextFor: a seat is read from a store (its `seenBy`); a bare { graph, schema } is read as it is handed, with no principal");let o=n?e.seenBy(n):e,a=n&&t?o.graph.getNode(t.id)??null:t,d=o.schema,l=a&&d.tryDefinition(a.kind),i=!a||(r.slot??"page")==="page",{money:s,firstHeading:f}=r;return{node:a,graph:o.graph,schema:d,kinds:U(d),fields:a?Qe(d,a.kind):{},definition:l||void 0,today:r.today??o.today?.()??H(s?.timeZone),money:s,heading:r.heading??(i?2:3),firstHeading:f,budget:r.budget??(i?qe:Ye),...i?{}:{glance:!0}}}export{we as a,tn as b,ve as c,on as d,Se as e,Ae as f,Oe as g,jn as h,je as i,U as j,ze as k,Pn as l,vn as m,Vn as n};