graview 0.1.62 → 0.1.64

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 (202) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +6 -6
  3. package/dist/index.js.map +1 -1
  4. package/dist/preview/chunk.2D7K2IJQ.js +4 -0
  5. package/dist/preview/{chunk.UFDJXQQQ.js → chunk.2DH42I7L.js} +6 -6
  6. package/dist/preview/chunk.2E62YCMZ.js +1 -0
  7. package/dist/preview/{chunk.GX4G4BX3.js → chunk.2G5WLG3Z.js} +1 -1
  8. package/dist/preview/chunk.2HV5FF6O.js +1 -0
  9. package/dist/preview/{chunk.LGRLVJGS.js → chunk.2JDAUKSN.js} +3 -3
  10. package/dist/preview/{chunk.ZN3PUM2I.js → chunk.2JEN2RCB.js} +1 -1
  11. package/dist/preview/{chunk.66P5IDTH.js → chunk.2TCOLAL2.js} +1 -1
  12. package/dist/preview/{chunk.OWOOKLIU.js → chunk.2V7QTIAV.js} +1 -1
  13. package/dist/preview/{chunk.IQ3PRWGO.js → chunk.2VIS2NAT.js} +2 -2
  14. package/dist/preview/{chunk.UQQKDBIH.js → chunk.2VYGDY5Z.js} +1 -1
  15. package/dist/preview/{chunk.WEOVK2T4.js → chunk.37I45R6V.js} +1 -1
  16. package/dist/preview/chunk.3FKKH2XU.js +74 -0
  17. package/dist/preview/chunk.3J7XLJP2.js +1 -0
  18. package/dist/preview/chunk.3OEODIHB.js +1 -0
  19. package/dist/preview/{chunk.WPXPVD33.js → chunk.3RD4JHVG.js} +1 -1
  20. package/dist/preview/{chunk.CHHYIMB7.js → chunk.3RUV4HE4.js} +1 -1
  21. package/dist/preview/chunk.3SAESG6X.js +1 -0
  22. package/dist/preview/{chunk.4HEFUOLV.js → chunk.47N2G7A5.js} +1 -1
  23. package/dist/preview/{chunk.A3ZC2JBO.js → chunk.4DZOAB4D.js} +1 -1
  24. package/dist/preview/chunk.4HTB6TX2.js +1 -0
  25. package/dist/preview/chunk.4Q5PCMGZ.js +18 -0
  26. package/dist/preview/{chunk.DPEIT3TW.js → chunk.4U45EY5M.js} +1 -1
  27. package/dist/preview/{chunk.2B6P4GPS.js → chunk.4VRX7FCO.js} +1 -1
  28. package/dist/preview/{chunk.JT3MFPRD.js → chunk.4XCYZRZ3.js} +1 -1
  29. package/dist/preview/chunk.52MBXPEK.js +1 -0
  30. package/dist/preview/chunk.5AD2QHWH.js +3 -0
  31. package/dist/preview/{chunk.MDEX6ZVE.js → chunk.5B7NG6WH.js} +1 -1
  32. package/dist/preview/chunk.5HJ2GTKZ.js +1 -0
  33. package/dist/preview/chunk.5IEZF433.js +2 -0
  34. package/dist/preview/{chunk.QGU5QTR6.js → chunk.5PPCK7QT.js} +1 -1
  35. package/dist/preview/chunk.6NRWLCIZ.js +5 -0
  36. package/dist/preview/chunk.75JQCTR6.js +1 -0
  37. package/dist/preview/{chunk.KMV6PJFL.js → chunk.77JI5T4F.js} +1 -1
  38. package/dist/preview/chunk.77MLXWZV.js +35 -0
  39. package/dist/preview/chunk.7AOEZJRM.js +1 -0
  40. package/dist/preview/{chunk.QIPASE42.js → chunk.7CLKGKSF.js} +1 -1
  41. package/dist/preview/{chunk.BZMQDEIY.js → chunk.7SRSE5IS.js} +1 -1
  42. package/dist/preview/{chunk.2GEJNG2U.js → chunk.7VAHHEDX.js} +1 -1
  43. package/dist/preview/{chunk.VJBBVLGZ.js → chunk.7ZG77OI3.js} +1 -1
  44. package/dist/preview/chunk.7ZHH7WBN.js +1 -0
  45. package/dist/preview/chunk.AJEK3I5X.js +6 -0
  46. package/dist/preview/chunk.APRWUIE3.js +1 -0
  47. package/dist/preview/{chunk.QHY5NVYH.js → chunk.APUQIELA.js} +1 -1
  48. package/dist/preview/{chunk.Y4FZKUOK.js → chunk.ATHLE33D.js} +1 -1
  49. package/dist/preview/chunk.B2YTHEX5.js +1 -0
  50. package/dist/preview/{chunk.ELOFPE25.js → chunk.B6JR7EQO.js} +1 -1
  51. package/dist/preview/{chunk.5ODHHH35.js → chunk.BN42H3C6.js} +1 -1
  52. package/dist/preview/{chunk.DD2NKFDX.js → chunk.BVIJXL4J.js} +1 -1
  53. package/dist/preview/{chunk.5HGD6OWL.js → chunk.CC7P435K.js} +2 -2
  54. package/dist/preview/{chunk.IQMD7DG3.js → chunk.CJHYGRWV.js} +1 -1
  55. package/dist/preview/chunk.CM65MCHA.js +1 -0
  56. package/dist/preview/{chunk.MYNMBOLD.js → chunk.D2XLECMP.js} +1 -1
  57. package/dist/preview/chunk.DJIF7IAQ.js +2 -0
  58. package/dist/preview/{chunk.G4ULQK64.js → chunk.DLWFULWE.js} +1 -1
  59. package/dist/preview/{chunk.QDWSU47A.js → chunk.DMENNIHT.js} +1 -1
  60. package/dist/preview/{chunk.L3WTKQQL.js → chunk.DN7UCBOA.js} +1 -1
  61. package/dist/preview/{chunk.22BZU7ME.js → chunk.DQAMVVE6.js} +1 -1
  62. package/dist/preview/chunk.DUP2CGVH.js +1 -0
  63. package/dist/preview/{chunk.TM4EPUNO.js → chunk.DYRULRFX.js} +1 -1
  64. package/dist/preview/{chunk.AFNSAQEQ.js → chunk.E4TXLT25.js} +1 -1
  65. package/dist/preview/{chunk.DDUCIUVW.js → chunk.F6BNFLQM.js} +1 -1
  66. package/dist/preview/chunk.FN34P4IS.js +1 -0
  67. package/dist/preview/{chunk.AJSUHPBE.js → chunk.FUPYIOXZ.js} +1 -1
  68. package/dist/preview/{chunk.7KVUUEZA.js → chunk.FXRYMT3U.js} +1 -1
  69. package/dist/preview/{chunk.DEAP3H2L.js → chunk.G5BVZLCM.js} +1 -1
  70. package/dist/preview/{chunk.Y2YYH3JN.js → chunk.G7YLK4PX.js} +1 -1
  71. package/dist/preview/chunk.GF62K25C.js +1 -0
  72. package/dist/preview/chunk.GFQPO3NC.js +1 -0
  73. package/dist/preview/{chunk.5STU3KYG.js → chunk.GH5UBSQI.js} +1 -1
  74. package/dist/preview/chunk.GHHKRFPD.js +1 -0
  75. package/dist/preview/{chunk.THVC2BEC.js → chunk.GP5DAA4P.js} +1 -1
  76. package/dist/preview/{chunk.VN23AGIY.js → chunk.HPG6CNKM.js} +1 -1
  77. package/dist/preview/chunk.HSJEOM3W.js +1 -0
  78. package/dist/preview/{chunk.H5S7OL2U.js → chunk.HZPRMHSL.js} +1 -1
  79. package/dist/preview/chunk.IQGSEAQ2.js +5 -0
  80. package/dist/preview/{chunk.PCDUV3WP.js → chunk.ITBG37WJ.js} +1 -1
  81. package/dist/preview/{chunk.SVPKUWZU.js → chunk.JHUCKEJS.js} +1 -1
  82. package/dist/preview/{chunk.H7N7WN4U.js → chunk.JOM6MFVE.js} +1 -1
  83. package/dist/preview/{chunk.DNVWSWL2.js → chunk.JS2UZYGB.js} +1 -1
  84. package/dist/preview/{chunk.7XLS6XTY.js → chunk.K2PXP5H6.js} +1 -1
  85. package/dist/preview/{chunk.6AKW7TXM.js → chunk.K54ISAXN.js} +1 -1
  86. package/dist/preview/{chunk.3FON2Y72.js → chunk.K5YFUMRS.js} +1 -1
  87. package/dist/preview/chunk.KHXRJLLU.js +50 -0
  88. package/dist/preview/chunk.KMIFSPGQ.js +1 -0
  89. package/dist/preview/chunk.L4V5VLSM.js +1 -0
  90. package/dist/preview/{chunk.T6WHGKWR.js → chunk.LDMBJC3B.js} +1 -1
  91. package/dist/preview/{chunk.PLTH2LW5.js → chunk.LTOQ22ZJ.js} +1 -1
  92. package/dist/preview/{chunk.UVA7AALY.js → chunk.M5VHUIDB.js} +1 -1
  93. package/dist/preview/chunk.N643PVQA.js +1 -0
  94. package/dist/preview/{chunk.FULEUL34.js → chunk.NGRL3QOI.js} +1 -1
  95. package/dist/preview/{chunk.OFWNMTGB.js → chunk.NRPBTV6O.js} +2 -2
  96. package/dist/preview/{chunk.N6EJXXQK.js → chunk.O7HHNQK4.js} +2 -2
  97. package/dist/preview/{chunk.5YAOKOGV.js → chunk.OW3M4OBN.js} +1 -1
  98. package/dist/preview/{chunk.2N4Z5K5S.js → chunk.OXFDB5BB.js} +1 -1
  99. package/dist/preview/{chunk.4TX6VCBT.js → chunk.P4TAX3HE.js} +1 -1
  100. package/dist/preview/{chunk.RYRQ66JN.js → chunk.P6FNJR6E.js} +1 -1
  101. package/dist/preview/chunk.PR74PGLC.js +1 -0
  102. package/dist/preview/{chunk.F7YXLYLX.js → chunk.PVDDSBRG.js} +1 -1
  103. package/dist/preview/{chunk.OUDATENL.js → chunk.QROPDEJF.js} +1 -1
  104. package/dist/preview/{chunk.I77ZGIFE.js → chunk.QRT6BZR6.js} +1 -1
  105. package/dist/preview/{chunk.OWT3VVOT.js → chunk.R5MLRKAO.js} +2 -2
  106. package/dist/preview/chunk.RDA35HZB.js +2 -0
  107. package/dist/preview/{chunk.ROZTJ6IY.js → chunk.REXU6ARY.js} +1 -1
  108. package/dist/preview/chunk.S6QZBWCJ.js +1 -0
  109. package/dist/preview/{chunk.MAKODQO3.js → chunk.S7SHWDPR.js} +1 -1
  110. package/dist/preview/{chunk.SWMDFXUX.js → chunk.SADHOSRC.js} +1 -1
  111. package/dist/preview/chunk.SJHUC4TL.js +1 -0
  112. package/dist/preview/chunk.SL5FXE3R.js +1 -0
  113. package/dist/preview/{chunk.X6KYRBL6.js → chunk.T4JP6BGP.js} +1 -1
  114. package/dist/preview/{chunk.TIALD6SC.js → chunk.T4TRJDBF.js} +1 -1
  115. package/dist/preview/{chunk.M4AYA2PL.js → chunk.TA2JTUNX.js} +1 -1
  116. package/dist/preview/{chunk.EVBCEEQ4.js → chunk.TMHVYI5R.js} +1 -1
  117. package/dist/preview/chunk.TOLW64EO.js +1 -0
  118. package/dist/preview/chunk.TP3PZRHE.js +1 -0
  119. package/dist/preview/{chunk.PZQNR4KZ.js → chunk.TQ2G4AM4.js} +1 -1
  120. package/dist/preview/{chunk.5J3O2FVG.js → chunk.TUR2DA2M.js} +1 -1
  121. package/dist/preview/{chunk.B23WZQXQ.js → chunk.TYIBLD2D.js} +1 -1
  122. package/dist/preview/{chunk.DC35FJAB.js → chunk.UD2GGG7L.js} +1 -1
  123. package/dist/preview/chunk.UDU545CL.js +1 -0
  124. package/dist/preview/{chunk.RPDH32XV.js → chunk.UDYFGYJP.js} +1 -1
  125. package/dist/preview/{chunk.SEHRPTNA.js → chunk.UJNLT3L6.js} +1 -1
  126. package/dist/preview/chunk.UN2IAA5R.js +1 -0
  127. package/dist/preview/chunk.VLX7YWVH.js +25 -0
  128. package/dist/preview/{chunk.T3UQ7ZQK.js → chunk.VT4YBFZL.js} +1 -1
  129. package/dist/preview/{chunk.ELTV44HU.js → chunk.VZAF3452.js} +2 -2
  130. package/dist/preview/{chunk.O2BHPYA4.js → chunk.WFCE7NLK.js} +2 -2
  131. package/dist/preview/{chunk.CY3ELWCM.js → chunk.WHX47OJM.js} +1 -1
  132. package/dist/preview/{chunk.NUWDMH47.js → chunk.WMARJ5E3.js} +1 -1
  133. package/dist/preview/chunk.WPQP54FM.js +1 -0
  134. package/dist/preview/{chunk.6JO5HQDR.js → chunk.WX23K7ZU.js} +1 -1
  135. package/dist/preview/{chunk.W4BKYSZX.js → chunk.X36BYTEG.js} +1 -1
  136. package/dist/preview/{chunk.AQRB7LDA.js → chunk.XCLW4GP7.js} +1 -1
  137. package/dist/preview/{chunk.DDO3GLEJ.js → chunk.XEG7ZDRG.js} +1 -1
  138. package/dist/preview/{chunk.ILIIBSGA.js → chunk.XIVELWAM.js} +1 -1
  139. package/dist/preview/{chunk.75GVFX7L.js → chunk.XJWKIXPV.js} +1 -1
  140. package/dist/preview/{chunk.O75HWF3F.js → chunk.XQ5RTPEF.js} +1 -1
  141. package/dist/preview/{chunk.NOGGSLVG.js → chunk.YEXFVDRA.js} +1 -1
  142. package/dist/preview/{chunk.UXMPFPFH.js → chunk.YIZPW7IK.js} +2 -2
  143. package/dist/preview/chunk.YLOGIJOH.js +1 -0
  144. package/dist/preview/chunk.YMXWS4XN.js +3 -0
  145. package/dist/preview/{chunk.Z2TDZSMN.js → chunk.YSBTE3PX.js} +1 -1
  146. package/dist/preview/{chunk.RD2X25XB.js → chunk.Z26T5E76.js} +1 -1
  147. package/dist/preview/{chunk.A3OL2BI2.js → chunk.Z4XGEV34.js} +1 -1
  148. package/dist/preview/chunk.ZA5TDCBC.js +1 -0
  149. package/dist/preview/chunk.ZNDVJGTY.js +1 -0
  150. package/dist/preview/chunk.ZQGLPP7A.js +1 -0
  151. package/dist/preview/index.html +53 -52
  152. package/dist/preview/page.js +2 -2
  153. package/dist/preview/splash.js +7 -6
  154. package/package.json +6 -6
  155. package/dist/preview/chunk.2AT3GRXM.js +0 -1
  156. package/dist/preview/chunk.4HRYB7HF.js +0 -1
  157. package/dist/preview/chunk.5MZYCELA.js +0 -6
  158. package/dist/preview/chunk.7M4HNKDR.js +0 -1
  159. package/dist/preview/chunk.7OBIBPYH.js +0 -1
  160. package/dist/preview/chunk.7V56P2A7.js +0 -1
  161. package/dist/preview/chunk.7YOAW7ED.js +0 -1
  162. package/dist/preview/chunk.ACTXR2MI.js +0 -3
  163. package/dist/preview/chunk.AI34V6WV.js +0 -74
  164. package/dist/preview/chunk.BLUKSGI4.js +0 -1
  165. package/dist/preview/chunk.CAKFNKN5.js +0 -1
  166. package/dist/preview/chunk.CGALLZ54.js +0 -1
  167. package/dist/preview/chunk.DHJ3FQTR.js +0 -1
  168. package/dist/preview/chunk.DZZL5IDD.js +0 -5
  169. package/dist/preview/chunk.H24OC6OE.js +0 -1
  170. package/dist/preview/chunk.H73ZPYUX.js +0 -1
  171. package/dist/preview/chunk.HANJZ6FA.js +0 -1
  172. package/dist/preview/chunk.HIMQ65QT.js +0 -1
  173. package/dist/preview/chunk.IQPILSV3.js +0 -18
  174. package/dist/preview/chunk.IYBEXENQ.js +0 -1
  175. package/dist/preview/chunk.J7Q2WAF4.js +0 -28
  176. package/dist/preview/chunk.JYFZCJ4N.js +0 -2
  177. package/dist/preview/chunk.KDXU5DT3.js +0 -1
  178. package/dist/preview/chunk.KL7E4YHJ.js +0 -1
  179. package/dist/preview/chunk.LAYQ5PFS.js +0 -1
  180. package/dist/preview/chunk.LTZUF5VG.js +0 -1
  181. package/dist/preview/chunk.M7RESZB6.js +0 -25
  182. package/dist/preview/chunk.MGALQLRW.js +0 -1
  183. package/dist/preview/chunk.NAD7ZXYP.js +0 -1
  184. package/dist/preview/chunk.NHTGAP3G.js +0 -3
  185. package/dist/preview/chunk.NUYA4BWI.js +0 -1
  186. package/dist/preview/chunk.OKZT2QBM.js +0 -2
  187. package/dist/preview/chunk.OUPURRDE.js +0 -1
  188. package/dist/preview/chunk.PD2DECOP.js +0 -1
  189. package/dist/preview/chunk.PKWQKFPE.js +0 -2
  190. package/dist/preview/chunk.RMR24LFJ.js +0 -4
  191. package/dist/preview/chunk.RRKI24WY.js +0 -1
  192. package/dist/preview/chunk.SGCW2XRC.js +0 -1
  193. package/dist/preview/chunk.SS7234R6.js +0 -1
  194. package/dist/preview/chunk.TKUNRFDE.js +0 -1
  195. package/dist/preview/chunk.U6ZRJKVM.js +0 -1
  196. package/dist/preview/chunk.UKQUUPKE.js +0 -1
  197. package/dist/preview/chunk.VACKSKGJ.js +0 -1
  198. package/dist/preview/chunk.VC3V7HLL.js +0 -1
  199. package/dist/preview/chunk.VIH5AX7S.js +0 -5
  200. package/dist/preview/chunk.WKI5INH7.js +0 -1
  201. package/dist/preview/chunk.Y4S7CDRB.js +0 -1
  202. package/dist/preview/chunk.YP2QSPXU.js +0 -50
