graview 0.1.54 → 0.1.56

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 (197) 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.XTT6ERI3.js → chunk.22MIRLL6.js} +1 -1
  5. package/dist/preview/chunk.2BLRCT3E.js +1 -0
  6. package/dist/preview/chunk.2DETYEJM.js +1 -0
  7. package/dist/preview/{chunk.AN5QCSVK.js → chunk.2E6EWVWR.js} +1 -1
  8. package/dist/preview/{chunk.RBYRT2I2.js → chunk.2HZGUVB2.js} +1 -1
  9. package/dist/preview/{chunk.ZBHFCSKO.js → chunk.2OX4YI46.js} +1 -1
  10. package/dist/preview/{chunk.E5JX5LWY.js → chunk.2YNZVNCA.js} +1 -1
  11. package/dist/preview/chunk.3V2WH6F7.js +1 -0
  12. package/dist/preview/chunk.3X3GLNWQ.js +1 -0
  13. package/dist/preview/chunk.45VIF2SX.js +5 -0
  14. package/dist/preview/{chunk.VGOWGOGD.js → chunk.4EUH6TLG.js} +2 -2
  15. package/dist/preview/chunk.4EY6WPSM.js +2 -0
  16. package/dist/preview/{chunk.Y2DFDMT6.js → chunk.4KMY24YC.js} +1 -1
  17. package/dist/preview/chunk.4YI6656P.js +1 -0
  18. package/dist/preview/{chunk.D2PJG5N7.js → chunk.5B4HNQGR.js} +1 -1
  19. package/dist/preview/chunk.5MS2TQFX.js +1 -0
  20. package/dist/preview/chunk.5MSWUTDB.js +1 -0
  21. package/dist/preview/{chunk.BOMYLOCX.js → chunk.64IKLRUS.js} +1 -1
  22. package/dist/preview/{chunk.VYKEIKY5.js → chunk.65Q5MKDW.js} +1 -1
  23. package/dist/preview/{chunk.3IEJQAK7.js → chunk.6HLKAUWF.js} +1 -1
  24. package/dist/preview/chunk.6Q6BW4QT.js +2 -0
  25. package/dist/preview/chunk.7ECBGIUK.js +1 -0
  26. package/dist/preview/{chunk.J2Z6WLCH.js → chunk.7NP2I2UP.js} +1 -1
  27. package/dist/preview/{chunk.5C43AM3X.js → chunk.7O6Z3BFR.js} +1 -1
  28. package/dist/preview/chunk.7RJGEU3Y.js +1 -0
  29. package/dist/preview/{chunk.TUNHUTQ5.js → chunk.7U2JO7ET.js} +1 -1
  30. package/dist/preview/chunk.7Z2PRPYE.js +1 -0
  31. package/dist/preview/{chunk.3JMZHCB4.js → chunk.7Z4USR3Y.js} +1 -1
  32. package/dist/preview/chunk.AGTFYPXY.js +1 -0
  33. package/dist/preview/{chunk.XZJ6XX5I.js → chunk.AIK3Z25Y.js} +1 -1
  34. package/dist/preview/{chunk.ZDDWXRPK.js → chunk.AKVBU5K5.js} +1 -1
  35. package/dist/preview/chunk.AKW6NR3X.js +1 -0
  36. package/dist/preview/{chunk.2DFWOLL2.js → chunk.AM2YRNOQ.js} +1 -1
  37. package/dist/preview/{chunk.2WSRJGW2.js → chunk.APXYWI3L.js} +1 -1
  38. package/dist/preview/{chunk.7SCENHVG.js → chunk.AQCU6TPV.js} +1 -1
  39. package/dist/preview/{chunk.B2X6DA2Q.js → chunk.AZUTYY2S.js} +1 -1
  40. package/dist/preview/chunk.BJUUSIQY.js +1 -0
  41. package/dist/preview/{chunk.FRZQSSGE.js → chunk.BNEOLRQG.js} +1 -1
  42. package/dist/preview/chunk.BT7RLFPO.js +1 -0
  43. package/dist/preview/{chunk.4GHXAWIE.js → chunk.C2VFDBSG.js} +1 -1
  44. package/dist/preview/{chunk.C3AHDHX7.js → chunk.CGM7OER2.js} +1 -1
  45. package/dist/preview/{chunk.4F5M5XZG.js → chunk.CKV2QCH5.js} +1 -1
  46. package/dist/preview/{chunk.4KTHJY5N.js → chunk.CU2NQ5WF.js} +1 -1
  47. package/dist/preview/{chunk.ARRLAAG6.js → chunk.D4LN33J2.js} +1 -1
  48. package/dist/preview/{chunk.W6NCLU5Y.js → chunk.D6BMAGPR.js} +1 -1
  49. package/dist/preview/{chunk.RCFAHV5N.js → chunk.D6KF72MZ.js} +1 -1
  50. package/dist/preview/{chunk.L7MFTL5S.js → chunk.DH7M57SE.js} +1 -1
  51. package/dist/preview/chunk.DPPT6WAJ.js +2 -0
  52. package/dist/preview/{chunk.45HTFSWD.js → chunk.DTSTUC2W.js} +1 -1
  53. package/dist/preview/{chunk.VTO6UWUP.js → chunk.DWMAFMYZ.js} +1 -1
  54. package/dist/preview/chunk.DZYLH5IM.js +1 -0
  55. package/dist/preview/{chunk.PZ4G5QA5.js → chunk.E33EJU3Q.js} +1 -1
  56. package/dist/preview/{chunk.33YC5RCB.js → chunk.E4EN4X5F.js} +1 -1
  57. package/dist/preview/{chunk.DF7IPT7V.js → chunk.E4HSSGF7.js} +1 -1
  58. package/dist/preview/{chunk.PZWJUQAO.js → chunk.E5XNQTEU.js} +1 -1
  59. package/dist/preview/{chunk.FWKNR7XF.js → chunk.EC5IWN74.js} +2 -2
  60. package/dist/preview/chunk.FBR4HJ2Q.js +1 -0
  61. package/dist/preview/{chunk.AKLVSZ5A.js → chunk.FCUDBMGC.js} +1 -1
  62. package/dist/preview/chunk.FOQENWF5.js +1 -0
  63. package/dist/preview/{chunk.SLBWPVIY.js → chunk.FQLNBIQ5.js} +1 -1
  64. package/dist/preview/{chunk.562IVJHX.js → chunk.G3ORIU7C.js} +1 -1
  65. package/dist/preview/chunk.GNQW4JOG.js +18 -0
  66. package/dist/preview/chunk.GUP7LC5O.js +21 -0
  67. package/dist/preview/{chunk.FWZF7X6A.js → chunk.HFVMGTNL.js} +2 -2
  68. package/dist/preview/chunk.HVN2DVP3.js +1 -0
  69. package/dist/preview/{chunk.4WH4N4V7.js → chunk.I2C5LPB5.js} +1 -1
  70. package/dist/preview/{chunk.BPWSQVEN.js → chunk.IF4FCQPG.js} +1 -1
  71. package/dist/preview/{chunk.U7GN6UPR.js → chunk.ILSK2E3R.js} +1 -1
  72. package/dist/preview/{chunk.2LMB5E6N.js → chunk.IRMO4FUC.js} +1 -1
  73. package/dist/preview/chunk.IT763BYH.js +1 -0
  74. package/dist/preview/chunk.IUQOSPQX.js +1 -0
  75. package/dist/preview/{chunk.Y36WSKL5.js → chunk.J3YBEZKE.js} +1 -1
  76. package/dist/preview/{chunk.4V64RBCK.js → chunk.JHFHIG4P.js} +1 -1
  77. package/dist/preview/chunk.JL4DGITZ.js +1 -0
  78. package/dist/preview/{chunk.463PGKOL.js → chunk.JQY2UKU6.js} +1 -1
  79. package/dist/preview/{chunk.IDYPQ45A.js → chunk.JZDKHWRL.js} +1 -1
  80. package/dist/preview/{chunk.6BBB7SJL.js → chunk.K2JE3PD7.js} +1 -1
  81. package/dist/preview/chunk.K4MO22RM.js +1 -0
  82. package/dist/preview/{chunk.NEJSKMJV.js → chunk.K5YLQAFW.js} +1 -1
  83. package/dist/preview/{chunk.IMHUKSPM.js → chunk.KBL4Y4UN.js} +1 -1
  84. package/dist/preview/chunk.KMEKMCKG.js +3 -0
  85. package/dist/preview/{chunk.3ZONBC6L.js → chunk.LKK7VQBA.js} +1 -1
  86. package/dist/preview/chunk.LLOZKUCA.js +1 -0
  87. package/dist/preview/{chunk.YXRKZMS5.js → chunk.LP3SHWJG.js} +1 -1
  88. package/dist/preview/chunk.LVOVPU64.js +1 -0
  89. package/dist/preview/chunk.MEJUAV3Y.js +1 -0
  90. package/dist/preview/{chunk.7JCUSYS5.js → chunk.MFDSWA2W.js} +1 -1
  91. package/dist/preview/{chunk.JTOAZ2IR.js → chunk.MJMVGW6Z.js} +1 -1
  92. package/dist/preview/{chunk.SDO3DD77.js → chunk.MLRPCZVS.js} +1 -1
  93. package/dist/preview/{chunk.OCV46AFN.js → chunk.MORMTKVR.js} +1 -1
  94. package/dist/preview/{chunk.FMP6NDRZ.js → chunk.N3Q5CPVA.js} +1 -1
  95. package/dist/preview/{chunk.VW6X53E7.js → chunk.N7EEPFYV.js} +1 -1
  96. package/dist/preview/{chunk.NGWHV4G6.js → chunk.NBLMANHT.js} +1 -1
  97. package/dist/preview/{chunk.5RH6FO3K.js → chunk.NFU4UM6F.js} +1 -1
  98. package/dist/preview/chunk.NPAWTPLQ.js +25 -0
  99. package/dist/preview/{chunk.B6PKKEY3.js → chunk.NQ4VGKEC.js} +1 -1
  100. package/dist/preview/{chunk.MNW2ZBQ6.js → chunk.NUE5VG4G.js} +1 -1
  101. package/dist/preview/{chunk.XBDFXFWM.js → chunk.O6LDZWLR.js} +1 -1
  102. package/dist/preview/chunk.OBUKZQCZ.js +1 -0
  103. package/dist/preview/{chunk.GKLDSHHH.js → chunk.ONGZ3YQF.js} +1 -1
  104. package/dist/preview/chunk.OYGPNO7A.js +1 -0
  105. package/dist/preview/chunk.PJCVFYFU.js +1 -0
  106. package/dist/preview/{chunk.IYYP6QUH.js → chunk.PMPDLE56.js} +1 -1
  107. package/dist/preview/{chunk.PR2TSHE7.js → chunk.PRV3KYT6.js} +2 -2
  108. package/dist/preview/chunk.Q7X2IVLH.js +1 -0
  109. package/dist/preview/chunk.QAIYYIZQ.js +1 -0
  110. package/dist/preview/chunk.QNNRSPIJ.js +2 -0
  111. package/dist/preview/{chunk.KI6M3EWZ.js → chunk.QSO5BP2H.js} +1 -1
  112. package/dist/preview/{chunk.WICMCZ27.js → chunk.QW3QLE53.js} +1 -1
  113. package/dist/preview/{chunk.WHGEDJB2.js → chunk.QYFZ7AZS.js} +2 -2
  114. package/dist/preview/{chunk.Q6RUTFU3.js → chunk.RDL6652E.js} +1 -1
  115. package/dist/preview/{chunk.MDWCX3YU.js → chunk.RR2IFETZ.js} +1 -1
  116. package/dist/preview/{chunk.R7RDUW37.js → chunk.RXYE2DAJ.js} +1 -1
  117. package/dist/preview/chunk.SDLUWRGI.js +1 -0
  118. package/dist/preview/chunk.SOTB6C5A.js +1 -0
  119. package/dist/preview/{chunk.3SOJJAMY.js → chunk.SRC37GNP.js} +1 -1
  120. package/dist/preview/{chunk.CB7IUKY7.js → chunk.SVAQGVS4.js} +1 -1
  121. package/dist/preview/chunk.T2RME6XF.js +1 -0
  122. package/dist/preview/{chunk.COWJTVZV.js → chunk.T6HG2XIP.js} +1 -1
  123. package/dist/preview/{chunk.6TILXTP6.js → chunk.TAIYNHSW.js} +1 -1
  124. package/dist/preview/chunk.TAJ2R44N.js +1 -0
  125. package/dist/preview/{chunk.BUDEUNBN.js → chunk.TQCRFZ53.js} +1 -1
  126. package/dist/preview/{chunk.ZYW7Q5EN.js → chunk.TXWCTHMI.js} +1 -1
  127. package/dist/preview/chunk.UE5YS3GN.js +1 -0
  128. package/dist/preview/{chunk.C6HBYRGJ.js → chunk.UQQAGT3R.js} +1 -1
  129. package/dist/preview/chunk.USB6B6L3.js +104 -0
  130. package/dist/preview/{chunk.KRVEAIKW.js → chunk.USQNSNIA.js} +1 -1
  131. package/dist/preview/{chunk.AZGXBTOQ.js → chunk.V3NPUAPB.js} +1 -1
  132. package/dist/preview/{chunk.NDI5OWIB.js → chunk.VDD3RHLB.js} +1 -1
  133. package/dist/preview/{chunk.ULSN3ASK.js → chunk.VEOS25PQ.js} +1 -1
  134. package/dist/preview/chunk.VIQ6EF2O.js +1 -0
  135. package/dist/preview/{chunk.OZ4EJ5M6.js → chunk.VLBY66PB.js} +2 -2
  136. package/dist/preview/chunk.VSM72NVF.js +1 -0
  137. package/dist/preview/{chunk.GVUJCOKD.js → chunk.VYW7DSUW.js} +2 -2
  138. package/dist/preview/{chunk.DTJ4FIHM.js → chunk.WMB2NNBD.js} +1 -1
  139. package/dist/preview/{chunk.KJGNLWU3.js → chunk.WPJVMVAL.js} +1 -1
  140. package/dist/preview/{chunk.CB5DGKR5.js → chunk.XGCOWCA2.js} +1 -1
  141. package/dist/preview/chunk.XJFAUOJS.js +1 -0
  142. package/dist/preview/{chunk.7TMWMW4W.js → chunk.XY5EVI22.js} +1 -1
  143. package/dist/preview/chunk.YEJ4LNUP.js +5 -0
  144. package/dist/preview/{chunk.FCZ7UFJI.js → chunk.YL5ZCRHQ.js} +1 -1
  145. package/dist/preview/{chunk.MAWP27FD.js → chunk.YLMOGGEP.js} +1 -1
  146. package/dist/preview/{chunk.WVWXNW74.js → chunk.ZFXHZZHW.js} +1 -1
  147. package/dist/preview/index.html +52 -51
  148. package/dist/preview/page.js +2 -2
  149. package/package.json +6 -6
  150. package/dist/preview/chunk.25P5SDNR.js +0 -1
  151. package/dist/preview/chunk.27O4LIDU.js +0 -1
  152. package/dist/preview/chunk.3G5DEGFA.js +0 -1
  153. package/dist/preview/chunk.3MZIWKNG.js +0 -5
  154. package/dist/preview/chunk.3V2WXZU3.js +0 -1
  155. package/dist/preview/chunk.4BX3KLAA.js +0 -1
  156. package/dist/preview/chunk.4TGQ6Z6E.js +0 -1
  157. package/dist/preview/chunk.57VTD3CU.js +0 -1
  158. package/dist/preview/chunk.5M62CMLA.js +0 -1
  159. package/dist/preview/chunk.5VF2RT4H.js +0 -1
  160. package/dist/preview/chunk.5XAIP3BS.js +0 -1
  161. package/dist/preview/chunk.5ZWE72VJ.js +0 -1
  162. package/dist/preview/chunk.6SPORDJC.js +0 -1
  163. package/dist/preview/chunk.7UD2JR6J.js +0 -1
  164. package/dist/preview/chunk.AG7CUSSV.js +0 -1
  165. package/dist/preview/chunk.C6HI3LRB.js +0 -1
  166. package/dist/preview/chunk.D6ACCKYJ.js +0 -1
  167. package/dist/preview/chunk.EC7I33WI.js +0 -1
  168. package/dist/preview/chunk.GHPCSNM6.js +0 -21
  169. package/dist/preview/chunk.HLDMTKUP.js +0 -1
  170. package/dist/preview/chunk.J3OX474P.js +0 -1
  171. package/dist/preview/chunk.JCFYZEMY.js +0 -1
  172. package/dist/preview/chunk.JLB4QP6Q.js +0 -1
  173. package/dist/preview/chunk.JXGDVJ4N.js +0 -1
  174. package/dist/preview/chunk.K2J26XMB.js +0 -104
  175. package/dist/preview/chunk.KLJDBYAZ.js +0 -1
  176. package/dist/preview/chunk.LNOWO3IY.js +0 -2
  177. package/dist/preview/chunk.LOUICR7K.js +0 -1
  178. package/dist/preview/chunk.LU3B3SZH.js +0 -1
  179. package/dist/preview/chunk.LVOL2LEC.js +0 -1
  180. package/dist/preview/chunk.LYFEGG6E.js +0 -1
  181. package/dist/preview/chunk.MPMROUZA.js +0 -1
  182. package/dist/preview/chunk.MVRNEC3Y.js +0 -2
  183. package/dist/preview/chunk.OLKFEHWB.js +0 -1
  184. package/dist/preview/chunk.PCNEM3WE.js +0 -1
  185. package/dist/preview/chunk.QB7RYJ67.js +0 -5
  186. package/dist/preview/chunk.RLO3RDYH.js +0 -2
  187. package/dist/preview/chunk.RYMSHMLM.js +0 -1
  188. package/dist/preview/chunk.SF4BYBH6.js +0 -25
  189. package/dist/preview/chunk.SG7YVKH4.js +0 -1
  190. package/dist/preview/chunk.T42H5RXN.js +0 -1
  191. package/dist/preview/chunk.TI4OSTQV.js +0 -1
  192. package/dist/preview/chunk.VFMC45E7.js +0 -1
  193. package/dist/preview/chunk.VWQ57LTT.js +0 -18
  194. package/dist/preview/chunk.Y36MLVMT.js +0 -1
  195. package/dist/preview/chunk.Z6O7RUSR.js +0 -1
  196. package/dist/preview/chunk.ZAGP3OKY.js +0 -1
  197. package/dist/preview/chunk.ZUBC3UFG.js +0 -2