@@ -1,4 +0,0 @@
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};
@@ -1 +0,0 @@
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 +0,0 @@
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};
@@ -1 +0,0 @@
1
- import{a as U,b as Y,c as G,d as D}from"./chunk.RPDH32XV.js";import"./chunk.AI34V6WV.js";import"./chunk.G4ULQK64.js";import{G as ae,O as L,P as F,T as V,ca as _}from"./chunk.M7RESZB6.js";import"./chunk.SDO3U72B.js";import{W as H,ab as K,bb as B,id as M}from"./chunk.DZZL5IDD.js";import"./chunk.FQLNBIQ5.js";import{b as R}from"./chunk.AJZBJBMO.js";function O(n,t){let r=K(n);return r==="agent"?"agent":r!=="human"&&r!=="visitor"?"app":n.onBehalfOf!==void 0?"person":n.id===void 0||t?.id===void 0||n.id===t.id?"you":"person"}var re=n=>n.ops.filter(t=>t.withheld!==!0);function X(n,t={}){let r=[];for(let e of n.batches()){let s=e.ops[0],d=e.ops.at(-1),l=re(e).length===0,h=l?void 0:Y(e.ops),c=r.at(-1);if(h&&c?.typed&&c.author&&U(c.author,e.author)&&c.typed.node===h.node&&c.typed.field===h.field){let S=G(c.typed,h);r[r.length-1]={...c,seq:d.seq+1,at:d.at,batch:e.id,batches:[...c.batches??[],e.id],typed:S,said:D(S,n.schema,n.graph,!1)};continue}r.push({seq:d.seq+1,from:s.seq,at:d.at,batch:e.id,maker:l?"person":O(e.author,t.me),author:l?void 0:e.author,said:h?D(h,n.schema,n.graph,!1):e.intent,declaration:!1,withheld:l,...h?{batches:[e.id],typed:h}:{}})}let i=[...n.log.epochs().filter(e=>e.change!==void 0).map(e=>({seq:e.seq,sentence:e.change,...e.at?{at:e.at}:{}})),...t.declarations??[]];for(let e of i){if(e.seq<n.log.horizon||e.seq>n.log.length)continue;let s=r.findIndex(d=>d.seq===e.seq);if(s>=0&&!r[s].withheld){r[s]={...r[s],declaration:!0,said:e.sentence};continue}r.push({seq:e.seq,from:e.seq,at:e.at,batch:void 0,maker:e.author?O(e.author,t.me):"app",author:e.author,said:e.sentence,declaration:!0,withheld:!1})}return r.sort((e,s)=>e.seq-s.seq||+(e.batch!==void 0)-+(s.batch!==void 0))}function J(n,t){let r=n.log.all(),i=new Map(r.map(e=>[e.id,e.seq]));return n.batches().filter(e=>!e.undone&&e.ops[0].seq>=t).filter(e=>!e.ops.every(s=>s.undoes!==void 0&&(i.get(s.undoes)??-1)>=t)).map(e=>e.id)}function Q(n,t){return n.withheld?"Someone":n.maker==="you"?"you":n.author?B(n.author,t):"the app"}var p=R(ae(),1);var o=R(V(),1),oe={kind:"human"},ie=[1,2,4,8],se=900,E={you:"You",person:"A person",agent:"An agent",app:"The app"},Z={you:"var(--graview-accent)",person:"var(--graview-ink-muted)",agent:"var(--graview-activity, var(--graview-good))",app:"var(--graview-edge-bright)"};function de(n,t,r){return[...new Set([...r,t,...n.map(i=>i.seq)])].sort((i,e)=>i-e)}function le(n,t){let r=n.withheld===!0;return{seq:n.seq+1,from:n.seq,at:n.at,batch:n.batch,maker:r?"person":O(n.author,t),author:r?void 0:n.author,said:n.batchIntent??n.intent,declaration:!1,withheld:r}}function ce(n,t){let r=0;for(let i=0;i<n.length;i++)n[i]<=t&&(r=i);return r}function pe(n,t,r){let i=J(n,t);if(i.length===0)return null;let e=n.canUndo(i);if(!e.ok)return null;let s=new Set(n.permittedMutations(r).map(d=>d.name));return e.ops.every(d=>d.mutation!==null&&s.has(d.mutation.name))?i:null}function we({face:n}){let t=L(),r=_(),i=r?.principal??oe,e=F(t.live,i),s=e.log.length,d=(0,p.useMemo)(()=>X(e,{me:i,...t.host?.declarations?{declarations:t.host.declarations}:{}}),[e,i,t.host,s]),l=e.log.horizon,h=l>0&&t.host?.archived!==void 0,c=t.kept,S=(0,p.useMemo)(()=>h?c?.stops??Array.from({length:l},(a,g)=>g):[],[h,c,l]),m=(0,p.useMemo)(()=>de(d,l,S),[d,l,S]),f=t.archive,y=f?.seq??t.past?.seq??s,x=t.host?.kept&&(f?.behindKept||c!==void 0&&(y<=c.through||c.from>0&&y<=c.from))?t.host.kept:void 0,w=ce(m,y),b=m.length-1,j=y<l&&t.past?.seq===y?t.past.store.log.all().at(-1):void 0,q=j?le(j,i):y<l?void 0:[...d].reverse().find(a=>a.seq<=y&&a.seq>(m[w-1]??-1))??[...d].reverse().find(a=>a.seq<=y),[k,A]=(0,p.useState)(!1),[T,ee]=(0,p.useState)(1),[C,W]=(0,p.useState)(null);(0,p.useEffect)(()=>{if(!k)return;if(w>=b){A(!1);return}let a=setTimeout(()=>t.show(m[w+1]),se/T);return()=>clearTimeout(a)},[k,w,b,T,m,t]);let z=(0,p.useMemo)(()=>t.past&&!f&&y>=l?pe(e,y,i):null,[t.past,f,e,y,l,i,s]),N=a=>Q(a,{graph:e.graph,schema:e.schema,...r?.seats?{seats:r.seats}:{},...r?.people?{people:r.people}:{}}),v=t.past?t.past.at?H(t.past.at,r?.locale):"the start":null,$=f?f.refused?"The archive could not be read":f.behindKept?"Nothing this far back is kept":"Reading the older changes from the archive\u2026":q?`${N(q)==="you"?"You":N(q)}: ${q.said}`:"Nothing had happened yet",I=(0,p.useRef)(null);(0,p.useLayoutEffect)(()=>{let a=I.current,g=a?.parentElement;if(n!=="scene"||!a||!g)return;let u=()=>g.style.setProperty("--graview-sheet",`${Math.ceil(a.getBoundingClientRect().height)+24}px`);u();let P=typeof ResizeObserver>"u"?null:new ResizeObserver(u);return P?.observe(a),()=>{P?.disconnect(),g.style.removeProperty("--graview-sheet")}},[n]);let te=n==="scene"?{position:"absolute",left:"50%",bottom:12,transform:"translateX(-50%)",width:"min(720px, calc(100% - 32px))",zIndex:M("rail")}:{position:"sticky",top:0,zIndex:M("rail"),margin:"0 auto 12px",maxWidth:960,width:"100%"};return(0,o.jsxs)("section",{ref:I,"aria-label":"Timeline","data-testid":"timeline","data-graview-past":t.past?String(t.past.seq):"now","data-graview-offstage":"",style:{...te,boxSizing:"border-box",display:"grid",gap:8,padding:"10px 12px",borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)",color:"var(--graview-ink)",fontSize:"0.8125rem"},children:[(0,o.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"4px 12px"},children:[(0,o.jsx)("strong",{"data-testid":"as-of",role:"status",style:{fontWeight:600},children:f?"Archived changes":v?`As of ${v}`:"Now"}),(0,o.jsx)("span",{"data-testid":"timeline-caption",style:{color:"var(--graview-ink-muted)",minWidth:0,overflowWrap:"anywhere"},children:$}),v?(0,o.jsx)("span",{style:{color:"var(--graview-ink-faint)"},"data-testid":"past-read-only",children:"Nothing changes while you look back."}):null]}),(0,o.jsxs)("div",{style:{position:"relative",height:22},"aria-hidden":"true",children:[h?(0,o.jsx)("span",{"data-testid":"timeline-archived",title:"Changes read from the archive as you scrub back",style:{position:"absolute",left:0,bottom:0,height:6,width:`${b===0?0:m.indexOf(l)/b*100}%`,borderRadius:2,background:"var(--graview-edge)"}}):null,m.slice(1).map((a,g)=>{let u=[...d].reverse().find(ne=>ne.seq===a);if(!u)return null;let P=b===0?0:(g+1)/b*100;return(0,o.jsx)("span",{"data-graview-tick":a,"data-maker":u.maker,...u.declaration?{"data-declaration":""}:{},title:`${E[u.maker]}: ${u.said}`,style:{position:"absolute",left:`calc(${P}% - 1px)`,bottom:0,width:u.declaration?4:2,height:u.declaration?22:12,borderRadius:2,background:u.declaration?"var(--graview-ink)":Z[u.maker],opacity:a<=y?1:.45}},`${a}:${u.batch??"declaration"}`)})]}),(0,o.jsx)("input",{type:"range","data-testid":"scrubber","aria-label":"Moment",min:0,max:b,step:1,value:w,"aria-valuetext":v?`As of ${v}. ${$}`:`Now. ${$}`,onChange:a=>{A(!1),t.show(m[Number(a.currentTarget.value)]??s)},style:{width:"100%",margin:0,accentColor:"var(--graview-accent)"}}),(0,o.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:8},children:[(0,o.jsx)("button",{type:"button","data-testid":"play","aria-pressed":k,onClick:()=>{!k&&w>=b&&t.show(m[0]),A(!k)},style:{minHeight:28,minWidth:64},children:k?"Pause":"Play"}),(0,o.jsxs)("label",{style:{display:"inline-flex",alignItems:"center",gap:6,color:"var(--graview-ink-muted)"},children:["Speed",(0,o.jsx)("select",{"data-testid":"speed",value:T,onChange:a=>ee(Number(a.currentTarget.value)),style:{minHeight:28},children:ie.map(a=>(0,o.jsxs)("option",{value:a,children:[a,"\xD7"]},a))})]}),(0,o.jsx)("span",{"aria-hidden":"true",style:{display:"inline-flex",gap:10,color:"var(--graview-ink-faint)",flexWrap:"wrap"},children:Object.keys(E).filter(a=>d.some(g=>g.maker===a)).map(a=>(0,o.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[(0,o.jsx)("span",{style:{width:8,height:8,borderRadius:2,background:Z[a]}}),E[a]]},a))}),(0,o.jsxs)("span",{style:{marginLeft:"auto",display:"inline-flex",gap:8},children:[z?(0,o.jsx)("button",{type:"button","data-testid":"restore-here",title:"Take back every change since, as one change you can undo",onClick:()=>{W(null);try{e.undo([...z],{author:i,intent:v?`Restore to ${v}`:"Restore"}),t.show(null)}catch(a){W(a instanceof Error?a.message:String(a))}},style:{minHeight:28},children:"Restore to here"}):null,(0,o.jsx)("button",{type:"button","data-testid":"back-to-now",onClick:()=>t.show(null),style:{minHeight:28},children:"Back to now"})]})]}),C?(0,o.jsx)("span",{role:"alert","data-testid":"restore-refused",style:{color:"var(--graview-warn)"},children:C}):null,f?.refused?(0,o.jsx)("span",{role:"alert","data-testid":"archive-refused",style:{color:"var(--graview-warn)"},children:f.refused}):null,x?(0,o.jsxs)("span",{"data-testid":"timeline-kept",style:{color:"var(--graview-ink-faint)"},children:[x.sentence,x.action?(0,o.jsxs)(o.Fragment,{children:[" ",(0,o.jsx)("a",{"data-testid":"timeline-kept-action",href:x.action.href,style:{color:"var(--graview-ink-muted)"},children:x.action.label})]}):null]}):null,l>0&&!h?(0,o.jsx)("span",{"data-testid":"timeline-horizon",style:{color:"var(--graview-ink-faint)"},children:"The changes before the timeline's start were archived."}):null]})}export{we as Timeline};
@@ -1 +0,0 @@
1
- function k(e){let t=e+1;return t*t-b(t).length}function b(e){if(e<3)return[];if(e%2===1){let i=(e-1)/2;return[[i,i]]}let t=e/2-1,r=e/2;return[[t,t],[r,t],[t,r],[r,r]]}function x(e){let t=2166136261;for(let r=0;r<e.length;r++)t=Math.imul(t^e.charCodeAt(r),16777619);return(t>>>0)%1e3/1e3}function O(e,t){let r=e.side+1,i=new Set(b(r).map(([o,n])=>`${o},${n}`)),c=e.side/r,d=[];for(let o=0;o<r;o++)for(let n=0;n<r;n++)i.has(`${n},${o}`)||d.push([n,o]);d.sort((o,n)=>o[0]+o[1]-(n[0]+n[1])||o[0]-n[0]);let a=t.slice(0,d.length);return{buildings:a.map((o,n)=>{let[m,u]=d[n];return{id:o,col:e.col+(m+.5)*c,row:e.row+(u+.5)*c,footprint:c*.62,height:.55+x(o)*.7}}),rest:Math.max(0,t.length-a.length)}}var w={done:.12,waiting:.55,active:1.05};function S(e,t,r=[]){let i=e.side,c=i/Math.max(1,t.length),d=Math.max(1,...t.map(s=>s.length)),a=c;for(let s=1;c/s>=i/8-1e-9&&(a=c/s,!(s*Math.floor(i/a+1e-9)>=d));s++);let y=Math.max(1,Math.floor(c/a+1e-9)),o=Math.max(1,Math.floor(i/a+1e-9)),n=i/o,m=[],u=[];return t.forEach((s,l)=>{let f=s.slice(0,y*o);if(f.forEach((M,p)=>{m.push({id:M,lane:l,col:e.col+(p%o+.5)*n,row:e.row+l*c+(Math.floor(p/o)+.5)*a,footprint:Math.min(n,a)*.66,height:r[l]??w.waiting})}),s.length<=f.length)return;let h=u[0],g=s.length-f.length;h?u[0]={...h,count:h.count+g,rows:h.rows+1}:u.push({lane:l,count:g,rows:1,col:e.col-.15,row:e.row+(l+.5)*c})}),m.sort((s,l)=>s.col+s.row-(l.col+l.row)||s.col-l.col),{blocks:m,rests:u}}export{k as a,x as b,O as c,w as d,S as e};
@@ -1 +0,0 @@
1
- import{$ as E,Cc as x,Fc as D,L as j,R as N,U as B,Y as b,lb as K,mb as m,pa as $,qc as O,tc as L,uc as _,vb as W,wc as F,xc as I,zb as C}from"./chunk.DZZL5IDD.js";import{j as f}from"./chunk.FQLNBIQ5.js";var G=e=>W(e).id??e.session;function T(e){let o=O(e),n=new Map;for(let t of e){if(t.vote===void 0||t.withheld||o.has(t.id))continue;let i=G(t.author);if(i===void 0)continue;let s=n.get(t.vote.suggestion);s||n.set(t.vote.suggestion,s=new Map),t.vote.vote===null?s.delete(i):s.set(i,t.vote.vote)}return n}function U(e,o){let n=0,t=0;for(let r of e?.values()??[])r==="for"?n++:t++;let i=o&&G(o),s=i!==void 0?e?.get(i):void 0;return{for:n,against:t,...s!==void 0?{mine:s}:{}}}var k=(e,o)=>e.expiresAt!==void 0&&Date.parse(e.expiresAt)<=Date.parse(o),X=(e,o,n)=>(e??[]).some(t=>t.suggestion===o&&(t.until===void 0||Date.parse(t.until)>Date.parse(n)));function Y(e,o=()=>!0,n={}){let t=O(e),i=new Set(e.map(a=>a.lineage?.suggestion)),s=n.now??new Date().toISOString(),r;return e.filter(a=>a.suggests&&!a.withheld&&!t.has(a.id)&&!i.has(a.id)&&!k(a,s)&&!X(n.dismissed,a.id,s)).map(({id:a,batch:l,suggests:d,intent:g,author:u,lineage:c,at:h,expiresAt:p})=>{let R=new Set;return JSON.stringify(d.map(V=>V.args),(V,A)=>(typeof A=="string"&&o(A)&&R.add(A),A)),{id:a,batch:l,calls:d,intent:g,author:u,...c?{lineage:c}:{},at:h,expiresAt:p,about:[...R],tally:U((r??=T(e)).get(a),n.voter)}})}function q(e,o){return e.ops.length>0&&e.ops.every(n=>n.suggests!==void 0||n.undoes!==void 0&&o(n.undoes)?.suggests!==void 0)}var P=e=>[...e].length;function Z(e){let o,n=0,t=0;for(let i of e.ops){let s=i.mutation?.name===C&&i.withheld!==!0&&i.undoes===void 0?i.mutation.args:void 0;if(typeof s?.node!="string"||typeof s.field!="string"||o&&(o.node!==s.node||o.field!==s.field))return;o={node:s.node,field:s.field};for(let r of i.primitives)r.op==="splice-text"?(n+=P(r.inserted),t+=P(r.removed)):r.op==="patch-node"&&typeof r.after[s.field]=="string"&&(n+=P(r.after[s.field]))}return o&&{...o,inserted:n,removed:t}}function H(e,o,n){let t=n.getNode(e.node)?.kind,i=[...e.inserted>0||e.removed===0?[`+${e.inserted}`]:[],...e.removed>0?[`\u2212${e.removed}`]:[]];return`Wrote in ${$(t?o.tryDefinition(t):void 0,e.field)} (${i.join(" ")})`}var S=e=>JSON.stringify([e.kind,e.id??"",e.name??""]),Q=e=>e.ops.find(o=>o.lineage?.run!==void 0)?.lineage?.run;function ee(e,o=()=>{}){let n=[];for(let t of e){if(q(t,o))continue;if(!x(t.author)){let g=Z(t),u=n.at(-1),c=g&&u&&"batch"in u&&S(u.batch.author)===S(t.author)&&u.typed?.node===g.node&&u.typed.field===g.field?u.typed:void 0;c?n[n.length-1]={batch:t,typed:{...c,batches:[...c.batches,t],inserted:c.inserted+g.inserted,removed:c.removed+g.removed}}:n.push(g?{batch:t,typed:{batches:[t],...g}}:{batch:t});continue}let i=Q(t),s=S(t.author),r=i!==void 0?n.findIndex(g=>"digest"in g&&g.digest.run===i&&S(g.digest.author)===s):n.length-1,a=n[r],l=a!==void 0&&"digest"in a&&S(a.digest.author)===s&&a.digest.run===i?a.digest:void 0,d=[...l?.batches??[],t];l&&n.splice(r,1),n.push({digest:{author:t.author,batches:d,things:ne(d),at:t.at,...i!==void 0?{run:i}:{}}})}return n}var ne=e=>e.reduce((o,n)=>o+(n.undone?0:n.ops.length),0),te=e=>{let o=Date.parse(e);if(Number.isNaN(o))return!1;let{minutes:n}=B(o,N());return n<6*60||n>=21*60};function ie(e,o=b(new Date().toISOString())??j()){let n=b(e.at)??e.at.slice(0,10),i=e.run!==void 0&&n===o&&[e.at,...(e.batches??[]).map(s=>s.at)].every(te)?"overnight":n===o?"today":`on ${E(n)}`;return`Tidied ${e.things===1?"one thing":`${e.things} things`} ${i}`}var y=e=>e,w=(e,o)=>o===void 0?{}:{[e]:o};function we(e,o,n){let t=f(e)?.store??e,i=y(t),s=_(n.lineage);if(s===void 0)throw new m("A suggestion says what it is based on: { basis, confidence? }");let r=n.author??i.by;if(n.expiresAt!==void 0&&Number.isNaN(Date.parse(n.expiresAt)))throw new m(`A suggestion expires at a time: "${n.expiresAt}" is not one (an ISO time, like 2026-10-23T06:00:00Z).`);let a=i.actMeanings(),l=D(o,a),d=M(t).find(p=>D(p.calls,a)===l);if(d)return t.log.get(d.id);i.refuseDeclined(o,r);let g=i.rehearsal();g.suggesting=!0;let u=g.applying(o,{author:r,lineage:s,...w("via",n.via)});if(u.ops.length===0)return;let c=[...new Set(u.ops.flatMap(p=>p.described??[]))],h={id:i.nextId(),seq:t.log.length,batch:i.mintBatch("batch"),author:r,intent:u.ops.map(p=>p.intent).join("; "),...w("batchIntent",n.intent),mutation:null,primitives:[],reads:[],writes:[],...c.length>0?{described:c}:{},at:i.now(),...w("via",n.via),lineage:s,suggests:o,...w("expiresAt",n.expiresAt)};return t.log.append(h),t.notify(K,[h]),h}function M(e,o,n={}){let t=f(e),i=t?.store??e,s=o??t?.principal,r=(s!==void 0?i.seenBy(s):i).log.all();return Y(r,a=>i.graph.has(a),{now:y(i).now(),dismissed:n.dismissed,voter:s})}function J(e,o,n){let t=f(e),i=t?.store??e,s=n??t?.principal??y(i).by;return o.calls.every(r=>i.permits(r,s).ok)}function z(e,o,n,t={}){let i=f(e)?.store??e,s=t.author??y(i).by;v(i,o,s);let r=i.applyAll([{name:F,args:{suggestion:o,vote:n}}],{...t,author:s});return n===null?r:{...r,voted:n}}function v(e,o,n){let t=M(e,n).find(s=>s.id===o),i=t?void 0:e.log.get(o);if(i?.suggests&&k(i,y(e).now()))throw new m(`That suggestion expired on ${i.expiresAt.slice(0,10)}.`);if(!t)throw new m("That suggestion is no longer waiting: it was accepted or declined, or it is not one you can see.");return t}function ve(e,o,n={}){let t=f(e)?.store??e,i=n.author??y(t).by,s=v(t,o,i);return J(t,s,i)?t.applyAll(s.calls,{...n,author:i,lineage:{...s.lineage,suggestion:o}}):z(t,o,"for",{...n,author:i})}function be(e,o,n={}){let t=f(e)?.store??e,i=n.author??y(t).by,s=v(t,o,i);return J(t,s,i)?t.undo(s.batch,{...n,author:i}):z(t,o,"against",{...n,author:i})}var oe={kind:"system",id:"tidying",name:"Graview, tidying",automated:!0};I.op=(e,o,n,t,i,s)=>{let r=e,{suggestion:a,vote:l}=n.args,d=v(r,a,i),g=l==="for"?`For: ${d.intent}`:l==="against"?`Against: ${d.intent}`:`Withdraws a vote on: ${d.intent}`;return{id:o.id,seq:r.log.length,batch:t,author:i,intent:g,mutation:n,primitives:[],reads:[],writes:[],...d.about.length>0?{described:d.about}:{},at:o.at,...s.via!==void 0?{via:s.via}:{},vote:{suggestion:a,vote:l}}};I.accepting=(e,o)=>{let n=e,t=n.tidying?.autoAcceptAt;if(t===void 0||o.vote?.vote!=="for")return;let i=o.vote.suggestion,s=M(n).find(d=>d.id===i);if(!s)return;let a=[...T(n.log.all()).get(i)??[]].filter(([,d])=>d==="for").map(([d])=>d);if(a.length<t)return;let l=x(s.author)?s.author:oe;return{calls:s.calls,author:l,lineage:{...s.lineage,suggestion:i,voters:a.slice(0,L)}}};export{H as a,ee as b,ie as c,we as d,M as e,J as f,z as g,ve as h,be as i};
@@ -1 +0,0 @@
1
- import{l as O}from"./chunk.OJGHDWI6.js";import{j as C}from"./chunk.OKZT2QBM.js";import{G as b,La as K,T as M,ba as w,c as W,ca as I,da as H,x as G}from"./chunk.M7RESZB6.js";import{$b as L,C as D,Kb as N,Tb as _,dd as V,ed as B,kc as j,vb as F}from"./chunk.DZZL5IDD.js";import{b as m}from"./chunk.AJZBJBMO.js";function U(n,e){let t=n.graph.getNode(e);if(!t)return[];let i=t.kind,a=n.schema.tryDefinition(i);if(!a)return[];let c=n.seenFor,u=c?N.keptFrom?.(n,c)?.(t):void 0,o=new Map;for(let r of n.allMutations()){let s=r.subject;if(!s||!(s.kinds==="*"||s.kinds.includes(i)))continue;let l=r.input.shape??{};for(let d of j(r,a)){if(u?.(d)||!_(r,n.schema,n.graph,e,d,c&&F(c).id))continue;let x=d in l,k=[];for(let h of Object.keys(l)){if(h===s.arg||h===d||ee(l[h]))continue;let v=L(r.input).find(S=>S.name===h);k.push({name:h,...v?{kinds:v.kinds}:{},...v?{candidates:v.kinds.includes("*")?n.graph.allNodes().map(S=>S.id):v.kinds.flatMap(S=>n.graph.nodesOfKind(S).map(Z=>Z.id))}:{},shape:C(r.input,h)})}let X={field:d,mutation:r.name,title:r.title??r.name,shape:x?C(r.input,d):{type:"unknown"},takesValue:x,alternatives:[],open:k,clearable:x&&(r.clearable?.includes(d)??!1),call:h=>({name:r.name,args:x?{[s.arg]:e,[d]:h}:{[s.arg]:e}})};o.set(d,[...o.get(d)??[],X])}}return[...o.values()].map(r=>{let s=[...r.filter(d=>d.takesValue),...r.filter(d=>!d.takesValue)],[f,...l]=s;return{...f,alternatives:l}})}function ee(n){let e=D(n)?.type;return e==="optional"||e==="default"||e==="nullable"}var R=m(b(),1);function Se(n){let{store:e,principal:t}=w(),i=H(),a=(0,R.useMemo)(()=>n===null?[]:U(e,n),[e,n,i]),c=(0,R.useCallback)((u,o,r={})=>{let s=u.call(o);e.apply({name:s.name,args:{...s.args,...r}},{author:t})},[e,t]);return{fields:a,commit:c}}var $=m(b(),1);function Xe(){let{brand:n}=w(),e=n?.kit;return(0,$.useMemo)(()=>V(e),[e])}function Ze(n,e){let t=B(n,e),i={...t.color!==void 0?{color:t.color}:{},...t.pattern!==void 0?{pattern:t.pattern}:{},...t.width!==void 0?{width:t.width}:{},...t.cap!==void 0?{cap:t.cap}:{},...t.opacity!==void 0?{opacity:t.opacity}:{}};return{connector:t,style:O(e,{[e]:i})}}var q=m(b(),1);var g=m(M(),1);function ne(n){let e=n?.hint;return typeof e=="string"&&e.length>0?e:void 0}function te(n){if(n instanceof Error&&n.message)return n.message;let e=String(n);return e==="[object Object]"?"The view threw without a message.":e}var z=class extends q.Component{static contextType=K;state={};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[graview] the ${this.props.view??"view"} of ${this.props.kind} threw while rendering`,e,t.componentStack),this.context?.(e,{module:"@graview/react"})}render(){let{error:e}=this.state;if(!e)return this.props.children;let t=ne(e);return(0,g.jsxs)("div",{role:"alert","data-graview-view-error":this.props.kind,style:{display:"flex",flexDirection:"column",gap:"0.375rem",padding:"var(--graview-pad, 12px)",height:"100%",overflow:"auto",boxSizing:"border-box",borderRadius:"var(--graview-radius-sm, 6px)",background:"var(--graview-panel-warning, #fdf3ec)",color:"var(--graview-ink, #1a1a1a)",font:"var(--graview-font-body, 13px/1.45 system-ui)",fontSize:"0.875rem",lineHeight:1.45},children:[(0,g.jsx)("strong",{style:{color:"var(--graview-warn, #b4462a)"},children:this.props.view?`${this.props.view} could not draw`:"This view could not draw"}),(0,g.jsx)("span",{style:{color:"var(--graview-ink-muted, #555)"},children:this.props.kind}),(0,g.jsx)("span",{children:te(e)}),t?(0,g.jsx)("span",{style:{color:"var(--graview-ink-muted, #555)"},children:t}):null]})}};var y=m(b(),1);var Q=m(M(),1),A=(0,y.createContext)([]);function on({sections:n,children:e}){let t=(0,y.useContext)(A),i=(0,y.useMemo)(()=>[...t,...n.filter(a=>!t.includes(a))],[t,n]);return(0,Q.jsx)(A.Provider,{value:i,children:e})}function Y(){let n=(0,y.useContext)(A),e=I()?.menuSections;return(0,y.useMemo)(()=>e?[...n,...e.filter(t=>!n.includes(t))]:n,[n,e])}function an(){let n=Y();return(0,y.useCallback)(e=>{for(let t of n)try{t(e)?.prepare?.()}catch{}},[n])}function sn(n){let e=Y();if(n===null||e.length===0)return{start:[],end:[]};let t=e.flatMap(i=>{try{let a=i(n);return a&&((a.items?.length??0)>0||a.render)?[a]:[]}catch{return[]}});return{start:t.filter(i=>i.at==="start"),end:t.filter(i=>i.at!=="start")}}var re=m(b(),1);function un(){return w().activity}var P=(n,e)=>n.length*e*.58;var oe=156,ie=2,E=oe-18,ae=7.1,se=16;function ce(n,e){let t=0,i=E;for(let a of n.split(" ")){let c=e(a),u=i+e(" ")+c;if(u<=E)i=u;else{let o=Math.ceil(c/E)||1;t+=o,i=c-(o-1)*E}}return t}var de=16.25,J=27,ue=(n,e)=>{let t=Math.ceil(n.length*ae/E);return e?Math.max(J,Math.ceil(Math.max(t,ce(n,e))*de)+6):Math.max(J,t*se+6)};function fn(n,e,t){return n.length===0?0:10+n.reduce((i,a)=>i+ue(a,t),0)+(n.length-1)*ie}var le=27,pe=8,mn=4,fe=64,yn=n=>Math.max(1,Math.min(pe,n)),hn=n=>n*le+fe;var p=m(b(),1);function wn(n,{units:e,target:t=0,legibleAt:i=260}){let[a,c]=(0,p.useState)(e);(0,p.useEffect)(()=>{let o=n.current;if(o===null||typeof ResizeObserver>"u")return;let r=new ResizeObserver(([s])=>{let f=s?.contentRect.width??0;f>0&&c(f)});return r.observe(o),()=>r.disconnect()},[n]);let u=a/e;return{scale:u,width:a,touchable:u*t>=24,legible:a>=i}}function vn(n="--graview-font-body",e="sans-serif"){let t=(0,p.useRef)(void 0),i=(0,p.useMemo)(()=>{if(typeof getComputedStyle!="function"||typeof document>"u")return e;let a=getComputedStyle(document.documentElement).getPropertyValue(n).trim();return a.length>0?a:e},[n,e]);return(0,p.useMemo)(()=>{t.current===void 0&&(t.current=typeof document>"u"?null:document.createElement("canvas").getContext("2d")??null);let a=t.current;return a===null?P:(c,u)=>{a.font=`${u}px ${i}`;let o=a.measureText(c).width;return o>0?o:P(c,u)}},[i])}var Sn=(0,p.createContext)(void 0);var T=3;function me(n){let e=W(n),t=e.focusId;if(!t)return null;if(e.within?.view){let[a]=G(t);if(a)return{at:`screen:${a}`,audience:!0}}return{at:t,audience:!1}}var ye=102,he=32;function Mn(n,e,t){let i=[],a=new Map,c=new Map,u=0;for(let o of n){let r=me(o.stop),s=r?e(r.at):null;if(!r||!s){o.name&&i.push({kind:"edge",presence:o,point:{x:t-8,y:ye+u++*he}});continue}if(!o.name){let k=c.get(r.at);c.set(r.at,{n:(k?.n??0)+1,box:s});continue}let f=a.get(r.at)??[];if(f.push(o),a.set(r.at,f),f.length>T)continue;let l=s,d=f.length-1,x=r.audience?{x:l.x+l.width*.5+(d-1)*26,y:l.y+Math.min(l.height,24)}:{x:l.x+l.width*.5-26-d*26,y:l.y+l.height-4};i.push({kind:"person",presence:o,point:x,at:r.at,index:d,of:f.length,audience:r.audience})}for(let[o,r]of a){if(r.length<=T)continue;let s=e(o);s&&i.push({kind:"count",at:o,point:{x:s.x+s.width*.5+2*26+18,y:s.y+s.height-4},n:r.length-T})}for(let[o,{n:r,box:s}]of c)i.push({kind:"count",at:o,point:{x:s.x+s.width*.5+40,y:s.y+s.height-4},n:r});for(let o of n)if(o.name){if(o.robot?.at&&o.robot.mode!=="docked"){let r=e(o.robot.at);r&&i.push({kind:"robot",presence:o,point:{x:r.x+r.width/2+22,y:r.y+r.height-4},mode:o.robot.mode})}if(o.over){let r=e(o.over);r&&i.push({kind:"over",presence:o,box:r})}}return i}export{un as a,P as b,oe as c,ie as d,J as e,fn as f,le as g,mn as h,fe as i,yn as j,hn as k,wn as l,vn as m,Se as n,Xe as o,Ze as p,Mn as q,z as r,on as s,an as t,sn as u};
@@ -1 +0,0 @@
1
- import{a as re,b as ne,c as O}from"./chunk.NJSK3UO2.js";import{a as B,b as L}from"./chunk.DEAP3H2L.js";import{a as Z,e as ee}from"./chunk.FULEUL34.js";import{e as J,f as _,g as Q,h as U,i as X,j as Y}from"./chunk.L3WTKQQL.js";import"./chunk.QDWSU47A.js";import{G as z,Ka as R,M as T,O as G,T as D,ca as b,ia as I,la as x,oa as V,pa as j,ra as C,ta as M}from"./chunk.M7RESZB6.js";import"./chunk.SDO3U72B.js";import"./chunk.DZZL5IDD.js";import"./chunk.FQLNBIQ5.js";import{b as v}from"./chunk.AJZBJBMO.js";var i=v(z(),1);var a=v(D(),1),te=e=>({...e.node?{node:{id:e.node.id}}:{},...e.nodes?{nodes:e.nodes.map(n=>({id:n.id}))}:{},...e.label!==void 0?{label:e.label}:{},fidelity:e.fidelity,cardinality:e.cardinality,mode:e.mode,selected:e.selected,...e.implicated?{implicated:e.implicated}:{},...e.flagged?{flagged:e.flagged}:{}});function N(e){let n=G(),r=n?.past?.seq,s=n?.host?.viewAt,t=(0,i.useMemo)(()=>r===void 0||!s||e.draft?void 0:s(e.manifest.name,r),[s,r,e]);return(0,i.useMemo)(()=>t===null?null:t===void 0?e:{...e,worker:t},[t,e])}function $({definition:e,store:n,principal:r,input:s,goTo:t,places:o,arrangement:l,scheme:d,brand:m,onFailure:u,drawsItsOwn:w,tick:f}){let p=(0,i.useRef)(null),y=(0,i.useRef)(null),k=T(),g=(0,i.useContext)(I),c=(0,i.useRef)({input:s,goTo:t,places:o,arrangement:l,onFailure:u,brand:m,hostFiles:k,told:g});c.current={input:s,goTo:t,places:o,arrangement:l,onFailure:u,brand:m,hostFiles:k,told:g},(0,i.useEffect)(()=>{let A=p.current;if(!A)return;let H=e.file??(c.current.hostFiles?.src?h=>c.current.hostFiles?.src?.(h)??h:void 0);typeof e.worker=="function"&&O(e.worker).catch(()=>{});let K=L(B,({mountWorkerView:h})=>{y.current=h(A,{manifest:e.manifest,worker:e.worker,store:n,principal:r,input:()=>c.current.input?.()??{},goTo:()=>c.current.goTo,places:()=>c.current.places?.()??[],arrangement:()=>c.current.arrangement?.(),brand:()=>c.current.brand,onFailure:(W,q)=>c.current.onFailure(W,q),...w?{fallback:!1}:{},...e.limits?{limits:e.limits}:{},...e.author?{author:e.author}:{},...e.onProblem?{onProblem:e.onProblem}:{},...e.asset?{asset:e.asset}:{},...H?{file:H}:{},...e.images?{images:e.images}:{},...e.links?{links:e.links}:{},files:()=>c.current.hostFiles,onContentHeight:W=>c.current.told?.(W)})});return()=>{K(),y.current?.dispose(),y.current=null}},[e,n,r]),(0,i.useEffect)(()=>y.current?.update(),[d,m,f]);let F=(0,a.jsx)("div",{ref:p,"data-worker-view-place":e.manifest.name,style:{minWidth:0}});if(!e.draft)return F;let P=e.manifest.title??e.manifest.name;return(0,a.jsxs)("div",{role:"group","aria-label":`Draft: ${P}`,"data-graview-draft-view":e.manifest.name,style:{display:"grid",gap:8,alignContent:"start",minWidth:0},children:[(0,a.jsxs)("p",{"data-testid":"draft-view-line",style:ae,children:[(0,a.jsxs)("span",{children:["Draft \u2014 ",(0,a.jsx)("span",{style:{color:"var(--graview-ink)",fontWeight:600},children:P})]}),(0,a.jsx)("span",{"aria-hidden":"true",children:"\xB7"}),(0,a.jsx)("span",{children:"Not kept"})]}),F]})}var ae={margin:0,display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"4px 8px",fontSize:"0.875rem",color:"var(--graview-ink-muted)",borderBottom:"1px solid var(--graview-edge)",paddingBottom:8};function E({view:e,props:n,fellBack:r}){return(0,a.jsx)("div",{"data-worker-view-fallback":"",...r?{"data-worker-view-fell-back":r.name,"data-worker-view-failed":r.reason}:{},style:{display:"contents"},children:(0,a.jsx)(e,{...n})})}function oe({name:e,reason:n,children:r}){return(0,a.jsx)("div",{"data-worker-view-fell-back":e,"data-worker-view-failed":n,style:{display:"contents"},children:r})}function S(e,n={}){let r=n.fallback,s=e.manifest.replaces==="page";function t(o){let l=b(),d=x(),m=(0,i.useContext)(R),[u,w]=(0,i.useState)(null),f=(0,i.useRef)(o);f.current=o;let p=N(e);if(!l)return null;if(p===null)return r&&!(m&&V(r)&&!s)?(0,a.jsx)(E,{view:r,props:o}):null;if(u&&r)return m&&V(r)&&!s?null:(0,a.jsx)(E,{view:r,props:o,fellBack:{name:e.manifest.name,reason:u}});let y=n.beside&&!(m&&V(n.beside))?n.beside:void 0,k=(0,a.jsx)($,{definition:p,store:l.store,principal:l.principal,input:()=>te(f.current),goTo:d,places:()=>l.views.places(),arrangement:()=>l.views.arrangement?.(),scheme:l.scheme,brand:l.brand,tick:o,drawsItsOwn:r!==void 0,onFailure:(g,c)=>{w(g),e.onFailure?.(g,c)}});return y?(0,a.jsxs)("div",{"data-worker-view-beside":e.manifest.name,style:{display:"grid",gap:12,minWidth:0},children:[k,(0,a.jsx)(y,{...o})]}):k}return t.displayName=`WorkerView(${e.manifest.name})`,t}function ie(e,n){let{manifest:r}=n;if(r.attach==="home"){if(!e.home)throw new Error(`The worker view "${r.name}" is the home's body: draw it with workerHome, on the home.`);let u=e.homes?.(),w=n.draft?void 0:u?u.filter(p=>p.name===void 0).at(-1)?.view:e.homeView?.(),f=S(n,w?{fallback:w}:{});return e.home(r.bleed===!0?C(f):f,n.draft?void 0:{name:r.name}),e}let s={cardinality:r.cardinality,fidelity:"full"},t=e.lookup(r.attach,s)??e.resolve(r.attach,s)?.view,o=r.cardinality==="one",l=n.draft===!0,d=S(n,{...t&&!l?{fallback:t}:{},...o&&r.replaces!=="page"&&t?{beside:t}:{}});r.replaces==="page"&&j(d);let m=t?.says;return o&&r.replaces!=="page"&&typeof m=="function"&&(d.says=m),r.bleed===!0&&C(d),d.flows=r.flows!==!1,r.heading==="own"&&(d.ownHeading=!0),M(d,r.scene?.maxHeight!==void 0?{maxHeight:r.scene.maxHeight}:{}),e.register(r.attach,s,d,r.title?{title:r.title,...l?{}:{name:r.name},lens:"view",...r.reads?.kinds?.length?{reads:r.reads.kinds}:{}}:l?void 0:{name:r.name}),e}function se(e,n={}){let r=n.fallback;function s({context:t}){let o=b(),l=x(),[d,m]=(0,i.useState)(null),u=N(e);return d&&r?(0,a.jsx)(oe,{name:e.manifest.name,reason:d,children:(0,a.jsx)(r,{context:t})}):u===null&&r?(0,a.jsx)(r,{context:t}):u===null?null:(0,a.jsx)($,{definition:u,store:t.store,principal:t.principal??o?.principal??{kind:"human"},goTo:l,...o?{places:()=>o.views.places(),arrangement:()=>o.views.arrangement?.(),scheme:o.scheme,brand:o.brand}:{},drawsItsOwn:r!==void 0,onFailure:(w,f)=>{m(w),e.onFailure?.(w,f)}})}return s.displayName=`WorkerHome(${e.manifest.name})`,s}export{_ as checkManifest,re as checkViewSource,ee as judgeCodeAct,J as manifestActs,X as readsComputed,ie as registerWorkerView,Z as sightIsTotal,Q as unreadEdges,U as unreadEdgesSentence,ne as viewScript,se as workerHome,S as workerView,Y as workerViewProps};
@@ -1 +0,0 @@
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 te}from"./chunk.OWOOKLIU.js";import{o as Se,p as ee,s as $,t as be}from"./chunk.UKQUUPKE.js";import{m as J,n as ye,o as we,p as X,q as Z}from"./chunk.OJGHDWI6.js";import{c as ke}from"./chunk.ACTXR2MI.js";import{a as he,b as U,c as j,e as ve,n as Me}from"./chunk.AI34V6WV.js";import{b as de}from"./chunk.G4ULQK64.js";import{D as z,F as Y,G as O,Ga as fe,Ha as ge,Ia as T,J as pe,Ma as _,O as me,Oa as F,T as M,ba as A,ca as q,da as B,m as le,v as ce,z as ue}from"./chunk.M7RESZB6.js";import{a as E}from"./chunk.SDO3U72B.js";import{Fd as se,dd as ie,id as ae,na as H}from"./chunk.DZZL5IDD.js";import{b as y}from"./chunk.AJZBJBMO.js";var P=y(O(),1),x=y(M(),1),ne=T(E(()=>(__graviewPreload(import.meta.url,["./chunk.M7RESZB6.js","./chunk.SDO3U72B.js","./chunk.DZZL5IDD.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.Z2TDZSMN.js")))),xe=ne.part(t=>(0,x.jsx)(t.HoverChipDoor,{}),{quiet:!0}),De="A",Q=T(E(()=>(__graviewPreload(import.meta.url,["./chunk.KHRS2SKB.js","./chunk.4HRYB7HF.js","./chunk.T6PU3NKP.js","./chunk.ELOFPE25.js","./chunk.RMR24LFJ.js","./chunk.KMV6PJFL.js","./chunk.NAD7ZXYP.js","./chunk.2GEJNG2U.js","./chunk.HJCQ6I3S.js","./chunk.22BZU7ME.js","./chunk.2N4Z5K5S.js","./chunk.JYFZCJ4N.js","./chunk.U6ZRJKVM.js","./chunk.PLTH2LW5.js","./chunk.66P5IDTH.js","./chunk.AJSUHPBE.js","./chunk.KDXU5DT3.js","./chunk.M4AYA2PL.js","./chunk.H5S7OL2U.js","./chunk.PZQNR4KZ.js","./chunk.W4BKYSZX.js","./chunk.T6WHGKWR.js","./chunk.XOZU4OFA.js","./chunk.Y2YYH3JN.js","./chunk.YFVJUHAK.js","./chunk.NOGGSLVG.js","./chunk.SGCW2XRC.js","./chunk.ZN3PUM2I.js","./chunk.QIPASE42.js","./chunk.EVBCEEQ4.js","./chunk.OWT3VVOT.js","./chunk.NHTGAP3G.js","./chunk.UKQUUPKE.js","./chunk.OJGHDWI6.js","./chunk.DDUCIUVW.js","./chunk.NUYA4BWI.js","./chunk.OKZT2QBM.js","./chunk.ACTXR2MI.js","./chunk.AI34V6WV.js","./chunk.G4ULQK64.js","./chunk.M7RESZB6.js","./chunk.SDO3U72B.js","./chunk.DZZL5IDD.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.PKWQKFPE.js"))));var Ce=Q.part((t,e)=>(0,x.jsx)(t.InspectorPane,{...e}),{what:"This card's acts"});function Le(t){let e=()=>{(typeof navigator>"u"||navigator.onLine!==!1)&&t()},n=globalThis;if(n.requestIdleCallback){let c=n.requestIdleCallback(e,{timeout:5e3});return()=>n.cancelIdleCallback?.(c)}let i=setTimeout(e,2500);return()=>clearTimeout(i)}var Oe=150,Ne="[data-graview-pick], [data-graview-view], [data-graview-record], [data-graview-act], [data-graview-field], a[href]";function Re(t){if(t.closest("[data-graview-face='pages'], [data-graview-popover]"))return null;let e=t.closest("[data-graview-pick]")?.getAttribute("data-graview-pick")??t.closest("[data-graview-view]")?.getAttribute("data-graview-view");return e?{face:"scene",on:e,about:[e]}:null}function We(t){let{store:e,principal:n,providers:i,ai:c}=A(),p=be(),h=Y(c),r=(0,P.useRef)({aimAt:t,store:e,principal:n,providers:i,prepareSections:p,chipsOn:h});r.current={aimAt:t,store:e,principal:n,providers:i,prepareSections:p,chipsOn:h},(0,P.useEffect)(()=>{if(typeof document>"u")return;let u=null,w=null,k=null,l=g=>{let m=r.current,b=m.chipsOn?m.aimAt(g):null;b&&(k=g,ne.load().then(G=>{k===g&&G.restOn(b,g)},()=>{}))},f=()=>{u&&clearTimeout(u.timer),u=null},s=g=>{let m=r.current,b=m.aimAt(g);if(!b)return;let G=JSON.stringify([b.face,b.on,b.about,b.field,b.place,b.act,m.store.log.length]);G!==w&&(w=G,m.prepareSections(b),Q.load().then(Pe=>Pe.prepareActs(m.store,b,{principal:m.principal,providers:m.providers}),()=>{}))},o=g=>g.target instanceof Element?g.target.closest(Ne):null,d=g=>{if(g.pointerType==="touch")return;let m=o(g);m!==null&&m===u?.element||(f(),m!==null&&(u={element:m,timer:setTimeout(()=>{u=null,s(m),l(m)},Oe)}))},v=g=>{let m=g.relatedTarget;k!==null&&!(m instanceof Node&&k.contains(m))&&(k=null,ne.current?.leaveRest()),u!==null&&(m instanceof Node&&u.element.contains(m)||f())},S=g=>{if(g.pointerType==="mouse")return;let m=o(g);m&&s(m)},I=g=>{if(!fe())return;let m=o(g);m&&s(m)};return document.addEventListener("pointerover",d,{passive:!0}),document.addEventListener("pointerout",v,{passive:!0}),document.addEventListener("pointerdown",S,{capture:!0,passive:!0}),document.addEventListener("focusin",I),()=>{f(),document.removeEventListener("pointerover",d),document.removeEventListener("pointerout",v),document.removeEventListener("pointerdown",S,{capture:!0}),document.removeEventListener("focusin",I)}},[])}function it({placement:t="float",openActs:e,aimAt:n}={}){let{menuAt:i,setMenuAt:c,registerActsDoor:p,ai:h}=A(),{selection:r}=_();We(n??Re),(0,P.useEffect)(()=>{if(Q.current)return;let f=()=>{v(),Q.prefetch()},s=()=>{},o=ge(()=>void(s=Le(f))),d=["pointerdown","keydown"];for(let S of d)document.addEventListener(S,f,{capture:!0,passive:!0});function v(){o(),s();for(let S of d)document.removeEventListener(S,f,{capture:!0})}return v},[]),(0,P.useEffect)(()=>{if(t==="menu")return p({key:De,open:e??(f=>{let s=f.getBoundingClientRect(),o=f.closest("[data-graview-pick]")?.getAttribute("data-graview-pick")??f.closest("[data-graview-view]")?.getAttribute("data-graview-view")??void 0;c({x:Math.round(s.left+Math.min(16,s.width/2)),y:Math.round(Math.min(s.bottom,s.top+36)),...o?{on:o}:{}})})}),()=>p(null)},[t,p,c,e]);let u=i!==null||r.length>0&&e===void 0,[w,k]=(0,P.useState)(u);(0,P.useEffect)(()=>{u&&k(!0)},[u]);let l=Y(h)?(0,x.jsx)(P.Suspense,{fallback:null,children:(0,x.jsx)(xe,{})}):null;return!w&&!u?l:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(P.Suspense,{fallback:null,children:(0,x.jsx)(Ce,{placement:t,chosen:e===void 0})}),l]})}var K=y(O(),1),V=y(M(),1),Ge=T(E(()=>(__graviewPreload(import.meta.url,["./chunk.KHRS2SKB.js","./chunk.4HRYB7HF.js","./chunk.25VJPUDH.js","./chunk.T6PU3NKP.js","./chunk.ELOFPE25.js","./chunk.BLUKSGI4.js","./chunk.UFDJXQQQ.js","./chunk.ELTV44HU.js","./chunk.CY3ELWCM.js","./chunk.RMR24LFJ.js","./chunk.I77ZGIFE.js","./chunk.OWOOKLIU.js","./chunk.RD2X25XB.js","./chunk.KMV6PJFL.js","./chunk.SWMDFXUX.js","./chunk.A3ZC2JBO.js","./chunk.NAD7ZXYP.js","./chunk.2GEJNG2U.js","./chunk.HJCQ6I3S.js","./chunk.22BZU7ME.js","./chunk.2N4Z5K5S.js","./chunk.JYFZCJ4N.js","./chunk.U6ZRJKVM.js","./chunk.PLTH2LW5.js","./chunk.66P5IDTH.js","./chunk.UQQKDBIH.js","./chunk.AJSUHPBE.js","./chunk.LAYQ5PFS.js","./chunk.KDXU5DT3.js","./chunk.O2BHPYA4.js","./chunk.M4AYA2PL.js","./chunk.H5S7OL2U.js","./chunk.PZQNR4KZ.js","./chunk.W4BKYSZX.js","./chunk.T6WHGKWR.js","./chunk.XOZU4OFA.js","./chunk.Y2YYH3JN.js","./chunk.YFVJUHAK.js","./chunk.NOGGSLVG.js","./chunk.WVUJXDXZ.js","./chunk.SGCW2XRC.js","./chunk.ZN3PUM2I.js","./chunk.QIPASE42.js","./chunk.EVBCEEQ4.js","./chunk.OWT3VVOT.js","./chunk.NHTGAP3G.js","./chunk.GZHZLJBF.js","./chunk.UKQUUPKE.js","./chunk.OJGHDWI6.js","./chunk.DDUCIUVW.js","./chunk.NUYA4BWI.js","./chunk.OKZT2QBM.js","./chunk.ACTXR2MI.js","./chunk.AI34V6WV.js","./chunk.G4ULQK64.js","./chunk.M7RESZB6.js","./chunk.SDO3U72B.js","./chunk.DZZL5IDD.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.DHJ3FQTR.js")))),He=Ge.part((t,e)=>{let n=t.DraftFrame;return(0,V.jsx)(n,{...e})},{what:"The view"});function ct(t){let{seatTalk:e}=A();return(0,K.useSyncExternalStore)(e.subscribe,()=>e.get().draft!==null,()=>!1)?(0,V.jsx)(K.Suspense,{fallback:null,children:(0,V.jsx)(He,{...t})}):null}var C=y(O(),1),D=y(M(),1),Ae=T(E(()=>(__graviewPreload(import.meta.url,["./chunk.2GEJNG2U.js","./chunk.N6EJXXQK.js","./chunk.BJUUSIQY.js","./chunk.PZQNR4KZ.js","./chunk.W4BKYSZX.js","./chunk.T6WHGKWR.js","./chunk.XOZU4OFA.js","./chunk.Y2YYH3JN.js","./chunk.5STU3KYG.js","./chunk.ZN3PUM2I.js","./chunk.NUYA4BWI.js","./chunk.OKZT2QBM.js","./chunk.ACTXR2MI.js","./chunk.AI34V6WV.js","./chunk.G4ULQK64.js","./chunk.M7RESZB6.js","./chunk.SDO3U72B.js","./chunk.DZZL5IDD.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.7M4HNKDR.js")))),ze=Ae.part((t,e)=>{let n=t.QuickAskCard;return(0,D.jsx)(n,{...e})},{what:"The quick ask"});function gt({face:t,on:e=!0}){let{ai:n,aiDesk:i,selection:c,view:p}=A(),h=me()?.open??!1,r=e&&z(n)&&!h,u=ve(i),w=(0,C.useRef)(null),k=(0,C.useRef)({selection:c,place:p.within?.view});return k.current={selection:c,place:p.within?.view},(0,C.useEffect)(()=>{if(!r)return;let l=he(i);return l.drawn+=1,U(l),()=>{l.drawn=Math.max(0,l.drawn-1),l.drawn===0&&(l.open=null),U(l)}},[r,i]),(0,C.useEffect)(()=>{if(!r)return;let l=f=>{if(f.defaultPrevented||f.key.toLowerCase()!=="k"||!(f.metaKey||f.ctrlKey)||f.altKey||f.shiftKey)return;let s=w.current?.closest("[data-graview-embed]"),o=f.target,d=!(o instanceof Node)||o===document.body||o===document.documentElement;if(s&&!(d||o instanceof Node&&s.contains(o)))return;f.preventDefault(),Ae.prefetch();let v=document.activeElement,{selection:S,place:I}=k.current;j(i,{pointed:{...S[0]!==void 0?{on:S[0]}:{},about:S,...I?{place:I}:{}},returnTo:v instanceof HTMLElement&&v!==document.body?v:null})};return window.addEventListener("keydown",l,!0),()=>window.removeEventListener("keydown",l,!0)},[r,i]),r?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{ref:w,hidden:!0,"data-graview-quick-ask":t}),u?(0,D.jsx)(C.Suspense,{fallback:null,children:(0,D.jsx)(ze,{face:t,opening:u,close:()=>j(i,null)},u.at)}):null]}):null}var R=y(O(),1),L=y(M(),1),oe=T(E(()=>(__graviewPreload(import.meta.url,["./chunk.N6EJXXQK.js","./chunk.BJUUSIQY.js","./chunk.PZQNR4KZ.js","./chunk.W4BKYSZX.js","./chunk.T6WHGKWR.js","./chunk.XOZU4OFA.js","./chunk.Y2YYH3JN.js","./chunk.5STU3KYG.js","./chunk.ZN3PUM2I.js","./chunk.NUYA4BWI.js","./chunk.OKZT2QBM.js","./chunk.ACTXR2MI.js","./chunk.AI34V6WV.js","./chunk.G4ULQK64.js","./chunk.M7RESZB6.js","./chunk.SDO3U72B.js","./chunk.DZZL5IDD.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.2AT3GRXM.js")))),qe=oe.part((t,e)=>{let n=t.InlineAiMenu;return(0,L.jsx)(n,{...e})},{what:"The AI's suggestions"}),Be=oe.part((t,e)=>{let n=t.GhostTray;return(0,L.jsx)(n,{...e})},{quiet:!0});function _e(){let{ai:t}=A(),e=z(t);return(0,R.useMemo)(()=>e?n=>({id:"inline-ai",heading:"AI",render:i=>(0,L.jsx)(R.Suspense,{fallback:null,children:(0,L.jsx)(qe,{target:n,close:i})}),prepare:()=>oe.prefetch()}):null,[e])}var Fe=[];function St({children:t}){let e=_e(),n=(0,R.useMemo)(()=>e?[e]:Fe,[e]);return(0,L.jsx)($,{sections:n,children:t})}function bt(t){let{ai:e,aiDesk:n}=A(),{ghost:i}=pe(n);return i===null||i.onCard||e.off?null:(0,L.jsx)(R.Suspense,{fallback:null,children:(0,L.jsx)(Be,{...t})})}var N=y(O(),1);var Te=y(M(),1),Qe=t=>globalThis[Symbol.for("graview.shown-lists")]?.get(t),Ee=T(E(()=>(__graviewPreload(import.meta.url,["./chunk.AI34V6WV.js","./chunk.G4ULQK64.js","./chunk.M7RESZB6.js","./chunk.SDO3U72B.js","./chunk.DZZL5IDD.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.SEHRPTNA.js"))));function Ve(t){let e=t.about[0];if(t.about.length!==1||!e?.startsWith("aggregate:"))return;let n=e.slice(10).split("+");return n.length===1?n[0]:void 0}function Ke(t,e){return t.filter(n=>n.as!==e.as&&!n.hidden&&(n.kind===e.kind||n.over?.includes(e.kind)===!0)).at(-1)}function Ye(t){let e=q(),n=e?.keptViews,i=e?.views,c=(0,N.useContext)(Me);return(0,N.useMemo)(()=>i?p=>{let h=n?.current(),r=Ve(p),u=s=>s.length>0?{id:"tidy-view",items:s,prepare:()=>Ee.prefetch()}:null,w=(s,...o)=>Ee.load().then(d=>d[s](...o),()=>!1),k=(s,o)=>Qe(s)?.().menu(o,n,c)??[];if(p.place===void 0){if(p.face!=="pages"||r===void 0||p.on!==void 0)return null;let s=h?.may.lenses===!0&&n?.lens!==void 0,o=H(e.store.schema,r),d=i.arrangement?.()?.hide?.includes(r)===!0;return u([...s?[{id:d?"show-list":"hide-list",label:d?"Show":"Hide",hint:d?"Back in the places, for everyone":"Off the places, for everyone; still at its address",run:()=>void w("setListHidden",r,o,n,!d,c)}]:[],...k(`list:${r}`,s)])}let l=i.places().find(s=>s.as===p.place&&(r===void 0||s.kind===r||s.over?.includes(r)===!0));if(!l)return null;let f=n&&h?se(l,h,n):null;return u([...f?[l.hidden?{id:"show-view",label:"Show",hint:"Back in the places, for everyone",run:()=>void w("setHidden",l,f,n,!1,c)}:{id:"hide-view",label:"Hide",hint:"Off the places and the scene, for everyone",run:()=>void w("setHidden",l,f,n,!0,c)},{id:"delete-view",label:"Delete",hint:`Kept ${30} days under Recently deleted`,run:()=>{let s=Ke(i.places(),l);w("remove",l,f,n,c).then(o=>o&&t?.(l,s))}}]:[],...k(`place:${l.as}`,f==="lens")])}:null,[n,i,c,t])}var Ue=[];function Dt({children:t}){let{view:e,go:n}=F(),i=(0,N.useCallback)((h,r)=>{let u=e.within?.view;e.focusId===ce(h.kind)&&(u===void 0||u===h.as)&&n(r?ue(e,r.kind,r.as):le(e,!0))},[e,n]),c=Ye(i),p=(0,N.useMemo)(()=>c?[c]:Ue,[c]);return(0,Te.jsx)($,{sections:p,children:t})}function Nt(t={}){return t.scope===void 0?te:de(te,t.scope)}var W=y(O(),1),a=y(M(),1);function Bt({inside:t=!1,widthOf:e}={}){let{store:n,view:i,emphasis:c,setEmphasis:p}=A(),h=Se(),{selection:r,set:u}=_(),{show:w}=F(),k=B(),l=(0,W.useMemo)(()=>{let o=new Map;for(let d of n.graph.allEdges()){let v=o.get(d.kind)??{count:0,ends:new Set};v.count+=1;for(let S of[d.from,d.to]){let I=n.graph.getNode(S);I&&v.ends.add(`kind:${I.kind}`)}o.set(d.kind,v)}return[...o.entries()].sort(([d],[v])=>d.localeCompare(v)).map(([d,v])=>({kind:d,count:v.count,ends:[...v.ends]}))},[n,k]),f=Math.max(0,...l.map(o=>o.count));if((0,W.useEffect)(()=>()=>p(null),[p]),!i.overview&&!t||l.length===0)return null;let s=new Set;for(let o of r){if(o.startsWith("kind:")){s.add(o);continue}let d=n.graph.getNode(o);d&&s.add(`kind:${d.kind}`)}return(0,a.jsxs)("section",{"aria-label":"What the lines mean",role:t?"group":void 0,"data-testid":"relation-key",style:t?{display:"grid",gap:1}:{position:"absolute",left:16,top:14,zIndex:ae("rail"),display:"grid",gap:1,padding:"8px 10px",borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-low)",maxWidth:je,animation:"graview-settle 380ms 280ms ease backwards"},children:[t?null:(0,a.jsx)("span",{style:{fontSize:"0.75rem",letterSpacing:"0.16em",textTransform:"uppercase",color:"var(--graview-ink-faint)",paddingBottom:2},children:l.length===1?"1 relation":`${l.length} relations`}),e?(0,a.jsx)(Xe,{aloft:i.overview===!0}):null,l.map(({kind:o,count:d,ends:v})=>{let{connector:S,style:I}=ee(h,o),g=Je(n.schema,o),m=c!==null?c===o:s.size===0||v.some(b=>s.has(b));return(0,a.jsxs)("button",{type:"button",title:n.schema.edge(o)?.description===void 0?`${d} of these`:g.words,onMouseEnter:()=>p(o),onMouseLeave:()=>p(null),onFocus:()=>p(o),onBlur:()=>p(null),onClick:()=>{u(v),w(null)},style:{all:"unset",outline:"revert-layer",cursor:"pointer",display:"grid",gridTemplateColumns:"30px 1fr auto",alignItems:"center",gap:8,minHeight:23,padding:"2px 4px",borderRadius:6,opacity:m?1:.4},children:[(0,a.jsx)("svg",{width:"30",height:"10","aria-hidden":"true",style:{display:"block",opacity:S.visible?1:.35},children:i.overview&&e?(0,a.jsx)("path",{d:"M 1 5 L 29 5",fill:"none",className:"graview-key-ribbon",stroke:"var(--graview-ink)",strokeOpacity:.35,strokeWidth:e(d,f)}):(0,a.jsx)("path",{d:"M 1 5 L 29 5",fill:"none",stroke:X(I),strokeWidth:Z(I,!0),strokeDasharray:J[I.pattern],strokeLinecap:"round"})}),(0,a.jsxs)("span",{style:{display:"grid",minWidth:0},"data-graview-relation-words":o,children:[(0,a.jsx)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-ink)"},children:g.words}),(0,a.jsx)("span",{style:{fontSize:"0.6875rem",color:"var(--graview-ink-faint)"},children:g.ends})]}),S.visible?null:(0,a.jsx)("span",{"data-graview-quiet":o,style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",fontStyle:"italic"},children:"not drawn"}),(0,a.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",fontVariantNumeric:"tabular-nums"},children:d})]},o)})]})}var je="min(280px, calc(100% - 28px))";function Je(t,e,n){let i=t.edge(e)?.from??[],c=new Map;for(let r of n!==void 0&&i.includes(n)?[n]:i.length>0?i:[""]){let u=ke(t,r,e,"out");c.set(u,[...c.get(u)??[],r])}let p=r=>r==="*"?"anything":H(t,r),h=[...c].map(([r,u])=>{let w=u.flatMap(l=>t.tryDefinition(l)?.edges[e]?.to??[]),k=u[0]&&w.length>0?`${u.map(p).join(", ")} \u2192 ${(w.includes("*")?["*"]:[...new Set(w)]).map(p).join(", ")}`:"";return[r.charAt(0).toUpperCase()+r.slice(1),k]});return{words:h.map(([r])=>r).join(" \xB7 "),ends:h.flatMap(([,r])=>r?[r]:[]).join(" \xB7 ")}}function _t({edgeKind:t,kit:e,width:n=30}){let i=q(),c=(0,W.useMemo)(()=>ie(e??i?.brand?.kit),[e,i?.brand?.kit]),{connector:p,style:h}=ee(c,t);return(0,a.jsx)("svg",{width:n,height:"8","aria-hidden":"true","data-testid":"relation-mark","data-graview-relation":t,style:{display:"inline-block",verticalAlign:"middle",opacity:p.visible?1:.35},children:(0,a.jsx)("path",{d:`M 1 4 L ${n-1} 4`,fill:"none",stroke:X(h),strokeWidth:Z(h,!0),strokeDasharray:J[h.pattern],strokeLinecap:"round"})})}function Xe({aloft:t}){let e={display:"grid",gridTemplateColumns:"30px 1fr",alignItems:"center",gap:8,minHeight:23,padding:"2px 4px"},n={fontSize:"0.75rem",color:"var(--graview-ink-muted)"};return(0,a.jsxs)("div",{role:"group","aria-label":"The lines","data-testid":"line-manners",style:{display:"grid",gap:1,paddingBottom:6,marginBottom:4,borderBottom:"1px solid var(--graview-edge)"},children:[t?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{style:e,"data-graview-manner":"ribbon",children:[(0,a.jsx)("svg",{width:"30",height:"10","aria-hidden":"true",children:(0,a.jsx)("path",{d:"M 1 5 L 29 5",stroke:"var(--graview-ink)",strokeOpacity:.35,strokeWidth:6})}),(0,a.jsx)("span",{style:n,children:"A relation between two districts, as wide as the links along it \u2014 point at one for its words"})]}),(0,a.jsxs)("div",{style:e,"data-graview-manner":"record",children:[(0,a.jsxs)("svg",{width:"30",height:"10","aria-hidden":"true",children:[(0,a.jsx)("path",{d:"M 1 5 L 25 5",stroke:"var(--graview-accent)",strokeWidth:1.8,strokeLinecap:"round"}),(0,a.jsx)("circle",{cx:26,cy:5,r:3,fill:"var(--graview-accent)"})]}),(0,a.jsx)("span",{style:n,children:"A chosen record's link to another record, labeled with the relation"})]}),(0,a.jsxs)("div",{style:e,"data-graview-manner":"district",children:[(0,a.jsx)("svg",{width:"30",height:"10","aria-hidden":"true",children:(0,a.jsx)("path",{d:"M 1 5 L 29 5",stroke:"var(--graview-accent)",strokeWidth:1.8,strokeDasharray:"5 4"})}),(0,a.jsx)("span",{style:n,children:"A chosen record's links into a district, with how many"})]})]}):null,(0,a.jsxs)("div",{style:e,"data-graview-manner":"unsure",children:[(0,a.jsx)("svg",{width:"30",height:"10","aria-hidden":"true",children:(0,a.jsx)("path",{d:"M 1 5 L 29 5",stroke:"var(--graview-accent)",strokeOpacity:we,strokeWidth:1.8,strokeDasharray:ye,strokeLinecap:"round"})}),(0,a.jsx)("span",{style:n,children:"Unsure: a link its maker was less than sure of, until a person keeps it \u2014 point at its words for what it was based on"})]})]})}var Ie=y(O(),1),re=y(M(),1),Ze=T(E(()=>(__graviewPreload(import.meta.url,["./chunk.25VJPUDH.js","./chunk.QHY5NVYH.js","./chunk.U6ZRJKVM.js","./chunk.PLTH2LW5.js","./chunk.66P5IDTH.js","./chunk.AJSUHPBE.js","./chunk.KDXU5DT3.js","./chunk.W4BKYSZX.js","./chunk.NUYA4BWI.js","./chunk.OKZT2QBM.js","./chunk.ACTXR2MI.js","./chunk.AI34V6WV.js","./chunk.G4ULQK64.js","./chunk.M7RESZB6.js","./chunk.SDO3U72B.js","./chunk.DZZL5IDD.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.H73ZPYUX.js")))),et=Ze.part(t=>(0,re.jsx)(t.SuggestedTray,{}),{quiet:!0});function Vt(){let{store:t,whileAway:e}=A(),n=B();return(0,Ie.useMemo)(()=>t.log.all().some(c=>c.suggests!==void 0&&!c.withheld),[t,n])||e?.tidied?(0,re.jsx)(et,{}):null}export{it as a,ct as b,gt as c,Bt as d,je as e,_t as f,_e as g,St as h,bt as i,Ye as j,Dt as k,Nt as l,Vt as m};