@@ -1 +1 @@
1
- import{a as U,b as Y,c as G,d as D}from"./chunk.JTOAZ2IR.js";import"./chunk.FWZF7X6A.js";import"./chunk.3JMZHCB4.js";import{G as ae,O as L,P as F,T as V,ca as _}from"./chunk.SF4BYBH6.js";import"./chunk.SDO3U72B.js";import{Qc as M,R as H,Xa as K,Ya as B}from"./chunk.3MZIWKNG.js";import"./chunk.SLBWPVIY.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
+ import{a as U,b as Y,c as G,d as D}from"./chunk.MJMVGW6Z.js";import"./chunk.HFVMGTNL.js";import"./chunk.7Z4USR3Y.js";import{G as ae,O as L,P as F,T as V,ca as _}from"./chunk.NPAWTPLQ.js";import"./chunk.SDO3U72B.js";import{T as H,Vc as M,Za as K,_a as B}from"./chunk.YEJ4LNUP.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,4 +1,4 @@
1
- import{a as z,b as Y,d as ee}from"./chunk.LU3B3SZH.js";import"./chunk.HLDMTKUP.js";import{bc as J,da as Q,ha as U,ma as X,qa as _}from"./chunk.3MZIWKNG.js";import"./chunk.SLBWPVIY.js";import"./chunk.AJZBJBMO.js";function ce(t){let r=t?.indexOf(":")??-1;if(!(!t||r<=0||r===t.length-1))return{relation:t.slice(0,r),record:t.slice(r+1)}}function ne(t,r){if(t.length===0)return!0;let d=`${r.split("/")[0]}/*`;return t.some(a=>a==="*"||a==="*/*"||a===r||a===d)}function re(t,r){let d=r.startsWith("image/")?"image":r.startsWith("video/")?"video":"file";return t.find(a=>a.as===d)??t.find(a=>a.as==="file")}function fe(t,r){let d=new Set(t.map(k=>k.as==="image"?"image/":k.as==="video"?"video/":""));if(d.has("")||r.kinds.length===0)return r.kinds.join(",");let a=[];for(let k of d){let m=r.kinds.filter(l=>l.startsWith(k));a.push(...m.length>0?m:[`${k}*`])}return a.join(",")}var T=t=>t.input?.shape??{},ie=(t,r)=>T(t)[r]?.safeParse(void 0).success===!1;function ae(t,r){let d=new Set(z(t.input).map(a=>a.name));return Object.keys(T(t)).filter(a=>!r.has(a)&&!d.has(a)&&ie(t,a)&&T(t)[a].safeParse("a name").success&&!T(t)[a].safeParse(1).success)}var ue=t=>t.replace(/\.[a-z0-9]{1,5}$/i,"")||t,se=(t,r)=>{let d=Number.isFinite(Date.parse(r))?new Date(Date.parse(r)).toISOString():r;return[r,d,d.replace(/\.\d{3}Z$/,"Z"),r.slice(0,10)].find(a=>t.safeParse(a).success)},pe="2026-01-01T00:00:00.000Z";function te(t,r){let d=T(t),a=new Set(ae(t,r)),k=Object.keys(d).filter(l=>!r.has(l)&&!a.has(l)&&ie(t,l)),m=k.filter(l=>se(d[l],pe)!==void 0);return{timed:m,left:k.filter(l=>!m.includes(l))}}function oe(t,r,d,a,k){let m=e=>({ok:!1,says:e}),{kind:l}=a,R=(d.accepts??[]).filter(e=>e.kind===l&&(a.field===void 0||e.field===a.field));if(R.length===0)return m(a.field===void 0?`The view's accepts names no field of "${l}", so nothing dropped there can become one.`:`The view's accepts does not name ${l}'s "${a.field}".`);let A=k.files;if(!A||!(A.maxBytes>0))return m("This host takes no files.");let j=R.flatMap(e=>{let n=ee(t,e.kind,e.field);return n?[{field:e.field,...n}]:[]}),w=j.filter(e=>e.as==="file"||A.kinds.length===0||A.kinds.some(n=>n==="*"||n==="*/*"||n.startsWith(e.as==="image"?"image/":"video/")));if(w.length===0)return m(`This host takes none of what ${l}'s ${j.map(e=>`"${e.field}"`).join(" or ")} holds.`);let c=a.connect===void 0?void 0:ce(a.connect);if(a.connect!==void 0&&(!c||k.shown.has(a.connect)))return m(`data-drop-connect is "<relation>:<record id>", not "${a.connect}".`);if(c&&!k.shown.has(c.record))return m(`data-drop-connect names "${c.record}", which this view was not shown.`);let g=c?t.seenBy(r).graph.getNode(c.record):void 0;if(c&&!g)return m(`data-drop-connect names "${c.record}", which this seat does not see.`);let $=e=>Object.hasOwn(t.schema.tryDefinition(e)?.edges??{},c.relation),E=c?$(l):!1;if(c&&!E&&!$(g.kind))return m(`Neither a "${l}" nor a "${g.kind}" has the relation "${c.relation}".`);let H=t.allMutations(),F=e=>t.permits(e,r).ok,Z=e=>w.every(n=>Object.hasOwn(T(e),n.field)),V=H.filter(e=>(e.creates??[]).includes(l)&&Z(e)),x=X(t.schema.tryDefinition(l),l),O=U(t.schema,l).toLowerCase(),S=g?Q(t.schema.tryDefinition(g.kind),g):void 0,G=e=>`${e===1?`a ${x}`:`${e} ${O}`}${S?` to ${S}`:""}`,K=e=>`Add ${G(e)}`,L=e=>`Added ${G(e)}.`,B=`Drop to add ${O}${S?` to ${S}`:""}.`,N=(e,n,u,v)=>{let I=new Set(Object.keys(n)),D=_(u.at)??v??new Date().toISOString();for(let C of te(e,I).timed)n[C]=se(T(e)[C],D);for(let C of ae(e,I))n[C]=ue(u.name);return n},q=(e,...n)=>new Set([...w.map(u=>u.field),...n,...z(e.input).map(u=>u.name)]),P=(e,...n)=>te(e,q(e,...n)).left,i=(e,n)=>m(`"${e.title??e.name}" asks for ${n.map(u=>`"${u}"`).join(" and ")}, which no dropped file says, so nothing dropped here can become a ${x}.`),o=(e,n)=>e.list?[n]:n,f={ok:!0,kind:l,fields:w,accept:fe(w,A),...c?{connect:c}:{},intent:K,invite:B,added:L};if(!c){let e=V.find(n=>!n.subject&&F({name:n.name,args:{}}));return e?P(e).length>0?i(e,P(e)):{...f,calls:n=>[{name:e.name,args:N(e,{[n.field]:o(w.find(u=>u.field===n.field),n.value)},n.value,n.at)}]}:m(`This seat may not make a "${l}" here.`)}let s=V.find(e=>e.subject&&(e.subject.kinds==="*"||e.subject.kinds.includes(g.kind))&&(e.connects??[]).includes(c.relation)&&F({name:e.name,args:{[e.subject.arg]:c.record}}));if(s){let e=s.subject.arg;return P(s,e).length>0?i(s,P(s,e)):{...f,calls:n=>[{name:s.name,args:N(s,{[e]:c.record,[n.field]:o(w.find(u=>u.field===n.field),n.value)},n.value,n.at)}]}}let p=V.find(e=>!e.subject&&F({name:e.name,args:{}}));if(!p)return m(`This seat may not make a "${l}" here.`);if(P(p).length>0)return i(p,P(p));let y=E?l:g.kind,W=E?g.kind:l,M=H.find(e=>{if(!(e.connects??[]).includes(c.relation)||!e.subject)return!1;let n=e.subject.kinds;if(n!=="*"&&!n.includes(y))return!1;let u=z(e.input).find(v=>v.name!==e.subject.arg&&(v.kinds.includes("*")||v.kinds.includes(W)));return u?F({name:e.name,args:E?{[u.name]:c.record}:{[e.subject.arg]:c.record}}):!1});if(!M)return m(`This seat may not link a "${l}" to ${c.record} by "${c.relation}".`);let h=M.subject.arg,b=z(M.input).find(e=>e.name!==h&&(e.kinds.includes("*")||e.kinds.includes(W))).name;return{...f,calls:(e,n)=>[{name:p.name,args:N(p,{[e.field]:o(w.find(u=>u.field===e.field),e.value)},e.value,e.at)},{name:M.name,args:E?{[h]:J(n*2),[b]:c.record}:{[h]:c.record,[b]:J(n*2)}}]}}var de=t=>t.type.startsWith("image/"),me=t=>t.type.startsWith("video/"),ge=`
1
+ import{a as z,b as Y,d as ee}from"./chunk.AGTFYPXY.js";import"./chunk.FBR4HJ2Q.js";import{ec as J,ga as Q,ja as U,oa as X,sa as _}from"./chunk.YEJ4LNUP.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";function ce(t){let r=t?.indexOf(":")??-1;if(!(!t||r<=0||r===t.length-1))return{relation:t.slice(0,r),record:t.slice(r+1)}}function ne(t,r){if(t.length===0)return!0;let d=`${r.split("/")[0]}/*`;return t.some(a=>a==="*"||a==="*/*"||a===r||a===d)}function re(t,r){let d=r.startsWith("image/")?"image":r.startsWith("video/")?"video":"file";return t.find(a=>a.as===d)??t.find(a=>a.as==="file")}function fe(t,r){let d=new Set(t.map(k=>k.as==="image"?"image/":k.as==="video"?"video/":""));if(d.has("")||r.kinds.length===0)return r.kinds.join(",");let a=[];for(let k of d){let m=r.kinds.filter(l=>l.startsWith(k));a.push(...m.length>0?m:[`${k}*`])}return a.join(",")}var T=t=>t.input?.shape??{},ie=(t,r)=>T(t)[r]?.safeParse(void 0).success===!1;function ae(t,r){let d=new Set(z(t.input).map(a=>a.name));return Object.keys(T(t)).filter(a=>!r.has(a)&&!d.has(a)&&ie(t,a)&&T(t)[a].safeParse("a name").success&&!T(t)[a].safeParse(1).success)}var ue=t=>t.replace(/\.[a-z0-9]{1,5}$/i,"")||t,se=(t,r)=>{let d=Number.isFinite(Date.parse(r))?new Date(Date.parse(r)).toISOString():r;return[r,d,d.replace(/\.\d{3}Z$/,"Z"),r.slice(0,10)].find(a=>t.safeParse(a).success)},pe="2026-01-01T00:00:00.000Z";function te(t,r){let d=T(t),a=new Set(ae(t,r)),k=Object.keys(d).filter(l=>!r.has(l)&&!a.has(l)&&ie(t,l)),m=k.filter(l=>se(d[l],pe)!==void 0);return{timed:m,left:k.filter(l=>!m.includes(l))}}function oe(t,r,d,a,k){let m=e=>({ok:!1,says:e}),{kind:l}=a,R=(d.accepts??[]).filter(e=>e.kind===l&&(a.field===void 0||e.field===a.field));if(R.length===0)return m(a.field===void 0?`The view's accepts names no field of "${l}", so nothing dropped there can become one.`:`The view's accepts does not name ${l}'s "${a.field}".`);let A=k.files;if(!A||!(A.maxBytes>0))return m("This host takes no files.");let j=R.flatMap(e=>{let n=ee(t,e.kind,e.field);return n?[{field:e.field,...n}]:[]}),w=j.filter(e=>e.as==="file"||A.kinds.length===0||A.kinds.some(n=>n==="*"||n==="*/*"||n.startsWith(e.as==="image"?"image/":"video/")));if(w.length===0)return m(`This host takes none of what ${l}'s ${j.map(e=>`"${e.field}"`).join(" or ")} holds.`);let c=a.connect===void 0?void 0:ce(a.connect);if(a.connect!==void 0&&(!c||k.shown.has(a.connect)))return m(`data-drop-connect is "<relation>:<record id>", not "${a.connect}".`);if(c&&!k.shown.has(c.record))return m(`data-drop-connect names "${c.record}", which this view was not shown.`);let g=c?t.seenBy(r).graph.getNode(c.record):void 0;if(c&&!g)return m(`data-drop-connect names "${c.record}", which this seat does not see.`);let $=e=>Object.hasOwn(t.schema.tryDefinition(e)?.edges??{},c.relation),E=c?$(l):!1;if(c&&!E&&!$(g.kind))return m(`Neither a "${l}" nor a "${g.kind}" has the relation "${c.relation}".`);let H=t.allMutations(),F=e=>t.permits(e,r).ok,Z=e=>w.every(n=>Object.hasOwn(T(e),n.field)),V=H.filter(e=>(e.creates??[]).includes(l)&&Z(e)),x=X(t.schema.tryDefinition(l),l),O=U(t.schema,l).toLowerCase(),S=g?Q(t.schema.tryDefinition(g.kind),g):void 0,G=e=>`${e===1?`a ${x}`:`${e} ${O}`}${S?` to ${S}`:""}`,K=e=>`Add ${G(e)}`,L=e=>`Added ${G(e)}.`,B=`Drop to add ${O}${S?` to ${S}`:""}.`,N=(e,n,u,v)=>{let I=new Set(Object.keys(n)),D=_(u.at)??v??new Date().toISOString();for(let C of te(e,I).timed)n[C]=se(T(e)[C],D);for(let C of ae(e,I))n[C]=ue(u.name);return n},q=(e,...n)=>new Set([...w.map(u=>u.field),...n,...z(e.input).map(u=>u.name)]),P=(e,...n)=>te(e,q(e,...n)).left,i=(e,n)=>m(`"${e.title??e.name}" asks for ${n.map(u=>`"${u}"`).join(" and ")}, which no dropped file says, so nothing dropped here can become a ${x}.`),o=(e,n)=>e.list?[n]:n,f={ok:!0,kind:l,fields:w,accept:fe(w,A),...c?{connect:c}:{},intent:K,invite:B,added:L};if(!c){let e=V.find(n=>!n.subject&&F({name:n.name,args:{}}));return e?P(e).length>0?i(e,P(e)):{...f,calls:n=>[{name:e.name,args:N(e,{[n.field]:o(w.find(u=>u.field===n.field),n.value)},n.value,n.at)}]}:m(`This seat may not make a "${l}" here.`)}let s=V.find(e=>e.subject&&(e.subject.kinds==="*"||e.subject.kinds.includes(g.kind))&&(e.connects??[]).includes(c.relation)&&F({name:e.name,args:{[e.subject.arg]:c.record}}));if(s){let e=s.subject.arg;return P(s,e).length>0?i(s,P(s,e)):{...f,calls:n=>[{name:s.name,args:N(s,{[e]:c.record,[n.field]:o(w.find(u=>u.field===n.field),n.value)},n.value,n.at)}]}}let p=V.find(e=>!e.subject&&F({name:e.name,args:{}}));if(!p)return m(`This seat may not make a "${l}" here.`);if(P(p).length>0)return i(p,P(p));let y=E?l:g.kind,W=E?g.kind:l,M=H.find(e=>{if(!(e.connects??[]).includes(c.relation)||!e.subject)return!1;let n=e.subject.kinds;if(n!=="*"&&!n.includes(y))return!1;let u=z(e.input).find(v=>v.name!==e.subject.arg&&(v.kinds.includes("*")||v.kinds.includes(W)));return u?F({name:e.name,args:E?{[u.name]:c.record}:{[e.subject.arg]:c.record}}):!1});if(!M)return m(`This seat may not link a "${l}" to ${c.record} by "${c.relation}".`);let h=M.subject.arg,b=z(M.input).find(e=>e.name!==h&&(e.kinds.includes("*")||e.kinds.includes(W))).name;return{...f,calls:(e,n)=>[{name:p.name,args:N(p,{[e.field]:o(w.find(u=>u.field===e.field),e.value)},e.value,e.at)},{name:M.name,args:E?{[h]:J(n*2),[b]:c.record}:{[h]:c.record,[b]:J(n*2)}}]}}var de=t=>t.type.startsWith("image/"),me=t=>t.type.startsWith("video/"),ge=`
2
2
  [data-graview-drop-over] { outline: 2px dashed var(--graview-accent, Highlight) !important; outline-offset: 2px !important; background-color: color-mix(in srgb, var(--graview-accent, Highlight) 10%, transparent) !important; }
3
3
  [data-graview-drop-status], [data-graview-drop-refused] { margin: 4px 0 0; font: 0.8125rem/1.4 var(--graview-font-body, system-ui, sans-serif); color: var(--graview-ink-muted, GrayText); }
4
4
  [data-graview-drop-refused] { color: var(--graview-warn, var(--graview-ink, CanvasText)); }
@@ -1 +1 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{s as P}from"./chunk.PZWJUQAO.js";import{G as M,Ga as S,O as w,T as y,ba as m,ca as I,s as b,w as T,x as A}from"./chunk.SF4BYBH6.js";import{a as p}from"./chunk.SDO3U72B.js";import{b as f}from"./chunk.AJZBJBMO.js";var C=f(M(),1),h=f(y(),1),x=S(p(()=>(__graviewPreload(import.meta.url,["./chunk.JTOAZ2IR.js","./chunk.FWZF7X6A.js","./chunk.3JMZHCB4.js","./chunk.SF4BYBH6.js","./chunk.SDO3U72B.js","./chunk.3MZIWKNG.js","./chunk.SLBWPVIY.js","./chunk.AJZBJBMO.js"]),import("./chunk.VW6X53E7.js")))),O=x.part((e,n)=>(0,h.jsx)(e.Timeline,{...n}),{what:"The timeline"}),q=()=>x.prefetch();function K({face:e}){return w()?.open?(0,h.jsx)(C.Suspense,{fallback:null,children:(0,h.jsx)(O,{face:e})}):null}var i=f(M(),1),u=f(y(),1),v=new WeakMap,D=e=>{let n=v.get(e);return n||v.set(e,n={ask:null,doors:[],listeners:new Set}),n},k=e=>{for(let n of e.listeners)n()};function g(e,n){let t=D(e);t.ask=n,k(t)}var N=S(p(()=>(__graviewPreload(import.meta.url,["./chunk.RBYRT2I2.js","./chunk.JTOAZ2IR.js","./chunk.3IEJQAK7.js","./chunk.AKLVSZ5A.js","./chunk.ZUBC3UFG.js","./chunk.FWZF7X6A.js","./chunk.3JMZHCB4.js","./chunk.SF4BYBH6.js","./chunk.SDO3U72B.js","./chunk.3MZIWKNG.js","./chunk.SLBWPVIY.js","./chunk.AJZBJBMO.js"]),import("./chunk.U7GN6UPR.js")))),B=N.part((e,n)=>{let t=e.NotifySheet;return(0,u.jsx)(t,{...n})},{what:"Notify me"}),W=N.part((e,n)=>{let t=e.NotifiedList;return(0,u.jsx)(t,{...n})},{quiet:!0}),E=(e,n)=>n===void 0&&(e.onBehalfOf??e).id!==void 0;function F(e,n,t){let c=d=>t.tryDefinition(d)?.noun??d.replace(/[-_]+/g," "),o=e.on!==void 0?e.on:e.about.length===1?e.about[0]:void 0;if(e.act!==void 0){let d=o!==void 0&&n(o)!==void 0?o:void 0;return{label:"Notify me when someone does this\u2026",choices:[{on:"act",act:e.act,...d!==void 0?{record:d}:{}},...d!==void 0?[{on:"act",act:e.act}]:[]]}}if(o===void 0)return null;let s=n(o);if(s!==void 0)return{label:"Notify me when this changes\u2026",choices:[{on:"changed",record:o},{on:"act",record:o},{on:"reaches",kind:s,condition:"",record:o}]};let r=b(o)!==null?[b(o)]:T(o)?A(o):[];if(r.length!==1||!t.kinds.includes(r[0]))return null;let l=r[0],a=c(l);return{label:`Notify me when ${/^[aeiou]/i.test(a)?"an":"a"} ${a} is added\u2026`,choices:[{on:"created",kind:l},{on:"changed",kind:l},{on:"reaches",kind:l,condition:""}]}}function L(){let{store:e,principal:n,subscriptions:t,signIn:c}=m(),o=E(n,c);return(0,i.useMemo)(()=>o?s=>{let r=F(s,a=>e.graph.getNode(a)?.kind,e.schema);return r?{id:"notify",items:[{id:"notify-me",label:r.label,run:()=>g(t,{choices:r.choices,returnTo:s.element??null})}],prepare:()=>N.prefetch()}:null}:null,[o,e,t])}var z=[];function U({children:e}){let n=L(),t=(0,i.useMemo)(()=>n?[n]:z,[n]);return(0,u.jsx)(P,{sections:t,children:e})}function V(){let{subscriptions:e}=m(),n=(0,i.useId)(),t=D(e);(0,i.useEffect)(()=>(t.doors.push(n),k(t),()=>{t.doors.splice(t.doors.indexOf(n),1),k(t)}),[t,n]);let c=(0,i.useMemo)(()=>r=>(t.listeners.add(r),()=>void t.listeners.delete(r)),[t]),o=(0,i.useSyncExternalStore)(c,()=>t.ask,()=>null),s=(0,i.useSyncExternalStore)(c,()=>t.doors[0]===n,()=>!1);return!o||!s?null:(0,u.jsx)(i.Suspense,{fallback:null,children:(0,u.jsx)(B,{ask:o,close:()=>g(e,null)})})}function X({choices:e,label:n="Notify me",style:t,className:c,testId:o="notify-me"}){let{principal:s,subscriptions:r,signIn:l}=m();return E(s,l)?(0,u.jsx)("button",{type:"button","data-testid":o,className:c,onClick:a=>g(r,{choices:e,returnTo:a.currentTarget}),style:t,children:n}):null}function G(){let e=I(),n=e?.subscriptions,t=e?(e.principal.onBehalfOf??e.principal).id:void 0,[c,o]=(0,i.useState)(0);return(0,i.useEffect)(()=>{if(t===void 0||!n)return;let s=!0,r=()=>void Promise.resolve(n.list(t)).then(a=>s&&o(a.length),()=>s&&o(0));r();let l=n.onChange?.(r);return()=>{s=!1,l?.()}},[n,t]),c}function Y({style:e}){return G()===0?null:(0,u.jsx)(i.Suspense,{fallback:null,children:(0,u.jsx)(W,{...e?{style:e}:{}})})}export{q as a,K as b,L as c,U as d,V as e,X as f,G as g,Y as h};
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{s as P}from"./chunk.E5XNQTEU.js";import{G as M,Ga as S,O as w,T as y,ba as m,ca as I,s as b,w as T,x as A}from"./chunk.NPAWTPLQ.js";import{a as p}from"./chunk.SDO3U72B.js";import{b as f}from"./chunk.AJZBJBMO.js";var C=f(M(),1),h=f(y(),1),x=S(p(()=>(__graviewPreload(import.meta.url,["./chunk.MJMVGW6Z.js","./chunk.HFVMGTNL.js","./chunk.7Z4USR3Y.js","./chunk.NPAWTPLQ.js","./chunk.SDO3U72B.js","./chunk.YEJ4LNUP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.N7EEPFYV.js")))),O=x.part((e,n)=>(0,h.jsx)(e.Timeline,{...n}),{what:"The timeline"}),q=()=>x.prefetch();function K({face:e}){return w()?.open?(0,h.jsx)(C.Suspense,{fallback:null,children:(0,h.jsx)(O,{face:e})}):null}var i=f(M(),1),u=f(y(),1),v=new WeakMap,D=e=>{let n=v.get(e);return n||v.set(e,n={ask:null,doors:[],listeners:new Set}),n},k=e=>{for(let n of e.listeners)n()};function g(e,n){let t=D(e);t.ask=n,k(t)}var N=S(p(()=>(__graviewPreload(import.meta.url,["./chunk.2HZGUVB2.js","./chunk.MJMVGW6Z.js","./chunk.6HLKAUWF.js","./chunk.FCUDBMGC.js","./chunk.KMEKMCKG.js","./chunk.HFVMGTNL.js","./chunk.7Z4USR3Y.js","./chunk.NPAWTPLQ.js","./chunk.SDO3U72B.js","./chunk.YEJ4LNUP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.ILSK2E3R.js")))),B=N.part((e,n)=>{let t=e.NotifySheet;return(0,u.jsx)(t,{...n})},{what:"Notify me"}),W=N.part((e,n)=>{let t=e.NotifiedList;return(0,u.jsx)(t,{...n})},{quiet:!0}),E=(e,n)=>n===void 0&&(e.onBehalfOf??e).id!==void 0;function F(e,n,t){let c=d=>t.tryDefinition(d)?.noun??d.replace(/[-_]+/g," "),o=e.on!==void 0?e.on:e.about.length===1?e.about[0]:void 0;if(e.act!==void 0){let d=o!==void 0&&n(o)!==void 0?o:void 0;return{label:"Notify me when someone does this\u2026",choices:[{on:"act",act:e.act,...d!==void 0?{record:d}:{}},...d!==void 0?[{on:"act",act:e.act}]:[]]}}if(o===void 0)return null;let s=n(o);if(s!==void 0)return{label:"Notify me when this changes\u2026",choices:[{on:"changed",record:o},{on:"act",record:o},{on:"reaches",kind:s,condition:"",record:o}]};let r=b(o)!==null?[b(o)]:T(o)?A(o):[];if(r.length!==1||!t.kinds.includes(r[0]))return null;let l=r[0],a=c(l);return{label:`Notify me when ${/^[aeiou]/i.test(a)?"an":"a"} ${a} is added\u2026`,choices:[{on:"created",kind:l},{on:"changed",kind:l},{on:"reaches",kind:l,condition:""}]}}function L(){let{store:e,principal:n,subscriptions:t,signIn:c}=m(),o=E(n,c);return(0,i.useMemo)(()=>o?s=>{let r=F(s,a=>e.graph.getNode(a)?.kind,e.schema);return r?{id:"notify",items:[{id:"notify-me",label:r.label,run:()=>g(t,{choices:r.choices,returnTo:s.element??null})}],prepare:()=>N.prefetch()}:null}:null,[o,e,t])}var z=[];function U({children:e}){let n=L(),t=(0,i.useMemo)(()=>n?[n]:z,[n]);return(0,u.jsx)(P,{sections:t,children:e})}function V(){let{subscriptions:e}=m(),n=(0,i.useId)(),t=D(e);(0,i.useEffect)(()=>(t.doors.push(n),k(t),()=>{t.doors.splice(t.doors.indexOf(n),1),k(t)}),[t,n]);let c=(0,i.useMemo)(()=>r=>(t.listeners.add(r),()=>void t.listeners.delete(r)),[t]),o=(0,i.useSyncExternalStore)(c,()=>t.ask,()=>null),s=(0,i.useSyncExternalStore)(c,()=>t.doors[0]===n,()=>!1);return!o||!s?null:(0,u.jsx)(i.Suspense,{fallback:null,children:(0,u.jsx)(B,{ask:o,close:()=>g(e,null)})})}function X({choices:e,label:n="Notify me",style:t,className:c,testId:o="notify-me"}){let{principal:s,subscriptions:r,signIn:l}=m();return E(s,l)?(0,u.jsx)("button",{type:"button","data-testid":o,className:c,onClick:a=>g(r,{choices:e,returnTo:a.currentTarget}),style:t,children:n}):null}function G(){let e=I(),n=e?.subscriptions,t=e?(e.principal.onBehalfOf??e.principal).id:void 0,[c,o]=(0,i.useState)(0);return(0,i.useEffect)(()=>{if(t===void 0||!n)return;let s=!0,r=()=>void Promise.resolve(n.list(t)).then(a=>s&&o(a.length),()=>s&&o(0));r();let l=n.onChange?.(r);return()=>{s=!1,l?.()}},[n,t]),c}function Y({style:e}){return G()===0?null:(0,u.jsx)(i.Suspense,{fallback:null,children:(0,u.jsx)(W,{...e?{style:e}:{}})})}export{q as a,K as b,L as c,U as d,V as e,X as f,G as g,Y as h};
@@ -0,0 +1,25 @@
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 Ye}from"./chunk.SDO3U72B.js";import{$d as Rt,Ed as ao,Ia as Xn,L as Zn,Ma as kt,Oa as Jn,Ud as so,Vc as to,Yd as lo,_a as Qn,_d as Ue,dd as no,fd as oo,ld as ro,od as io,uc as eo}from"./chunk.YEJ4LNUP.js";import{a as $e,b as H}from"./chunk.AJZBJBMO.js";var To=$e(w=>{"use strict";var _t=Symbol.for("react.transitional.element"),ti=Symbol.for("react.portal"),ni=Symbol.for("react.fragment"),oi=Symbol.for("react.strict_mode"),ri=Symbol.for("react.profiler"),ii=Symbol.for("react.consumer"),ai=Symbol.for("react.context"),si=Symbol.for("react.forward_ref"),li=Symbol.for("react.suspense"),di=Symbol.for("react.memo"),xo=Symbol.for("react.lazy"),ui=Symbol.for("react.activity"),So=Symbol.iterator;function ci(e){return e===null||typeof e!="object"?null:(e=So&&e[So]||e["@@iterator"],typeof e=="function"?e:null)}var Eo={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Po=Object.assign,Ao={};function he(e,t,n){this.props=e,this.context=t,this.refs=Ao,this.updater=n||Eo}he.prototype.isReactComponent={};he.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};he.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function ko(){}ko.prototype=he.prototype;function Ht(e,t,n){this.props=e,this.context=t,this.refs=Ao,this.updater=n||Eo}var Dt=Ht.prototype=new ko;Dt.constructor=Ht;Po(Dt,he.prototype);Dt.isPureReactComponent=!0;var wo=Array.isArray;function Lt(){}var O={H:null,A:null,T:null,S:null},Ro=Object.prototype.hasOwnProperty;function Nt(e,t,n){var o=n.ref;return{$$typeof:_t,type:e,key:t,ref:o!==void 0?o:null,props:n}}function pi(e,t){return Nt(e.type,t,e.props)}function jt(e){return typeof e=="object"&&e!==null&&e.$$typeof===_t}function fi(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var vo=/\/+/g;function It(e,t){return typeof e=="object"&&e!==null&&e.key!=null?fi(""+e.key):t.toString(36)}function yi(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch(typeof e.status=="string"?e.then(Lt,Lt):(e.status="pending",e.then(function(t){e.status==="pending"&&(e.status="fulfilled",e.value=t)},function(t){e.status==="pending"&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}function ge(e,t,n,o,r){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(i){case"bigint":case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case _t:case ti:a=!0;break;case xo:return a=e._init,ge(a(e._payload),t,n,o,r)}}if(a)return r=r(e),a=o===""?"."+It(e,0):o,wo(r)?(n="",a!=null&&(n=a.replace(vo,"$&/")+"/"),ge(r,t,n,"",function(c){return c})):r!=null&&(jt(r)&&(r=pi(r,n+(r.key==null||e&&e.key===r.key?"":(""+r.key).replace(vo,"$&/")+"/")+a)),t.push(r)),1;a=0;var s=o===""?".":o+":";if(wo(e))for(var l=0;l<e.length;l++)o=e[l],i=s+It(o,l),a+=ge(o,t,n,i,r);else if(l=ci(e),typeof l=="function")for(e=l.call(e),l=0;!(o=e.next()).done;)o=o.value,i=s+It(o,l++),a+=ge(o,t,n,i,r);else if(i==="object"){if(typeof e.then=="function")return ge(yi(e),t,n,o,r);throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.")}return a}function ot(e,t,n){if(e==null)return e;var o=[],r=0;return ge(e,o,"","",function(i){return t.call(n,i,r++)}),o}function mi(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var bo=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},gi={map:ot,forEach:function(e,t,n){ot(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ot(e,function(){t++}),t},toArray:function(e){return ot(e,function(t){return t})||[]},only:function(e){if(!jt(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};w.Activity=ui;w.Children=gi;w.Component=he;w.Fragment=ni;w.Profiler=ri;w.PureComponent=Ht;w.StrictMode=oi;w.Suspense=li;w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=O;w.__COMPILER_RUNTIME={__proto__:null,c:function(e){return O.H.useMemoCache(e)}};w.cache=function(e){return function(){return e.apply(null,arguments)}};w.cacheSignal=function(){return null};w.cloneElement=function(e,t,n){if(e==null)throw Error("The argument must be a React element, but you passed "+e+".");var o=Po({},e.props),r=e.key;if(t!=null)for(i in t.key!==void 0&&(r=""+t.key),t)!Ro.call(t,i)||i==="key"||i==="__self"||i==="__source"||i==="ref"&&t.ref===void 0||(o[i]=t[i]);var i=arguments.length-2;if(i===1)o.children=n;else if(1<i){for(var a=Array(i),s=0;s<i;s++)a[s]=arguments[s+2];o.children=a}return Nt(e.type,r,o)};w.createContext=function(e){return e={$$typeof:ai,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:ii,_context:e},e};w.createElement=function(e,t,n){var o,r={},i=null;if(t!=null)for(o in t.key!==void 0&&(i=""+t.key),t)Ro.call(t,o)&&o!=="key"&&o!=="__self"&&o!=="__source"&&(r[o]=t[o]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var s=Array(a),l=0;l<a;l++)s[l]=arguments[l+2];r.children=s}if(e&&e.defaultProps)for(o in a=e.defaultProps,a)r[o]===void 0&&(r[o]=a[o]);return Nt(e,i,r)};w.createRef=function(){return{current:null}};w.forwardRef=function(e){return{$$typeof:si,render:e}};w.isValidElement=jt;w.lazy=function(e){return{$$typeof:xo,_payload:{_status:-1,_result:e},_init:mi}};w.memo=function(e,t){return{$$typeof:di,type:e,compare:t===void 0?null:t}};w.startTransition=function(e){var t=O.T,n={};O.T=n;try{var o=e(),r=O.S;r!==null&&r(n,o),typeof o=="object"&&o!==null&&typeof o.then=="function"&&o.then(Lt,bo)}catch(i){bo(i)}finally{t!==null&&n.types!==null&&(t.types=n.types),O.T=t}};w.unstable_useCacheRefresh=function(){return O.H.useCacheRefresh()};w.use=function(e){return O.H.use(e)};w.useActionState=function(e,t,n){return O.H.useActionState(e,t,n)};w.useCallback=function(e,t){return O.H.useCallback(e,t)};w.useContext=function(e){return O.H.useContext(e)};w.useDebugValue=function(){};w.useDeferredValue=function(e,t){return O.H.useDeferredValue(e,t)};w.useEffect=function(e,t){return O.H.useEffect(e,t)};w.useEffectEvent=function(e){return O.H.useEffectEvent(e)};w.useId=function(){return O.H.useId()};w.useImperativeHandle=function(e,t,n){return O.H.useImperativeHandle(e,t,n)};w.useInsertionEffect=function(e,t){return O.H.useInsertionEffect(e,t)};w.useLayoutEffect=function(e,t){return O.H.useLayoutEffect(e,t)};w.useMemo=function(e,t){return O.H.useMemo(e,t)};w.useOptimistic=function(e,t){return O.H.useOptimistic(e,t)};w.useReducer=function(e,t,n){return O.H.useReducer(e,t,n)};w.useRef=function(e){return O.H.useRef(e)};w.useState=function(e){return O.H.useState(e)};w.useSyncExternalStore=function(e,t,n){return O.H.useSyncExternalStore(e,t,n)};w.useTransition=function(){return O.H.useTransition()};w.version="19.2.8"});var W=$e((es,Mo)=>{"use strict";Mo.exports=To()});var Wo=$e(at=>{"use strict";var ki=Symbol.for("react.transitional.element"),Ri=Symbol.for("react.fragment");function jo(e,t,n){var o=null;if(n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),"key"in t){n={};for(var r in t)r!=="key"&&(n[r]=t[r])}else n=t;return t=n.ref,{$$typeof:ki,type:e,key:o,ref:t!==void 0?t:null,props:n}}at.Fragment=Ri;at.jsx=jo;at.jsxs=jo});var De=$e((us,Go)=>{"use strict";Go.exports=Wo()});var fe={focusId:null,relation:null,expanded:[],pins:{}},Ze=e=>{let t=Number(e);return Number.isFinite(t)?t:null};function Q(e){let t=new URLSearchParams;e.focusId&&t.set("focus",e.focusId),e.relation&&t.set("relation",e.relation),e.overview&&t.set("overview","1"),e.zoom&&t.set("zoom","1"),e.past&&t.set("past","1"),e.shown&&e.shown.length>0&&t.set("show",[...e.shown].sort().join(",")),e.selection!==void 0&&e.selection.length>0&&t.set("sel",[...e.selection].sort().join(",")),e.expanded.length>0&&t.set("expand",[...e.expanded].sort().join(","));for(let o of Object.keys(e.pins).sort()){let r=e.pins[o];t.set(`pin.${o}`,`${Xe(r.x)},${Xe(r.y)}`)}e.pan&&(e.pan.x!==0||e.pan.y!==0)&&t.set("pan",`${Xe(e.pan.x)},${Xe(e.pan.y)}`);for(let o of Object.keys(e.within??{}).sort()){let r=e.within[o];r.length>0&&t.set(`in.${o}`,r)}e.q&&e.q.trim().length>0&&t.set("q",e.q);let n=t.toString();return n?`#${n}`:"#"}function Yr(e){return e&&e.startsWith("agg:")?`aggregate:${e.slice(4)}`:e}function Je(e){let t=e.includes("#")?e.slice(e.indexOf("#")+1):e,n=new URLSearchParams(t),o=Object.create(null);for(let[g,y]of n){if(!g.startsWith("pin."))continue;let[m,b]=y.split(","),k=m===void 0?null:Ze(m),f=b===void 0?null:Ze(b);k===null||f===null||(o[g.slice(4)]={x:k,y:f})}let r=Object.create(null);for(let[g,y]of n)!g.startsWith("in.")||y.length===0||(r[g.slice(3)]=y);let i=n.get("view");i&&i.length>0&&r.view===void 0&&(r.view=i);let a=n.get("pan")?.split(",")??[],s=a[0]===void 0?null:Ze(a[0]),l=a[1]===void 0?null:Ze(a[1]),c=(n.get("sel")??"").split(",").filter(g=>g.length>0).sort(),u=n.get("overview")==="1";return{...c.length>0?{selection:c}:{},...u?{overview:!0}:{},...n.get("zoom")==="1"?{zoom:!0}:{},...n.get("past")==="1"?{past:!0}:{},...n.get("show")?{shown:[...new Set(n.get("show").split(",").filter(Boolean))].sort()}:{},...s!==null&&l!==null?{pan:{x:s,y:l}}:{},...Object.keys(r).length>0?{within:r}:{},...n.get("q")?.trim()?{q:n.get("q")}:{},focusId:Yr(n.get("focus")),relation:n.get("relation"),expanded:(n.get("expand")??"").split(",").filter(g=>g.length>0&&(u||!g.startsWith("kind:"))).sort(),pins:o}}function Da(e){let t=Je(e);return Q(t)==="#"?{...t,overview:!0}:t}function Na(e){let t=Q(e);return t==="#overview=1"?"":t}function Xe(e){return Math.round(e*100)/100}function co(e,t){return Q(e)===Q(t)}var uo="edge:";function po(e){if(!e.startsWith(uo))return null;let t=e.slice(uo.length).split(":");if(t.length!==3)return null;let[n,o,r]=t;if(!n||!o||!r)return null;try{return{kind:decodeURIComponent(n),from:decodeURIComponent(o),to:decodeURIComponent(r)}}catch{return null}}function Tt(e){let{pan:t,...n}=e;return{...n,pins:{}}}function z(e,t){if(t===e.focusId)return{...e,focusId:t};let n=Tt(e);return{...n.within?.q!==void 0?le(n,"q",null):n,focusId:t}}function fo(e,t){return{...e,relation:t}}function le(e,t,n){let o={...e.within??{}};if(n===null?delete o[t]:o[t]=n,Object.keys(o).length===0){let{within:r,...i}=e;return i}return{...e,within:o}}function ye(e,t){if(t!==e.overview&&(e=Tt(e)),!t){let n=e.expanded.filter(o=>!o.startsWith("kind:"));return{...e,overview:!1,expanded:n}}return{...e,overview:t}}function Qe(e,t){if(t.length===0){let{selection:n,...o}=e;return o}return{...e,selection:[...t]}}function _e(e,t){if(t!==(e.zoom===!0)&&(e=Tt(e)),!t){let{zoom:n,...o}=e;return o}return{...e,zoom:!0}}function et(e,t){let n=new Set(e.expanded);return n.has(t)?n.delete(t):n.add(t),{...e,expanded:[...n].sort()}}var nt="aggregate:",tt="kind:";function Mt(e){return`${tt}${e}`}function me(e){return e.startsWith(tt)?e.slice(tt.length):null}var Ga="kinds:beyond";function Zr(e){let t=me(e);return t?[t]:de(e)}function ee(...e){return`${nt}${[...e].sort().join("+")}`}function yo(e){return e.startsWith(nt)}function de(e){return!yo(e)||e.includes("|")?[]:e.slice(nt.length).split("+").filter(Boolean)}function mo(e,t,n={}){let o=me(t);if(o!==null&&e.overview&&n.ownPicture!==!0)return et(e,t);let r=o!==null?ee(o):t;if(e.zoom&&e.focusId===r&&!(o!==null&&n.carry))return _e(e,!1);if(o!==null&&n.carry){let i=ye({...z(e,r),relation:null},!1);return le(_e(i,!0),"q",n.carry)}return _e({...z(e,r),relation:null},!0)}function Xr(e,t,n){return le(ye(z(e,ee(t)),!1),"view",n)}function Fa(e,t){return e.id<t.id?-1:e.id>t.id?1:0}var go="aggregate:";function Ct(e){return e.startsWith(go)&&e.includes("|")}var Ot=e=>e?.off===!0,Jr=e=>e!==void 0&&!Ot(e)&&(e.fast!==void 0||e.thinking!==void 0||e.answer!==void 0||e.decide!==void 0||e.complete!==void 0||e.turn!==void 0),ho=e=>e!==void 0&&!Ot(e)&&(e.fast!==void 0||e.decide!==void 0),Qr=e=>e?.suggestOnOpen!==!1&&ho(e),ei=e=>e?.hoverChips===!0&&ho(e);var Vt={};var Co=H(W(),1),hi={turns:[],outcomes:new Map,busy:!1,pending:null,draft:null,draftNote:null},Oo=e=>`graview:seat:${e}`;function Si(e){if(!e)return{};try{let t=sessionStorage.getItem(e);if(!t)return{};let n=JSON.parse(t);return{...Array.isArray(n.turns)?{turns:n.turns}:{},...Array.isArray(n.outcomes)?{outcomes:new Map(n.outcomes)}:{},...n.draft?.drawn?{draft:n.draft}:{}}}catch{return{}}}function wi(e,t){if(e)try{sessionStorage.setItem(e,JSON.stringify({turns:t.turns.slice(-40),outcomes:[...t.outcomes],draft:t.draft}))}catch{}}function Wt(e){let t=e===null?null:Oo(e),n={...hi,...Si(t)},o=new Set,r=(i,a=!0)=>{n=i,a&&wi(t,n);for(let s of[...o])s()};return{get:()=>n,subscribe(i){return o.add(i),()=>void o.delete(i)},setTurns:i=>r({...n,turns:i(n.turns)}),settle:(i,a)=>r({...n,outcomes:new Map(n.outcomes).set(i,a)}),setBusy:i=>r({...n,busy:i},!1),ask:i=>r({...n,pending:i.trim()||null}),takePending(){let i=n.pending;return i!==null&&r({...n,pending:null},!1),i},setDraft:(i,a=null)=>r({...n,draft:i,draftNote:a})}}function vi(e){return(0,Co.useSyncExternalStore)(e.subscribe,e.get,e.get)}var Io=H(W(),1),bi={entries:[],ghost:null,loaded:!1};function Vo(e,t){let n=new Map(e.map(o=>[o.id,o]));for(let o of t)n.set(o.id,{...n.get(o.id),...o});return[...n.values()].sort((o,r)=>o.at<r.at?1:o.at>r.at?-1:0)}function Gt(e){let t=bi,n=new Set,o=r=>{t=r;for(let i of[...n])i()};return{get:()=>t,subscribe:r=>(n.add(r),()=>n.delete(r)),record:r=>{o({...t,entries:Vo(t.entries,[r])}),Promise.resolve(e()?.keep?.(r)).catch(i=>{console.warn("The host did not keep an AI interaction:",i)})},setGhost:r=>o({...t,ghost:r}),load:()=>{if(t.loaded)return;o({...t,loaded:!0});let r=e()?.load;r&&Promise.resolve(r()).then(i=>o({...t,entries:Vo(t.entries,i)})).catch(i=>{console.warn("The host's AI interactions could not be read:",i)})}}}function xi(e){return(0,Io.useSyncExternalStore)(e.subscribe,e.get,e.get)}function Lo(e){return e?.closest?.("[data-graview-pick]")?.getAttribute("data-graview-pick")??null}var rt=H(W(),1),it=(0,rt.createContext)(void 0),Ei=()=>(0,rt.useContext)(it);var P=H(W(),1),He=(0,P.createContext)(null);function Ho(){return(0,P.useContext)(He)}function Pi(e,t){let n=Ho(),o=(0,P.useMemo)(()=>n?n.live.seenBy(t):e,[n,e,t]),r=(0,P.useRef)(0),i=(0,P.useCallback)(a=>o.subscribe(()=>{r.current+=1,a()}),[o]);return(0,P.useSyncExternalStore)(i,()=>r.current,()=>0),o}var Do=Ye(()=>(__graviewPreload(import.meta.url,["./chunk.7ECBGIUK.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.SDLUWRGI.js")));function Ft(e){let[,t]=(0,P.useReducer)(o=>o+1,0),n=e.publishing?.mode==="on-publish"&&!no();return(0,P.useEffect)(()=>{n&&Do().then(t,()=>{})},[n]),!n}var _o,Ai=400;function Kt(e,t,n){let o=(0,P.useContext)(He),r=o!==null&&o.owns(e,t),[i,a]=(0,P.useState)(null),[s,l]=(0,P.useState)(_o);(0,P.useEffect)(()=>{if(s||r||i===null)return;let E=!0;return Do().then(I=>{_o=I,E&&l(I)},()=>{}),()=>{E=!1}},[s,r,i]);let[c,u]=(0,P.useState)(0),[g,y]=(0,P.useMemo)(()=>r||i===null||!s?[]:[i>=e.log.length?void 0:s.askArchived(e,i,n)??s.askDeclaration(n,i),s.keptOf(e,n)],[r,e,i,n,s,c]),m=g&&"waiting"in g?g.waiting:void 0,b=g&&"seq"in g?g:null,[k,f]=(0,P.useState)(void 0);(0,P.useEffect)(()=>{if(!m)return;let E=!0,I=setTimeout(()=>E&&f(m),Ai);return m.then(()=>E&&u(_=>_+1)),()=>{E=!1,clearTimeout(I)}},[m]);let S=m!==void 0&&k!==m||b!==null,v=(0,P.useMemo)(()=>{if(r||i===null||i>=e.log.length||!s||S)return null;try{let E=s.pastAt(e,i,n);return{seq:i,at:E.past?.at,store:E}}catch{return null}},[r,e,i,n,s,S,c]),A=(0,P.useRef)(null),x=S?A.current:v;(0,P.useEffect)(()=>{A.current=x},[x]);let F=(0,P.useCallback)(E=>a(E===null?null:E>=e.log.length?Number.POSITIVE_INFINITY:E),[e]),D=(0,P.useCallback)((E,I)=>[e,x?.store].some(_=>_!==void 0&&(_===E||_.seenBy(I)===E)),[e,x]),N=i!==null,V=(0,P.useMemo)(()=>({past:x,open:N,show:F,live:e,host:n,owns:D,archive:b,kept:y}),[x,N,F,e,n,D,b,y]);return r?o:V}var No=H(W(),1),Bt=(0,No.createContext)(null);var Fo=e=>`graview:setting:${e}`;function Ko(){return localStorage}function Bo(e,t){try{let n=(t??Ko()).getItem(Fo(e.name));if(n!==null&&e.options.some(o=>o.value===n))return n}catch{}return e.initial}function qo(e,t,n){try{(n??Ko()).setItem(Fo(e.name),t)}catch{}}function zo(e,t){if(typeof document>"u")return;let n=document.documentElement;if(e.honored==="root-font-size"){n.style.fontSize=t===e.initial?"":t;return}let o=`graview${e.name.replace(/-([a-z0-9])/g,(r,i)=>i.toUpperCase()).replace(/^[a-z]/,r=>r.toUpperCase())}`;t===e.initial?delete n.dataset[o]:n.dataset[o]=t}var L=H(W(),1);function qt(e){return Ue(e)}var Ti=12,Mi=4;function Ci(e,t,n){let o=qt(t);return e.get(o)??{participant:o,who:t.id??t.kind,at:null,mode:"docked",since:n,trail:[]}}var st=(e,t)=>t===null||e[e.length-1]===t?e:[...e,t].slice(-Ti);function $o(e,t){let n=e.filter(r=>r.length>0);if(n.length===0)return null;if(n.length<=Mi)return n[0];let o=new Set(n.map(r=>t(r)).filter(r=>r!==void 0));return o.size===1?Mt([...o][0]):n[0]}function zt(e,t,n){let o=new Map(e);if(t.type==="rest"){for(let[a,s]of e)s.mode!=="asking"&&s.mode!=="docked"&&t.at-s.since>=t.holdMs&&o.set(a,{...s,mode:"docked",at:null,trail:[],say:void 0,confidence:void 0});return o}if(t.author.kind!=="agent")return o;let r=Ci(e,t.author,t.at),i=a=>o.set(r.participant,{...r,...a,since:t.at});switch(t.type){case"read":{let a=$o(t.ids,n);return i({at:a,mode:"reading",trail:st(r.trail,a)}),o}case"about-to-write":case"write":{let a=$o(t.ids,n);return i({at:a,mode:"writing",trail:st(r.trail,a),say:void 0,confidence:void 0}),o}case"refused":return i({at:t.where,mode:"refused",say:t.say,confidence:void 0,trail:st(r.trail,t.where)}),o;case"asking":return i({at:t.where??r.at,mode:"asking",say:t.say,...t.confidence!==void 0?{confidence:t.confidence}:{confidence:void 0},trail:st(r.trail,t.where)}),o;case"said":return i({say:t.say,...t.confidence!==void 0?{confidence:t.confidence}:{confidence:void 0},...t.caption?{caption:t.caption}:{}}),o;case"over":return i({over:t.over}),o;case"home":return i({at:null,mode:"docked",trail:[],say:void 0,confidence:void 0,over:null}),o;default:return o}}var Uo="graview:session";function Yo(e){let t=()=>typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID().slice(0,8):Math.random().toString(36).slice(2,10);try{let n=e??sessionStorage,o=n.getItem(Uo);if(o)return o;let r=t();return n.setItem(Uo,r),r}catch{return t()}}var $t={name:"share-where",title:"Where you are",description:"Whether the others here see which stop you are on.",honored:"root-attribute",options:[{value:"shared",label:"Shown"},{value:"private",label:"Hidden"}],initial:"shared"},Ut={name:"share-over",title:"What you point at",description:"Whether the others see the thing under your pointer, outlined in your color.",honored:"root-attribute",options:[{value:"private",label:"Kept to yourself"},{value:"shared",label:"Outlined for others"}],initial:"private"},Zo=[$t,Ut],Oi=800;function Xo(e){let{channel:t,store:n,view:o,principal:r,session:i,robots:a,seatWho:s,settingValues:l,setView:c,ttlMs:u=lo,people:g,seats:y}=e,[m,b]=(0,L.useState)(()=>new Map),[k,f]=(0,L.useState)(null),[S,v]=(0,L.useState)(null),[A,x]=(0,L.useState)(null),F=typeof r.id=="string"&&r.id.length>0,D=F&&(l[$t.name]??$t.initial)==="shared",N=D&&(l[Ut.name]??Ut.initial)==="shared",V=qt({kind:r.kind,...r.id?{id:r.id}:{},session:i}),E=F?Qn(r,{graph:n.graph,schema:n.schema,...y?{seats:y}:{},...g?{people:g}:{}}):"",I=s?a.get(`agent:${s}:${i}`):void 0,_=(0,L.useMemo)(()=>!t||!D?null:{participant:V,kind:r.kind,name:E,...r.onBehalfOf?.id?{onBehalfOf:r.onBehalfOf.id,...r.onBehalfOf.name?{onBehalfOfName:r.onBehalfOf.name}:{}}:{},hue:eo(r.id??"nobody"),stop:A??Q(o),...N?{over:k}:{},...I?{robot:{at:I.at,mode:I.mode}}:{},at:new Date().toISOString()},[t,D,N,V,E,r.id,r.kind,r.onBehalfOf?.id,r.onBehalfOf?.name,o,A,k,I?.at,I?.mode]),We=(0,L.useRef)(null),Pe=R=>R&&t?.here({...R,caret:We.current??void 0,at:new Date().toISOString()}),Ae=(0,L.useCallback)(R=>{We.current=R,Pe(_)},[t,_]);(0,L.useEffect)(()=>{if(!_)return;Pe(_);let R=setInterval(()=>Pe(_),Oi);return()=>clearInterval(R)},[t,_]),(0,L.useEffect)(()=>t?t.onWho(B=>b(Rt(new Map,B,Date.now(),u))):void 0,[t,u]);let ke=m.size>0;(0,L.useEffect)(()=>{if(!ke)return;let R=setInterval(()=>{b(B=>{let X=Rt(B,[],Date.now(),u);return X.size===B.size?B:X})},Math.max(250,Math.min(1e3,u/4)));return()=>clearInterval(R)},[ke,u]),(0,L.useEffect)(()=>{if(!t||typeof window>"u")return;let R=()=>t.leave();return window.addEventListener("pagehide",R),()=>window.removeEventListener("pagehide",R)},[t]),(0,L.useEffect)(()=>{if(!N||typeof document>"u")return;let R=null,B=X=>{let ie=Lo(X.target);ie!==R&&(R=ie,f(ie))};return document.addEventListener("pointermove",B,{passive:!0}),()=>document.removeEventListener("pointermove",B)},[N]);let ue=(0,L.useRef)(null),K=S?m.get(S)??null:null,oe=(0,L.useCallback)(R=>{ue.current=null,v(R)},[]);(0,L.useEffect)(()=>{if(S){if(!K){v(null);return}K.stop!==ue.current?.stop&&(ue.current={stop:K.stop,at:Date.now()},c(Je(K.stop)))}},[S,K,c]),(0,L.useEffect)(()=>{let R=ue.current;!S||R===null||Date.now()-R.at<400||co(o,Je(R.stop))||v(null)},[o,S]),(0,L.useEffect)(()=>{if(!S||typeof document>"u")return;let R=B=>{B.key==="Escape"&&v(null)};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[S]);let Re=_!==null,re=(0,L.useMemo)(()=>Re?{participant:V,name:E}:null,[Re,V,E]);return(0,L.useMemo)(()=>({who:m,sharing:re,following:K,follow:oe,sayWhere:x,sayCaret:Ae}),[m,re,K,oe,Ae])}var U=H(W(),1);function Jo(e){return Ue(e.author)}function Vi(e,t){return e.length>1?"co-edited":t==="rule"?"rule":t==="agent"?"autonomous":"directed"}function Qo(e,t,n,o,r){let i=new Map;for(let[l,c]of e)o-c.at<r&&i.set(l,c);let a=new Set(n.flatMap(l=>l.nodeIds)),s=(l,c,u)=>{let g=i.get(l),y=g?.participants.includes(Jo(c))?g.participants:[...g?.participants??[],Jo(c)];i.set(l,{at:o,manner:Vi(y,c.author.kind),intent:c.intent,wrote:(g?.wrote??!1)||(u.wrote??!1),read:(g?.read??!1)||(u.read??!1),broke:(g?.broke??!1)||a.has(l),participants:y})};for(let l of t){for(let c of l.writes)s(c,l,{wrote:!0});for(let c of l.reads)l.writes.includes(c)||s(c,l,{read:!0})}for(let l of n)for(let c of l.nodeIds){let u=i.get(c);i.set(c,{at:o,manner:u?.manner??"rule",intent:u?.intent??l.message,wrote:u?.wrote??!1,read:u?.read??!1,broke:!0,participants:u?.participants??["rule::"]})}return i}var Ii=2600;function er(e,t=Ii){let[n,o]=(0,U.useState)(()=>new Map),r=(0,U.useRef)(n);r.current=n;let i=(0,U.useRef)(null),a=(0,U.useCallback)(l=>{r.current=l,o(l),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{r.current=new Map,o(new Map)},t)},[t]);(0,U.useEffect)(()=>{let l=e.violations(),c=e.subscribe((u,g)=>{let y=e.violations(),m=io(e.allInvariants(),l,y).introduces;l=y,a(Qo(r.current,g,m.map(b=>({nodeIds:b.nodeIds,message:b.message})),Date.now(),t))});return()=>{c(),i.current&&clearTimeout(i.current)}},[e,t,a]);let s=(0,U.useCallback)(l=>{l.reads.length!==0&&a(Qo(r.current,[Li(l)],[],Date.now(),t))},[t,a]);return{activity:n,noteAttention:s}}function Li(e){return{id:`attention:${e.intent}`,seq:-1,batch:"attention",author:e.author,intent:e.intent,mutation:null,primitives:[],reads:e.reads,writes:[],at:new Date().toISOString()}}var d=H(W(),1);function tr(){let e=null,t=new Set,n=new Set,o=r=>{for(let i of n)i(r)};return{subscribe(r){return t.add(r),t.size===1&&o(!0),()=>{t.delete(r),t.size===0&&(e=null,o(!1))}},snapshot:()=>e,set(r){if(!(e===r||e&&r&&e.x===r.x&&e.y===r.y)){e=r;for(let i of t)i()}},get listeners(){return t.size},onActive(r){return n.add(r),()=>void n.delete(r)}}}var lt=H(W(),1),_i=e=>e.definitions.some(t=>Xn(t).size>0);function nr(e,t,n){let[o,r]=(0,lt.useState)(void 0),i=(n.roles??[]).join("\0");return(0,lt.useEffect)(()=>{if(!t||!_i(e.schema)){r(void 0);return}let a=!0,s=!1,l=e.graph,c=()=>{s||(s=!0,queueMicrotask(()=>{s=!1,a&&e.reread()}))},u=Jn(t,{kind:n.kind,...n.id===void 0?{}:{id:n.id},...n.roles?{roles:n.roles}:{}},c);return kt(l,u.read),r(u),e.reread(),()=>{a=!1,kt(l,void 0)}},[e,t,n.kind,n.id,i]),o}function or(){let e=!1,t=new Set;return{moving:()=>e,set(n){if(n!==e){e=n;for(let o of t)o()}},subscribe(n){return t.add(n),()=>t.delete(n)}}}var te=H(De(),1),Hi="graview:place-menu",Ne=(0,d.createContext)(null),sr=(0,d.createContext)("scene");function Di({mode:e,children:t}){return(0,te.jsx)(sr.Provider,{value:e,children:t})}function Ni(){return(0,d.useContext)(sr)}var lr={kind:"human"},ji=[],Wi=[],Gi=[],Yt=[];function dr(e,t){let n=(0,d.useId)();(0,d.useEffect)(()=>{if(!globalThis.__graviewWatch)return;let o=t??lr,r=()=>ro(e,o,n);r();let i,a=e.subscribe(()=>{clearTimeout(i),i=setTimeout(r,250)});return()=>{clearTimeout(i),a(),globalThis.__graviewWatch?.unseen?.({words:[],from:n,gone:!0})}},[e,t,n])}var Fi=()=>{try{return typeof location<"u"&&new URLSearchParams(location.search).get("as")==="published"?"published":void 0}catch{return}},Ki={off:!0};function Bi({store:e,views:t,initialView:n,scheme:o="dark",initialSelection:r,principal:i,as:a,seats:s=ji,onSeat:l,people:c=Wi,memory:u,presenceTtlMs:g,app:y,settings:m=y?.settings??Gi,presence:b,typing:k,brand:f,locale:S,timeZone:v,onKeepLens:A,providers:x,ai:F,files:D,resolveApp:N,history:V,linkedRecords:E,menuSections:I,keptViews:_,onExport:We,subscriptions:Pe,dismissals:Ae,whileAway:ke,signIn:ue,view:K,onViewChange:oe,children:Re}){let re=(0,d.useContext)(Ne),R=I??re?.menuSections,B=ue??re?.signIn,X=_??re?.keptViews,ie=We??re?.onExport,[_r,Hr]=(0,d.useState)(null),ce=_r??i??s[0]?.principal??lr,Ge=Kt(e,ce,V),fn=Ge.past&&Ge.live===e?Ge.past.store:e,wt=a??Fi(),vt=!Ft(e),j=(0,d.useMemo)(()=>vt?e:fn.seenBy(ce,wt?{as:wt}:void 0),[vt,e,fn,ce,wt]);dr(e,ce);let[ae]=(0,d.useState)(()=>Yo(u)),[yn,Dr]=(0,d.useState)(!1),mn=(0,d.useCallback)(()=>Dr(!0),[]),se=(0,d.useMemo)(()=>b?[...m,...Zo]:m,[m,b]),[bt]=(0,d.useState)(()=>n??Qt(t,e.schema)),[Nr,gn]=(0,d.useState)(()=>Qe(bt??fe,r??bt?.selection??[])),Te=(0,d.useRef)(bt??fe).current,[hn,jr]=(0,d.useState)(null),[Sn,Wr]=(0,d.useState)(null),Z=(0,d.useContext)(Ne),[wn]=(0,d.useState)(()=>Z?.seatTalk??Wt(f?.name??e.schema.kinds.join(","))),xt=F??Z?.ai??Vt,Fe=(0,d.useMemo)(()=>xt.off?Ki:xt,[xt]),vn=(0,d.useRef)(Fe.interactions);vn.current=Fe.interactions;let[bn]=(0,d.useState)(()=>Z?.aiDesk??Gt(()=>vn.current)),[Gr]=(0,d.useState)(()=>Z?.subscriptions??oo()),xn=Pe??Z?.subscriptions??Gr,Et=A??Z?.onKeepLens,Ke=y??Z?.app,Be=S??Z?.locale,Fr=f?.locale??Ke?.brand?.locale,qe=v??Z?.timeZone;Zn({reader:Be,app:Fr,readerTimeZone:qe,appTimeZone:f?.timeZone??Ke?.brand?.timeZone});let En=(0,d.useRef)(null),Pn=(0,d.useCallback)(p=>{En.current=p},[]),An=(0,d.useCallback)(p=>En.current?.whereIs(p)??null,[]),[kn]=(0,d.useState)(()=>tr()),[Rn]=(0,d.useState)(()=>or()),[Pt,Kr]=(0,d.useState)(null),[Me,Tn]=(0,d.useState)(()=>new Map),Ce=(0,d.useRef)(Me);Ce.current=Me;let Oe=(0,d.useRef)(null),At=(0,d.useCallback)(p=>j.graph.getNode(p)?.kind,[j]),J=(0,d.useCallback)(p=>{let h=zt(Ce.current,p,At);Ce.current=h,Tn(h),Oe.current&&clearTimeout(Oe.current),[...h.values()].some(C=>C.mode!=="docked"&&C.mode!=="asking")&&(Oe.current=setTimeout(()=>{let C=zt(Ce.current,{type:"rest",at:Date.now(),holdMs:Jt},At);Ce.current=C,Tn(C)},Jt+20))},[At]),Mn=(0,d.useCallback)(p=>J({...p,at:p.at??Date.now()}),[J]),Cn=(0,d.useCallback)(p=>{Kr(p),p&&J({type:"home",author:{kind:"agent",id:p,session:ae},at:Date.now()})},[J,ae]);(0,d.useEffect)(()=>j.subscribe((p,h)=>{for(let T of h)T.author.kind==="agent"&&J({type:"write",author:T.author,ids:T.writes,at:Date.now()})}),[j,J]),(0,d.useEffect)(()=>()=>{Oe.current&&clearTimeout(Oe.current)},[]);let $=(0,d.useMemo)(()=>({...ce,session:ae}),[ce,ae]),On=nr(j,E,$),Vn=(0,d.useCallback)(p=>{Hr(p),l?.(p)},[l]),[Ve,Br]=(0,d.useState)(()=>Object.fromEntries(se.map(p=>[p.name,Bo(p,u)])));(0,d.useEffect)(()=>{for(let p of se)zo(p,Ve[p.name]??p.initial)},[se,Ve]);let In=(0,d.useCallback)((p,h)=>{let T=se.find(C=>C.name===p);!T||!T.options.some(C=>C.value===h)||(qo(T,h,u),Br(C=>({...C,[p]:h})))},[se,u]),[Ln,qr]=(0,d.useState)(null),{activity:_n,noteAttention:Hn}=er(j),Dn=(0,d.useCallback)(p=>{Hn(p),J({type:"read",author:p.author,ids:p.reads,at:Date.now()})},[Hn,J]),pe=(0,d.useCallback)(p=>{if(me(p)!==null||de(p).length>0||Ct(p))return!0;let h=po(p);return h?j.graph.allEdges().some(T=>T.kind===h.kind&&T.from===h.from&&T.to===h.to):j.graph.getNode(p)!==void 0},[j]),Nn=(0,d.useCallback)(p=>{let h=p.selection??Yt,T=h.filter(pe),C=T.length===h.length?p:Qe(p,T);return C.focusId!==null&&!pe(C.focusId)&&(C=z(C,null)),C},[pe]),Ie=(0,d.useCallback)(p=>{let h=Nn(p),T=ar(j,$,h.shown);if(h.focusId!==null&&T.size>0){let C=de(h.focusId),Yn=j.graph.getNode(h.focusId);(C.length>0?C.every(Ur=>T.has(Ur)):Yn?T.has(Yn.kind):!1)&&(h={...h,focusId:null})}if(!h.overview&&h.focusId===null){let C=Te.focusId!==null&&!pe(Te.focusId)?Qt(t,e.schema)??{...fe,overview:!0}:Te;C.focusId!==null&&pe(C.focusId)?h={...h,focusId:C.focusId}:C.overview===!0&&(h={...h,overview:!0})}return h},[Nn,pe,j,Te,$,t,e.schema]),q=Ie(K??Nr),jn=(0,d.useMemo)(()=>ar(j,$,q.shown),[j,$,q.shown]),Wn=(0,d.useMemo)(()=>[...j.modules.administered.entries()].map(([p,h])=>{let T=j.mayAdminister(p,$);return{name:p,...h.description?{description:h.description}:{},kinds:h.kinds??[],canShow:T,shown:T&&(q.shown??[]).includes(p)}}),[j,$,q.shown]),Le=(0,d.useCallback)(p=>{let h=T=>Ie(typeof p=="function"?p(T):p);if(K!==void 0){oe?.(h(K));return}oe&&oe(h(q)),gn(T=>h(T))},[q,oe,K,Ie]);(0,d.useEffect)(()=>{K===void 0&&gn(p=>{let h=Ie(p);return h===p?p:h})},[q,K,Ie]);let Gn=q.selection??Yt,Fn=(0,d.useCallback)(p=>{Le(h=>Qe(h,typeof p=="function"?p(h.selection??Yt):p))},[Le]),{who:ze,following:Kn,follow:Bn,sayWhere:zr,sayCaret:qn,sharing:zn}=Xo({channel:b,store:j,view:q,principal:$,session:ae,robots:Me,seatWho:Pt,settingValues:Ve,setView:Le,seats:s,people:c,...g!==void 0?{ttlMs:g}:{}}),$r=(0,d.useMemo)(()=>({store:j,scheme:o,views:t,view:q,setView:Le,homeView:Te,selection:Gn,setSelection:Fn,menuAt:hn,setMenuAt:jr,whereIs:An,pointer:kn,motion:Rn,registerScene:Pn,robots:Me,noteSeat:Mn,seatWho:Pt,registerSeatWho:Cn,actsDoor:Sn,registerActsDoor:Wr,seatTalk:wn,aiDesk:bn,...u?{memory:u}:{},who:ze,following:Kn,follow:Bn,sayWhere:zr,sharing:zn,session:ae,ai:Fe,resolveApp:N,linkedRecords:E,menuSections:R,...X?{keptViews:X}:{},...ie?{onExport:ie}:{},subscriptions:xn,dismissals:Ae,whileAway:ke,signIn:B,linkedReads:On,movedByHand:yn,noteMoved:mn,emphasis:Ln,setEmphasis:qr,activity:_n,noteAttention:Dn,principal:$,seats:s,people:c,takeSeat:Vn,settings:se,settingValues:Ve,chooseSetting:In,hiddenKinds:jn,administered:Wn,...x?{providers:x}:{},...f?{brand:f}:{},...Et?{onKeepLens:Et}:{},app:Ke,...Be?{locale:Be}:{},...qe?{timeZone:qe}:{}}),[j,o,t,q,Le,Gn,Fn,hn,An,kn,Rn,Pn,Me,Mn,Pt,Cn,Sn,wn,bn,u,ze,Kn,Bn,zn,ae,Fe,N,E,R,X,ie,xn,Ae,ke,B,On,yn,mn,Ln,_n,Dn,$,s,c,Vn,se,Ve,In,jn,Wn,x,f,Et,Ke,Be,qe]),$n=(0,d.useMemo)(()=>k?{typing:k,sayCaret:qn,who:ze}:null,[k,qn,ze]),Un=D?(0,te.jsx)(it.Provider,{value:D,children:Re}):Re;return(0,te.jsx)(Ne.Provider,{value:$r,children:(0,te.jsx)(He.Provider,{value:Ge,children:(0,te.jsx)(Yi,{children:vt?null:$n?(0,te.jsx)(Bt.Provider,{value:$n,children:Un}):Un})})})}var ur=(0,d.createContext)(null),Zt,Xt=new Set,qi=e=>(Xt.add(e),()=>void Xt.delete(e)),rr=()=>Zt;function zi(e){if(!Zt){Zt=e;for(let t of[...Xt])t()}}var $i=300;function Ui(e){let t=0;return async(n,o)=>{let r=++t;return await new Promise(i=>setTimeout(i,$i)),r===t?e(n,o):[]}}function Yi({children:e}){let{store:t,view:n,views:o,principal:r,hiddenKinds:i,selection:a,ai:s}=ne(),l=dt(),c=n.q,u=n.focusId,g=!!(c&&c.trim().length>0),y=(0,d.useSyncExternalStore)(qi,rr,rr),m=(0,d.useMemo)(()=>g&&y?{flagged:new Set(t.violations().flatMap(A=>A.nodeIds)),touched:y.touchWeights(t.log.all())}:null,[t,l,g,y]),b=u?t.graph.getNode(u)?.kind??me(u)??(de(u).length===1?de(u)[0]:void 0):void 0,k=(0,d.useMemo)(()=>s.near&&Ui(s.near),[s.near]),f=(0,d.useMemo)(()=>!c||!m||!y?null:y.search(t,c,{...b?{inKind:b}:{},principal:r,places:o.places(),kinds:t.schema.kinds.filter(A=>!i.has(A)),from:[...a,...u&&t.graph.has(u)?[u]:[]],flagged:m.flagged,touched:m.touched,limit:200,rank:k}),[t,c,r,o,i,a,u,b,m,k]),[S,v]=(0,d.useState)();return(0,d.useEffect)(()=>void f?.later?.then(A=>v([f,A])),[f]),(0,te.jsx)(ur.Provider,{value:S?.[0]===f?S[1]:f,children:e})}var ir=new WeakMap;function Gs(e){let t=ir.get(e);return t||ir.set(e,t=new Set(e.matched)),t}function Zi(){return(0,d.useContext)(ur)}function ne(){let e=(0,d.useContext)(Ne);if(!e)throw new Error("useGraview must be used inside a <GraviewProvider>.");return e}function en(){return(0,d.useContext)(Ne)??null}function dt(){let{store:e}=ne(),t=(0,d.useRef)(null),n=(0,d.useRef)(null),o=(0,d.useCallback)(()=>(n.current!==e&&(n.current=e,t.current=null),t.current??=e.graph.allNodes(),t.current),[e]),r=(0,d.useCallback)(i=>e.subscribe(()=>{t.current=null,i()}),[e]);return(0,d.useSyncExternalStore)(r,o,o)}function Xi(e){let{store:t}=ne(),n=(0,d.useCallback)(r=>t.subscribe(r),[t]),o=(0,d.useCallback)(()=>e===null?void 0:t.graph.getNode(e),[t,e]);return(0,d.useSyncExternalStore)(n,o,o)}function ar(e,t,n){let o=new Set(e.modules.disabledKinds);for(let r of e.kindsKeptFrom(t))o.add(r);for(let[r,i]of e.modules.administered)if(!(e.mayAdminister(r,t)&&(n??[]).includes(r)))for(let a of i.kinds??[])o.add(a);return o}var Jt=2600;var cr=new WeakSet,Ji=e=>cr.has(e),Qi=e=>void cr.add(e);function Qt(e,t){let n=so(e.arrangement?.()?.first,t,e.places());if(!(!n||n.to==="home"))return n.to==="place"?{...fe,focusId:ee(n.place.kind),within:{view:n.place.as}}:{...fe,focusId:ee(n.kind)}}var pr=H(W(),1),ea=(0,pr.createContext)(!1);var ut=Symbol.for("graview.default-view");function fr(e){return Object.defineProperty(e,ut,{value:!0,enumerable:!1}),e}function yr(e){return typeof e=="function"&&e[ut]===!0}var ct=Symbol.for("graview.replaces-page");function mr(e){return Object.defineProperty(e,ct,{value:!0,enumerable:!1}),e}function gr(e){return typeof e=="function"&&e[ct]===!0}var pt=Symbol.for("graview.bleeds");function hr(e){return Object.defineProperty(e,pt,{value:!0,enumerable:!1}),e}function Sr(e){return typeof e=="function"&&e[pt]===!0}var ft=Symbol.for("graview.previews");function wr(e,t={}){return Object.defineProperty(e,ft,{value:t,enumerable:!1}),e}function vr(e){return typeof e=="function"?e[ft]:void 0}function ta(e){return ao(e)}function na(e,t){if(t===e)return e;for(let r of t.registrations())e.register(r.kind,r,r.view,r);let n=t.arrangement?.();n&&e.arrange?.(n);let o=t.homes?.()??[];if(o.length>0)for(let r of o)e.home?.(r.view,r.name!==void 0?{name:r.name}:void 0);else{let r=t.homeView?.();r&&e.home?.(r)}return e}var M=H(W(),1),Y=H(De(),1),tn=new Set,yt=0;function nn(e){return()=>{yt+=1;let t=e();return t.then(()=>void(yt-=1),()=>void(yt-=1)),t}}var oa=()=>yt,gt=(0,M.createContext)(null);function ra(){return{waiting:new Map,at:0}}function ia(e){for(let[t,n]of e.waiting)n<e.at&&e.waiting.delete(t);e.at+=1}var aa=e=>e?.waiting.size??0;function Er(e,t){e?.waiting.set(t,e.at)}function Pr(e){let t=(0,M.useContext)(gt);(0,M.useLayoutEffect)(()=>{t?.waiting.delete(e)},[t,e])}function sa(e){let t={},n=!1,o=new Set,r=(0,M.lazy)(nn(()=>e().then(a=>{n=!0;let s=a.default;function l(c){return Pr(t),(0,M.createElement)(s,c)}return{default:l}},a=>{for(let s of o)s.waiting.delete(t);throw a})));function i(a){let s=(0,M.useContext)(gt);return!n&&s&&(o.add(s),Er(s,t)),(0,M.createElement)(r,a)}return i}var Ar=!1,kr=!1,mt=new Set;function la(){Ar=!0}function da(){kr=!0;for(let e of[...mt])e();mt.clear()}var Rr=()=>kr||!Ar;function ua(e){return Rr()?(e(),()=>{}):(mt.add(e),()=>void mt.delete(e))}var br=!1;function on(){for(let e of[...tn])e()}function ca(){br||typeof window>"u"||(br=!0,window.addEventListener("online",on))}function rn(e){let t,n=!1,o=!1,r,i=0,a=new Set,s=()=>{i+=1;for(let y of[...a])y()},l=y=>(a.add(y),()=>void a.delete(y)),c=()=>i,u=()=>void g().catch(()=>{});function g(){if(n)return Promise.resolve(t);if(r)return r;let y=e().then(m=>(t=m,n=!0,o=!1,r=void 0,tn.delete(u),s(),m),m=>{throw r=void 0,o=!0,tn.add(u),ca(),s(),m});return y.catch(()=>{}),r=y,y}return{load:g,prefetch:u,get current(){return t},get failed(){return o},part(y,m={}){let b=m.what??"This part",k={};function f(A){(0,M.useSyncExternalStore)(l,c,c),Pr(k);let x=(0,M.useRef)(null),F=(0,M.useRef)(null),D=(0,M.useRef)(!1);return(0,M.useEffect)(()=>{o&&r===void 0&&u()},[]),n&&typeof document<"u"&&x.current!==null&&document.activeElement===x.current&&(D.current=!0),(0,M.useLayoutEffect)(()=>{if(!(!n||!D.current)){D.current=!1;for(let N=F.current?.nextElementSibling??null;N!==null;N=N.nextElementSibling){let V=N.matches(xr)?N:N.querySelector(xr);if(V instanceof HTMLElement){V.focus();return}}}}),n?(0,Y.jsxs)(Y.Fragment,{children:[D.current?(0,Y.jsx)("span",{ref:F,hidden:!0}):null,y(t,A)]}):m.quiet?null:(0,Y.jsx)(pa,{what:b,button:x,...m.as?{as:m.as}:{}})}let S=(0,M.lazy)(nn(()=>g().then(()=>({default:f}),()=>({default:f}))));function v(A){let x=(0,M.useContext)(gt),[F]=(0,M.useState)(()=>n||o);return!n&&!o&&Er(x,k),(0,M.createElement)(F?f:S,A)}return v}}}var xr="button,a[href],input,select,textarea,[tabindex]:not([tabindex='-1'])";function pa({what:e,button:t,as:n="p"}){let r=typeof navigator<"u"&&navigator.onLine===!1?`${e} will load when you're back online.`:`${e} didn't load.`;return(0,Y.jsxs)(n,{"data-testid":"lazy-part-missing",style:{margin:0,fontSize:"0.875rem",color:"var(--graview-ink-muted)"},children:[(0,Y.jsx)("span",{role:"status",children:r})," ",(0,Y.jsx)("button",{ref:t,type:"button","data-testid":"lazy-part-retry",onClick:on,style:{font:"inherit",fontWeight:600,color:"var(--graview-ink)",background:"none",border:"1px solid var(--graview-edge)",borderRadius:6,padding:"2px 10px"},children:"Try again"})]})}var we=H(W(),1);function fa(){let{selection:e,setSelection:t}=ne();return(0,we.useMemo)(()=>({selection:e,set:n=>t(n),clear:()=>t([]),toggle:n=>t(o=>o.includes(n)?o.filter(r=>r!==n):[...o,n]),isSelected:n=>e.includes(n)}),[e,t])}function ya(){let{store:e}=ne(),t=dt();return(0,we.useMemo)(()=>ma(e),[e,t])}var Tr=new WeakMap;function ma(e){let t=Tr.get(e);if(!t){let n={violations:null};e.subscribe(()=>{n.violations=null}),Tr.set(e,n),t=n}return t.violations??=e.violations(),t.violations}function ga(){let{view:e,setView:t}=ne();return(0,we.useMemo)(()=>({view:e,url:Q(e),focus:n=>t(o=>z(o,n)),show:n=>t(o=>fo(o,n)),toggle:n=>t(o=>et(o,n)),go:n=>t(n)}),[e,t])}var Se={at:0,depth:0,listeners:new Set,tell(){for(let e of this.listeners)e()}};typeof window<"u"&&window.addEventListener("popstate",e=>{let t=e.state;Se.at=typeof t?.graview=="number"?t.graview:0,Se.at>Se.depth&&(Se.depth=Se.at),Se.tell()});var G=H(W(),1),sn={profile:{trigger:"profile-button",pane:"profile",opens:"press",focus:"into",drawn:["shell","embed"]},problems:{trigger:"standing",pane:"problems",opens:"press",focus:"into",drawn:["shell","embed"]},places:{trigger:"app-places-open",pane:"app-places",opens:"press",focus:"into",drawn:["embed"]},here:{trigger:"here-open",pane:"here-list",opens:"press",focus:"into",drawn:["shell","embed","pages"]},suggested:{trigger:"suggested-button",pane:"suggested",opens:"press",focus:"into",drawn:["shell","embed","pages"]},activity:{trigger:"activity-button",pane:"activity",opens:"press",focus:"into",drawn:["shell","embed","pages"]},find:{trigger:"find-box",pane:"find-strip",opens:"typing",focus:"stays",drawn:["shell"]},districts:{trigger:"beyond-more",pane:"beyond-list",opens:"press",focus:"into",drawn:["shell","embed"]},acts:{trigger:null,pane:"context-menu",opens:"context-menu",focus:"into",drawn:["shell","embed","pages"]},arrange:{trigger:"arrange-add",pane:"arrange-list",opens:"press",focus:"into",drawn:["pages"]},"studio-ask":{trigger:"studio-agent",pane:"studio-agent-panel",opens:"press",focus:"into",drawn:["studio"]}},ha={position:"fixed",inset:"auto",margin:0,zIndex:to("popover"),boxSizing:"border-box"},ht=6,ve=8,Sa=e=>typeof e.showPopover=="function";function St(e){try{return e.matches(":popover-open")}catch{return!1}}function wa(e){if(typeof e=="function"){let o=e();return o?{left:o.x,right:o.x,top:o.y,bottom:o.y}:null}let t=e.current;if(!t||!t.isConnected)return null;let n=t.getBoundingClientRect();return{left:n.left,right:n.right,top:n.top,bottom:n.bottom}}function ln(e,t,n={}){let o=wa(t);if(!o)return;let r={width:document.documentElement.clientWidth||innerWidth,height:innerHeight},i=e.dataset.graviewDesignedHeight??=e.style.maxHeight;e.style.maxHeight=i;let a=e.getBoundingClientRect(),s=r.height-o.bottom-ht-ve,l=o.top-ht-ve,c=a.height<=s||s>=l,u=Math.max(96,Math.floor(c?s:l)),g=Math.min(a.height,u);a.height>u&&(e.style.maxHeight=i?`min(${i}, ${u}px)`:`${u}px`);let y=a.width,m=n.align==="start"?o.left:o.right-y,b=typeof t=="function"?null:t.current?.closest("[data-graview-embed]")?.getBoundingClientRect();b&&y<=b.right-b.left&&(m<b.left?m=o.left+y<=b.right?o.left:b.left:m+y>b.right&&(m=o.right-y>=b.left?o.right-y:b.right-y));let k=y>=r.width-2*ve?Math.max(0,(r.width-y)/2):Math.max(ve,Math.min(m,r.width-ve-y)),f=c?o.bottom+ht:Math.max(ve,o.top-ht-g);e.style.left=`${Math.round(k)}px`,e.style.top=`${Math.round(f)}px`}function Mr(e,t,n,o={}){let r=o.align??"end";(0,G.useLayoutEffect)(()=>{let i=e.current;if(!t||!i)return;if(Sa(i)&&!St(i))try{i.showPopover(),ba()}catch{}let a=0,s=c=>{c?.target instanceof Node&&i.contains(c.target)||(cancelAnimationFrame(a),a=requestAnimationFrame(()=>ln(i,n,{align:r})))};ln(i,n,{align:r}),addEventListener("resize",s),addEventListener("scroll",s,!0);let l=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>s());return l?.observe(i),()=>{if(cancelAnimationFrame(a),removeEventListener("resize",s),removeEventListener("scroll",s,!0),l?.disconnect(),i.isConnected&&St(i))try{i.hidePopover()}catch{}}},[t,e,r])}var dn=new Set;function va(e){return dn.add(e),()=>dn.delete(e)}function ba(){for(let e of dn)if(!(!e.isConnected||!St(e)))try{e.hidePopover(),e.showPopover()}catch{}}var be=null,xa='button:not([disabled]), [href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"])';function Ea(e){for(let t of e.querySelectorAll(xa))if(t.closest("[hidden]")===null&&getComputedStyle(t).visibility!=="hidden")return t;return e}var an=()=>{let e=document.activeElement;return e===null||e===document.body};function Pa(e,t={}){let{at:n,returnTo:o,onOpenChange:r}=t,i=t.popover!==!1,[a,s]=(0,G.useState)(!1),l=t.open??a,c=(0,G.useRef)(null),u=(0,G.useRef)(null),g=(0,G.useCallback)(v=>{c.current=v},[]),y=(0,G.useCallback)(v=>{u.current=v},[]),m=`graview-popover-${(0,G.useId)().replace(/:/g,"")}`,b=(0,G.useRef)({onOpenChange:r,returnTo:o,controlled:t.open!==void 0});b.current={onOpenChange:r,returnTo:o,controlled:t.open!==void 0};let k=(0,G.useCallback)(v=>{b.current.controlled||s(v),b.current.onOpenChange?.(v)},[]),f=(0,G.useCallback)(()=>{(document.querySelector(`[aria-controls="${m}"]`)??c.current??b.current.returnTo?.()??null)?.focus({preventScroll:!0})},[m]),S=(0,G.useCallback)(v=>{let A=u.current,x=typeof document>"u"?null:document.activeElement,F=x===null||x===document.body||A!==null&&A.contains(x);k(!1),!(!v||!F)&&(f(),requestAnimationFrame(()=>{an()&&f()}))},[k,f]);return Mr(u,i&&l,n??c,t.align?{align:t.align}:{}),(0,G.useEffect)(()=>{if(!i||!l)return;let v={name:e,close:()=>S(!1)};if(be&&be.close!==v.close&&be.close(),be=v,sn[e].focus==="into"){let V=u.current;V&&!V.contains(document.activeElement)&&Ea(V).focus({preventScroll:!0})}let A=V=>{V.key==="Escape"&&S(!0)},x=V=>{let E=V.target;if(!(E instanceof Node))return;let I=u.current;if(I?.contains(E)||c.current?.contains(E))return;let _=E instanceof Element?E.closest('[role="dialog"], [role="alertdialog"]'):null;_&&!(I&&_.contains(I))||(S(!1),sn[e].focus==="into"&&requestAnimationFrame(()=>{(an()||I!==null&&I.contains(document.activeElement))&&f()}))},F=null,D=null,N=V=>{let E=V.target;if(!(E instanceof Element))return;let I=u.current,_=E.closest('[role="dialog"], [role="alertdialog"]');!_||I&&(I.contains(_)||_.contains(I))||(F=_,S(!1))};return document.addEventListener("keydown",A),document.addEventListener("pointerdown",x,!0),document.addEventListener("focusin",N),()=>{document.removeEventListener("keydown",A),document.removeEventListener("pointerdown",x,!0),document.removeEventListener("focusin",N);let V=F;V&&typeof MutationObserver<"u"&&(D?.disconnect(),D=new MutationObserver(()=>{V.isConnected||(D?.disconnect(),requestAnimationFrame(()=>{(an()||document.activeElement.closest("[hidden]")!==null)&&f()}))}),D.observe(document.body,{childList:!0,subtree:!0}),setTimeout(()=>D?.disconnect(),10*6e4)),be?.close===v.close&&(be=null)}},[i,l,e,S,f]),{open:l,setOpen:v=>v?k(!0):S(!0),toggle:()=>l?S(!0):k(!0),trigger:{ref:g,"aria-expanded":l,"aria-controls":m,"data-graview-popover-trigger":e},pane:{ref:y,id:m,popover:"manual",tabIndex:-1,"data-graview-popover":e,"data-graview-overlay":""}}}var xe=H(W(),1);var Cr=(0,xe.createContext)(null);function Aa(){let e=(0,xe.useContext)(Cr),t=en(),n=(o,r,i)=>t?.setView(a=>le(le(ye(z(a,ee(o)),!1),"view",r),"filter",i?.filter??null));return(0,xe.useMemo)(()=>e??{record:o=>{t&&(t.setView(r=>z(ye(r,!1),o)),t.setSelection([o]))},place:(o,r)=>{let i=t?.views.places().find(a=>a.as===o);i&&n(i.kind,i.as,r)},list:(o,r)=>n(o,null,r)},[e,t])}var Ee=H(W(),1);var ka=rn(Ye(()=>(__graviewPreload(import.meta.url,["./chunk.NPAWTPLQ.js","./chunk.SDO3U72B.js","./chunk.YEJ4LNUP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.PMPDLE56.js"))));function Ra(e,t,n){let o,r=!1,i=()=>{let{hidden:s,removed:l}=t.current();o||r||s.length+l.length===0||(o=()=>{},ka.load().then(c=>{r||(o=c.watchTidied(e,t,n))},String))};i();let a=t.onChange?.(i);return()=>{r=!0,a?.(),o?.()}}function Ta(e,t){let[n,o]=(0,Ee.useState)();return(0,Ee.useEffect)(()=>t?Ra(e,t,r=>o([e,r])):void 0,[e,t]),n?.[0]===e?n[1]:e}var Or=H(W(),1),Ma=(0,Or.createContext)(!1);var un=H(W(),1),Ca=(0,un.createContext)(null),Oa=(0,un.createContext)(null);var Vr=H(W(),1),Va=(0,Vr.createContext)(null);var Ir=H(W(),1),cn='button:not([disabled]), a[href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"])',pn=e=>e instanceof HTMLElement&&(e.matches(cn)||e.hasAttribute("tabindex")),je=e=>typeof e.checkVisibility=="function"?e.checkVisibility():e.getClientRects().length>0;function Ia(e,t){let n=l=>l.replace(/["\\]/g,"\\$&"),o=t.getAttribute("data-testid"),r=t.getAttribute("data-graview-pick"),i=t.getAttribute("aria-label"),a=o?`[data-testid="${n(o)}"]`:r?`[data-graview-pick="${n(r)}"]`:i?`${t.tagName.toLowerCase()}[aria-label="${n(i)}"]`:null;if(!a)return null;let s=e.querySelector(a);return s&&pn(s)&&je(s)?s:null}var La=e=>e.isConnected&&pn(e)&&!e.matches(":disabled")&&e instanceof HTMLElement&&je(e);function Lr(e,t){let n=t?Ia(e,t):null;if(n)return n;let o=e.querySelector("[data-graview-view][tabindex]");if(o&&je(o))return o;for(let r of e.querySelectorAll(cn))if(je(r))return r;return pn(e)&&je(e)?e:null}function _a(e){(0,Ir.useEffect)(()=>{let t=e.current;if(!t||typeof MutationObserver>"u")return;let n=[],o=f=>{let S=f.target;if(S instanceof Element){n=[];for(let v=S;v&&v!==t.parentElement;v=v.parentElement)n.push(v)}},r=!1,i=!1,a=t.ownerDocument,s=()=>!i&&a.defaultView!==null,l=(f,S)=>void setTimeout(()=>s()&&S(),f),c=f=>void requestAnimationFrame(()=>s()&&f()),u=f=>{if(r=!1,i)return;let S=a.activeElement;if(!(!(S===null||S===a.body||S===a.documentElement)||n.length===0)){if(La(n[0])){f&&n[0]instanceof HTMLElement&&n[0].focus({preventScroll:!0});return}for(let A of n.slice(1)){if(!A.isConnected)continue;let x=Lr(A,n[0]);if(x){x.focus({preventScroll:!0}),n=[];return}}}},g=(f,S=Date.now()+2500)=>{l(100,()=>{u(f);let v=a.activeElement;(v===null||v===a.body||v===a.documentElement)&&n.length>0&&Date.now()<S&&g(f,S)})},y=()=>{r||n.length===0||(r=!0,l(60,()=>c(()=>{u(!1),g(!1)})))},m=f=>{if(!(f instanceof KeyboardEvent&&!["Enter"," ","Escape"].includes(f.key))){if(!(f instanceof KeyboardEvent)){let S=f.target instanceof Element?f.target.closest(cn):null,v=a.activeElement,A=v===null||v===a.body||v===a.documentElement;if(S&&A&&t.contains(S)){n=[];for(let x=S;x&&x!==t.parentElement;x=x.parentElement)n.push(x);l(150,()=>c(()=>{u(!1),g(!1)}));return}}!(f instanceof KeyboardEvent)&&!(f.target instanceof Node&&n[0]?.contains(f.target))||l(150,()=>c(()=>{u(!0),g(!0)}))}},b=new MutationObserver(()=>{n.length>0&&!n[0].isConnected&&y()}),k=f=>{f.relatedTarget===null&&y()};return t.addEventListener("focusin",o),t.addEventListener("focusout",k),t.addEventListener("click",m),t.addEventListener("keydown",m),b.observe(t,{childList:!0,subtree:!0}),()=>{i=!0,t.removeEventListener("focusin",o),t.removeEventListener("focusout",k),t.removeEventListener("click",m),t.removeEventListener("keydown",m),b.disconnect()}},[e])}export{fe as a,Q as b,Je as c,Da as d,Na as e,co as f,uo as g,po as h,Tt as i,z as j,fo as k,le as l,ye as m,Qe as n,_e as o,et as p,nt as q,Mt as r,me as s,Ga as t,Zr as u,ee as v,yo as w,de as x,mo as y,Xr as z,Fa as A,go as B,Ct as C,Jr as D,Qr as E,ei as F,W as G,Wt as H,vi as I,xi as J,Lo as K,it as L,Ei as M,He as N,Ho as O,Pi as P,Ft as Q,Kt as R,Bt as S,De as T,Hi as U,Ne as V,Di as W,Ni as X,dr as Y,Bi as Z,zi as _,Gs as $,Zi as aa,ne as ba,en as ca,dt as da,Xi as ea,Ji as fa,Qi as ga,Qt as ha,Cr as ia,Aa as ja,ea as ka,fr as la,yr as ma,mr as na,gr as oa,hr as pa,Sr as qa,wr as ra,vr as sa,ta,na as ua,nn as va,oa as wa,gt as xa,ra as ya,ia as za,aa as Aa,sa as Ba,la as Ca,da as Da,Rr as Ea,ua as Fa,rn as Ga,Ta as Ha,Ma as Ia,Ca as Ja,Oa as Ka,Va as La,fa as Ma,ya as Na,ga as Oa,Se as Pa,_a as Qa,ha as Ra,St as Sa,Mr as Ta,va as Ua,Pa as Va};
2
+ /*! Bundled license information:
3
+
4
+ react/cjs/react.production.js:
5
+ (**
6
+ * @license React
7
+ * react.production.js
8
+ *
9
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
10
+ *
11
+ * This source code is licensed under the MIT license found in the
12
+ * LICENSE file in the root directory of this source tree.
13
+ *)
14
+
15
+ react/cjs/react-jsx-runtime.production.js:
16
+ (**
17
+ * @license React
18
+ * react-jsx-runtime.production.js
19
+ *
20
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
21
+ *
22
+ * This source code is licensed under the MIT license found in the
23
+ * LICENSE file in the root directory of this source tree.
24
+ *)
25
+ */
@@ -1 +1 @@
1
- import{q as ce}from"./chunk.MPMROUZA.js";import{a as Z,b as C,c as ee,d as te,g as oe,j as re,k as P,l as se,p as le,s as de}from"./chunk.OLKFEHWB.js";import{a as ie,b as ne,c as ae}from"./chunk.Q6RUTFU3.js";import"./chunk.AZGXBTOQ.js";import"./chunk.KRVEAIKW.js";import"./chunk.XOZU4OFA.js";import"./chunk.AG7CUSSV.js";import{a as X}from"./chunk.IDYPQ45A.js";import"./chunk.TI4OSTQV.js";import"./chunk.7UD2JR6J.js";import"./chunk.5ZWE72VJ.js";import"./chunk.RLO3RDYH.js";import"./chunk.TUNHUTQ5.js";import{c as _,j as J}from"./chunk.FWZF7X6A.js";import"./chunk.3JMZHCB4.js";import{G as me,J as U,T as V,ba as j}from"./chunk.SF4BYBH6.js";import"./chunk.SDO3U72B.js";import{Qc as Y,ha as B}from"./chunk.3MZIWKNG.js";import"./chunk.SLBWPVIY.js";import{b as O}from"./chunk.AJZBJBMO.js";var a=O(me(),1);var d=O(V(),1),ke=new Set(["show","go","to","open","the","a","an","me"]),ge=r=>r.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,""),W=(r,p)=>{let s=ge(r);return p.every(t=>s.includes(t))},pe=r=>r&&!/^.\p{Lu}/u.test(r)?`${r[0].toLowerCase()}${r.slice(1)}`:r,L={act:4,show:3,place:3,record:4},we=360,h=12;function De({face:r,opening:p,close:s}){let t=X(),{setMenuAt:v}=j(),n=(0,a.useMemo)(()=>p.target??Z(p.pointed??{about:[]},e=>t.store.graph.has(e)),[p,t.store]),f=(0,a.useMemo)(()=>oe(t.store,n,t.places),[t.store,n,t.places]),[u,y]=(0,a.useState)(""),[b,m]=(0,a.useState)(-1),[l,$]=(0,a.useState)(null),[A,I]=(0,a.useState)(null),E=(0,a.useRef)(null),z=(0,a.useRef)(null),T=(0,a.useId)(),R=(0,a.useRef)(!0),{ghost:G}=U(t.desk);(0,a.useEffect)(()=>()=>{R.current=!1;let e=t.desk.get().ghost;e?.onCard&&t.desk.setGhost({...e,onCard:!1})},[t.desk]);let M=(0,a.useMemo)(()=>{let e=P(t,n);return ee(t.store,n,{principal:t.principal,places:t.places,...e.acts?{acts:e.acts}:{}})},[t,n]),K=(0,a.useMemo)(()=>{let e=C(n);if(e.length===0)return[];let i=new Set(M.candidates.flatMap(c=>c.type==="act"?[c.mutation]:[]));return ie(t.store,e,{principal:t.principal,...e.length===1?{focus:e[0]}:{}}).affordances.filter(c=>!c.destructive&&i.has(c.mutation))},[t.store,t.principal,n,M]),q=(0,a.useCallback)(()=>{let e=p.returnTo,i=ue(E.current,n,r);s(),requestAnimationFrame(()=>{if(e?.isConnected&&!e.closest("[inert]"))return e.focus({preventScroll:!0});let c=(i&&i.tabIndex>=0?i:null)??document.querySelector("[data-graview-page-title]")??document.querySelector("main");c&&c.tabIndex<0&&!c.hasAttribute("tabindex")&&c.setAttribute("tabindex","-1"),c?.focus({preventScroll:!0})})},[p.returnTo,n,r,s]),F=(0,a.useCallback)(e=>{if(e.open.length>0){let i=E.current?.getBoundingClientRect();s(),v({x:i?.left??0,y:i?.top??0,on:e.args.id??C(n)[0],about:C(n)});return}try{ae(t.store,e,{},{pressed:t.principal?{author:t.principal}:{}}),ne(t.store,e,{},{author:t.principal}),q()}catch(i){I(i instanceof Error?i.message:String(i))}},[t.store,t.principal,s,q,v,n]),H=(0,a.useCallback)(async e=>{let i=e.trim();if(!i)return;let c=l?.result?.answer?{said:l.said,answer:l.result.answer}:void 0;y(""),m(-1),I(null),$({said:i,result:null});let S=await re(t.ai,{...P(t,n,i),said:i,...c?{follows:c}:{}});t.desk.record(S.interaction),S.ghost&&S.ghost.proposals.length>0&&t.desk.setGhost({ghost:S.ghost,onCard:!0}),R.current&&$({said:i,result:S})},[l,t,n]),N=(0,a.useRef)(p.asked);(0,a.useEffect)(()=>{let e=N.current;N.current=void 0,e&&H(e)},[]);let k=(0,a.useMemo)(()=>{let e=u.trim();if(!e&&l)return[];let i=ge(e).split(/\s+/).filter(o=>o&&!ke.has(o)),c=/^show\b/i.test(e),S=/^(go|open)\b/i.test(e),x=[];if(!c&&!S)for(let o of K.filter(g=>W(g.label,i)).slice(0,L.act))x.push({id:`act:${o.id}`,kind:"act",label:o.label,hint:o.open.length>0?"asks more":"do it",take:()=>F(o)});let Q=e&&!/\?\s*$/.test(e)?te(t.store,n,{principal:t.principal,places:t.places,said:e}):[];for(let o of Q)x.push({id:`place:${o.place}`,kind:"place",label:o.fit==="full"?`Open ${o.title}`:`Open and adjust ${o.title}`,hint:o.fit==="full"?"a view you have":"adjust it",take:()=>{s(),t.goTo.place(o.place),o.fit==="partial"&&_(t.desk,{target:{on:"lens",place:o.place,...o.kind?{kind:o.kind}:{}},asked:e})}});if(!S){let o=M.candidates.filter(g=>g.type==="panel");for(let g of o.filter(D=>W(`show ${D.label}`,i)).slice(0,L.show))x.push({id:g.id,kind:"show",label:`Show ${pe(g.label)}`,hint:"a panel",take:()=>{s(),se(t,{title:g.label,recipe:{...g.panel,title:g.label}})}})}if(!c){for(let o of t.places.filter(g=>W(g.title,i)&&!Q.some(D=>D.place===g.as)).slice(0,L.place))x.push({id:`place:${o.as}`,kind:"place",label:`Go to ${o.title}`,take:()=>(s(),t.goTo.place(o.as))});if(i.length>0){let o=ce(t.store,e.replace(/^(go to|open)\s+/i,""),{principal:t.principal,from:C(n),limit:L.record}).hits;for(let g of o)g.about==="node"&&x.push({id:`record:${g.id}`,kind:"record",label:g.label,hint:B(t.store.schema,g.kind),take:()=>(s(),t.goTo.record(g.id))})}}return e&&x.push({id:"ask",kind:"ask",label:e,take:()=>void H(e)}),x},[u,K,M,t,n,F,H,s,l]);(0,a.useEffect)(()=>m(u.trim()?0:-1),[u]),(0,a.useLayoutEffect)(()=>{let e=E.current;if(!e)return;if(typeof e.showPopover=="function")try{e.showPopover()}catch{}z.current?.focus({preventScroll:!0});let i=0,c=()=>{be(e,ue(e,n,r)),i=requestAnimationFrame(c)};return c(),()=>cancelAnimationFrame(i)},[n,r]),(0,a.useEffect)(()=>{if(l)return;let e=i=>{i.target instanceof Node&&E.current?.contains(i.target)||s()};return document.addEventListener("pointerdown",e,!0),()=>document.removeEventListener("pointerdown",e,!0)},[l,s]);let fe=e=>{if(e.key==="ArrowDown"&&k.length>0)e.preventDefault(),m(i=>Math.min(k.length-1,i+1));else if(e.key==="ArrowUp"&&k.length>0)e.preventDefault(),m(i=>Math.max(0,i-1));else if(e.key==="Enter"){e.preventDefault();let i=k[b];i?i.take():u.trim()&&H(u)}},w=l?.result??null,he=k[b];return(0,d.jsxs)("section",{ref:E,popover:"manual",role:"region","aria-label":l?`Answer about ${f}`:`Ask about ${f}`,"data-testid":"quick-ask","data-quick-ask":l?"answer":"bar","data-quick-ask-face":r,"data-graview-offstage":"","data-graview-overlay":"",onKeyDown:e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),q())},onMouseDown:e=>e.stopPropagation(),style:ve,children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[(0,d.jsxs)("p",{"data-testid":"quick-ask-about",style:{margin:0,flex:"1 1 auto",minWidth:0,fontSize:"0.75rem",color:"var(--graview-ink-muted)",overflowWrap:"anywhere"},children:["About ",f]}),(0,d.jsx)("button",{type:"button","data-testid":"quick-ask-close","aria-label":"Close",title:"Close",onClick:q,style:ye,children:(0,d.jsx)("span",{"aria-hidden":"true",children:"\u2715"})})]}),l?(0,d.jsxs)("div",{"data-testid":"quick-answer",style:{display:"grid",gap:8},children:[(0,d.jsxs)("p",{"data-testid":"quick-answer-asked",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-ink-muted)",fontStyle:"italic",overflowWrap:"anywhere"},children:["\u201C",l.said,"\u201D"]}),(0,d.jsx)("p",{"data-testid":"quick-answer-text","aria-live":"polite",style:{margin:0,fontSize:"0.9375rem",lineHeight:1.45,color:w?.interaction.outcome==="failed"?"var(--graview-warn)":"var(--graview-ink)",overflowWrap:"anywhere"},children:w===null?"Thinking\u2026":w.interaction.outcome==="failed"?w.interaction.failed??"The AI could not answer that here.":w.answer??""}),w&&w.offers.length>0?(0,d.jsx)("ul",{"aria-label":"What acts on it",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:6},children:w.offers.map(e=>(0,d.jsx)("li",{children:(0,d.jsx)("button",{type:"button","data-testid":"quick-answer-offer","data-ai-offer":e.id,"data-ai-offer-type":e.type,onClick:()=>{le(t,w,e,s).then(i=>{i&&R.current&&I(i)})},style:xe,children:e.type==="panel"?`Show ${pe(e.label)}`:e.type==="place"?`Go to ${e.label}`:e.label})},e.id))}):null,G?.onCard&&G.ghost.interaction===w?.interaction.id?(0,d.jsx)(de,{placement:"card"}):null]}):null,(0,d.jsxs)("div",{style:{display:"grid",gap:4},children:[(0,d.jsx)("input",{ref:z,type:"text",role:"combobox","data-testid":"quick-ask-input","aria-label":l?`Ask a follow-up about ${f}`:`Ask about ${f}, or go somewhere`,"aria-expanded":k.length>0,"aria-controls":T,"aria-autocomplete":"list",...he?{"aria-activedescendant":`${T}-${b}`}:{},autoComplete:"off",enterKeyHint:"go",placeholder:l?"Ask a follow-up\u2026":"Ask, or go to\u2026",value:u,readOnly:l!==null&&w===null,"aria-busy":l!==null&&w===null,onChange:e=>y(e.target.value),onKeyDown:fe,style:Ae}),(0,d.jsx)("div",{id:T,role:"listbox","aria-label":u.trim()?`What \u201C${u.trim()}\u201D finds here`:"What can be done here",hidden:k.length===0,style:{display:k.length===0?"none":"grid",gap:1,maxHeight:280,overflowY:"auto"},children:k.map((e,i)=>(0,d.jsx)("div",{id:`${T}-${i}`,role:"option","aria-selected":i===b,"data-testid":"quick-ask-option","data-quick-ask-kind":e.kind,"data-quick-ask-row":e.id,onMouseEnter:()=>m(i),onMouseDown:c=>c.preventDefault(),onClick:e.take,style:{...Se,background:i===b?"var(--graview-panel-muted)":"transparent",...e.kind==="ask"?{borderTop:"1px solid var(--graview-edge)",marginTop:2}:{}},children:e.kind==="ask"?(0,d.jsxs)("span",{children:["Ask: ",(0,d.jsxs)("span",{style:{fontWeight:600},children:["\u2018",e.label,"\u2019"]})]}):(0,d.jsxs)("span",{children:[e.label,e.hint?(0,d.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",e.hint]}):null]})},e.id))})]}),A?(0,d.jsx)("p",{role:"alert","data-testid":"quick-ask-refused",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-warn)"},children:A}):null,(0,d.jsx)("span",{style:J,"aria-live":"polite",children:k.length>0&&u.trim()?`${k.length} ${k.length===1?"way":"ways"} to go on`:""})]})}function ue(r,p,s){let t=r?.closest("[data-graview-embed]")??document,v=p.on==="list"?[`aggregate:${p.kind}`,`kind:${p.kind}`]:p.on==="lens"&&p.kind?[`aggregate:${p.kind}`]:C(p);for(let n of v)for(let f of t.querySelectorAll(`[data-graview-view="${CSS.escape(n)}"], [data-graview-pick="${CSS.escape(n)}"]`)){if(r?.contains(f))continue;let u=f.getBoundingClientRect();if(u.width>0&&u.height>0)return f}return s==="pages"?t.querySelector("main [data-graview-page-title]")??t.querySelector("main h1"):null}function be(r,p){let s={width:document.documentElement.clientWidth||innerWidth,height:innerHeight},t=Math.min(we,s.width-2*h),v=r.getBoundingClientRect().height,n=p?.getBoundingClientRect(),f,u,y,b=A=>Math.max(h,Math.min(A,s.height-v-h));if(n&&n.width>0&&n.bottom>0&&n.top<s.height)if(n.right+h+t<=s.width-h)f=n.right+h,u=b(n.top),y="right";else if(n.left-h-t>=h)f=n.left-h-t,u=b(n.top),y="left";else{f=Math.max(h,Math.min(n.left,s.width-t-h));let A=n.bottom+h;u=A+v<=s.height-h?A:b(n.top-h-v),y=A+v<=s.height-h?"below":"above"}else f=(s.width-t)/2,u=b(72),y="top";let m=r.style,l={left:`${Math.round(f)}px`,top:`${Math.round(u)}px`,width:`${Math.round(t)}px`};m.left!==l.left&&(m.left=l.left),m.top!==l.top&&(m.top=l.top),m.width!==l.width&&(m.width=l.width);let $=p?.getAttribute("data-graview-view")??p?.getAttribute("data-graview-pick")??(p?"page":"");r.getAttribute("data-quick-ask-beside")!==$&&r.setAttribute("data-quick-ask-beside",$),r.getAttribute("data-quick-ask-side")!==y&&r.setAttribute("data-quick-ask-side",y)}var ve={position:"fixed",inset:"auto",margin:0,zIndex:Y("popover"),boxSizing:"border-box",display:"grid",gap:10,padding:12,borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",color:"var(--graview-ink)",boxShadow:"var(--graview-lift-high)",maxHeight:"calc(100dvh - 24px)",overflowY:"auto",fontSize:"0.875rem"},ye={display:"inline-grid",placeItems:"center",width:28,height:28,padding:0,font:"inherit",fontSize:"0.875rem",lineHeight:1,color:"var(--graview-ink-muted)",background:"transparent",border:"1px solid transparent",borderRadius:6,boxShadow:"none",cursor:"pointer"},Ae={boxSizing:"border-box",width:"100%",height:36,padding:"0 10px",font:"inherit",fontSize:"max(1rem,16px)",color:"var(--graview-ink)",background:"var(--graview-panel)",border:"1px solid var(--graview-edge)",borderRadius:8},Se={display:"flex",alignItems:"center",minHeight:30,padding:"4px 8px",borderRadius:6,cursor:"pointer",overflowWrap:"anywhere"},xe={display:"inline-flex",alignItems:"center",minHeight:30,padding:"2px 10px",font:"inherit",fontSize:"0.8125rem",borderRadius:8};export{De as QuickAskCard};
1
+ import{q as ce}from"./chunk.7RJGEU3Y.js";import{a as Z,b as C,c as ee,d as te,g as oe,j as re,k as P,l as se,p as le,s as de}from"./chunk.4EY6WPSM.js";import"./chunk.BJUUSIQY.js";import{a as ie,b as ne,c as ae}from"./chunk.RDL6652E.js";import"./chunk.V3NPUAPB.js";import"./chunk.USQNSNIA.js";import"./chunk.XOZU4OFA.js";import"./chunk.IT763BYH.js";import{a as X}from"./chunk.JZDKHWRL.js";import"./chunk.SOTB6C5A.js";import"./chunk.XJFAUOJS.js";import"./chunk.DPPT6WAJ.js";import"./chunk.7U2JO7ET.js";import{c as _,j as J}from"./chunk.HFVMGTNL.js";import"./chunk.7Z4USR3Y.js";import{G as me,J as U,T as V,ba as j}from"./chunk.NPAWTPLQ.js";import"./chunk.SDO3U72B.js";import{Vc as Y,ja as B}from"./chunk.YEJ4LNUP.js";import"./chunk.FQLNBIQ5.js";import{b as O}from"./chunk.AJZBJBMO.js";var a=O(me(),1);var d=O(V(),1),ke=new Set(["show","go","to","open","the","a","an","me"]),ge=r=>r.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,""),W=(r,p)=>{let s=ge(r);return p.every(t=>s.includes(t))},pe=r=>r&&!/^.\p{Lu}/u.test(r)?`${r[0].toLowerCase()}${r.slice(1)}`:r,L={act:4,show:3,place:3,record:4},we=360,h=12;function De({face:r,opening:p,close:s}){let t=X(),{setMenuAt:v}=j(),n=(0,a.useMemo)(()=>p.target??Z(p.pointed??{about:[]},e=>t.store.graph.has(e)),[p,t.store]),f=(0,a.useMemo)(()=>oe(t.store,n,t.places),[t.store,n,t.places]),[u,y]=(0,a.useState)(""),[b,m]=(0,a.useState)(-1),[l,$]=(0,a.useState)(null),[A,I]=(0,a.useState)(null),E=(0,a.useRef)(null),z=(0,a.useRef)(null),T=(0,a.useId)(),R=(0,a.useRef)(!0),{ghost:G}=U(t.desk);(0,a.useEffect)(()=>()=>{R.current=!1;let e=t.desk.get().ghost;e?.onCard&&t.desk.setGhost({...e,onCard:!1})},[t.desk]);let M=(0,a.useMemo)(()=>{let e=P(t,n);return ee(t.store,n,{principal:t.principal,places:t.places,...e.acts?{acts:e.acts}:{}})},[t,n]),K=(0,a.useMemo)(()=>{let e=C(n);if(e.length===0)return[];let i=new Set(M.candidates.flatMap(c=>c.type==="act"?[c.mutation]:[]));return ie(t.store,e,{principal:t.principal,...e.length===1?{focus:e[0]}:{}}).affordances.filter(c=>!c.destructive&&i.has(c.mutation))},[t.store,t.principal,n,M]),q=(0,a.useCallback)(()=>{let e=p.returnTo,i=ue(E.current,n,r);s(),requestAnimationFrame(()=>{if(e?.isConnected&&!e.closest("[inert]"))return e.focus({preventScroll:!0});let c=(i&&i.tabIndex>=0?i:null)??document.querySelector("[data-graview-page-title]")??document.querySelector("main");c&&c.tabIndex<0&&!c.hasAttribute("tabindex")&&c.setAttribute("tabindex","-1"),c?.focus({preventScroll:!0})})},[p.returnTo,n,r,s]),F=(0,a.useCallback)(e=>{if(e.open.length>0){let i=E.current?.getBoundingClientRect();s(),v({x:i?.left??0,y:i?.top??0,on:e.args.id??C(n)[0],about:C(n)});return}try{ae(t.store,e,{},{pressed:t.principal?{author:t.principal}:{}}),ne(t.store,e,{},{author:t.principal}),q()}catch(i){I(i instanceof Error?i.message:String(i))}},[t.store,t.principal,s,q,v,n]),H=(0,a.useCallback)(async e=>{let i=e.trim();if(!i)return;let c=l?.result?.answer?{said:l.said,answer:l.result.answer}:void 0;y(""),m(-1),I(null),$({said:i,result:null});let S=await re(t.ai,{...P(t,n,i),said:i,...c?{follows:c}:{}});t.desk.record(S.interaction),S.ghost&&S.ghost.proposals.length>0&&t.desk.setGhost({ghost:S.ghost,onCard:!0}),R.current&&$({said:i,result:S})},[l,t,n]),N=(0,a.useRef)(p.asked);(0,a.useEffect)(()=>{let e=N.current;N.current=void 0,e&&H(e)},[]);let k=(0,a.useMemo)(()=>{let e=u.trim();if(!e&&l)return[];let i=ge(e).split(/\s+/).filter(o=>o&&!ke.has(o)),c=/^show\b/i.test(e),S=/^(go|open)\b/i.test(e),x=[];if(!c&&!S)for(let o of K.filter(g=>W(g.label,i)).slice(0,L.act))x.push({id:`act:${o.id}`,kind:"act",label:o.label,hint:o.open.length>0?"asks more":"do it",take:()=>F(o)});let Q=e&&!/\?\s*$/.test(e)?te(t.store,n,{principal:t.principal,places:t.places,said:e}):[];for(let o of Q)x.push({id:`place:${o.place}`,kind:"place",label:o.fit==="full"?`Open ${o.title}`:`Open and adjust ${o.title}`,hint:o.fit==="full"?"a view you have":"adjust it",take:()=>{s(),t.goTo.place(o.place),o.fit==="partial"&&_(t.desk,{target:{on:"lens",place:o.place,...o.kind?{kind:o.kind}:{}},asked:e})}});if(!S){let o=M.candidates.filter(g=>g.type==="panel");for(let g of o.filter(D=>W(`show ${D.label}`,i)).slice(0,L.show))x.push({id:g.id,kind:"show",label:`Show ${pe(g.label)}`,hint:"a panel",take:()=>{s(),se(t,{title:g.label,recipe:{...g.panel,title:g.label}})}})}if(!c){for(let o of t.places.filter(g=>W(g.title,i)&&!Q.some(D=>D.place===g.as)).slice(0,L.place))x.push({id:`place:${o.as}`,kind:"place",label:`Go to ${o.title}`,take:()=>(s(),t.goTo.place(o.as))});if(i.length>0){let o=ce(t.store,e.replace(/^(go to|open)\s+/i,""),{principal:t.principal,from:C(n),limit:L.record}).hits;for(let g of o)g.about==="node"&&x.push({id:`record:${g.id}`,kind:"record",label:g.label,hint:B(t.store.schema,g.kind),take:()=>(s(),t.goTo.record(g.id))})}}return e&&x.push({id:"ask",kind:"ask",label:e,take:()=>void H(e)}),x},[u,K,M,t,n,F,H,s,l]);(0,a.useEffect)(()=>m(u.trim()?0:-1),[u]),(0,a.useLayoutEffect)(()=>{let e=E.current;if(!e)return;if(typeof e.showPopover=="function")try{e.showPopover()}catch{}z.current?.focus({preventScroll:!0});let i=0,c=()=>{be(e,ue(e,n,r)),i=requestAnimationFrame(c)};return c(),()=>cancelAnimationFrame(i)},[n,r]),(0,a.useEffect)(()=>{if(l)return;let e=i=>{i.target instanceof Node&&E.current?.contains(i.target)||s()};return document.addEventListener("pointerdown",e,!0),()=>document.removeEventListener("pointerdown",e,!0)},[l,s]);let fe=e=>{if(e.key==="ArrowDown"&&k.length>0)e.preventDefault(),m(i=>Math.min(k.length-1,i+1));else if(e.key==="ArrowUp"&&k.length>0)e.preventDefault(),m(i=>Math.max(0,i-1));else if(e.key==="Enter"){e.preventDefault();let i=k[b];i?i.take():u.trim()&&H(u)}},w=l?.result??null,he=k[b];return(0,d.jsxs)("section",{ref:E,popover:"manual",role:"region","aria-label":l?`Answer about ${f}`:`Ask about ${f}`,"data-testid":"quick-ask","data-quick-ask":l?"answer":"bar","data-quick-ask-face":r,"data-graview-offstage":"","data-graview-overlay":"",onKeyDown:e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),q())},onMouseDown:e=>e.stopPropagation(),style:ve,children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[(0,d.jsxs)("p",{"data-testid":"quick-ask-about",style:{margin:0,flex:"1 1 auto",minWidth:0,fontSize:"0.75rem",color:"var(--graview-ink-muted)",overflowWrap:"anywhere"},children:["About ",f]}),(0,d.jsx)("button",{type:"button","data-testid":"quick-ask-close","aria-label":"Close",title:"Close",onClick:q,style:ye,children:(0,d.jsx)("span",{"aria-hidden":"true",children:"\u2715"})})]}),l?(0,d.jsxs)("div",{"data-testid":"quick-answer",style:{display:"grid",gap:8},children:[(0,d.jsxs)("p",{"data-testid":"quick-answer-asked",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-ink-muted)",fontStyle:"italic",overflowWrap:"anywhere"},children:["\u201C",l.said,"\u201D"]}),(0,d.jsx)("p",{"data-testid":"quick-answer-text","aria-live":"polite",style:{margin:0,fontSize:"0.9375rem",lineHeight:1.45,color:w?.interaction.outcome==="failed"?"var(--graview-warn)":"var(--graview-ink)",overflowWrap:"anywhere"},children:w===null?"Thinking\u2026":w.interaction.outcome==="failed"?w.interaction.failed??"The AI could not answer that here.":w.answer??""}),w&&w.offers.length>0?(0,d.jsx)("ul",{"aria-label":"What acts on it",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:6},children:w.offers.map(e=>(0,d.jsx)("li",{children:(0,d.jsx)("button",{type:"button","data-testid":"quick-answer-offer","data-ai-offer":e.id,"data-ai-offer-type":e.type,onClick:()=>{le(t,w,e,s).then(i=>{i&&R.current&&I(i)})},style:xe,children:e.type==="panel"?`Show ${pe(e.label)}`:e.type==="place"?`Go to ${e.label}`:e.label})},e.id))}):null,G?.onCard&&G.ghost.interaction===w?.interaction.id?(0,d.jsx)(de,{placement:"card"}):null]}):null,(0,d.jsxs)("div",{style:{display:"grid",gap:4},children:[(0,d.jsx)("input",{ref:z,type:"text",role:"combobox","data-testid":"quick-ask-input","aria-label":l?`Ask a follow-up about ${f}`:`Ask about ${f}, or go somewhere`,"aria-expanded":k.length>0,"aria-controls":T,"aria-autocomplete":"list",...he?{"aria-activedescendant":`${T}-${b}`}:{},autoComplete:"off",enterKeyHint:"go",placeholder:l?"Ask a follow-up\u2026":"Ask, or go to\u2026",value:u,readOnly:l!==null&&w===null,"aria-busy":l!==null&&w===null,onChange:e=>y(e.target.value),onKeyDown:fe,style:Ae}),(0,d.jsx)("div",{id:T,role:"listbox","aria-label":u.trim()?`What \u201C${u.trim()}\u201D finds here`:"What can be done here",hidden:k.length===0,style:{display:k.length===0?"none":"grid",gap:1,maxHeight:280,overflowY:"auto"},children:k.map((e,i)=>(0,d.jsx)("div",{id:`${T}-${i}`,role:"option","aria-selected":i===b,"data-testid":"quick-ask-option","data-quick-ask-kind":e.kind,"data-quick-ask-row":e.id,onMouseEnter:()=>m(i),onMouseDown:c=>c.preventDefault(),onClick:e.take,style:{...Se,background:i===b?"var(--graview-panel-muted)":"transparent",...e.kind==="ask"?{borderTop:"1px solid var(--graview-edge)",marginTop:2}:{}},children:e.kind==="ask"?(0,d.jsxs)("span",{children:["Ask: ",(0,d.jsxs)("span",{style:{fontWeight:600},children:["\u2018",e.label,"\u2019"]})]}):(0,d.jsxs)("span",{children:[e.label,e.hint?(0,d.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",e.hint]}):null]})},e.id))})]}),A?(0,d.jsx)("p",{role:"alert","data-testid":"quick-ask-refused",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-warn)"},children:A}):null,(0,d.jsx)("span",{style:J,"aria-live":"polite",children:k.length>0&&u.trim()?`${k.length} ${k.length===1?"way":"ways"} to go on`:""})]})}function ue(r,p,s){let t=r?.closest("[data-graview-embed]")??document,v=p.on==="list"?[`aggregate:${p.kind}`,`kind:${p.kind}`]:p.on==="lens"&&p.kind?[`aggregate:${p.kind}`]:C(p);for(let n of v)for(let f of t.querySelectorAll(`[data-graview-view="${CSS.escape(n)}"], [data-graview-pick="${CSS.escape(n)}"]`)){if(r?.contains(f))continue;let u=f.getBoundingClientRect();if(u.width>0&&u.height>0)return f}return s==="pages"?t.querySelector("main [data-graview-page-title]")??t.querySelector("main h1"):null}function be(r,p){let s={width:document.documentElement.clientWidth||innerWidth,height:innerHeight},t=Math.min(we,s.width-2*h),v=r.getBoundingClientRect().height,n=p?.getBoundingClientRect(),f,u,y,b=A=>Math.max(h,Math.min(A,s.height-v-h));if(n&&n.width>0&&n.bottom>0&&n.top<s.height)if(n.right+h+t<=s.width-h)f=n.right+h,u=b(n.top),y="right";else if(n.left-h-t>=h)f=n.left-h-t,u=b(n.top),y="left";else{f=Math.max(h,Math.min(n.left,s.width-t-h));let A=n.bottom+h;u=A+v<=s.height-h?A:b(n.top-h-v),y=A+v<=s.height-h?"below":"above"}else f=(s.width-t)/2,u=b(72),y="top";let m=r.style,l={left:`${Math.round(f)}px`,top:`${Math.round(u)}px`,width:`${Math.round(t)}px`};m.left!==l.left&&(m.left=l.left),m.top!==l.top&&(m.top=l.top),m.width!==l.width&&(m.width=l.width);let $=p?.getAttribute("data-graview-view")??p?.getAttribute("data-graview-pick")??(p?"page":"");r.getAttribute("data-quick-ask-beside")!==$&&r.setAttribute("data-quick-ask-beside",$),r.getAttribute("data-quick-ask-side")!==y&&r.setAttribute("data-quick-ask-side",y)}var ve={position:"fixed",inset:"auto",margin:0,zIndex:Y("popover"),boxSizing:"border-box",display:"grid",gap:10,padding:12,borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",color:"var(--graview-ink)",boxShadow:"var(--graview-lift-high)",maxHeight:"calc(100dvh - 24px)",overflowY:"auto",fontSize:"0.875rem"},ye={display:"inline-grid",placeItems:"center",width:28,height:28,padding:0,font:"inherit",fontSize:"0.875rem",lineHeight:1,color:"var(--graview-ink-muted)",background:"transparent",border:"1px solid transparent",borderRadius:6,boxShadow:"none",cursor:"pointer"},Ae={boxSizing:"border-box",width:"100%",height:36,padding:"0 10px",font:"inherit",fontSize:"max(1rem,16px)",color:"var(--graview-ink)",background:"var(--graview-panel)",border:"1px solid var(--graview-edge)",borderRadius:8},Se={display:"flex",alignItems:"center",minHeight:30,padding:"4px 8px",borderRadius:6,cursor:"pointer",overflowWrap:"anywhere"},xe={display:"inline-flex",alignItems:"center",minHeight:30,padding:"2px 10px",font:"inherit",fontSize:"0.8125rem",borderRadius:8};export{De as QuickAskCard};
@@ -1 +1 @@
1
- import"./chunk.5ZWE72VJ.js";import"./chunk.RLO3RDYH.js";import{b as m}from"./chunk.TUNHUTQ5.js";import"./chunk.FWZF7X6A.js";import"./chunk.3JMZHCB4.js";import{T as p}from"./chunk.SF4BYBH6.js";import"./chunk.SDO3U72B.js";import{U as l}from"./chunk.3MZIWKNG.js";import"./chunk.SLBWPVIY.js";import{b as f}from"./chunk.AJZBJBMO.js";var a=f(p(),1);function A({states:e,definition:v}){let s=e.values.reduce((t,n)=>t+n.count,0),u=t=>t===null?"with none":m(v,e.field,t).toLowerCase(),c=e.values.filter(t=>t.count>0).map(t=>`${l(t.count)} ${u(t.value)}`).join(", ");return s===0?null:(0,a.jsx)("div",{className:"graview-district-states",role:"img","aria-label":c,title:c,children:e.values.map((t,n)=>{if(t.count===0)return null;let y=e.values.filter(r=>r.count>0).length,w=t.count/s*(168-(y-1)),o=l(t.count),i=`${o} ${u(t.value)}`,d=r=>r.length*6.2+8<=w;return(0,a.jsx)("span",{"data-graview-tier":t.tier,style:{flexGrow:t.count},title:i,children:d(i)?i:d(o)?o:""},n)})})}export{A as StatesBar};
1
+ import"./chunk.XJFAUOJS.js";import"./chunk.DPPT6WAJ.js";import{b as m}from"./chunk.7U2JO7ET.js";import"./chunk.HFVMGTNL.js";import"./chunk.7Z4USR3Y.js";import{T as p}from"./chunk.NPAWTPLQ.js";import"./chunk.SDO3U72B.js";import{W as l}from"./chunk.YEJ4LNUP.js";import"./chunk.FQLNBIQ5.js";import{b as f}from"./chunk.AJZBJBMO.js";var a=f(p(),1);function A({states:e,definition:v}){let s=e.values.reduce((t,n)=>t+n.count,0),u=t=>t===null?"with none":m(v,e.field,t).toLowerCase(),c=e.values.filter(t=>t.count>0).map(t=>`${l(t.count)} ${u(t.value)}`).join(", ");return s===0?null:(0,a.jsx)("div",{className:"graview-district-states",role:"img","aria-label":c,title:c,children:e.values.map((t,n)=>{if(t.count===0)return null;let y=e.values.filter(r=>r.count>0).length,w=t.count/s*(168-(y-1)),o=l(t.count),i=`${o} ${u(t.value)}`,d=r=>r.length*6.2+8<=w;return(0,a.jsx)("span",{"data-graview-tier":t.tier,style:{flexGrow:t.count},title:i,children:d(i)?i:d(o)?o:""},n)})})}export{A as StatesBar};
@@ -1 +1 @@
1
- import"./chunk.WVUJXDXZ.js";import{a as k,b as q,c as pe}from"./chunk.3V2WXZU3.js";import"./chunk.7UD2JR6J.js";import"./chunk.BUDEUNBN.js";import"./chunk.3IEJQAK7.js";import"./chunk.AKLVSZ5A.js";import"./chunk.ZUBC3UFG.js";import"./chunk.GZHZLJBF.js";import{n as me}from"./chunk.PZWJUQAO.js";import"./chunk.OJGHDWI6.js";import"./chunk.NEJSKMJV.js";import"./chunk.5ZWE72VJ.js";import"./chunk.RLO3RDYH.js";import"./chunk.TUNHUTQ5.js";import"./chunk.FWZF7X6A.js";import"./chunk.3JMZHCB4.js";import{G as Le,M as S,O as ue,T as ce,ba as ge,ea as he}from"./chunk.SF4BYBH6.js";import"./chunk.SDO3U72B.js";import{Pc as de,ka as oe,na as w,pa as le,ra as E,sa as x,ta as se,ua as Y}from"./chunk.3MZIWKNG.js";import"./chunk.SLBWPVIY.js";import{b as U}from"./chunk.AJZBJBMO.js";var h=U(Le(),1);async function ye(e,n){let i=await createImageBitmap(e);try{let r=Math.min(1,n/Math.max(i.width,i.height)),a=document.createElement("canvas");a.width=Math.max(1,Math.round(i.width*r)),a.height=Math.max(1,Math.round(i.height*r));let l=a.getContext("2d");if(l===null)throw new Error("This browser will not give us a canvas to resize with.");return l.drawImage(i,0,0,a.width,a.height),a}finally{i.close()}}var t=U(ce(),1),Ve=2048,Ie=.85;function _(e){return e<1e3?`${e} bytes`:e<1e6?`${Math.round(e/1e3)} KB`:`${(e/1e6).toFixed(e<1e7?1:0)} MB`}function z(e){if(e.type==="application/pdf")return"PDF";let n=/\.([a-z0-9]{2,5})$/i.exec(e.name??"")?.[1];return n?n.toUpperCase():(e.type.split("/")[1]??e.type).replace(/^x-|^vnd\./,"").split(/[.+-]/)[0].toUpperCase()}function ke(e){let n=[...new Set(e.map(i=>i==="image/*"?"pictures":i==="video/*"?"videos":i==="*/*"||i==="*"?"any file":`${z({type:i})} files`))];return n.length<=1?n[0]??"no files":`${n.slice(0,-1).join(", ")} and ${n[n.length-1]}`}function Fe(e,n){if(e.length===0)return!0;let i=`${n.split("/")[0]}/*`;return e.some(r=>r==="*"||r==="*/*"||r===n||r===i)}var fe=/^image\/hei[cf]$|\.hei[cf]$/i,be=e=>fe.test(e.type)||fe.test(e.name),De={mov:"video/quicktime",mp4:"video/mp4",m4v:"video/mp4",webm:"video/webm",ogv:"video/ogg"},Be=e=>De[/\.([a-z0-9]{2,4})$/i.exec(e)?.[1]?.toLowerCase()??""];async function je(e,n,i){let r=e.name||(i.camera?"photo.jpg":"file"),a=e.type||(be({type:"",name:r})?"image/heic":Be(r)??"application/octet-stream"),l=be({type:a,name:r}),u=a.startsWith("image/")||l;if(i.image&&!u)return{refused:`\u201C${r}\u201D isn\u2019t a picture.`};if(i.video)return a.startsWith("video/")?K({blob:e,name:r,type:a},n):{refused:`\u201C${r}\u201D isn\u2019t a video.`};if(l||u&&/^image\/(jpeg|webp)$/.test(a)&&(i.camera||e.size>n.maxBytes||e.size>15e5))try{let c=await ye(e,Ve),b=await new Promise(p=>c.toBlob(p,"image/jpeg",Ie));if(b)return K({blob:b,name:l?r.replace(/\.hei[cf]$/i,"")+".jpg":r,type:"image/jpeg",width:c.width,height:c.height},n)}catch{if(l&&!Fe(n.kinds,a))return{refused:`\u201C${r}\u201D is a HEIC photo, which this browser can\u2019t turn into a JPEG and this host doesn\u2019t take. Save it as a JPEG and try again.`}}let y={};if(u&&!l)try{let c=await createImageBitmap(e);y={width:c.width,height:c.height},c.close()}catch{}return K({blob:e,name:r,type:a,...y},n)}function K(e,n){return Fe(n.kinds,e.type)?e.blob.size>n.maxBytes?{refused:`\u201C${e.name}\u201D is ${_(e.blob.size)}; this host takes files up to ${_(n.maxBytes)}.`}:e:{refused:`\u201C${e.name}\u201D is a ${z(e)} file; this host takes ${ke(n.kinds)}.`}}async function _e(e,n,i,r=!1){let a;try{a=await n.upload(e.blob,e.name)}catch(u){let s=u instanceof Error&&u.message.trim()?u.message.trim():"the host refused it";return{refused:`\u201C${e.name}\u201D wasn\u2019t kept: ${s}`}}return le(a)?i&&!E(a)?{refused:`\u201C${e.name}\u201D isn\u2019t a picture.`}:r&&!x(a)?{refused:`The host kept \u201C${e.name}\u201D as ${z(a)}, not as a video.`}:{...a,...a.width===void 0&&e.width?{width:e.width}:{},...a.height===void 0&&e.height?{height:e.height}:{}}:{refused:`The host\u2019s answer for \u201C${e.name}\u201D isn\u2019t a file a record can keep.`}}var F="var(--graview-radius, 8px)",P={color:"var(--graview-ink-muted)",fontSize:"0.8125rem"};function Z(e){let n=S(),i=ue()?.past!=null,[r,a]=(0,h.useState)(!1),l=n?.kept?ze(n,e.href):!0,[,u]=(0,h.useState)(0);return(0,h.useEffect)(()=>{if(typeof l!="object")return;let s=!0;return l.then(()=>s&&u(y=>y+1)),()=>void(s=!1)},[l]),[l===!1||i&&r,()=>a(!0)]}var J=new WeakMap;function ze(e,n){let i=J.get(e)?.get(n);if(i!==void 0)return i;let r;try{r=e.kept(n)}catch{return!0}if(typeof r=="boolean")return r;let a=J.get(e)??new Map;J.set(e,a);let l=Promise.resolve(r).then(u=>u!==!1,()=>!0);return a.set(n,l),l.then(u=>a.set(n,u)),l}function ee({file:e,style:n}){return(0,t.jsx)("span",{role:"img","aria-label":`${k(e)}, removed later`,"data-graview-removed-later":e.href,style:{display:"grid",placeItems:"center",textAlign:"center",padding:4,boxSizing:"border-box",fontSize:"0.6875rem",lineHeight:1.2,color:"var(--graview-ink-muted)",border:"1px dashed var(--graview-edge-bright)",borderRadius:F,...n},children:"removed later"})}function Q({file:e,size:n=56,style:i}){let r=S(),[a,l]=Z(e);return a?(0,t.jsx)(ee,{file:e,style:{width:n,height:n,flex:"none",...i}}):x(e)?(0,t.jsx)(Ae,{file:e,size:n,...i?{style:i}:{},onError:l}):(0,t.jsx)("img",{onError:l,src:w(r,e.href),alt:k(e),width:n,height:n,loading:"lazy",decoding:"async","data-graview-thumb":e.href,style:{width:n,height:n,objectFit:"cover",borderRadius:F,display:"block",flex:"none",background:"var(--graview-edge)",...i}})}function $e(e){let[n,i]=(0,h.useState)({}),r=e.duration??n.duration;return[{...r!==void 0?{duration:r}:{},width:e.width??n.width,height:e.height??n.height},u=>{let s=u.currentTarget;i({...Number.isFinite(s.duration)&&s.duration>0?{duration:s.duration}:{},...s.videoWidth>0&&s.videoHeight>0?{width:s.videoWidth,height:s.videoHeight}:{}})}]}var Ne=320,xe=(e,n)=>`${k(e)}, ${se({...n!==void 0?{duration:n}:{}})}`,Oe=(0,t.jsx)("span",{"data-graview-play-glyph":"","aria-hidden":"true",style:{position:"absolute",inset:0,display:"grid",placeItems:"center",pointerEvents:"none"},children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",width:"40%",height:"40%",style:{maxWidth:40,maxHeight:40,filter:"drop-shadow(0 1px 2px rgb(0 0 0 / 0.5))"},children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"11",fill:"rgb(0 0 0 / 0.55)"}),(0,t.jsx)("path",{d:"M9.5 7.5v9l7-4.5z",fill:"#fff"})]})});function Ae({file:e,size:n,style:i,onError:r}){let a=S(),[l,u]=$e(e),s={width:n,height:n,objectFit:"cover",display:"block",borderRadius:F,background:"var(--graview-edge)"};return(0,t.jsxs)("span",{role:"img","aria-label":xe(e,l.duration),"data-graview-thumb":e.href,"data-graview-video-thumb":"",style:{position:"relative",display:"block",width:n,height:n,flex:"none",...i},children:[e.poster?(0,t.jsx)("img",{src:w(a,e.poster),alt:"",width:n,height:n,loading:"lazy",decoding:"async",onError:r,style:s}):(0,t.jsx)("video",{src:w(a,e.href),preload:"metadata",muted:!0,playsInline:!0,"aria-hidden":"true",tabIndex:-1,width:n,height:n,onLoadedMetadata:u,onError:r,style:s}),Oe,l.duration!==void 0?(0,t.jsx)("span",{"data-graview-video-clock":"","aria-hidden":"true",style:{position:"absolute",right:3,bottom:3,padding:"0 4px",borderRadius:4,background:"rgb(0 0 0 / 0.65)",color:"#fff",fontSize:"0.6875rem",lineHeight:"16px",fontVariantNumeric:"tabular-nums"},children:q(l.duration)}):null]})}function Ge({file:e}){let n=S(),[i,r]=Z(e),[a,l]=$e(e);if(i)return(0,t.jsx)(ee,{file:e,style:{width:"100%",aspectRatio:"16 / 9"}});let u=a.width!==void 0&&a.height!==void 0;return(0,t.jsxs)("figure",{"data-graview-video-figure":e.href,style:{margin:0,display:"grid",gap:4,minWidth:0},children:[(0,t.jsx)("video",{"data-graview-video":e.href,src:w(n,e.href),...e.poster?{poster:w(n,e.poster)}:{},controls:!0,preload:"metadata",playsInline:!0,...u?{width:a.width,height:a.height}:{},"aria-label":xe(e,a.duration),onLoadedMetadata:l,onError:r,style:{display:"block",width:"100%",maxWidth:u?Math.max(a.width,Ne):"100%",height:"auto",maxHeight:"80vh",aspectRatio:u?`${a.width} / ${a.height}`:"16 / 9",borderRadius:F,background:"#000"},children:e.captions?(0,t.jsx)("track",{kind:"captions",src:w(n,e.captions),srcLang:"en",label:"Captions",default:!0}):null}),(0,t.jsx)("figcaption",{"data-graview-video-said":"",style:P,children:[e.caption??e.name,...a.duration!==void 0?[q(a.duration)]:[]].join(" \xB7 ")})]})}function Ue({file:e,onOpen:n}){let i=S(),[r,a]=Z(e);return r?(0,t.jsx)(ee,{file:e,style:{width:"100%",aspectRatio:"1"}}):(0,t.jsx)("button",{type:"button","aria-label":`Open ${k(e)} full size`,onClick:l=>n(l.currentTarget),style:{padding:0,border:0,background:"none",cursor:"zoom-in",display:"block",width:"100%",borderRadius:F},children:(0,t.jsx)("img",{src:w(i,e.href),alt:k(e),loading:"lazy",decoding:"async",onError:a,style:{width:"100%",aspectRatio:"1",objectFit:"cover",borderRadius:F,display:"block",background:"var(--graview-edge)"}})})}function X({files:e,label:n}){let i=S(),r=d=>w(i,d.href),a=e.filter(E),l=e.filter(x),u=e.filter(d=>!E(d)&&!x(d)),[s,y]=(0,h.useState)(null),c=(0,h.useRef)(null),b=(0,h.useRef)(null);(0,h.useEffect)(()=>{let d=c.current;s!==null&&d&&!d.open&&d.showModal?.()},[s]);let p=s===null?void 0:a[s];return(0,t.jsxs)("div",{style:{display:"grid",gap:10,minWidth:0},children:[a.length>0?(0,t.jsx)("ul",{"data-graview-gallery":"","aria-label":n,style:{listStyle:"none",margin:0,padding:0,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(96px, 1fr))",gap:8},children:a.map((d,T)=>(0,t.jsx)("li",{style:{minWidth:0},children:(0,t.jsx)(Ue,{file:d,onOpen:R=>{b.current=R,y(T)}})},d.href))}):null,l.length>0?(0,t.jsx)("ul",{"data-graview-videos":"","aria-label":n,style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:12},children:l.map(d=>(0,t.jsx)("li",{style:{minWidth:0},children:(0,t.jsx)(Ge,{file:d})},d.href))}):null,u.length>0?(0,t.jsx)("ul",{"data-graview-documents":"",style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:10},children:u.map(d=>(0,t.jsxs)("li",{"data-graview-document":d.type,style:{display:"grid",gap:6,minWidth:0},children:[d.type==="application/pdf"?(0,t.jsx)("object",{data:r(d),type:"application/pdf","aria-label":k(d),style:{width:"100%",height:420,border:"1px solid var(--graview-edge)",borderRadius:F},children:(0,t.jsxs)("p",{style:{margin:0,padding:12},children:["This browser shows no PDF here: ",(0,t.jsxs)("a",{href:r(d),download:d.name,children:["download ",d.name]}),"."]})}):null,(0,t.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",gap:"2px 10px",alignItems:"baseline",minWidth:0,overflowWrap:"anywhere"},children:[(0,t.jsx)("a",{href:r(d),download:d.name,...d.type==="application/pdf"?{target:"_blank",rel:"noopener"}:{},children:d.name}),(0,t.jsxs)("span",{style:P,children:[z(d)," \xB7 ",_(d.bytes)]})]}),d.caption?(0,t.jsx)("span",{style:P,children:d.caption}):null]},d.href))}):null,p?(0,t.jsx)("dialog",{ref:c,"data-graview-full":p.href,"aria-label":k(p),onClose:()=>{y(null),b.current?.focus()},onClick:d=>{d.target===d.currentTarget&&d.currentTarget.close()},style:{padding:0,border:0,borderRadius:F,maxWidth:"min(96vw, 1600px)",maxHeight:"94vh",background:"var(--graview-panel)",color:"var(--graview-ink)"},children:(0,t.jsxs)("figure",{style:{margin:0,display:"grid",gap:8,padding:10},children:[(0,t.jsx)("img",{src:r(p),alt:k(p),style:{maxWidth:"100%",maxHeight:"80vh",objectFit:"contain",display:"block",margin:"0 auto"}}),(0,t.jsxs)("figcaption",{style:{display:"flex",gap:12,alignItems:"center",justifyContent:"space-between"},children:[(0,t.jsx)("span",{children:p.caption??p.name}),(0,t.jsx)("form",{method:"dialog",style:{margin:0},children:(0,t.jsx)("button",{type:"submit",autoFocus:!0,children:"Close"})})]})]})}):null]})}function Se({value:e,onChange:n,several:i,image:r,video:a=!1,label:l,thumbs:u=!0}){let s=S(),y=(0,h.useId)(),c=(0,h.useRef)(null),b=(0,h.useRef)(null),[p,d]=(0,h.useState)(null),[T,R]=(0,h.useState)(null),[te,H]=(0,h.useState)([]),[N,O]=(0,h.useState)(!1),W=r?"image/":a?"video/":void 0,C=s?W?s.kinds.filter(o=>o.startsWith(W)||o==="*"||o==="*/*"):s.kinds:[],Pe=s?s.kinds.length===0||C.length>0:!1,Re=!a&&(s?s.kinds.length===0||(r?C:s.kinds).some(o=>o.startsWith("image/")||o.startsWith("*")):!1),ne=!!s&&s.maxBytes>0,L=ne&&(!W||Pe),V=r?"picture":a?"video":"file",ae=i?`${V}s`:`a ${V}`,ie=W?C.length>0?C.join(","):`${W}*`:s?.kinds.join(",")||void 0,We=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,A=(0,h.useRef)(e);A.current=e;let re=(0,h.useRef)(null),I=(0,h.useRef)(null);(0,h.useEffect)(()=>{let o=I.current;if(!o||o.from===e)return;I.current=null;let g=re.current?.children,f=g?.[Math.min(o.at,g.length-1)];((o.what==="move"?f?.querySelector("[data-graview-file-move]"):null)??f?.querySelector("[data-graview-file-remove]")??c.current?.parentElement?.querySelector("[data-graview-file-choose]"))?.focus()});let D=async(o,g)=>{if(!s||o.length===0)return;let f=i?o:o.slice(0,1),m=[],$=[];f.length<o.length&&$.push(`${l} holds one ${V}, so ${o.slice(1).map(v=>`\u201C${v.name||"the photo"}\u201D`).join(", ")} ${o.length>2?"were":"was"} left out.`),H([]),R(null);for(let v of f){d(`Sending ${v.name||"the photo"}\u2026`);let G=await je(v,s,{image:r,video:a,camera:g==="camera"});if("refused"in G){$.push(G.refused);continue}let M=await _e(G,s,r,a);"refused"in M?$.push(M.refused):[...i?A.current:[],...m].some(He=>He.href===M.href)?$.push(`\u201C${M.name}\u201D is already here.`):m.push(M)}if(d(null),H($),m.length!==0)try{n(i?[...A.current,...m]:m.slice(-1)),R(`Added ${m.map(v=>v.name).join(", ")}.`)}catch(v){H([...$,v instanceof Error?v.message:String(v)])}},B=(o,g,f)=>{try{I.current=f?{...f,from:e}:null,n(o),R(g)}catch(m){I.current=null,H([m instanceof Error?m.message:String(m)])}},j=o=>o?Array.from(o):[],Me=o=>{let g=j(o.clipboardData?.files);!L||g.length===0||(o.preventDefault(),D(g,"pasted"))},Te=o=>{O(!1),L&&(o.preventDefault(),D(j(o.dataTransfer?.files),"dropped"))};return(0,t.jsxs)("div",{role:"group","aria-labelledby":`${y}-label`,"data-graview-file-editor":"","data-graview-dropping":N?"":void 0,onPaste:Me,onDragOver:o=>{L&&(o.preventDefault(),O(!0))},onDragLeave:()=>O(!1),onDrop:Te,style:{display:"grid",gap:8,minWidth:0,padding:N?6:0,outline:N?"2px dashed var(--graview-accent)":"none",borderRadius:F},children:[(0,t.jsx)("span",{id:`${y}-label`,style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},children:l}),e.length>0&&(i||e.length>1)?(0,t.jsx)("ul",{ref:re,style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:6},children:e.map((o,g)=>(0,t.jsxs)("li",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap",minWidth:0},children:[u&&(E(o)||x(o))?(0,t.jsx)(Q,{file:o,size:40}):null,(0,t.jsx)("span",{style:{flex:"1 1 8rem",minWidth:0,overflowWrap:"anywhere"},children:o.name}),(0,t.jsx)(we,{file:o,onCaption:f=>B(e.map((m,$)=>$===g?ve(m,f):m),f?`${o.name} now says \u201C${f}\u201D.`:`${o.name} says its name again.`)}),i&&g>0?(0,t.jsx)("button",{type:"button","data-graview-file-move":"","aria-label":`Move ${o.name} earlier`,onClick:()=>B(e.map((f,m)=>m===g-1?o:m===g?e[g-1]:f),`Moved ${o.name} earlier.`,{at:g-1,what:"move"}),children:"\u2191"}):null,i?(0,t.jsx)("button",{type:"button","data-graview-file-remove":"","aria-label":`Remove ${o.name}`,onClick:()=>B(e.filter((f,m)=>m!==g),`Removed ${o.name}.`,{at:g,what:"remove"}),children:"Remove"}):null]},`${g}:${o.href}`))}):e.length===1?(0,t.jsx)(we,{file:e[0],onCaption:o=>B([ve(e[0],o)],o?`${e[0].name} now says \u201C${o}\u201D.`:`${e[0].name} says its name again.`)}):null,L?(0,t.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:8,alignItems:"center"},children:[(0,t.jsx)("input",{ref:c,type:"file",hidden:!0,multiple:i,...ie?{accept:ie}:{},"data-graview-file-input":"","aria-label":`Choose ${ae}`,onChange:o=>{let g=j(o.currentTarget.files);o.currentTarget.value="",D(g,"picked")}}),(0,t.jsx)("button",{type:"button",disabled:p!==null,onClick:()=>c.current?.click(),"data-graview-file-choose":"",children:e.length>0&&!i?`Replace the ${V}`:`Choose ${ae}`}),Re?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("input",{ref:b,type:"file",hidden:!0,accept:"image/*",capture:"environment","data-graview-photo-input":"","aria-label":"Take a photo",onChange:o=>{let g=j(o.currentTarget.files);o.currentTarget.value="",D(g,"camera")}}),We?(0,t.jsx)("button",{type:"button",disabled:p!==null,onClick:()=>b.current?.click(),children:"Take a photo"}):null]}):null,(0,t.jsxs)("span",{style:P,"data-graview-file-takes":"",children:["or drop or paste ",i?"them":"it"," here \xB7 ",s.kinds.length>0?ke(C.length>0?C:s.kinds):"any file",", up to ",_(s.maxBytes)]})]}):(0,t.jsx)("p",{style:{...P,margin:0},"data-graview-file-none":"",children:ne?`This host doesn\u2019t take ${a?"videos":"pictures"}, so none can be added here.`:"This host doesn\u2019t take files, so none can be added here."}),(0,t.jsx)("p",{"aria-live":"polite",style:{...P,margin:0,minHeight:p||T?void 0:0},"data-graview-file-status":"",children:p??T??""}),te.length>0?(0,t.jsx)("div",{role:"alert","data-graview-file-refused":"",style:{color:"var(--graview-warn)",fontSize:"0.875rem",display:"grid",gap:2},children:te.map((o,g)=>(0,t.jsx)("p",{style:{margin:0},children:o},g))}):null]})}var ve=(e,n)=>{let{caption:i,...r}=e;return n?{...r,caption:n}:r};function we({file:e,onCaption:n}){let[i,r]=(0,h.useState)(e.caption??"");(0,h.useEffect)(()=>r(e.caption??""),[e.caption]);let a=()=>{let l=i.trim().slice(0,500);l!==(e.caption??"")&&n(l)};return(0,t.jsx)("input",{type:"text",value:i,placeholder:E(e)||x(e)?"What it shows":"What it is","aria-label":`What ${e.name} ${E(e)||x(e)?"shows":"is"}`,"data-graview-file-caption":e.href,onChange:l=>r(l.target.value),onBlur:a,onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),a())},style:{flex:"1 1 10rem",minWidth:0,font:"inherit",fontSize:"0.875rem",minHeight:24}})}function Ee({field:e,label:n,labelStyle:i,valueStyle:r,style:a,children:l}){return(0,t.jsxs)("div",{"data-graview-files":e,style:{display:"grid",gap:6,minWidth:0,gridColumn:"1 / -1",...a},children:[(0,t.jsx)("dt",{style:i,children:n}),(0,t.jsx)("dd",{style:{margin:0,minWidth:0,display:"grid",gap:10,...r},children:l})]})}function Ce(e){let{nodeId:n,field:i,label:r,files:a}=e,{fields:l,commit:u}=me(n),s=l.find(p=>p.field===i&&p.takesValue),y=s?.shape,c=y?.type==="several"?y.of:y,b=y?.type==="several";return a.length===0&&c?.type!=="file"?null:(0,t.jsxs)(Ee,{...e,children:[(0,t.jsx)(X,{files:a,label:r}),s&&c?.type==="file"?(0,t.jsx)(Se,{value:a,thumbs:!1,several:b,image:c.image===!0,video:c.video===!0,label:r,onChange:p=>{let d=b?p:p[p.length-1];d!==void 0&&u(s,d)}}):null]})}function et(e){switch(e.as){case"field":return e.read?e.files.length>0?(0,t.jsx)(Ee,{...e,children:(0,t.jsx)(X,{files:e.files,label:e.label})}):null:(0,t.jsx)(Ce,{...e});case"unfilled":return(0,t.jsx)(Ye,{...e});case"thumb":return(0,t.jsx)(Q,{...e});case"block":return e.files.length>0?(0,t.jsx)("span",{className:"graview-spec-image","data-graview-field":e.field,"data-graview-image":e.view,style:{display:"block",minWidth:0,...e.view==="gallery"?{position:"relative",zIndex:de.raised}:{}},children:e.view==="thumb"?(0,t.jsx)(Q,{file:e.files[0],size:72}):(0,t.jsx)(X,{files:e.files,label:e.label})}):null;case"control":{let n=(0,t.jsx)(Se,{value:Y(e.value),several:e.several,image:e.image,video:e.video===!0,label:e.label,onChange:i=>e.onChange(e.several?i:i[i.length-1])});return e.title===void 0?n:(0,t.jsxs)("fieldset",{"data-graview-part":"group","data-graview-field":e.several?"files":"file",children:[(0,t.jsx)("legend",{"data-graview-part":"label",children:e.title}),n]})}}}function Ye({nodeId:e,skip:n,labels:i,labelStyle:r,style:a}){let{store:l}=ge(),u=he(e),s=u?l.schema.tryDefinition(u.kind):void 0,y=pe(s).filter(c=>!n.includes(c)&&!(s?.display?.hide??[]).includes(c)&&Y(u?.[c]).length===0);return y.length===0?null:(0,t.jsx)("dl",{style:{margin:0,display:"grid",gap:14,minWidth:0},children:y.map(c=>(0,t.jsx)(Ce,{nodeId:e,field:c,label:i?.[c]??oe(s,c),files:[],...r?{labelStyle:r}:{},...a?{style:a}:{}},c))})}export{Se as FilesEditor,Ve as SEND_EDGE,et as drawFiles,ke as kindsWords,je as prepare,_e as send,_ as sizeWords,Fe as takes,z as typeWords};
1
+ import"./chunk.WVUJXDXZ.js";import{a as k,b as q,c as pe}from"./chunk.T2RME6XF.js";import"./chunk.SOTB6C5A.js";import"./chunk.TQCRFZ53.js";import"./chunk.6HLKAUWF.js";import"./chunk.FCUDBMGC.js";import"./chunk.KMEKMCKG.js";import"./chunk.GZHZLJBF.js";import{n as me}from"./chunk.E5XNQTEU.js";import"./chunk.OJGHDWI6.js";import"./chunk.K5YLQAFW.js";import"./chunk.XJFAUOJS.js";import"./chunk.DPPT6WAJ.js";import"./chunk.7U2JO7ET.js";import"./chunk.HFVMGTNL.js";import"./chunk.7Z4USR3Y.js";import{G as Le,M as S,O as ue,T as ce,ba as ge,ea as he}from"./chunk.NPAWTPLQ.js";import"./chunk.SDO3U72B.js";import{Uc as de,ma as oe,pa as w,ra as le,ta as E,ua as x,va as se,wa as Y}from"./chunk.YEJ4LNUP.js";import"./chunk.FQLNBIQ5.js";import{b as U}from"./chunk.AJZBJBMO.js";var h=U(Le(),1);async function ye(e,n){let i=await createImageBitmap(e);try{let r=Math.min(1,n/Math.max(i.width,i.height)),a=document.createElement("canvas");a.width=Math.max(1,Math.round(i.width*r)),a.height=Math.max(1,Math.round(i.height*r));let l=a.getContext("2d");if(l===null)throw new Error("This browser will not give us a canvas to resize with.");return l.drawImage(i,0,0,a.width,a.height),a}finally{i.close()}}var t=U(ce(),1),Ve=2048,Ie=.85;function _(e){return e<1e3?`${e} bytes`:e<1e6?`${Math.round(e/1e3)} KB`:`${(e/1e6).toFixed(e<1e7?1:0)} MB`}function z(e){if(e.type==="application/pdf")return"PDF";let n=/\.([a-z0-9]{2,5})$/i.exec(e.name??"")?.[1];return n?n.toUpperCase():(e.type.split("/")[1]??e.type).replace(/^x-|^vnd\./,"").split(/[.+-]/)[0].toUpperCase()}function ke(e){let n=[...new Set(e.map(i=>i==="image/*"?"pictures":i==="video/*"?"videos":i==="*/*"||i==="*"?"any file":`${z({type:i})} files`))];return n.length<=1?n[0]??"no files":`${n.slice(0,-1).join(", ")} and ${n[n.length-1]}`}function Fe(e,n){if(e.length===0)return!0;let i=`${n.split("/")[0]}/*`;return e.some(r=>r==="*"||r==="*/*"||r===n||r===i)}var fe=/^image\/hei[cf]$|\.hei[cf]$/i,be=e=>fe.test(e.type)||fe.test(e.name),De={mov:"video/quicktime",mp4:"video/mp4",m4v:"video/mp4",webm:"video/webm",ogv:"video/ogg"},Be=e=>De[/\.([a-z0-9]{2,4})$/i.exec(e)?.[1]?.toLowerCase()??""];async function je(e,n,i){let r=e.name||(i.camera?"photo.jpg":"file"),a=e.type||(be({type:"",name:r})?"image/heic":Be(r)??"application/octet-stream"),l=be({type:a,name:r}),u=a.startsWith("image/")||l;if(i.image&&!u)return{refused:`\u201C${r}\u201D isn\u2019t a picture.`};if(i.video)return a.startsWith("video/")?K({blob:e,name:r,type:a},n):{refused:`\u201C${r}\u201D isn\u2019t a video.`};if(l||u&&/^image\/(jpeg|webp)$/.test(a)&&(i.camera||e.size>n.maxBytes||e.size>15e5))try{let c=await ye(e,Ve),b=await new Promise(p=>c.toBlob(p,"image/jpeg",Ie));if(b)return K({blob:b,name:l?r.replace(/\.hei[cf]$/i,"")+".jpg":r,type:"image/jpeg",width:c.width,height:c.height},n)}catch{if(l&&!Fe(n.kinds,a))return{refused:`\u201C${r}\u201D is a HEIC photo, which this browser can\u2019t turn into a JPEG and this host doesn\u2019t take. Save it as a JPEG and try again.`}}let y={};if(u&&!l)try{let c=await createImageBitmap(e);y={width:c.width,height:c.height},c.close()}catch{}return K({blob:e,name:r,type:a,...y},n)}function K(e,n){return Fe(n.kinds,e.type)?e.blob.size>n.maxBytes?{refused:`\u201C${e.name}\u201D is ${_(e.blob.size)}; this host takes files up to ${_(n.maxBytes)}.`}:e:{refused:`\u201C${e.name}\u201D is a ${z(e)} file; this host takes ${ke(n.kinds)}.`}}async function _e(e,n,i,r=!1){let a;try{a=await n.upload(e.blob,e.name)}catch(u){let s=u instanceof Error&&u.message.trim()?u.message.trim():"the host refused it";return{refused:`\u201C${e.name}\u201D wasn\u2019t kept: ${s}`}}return le(a)?i&&!E(a)?{refused:`\u201C${e.name}\u201D isn\u2019t a picture.`}:r&&!x(a)?{refused:`The host kept \u201C${e.name}\u201D as ${z(a)}, not as a video.`}:{...a,...a.width===void 0&&e.width?{width:e.width}:{},...a.height===void 0&&e.height?{height:e.height}:{}}:{refused:`The host\u2019s answer for \u201C${e.name}\u201D isn\u2019t a file a record can keep.`}}var F="var(--graview-radius, 8px)",P={color:"var(--graview-ink-muted)",fontSize:"0.8125rem"};function Z(e){let n=S(),i=ue()?.past!=null,[r,a]=(0,h.useState)(!1),l=n?.kept?ze(n,e.href):!0,[,u]=(0,h.useState)(0);return(0,h.useEffect)(()=>{if(typeof l!="object")return;let s=!0;return l.then(()=>s&&u(y=>y+1)),()=>void(s=!1)},[l]),[l===!1||i&&r,()=>a(!0)]}var J=new WeakMap;function ze(e,n){let i=J.get(e)?.get(n);if(i!==void 0)return i;let r;try{r=e.kept(n)}catch{return!0}if(typeof r=="boolean")return r;let a=J.get(e)??new Map;J.set(e,a);let l=Promise.resolve(r).then(u=>u!==!1,()=>!0);return a.set(n,l),l.then(u=>a.set(n,u)),l}function ee({file:e,style:n}){return(0,t.jsx)("span",{role:"img","aria-label":`${k(e)}, removed later`,"data-graview-removed-later":e.href,style:{display:"grid",placeItems:"center",textAlign:"center",padding:4,boxSizing:"border-box",fontSize:"0.6875rem",lineHeight:1.2,color:"var(--graview-ink-muted)",border:"1px dashed var(--graview-edge-bright)",borderRadius:F,...n},children:"removed later"})}function Q({file:e,size:n=56,style:i}){let r=S(),[a,l]=Z(e);return a?(0,t.jsx)(ee,{file:e,style:{width:n,height:n,flex:"none",...i}}):x(e)?(0,t.jsx)(Ae,{file:e,size:n,...i?{style:i}:{},onError:l}):(0,t.jsx)("img",{onError:l,src:w(r,e.href),alt:k(e),width:n,height:n,loading:"lazy",decoding:"async","data-graview-thumb":e.href,style:{width:n,height:n,objectFit:"cover",borderRadius:F,display:"block",flex:"none",background:"var(--graview-edge)",...i}})}function $e(e){let[n,i]=(0,h.useState)({}),r=e.duration??n.duration;return[{...r!==void 0?{duration:r}:{},width:e.width??n.width,height:e.height??n.height},u=>{let s=u.currentTarget;i({...Number.isFinite(s.duration)&&s.duration>0?{duration:s.duration}:{},...s.videoWidth>0&&s.videoHeight>0?{width:s.videoWidth,height:s.videoHeight}:{}})}]}var Ne=320,xe=(e,n)=>`${k(e)}, ${se({...n!==void 0?{duration:n}:{}})}`,Oe=(0,t.jsx)("span",{"data-graview-play-glyph":"","aria-hidden":"true",style:{position:"absolute",inset:0,display:"grid",placeItems:"center",pointerEvents:"none"},children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",width:"40%",height:"40%",style:{maxWidth:40,maxHeight:40,filter:"drop-shadow(0 1px 2px rgb(0 0 0 / 0.5))"},children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"11",fill:"rgb(0 0 0 / 0.55)"}),(0,t.jsx)("path",{d:"M9.5 7.5v9l7-4.5z",fill:"#fff"})]})});function Ae({file:e,size:n,style:i,onError:r}){let a=S(),[l,u]=$e(e),s={width:n,height:n,objectFit:"cover",display:"block",borderRadius:F,background:"var(--graview-edge)"};return(0,t.jsxs)("span",{role:"img","aria-label":xe(e,l.duration),"data-graview-thumb":e.href,"data-graview-video-thumb":"",style:{position:"relative",display:"block",width:n,height:n,flex:"none",...i},children:[e.poster?(0,t.jsx)("img",{src:w(a,e.poster),alt:"",width:n,height:n,loading:"lazy",decoding:"async",onError:r,style:s}):(0,t.jsx)("video",{src:w(a,e.href),preload:"metadata",muted:!0,playsInline:!0,"aria-hidden":"true",tabIndex:-1,width:n,height:n,onLoadedMetadata:u,onError:r,style:s}),Oe,l.duration!==void 0?(0,t.jsx)("span",{"data-graview-video-clock":"","aria-hidden":"true",style:{position:"absolute",right:3,bottom:3,padding:"0 4px",borderRadius:4,background:"rgb(0 0 0 / 0.65)",color:"#fff",fontSize:"0.6875rem",lineHeight:"16px",fontVariantNumeric:"tabular-nums"},children:q(l.duration)}):null]})}function Ge({file:e}){let n=S(),[i,r]=Z(e),[a,l]=$e(e);if(i)return(0,t.jsx)(ee,{file:e,style:{width:"100%",aspectRatio:"16 / 9"}});let u=a.width!==void 0&&a.height!==void 0;return(0,t.jsxs)("figure",{"data-graview-video-figure":e.href,style:{margin:0,display:"grid",gap:4,minWidth:0},children:[(0,t.jsx)("video",{"data-graview-video":e.href,src:w(n,e.href),...e.poster?{poster:w(n,e.poster)}:{},controls:!0,preload:"metadata",playsInline:!0,...u?{width:a.width,height:a.height}:{},"aria-label":xe(e,a.duration),onLoadedMetadata:l,onError:r,style:{display:"block",width:"100%",maxWidth:u?Math.max(a.width,Ne):"100%",height:"auto",maxHeight:"80vh",aspectRatio:u?`${a.width} / ${a.height}`:"16 / 9",borderRadius:F,background:"#000"},children:e.captions?(0,t.jsx)("track",{kind:"captions",src:w(n,e.captions),srcLang:"en",label:"Captions",default:!0}):null}),(0,t.jsx)("figcaption",{"data-graview-video-said":"",style:P,children:[e.caption??e.name,...a.duration!==void 0?[q(a.duration)]:[]].join(" \xB7 ")})]})}function Ue({file:e,onOpen:n}){let i=S(),[r,a]=Z(e);return r?(0,t.jsx)(ee,{file:e,style:{width:"100%",aspectRatio:"1"}}):(0,t.jsx)("button",{type:"button","aria-label":`Open ${k(e)} full size`,onClick:l=>n(l.currentTarget),style:{padding:0,border:0,background:"none",cursor:"zoom-in",display:"block",width:"100%",borderRadius:F},children:(0,t.jsx)("img",{src:w(i,e.href),alt:k(e),loading:"lazy",decoding:"async",onError:a,style:{width:"100%",aspectRatio:"1",objectFit:"cover",borderRadius:F,display:"block",background:"var(--graview-edge)"}})})}function X({files:e,label:n}){let i=S(),r=d=>w(i,d.href),a=e.filter(E),l=e.filter(x),u=e.filter(d=>!E(d)&&!x(d)),[s,y]=(0,h.useState)(null),c=(0,h.useRef)(null),b=(0,h.useRef)(null);(0,h.useEffect)(()=>{let d=c.current;s!==null&&d&&!d.open&&d.showModal?.()},[s]);let p=s===null?void 0:a[s];return(0,t.jsxs)("div",{style:{display:"grid",gap:10,minWidth:0},children:[a.length>0?(0,t.jsx)("ul",{"data-graview-gallery":"","aria-label":n,style:{listStyle:"none",margin:0,padding:0,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(96px, 1fr))",gap:8},children:a.map((d,T)=>(0,t.jsx)("li",{style:{minWidth:0},children:(0,t.jsx)(Ue,{file:d,onOpen:R=>{b.current=R,y(T)}})},d.href))}):null,l.length>0?(0,t.jsx)("ul",{"data-graview-videos":"","aria-label":n,style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:12},children:l.map(d=>(0,t.jsx)("li",{style:{minWidth:0},children:(0,t.jsx)(Ge,{file:d})},d.href))}):null,u.length>0?(0,t.jsx)("ul",{"data-graview-documents":"",style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:10},children:u.map(d=>(0,t.jsxs)("li",{"data-graview-document":d.type,style:{display:"grid",gap:6,minWidth:0},children:[d.type==="application/pdf"?(0,t.jsx)("object",{data:r(d),type:"application/pdf","aria-label":k(d),style:{width:"100%",height:420,border:"1px solid var(--graview-edge)",borderRadius:F},children:(0,t.jsxs)("p",{style:{margin:0,padding:12},children:["This browser shows no PDF here: ",(0,t.jsxs)("a",{href:r(d),download:d.name,children:["download ",d.name]}),"."]})}):null,(0,t.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",gap:"2px 10px",alignItems:"baseline",minWidth:0,overflowWrap:"anywhere"},children:[(0,t.jsx)("a",{href:r(d),download:d.name,...d.type==="application/pdf"?{target:"_blank",rel:"noopener"}:{},children:d.name}),(0,t.jsxs)("span",{style:P,children:[z(d)," \xB7 ",_(d.bytes)]})]}),d.caption?(0,t.jsx)("span",{style:P,children:d.caption}):null]},d.href))}):null,p?(0,t.jsx)("dialog",{ref:c,"data-graview-full":p.href,"aria-label":k(p),onClose:()=>{y(null),b.current?.focus()},onClick:d=>{d.target===d.currentTarget&&d.currentTarget.close()},style:{padding:0,border:0,borderRadius:F,maxWidth:"min(96vw, 1600px)",maxHeight:"94vh",background:"var(--graview-panel)",color:"var(--graview-ink)"},children:(0,t.jsxs)("figure",{style:{margin:0,display:"grid",gap:8,padding:10},children:[(0,t.jsx)("img",{src:r(p),alt:k(p),style:{maxWidth:"100%",maxHeight:"80vh",objectFit:"contain",display:"block",margin:"0 auto"}}),(0,t.jsxs)("figcaption",{style:{display:"flex",gap:12,alignItems:"center",justifyContent:"space-between"},children:[(0,t.jsx)("span",{children:p.caption??p.name}),(0,t.jsx)("form",{method:"dialog",style:{margin:0},children:(0,t.jsx)("button",{type:"submit",autoFocus:!0,children:"Close"})})]})]})}):null]})}function Se({value:e,onChange:n,several:i,image:r,video:a=!1,label:l,thumbs:u=!0}){let s=S(),y=(0,h.useId)(),c=(0,h.useRef)(null),b=(0,h.useRef)(null),[p,d]=(0,h.useState)(null),[T,R]=(0,h.useState)(null),[te,H]=(0,h.useState)([]),[N,O]=(0,h.useState)(!1),W=r?"image/":a?"video/":void 0,C=s?W?s.kinds.filter(o=>o.startsWith(W)||o==="*"||o==="*/*"):s.kinds:[],Pe=s?s.kinds.length===0||C.length>0:!1,Re=!a&&(s?s.kinds.length===0||(r?C:s.kinds).some(o=>o.startsWith("image/")||o.startsWith("*")):!1),ne=!!s&&s.maxBytes>0,L=ne&&(!W||Pe),V=r?"picture":a?"video":"file",ae=i?`${V}s`:`a ${V}`,ie=W?C.length>0?C.join(","):`${W}*`:s?.kinds.join(",")||void 0,We=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,A=(0,h.useRef)(e);A.current=e;let re=(0,h.useRef)(null),I=(0,h.useRef)(null);(0,h.useEffect)(()=>{let o=I.current;if(!o||o.from===e)return;I.current=null;let g=re.current?.children,f=g?.[Math.min(o.at,g.length-1)];((o.what==="move"?f?.querySelector("[data-graview-file-move]"):null)??f?.querySelector("[data-graview-file-remove]")??c.current?.parentElement?.querySelector("[data-graview-file-choose]"))?.focus()});let D=async(o,g)=>{if(!s||o.length===0)return;let f=i?o:o.slice(0,1),m=[],$=[];f.length<o.length&&$.push(`${l} holds one ${V}, so ${o.slice(1).map(v=>`\u201C${v.name||"the photo"}\u201D`).join(", ")} ${o.length>2?"were":"was"} left out.`),H([]),R(null);for(let v of f){d(`Sending ${v.name||"the photo"}\u2026`);let G=await je(v,s,{image:r,video:a,camera:g==="camera"});if("refused"in G){$.push(G.refused);continue}let M=await _e(G,s,r,a);"refused"in M?$.push(M.refused):[...i?A.current:[],...m].some(He=>He.href===M.href)?$.push(`\u201C${M.name}\u201D is already here.`):m.push(M)}if(d(null),H($),m.length!==0)try{n(i?[...A.current,...m]:m.slice(-1)),R(`Added ${m.map(v=>v.name).join(", ")}.`)}catch(v){H([...$,v instanceof Error?v.message:String(v)])}},B=(o,g,f)=>{try{I.current=f?{...f,from:e}:null,n(o),R(g)}catch(m){I.current=null,H([m instanceof Error?m.message:String(m)])}},j=o=>o?Array.from(o):[],Me=o=>{let g=j(o.clipboardData?.files);!L||g.length===0||(o.preventDefault(),D(g,"pasted"))},Te=o=>{O(!1),L&&(o.preventDefault(),D(j(o.dataTransfer?.files),"dropped"))};return(0,t.jsxs)("div",{role:"group","aria-labelledby":`${y}-label`,"data-graview-file-editor":"","data-graview-dropping":N?"":void 0,onPaste:Me,onDragOver:o=>{L&&(o.preventDefault(),O(!0))},onDragLeave:()=>O(!1),onDrop:Te,style:{display:"grid",gap:8,minWidth:0,padding:N?6:0,outline:N?"2px dashed var(--graview-accent)":"none",borderRadius:F},children:[(0,t.jsx)("span",{id:`${y}-label`,style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},children:l}),e.length>0&&(i||e.length>1)?(0,t.jsx)("ul",{ref:re,style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:6},children:e.map((o,g)=>(0,t.jsxs)("li",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap",minWidth:0},children:[u&&(E(o)||x(o))?(0,t.jsx)(Q,{file:o,size:40}):null,(0,t.jsx)("span",{style:{flex:"1 1 8rem",minWidth:0,overflowWrap:"anywhere"},children:o.name}),(0,t.jsx)(we,{file:o,onCaption:f=>B(e.map((m,$)=>$===g?ve(m,f):m),f?`${o.name} now says \u201C${f}\u201D.`:`${o.name} says its name again.`)}),i&&g>0?(0,t.jsx)("button",{type:"button","data-graview-file-move":"","aria-label":`Move ${o.name} earlier`,onClick:()=>B(e.map((f,m)=>m===g-1?o:m===g?e[g-1]:f),`Moved ${o.name} earlier.`,{at:g-1,what:"move"}),children:"\u2191"}):null,i?(0,t.jsx)("button",{type:"button","data-graview-file-remove":"","aria-label":`Remove ${o.name}`,onClick:()=>B(e.filter((f,m)=>m!==g),`Removed ${o.name}.`,{at:g,what:"remove"}),children:"Remove"}):null]},`${g}:${o.href}`))}):e.length===1?(0,t.jsx)(we,{file:e[0],onCaption:o=>B([ve(e[0],o)],o?`${e[0].name} now says \u201C${o}\u201D.`:`${e[0].name} says its name again.`)}):null,L?(0,t.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:8,alignItems:"center"},children:[(0,t.jsx)("input",{ref:c,type:"file",hidden:!0,multiple:i,...ie?{accept:ie}:{},"data-graview-file-input":"","aria-label":`Choose ${ae}`,onChange:o=>{let g=j(o.currentTarget.files);o.currentTarget.value="",D(g,"picked")}}),(0,t.jsx)("button",{type:"button",disabled:p!==null,onClick:()=>c.current?.click(),"data-graview-file-choose":"",children:e.length>0&&!i?`Replace the ${V}`:`Choose ${ae}`}),Re?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("input",{ref:b,type:"file",hidden:!0,accept:"image/*",capture:"environment","data-graview-photo-input":"","aria-label":"Take a photo",onChange:o=>{let g=j(o.currentTarget.files);o.currentTarget.value="",D(g,"camera")}}),We?(0,t.jsx)("button",{type:"button",disabled:p!==null,onClick:()=>b.current?.click(),children:"Take a photo"}):null]}):null,(0,t.jsxs)("span",{style:P,"data-graview-file-takes":"",children:["or drop or paste ",i?"them":"it"," here \xB7 ",s.kinds.length>0?ke(C.length>0?C:s.kinds):"any file",", up to ",_(s.maxBytes)]})]}):(0,t.jsx)("p",{style:{...P,margin:0},"data-graview-file-none":"",children:ne?`This host doesn\u2019t take ${a?"videos":"pictures"}, so none can be added here.`:"This host doesn\u2019t take files, so none can be added here."}),(0,t.jsx)("p",{"aria-live":"polite",style:{...P,margin:0,minHeight:p||T?void 0:0},"data-graview-file-status":"",children:p??T??""}),te.length>0?(0,t.jsx)("div",{role:"alert","data-graview-file-refused":"",style:{color:"var(--graview-warn)",fontSize:"0.875rem",display:"grid",gap:2},children:te.map((o,g)=>(0,t.jsx)("p",{style:{margin:0},children:o},g))}):null]})}var ve=(e,n)=>{let{caption:i,...r}=e;return n?{...r,caption:n}:r};function we({file:e,onCaption:n}){let[i,r]=(0,h.useState)(e.caption??"");(0,h.useEffect)(()=>r(e.caption??""),[e.caption]);let a=()=>{let l=i.trim().slice(0,500);l!==(e.caption??"")&&n(l)};return(0,t.jsx)("input",{type:"text",value:i,placeholder:E(e)||x(e)?"What it shows":"What it is","aria-label":`What ${e.name} ${E(e)||x(e)?"shows":"is"}`,"data-graview-file-caption":e.href,onChange:l=>r(l.target.value),onBlur:a,onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),a())},style:{flex:"1 1 10rem",minWidth:0,font:"inherit",fontSize:"0.875rem",minHeight:24}})}function Ee({field:e,label:n,labelStyle:i,valueStyle:r,style:a,children:l}){return(0,t.jsxs)("div",{"data-graview-files":e,style:{display:"grid",gap:6,minWidth:0,gridColumn:"1 / -1",...a},children:[(0,t.jsx)("dt",{style:i,children:n}),(0,t.jsx)("dd",{style:{margin:0,minWidth:0,display:"grid",gap:10,...r},children:l})]})}function Ce(e){let{nodeId:n,field:i,label:r,files:a}=e,{fields:l,commit:u}=me(n),s=l.find(p=>p.field===i&&p.takesValue),y=s?.shape,c=y?.type==="several"?y.of:y,b=y?.type==="several";return a.length===0&&c?.type!=="file"?null:(0,t.jsxs)(Ee,{...e,children:[(0,t.jsx)(X,{files:a,label:r}),s&&c?.type==="file"?(0,t.jsx)(Se,{value:a,thumbs:!1,several:b,image:c.image===!0,video:c.video===!0,label:r,onChange:p=>{let d=b?p:p[p.length-1];d!==void 0&&u(s,d)}}):null]})}function et(e){switch(e.as){case"field":return e.read?e.files.length>0?(0,t.jsx)(Ee,{...e,children:(0,t.jsx)(X,{files:e.files,label:e.label})}):null:(0,t.jsx)(Ce,{...e});case"unfilled":return(0,t.jsx)(Ye,{...e});case"thumb":return(0,t.jsx)(Q,{...e});case"block":return e.files.length>0?(0,t.jsx)("span",{className:"graview-spec-image","data-graview-field":e.field,"data-graview-image":e.view,style:{display:"block",minWidth:0,...e.view==="gallery"?{position:"relative",zIndex:de.raised}:{}},children:e.view==="thumb"?(0,t.jsx)(Q,{file:e.files[0],size:72}):(0,t.jsx)(X,{files:e.files,label:e.label})}):null;case"control":{let n=(0,t.jsx)(Se,{value:Y(e.value),several:e.several,image:e.image,video:e.video===!0,label:e.label,onChange:i=>e.onChange(e.several?i:i[i.length-1])});return e.title===void 0?n:(0,t.jsxs)("fieldset",{"data-graview-part":"group","data-graview-field":e.several?"files":"file",children:[(0,t.jsx)("legend",{"data-graview-part":"label",children:e.title}),n]})}}}function Ye({nodeId:e,skip:n,labels:i,labelStyle:r,style:a}){let{store:l}=ge(),u=he(e),s=u?l.schema.tryDefinition(u.kind):void 0,y=pe(s).filter(c=>!n.includes(c)&&!(s?.display?.hide??[]).includes(c)&&Y(u?.[c]).length===0);return y.length===0?null:(0,t.jsx)("dl",{style:{margin:0,display:"grid",gap:14,minWidth:0},children:y.map(c=>(0,t.jsx)(Ce,{nodeId:e,field:c,label:i?.[c]??oe(s,c),files:[],...r?{labelStyle:r}:{},...a?{style:a}:{}},c))})}export{Se as FilesEditor,Ve as SEND_EDGE,et as drawFiles,ke as kindsWords,je as prepare,_e as send,_ as sizeWords,Fe as takes,z as typeWords};
@@ -0,0 +1 @@
1
+ import{a as N,b as T}from"./chunk.25VJPUDH.js";import{e as D,f as E,g as R}from"./chunk.AKVBU5K5.js";import{b as I}from"./chunk.LLOZKUCA.js";import"./chunk.DH7M57SE.js";import{d as z}from"./chunk.CKV2QCH5.js";import"./chunk.TAJ2R44N.js";import{a as C}from"./chunk.V3NPUAPB.js";import"./chunk.XJFAUOJS.js";import"./chunk.DPPT6WAJ.js";import"./chunk.7U2JO7ET.js";import{j as f}from"./chunk.HFVMGTNL.js";import"./chunk.7Z4USR3Y.js";import{G as M,Ra as W,T as k,Va as A,ba as b,da as H}from"./chunk.NPAWTPLQ.js";import"./chunk.SDO3U72B.js";import{_a as x}from"./chunk.YEJ4LNUP.js";import"./chunk.FQLNBIQ5.js";import{b as v}from"./chunk.AJZBJBMO.js";var n=v(M(),1);var e=v(k(),1);function O(t,o){let r=[t>0?`${t===1?"one suggestion":`${t} suggestions`} waiting`:"",o>0?`tidied ${o===1?"one thing":`${o} things`} while you were away`:""].filter(Boolean);return r.length>0?r.join(" \xB7 ").replace(/^./,s=>s.toUpperCase()):void 0}function F(){let{store:t,principal:o,dismissals:r,whileAway:s,app:u}=b(),h=H(),l=(0,n.useMemo)(()=>T(r,u?.name??"app",o),[r,u?.name,o]),[m,y]=(0,n.useReducer)(g=>g+1,0);(0,n.useEffect)(()=>l.onChange?.(y),[l]);let a=(0,n.useMemo)(()=>D(t,o,{dismissed:l.list()}),[t,o,h,l,m]),[w,p]=(0,n.useState)(""),i=A("suggested"),d=s?.tidied??0,c=s?O(a.length,d):void 0;if(a.length===0&&d===0)return null;let L=g=>{if(p(g),a.length>1){requestAnimationFrame(()=>document.querySelector('[data-testid="suggested"] [data-testid="suggestion-accept"]')?.focus());return}i.setOpen(!1),(document.querySelector('[data-testid="activity-button"]')??document.querySelector('[data-graview-app-bar] button:not([data-testid="suggested-button"])'))?.focus()};return(0,e.jsxs)("div",{style:{position:"relative"},children:[(0,e.jsxs)("button",{type:"button","data-testid":"suggested-button",...i.trigger,onClick:i.toggle,title:c??"What tidying suggests, waiting for you",...c?{"aria-label":`Suggested: ${c}`}:{},style:{display:"inline-flex",alignItems:"center",gap:6,minHeight:30,padding:"0 8px",borderRadius:8,border:"1px solid transparent",background:"transparent",boxShadow:"none",fontSize:"0.875rem",whiteSpace:"nowrap",color:"var(--graview-ink-muted)"},children:[a.length>0?a.length:`Tidied ${d}`,(0,e.jsxs)("svg",{className:"graview-activity-mark",width:"15",height:"15",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",style:{display:"var(--graview-activity-mark, none)"},children:[(0,e.jsx)("path",{d:"M3 4.5 H13 M3 8 H10 M3 11.5 H8",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),(0,e.jsx)("circle",{cx:"12.25",cy:"11.5",r:"1.6",fill:"none",stroke:"currentColor",strokeWidth:"1.3"})]}),a.length>0?(0,e.jsx)("span",{className:"graview-activity-word",children:" Suggested"}):null]}),i.open?(0,e.jsxs)("section",{...i.pane,"aria-label":"Suggested","data-testid":"suggested","data-graview-offstage":"",style:{...W,width:"min(320px, calc(100vw - 16px))",maxHeight:"min(52cqh, 460px)",overflowX:"hidden",overflowY:"auto",display:"flex",flexDirection:"column",gap:9,padding:12,borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)"},children:[(0,e.jsx)("h2",{style:{...f,margin:0},children:"Suggested"}),c?(0,e.jsxs)("p",{"data-testid":"while-away",style:{margin:0,fontSize:"0.8125rem",lineHeight:1.45,color:"var(--graview-ink-muted)"},children:[c,"."]}):null,(0,e.jsx)("p",{style:{margin:0,fontSize:"0.75rem",lineHeight:1.45,color:"var(--graview-ink-faint)"},children:a.length>0?"Not made yet: each waits for you.":"What it did is in Activity."}),(0,e.jsx)("ol",{"data-testid":"suggestions",style:{margin:0,padding:0,listStyle:"none",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:10,fontSize:"0.8125rem",minWidth:0},children:a.map(g=>(0,e.jsx)(q,{suggestion:g,notNow:l,settled:L},g.id))}),(0,e.jsx)("span",{role:"status","data-testid":"suggestion-heard",style:f,children:w})]}):null]})}var S={minWidth:0,overflowWrap:"anywhere"},$={accept:"Accepted.",decline:"Declined: it will not be suggested again.",later:"Hidden from you until tomorrow."};function q({suggestion:t,notNow:o,settled:r}){let{store:s,principal:u,seats:h,people:l}=b(),[m,y]=(0,n.useState)(null),a=(0,n.useId)(),w=x(t.author,{graph:s.graph,schema:s.schema,seats:h,people:l}),p=async i=>{y(null);try{i==="accept"?E(s,t.id,{author:u}):i==="decline"?R(s,t.id,{author:u}):await o.dismiss({suggestion:t.id,at:new Date().toISOString(),until:N()}),r($[i])}catch(d){y(d instanceof Error?d.message:String(d))}};return(0,e.jsxs)("li",{"data-testid":"suggestion","data-suggestion":t.id,style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:5,lineHeight:1.45,minWidth:0},children:[(0,e.jsxs)("span",{"data-graview-suggestion-words":"",style:S,children:[(0,e.jsx)("strong",{style:{fontWeight:600},children:w})," ",(0,e.jsx)("span",{style:{color:"var(--graview-ink-muted)"},children:"suggests"})," ",t.intent]}),t.lineage?(0,e.jsx)("span",{"data-graview-lineage":"",style:{...S,color:"var(--graview-ink-faint)"},children:C(t.lineage)}):null,t.about.length>0?(0,e.jsx)("div",{"data-graview-suggestion-records":"",style:{display:"flex",flexWrap:"wrap",gap:4,minWidth:0},children:t.about.slice(0,4).map(i=>(0,e.jsx)(z,{label:I(s,i),pickId:i},i))}):null,(0,e.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:6,minWidth:0},children:[(0,e.jsx)("button",{type:"button","data-testid":"suggestion-accept",onClick:()=>void p("accept"),style:{minHeight:24,padding:"1px 10px",fontSize:"0.75rem"},children:"Accept"}),(0,e.jsx)("button",{type:"button","data-testid":"suggestion-decline",onClick:()=>void p("decline"),style:{minHeight:24,padding:"1px 10px",fontSize:"0.75rem"},children:"Decline"}),(0,e.jsx)("button",{type:"button","data-testid":"suggestion-not-now",onClick:()=>void p("later"),title:"Hide it from you until tomorrow. It still waits for everyone else.","aria-describedby":a,style:{minHeight:24,padding:"1px 10px",fontSize:"0.75rem",marginInlineStart:"auto",border:"1px solid transparent",background:"transparent",boxShadow:"none",color:"var(--graview-ink-muted)"},children:"Not now"}),(0,e.jsx)("span",{id:a,style:f,children:"Hides it from you until tomorrow; it still waits for everyone else."})]}),m?(0,e.jsx)("span",{"data-testid":"suggestion-refused",role:"alert",style:{...S,fontSize:"0.75rem",color:"var(--graview-warn)"},children:m}):null]})}export{F as SuggestedTray,O as awayWords};
@@ -1,4 +1,4 @@
1
- import{Pc as e}from"./chunk.3MZIWKNG.js";var i=`
1
+ import{Uc as e}from"./chunk.YEJ4LNUP.js";var i=`
2
2
  .graview-spec{display:flex;flex-direction:column;gap:6px;min-width:0;color:var(--graview-ink)}
3
3
 
4
4
  .graview-spec-row{flex-direction:row;flex-wrap:wrap;align-items:center;gap:4px 10px;box-sizing:border-box;max-width:100%;padding:5px 10px;border:1px solid var(--graview-edge);border-radius:var(--graview-radius-sm,8px);background:var(--graview-panel);font-size:.875rem}
@@ -0,0 +1 @@
1
+ import{a,b}from"./chunk.AQCU6TPV.js";import"./chunk.6Q6BW4QT.js";import"./chunk.DTSTUC2W.js";import"./chunk.RDL6652E.js";import"./chunk.V3NPUAPB.js";import"./chunk.IT763BYH.js";import"./chunk.T2RME6XF.js";import"./chunk.SOTB6C5A.js";import"./chunk.TQCRFZ53.js";import"./chunk.6HLKAUWF.js";import"./chunk.FCUDBMGC.js";import"./chunk.KMEKMCKG.js";import"./chunk.XJFAUOJS.js";import"./chunk.DPPT6WAJ.js";import"./chunk.7U2JO7ET.js";import"./chunk.YEJ4LNUP.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";export{b as actOnSeveral,a as actsForSeveral};
@@ -0,0 +1 @@
1
+ import{a as Y,b as _,c as D,e as R,h as H,i as q,j as S,k as N,l as x,n as P,o as V}from"./chunk.7RJGEU3Y.js";import{b as U}from"./chunk.DPPT6WAJ.js";import{G as T,K as j,Q as A,Ya as F,Z as W,bb as I,da as k,ga as B}from"./chunk.YEJ4LNUP.js";function te(e,r){return e===void 0||e===!0?!0:e===!1?!1:e[r]!==!1}function ne(e){let r={};return e.query&&e.query.trim().length>0&&(r.q=e.query),e.archived!==void 0&&e.archived!==!1&&(r.archived=String(e.archived)),e.sort&&(r.sort=e.sort.direction==="desc"?`${e.sort.by}:desc`:e.sort.by),e.filter?.length&&(r.filter=e.filter.map(n=>`${n.key}:${n.value}`).join(",")),e.group&&(r.group=e.group.bucket?`${e.group.by}:${e.group.bucket}`:e.group.by),r}function oe(e,r){let n=[],d={};if(e.query&&(d.query=e.query),e.archived!==void 0&&e.archived!==!1&&(d.archived=e.archived),e.sort&&(r.sorts.some(u=>u.key===e.sort.by)?d.sort=e.sort:n.push(`sort ${e.sort.by}`)),e.filter){let u=e.filter.filter(c=>r.filters.find(a=>a.key===c.key)?!0:(n.push(`filter ${c.key}`),!1));u.length>0&&(d.filter=u)}return e.group&&(r.groups.some(u=>u.key===e.group.by)?d.group=e.group:n.push(`group ${e.group.by}`)),{arrangement:d,dropped:n}}function O(e,r){return B(e.schema.tryDefinition(r.kind),S(r))}var ie=(e,r)=>e==null?r==null?0:1:r==null?-1:typeof e=="number"&&typeof r=="number"?e-r:typeof e=="boolean"&&typeof r=="boolean"?e===r?0:e?1:-1:String(e).localeCompare(String(r),void 0,{numeric:!0,sensitivity:"base"});function se(e,r,n){if(n==="label")return O(e,r);let d=e.schema.tryDefinition(r.kind);return d&&n in(d.fields.shape??{})?F(q(r),n,e.today??j()):d?.computed?.[n]!==void 0?e.read?.(r,n):N(e.graph,r.id,n).map(c=>O(e,c)).sort()[0]}var de=/^(\d{4})-(\d{2})-(\d{2})/;function Z(e,r){if(T.test(e)){let[s,i]=[e.slice(0,4),e.slice(5,7)];return r==="year"?`${s}-01-01`:r==="decade"?`${String(Number(s)-Number(s)%10).padStart(4,"0")}-01-01`:r==="month"&&i?`${s}-${i}-01`:e}let n=de.exec(e);if(!n)return;let[,d,u,c]=n;if(r==="day")return`${d}-${u}-${c}`;if(r==="month")return`${d}-${u}-01`;if(r==="year")return`${d}-01-01`;if(r==="decade")return`${String(Number(d)-Number(d)%10).padStart(4,"0")}-01-01`;let f=new Date(Date.UTC(Number(d),Number(u)-1,Number(c))),a=(f.getUTCDay()+6)%7;return f.setUTCDate(f.getUTCDate()-a),f.toISOString().slice(0,10)}function ue(e,r){return T.test(e)?A(e):r==="month"?W(e):r==="week"?`Week of ${A(e)}`:r==="year"?e.slice(0,4):r==="decade"?`The ${e.slice(0,4)}s`:A(e)}function fe(e,r,n){return z(e,n)(r)}function z(e,r){let{words:n,conditions:d}=P(r);if(n.length===0&&d.length===0)return()=>!0;let u=new Map,c=f=>{let a=u.get(f);return a||(a=new Set(R(e.schema,f).filters.map(s=>s.key)),u.set(f,a)),a};return f=>{let a=c(f.kind),s=d.filter(i=>a.has(i.key));return s.every(i=>x(e,f,i))?n.length>0?V(e.schema.tryDefinition(f.kind),S(f),n,e.searchIn)!==void 0:s.length>0:!1}}function ae(e,r,n){let d=r.query?.trim(),u=r.archived===void 0?e:e.filter(t=>I(t,r.archived)),c=d?u.filter(z(n,d)):u,f=r.filter?.length?c.filter(t=>r.filter.every(l=>x(n,t,l))):[...c],a=[];for(let t=r.sort;t&&a.length<4;t=t.then)a.push(t);let s=a.length>0?f.map((t,l)=>({node:t,index:l,values:a.map(o=>se(n,t,o.by))})).sort((t,l)=>{for(let[o,p]of a.entries()){let[b,E]=[t.values[o],l.values[o]],G=ie(b,E),M=p.direction==="desc"&&G!==0&&b!==void 0&&E!==void 0?-G:G;if(M!==0)return M}return t.index-l.index}).map(t=>t.node):f,i=r.group;if(!i)return{nodes:s,groups:[{key:"",label:"",nodes:s}],grouped:!1};let y=new Map,g=(t,l,o)=>{let p=y.get(t)??{label:l,nodes:[]};p.nodes.push(o),y.set(t,p)},L=s[0],m=L?n.schema.tryDefinition(L.kind):void 0,w=m?.fields.shape??{},X=m?Y(m,i.by):k(i.by),$=i.by in w,h=$?_(w[i.by]):void 0,ee=D(n.schema,L?.kind??"").find(t=>t.key===i.by)?.label,v=$?`No ${X.toLowerCase()}`:`Without ${(ee??k(i.by)).toLowerCase()}`,K=$?new Map:U([...new Map(s.flatMap(t=>N(n.graph,t.id,i.by)).map(t=>[t.id,t])).values()].map(S),t=>n.schema.tryDefinition(t));for(let t of s){if($){let o=F(q(t),i.by,n.today??j());if(o==null||o==="")g("",v,t);else if(h==="date"){let p=i.bucket??"day",b=Z(String(o),p);b?g(b,ue(b,p),t):g("",v,t)}else if(h==="boolean")g(o?"1":"0",o?"Yes":"No",t);else{let p=m?.display?.format?.[i.by];g(String(o),p?p(o):h==="choice"?k(String(o)):String(o),t)}continue}let l=N(n.graph,t.id,i.by).map(o=>({id:o.id,label:K.has(o.id)?`${O(n,o)} \xB7 ${K.get(o.id)}`:O(n,o)})).sort((o,p)=>o.label.localeCompare(p.label));l.length===0?g("",v,t):g(l.map(o=>o.id).join(","),l.map(o=>o.label).join(", "),t)}let C=h==="choice"?H(w[i.by]):void 0,re=[...y.entries()].sort(([t,l],[o,p])=>t===""?1:o===""?-1:C?C.indexOf(t)-C.indexOf(o):h==="boolean"?o.localeCompare(t):h==="date"?t.localeCompare(o):l.label.localeCompare(p.label)).map(([t,l])=>({key:t,label:l.label,nodes:l.nodes}));return{nodes:s,groups:re,grouped:!0}}function Q(e){if(e===void 0)return;if(typeof e=="string")return{by:e,direction:"asc"};let r=e.then===void 0?void 0:typeof e.then=="string"?{by:e.then,direction:"asc"}:{by:e.then.by,direction:e.then.direction??"asc"};return{by:e.by,direction:e.direction??"asc",...r?{then:r}:{}}}function J(e){if(e!==void 0)return typeof e=="string"?{by:e}:e}function le(e){let r=Q(e?.sort),n=J(e?.group);if(!(!r&&!n))return{...r?{sort:r}:{},...n?{group:{by:n.by}}:{}}}var ce=(e,r)=>r?e==="1"?"true":"false":e;function pe(e,r,n){let d=n.type==="boolean",u=d?["true","false"]:n.options??[],c=[...new Set([...(r.order??[]).filter(s=>u.includes(s)),...u])],f=r.closed??[],a=s=>{if(s.key==="")return[1,0];let i=ce(s.key,d);if(f.includes(i))return[2,f.indexOf(i)];let y=c.indexOf(i);return[0,y<0?c.length:y]};return e.map((s,i)=>({group:s,at:i,rank:a(s)})).sort((s,i)=>s.rank[0]-i.rank[0]||s.rank[1]-i.rank[1]||s.at-i.at).map(({group:s,rank:i})=>({...s,closed:i[0]===2}))}export{J as a,le as b,pe as c,te as d,ne as e,oe as f,fe as g,ae as h};
@@ -1 +1 @@
1
- import{fa as V,ga as w}from"./chunk.SF4BYBH6.js";import"./chunk.SDO3U72B.js";import{md as u,qd as h}from"./chunk.3MZIWKNG.js";import"./chunk.SLBWPVIY.js";import"./chunk.AJZBJBMO.js";var c=i=>[i,...u.filter(o=>o!==i)];function p(i,o){if(o.hidden.length===0&&o.removed.length===0)return i;let a=new Set(o.removed.filter(e=>!e.lens).map(e=>e.name)),f=new Set(o.hidden),r=e=>e?.name!==void 0&&(a.has(e.name)||e.title!==void 0&&f.has(e.name)),m=()=>(i.homes?.()??[]).filter(e=>e.name===void 0||!a.has(e.name)),l=(e,t,d)=>[...i.registrations()].reverse().find(n=>n.kind===e&&n.cardinality===t&&n.fidelity===d&&!n.beside&&!n.hidden&&!r(n)),y=(e,t)=>{for(let d of c(t.fidelity)){let n=l(e,t.cardinality,d);if(n)return n}if(t.cardinality==="one")for(let d of c(t.fidelity)){let n=l(e,"many",d);if(n)return n}},s={...i,register(e,t,d,n){return i.register(e,t,d,n),s},...i.home?{home(e,t){return i.home(e,t),s}}:{},...i.homes?{homes:m,homeView:()=>m().at(-1)?.view}:{},lookup(e,t){return i.lookup(e,t)===void 0?void 0:l(e,t.cardinality,t.fidelity)?.view},places:()=>i.places().filter(e=>!(e.name!==void 0&&a.has(e.name))).map(e=>e.name!==void 0&&f.has(e.name)&&!e.hidden?{...e,hidden:!0}:e),resolve(e,t,d){let n=i.resolve(e,t,d);return!n||!r(n)||d!==void 0&&n.name!==void 0&&!a.has(n.name)&&n.title!==void 0&&h(n.title)===d?n:y(e,t)},all:()=>i.all().filter(e=>!(e.name!==void 0&&a.has(e.name))),homes:()=>(i.homes?.()??[]).filter(e=>!(e.name!==void 0&&a.has(e.name))),homeView:()=>i.homes?s.homes().at(-1)?.view:i.homeView?.()};return V(i)&&w(s),s}function R(i,o,a){let f,r=()=>{let m=o.current();f&&m.hidden===f.hidden&&m.removed===f.removed||(f=m,a(p(i,m)))};return r(),o.onChange?.(r)??(()=>{})}export{p as tidyViews,R as watchTidied};
1
+ import{fa as V,ga as w}from"./chunk.NPAWTPLQ.js";import"./chunk.SDO3U72B.js";import{ud as u,yd as h}from"./chunk.YEJ4LNUP.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var c=i=>[i,...u.filter(o=>o!==i)];function p(i,o){if(o.hidden.length===0&&o.removed.length===0)return i;let a=new Set(o.removed.filter(e=>!e.lens).map(e=>e.name)),f=new Set(o.hidden),r=e=>e?.name!==void 0&&(a.has(e.name)||e.title!==void 0&&f.has(e.name)),m=()=>(i.homes?.()??[]).filter(e=>e.name===void 0||!a.has(e.name)),l=(e,t,d)=>[...i.registrations()].reverse().find(n=>n.kind===e&&n.cardinality===t&&n.fidelity===d&&!n.beside&&!n.hidden&&!r(n)),y=(e,t)=>{for(let d of c(t.fidelity)){let n=l(e,t.cardinality,d);if(n)return n}if(t.cardinality==="one")for(let d of c(t.fidelity)){let n=l(e,"many",d);if(n)return n}},s={...i,register(e,t,d,n){return i.register(e,t,d,n),s},...i.home?{home(e,t){return i.home(e,t),s}}:{},...i.homes?{homes:m,homeView:()=>m().at(-1)?.view}:{},lookup(e,t){return i.lookup(e,t)===void 0?void 0:l(e,t.cardinality,t.fidelity)?.view},places:()=>i.places().filter(e=>!(e.name!==void 0&&a.has(e.name))).map(e=>e.name!==void 0&&f.has(e.name)&&!e.hidden?{...e,hidden:!0}:e),resolve(e,t,d){let n=i.resolve(e,t,d);return!n||!r(n)||d!==void 0&&n.name!==void 0&&!a.has(n.name)&&n.title!==void 0&&h(n.title)===d?n:y(e,t)},all:()=>i.all().filter(e=>!(e.name!==void 0&&a.has(e.name))),homes:()=>(i.homes?.()??[]).filter(e=>!(e.name!==void 0&&a.has(e.name))),homeView:()=>i.homes?s.homes().at(-1)?.view:i.homeView?.()};return V(i)&&w(s),s}function R(i,o,a){let f,r=()=>{let m=o.current();f&&m.hidden===f.hidden&&m.removed===f.removed||(f=m,a(p(i,m)))};return r(),o.onChange?.(r)??(()=>{})}export{p as tidyViews,R as watchTidied};