graview 0.1.45 → 0.1.47

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 (145) hide show
  1. package/dist/preview/{chunk.L2PI7V4R.js → chunk.24OZGU7J.js} +1 -1
  2. package/dist/preview/{chunk.EVW5YY3W.js → chunk.2CLANQHZ.js} +1 -1
  3. package/dist/preview/{chunk.URXSZQSF.js → chunk.2L3VFGHX.js} +1 -1
  4. package/dist/preview/chunk.2MCZ4CU5.js +1 -0
  5. package/dist/preview/{chunk.R2AG4NHQ.js → chunk.2W22AWSL.js} +1 -1
  6. package/dist/preview/chunk.3LDYUO77.js +1 -0
  7. package/dist/preview/{chunk.JR7RDOEP.js → chunk.47RTA6M3.js} +1 -1
  8. package/dist/preview/chunk.4OGOTHRD.js +1 -0
  9. package/dist/preview/{chunk.WPOTEXJZ.js → chunk.4YS7547F.js} +1 -1
  10. package/dist/preview/{chunk.6X3G3PWL.js → chunk.4YXJPKXD.js} +1 -1
  11. package/dist/preview/{chunk.UNCS63AM.js → chunk.52VGZBO3.js} +1 -1
  12. package/dist/preview/{chunk.PRD3UNJX.js → chunk.57ZSMK3R.js} +1 -1
  13. package/dist/preview/{chunk.6MADC6DM.js → chunk.5AGW4NRZ.js} +1 -1
  14. package/dist/preview/chunk.5G53VDOC.js +1 -0
  15. package/dist/preview/chunk.5M4TMZXC.js +1 -0
  16. package/dist/preview/{chunk.GEPNIMXW.js → chunk.5TM5VA2H.js} +1 -1
  17. package/dist/preview/{chunk.Y5ARSVH4.js → chunk.63MS2LOP.js} +1 -1
  18. package/dist/preview/{chunk.HGTPTRMM.js → chunk.6QVXXQCW.js} +1 -1
  19. package/dist/preview/{chunk.UM7GWXEW.js → chunk.6TIEX67B.js} +1 -1
  20. package/dist/preview/chunk.6YD2DLIC.js +1 -0
  21. package/dist/preview/chunk.76GF5US2.js +50 -0
  22. package/dist/preview/{chunk.55D33E5A.js → chunk.7ELB37JU.js} +1 -1
  23. package/dist/preview/chunk.7N2GXZYI.js +3 -0
  24. package/dist/preview/{chunk.EAUVEVVO.js → chunk.7NNI7YH4.js} +1 -1
  25. package/dist/preview/{chunk.KUUDW7VR.js → chunk.A3RNSSUQ.js} +1 -1
  26. package/dist/preview/{chunk.W44VRHKS.js → chunk.A7RKTSOH.js} +2 -2
  27. package/dist/preview/{chunk.CBUSFM3E.js → chunk.AGIO2GRV.js} +29 -7
  28. package/dist/preview/{chunk.QPCSS322.js → chunk.AWXDZUKH.js} +1 -1
  29. package/dist/preview/{chunk.5EDA3JHU.js → chunk.AYA7SYIU.js} +1 -1
  30. package/dist/preview/{chunk.T7XH7FVJ.js → chunk.BBS5C2BY.js} +1 -1
  31. package/dist/preview/{chunk.L3FOLN3K.js → chunk.C3NHNYA6.js} +1 -1
  32. package/dist/preview/{chunk.S5MQVPLF.js → chunk.C44MC5X3.js} +1 -1
  33. package/dist/preview/{chunk.L3FQZCWI.js → chunk.CMOXKRWT.js} +1 -1
  34. package/dist/preview/{chunk.7ZRFXI73.js → chunk.COYLGLTI.js} +1 -1
  35. package/dist/preview/{chunk.UY7IOVR6.js → chunk.CTQULC5F.js} +1 -1
  36. package/dist/preview/{chunk.5B2LH2SR.js → chunk.DNROW6LX.js} +1 -1
  37. package/dist/preview/{chunk.JLEC3USG.js → chunk.DQS7D2W2.js} +1 -1
  38. package/dist/preview/{chunk.ZBR2QY67.js → chunk.ETPKXUAN.js} +1 -1
  39. package/dist/preview/{chunk.XXEYRHRG.js → chunk.ETR6AV47.js} +1 -1
  40. package/dist/preview/{chunk.FPASZ4RD.js → chunk.EUPSAYEI.js} +1 -1
  41. package/dist/preview/{chunk.6SJA4FSW.js → chunk.EYI3Y2DY.js} +1 -1
  42. package/dist/preview/chunk.F2VMMCVK.js +1 -0
  43. package/dist/preview/{chunk.SDU76JU6.js → chunk.F67F6QZ6.js} +1 -1
  44. package/dist/preview/chunk.FOJDVK2Q.js +1 -0
  45. package/dist/preview/{chunk.VC3BX2ZF.js → chunk.FOQ27RAR.js} +1 -1
  46. package/dist/preview/{chunk.LSLLKICK.js → chunk.FWSCBHZ5.js} +1 -1
  47. package/dist/preview/chunk.G446PWV6.js +1 -0
  48. package/dist/preview/{chunk.RYRTKIKB.js → chunk.GCKZ2YRJ.js} +2 -2
  49. package/dist/preview/{chunk.66JF3UMG.js → chunk.GQHAAKJG.js} +1 -1
  50. package/dist/preview/chunk.I6JLOEJU.js +1 -0
  51. package/dist/preview/chunk.IJNOT4S4.js +4 -0
  52. package/dist/preview/chunk.IPAZOKMQ.js +1 -0
  53. package/dist/preview/{chunk.JDMXZFSG.js → chunk.IQ2HKGJS.js} +1 -1
  54. package/dist/preview/{chunk.DQHPEKWK.js → chunk.IROYMLER.js} +1 -1
  55. package/dist/preview/chunk.ISNEX772.js +1 -0
  56. package/dist/preview/{chunk.3NMINX5Z.js → chunk.IXOQQBJE.js} +1 -1
  57. package/dist/preview/{chunk.DLFWBG33.js → chunk.IYIN6VSN.js} +1 -1
  58. package/dist/preview/chunk.JUWWRRHA.js +1 -0
  59. package/dist/preview/{chunk.GER2XRD4.js → chunk.K2NCGPCL.js} +1 -1
  60. package/dist/preview/{chunk.4KNEBLB7.js → chunk.KSM6NVAT.js} +1 -1
  61. package/dist/preview/{chunk.OF34OZ4V.js → chunk.KSXB4LDF.js} +1 -1
  62. package/dist/preview/{chunk.4XOWRYRU.js → chunk.L4YNDNX7.js} +6 -6
  63. package/dist/preview/{chunk.E4G6DXSB.js → chunk.MBETS27C.js} +1 -1
  64. package/dist/preview/{chunk.FOFLD64U.js → chunk.MCB26YCQ.js} +1 -1
  65. package/dist/preview/chunk.MCCUVGTE.js +1 -0
  66. package/dist/preview/{chunk.ZJ2VS4M4.js → chunk.MF73YBJL.js} +1 -1
  67. package/dist/preview/{chunk.ZEAH57AZ.js → chunk.N7JT6MG2.js} +1 -1
  68. package/dist/preview/{chunk.SGKPGVBB.js → chunk.NDWW5EER.js} +1 -1
  69. package/dist/preview/{chunk.VSAPJAT3.js → chunk.NEEOVRB7.js} +1 -1
  70. package/dist/preview/{chunk.NMIXBH37.js → chunk.NFIGGSMJ.js} +1 -1
  71. package/dist/preview/{chunk.JBW3DI7E.js → chunk.O2WWYZI7.js} +1 -1
  72. package/dist/preview/{chunk.6BJBPDF3.js → chunk.O4WEJ47H.js} +14 -4
  73. package/dist/preview/{chunk.ICGNIK3Z.js → chunk.OCTOGZVJ.js} +2 -2
  74. package/dist/preview/{chunk.FTM64IDI.js → chunk.OJGUIWDD.js} +1 -1
  75. package/dist/preview/{chunk.GIYFEGAP.js → chunk.OONCUAOH.js} +1 -1
  76. package/dist/preview/{chunk.3HSPWSAI.js → chunk.P4KCZRIG.js} +1 -1
  77. package/dist/preview/{chunk.W2RCWPLK.js → chunk.PBKO5CKD.js} +1 -1
  78. package/dist/preview/{chunk.JSSFA3FC.js → chunk.PC6PID5X.js} +1 -1
  79. package/dist/preview/{chunk.JLYNMAME.js → chunk.PYE3WZM7.js} +1 -1
  80. package/dist/preview/{chunk.BS2SJC2P.js → chunk.QGG6ZRJ5.js} +2 -2
  81. package/dist/preview/{chunk.LEO2KWLZ.js → chunk.QZEZHCOI.js} +1 -1
  82. package/dist/preview/{chunk.DQOCBKC3.js → chunk.R6V37SR7.js} +1 -1
  83. package/dist/preview/{chunk.FF6DBQMB.js → chunk.RBJAPOZ3.js} +1 -1
  84. package/dist/preview/{chunk.TBSNNOQU.js → chunk.RG6WNOBW.js} +1 -1
  85. package/dist/preview/{chunk.5O5IJVLN.js → chunk.RUPRZDN3.js} +1 -1
  86. package/dist/preview/{chunk.S6WHA4CW.js → chunk.RVJXO5GG.js} +1 -1
  87. package/dist/preview/chunk.RX2M4C5W.js +2 -0
  88. package/dist/preview/{chunk.KBHU54NM.js → chunk.RZF3QM4E.js} +1 -1
  89. package/dist/preview/{chunk.7KVWV577.js → chunk.S5IQFZ5Z.js} +1 -1
  90. package/dist/preview/{chunk.2EFH63WS.js → chunk.SD6N4DGF.js} +1 -1
  91. package/dist/preview/{chunk.RPX35VYU.js → chunk.SGKK4UKP.js} +1 -1
  92. package/dist/preview/{chunk.V5FIZIX2.js → chunk.SWWAEOZ7.js} +1 -1
  93. package/dist/preview/chunk.SZR3Z43B.js +1 -0
  94. package/dist/preview/{chunk.ICCIZDTQ.js → chunk.T42S2WMB.js} +1 -1
  95. package/dist/preview/chunk.T7RJCEJB.js +18 -0
  96. package/dist/preview/{chunk.2YABX3SC.js → chunk.TCXKPILZ.js} +1 -1
  97. package/dist/preview/{chunk.TOXWNEOQ.js → chunk.TJEV5ZAM.js} +3 -3
  98. package/dist/preview/{chunk.LNG3CQNI.js → chunk.UV3YU64Z.js} +1 -1
  99. package/dist/preview/{chunk.UJKT2G6M.js → chunk.V7XHNRQM.js} +2 -2
  100. package/dist/preview/{chunk.FCAYURB4.js → chunk.VAFSSSSI.js} +1 -1
  101. package/dist/preview/{chunk.M5GJHVWZ.js → chunk.VC3UGFHY.js} +1 -1
  102. package/dist/preview/{chunk.NIVTK2W5.js → chunk.VSNHCGKC.js} +1 -1
  103. package/dist/preview/{chunk.XMCFZD3A.js → chunk.VXVWUIGO.js} +1 -1
  104. package/dist/preview/chunk.W6COSBO2.js +21 -0
  105. package/dist/preview/{chunk.E37V2EJM.js → chunk.WHEUTAXA.js} +1 -1
  106. package/dist/preview/{chunk.HWCHFQ7O.js → chunk.WJS6P7GI.js} +1 -1
  107. package/dist/preview/chunk.X5G7FOPY.js +12 -0
  108. package/dist/preview/{chunk.BGYY55VO.js → chunk.XYEFZ2OO.js} +1 -1
  109. package/dist/preview/chunk.Y4ZUJUUT.js +25 -0
  110. package/dist/preview/chunk.YHH4TWZ2.js +1 -0
  111. package/dist/preview/{chunk.4RJZVTW7.js → chunk.YVONXFKE.js} +1 -1
  112. package/dist/preview/{chunk.5R2R364Q.js → chunk.Z4UM4CMT.js} +1 -1
  113. package/dist/preview/{chunk.4HYJHGI4.js → chunk.ZCYGUP3I.js} +1 -1
  114. package/dist/preview/chunk.ZIEHF67C.js +1 -0
  115. package/dist/preview/{chunk.II7VTGNC.js → chunk.ZL7ZBJUU.js} +1 -1
  116. package/dist/preview/{chunk.FHZBXMXR.js → chunk.ZQY6ODXC.js} +1 -1
  117. package/dist/preview/{chunk.6KWFTSK4.js → chunk.ZWVN75EY.js} +1 -1
  118. package/dist/preview/index.html +36 -36
  119. package/dist/preview/page.js +2 -2
  120. package/package.json +6 -6
  121. package/dist/preview/chunk.2JJYGYT2.js +0 -1
  122. package/dist/preview/chunk.2LKMNEWZ.js +0 -1
  123. package/dist/preview/chunk.6SWW6KEV.js +0 -1
  124. package/dist/preview/chunk.6UIW664O.js +0 -6
  125. package/dist/preview/chunk.6USUVORO.js +0 -1
  126. package/dist/preview/chunk.B6KT6BTG.js +0 -49
  127. package/dist/preview/chunk.C2UFMFJ3.js +0 -3
  128. package/dist/preview/chunk.CSDERNQV.js +0 -1
  129. package/dist/preview/chunk.F6HMZL65.js +0 -1
  130. package/dist/preview/chunk.GFLAGZSB.js +0 -1
  131. package/dist/preview/chunk.GVY5UQTJ.js +0 -1
  132. package/dist/preview/chunk.HZGVEHEN.js +0 -1
  133. package/dist/preview/chunk.J7G3AATY.js +0 -14
  134. package/dist/preview/chunk.JHIUG25Q.js +0 -1
  135. package/dist/preview/chunk.K46YRA65.js +0 -1
  136. package/dist/preview/chunk.K6KMLD2B.js +0 -21
  137. package/dist/preview/chunk.L24FCXZ7.js +0 -1
  138. package/dist/preview/chunk.MGWMGLWE.js +0 -1
  139. package/dist/preview/chunk.OMZ3LDDN.js +0 -1
  140. package/dist/preview/chunk.OYHQSXNC.js +0 -1
  141. package/dist/preview/chunk.SZ34UAQ3.js +0 -2
  142. package/dist/preview/chunk.WM2LWHTJ.js +0 -1
  143. package/dist/preview/chunk.WSTBCWW7.js +0 -4
  144. package/dist/preview/chunk.XWAMQPUM.js +0 -25
  145. package/dist/preview/chunk.ZTIF23VF.js +0 -1
@@ -1 +1 @@
1
- import{a as xe}from"./chunk.HJCQ6I3S.js";import{a as je,b as Ee,c as Ie,d as Re}from"./chunk.BNPQUI3F.js";import"./chunk.TKUNRFDE.js";import{c as he}from"./chunk.6RY6OSE6.js";import"./chunk.HDRD33II.js";import"./chunk.DX357TZ3.js";import"./chunk.H7KCWCB4.js";import{G as Ke,R as Pe}from"./chunk.XWAMQPUM.js";import"./chunk.SDO3U72B.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import{b as pe}from"./chunk.AJZBJBMO.js";var P=pe(Ke(),1);var E=.5,fe=1,ye=.76,Le=3,We=3,Ae=.6;function Oe(c){let{ribbons:m,plots:u,cell:i}=c,a=c.tilt??.5,g=c.labels??[],b=[...u.values()],k=new Map;if(b.length===0||i<=0)return k;let L=Math.min(...b.map(n=>n.col))-3,A=Math.min(...b.map(n=>n.row))-3,G=Math.max(...b.map(n=>n.col+n.side))+3,ce=Math.max(...b.map(n=>n.row+n.side))+3,h=Math.round((G-L)/E)+1,p=Math.round((ce-A)/E)+1,N=n=>L+n*E,B=n=>A+n*E,I=4,_=!0,C=(n,e)=>{if(!_)return!1;let t=he(n,e,i,a);return g.some(s=>t.x>s.x-I&&t.x<s.x+s.width+I&&t.y>s.y-I&&t.y<s.y+s.height+I)},H=(n,e)=>b.some(t=>n>t.col-ye&&n<t.col+t.side+ye&&e>t.row-ye&&e<t.row+t.side+ye),F=new Uint8Array(h*p),J=new Uint8Array(h*p);for(let n=0;n<h;n++)for(let e=0;e<p;e++){let t=N(n),s=B(e);J[e*h+n]=H(t,s)?0:1,F[e*h+n]=J[e*h+n]&&!C(t,s)?1:0}let Q=F,se=new Float32Array(h*p);for(let n=0;n<h;n++)for(let e=0;e<p;e++){let t=N(n),s=B(e);se[e*h+n]=Math.min(...b.map(o=>Math.max(0,o.col-t,t-(o.col+o.side),o.row-s,s-(o.row+o.side))))}let Z=(n,e,t,s)=>{let o=N(n)+t*E/2,l=B(e)+s*E/2;return!H(o,l)&&!C(o,l)},ue=n=>{let e=[],t=(o,l)=>{let w=[],d=Math.min(1,l/3);for(let y=Math.ceil((o+d)/E-1e-9)*E;y<=o+l-d+1e-9;y+=E)w.push(y);return w},s=(o,l,w,d)=>{let y=Math.round((o-L)/E),r=Math.round((l-A)/E);y>=0&&r>=0&&y<h&&r<p&&Q[r*h+y]&&e.push({i:y,j:r,out:w,curb:d})};for(let o of t(n.row,n.side))s(n.col-fe,o,1,{col:n.col,row:o}),s(n.col+n.side+fe,o,0,{col:n.col+n.side,row:o});for(let o of t(n.col,n.side))s(o,n.row-fe,3,{col:o,row:n.row}),s(o,n.row+n.side+fe,2,{col:o,row:n.row+n.side});return e},ee=new Map,V=(n,e,t,s)=>n<t||n===t&&e<s?`${n},${e}-${t},${s}`:`${t},${s}-${n},${e}`,de=[[1,0],[-1,0],[0,1],[0,-1]],X=new Map;for(let n of m){let e=u.get(n.from),t=u.get(n.to);if(!e||!t||e===t)continue;let s=-1,o=[],l=new Map,w=new Int32Array(0),d=1/0,y=[];for(let f of[!0,!1]){s=-1,d=1/0,_=f,Q=f?F:J,o=ue(e);let W=ue(t);if(o.length===0||W.length===0){y.push({reached:-1,starts:o,goal:l,back:w,best:d});continue}l=new Map(W.map(j=>[j.j*h+j.i,j]));let ne=(j,R)=>{let re=N(j),ae=B(R);return(Math.max(0,t.col-re,re-(t.col+t.side))+Math.max(0,t.row-ae,ae-(t.row+t.side)))*Ae},oe=h*p*4,ie=new Float64Array(oe).fill(1/0);w=new Int32Array(oe).fill(-1);let le=new ke;for(let j of o){let R=(j.j*h+j.i)*4+j.out;ie[R]=0,le.push(R,ne(j.i,j.j))}let Ce=[1,0,3,2];for(;le.size>0&&!(le.peekKey()>=d);){let R=le.pop(),re=Math.floor(R/4),ae=R%4,ge=re%h,we=Math.floor(re/h),ve=l.get(re);if(ve){let q=ie[R]+(ae===Ce[ve.out]?0:Le);q<d&&(d=q,s=R);continue}for(let q=0;q<4;q++){let[Me,$e]=de[q],U=ge+Me,z=we+$e;if(U<0||z<0||U>=h||z>=p||!Q[z*h+U]||!Z(ge,we,Me,$e))continue;let Te=E*(ee.has(V(ge,we,U,z))?Ae:1)*(1+Math.max(0,se[z*h+U]-We))+(q===ae?0:Le),me=(z*h+U)*4+q,be=ie[R]+Te;be<ie[me]&&(ie[me]=be,w[me]=R,le.push(me,be+ne(U,z)))}}y.push({reached:s,starts:o,goal:l,back:w,best:d})}_=!0,Q=F;let[r,v]=y,M=r&&r.reached!==-1&&(!v||v.reached===-1||r.best<=1.3*v.best+2)?r:v;if(!M||M.reached===-1)continue;({reached:s,starts:o,goal:l,back:w}=M);let x=[];for(let f=s;f!==-1;f=w[f]){let W=Math.floor(f/4),ne=x[x.length-1],oe={i:W%h,j:Math.floor(W/h)};(!ne||ne.i!==oe.i||ne.j!==oe.j)&&x.push(oe)}x.reverse();for(let f=1;f<x.length;f++){let W=V(x[f-1].i,x[f-1].j,x[f].i,x[f].j);ee.set(W,[...ee.get(W)??[],n.key])}let D=o.find(f=>f.i===x[0].i&&f.j===x[0].j),$=l.get(x[x.length-1].j*h+x[x.length-1].i);X.set(n.key,{cells:x,start:D.curb,end:$.curb})}let O=new Map(m.map(n=>[n.key,n.width])),T=new Map(m.map((n,e)=>[n.key,e])),te=i*a/Math.sqrt(1+a*a),Y=(n,e)=>n==="col"?`r${e.row.toFixed(2)}`:`c${e.col.toFixed(2)}`,K=new Map;for(let[n,e]of X)for(let t=1;t<e.cells.length;t++){let s=e.cells[t-1],o=e.cells[t],l=Y(s.i!==o.i?"col":"row",{col:N(s.i),row:B(s.j)});K.set(l,(K.get(l)??new Set).add(n))}for(let[n,e]of X){let t=[e.start,...e.cells.map(r=>({col:N(r.i),row:B(r.j)})),e.end],s=r=>r>=2&&r<=e.cells.length?V(e.cells[r-2].i,e.cells[r-2].j,e.cells[r-1].i,e.cells[r-1].j):null,o=[];for(let r=1;r<t.length;r++){let v=Math.abs(t[r].col-t[r-1].col)>1e-9?"col":"row",M=o[o.length-1];M&&M.axis===v?M.to=r:o.push({from:r-1,to:r,axis:v})}if(o.length===0)continue;let l=o.map(r=>{if(!Array.from({length:r.to-r.from},($,f)=>s(r.from+1+f)).some($=>$!==null))return 0;let v=K.get(Y(r.axis,t[r.from]))??new Set;if(!v.has(n))return 0;let M=[...v].sort(($,f)=>(T.get($)??0)-(T.get(f)??0)),D=-(M.reduce(($,f)=>$+(O.get(f)??2)+2,0)-2)/2;for(let $ of M){if($===n)return(D+(O.get($)??2)/2)/te;D+=(O.get($)??2)+2}return 0}),w=r=>{let v=o[r],M=t[v.from];return v.axis==="col"?{row:M.row+l[r]}:{col:M.col+l[r]}},d=(r,v,M)=>({col:r.col??v.col??M.col,row:r.row??v.row??M.row}),y=[d(w(0),{},t[0])];for(let r=0;r+1<o.length;r++)y.push(d(w(r),w(r+1),t[o[r].to]));y.push(d(w(o.length-1),{},t[t.length-1])),k.set(n,y.map(r=>he(r.col,r.row,i,a)))}return k}var ke=class{items=[];keys=[];get size(){return this.items.length}peekKey(){return this.keys[0]??1/0}push(m,u){this.items.push(m),this.keys.push(u);let i=this.items.length-1;for(;i>0;){let a=i-1>>1;if(this.keys[a]<=this.keys[i])break;this.swap(i,a),i=a}}pop(){let m=this.items[0],u=this.items.pop(),i=this.keys.pop();if(this.items.length>0){this.items[0]=u,this.keys[0]=i;let a=0;for(;;){let g=2*a+1,b=g+1,k=a;if(g<this.items.length&&this.keys[g]<this.keys[k]&&(k=g),b<this.items.length&&this.keys[b]<this.keys[k]&&(k=b),k===a)break;this.swap(a,k),a=k}}return m}swap(m,u){[this.items[m],this.items[u]]=[this.items[u],this.items[m]],[this.keys[m],this.keys[u]]=[this.keys[u],this.keys[m]]}};function Se(c,m){let u=c.col+c.side,i=u+.25+.22*Math.max(0,m),a=c.row+c.side*Math.max(.1,.3-.06*m),g=c.row+c.side*Math.min(.9,.7+.06*m);return[{col:u,row:a},{col:i,row:a},{col:i,row:g},{col:u,row:g}]}function Be(c,m){return c.map(u=>he(u.col,u.row,m.cell,m.tilt))}function Fe(c){return c.map((m,u)=>`${u===0?"M":"L"} ${m.x.toFixed(1)} ${m.y.toFixed(1)}`).join(" ")}function Ne(c){if(c.length===0)return{x:0,y:0};let m=0;for(let i=1;i<c.length;i++)m+=Math.hypot(c[i].x-c[i-1].x,c[i].y-c[i-1].y);let u=m/2;for(let i=1;i<c.length;i++){let a=c[i-1],g=c[i],b=Math.hypot(g.x-a.x,g.y-a.y);if(b>=u&&b>0)return{x:a.x+(g.x-a.x)*u/b,y:a.y+(g.y-a.y)*u/b};u-=b}return c[c.length-1]}var S=pe(Pe(),1);function Ue({frame:c,width:m,height:u,pan:i,store:a,graphVersion:g,selection:b,view:k,emphasis:L,hiddenKinds:A,drawn:G}){let[ce,h]=(0,P.useState)(null),p=c.city,N=e=>a.graph.getNode(e)?.kind,B=(0,P.useMemo)(()=>je(a.graph.allEdges(),e=>a.graph.getNode(e)?.kind),[a,g]),I=new Map;for(let e of c.nodes){let t=e.id.startsWith("kind:")?Ie(e.id):null;t!==null&&e.plot&&Math.round(e.plane)===2&&I.set(t,e.plot)}let _=[...I].map(([e,t])=>`${e}:${t.col},${t.row},${t.side}`).join(";"),C=p?.cell??0,H=B.filter(e=>I.has(e.from)&&I.has(e.to)&&!A.has(e.from)&&!A.has(e.to)&&G(e.edge)),F=p?.tilt??.5,[J,Q]=(0,P.useState)([]),se=J.map(e=>`${Math.round(e.x)},${Math.round(e.y)},${Math.round(e.width)},${Math.round(e.height)}`).join(";"),[Z,ue]=(0,P.useState)(null),ee=c.t>=1;(0,P.useLayoutEffect)(()=>{let e=Z?.parentElement;if(!e||!p||!ee)return;let t=e.getBoundingClientRect(),s=p.originX+i.x,o=p.originY+i.y,l=[...e.querySelectorAll('[data-graview-view^="kind:"] .graview-kind-face')].flatMap(d=>{let y=d.getBoundingClientRect();return y.width>0&&y.height>0?[{x:y.left-t.left-s,y:y.top-t.top-o,width:y.width,height:y.height}]:[]});l.map(d=>`${Math.round(d.x)},${Math.round(d.y)},${Math.round(d.width)},${Math.round(d.height)}`).join(";")!==se&&Q(l)},[Z,ee,_,C,F]);let V=(0,P.useMemo)(()=>{if(C===0)return[];let e=new Map,t=Math.max(0,...H.map(o=>o.links)),s=Oe({ribbons:H.map(o=>({key:o.key,from:o.from,to:o.to,width:xe(o.links,t)})),plots:I,cell:C,tilt:F,labels:J});return H.flatMap(o=>{let l;if(o.from===o.to){let w=e.get(o.from)??0;e.set(o.from,w+1),l=Be(Se(I.get(o.from),w),{cell:C,tilt:F})}else l=s.get(o.key);return!l||l.length<2?[]:[{ribbon:o,points:l,d:Fe(l),middle:Ne(l),width:xe(o.links,t)}]})},[C,F,_,B,G,A,se]),de=(0,P.useRef)([]),X=(0,P.useRef)({x:0,y:0});if(X.current=p?{x:p.originX+i.x,y:p.originY+i.y}:{x:0,y:0},(0,P.useEffect)(()=>{let e=Z?.parentElement;if(!e||typeof window>"u")return;let t=0,s=null,o=()=>{t=0;let d=s;if(!d)return;let y=d.target;if(d.pointerType==="touch"||d.buttons!==0||y?.closest("[data-graview-view], button, a, input, select, textarea, [data-graview-overlay], [data-graview-offstage]")){h(null);return}let r=e.getBoundingClientRect(),v=d.clientX-r.left-X.current.x,M=d.clientY-r.top-X.current.y,x=null,D=1/0;for(let $ of de.current){let f=qe($.points,v,M);f<=$.reach&&f<D&&(D=f,x=$.key)}h(x)},l=d=>{s=d,t===0&&(t=requestAnimationFrame(o))},w=()=>h(null);return e.addEventListener("pointermove",l,{passive:!0}),e.addEventListener("pointerleave",w),()=>{t!==0&&cancelAnimationFrame(t),e.removeEventListener("pointermove",l),e.removeEventListener("pointerleave",w)}},[Z]),!p||!k.overview||V.length===0)return null;let O=Ee(b,k,N);if(O.records.length>0||O.lens!==null)return null;let T=O.districts.length>0?V.filter(({ribbon:e})=>O.districts.includes(e.from)||O.districts.includes(e.to)):V;if(T.length===0)return null;let te=L??null,Y=T.find(({ribbon:e})=>e.key===ce);de.current=T.map(({ribbon:e,points:t,width:s})=>({key:e.key,points:t,reach:s/2+6}));let K={x:p.originX+i.x,y:p.originY+i.y},n=`translate(${K.x.toFixed(1)} ${K.y.toFixed(1)})`;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("svg",{ref:ue,className:"graview-ribbons","aria-hidden":"true","data-graview-world":"","data-graview-ribbons":T.length,width:m,height:u,style:{position:"absolute",left:0,top:0,pointerEvents:"none",overflow:"visible"},children:(0,S.jsx)("g",{transform:n,children:T.map(({ribbon:e,d:t,width:s})=>{let o=ce===e.key||te!==null&&te===e.edge||O.districts.length>0,l=te!==null&&te!==e.edge;return(0,S.jsx)("g",{className:"graview-ribbon","data-graview-ribbon":e.edge,"data-graview-from":`kind:${e.from}`,"data-graview-to":`kind:${e.to}`,"data-graview-links":e.links,"data-graview-lit":o&&!l?"":void 0,"data-graview-receded":l?"":void 0,children:(0,S.jsx)("path",{className:"graview-ribbon-band",d:t,style:{strokeWidth:s}})},e.key)})})}),Y?(0,S.jsx)("div",{className:"graview-ribbon-said","data-graview-world":"","data-testid":"ribbon-said",role:"status",style:{position:"absolute",left:K.x+Y.middle.x,top:K.y+Y.middle.y,pointerEvents:"none"},children:Re(a.schema,Y.ribbon)}):null]})}function qe(c,m,u){let i=1/0;for(let a=1;a<c.length;a++){let g=c[a-1],b=c[a],k=b.x-g.x,L=b.y-g.y,A=k*k+L*L,G=A===0?0:Math.max(0,Math.min(1,((m-g.x)*k+(u-g.y)*L)/A));i=Math.min(i,Math.hypot(m-(g.x+G*k),u-(g.y+G*L)))}return i}export{Ue as Ribbons,qe as distanceTo};
1
+ import{a as xe}from"./chunk.HJCQ6I3S.js";import{a as je,b as Ee,c as Ie,d as Re}from"./chunk.BNPQUI3F.js";import"./chunk.TKUNRFDE.js";import{c as he}from"./chunk.6RY6OSE6.js";import"./chunk.HDRD33II.js";import"./chunk.DX357TZ3.js";import"./chunk.H7KCWCB4.js";import{G as Ke,R as Pe}from"./chunk.Y4ZUJUUT.js";import"./chunk.SDO3U72B.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import{b as pe}from"./chunk.AJZBJBMO.js";var P=pe(Ke(),1);var E=.5,fe=1,ye=.76,Le=3,We=3,Ae=.6;function Oe(c){let{ribbons:m,plots:u,cell:i}=c,a=c.tilt??.5,g=c.labels??[],b=[...u.values()],k=new Map;if(b.length===0||i<=0)return k;let L=Math.min(...b.map(n=>n.col))-3,A=Math.min(...b.map(n=>n.row))-3,G=Math.max(...b.map(n=>n.col+n.side))+3,ce=Math.max(...b.map(n=>n.row+n.side))+3,h=Math.round((G-L)/E)+1,p=Math.round((ce-A)/E)+1,N=n=>L+n*E,B=n=>A+n*E,I=4,_=!0,C=(n,e)=>{if(!_)return!1;let t=he(n,e,i,a);return g.some(s=>t.x>s.x-I&&t.x<s.x+s.width+I&&t.y>s.y-I&&t.y<s.y+s.height+I)},H=(n,e)=>b.some(t=>n>t.col-ye&&n<t.col+t.side+ye&&e>t.row-ye&&e<t.row+t.side+ye),F=new Uint8Array(h*p),J=new Uint8Array(h*p);for(let n=0;n<h;n++)for(let e=0;e<p;e++){let t=N(n),s=B(e);J[e*h+n]=H(t,s)?0:1,F[e*h+n]=J[e*h+n]&&!C(t,s)?1:0}let Q=F,se=new Float32Array(h*p);for(let n=0;n<h;n++)for(let e=0;e<p;e++){let t=N(n),s=B(e);se[e*h+n]=Math.min(...b.map(o=>Math.max(0,o.col-t,t-(o.col+o.side),o.row-s,s-(o.row+o.side))))}let Z=(n,e,t,s)=>{let o=N(n)+t*E/2,l=B(e)+s*E/2;return!H(o,l)&&!C(o,l)},ue=n=>{let e=[],t=(o,l)=>{let w=[],d=Math.min(1,l/3);for(let y=Math.ceil((o+d)/E-1e-9)*E;y<=o+l-d+1e-9;y+=E)w.push(y);return w},s=(o,l,w,d)=>{let y=Math.round((o-L)/E),r=Math.round((l-A)/E);y>=0&&r>=0&&y<h&&r<p&&Q[r*h+y]&&e.push({i:y,j:r,out:w,curb:d})};for(let o of t(n.row,n.side))s(n.col-fe,o,1,{col:n.col,row:o}),s(n.col+n.side+fe,o,0,{col:n.col+n.side,row:o});for(let o of t(n.col,n.side))s(o,n.row-fe,3,{col:o,row:n.row}),s(o,n.row+n.side+fe,2,{col:o,row:n.row+n.side});return e},ee=new Map,V=(n,e,t,s)=>n<t||n===t&&e<s?`${n},${e}-${t},${s}`:`${t},${s}-${n},${e}`,de=[[1,0],[-1,0],[0,1],[0,-1]],X=new Map;for(let n of m){let e=u.get(n.from),t=u.get(n.to);if(!e||!t||e===t)continue;let s=-1,o=[],l=new Map,w=new Int32Array(0),d=1/0,y=[];for(let f of[!0,!1]){s=-1,d=1/0,_=f,Q=f?F:J,o=ue(e);let W=ue(t);if(o.length===0||W.length===0){y.push({reached:-1,starts:o,goal:l,back:w,best:d});continue}l=new Map(W.map(j=>[j.j*h+j.i,j]));let ne=(j,R)=>{let re=N(j),ae=B(R);return(Math.max(0,t.col-re,re-(t.col+t.side))+Math.max(0,t.row-ae,ae-(t.row+t.side)))*Ae},oe=h*p*4,ie=new Float64Array(oe).fill(1/0);w=new Int32Array(oe).fill(-1);let le=new ke;for(let j of o){let R=(j.j*h+j.i)*4+j.out;ie[R]=0,le.push(R,ne(j.i,j.j))}let Ce=[1,0,3,2];for(;le.size>0&&!(le.peekKey()>=d);){let R=le.pop(),re=Math.floor(R/4),ae=R%4,ge=re%h,we=Math.floor(re/h),ve=l.get(re);if(ve){let q=ie[R]+(ae===Ce[ve.out]?0:Le);q<d&&(d=q,s=R);continue}for(let q=0;q<4;q++){let[Me,$e]=de[q],U=ge+Me,z=we+$e;if(U<0||z<0||U>=h||z>=p||!Q[z*h+U]||!Z(ge,we,Me,$e))continue;let Te=E*(ee.has(V(ge,we,U,z))?Ae:1)*(1+Math.max(0,se[z*h+U]-We))+(q===ae?0:Le),me=(z*h+U)*4+q,be=ie[R]+Te;be<ie[me]&&(ie[me]=be,w[me]=R,le.push(me,be+ne(U,z)))}}y.push({reached:s,starts:o,goal:l,back:w,best:d})}_=!0,Q=F;let[r,v]=y,M=r&&r.reached!==-1&&(!v||v.reached===-1||r.best<=1.3*v.best+2)?r:v;if(!M||M.reached===-1)continue;({reached:s,starts:o,goal:l,back:w}=M);let x=[];for(let f=s;f!==-1;f=w[f]){let W=Math.floor(f/4),ne=x[x.length-1],oe={i:W%h,j:Math.floor(W/h)};(!ne||ne.i!==oe.i||ne.j!==oe.j)&&x.push(oe)}x.reverse();for(let f=1;f<x.length;f++){let W=V(x[f-1].i,x[f-1].j,x[f].i,x[f].j);ee.set(W,[...ee.get(W)??[],n.key])}let D=o.find(f=>f.i===x[0].i&&f.j===x[0].j),$=l.get(x[x.length-1].j*h+x[x.length-1].i);X.set(n.key,{cells:x,start:D.curb,end:$.curb})}let O=new Map(m.map(n=>[n.key,n.width])),T=new Map(m.map((n,e)=>[n.key,e])),te=i*a/Math.sqrt(1+a*a),Y=(n,e)=>n==="col"?`r${e.row.toFixed(2)}`:`c${e.col.toFixed(2)}`,K=new Map;for(let[n,e]of X)for(let t=1;t<e.cells.length;t++){let s=e.cells[t-1],o=e.cells[t],l=Y(s.i!==o.i?"col":"row",{col:N(s.i),row:B(s.j)});K.set(l,(K.get(l)??new Set).add(n))}for(let[n,e]of X){let t=[e.start,...e.cells.map(r=>({col:N(r.i),row:B(r.j)})),e.end],s=r=>r>=2&&r<=e.cells.length?V(e.cells[r-2].i,e.cells[r-2].j,e.cells[r-1].i,e.cells[r-1].j):null,o=[];for(let r=1;r<t.length;r++){let v=Math.abs(t[r].col-t[r-1].col)>1e-9?"col":"row",M=o[o.length-1];M&&M.axis===v?M.to=r:o.push({from:r-1,to:r,axis:v})}if(o.length===0)continue;let l=o.map(r=>{if(!Array.from({length:r.to-r.from},($,f)=>s(r.from+1+f)).some($=>$!==null))return 0;let v=K.get(Y(r.axis,t[r.from]))??new Set;if(!v.has(n))return 0;let M=[...v].sort(($,f)=>(T.get($)??0)-(T.get(f)??0)),D=-(M.reduce(($,f)=>$+(O.get(f)??2)+2,0)-2)/2;for(let $ of M){if($===n)return(D+(O.get($)??2)/2)/te;D+=(O.get($)??2)+2}return 0}),w=r=>{let v=o[r],M=t[v.from];return v.axis==="col"?{row:M.row+l[r]}:{col:M.col+l[r]}},d=(r,v,M)=>({col:r.col??v.col??M.col,row:r.row??v.row??M.row}),y=[d(w(0),{},t[0])];for(let r=0;r+1<o.length;r++)y.push(d(w(r),w(r+1),t[o[r].to]));y.push(d(w(o.length-1),{},t[t.length-1])),k.set(n,y.map(r=>he(r.col,r.row,i,a)))}return k}var ke=class{items=[];keys=[];get size(){return this.items.length}peekKey(){return this.keys[0]??1/0}push(m,u){this.items.push(m),this.keys.push(u);let i=this.items.length-1;for(;i>0;){let a=i-1>>1;if(this.keys[a]<=this.keys[i])break;this.swap(i,a),i=a}}pop(){let m=this.items[0],u=this.items.pop(),i=this.keys.pop();if(this.items.length>0){this.items[0]=u,this.keys[0]=i;let a=0;for(;;){let g=2*a+1,b=g+1,k=a;if(g<this.items.length&&this.keys[g]<this.keys[k]&&(k=g),b<this.items.length&&this.keys[b]<this.keys[k]&&(k=b),k===a)break;this.swap(a,k),a=k}}return m}swap(m,u){[this.items[m],this.items[u]]=[this.items[u],this.items[m]],[this.keys[m],this.keys[u]]=[this.keys[u],this.keys[m]]}};function Se(c,m){let u=c.col+c.side,i=u+.25+.22*Math.max(0,m),a=c.row+c.side*Math.max(.1,.3-.06*m),g=c.row+c.side*Math.min(.9,.7+.06*m);return[{col:u,row:a},{col:i,row:a},{col:i,row:g},{col:u,row:g}]}function Be(c,m){return c.map(u=>he(u.col,u.row,m.cell,m.tilt))}function Fe(c){return c.map((m,u)=>`${u===0?"M":"L"} ${m.x.toFixed(1)} ${m.y.toFixed(1)}`).join(" ")}function Ne(c){if(c.length===0)return{x:0,y:0};let m=0;for(let i=1;i<c.length;i++)m+=Math.hypot(c[i].x-c[i-1].x,c[i].y-c[i-1].y);let u=m/2;for(let i=1;i<c.length;i++){let a=c[i-1],g=c[i],b=Math.hypot(g.x-a.x,g.y-a.y);if(b>=u&&b>0)return{x:a.x+(g.x-a.x)*u/b,y:a.y+(g.y-a.y)*u/b};u-=b}return c[c.length-1]}var S=pe(Pe(),1);function Ue({frame:c,width:m,height:u,pan:i,store:a,graphVersion:g,selection:b,view:k,emphasis:L,hiddenKinds:A,drawn:G}){let[ce,h]=(0,P.useState)(null),p=c.city,N=e=>a.graph.getNode(e)?.kind,B=(0,P.useMemo)(()=>je(a.graph.allEdges(),e=>a.graph.getNode(e)?.kind),[a,g]),I=new Map;for(let e of c.nodes){let t=e.id.startsWith("kind:")?Ie(e.id):null;t!==null&&e.plot&&Math.round(e.plane)===2&&I.set(t,e.plot)}let _=[...I].map(([e,t])=>`${e}:${t.col},${t.row},${t.side}`).join(";"),C=p?.cell??0,H=B.filter(e=>I.has(e.from)&&I.has(e.to)&&!A.has(e.from)&&!A.has(e.to)&&G(e.edge)),F=p?.tilt??.5,[J,Q]=(0,P.useState)([]),se=J.map(e=>`${Math.round(e.x)},${Math.round(e.y)},${Math.round(e.width)},${Math.round(e.height)}`).join(";"),[Z,ue]=(0,P.useState)(null),ee=c.t>=1;(0,P.useLayoutEffect)(()=>{let e=Z?.parentElement;if(!e||!p||!ee)return;let t=e.getBoundingClientRect(),s=p.originX+i.x,o=p.originY+i.y,l=[...e.querySelectorAll('[data-graview-view^="kind:"] .graview-kind-face')].flatMap(d=>{let y=d.getBoundingClientRect();return y.width>0&&y.height>0?[{x:y.left-t.left-s,y:y.top-t.top-o,width:y.width,height:y.height}]:[]});l.map(d=>`${Math.round(d.x)},${Math.round(d.y)},${Math.round(d.width)},${Math.round(d.height)}`).join(";")!==se&&Q(l)},[Z,ee,_,C,F]);let V=(0,P.useMemo)(()=>{if(C===0)return[];let e=new Map,t=Math.max(0,...H.map(o=>o.links)),s=Oe({ribbons:H.map(o=>({key:o.key,from:o.from,to:o.to,width:xe(o.links,t)})),plots:I,cell:C,tilt:F,labels:J});return H.flatMap(o=>{let l;if(o.from===o.to){let w=e.get(o.from)??0;e.set(o.from,w+1),l=Be(Se(I.get(o.from),w),{cell:C,tilt:F})}else l=s.get(o.key);return!l||l.length<2?[]:[{ribbon:o,points:l,d:Fe(l),middle:Ne(l),width:xe(o.links,t)}]})},[C,F,_,B,G,A,se]),de=(0,P.useRef)([]),X=(0,P.useRef)({x:0,y:0});if(X.current=p?{x:p.originX+i.x,y:p.originY+i.y}:{x:0,y:0},(0,P.useEffect)(()=>{let e=Z?.parentElement;if(!e||typeof window>"u")return;let t=0,s=null,o=()=>{t=0;let d=s;if(!d)return;let y=d.target;if(d.pointerType==="touch"||d.buttons!==0||y?.closest("[data-graview-view], button, a, input, select, textarea, [data-graview-overlay], [data-graview-offstage]")){h(null);return}let r=e.getBoundingClientRect(),v=d.clientX-r.left-X.current.x,M=d.clientY-r.top-X.current.y,x=null,D=1/0;for(let $ of de.current){let f=qe($.points,v,M);f<=$.reach&&f<D&&(D=f,x=$.key)}h(x)},l=d=>{s=d,t===0&&(t=requestAnimationFrame(o))},w=()=>h(null);return e.addEventListener("pointermove",l,{passive:!0}),e.addEventListener("pointerleave",w),()=>{t!==0&&cancelAnimationFrame(t),e.removeEventListener("pointermove",l),e.removeEventListener("pointerleave",w)}},[Z]),!p||!k.overview||V.length===0)return null;let O=Ee(b,k,N);if(O.records.length>0||O.lens!==null)return null;let T=O.districts.length>0?V.filter(({ribbon:e})=>O.districts.includes(e.from)||O.districts.includes(e.to)):V;if(T.length===0)return null;let te=L??null,Y=T.find(({ribbon:e})=>e.key===ce);de.current=T.map(({ribbon:e,points:t,width:s})=>({key:e.key,points:t,reach:s/2+6}));let K={x:p.originX+i.x,y:p.originY+i.y},n=`translate(${K.x.toFixed(1)} ${K.y.toFixed(1)})`;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("svg",{ref:ue,className:"graview-ribbons","aria-hidden":"true","data-graview-world":"","data-graview-ribbons":T.length,width:m,height:u,style:{position:"absolute",left:0,top:0,pointerEvents:"none",overflow:"visible"},children:(0,S.jsx)("g",{transform:n,children:T.map(({ribbon:e,d:t,width:s})=>{let o=ce===e.key||te!==null&&te===e.edge||O.districts.length>0,l=te!==null&&te!==e.edge;return(0,S.jsx)("g",{className:"graview-ribbon","data-graview-ribbon":e.edge,"data-graview-from":`kind:${e.from}`,"data-graview-to":`kind:${e.to}`,"data-graview-links":e.links,"data-graview-lit":o&&!l?"":void 0,"data-graview-receded":l?"":void 0,children:(0,S.jsx)("path",{className:"graview-ribbon-band",d:t,style:{strokeWidth:s}})},e.key)})})}),Y?(0,S.jsx)("div",{className:"graview-ribbon-said","data-graview-world":"","data-testid":"ribbon-said",role:"status",style:{position:"absolute",left:K.x+Y.middle.x,top:K.y+Y.middle.y,pointerEvents:"none"},children:Re(a.schema,Y.ribbon)}):null]})}function qe(c,m,u){let i=1/0;for(let a=1;a<c.length;a++){let g=c[a-1],b=c[a],k=b.x-g.x,L=b.y-g.y,A=k*k+L*L,G=A===0?0:Math.max(0,Math.min(1,((m-g.x)*k+(u-g.y)*L)/A));i=Math.min(i,Math.hypot(m-(g.x+G*k),u-(g.y+G*L)))}return i}export{Ue as Ribbons,qe as distanceTo};
@@ -1 +1 @@
1
- import{k as a,l as b,m as c,n as d,o as e,p as f,q as g,r as h,s as i}from"./chunk.ICGNIK3Z.js";import"./chunk.UKAPFIPJ.js";import"./chunk.UT6642FC.js";import"./chunk.WAB7UDHU.js";import"./chunk.IW7YFPGG.js";import"./chunk.R2AG4NHQ.js";import"./chunk.TI4OSTQV.js";import"./chunk.UHX4WTM7.js";import"./chunk.HDRD33II.js";import"./chunk.DX357TZ3.js";import"./chunk.H7KCWCB4.js";import"./chunk.6BJBPDF3.js";import"./chunk.XWAMQPUM.js";import"./chunk.SDO3U72B.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import"./chunk.AJZBJBMO.js";export{i as GhostTray,h as InlineAiMenu,g as askAgain,c as askInline,a as askOf,b as drawPanel,d as heldSuggestion,e as suggestOnce,f as takeOffer};
1
+ import{k as a,l as b,m as c,n as d,o as e,p as f,q as g,r as h,s as i}from"./chunk.OCTOGZVJ.js";import"./chunk.UKAPFIPJ.js";import"./chunk.UT6642FC.js";import"./chunk.WAB7UDHU.js";import"./chunk.IW7YFPGG.js";import"./chunk.2W22AWSL.js";import"./chunk.TI4OSTQV.js";import"./chunk.UHX4WTM7.js";import"./chunk.HDRD33II.js";import"./chunk.DX357TZ3.js";import"./chunk.H7KCWCB4.js";import"./chunk.O4WEJ47H.js";import"./chunk.Y4ZUJUUT.js";import"./chunk.SDO3U72B.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import"./chunk.AJZBJBMO.js";export{i as GhostTray,h as InlineAiMenu,g as askAgain,c as askInline,a as askOf,b as drawPanel,d as heldSuggestion,e as suggestOnce,f as takeOffer};
@@ -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{c as _e,d as xe,e as Me}from"./chunk.64WM4IBI.js";import{q as $e}from"./chunk.VW2VCPJX.js";import{a as Ne}from"./chunk.UKAPFIPJ.js";import{f as K}from"./chunk.IW7YFPGG.js";import{a as E}from"./chunk.Q7RQC3F7.js";import{a as Re,b as G,d as Te}from"./chunk.HDRD33II.js";import{a as ge}from"./chunk.H7KCWCB4.js";import{Aa as U,Ca as fe,Cb as ve,Ea as pe,Fa as V,Fb as Ae,Ib as q,K as le,Lc as Oe,Ma as me,Na as he,Qa as ye,Wa as F,Za as be,a as ce,da as C,vb as we,xa as ue,yb as ke,zb as Se}from"./chunk.AS4CQBOQ.js";var J=(t,n,e)=>{(t[n]===void 0||e>t[n])&&(t[n]=e)},D=(t,n,e)=>{(t[n]===void 0||e<t[n])&&(t[n]=e)},Z=(t,n)=>{t.format=n,n.includes("int")&&(t.isInt=!0)},Pe=(t,n)=>{t.mime=t.mime?t.mime.filter(e=>n.includes(e)):[...n]},Je=(t,n)=>{t.multipleOf??=[],t.multipleOf.includes(n)||t.multipleOf.push(n)},De=(t,n)=>(t.patterns??=new Set).add(n),Xe={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function z(t){let n={},{def:e,bag:r}=t._zod,i=t._zod.traits.has("$ZodCheck")?[t,...e.checks??[]]:e.checks??[];for(let o of i){let a=o._zod.def;switch(a.check){case"greater_than":J(n,a.inclusive?"minimum":"exclusiveMinimum",a.value);break;case"less_than":D(n,a.inclusive?"maximum":"exclusiveMaximum",a.value);break;case"multiple_of":Je(n,a.value);break;case"number_format":{Z(n,a.format);let d=Xe[a.format];d&&(J(n,"minimum",d[0]),D(n,"maximum",d[1]));break}case"bigint_format":Z(n,a.format);break;case"min_length":case"min_size":J(n,"minimum",a.minimum);break;case"max_length":case"max_size":D(n,"maximum",a.maximum);break;case"length_equals":J(n,"minimum",a.length),D(n,"maximum",a.length);break;case"size_equals":J(n,"minimum",a.size),D(n,"maximum",a.size);break;case"string_format":Z(n,a.format),a.pattern&&De(n,a.pattern),(a.format==="base64"||a.format==="base64url")&&(n.contentEncoding=a.format),(a.local||a.precision===-1)&&(n.laxFormat=!0);break;case"mime_type":Pe(n,a.mime);break}}r.minimum!==void 0&&J(n,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&J(n,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&D(n,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&D(n,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&Je(n,r.multipleOf),r.format!==void 0&&(n.format??=r.format,r.format.includes("int")&&(n.isInt=!0)),r.mime&&Pe(n,r.mime);for(let o of r.patterns??[])De(n,o);return n}var Qe={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""};function j(t){let n=t._zod.def;return n.type==="pipe"&&n.in._zod.traits.has("$ZodTransform")?j(n.out):n.type==="catch"?j(n.innerType):t._zod.optin}var en=new Set(["promise","optional","nonoptional","nullable","readonly","default","prefault","catch"]);function R(t,n=new Set){if(n.has(t))return!1;n.add(t);let e=t._zod.def,r=e.type;return r==="transform"?!0:r==="array"?R(e.element,n):r==="set"?R(e.valueType,n):r==="lazy"?R(e.getter(),n):en.has(r)?R(e.innerType,n):r==="intersection"?R(e.left,n)||R(e.right,n):r==="record"||r==="map"?R(e.keyType,n)||R(e.valueType,n):r==="pipe"?t._zod.traits.has("$ZodCodec")||R(e.in,n)||R(e.out,n):r==="object"?Object.values(e.shape).some(i=>R(i,n)):r==="union"?e.options.some(i=>R(i,n)):r==="tuple"?e.items.some(i=>R(i,n))||(e.rest?R(e.rest,n):!1):!1}function nn(t){let n=Object.values(t).filter(e=>typeof e=="number");return Object.entries(t).filter(([e])=>n.indexOf(+e)===-1).map(([,e])=>e)}function Ie(t){let n=t.anyOf;if(!Array.isArray(n)||n.length===0||t.type!==void 0)return;let e=[];for(let r of n){if(!r||typeof r!="object")return;Ie(r);let i=Object.keys(r);if(i.length!==1||i[0]!=="type")return;for(let o of[r.type].flat()){if(typeof o!="string")return;e.includes(o)||e.push(o)}}delete t.anyOf,t.type=e.length===1?e[0]:e}var je=new Set(["type","properties","required","additionalProperties"]),Ee=t=>{let n=t.additionalProperties;return n&&typeof n=="object"&&Object.keys(n).length?n:null},ze=(t,n)=>JSON.stringify(t)===JSON.stringify(n);function Y(t){for(let i of t){if(typeof i!="object"||i.type!=="object")return null;for(let o in i)if(!je.has(o))return null}let n={},e=new Set;for(let i of t){for(let o in i.properties){if(Object.prototype.hasOwnProperty.call(n,o))continue;let a=[];for(let d of t){let s=d.properties?.[o]??Ee(d);s&&!a.some(g=>ze(g,s))&&a.push(s)}n[o]=a.length===1?a[0]:Y(a)??{allOf:a}}for(let o of i.required??[])e.add(o)}let r={type:"object",properties:n};if(e.size&&(r.required=[...e]),t.every(i=>i.additionalProperties===!1))r.additionalProperties=!1;else{let i=[];for(let o of t){let a=Ee(o);a&&!i.some(d=>ze(d,a))&&i.push(a)}i.length===1?r.additionalProperties=i[0]:i.length>1&&(r.additionalProperties={allOf:i})}return r}function tn(t){let n=t.allOf;if(!Array.isArray(n)||n.length<2)return;for(let i of je)if(i in t)return;let e=n.filter(i=>Array.isArray(i.oneOf)||Array.isArray(i.anyOf)),r;if(!e.length)r=Y(n);else{let i=e[0],o=Array.isArray(i.oneOf)?"oneOf":"anyOf";if(Object.keys(i).length!==1)return;let a=n.filter(s=>s!==i),d=i[o].map(s=>Y([...a,s]));if(d.some(s=>!s))return;r={[o]:d}}r&&(delete t.allOf,Object.assign(t,r))}function He(t){let n=t;for(let k of["anyOf","oneOf"]){let A=n[k];if(!Array.isArray(A))continue;let m=A.map(He);m.some((l,w)=>l!==A[w])&&(n={...n,[k]:m})}let e=[n.type].flat(),r=!e.includes("string")&&e.some(k=>k==="number"||k==="integer"),i=n.enum??(n.const!==void 0?[n.const]:void 0);if(!r&&!i?.some(k=>typeof k=="number"))return n;let{minimum:o,maximum:a,exclusiveMinimum:d,exclusiveMaximum:s,multipleOf:g,format:f,id:b,...h}=n;return h.enum?h.enum=h.enum.map(k=>typeof k=="number"?String(k):k):typeof h.const=="number"&&(h.const=String(h.const)),r&&(h.type="string",i||(h.pattern=e.includes("number")?"^-?\\d+(?:\\.\\d+)?$":"^-?\\d+$")),h}var W=class{constructor(n,e){this.override=n;this.refs=e}done=new Map;path=[];cyclic=new Map;write(n,e=!1){let r=this.refs.get(n);if(r!==void 0&&!e)return{$ref:r};if(this.path.includes(n))return this.cyclic.has(n)||this.cyclic.set(n,""),{};let i=this.done.get(n);if(i)return i;this.path.push(n);try{let o=this.written(n);return this.done.set(n,o),o}finally{this.path.pop()}}written(n){let e={},r,i=n._zod.toJSONSchema?.();i?Object.assign(e,i):r=this.process(n,e);let o=ce.get(n);if(o)for(let d of Object.keys(o))e[d]=o[d];R(n)&&(delete e.examples,delete e.default),"_prefault"in e&&(e.default??=e._prefault,delete e._prefault);let a=e;if(r){let d=this.write(r);a={...e};for(let s of Object.keys(d))s in e||(a[s]=d[s])}return this.override({zodSchema:n,jsonSchema:a}),Ie(a),n._zod.def.type==="intersection"&&tn(a),a}process(n,e){let r=n._zod.def;switch(r.type){case"string":{e.type="string";let{minimum:i,maximum:o,format:a,patterns:d,contentEncoding:s,laxFormat:g}=z(n);if(typeof i=="number"&&(e.minLength=i),typeof o=="number"&&(e.maxLength=o),a&&(e.format=Qe[a]??a,(e.format===""||a==="time"||g)&&delete e.format),s&&(e.contentEncoding=s),d&&d.size>0){let f=[...d];f.length===1?e.pattern=f[0].source:e.allOf=f.map(b=>({pattern:b.source}))}return}case"number":{let{minimum:i,maximum:o,multipleOf:a,exclusiveMinimum:d,exclusiveMaximum:s,isInt:g}=z(n);if(e.type=g?"integer":"number",typeof d=="number"&&d>=(i??Number.NEGATIVE_INFINITY)?e.exclusiveMinimum=d:typeof i=="number"&&(e.minimum=i),typeof s=="number"&&s<=(o??Number.POSITIVE_INFINITY)?e.exclusiveMaximum=s:typeof o=="number"&&(e.maximum=o),a){let[f,...b]=new Set(a.filter(h=>Number.isFinite(h)&&h!==0).map(Math.abs));f!==void 0&&(e.multipleOf=f),b.length&&(e.allOf=[...e.allOf??[],...b.map(h=>({multipleOf:h}))])}return}case"boolean":case"success":e.type="boolean";return;case"null":e.type="null";return;case"never":e.not={};return;case"enum":{let i=nn(r.entries);i.length===0?e.not={}:(i.every(o=>typeof o=="number")&&(e.type="number"),i.every(o=>typeof o=="string")&&(e.type="string"),e.enum=i);return}case"literal":{let i=r.values.filter(o=>o!==void 0).map(o=>typeof o=="bigint"?Number(o):o);if(r.values.length===0)e.not={};else if(i.length===1)e.type=i[0]===null?"null":typeof i[0],e.const=i[0];else if(i.length>1){for(let o of["number","string","boolean"])i.every(a=>typeof a===o)&&(e.type=o);i.every(o=>o===null)&&(e.type="null"),e.enum=i}return}case"template_literal":e.type="string",e.pattern=n._zod.pattern.source;return;case"file":{e.type="string",e.format="binary",e.contentEncoding="binary";let{minimum:i,maximum:o,mime:a}=z(n);i!==void 0&&(e.minLength=i),o!==void 0&&(e.maxLength=o),a&&(a.length===0?e.not={}:a.length===1?e.contentMediaType=a[0]:e.anyOf=a.map(d=>({contentMediaType:d})));return}case"array":{let{minimum:i,maximum:o}=z(n);typeof i=="number"&&(e.minItems=i),typeof o=="number"&&(e.maxItems=o),e.type="array",e.items=this.write(r.element);return}case"object":{let i=r.shape;e.type="object";let o={};e.properties=o;for(let d in i)Object.defineProperty(o,d,{value:this.write(i[d]),writable:!0,enumerable:!0,configurable:!0});let a=Object.keys(i).filter(d=>j(i[d])===void 0);a.length>0&&(e.required=a),r.catchall?._zod.def.type==="never"?e.additionalProperties=!1:r.catchall&&(e.additionalProperties=this.write(r.catchall));return}case"union":e[r.inclusive===!1?"oneOf":"anyOf"]=r.options.map(i=>this.write(i));return;case"intersection":{let i=d=>"allOf"in d&&Object.keys(d).length===1,o=this.write(r.left),a=this.write(r.right);e.allOf=[...i(o)?o.allOf:[o],...i(a)?a.allOf:[a]];return}case"tuple":{let i=r.items;e.type="array",e.prefixItems=i.map(s=>this.write(s)),r.rest?e.items=this.write(r.rest):e.items=!1;let o=i.length;for(;o>0&&j(i[o-1])!==void 0;)o-=1;o>0&&(e.minItems=o),r.rest||(e.maxItems=i.length);let{minimum:a,maximum:d}=z(n);typeof a=="number"&&(e.minItems=a),typeof d=="number"&&(e.maxItems=d);return}case"record":{let i=r.keyType;e.type="object";let o=z(i).patterns;if(r.mode==="loose"&&o&&o.size>0){let d=this.write(r.valueType),s={};for(let g of o)s[g.source]=d;e.patternProperties=s}else e.propertyNames=He(this.write(i)),e.additionalProperties=this.write(r.valueType);let a=i._zod.values;if(a&&!r.partial&&j(r.valueType)===void 0){let d=[...a].filter(s=>typeof s=="string"||typeof s=="number");d.length>0&&(e.required=d.map(String))}return}case"nullable":e.anyOf=[this.write(r.innerType),{type:"null"}];return;case"default":case"prefault":{let i=r.defaultValue,o,a=!1,d=JSON.stringify(i,(s,g)=>typeof g=="bigint"?(a=!0,null):g);return!a&&d!==void 0&&(o=JSON.parse(d)),a||(e[r.type==="default"?"default":"_prefault"]=o),r.innerType}case"catch":{try{e.default=r.catchValue(void 0)}catch{}return r.innerType}case"readonly":return e.readOnly=!0,r.innerType;case"pipe":return r.in._zod.traits.has("$ZodTransform")?r.out:r.in;case"lazy":return n._zod.innerType;case"optional":case"nonoptional":case"promise":return r.innerType;default:return}}};function Le(t,n=()=>{}){let e=t,r=new W(n,new Map),i=r.write(e,!0);if(r.cyclic.size>0){let o=new Map,a=0,d=[];for(let g of r.cyclic.keys())if(g===e)o.set(g,"#");else{let f=`__schema${a++}`;o.set(g,`#/$defs/${f}`),d.push([g,f])}r=new W(n,o),i=r.write(e,!0);let s={};for(let[g,f]of d)s[f]=r.write(g,!0);d.length>0&&(i={...i,$defs:s})}return JSON.parse(JSON.stringify({$schema:"https://json-schema.org/draft/2020-12/schema",...i}))}function Fe(t){return Le(t,an)}var rn={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string"},on={phone:"A phone number as it is written, like +1 555 123 4567 or 020 7946 0958 ext. 12.",place:"An address or a place's name, as a person would search a map for it.",duration:"A length of time in whole minutes: 90 is 1 h 30 min."};function an(t){ue(t.zodSchema)&&(t.jsonSchema["x-graview-app-link"]=!0);let n=pe(t.zodSchema);if(n&&(t.jsonSchema.type==="string"||t.jsonSchema.type==="array")){t.jsonSchema["x-graview-linked"]={address:n.address,kinds:[...n.kinds],cardinality:n.cardinality};let s=n.kinds.join(" or "),g=`${n.cardinality==="many"?"Records":"A record"}: a ${s} in the app ${n.address}, as "${n.kinds[0]}:<id>" \u2014 an id found there with find_linked. Linking never changes that app.`,f=t.jsonSchema.description;typeof f=="string"&&f.includes(g)||(t.jsonSchema.description=`${typeof f=="string"&&f?`${f.replace(/\.?$/,".")} `:""}${g}`)}if(ye(t.zodSchema)&&(t.jsonSchema["x-graview-repeat"]=!0,!t.jsonSchema.type&&!t.jsonSchema.anyOf&&!t.jsonSchema.oneOf&&Object.assign(t.jsonSchema,sn())),ge(t.zodSchema)){t.jsonSchema.contentMediaType="text/markdown";let s=t.jsonSchema.description;typeof s=="string"&&s.endsWith("Written in Markdown.")||(t.jsonSchema.description=`${typeof s=="string"&&s?`${s.replace(/\.?$/,".")} `:""}Written in Markdown.`)}let e=Ae(t.zodSchema);if(e){let s=t.jsonSchema;s["x-graview-type"]=e,e==="duration"&&(s["x-graview-unit"]="minutes"),s.description??=on[e]}let r=ve(t.zodSchema,!1);if(r){let s=Re(r);t.jsonSchema["x-graview-format"]=s.format??"unit",s.currency&&(t.jsonSchema["x-graview-currency"]=s.currency),s.unit&&s.format!=="money"&&(t.jsonSchema["x-graview-unit"]=s.unit);let g=t.jsonSchema.description;t.jsonSchema.description=typeof g=="string"&&g.length>0?`${g} ${G(s)}`:G(s)}let i=t.zodSchema._zod?.def;if(!i||i.type!=="string"||typeof i.format!="string"||i.format==="regex")return;let o=t.jsonSchema,a=(i.checks??[]).map(s=>s._zod?.def).filter(s=>s?.format==="regex"&&s.pattern instanceof RegExp).map(s=>s.pattern.source);delete o.pattern;let d=o.allOf;Array.isArray(d)&&d.every(s=>typeof s=="object"&&s!==null&&Object.keys(s).length===1&&"pattern"in s)&&delete o.allOf,o.format=rn[i.format]??i.format,a.length===1?o.pattern=a[0]:a.length>1&&(o.allOf=a.map(s=>({pattern:s})))}function X(t){let n=q(t.input),e=Fe(t.input),r=e.properties??{};if(ke(t)){let i=t.creates.join(" | ");r.id={type:"string",minLength:1,description:`Optional: the id for the ${i} this makes. Refused if the graph already has it; left out, one is minted from the label.`},e.properties=r}Se(t)&&(e.additionalProperties=!1);for(let i of n){let o=r[i.name];if(!o)continue;let a=i.kinds.includes("*")?"any node kind":i.kinds.join(" | ");o.description=[o.description,`Id of a node (${a}).`].filter(Boolean).join(" ")}return{name:t.name,...t.title===void 0?{}:{title:t.title},description:t.description??t.title??t.name,inputSchema:e,nodeRefs:n}}function sn(){let t={type:"string",pattern:"^\\d{4}-\\d{2}-\\d{2}$"},n=(e,r)=>({type:"integer",minimum:e,maximum:r});return{type:"object",description:'How the date beside it repeats; the date is the first occurrence. "on" is weekdays for "week", days of the month (-1 the last) for "month".',properties:{every:{type:"string",enum:[...he]},interval:n(1,99),on:{type:"array",minItems:1,maxItems:31,items:{anyOf:[{type:"string",enum:[...me]},n(-1,31)]}},until:t,count:n(1,1e3),except:{type:"array",maxItems:500,items:t},continues:{type:"string",maxLength:200}},required:["every"],additionalProperties:!1}}function qe(t){let n=new Set;for(let e=t;e;e=e.onBehalfOf)e.id!==void 0&&n.add(`${e.kind}:${e.id}`);return n}function B(t,n){let e=qe(n),r=f=>{if(f.kind==="rule")return!1;let b=qe(f);if(b.size===0)return!1;for(let h of b)if(e.has(h))return!1;return!0},i,o=()=>{if(i)return i;i=new Map;for(let f of t.log.live()){if(f.undoes!==void 0)continue;let b=r(f.author)?f.author:void 0;for(let h of f.primitives){h.op==="remove-node"&&i.delete(h.node.id);let k=h.op==="add-node"?h.node.id:h.op==="patch-node"?h.id:void 0;if(k===void 0)continue;let A=h.op==="add-node"?Object.keys(h.node):Object.keys(h.after),m=i.get(k);(h.op==="add-node"||!m)&&i.set(k,m=new Map);for(let l of A)l==="id"||l==="kind"||(b?m.set(l,b):m.delete(l))}}return i},a=t.schema,d=new Map,s=(f,b)=>{let h=`${f}\0${b}`,k=d.get(h);if(k===void 0){let A=a.tryDefinition(f)?.fields?.shape;k=A!==void 0&&b in A&&Te(A[b]).type==="text",d.set(h,k)}return k},g=f=>t.graph.getNode(f)?.kind;return{prose:s,say:f=>F(f,{graph:t.graph,schema:a}),fieldBy(f,b){let h=g(f);if(!(h===void 0||!s(h,b)))return o().get(f)?.get(b)},recordBy(f){let b=g(f),h=o().get(f);if(b===void 0||!h)return;let k;for(let[A,m]of h)s(b,A)&&(k=m);return k}}}var Q=(t,n,e)=>({untrusted:!0,authoredBy:e.say(n),text:t}),dn="the host's ranker";function We(t,n){return{...t,hits:t.hits.map(e=>{if(e.about!=="node")return e;e.why.by==="meaning"&&e.why.matched!==void 0&&(e={...e,why:{...e.why,matched:{untrusted:!0,authoredBy:dn,text:e.why.matched}}});let r=n.recordBy(e.id);if(!r)return e;let i=n.prose(e.kind,e.why.field)?n.fieldBy(e.id,e.why.field):r;return{...e,label:Q(e.label,r,n),...e.apart!==void 0?{apart:Q(e.apart,r,n)}:{},why:i?{...e.why,fragment:Q(e.why.fragment,i,n)}:e.why}})}}var ee=(t,n,e)=>({title:t,readOnlyHint:n,destructiveHint:!1,idempotentHint:e,openWorldHint:!1}),cn={name:"subscribe",title:"Notify me when something happens",description:`Subscribe the person you act for to be told when something happens in this app \u2014 their host delivers it (an email, a push). on is one of: "act" (an act runs; give act, its declared name, and/or record), "created" (a record of kind is added), "changed" (a record of kind, or the one record, changes), "reaches" (a record of kind, or the one record, comes to satisfy condition, an expression in the app's rule language such as done == true or amount > 100). They are told only of changes someone else made, unless alsoMine is true, and only of records they may see. Returns the subscription and its sentence. Changes nothing in the app.`,inputSchema:{type:"object",properties:{on:{type:"string",enum:["act","created","changed","reaches"],description:"What to be told of."},act:{type:"string",description:"An act's declared name, for on: act."},kind:{type:"string",description:"A kind, for created, changed and reaches."},record:{type:"string",description:"One record, by id or name: for act, changed and reaches."},condition:{type:"string",description:"For reaches: what the record should come to satisfy, in the rule language (done == true)."},alsoMine:{type:"boolean",description:"Also when the person themselves made the change; false when unsaid."}},required:["on"],additionalProperties:!1},mutating:!1,annotations:ee("Notify me when something happens",!1,!1)},ln={name:"unsubscribe",title:"Stop notifying me",description:"Take away one of the person's subscriptions, by the id list_subscriptions or subscribe answered. Changes nothing in the app.",inputSchema:{type:"object",properties:{id:{type:"string",description:"The subscription's id."}},required:["id"],additionalProperties:!1},mutating:!1,annotations:ee("Stop notifying me",!1,!0)},un={name:"list_subscriptions",title:"What I am notified of",description:`List what the person you act for is told of in this app: each subscription's id and its sentence ("When someone else adds a task").`,inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:ee("What I am notified of",!0,!0)},ne=[cn,ln,un];var L=t=>{let n;return()=>n??=t().catch(e=>{throw n=void 0,e})},fn=L(()=>(__graviewPreload(import.meta.url,["./chunk.SZ34UAQ3.js","./chunk.VC3BX2ZF.js","./chunk.OYHQSXNC.js","./chunk.UHX4WTM7.js","./chunk.IKX4VDTW.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.RPX35VYU.js"))),pn=()=>(__graviewPreload(import.meta.url,["./chunk.Q7RQC3F7.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.QGVLJTZS.js")).catch(()=>{}),mn=async()=>{(await pn())?.judgeWithLines()},H=L(()=>(__graviewPreload(import.meta.url,["./chunk.WVUJXDXZ.js","./chunk.OYHQSXNC.js","./chunk.UHX4WTM7.js","./chunk.IKX4VDTW.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.H7KCWCB4.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.JSSFA3FC.js"))),hn=L(()=>(__graviewPreload(import.meta.url,["./chunk.4RJZVTW7.js","./chunk.G4JJXA63.js","./chunk.WBHM5I3I.js","./chunk.VC3BX2ZF.js","./chunk.WAB7UDHU.js","./chunk.IW7YFPGG.js","./chunk.Q5WEOX3Q.js","./chunk.OMZ3LDDN.js","./chunk.MGWMGLWE.js","./chunk.Q7RQC3F7.js","./chunk.WVUJXDXZ.js","./chunk.OYHQSXNC.js","./chunk.UHX4WTM7.js","./chunk.IKX4VDTW.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.HDRD33II.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.66JF3UMG.js"))),yn=L(()=>(__graviewPreload(import.meta.url,["./chunk.JR7RDOEP.js","./chunk.SZ34UAQ3.js","./chunk.VC3BX2ZF.js","./chunk.UKAPFIPJ.js","./chunk.UT6642FC.js","./chunk.OYHQSXNC.js","./chunk.UHX4WTM7.js","./chunk.IKX4VDTW.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.HDRD33II.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.II7VTGNC.js"))),gn=L(()=>(__graviewPreload(import.meta.url,["./chunk.Z6TMIAAB.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.63JLXGYX.js"))),bn=t=>t.definitions.some(n=>V(n).size>0),Be=t=>({value:U(t),label:t.label,...t.describe?{describe:t.describe}:{},...t.card?{card:t.card}:{},fields:t.fields,...t.app?{app:t.app}:{}});async function wn(t,n,e,r){let i=String(e.relation??""),[o,a]=i.includes(".")?i.split(".",2):[void 0,i],d=t.schema.definitions.flatMap(l=>[...V(l)].map(([w,S])=>({kind:l.kind,name:w,relation:S}))),s=d.filter(l=>l.name===a&&(o===void 0||l.kind===o));if(s.length!==1){let l=d.map(w=>`${w.kind}.${w.name}`).join(", ")||"none";return{ok:!1,error:`${s.length===0?`No relation to another app is called "${i}"`:`"${i}" names a relation of several kinds`}. The relations to other apps are: ${l}.`}}let{kind:g,name:f,relation:b}=s[0];if(!r)return{ok:!1,error:`This seat cannot read ${b.address}: its host reads no other app's records. Nothing was changed.`};let h={kind:n.kind,...n.id===void 0?{}:{id:n.id},...n.roles?{roles:n.roles}:{}},k=typeof e.of=="string"?e.of:void 0;if(k!==void 0){let l=t.graph.getNode(k);if(!l||l.kind!==g)return{ok:!1,error:`No ${g} "${k}".`};let w=fe(l[f],b),S=await Promise.all(w.map(c=>Promise.resolve().then(()=>r.resolve(c,h)).catch(()=>null)));return{ok:!0,data:{relation:`${g}.${f}`,app:b.address,records:S.map((c,u)=>c===null?{value:U(w[u]),missing:!0}:"denied"in c?{denied:!0,said:"linked record (no access)"}:Be(c))},reads:[k]}}let A=typeof e.limit=="number"&&e.limit>0?Math.min(e.limit,20):20,m=await Promise.resolve().then(()=>r.find({address:b.address,kinds:b.kinds,query:String(e.query??""),limit:A},h)).catch(()=>[]);return Array.isArray(m)?{ok:!0,data:{relation:`${g}.${f}`,app:b.address,records:m.map(Be),link:`edit-${g} with ${f} set to a record's value`}}:{ok:!0,data:{relation:`${g}.${f}`,app:b.address,denied:!0,said:"linked record (no access)"}}}var _=t=>({title:t,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}),Ce={description:'Which records: false (the default) the live ones, true only the archived ones, "all" both. An archived record is set aside, not gone: unarchive-<kind> brings it back.',anyOf:[{type:"boolean"},{type:"string",enum:["all"]}]},te={type:"number",description:"Where the page starts; 0 when unsaid."},oe=[{name:"search_graph",title:"Find by name",description:"Find things by name: records whose name or readable fields carry the words, and the kinds, places and rules the words name \u2014 each with why it matched. Reach for this before get_graph when you know what something is called. Words match the start of words, case and accents aside; key:value tokens narrow as a list's filter does (done:false, is:any for past records, kind:<kind>). Pass subject (a node id) to get the acts you may run on it as hits too. When few records match exactly, records with a near word follow \u2014 a typo, another form of the word, a meaning \u2014 each with near: true and why.matched, the record's own word that answered.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Words, with optional key:value conditions."},limit:{type:"number",description:"Most hits to return; at most 20."},subject:{type:"string",description:"A node id whose acts to include."},archived:Ce},required:["query"],additionalProperties:!1},mutating:!1,annotations:_("Find by name")},{name:"get_graph",title:"Read the graph",description:"Read the graph, 25 nodes a page: their fields, the edges out of them, and how many more. Start here when you need the shape of the domain rather than one thing in it.",inputSchema:{type:"object",properties:{offset:te,archived:Ce},additionalProperties:!1},mutating:!1,annotations:_("Read the graph")},{name:"get_node",title:"Read one node",description:"Read one node: its fields, its links (id, kind and label, 20 each way a page), the violations that implicate it, and its computed values: read-only fields worked out from what you can see, which no act sets. Use this to check a thing before you change it.",inputSchema:{type:"object",properties:{id:{type:"string",description:"A node's id, or its name."},offset:te},required:["id"],additionalProperties:!1},mutating:!1,annotations:_("Read one node")},{name:"get_violations",title:"List the problems",description:"List the invariant violations the graph currently has, 20 a page, with the repairs that would resolve each one. Read this before proposing work: a rule that is already broken is more urgent than anything you could add.",inputSchema:{type:"object",properties:{offset:te,context:{type:"object",description:"Evaluation context, e.g. { weekStart }."}},additionalProperties:!1},mutating:!1,annotations:_("List the problems")},{name:"get_affordances",title:"Ask what can be done",description:"Ask what can legally be done with a selection, ranked. Prefer these over composing a mutation by hand: they are derived from the schema, the invariants and the shape of the graph, so they cannot name an action that does not exist.",inputSchema:{type:"object",properties:{selection:{type:"array",items:{type:"string"},description:"Node ids."},context:{type:"object"}},required:["selection"],additionalProperties:!1},mutating:!1,annotations:_("Ask what can be done")},{name:"describe_place",title:"Say what a place shows",description:`Say what one place of the app shows you, as a person in your seat would see it: its headings, its figures as drawn, its lists with each record's title and what its card or row says, the headings a list is grouped under, what an empty list says, and any block that could not be worked out. Pass a place's slug ("home", a lens's address like "the-offers", a kind's like "offers") or a record's id, and width 390 for a phone. Use it after a change to check what somebody now sees, instead of guessing.`,inputSchema:{type:"object",properties:{place:{type:"string",description:`"home", a place's slug, or a record's id.`},width:{type:"number",description:"The screen's width in CSS pixels; 390 is a phone, 1440 when unsaid."}},required:["place"],additionalProperties:!1},mutating:!1,annotations:_("Say what a place shows")},{name:"preview_mutation",title:"Try an act without applying it",description:"Try a mutation without applying it: get back the diff it would produce and any invariant it would break. Do this when you are unsure, rather than applying and undoing.",inputSchema:{type:"object",properties:{mutation:{type:"string"},args:{type:"object"}},required:["mutation","args"],additionalProperties:!1},mutating:!1,annotations:_("Try an act without applying it")},{name:"undo_batch",title:"Undo a batch",description:"Undo one batch of operations. Fails, naming the blocking operation, when a later operation read what it wrote.",inputSchema:{type:"object",properties:{batch:{type:"string"},include:{type:"array",items:{type:"string"}}},required:["batch"],additionalProperties:!1},mutating:!0,annotations:{title:"Undo a batch",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}},{name:"list_suggestions",title:"List what is suggested",description:"List the suggestions waiting for a person: changes the app's own actor proposed and did not make, each with its id, what it would do, who suggested it, what it was based on and how sure (0 to 1). Nothing changes until one is accepted (accept_suggestion) or declined (decline_suggestion); a declined one is never suggested again.",inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:_("List what is suggested")},{name:"accept_suggestion",title:"Accept a suggestion",description:"Make a waiting suggestion's change, as this seat, carrying what it was based on. Returns the batch (undo_batch takes it back).",inputSchema:{type:"object",properties:{suggestion:{type:"string",description:"The suggestion's id, from list_suggestions."}},required:["suggestion"],additionalProperties:!1},mutating:!0,annotations:{title:"Accept a suggestion",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1}},{name:"decline_suggestion",title:"Decline a suggestion",description:"Decline a waiting suggestion: nothing changes, the decline is kept in the log, and the same change is never suggested or made by the app's own actor again.",inputSchema:{type:"object",properties:{suggestion:{type:"string",description:"The suggestion's id, from list_suggestions."}},required:["suggestion"],additionalProperties:!1},mutating:!0,annotations:{title:"Decline a suggestion",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}],Ve={name:"act_on_several",title:"Do one act to several records",description:`Run one act on several records at once, as one change with one undo. act is the act (its tool name or its declared name), records the records it runs on (ids or names; each goes in the act's subject), args what every call shares ("Set stage to Declined" is args { stage: "declined" }). Each record is judged on its own: one this seat may not change is named with why, and the rest still apply. Returns the batch (undo_batch takes it all back), the records changed, those already so, and those refused.`,inputSchema:{type:"object",properties:{act:{type:"string",description:"The act to run on each record."},records:{type:"array",items:{type:"string"},minItems:1,maxItems:200,description:"Ids or names of the records."},args:{type:"object",description:"Arguments every call shares, besides the record."}},required:["act","records"],additionalProperties:!1},mutating:!0,annotations:{title:"Do one act to several records",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}},ae={type:"object",description:"A lens, as draft_view returns one.",properties:{title:{type:"string"},lens:{type:"string"},on:{type:"string"},bindings:{type:"object"},options:{type:"object"}},required:["title","lens","on"]},se={name:"draft_view",title:"Draw a view",description:'Draw a view of the data from words ("a board of tasks by status", "who covers what") as a lens the app could keep; or check a lens you wrote (lens); or change the one on screen (current, with ask: "only this month"). Returns the lens and its add-lens edit, or one sentence saying why not. Writes nothing.',inputSchema:{type:"object",properties:{ask:{type:"string",description:"What to see, in words."},lens:ae,current:ae},additionalProperties:!1},mutating:!1,annotations:_("Draw a view")},Ge={name:"keep_lens",title:"Keep a view as a lens",description:"Keep a lens draft_view drew as one of the app's places: checked again, then written as the add-lens edit. Returns the remove-lens edit that takes it back.",inputSchema:{...ae,additionalProperties:!1},mutating:!0,annotations:{title:"Keep a view as a lens",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},Ke={name:"find_linked",title:"Find a record in another app",description:`A relation may go to a kind in another app (describe_app lists them under "Linked from other apps"). With relation and words, list the records there this seat may link \u2014 each with the value to link it by ("house:h1"), its name and its describe line. With of (a record id here), read the records that record links, as this seat may see them there. Linking one is the record's edit (edit-<kind>) with the relation set to the value. Another app this seat may not open answers denied, and nothing of it. Writes nothing; never changes the other app.`,inputSchema:{type:"object",properties:{relation:{type:"string",description:"The relation, by name (forHouse) or as <kind>.<relation> (scenario.forHouse)."},query:{type:"string",description:"Words to find by, in the other app's names; empty for the first few."},of:{type:"string",description:"A record here whose linked records to read, instead of finding."},limit:{type:"number",description:"Most records to return; at most 20."}},required:["relation"],additionalProperties:!1},mutating:!1,annotations:_("Find a record in another app")};function kn(t,n){return t===void 0?[]:t==="keep"&&!n?[se,Ge]:[se]}var Sn="An argument that names a record takes its id or its name.",Ze=[...oe.map(t=>t.name),Ve.name,se.name,Ge.name,Ke.name,...ne.map(t=>t.name)],Ye=64;function x(t){let{line:n,...e}=t;return e}function Ue(t){return{...t,...t.introduces?{introduces:t.introduces.map(x)}:{},...t.resolves?{resolves:t.resolves.map(x)}:{},...t.violationsAfter?{violationsAfter:t.violationsAfter.map(x)}:{}}}function vn(t){let n=t.normalize("NFKD").replace(/\p{M}/gu,"").replace(/[^A-Za-z0-9_-]/g,"_");return n.length===0&&(n="act"),/^[A-Za-z_]/.test(n)||(n=`act_${n}`),n.slice(0,Ye)}function An(t){let n=new Set(Ze),e=new Map;for(let r of t){let i=vn(r),o=i;for(let a=2;n.has(o);a+=1)o=`${i.slice(0,Ye-`_${a}`.length)}_${a}`;n.add(o),e.set(r,o)}return e}function On(t,n){if(n.size===0)return t;let e=Object.fromEntries(Object.entries(t.properties??{}).filter(([i])=>!n.has(i))),r=(t.required??[]).filter(i=>!n.has(i));return{...t,properties:e,...t.required?{required:r}:{}}}function Rn(t,n,e){let r=X(t),i=C(t),o=r.nodeRefs.length>0?`${r.description}${/[.!?]$/.test(r.description)?"":"."} ${Sn}`:r.description;return{name:n,title:i,description:o,inputSchema:On(r.inputSchema,e),mutating:!0,annotations:{title:i,readOnlyHint:!1,destructiveHint:t.destructive===!0||(t.severs?.length??0)>0,idempotentHint:t.idempotent===!0,openWorldHint:!1},act:t.name}}function de(t){if(t===null||typeof t!="object")return JSON.stringify(t)??"null";if(Array.isArray(t))return`[${t.map(de).join(",")}]`;let n=t;return`{${Object.keys(n).filter(e=>n[e]!==void 0).sort().map(e=>`${JSON.stringify(e)}:${de(n[e])}`).join(",")}}`}function Tn(t){return`sha256:${Oe(de(t))}`}function _n(t,n,e,r,i,o=!1,a=!1){let d=An(t.map(f=>f.name)),s=[...kn(r,e),...o?[Ke]:[],...a?ne:[]];return{definitions:e?[...oe.filter(f=>!f.mutating),...s]:[...oe,Ve,...s,...t.filter(f=>n.has(f.name)).map(f=>Rn(f,d.get(f.name),i(f)))],names:d}}function lt(t,n={}){let e=n.author??{kind:"agent"},r=t.allMutations(),i=new Set(t.permittedMutations(e).map(m=>m.name)),{definitions:o,names:a}=_n(r,i,n.readOnly===!0,n.drafts?n.drafts.keep?"keep":"draw":void 0,m=>K(t.schema,t.policy,e,m),bn(t.schema),n.subscriptions!==void 0),d=Tn(o),s={app:n.app?.brand?.locale,appTimeZone:n.app?.brand?.timeZone},g=m=>le(s,m),f=m=>{if(!Ze.includes(m)){for(let[l,w]of a)if(w===m)return l;return a.has(m)?m:void 0}},b=(m,l)=>{let w=r.find(u=>u.name===m);if(!w)return{args:l,resolved:[]};let S={...l},c=[];for(let u of q(w.input)){let p=S[u.name];if(typeof p!="string"||p.trim()==="")continue;let y=t.resolveRef(u,p,e);if(!y.ok){let v=y.reason==="none"?` Nothing was changed. Use search_graph to look it up, then pass its id as ${u.name}.`:" Nothing was changed.";return{ok:!1,error:`${y.message}${v}`,argument:u.name,candidates:y.candidates}}y.by!=="id"&&(S[u.name]=y.id,c.push({argument:u.name,given:p,id:y.id,label:y.label}))}return{args:S,resolved:c}},h=async(m,l)=>{try{await mn();let w=o.find(c=>c.name===m)??o.find(c=>c.act===m);if(!w){let c=f(m);if(c){let u=t.permits({name:c,args:l},e);if(!u.ok)return{ok:!1,error:u.refusal.message,reason:"forbidden"}}return{ok:!1,error:`Unknown tool "${m}". Available: ${o.map(u=>u.name).join(", ")}`}}if(w.mutating&&n.readOnly)return{ok:!1,error:`"${m}" changes the graph, and this seat is read-only.`,reason:"forbidden"};if(w.act!==void 0){let c=b(w.act,l);if("ok"in c)return c;let u=w.act,p=g(()=>E(t,e,t.apply({name:u,args:c.args},{...n.author?{author:n.author}:{},...ie(n.via)})));return{ok:!0,data:{batch:p.batch,intent:p.intent,introduces:p.introduces.map(x),resolves:p.resolves.map(x),...c.resolved.length>0?{resolved:c.resolved}:{}},diff:p.diff}}let S=t.seenBy(e);switch(w.name){case"search_graph":{let c=typeof n.places=="function"?n.places():n.places,u=typeof l.subject=="string"?l.subject:void 0,p=$e(S,String(l.query??""),{principal:e,rank:n.near,archived:be(l.archived),limit:typeof l.limit=="number"&&l.limit>0?Math.min(l.limit,20):20,...c?{places:c}:{},...u?{subject:u,from:[u]}:{}}),y=p.later?await p.later:p;return{ok:!0,data:(await H()).searchRead(y,We(y,B(S,e))),reads:y.hits.flatMap(v=>v.about==="node"?[v.id]:[])}}case"get_graph":return{ok:!0,...(await H()).graphRead(S,B(S,e),l)};case"get_node":{let c=String(l.id??""),u=c,p;if(!S.graph.getNode(c)){let v=c.trim()===""?void 0:t.resolveRef({name:"id",kinds:["*"]},c,e);if(v?.ok)u=v.id,p={argument:"id",given:c,id:u,label:v.label};else return v?.reason==="ambiguous"?{ok:!1,error:v.message,argument:"id",candidates:v.candidates}:{ok:!1,error:`No node "${c}".`}}let y=(await H()).nodeRead(S,B(S,e),u,l);return{ok:!0,data:p?{...y.data,resolved:[p]}:y.data,reads:y.reads}}case"describe_place":{let c=n.app??{name:"",schema:t.schema},u=typeof l.width=="number"&&Number.isFinite(l.width)&&l.width>0?l.width:1440,{describePlace:p}=await fn(),y=p(t,e,String(l.place??""),{app:c,width:u});if(!y.ok)return{ok:!1,error:`${y.error} The places are: ${y.places.join(", ")}.`};let v=new Set,M=I=>{for(let $ of I)for(let T of $.groups??[])for(let N of T.items)v.add(N.id),M(N.parts)};return M(y.description.parts),{ok:!0,data:y.description,reads:[...v]}}case"find_linked":return wn(S,e,l,n.linked);case"draft_view":case"keep_lens":{let c=n.app??{name:"",schema:t.schema};return(await hn()).runDraftTool(w.name,l,{app:c,principal:e,...n.drafts?{drafts:n.drafts}:{}})}case"get_violations":{let c=S.violations(l.context);return{ok:!0,...(await H()).violationsRead(c,l)}}case"get_affordances":{let c=l.selection??[];return{ok:!0,data:Ne(S,c,{...typeof n.derive=="function"?n.derive():n.derive,...n.author?{principal:n.author}:{},...l.context?{context:l.context}:{}}),reads:c.filter(p=>S.graph.has(p))}}case"preview_mutation":{let c=String(l.mutation),u=f(c)??c,p=b(u,l.args??{});if("ok"in p)return p;let y=t.missingFor({name:u,args:p.args},e);if(y)return{ok:!1,error:y.message,reason:"missing"};let v=E(t,e,t.preview({name:u,args:p.args},void 0,{author:e})),M=Ue(v);return{ok:!0,data:p.resolved.length>0?{...M,resolved:p.resolved}:M}}case"act_on_several":{let c=String(l.act??""),u=f(c)??c,p=r.find(O=>O.name===u);if(!p||!i.has(u)){let O=p?t.permits({name:u,args:{}},e):void 0;return O&&!O.ok?{ok:!1,error:O.refusal.message,reason:"forbidden"}:{ok:!1,error:`There is no act "${c}" this seat may run. Nothing was changed.`,reason:"invalid"}}let y=p.subject;if(!y)return{ok:!1,error:`"${C(p)}" does not act on a record, so it cannot be run on several. Nothing was changed.`,reason:"invalid"};let v=Array.isArray(l.records)?l.records.filter(O=>typeof O=="string"&&O.trim()!==""):[];if(v.length===0)return{ok:!1,error:"Name at least one record. Nothing was changed.",reason:"invalid"};let M=[],I=[];for(let O of v.slice(0,200)){let P=t.resolveRef({name:y.arg,kinds:y.kinds},O,e);if(!P.ok)return{ok:!1,error:`${P.message} Nothing was changed.`,argument:"records",candidates:P.candidates};M.push(P.id),P.by!=="id"&&I.push({argument:"records",given:O,id:P.id,label:P.label})}let $=b(u,{...l.args??{}});if("ok"in $)return $;let T=(await yn()).actOnSeveral(t,{mutation:u,subject:y.arg,args:$.args},M,{author:e,...ie(n.via)}),N=T.result?E(t,e,T.result):void 0;return{ok:!0,data:{...T.batch?{batch:T.batch,intent:T.intent}:{},applied:T.applied,unchanged:T.unchanged,refused:T.refused.map(O=>({record:O.id,label:O.label,error:O.message,reason:O.reason})),...T.allOrNothing?{keptNone:!0}:{},...N?{introduces:N.introduces.map(x),resolves:N.resolves.map(x)}:{},...I.length>0||$.resolved.length>0?{resolved:[...I,...$.resolved]}:{}},...N?{diff:N.diff}:{}}}case"subscribe":case"unsubscribe":case"list_subscriptions":{let c=await(await gn()).runSubscriptionTool(w.name,l,{store:t,principal:n.subscriber??e,app:n.app?.name??"app",subscriptions:n.subscriptions});return c.ok?{ok:!0,data:c.data}:{ok:!1,error:c.error}}case"list_suggestions":{let c=_e(t,e).map(u=>{let p=F(u.author,{graph:S.graph,schema:t.schema});return{id:u.id,intent:u.intent,by:p,at:u.at,about:u.about,...u.lineage?{basis:{untrusted:!0,authoredBy:p,text:u.lineage.basis},...u.lineage.confidence!==void 0?{confidence:u.lineage.confidence}:{}}:{}}});return{ok:!0,data:{suggestions:c},reads:[...new Set(c.flatMap(u=>u.about))]}}case"accept_suggestion":case"decline_suggestion":{let c=String(l.suggestion??""),u={author:e,...ie(n.via)},p=w.name==="accept_suggestion"?xe(t,c,u):Me(t,c,u),y=E(t,e,p);return{ok:!0,data:{batch:y.batch,intent:y.intent,introduces:y.introduces.map(x),resolves:y.resolves.map(x)},diff:y.diff}}case"undo_batch":{let c=String(l.batch),u=l.include??[],p=S.canUndo([c,...u]);if(!p.ok)return{ok:!1,error:p.message};let y=E(t,e,t.undo([c,...u],{...n.author?{author:n.author}:{}}));return{ok:!0,data:Ue(y),diff:y.diff}}default:return{ok:!1,error:`Unknown tool "${m}".`}}}catch(w){let{reason:S,wouldNeed:c}=we(w);return{ok:!1,error:w instanceof Error?w.message:String(w),reason:S,...c?{wouldNeed:c}:{}}}},k=new Set,A=m=>{for(let l of k)l(m)};return{definitions:o,hash:d,...n.author?{author:n.author}:{},onDiff(m){return t.subscribe(m)},onCall(m){return k.add(m),()=>k.delete(m)},async call(m,l){let w=(o.find(p=>p.name===m)??o.find(p=>p.act===m))?.mutating??!1,S={name:m,args:l,mutating:w,at:new Date().toISOString()};A({...S,phase:"running"});let c=p=>(A(p.ok?{...S,phase:"ok",...!w&&p.reads?{reads:p.reads}:{}}:{...S,phase:"failed",error:p.error}),p),u=await h(m,l);return c(u.ok&&!w?{...u,data:(await H()).withinReadChars(m,u.data)}:u)}}}function ie(t){let n=typeof t=="function"?t():t;return n?{via:n}:{}}export{de as a,lt as b};
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{c as _e,d as xe,e as Me}from"./chunk.64WM4IBI.js";import{q as $e}from"./chunk.VW2VCPJX.js";import{a as Ne}from"./chunk.UKAPFIPJ.js";import{f as K}from"./chunk.IW7YFPGG.js";import{a as E}from"./chunk.Q7RQC3F7.js";import{a as Re,b as G,d as Te}from"./chunk.HDRD33II.js";import{a as ge}from"./chunk.H7KCWCB4.js";import{Aa as U,Ca as fe,Cb as ve,Ea as pe,Fa as V,Fb as Ae,Ib as q,K as le,Lc as Oe,Ma as me,Na as he,Qa as ye,Wa as F,Za as be,a as ce,da as C,vb as we,xa as ue,yb as ke,zb as Se}from"./chunk.AS4CQBOQ.js";var J=(t,n,e)=>{(t[n]===void 0||e>t[n])&&(t[n]=e)},D=(t,n,e)=>{(t[n]===void 0||e<t[n])&&(t[n]=e)},Z=(t,n)=>{t.format=n,n.includes("int")&&(t.isInt=!0)},Pe=(t,n)=>{t.mime=t.mime?t.mime.filter(e=>n.includes(e)):[...n]},Je=(t,n)=>{t.multipleOf??=[],t.multipleOf.includes(n)||t.multipleOf.push(n)},De=(t,n)=>(t.patterns??=new Set).add(n),Xe={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function z(t){let n={},{def:e,bag:r}=t._zod,i=t._zod.traits.has("$ZodCheck")?[t,...e.checks??[]]:e.checks??[];for(let o of i){let a=o._zod.def;switch(a.check){case"greater_than":J(n,a.inclusive?"minimum":"exclusiveMinimum",a.value);break;case"less_than":D(n,a.inclusive?"maximum":"exclusiveMaximum",a.value);break;case"multiple_of":Je(n,a.value);break;case"number_format":{Z(n,a.format);let d=Xe[a.format];d&&(J(n,"minimum",d[0]),D(n,"maximum",d[1]));break}case"bigint_format":Z(n,a.format);break;case"min_length":case"min_size":J(n,"minimum",a.minimum);break;case"max_length":case"max_size":D(n,"maximum",a.maximum);break;case"length_equals":J(n,"minimum",a.length),D(n,"maximum",a.length);break;case"size_equals":J(n,"minimum",a.size),D(n,"maximum",a.size);break;case"string_format":Z(n,a.format),a.pattern&&De(n,a.pattern),(a.format==="base64"||a.format==="base64url")&&(n.contentEncoding=a.format),(a.local||a.precision===-1)&&(n.laxFormat=!0);break;case"mime_type":Pe(n,a.mime);break}}r.minimum!==void 0&&J(n,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&J(n,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&D(n,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&D(n,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&Je(n,r.multipleOf),r.format!==void 0&&(n.format??=r.format,r.format.includes("int")&&(n.isInt=!0)),r.mime&&Pe(n,r.mime);for(let o of r.patterns??[])De(n,o);return n}var Qe={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""};function j(t){let n=t._zod.def;return n.type==="pipe"&&n.in._zod.traits.has("$ZodTransform")?j(n.out):n.type==="catch"?j(n.innerType):t._zod.optin}var en=new Set(["promise","optional","nonoptional","nullable","readonly","default","prefault","catch"]);function R(t,n=new Set){if(n.has(t))return!1;n.add(t);let e=t._zod.def,r=e.type;return r==="transform"?!0:r==="array"?R(e.element,n):r==="set"?R(e.valueType,n):r==="lazy"?R(e.getter(),n):en.has(r)?R(e.innerType,n):r==="intersection"?R(e.left,n)||R(e.right,n):r==="record"||r==="map"?R(e.keyType,n)||R(e.valueType,n):r==="pipe"?t._zod.traits.has("$ZodCodec")||R(e.in,n)||R(e.out,n):r==="object"?Object.values(e.shape).some(i=>R(i,n)):r==="union"?e.options.some(i=>R(i,n)):r==="tuple"?e.items.some(i=>R(i,n))||(e.rest?R(e.rest,n):!1):!1}function nn(t){let n=Object.values(t).filter(e=>typeof e=="number");return Object.entries(t).filter(([e])=>n.indexOf(+e)===-1).map(([,e])=>e)}function Ie(t){let n=t.anyOf;if(!Array.isArray(n)||n.length===0||t.type!==void 0)return;let e=[];for(let r of n){if(!r||typeof r!="object")return;Ie(r);let i=Object.keys(r);if(i.length!==1||i[0]!=="type")return;for(let o of[r.type].flat()){if(typeof o!="string")return;e.includes(o)||e.push(o)}}delete t.anyOf,t.type=e.length===1?e[0]:e}var je=new Set(["type","properties","required","additionalProperties"]),Ee=t=>{let n=t.additionalProperties;return n&&typeof n=="object"&&Object.keys(n).length?n:null},ze=(t,n)=>JSON.stringify(t)===JSON.stringify(n);function Y(t){for(let i of t){if(typeof i!="object"||i.type!=="object")return null;for(let o in i)if(!je.has(o))return null}let n={},e=new Set;for(let i of t){for(let o in i.properties){if(Object.prototype.hasOwnProperty.call(n,o))continue;let a=[];for(let d of t){let s=d.properties?.[o]??Ee(d);s&&!a.some(g=>ze(g,s))&&a.push(s)}n[o]=a.length===1?a[0]:Y(a)??{allOf:a}}for(let o of i.required??[])e.add(o)}let r={type:"object",properties:n};if(e.size&&(r.required=[...e]),t.every(i=>i.additionalProperties===!1))r.additionalProperties=!1;else{let i=[];for(let o of t){let a=Ee(o);a&&!i.some(d=>ze(d,a))&&i.push(a)}i.length===1?r.additionalProperties=i[0]:i.length>1&&(r.additionalProperties={allOf:i})}return r}function tn(t){let n=t.allOf;if(!Array.isArray(n)||n.length<2)return;for(let i of je)if(i in t)return;let e=n.filter(i=>Array.isArray(i.oneOf)||Array.isArray(i.anyOf)),r;if(!e.length)r=Y(n);else{let i=e[0],o=Array.isArray(i.oneOf)?"oneOf":"anyOf";if(Object.keys(i).length!==1)return;let a=n.filter(s=>s!==i),d=i[o].map(s=>Y([...a,s]));if(d.some(s=>!s))return;r={[o]:d}}r&&(delete t.allOf,Object.assign(t,r))}function He(t){let n=t;for(let k of["anyOf","oneOf"]){let A=n[k];if(!Array.isArray(A))continue;let m=A.map(He);m.some((l,w)=>l!==A[w])&&(n={...n,[k]:m})}let e=[n.type].flat(),r=!e.includes("string")&&e.some(k=>k==="number"||k==="integer"),i=n.enum??(n.const!==void 0?[n.const]:void 0);if(!r&&!i?.some(k=>typeof k=="number"))return n;let{minimum:o,maximum:a,exclusiveMinimum:d,exclusiveMaximum:s,multipleOf:g,format:f,id:b,...h}=n;return h.enum?h.enum=h.enum.map(k=>typeof k=="number"?String(k):k):typeof h.const=="number"&&(h.const=String(h.const)),r&&(h.type="string",i||(h.pattern=e.includes("number")?"^-?\\d+(?:\\.\\d+)?$":"^-?\\d+$")),h}var W=class{constructor(n,e){this.override=n;this.refs=e}done=new Map;path=[];cyclic=new Map;write(n,e=!1){let r=this.refs.get(n);if(r!==void 0&&!e)return{$ref:r};if(this.path.includes(n))return this.cyclic.has(n)||this.cyclic.set(n,""),{};let i=this.done.get(n);if(i)return i;this.path.push(n);try{let o=this.written(n);return this.done.set(n,o),o}finally{this.path.pop()}}written(n){let e={},r,i=n._zod.toJSONSchema?.();i?Object.assign(e,i):r=this.process(n,e);let o=ce.get(n);if(o)for(let d of Object.keys(o))e[d]=o[d];R(n)&&(delete e.examples,delete e.default),"_prefault"in e&&(e.default??=e._prefault,delete e._prefault);let a=e;if(r){let d=this.write(r);a={...e};for(let s of Object.keys(d))s in e||(a[s]=d[s])}return this.override({zodSchema:n,jsonSchema:a}),Ie(a),n._zod.def.type==="intersection"&&tn(a),a}process(n,e){let r=n._zod.def;switch(r.type){case"string":{e.type="string";let{minimum:i,maximum:o,format:a,patterns:d,contentEncoding:s,laxFormat:g}=z(n);if(typeof i=="number"&&(e.minLength=i),typeof o=="number"&&(e.maxLength=o),a&&(e.format=Qe[a]??a,(e.format===""||a==="time"||g)&&delete e.format),s&&(e.contentEncoding=s),d&&d.size>0){let f=[...d];f.length===1?e.pattern=f[0].source:e.allOf=f.map(b=>({pattern:b.source}))}return}case"number":{let{minimum:i,maximum:o,multipleOf:a,exclusiveMinimum:d,exclusiveMaximum:s,isInt:g}=z(n);if(e.type=g?"integer":"number",typeof d=="number"&&d>=(i??Number.NEGATIVE_INFINITY)?e.exclusiveMinimum=d:typeof i=="number"&&(e.minimum=i),typeof s=="number"&&s<=(o??Number.POSITIVE_INFINITY)?e.exclusiveMaximum=s:typeof o=="number"&&(e.maximum=o),a){let[f,...b]=new Set(a.filter(h=>Number.isFinite(h)&&h!==0).map(Math.abs));f!==void 0&&(e.multipleOf=f),b.length&&(e.allOf=[...e.allOf??[],...b.map(h=>({multipleOf:h}))])}return}case"boolean":case"success":e.type="boolean";return;case"null":e.type="null";return;case"never":e.not={};return;case"enum":{let i=nn(r.entries);i.length===0?e.not={}:(i.every(o=>typeof o=="number")&&(e.type="number"),i.every(o=>typeof o=="string")&&(e.type="string"),e.enum=i);return}case"literal":{let i=r.values.filter(o=>o!==void 0).map(o=>typeof o=="bigint"?Number(o):o);if(r.values.length===0)e.not={};else if(i.length===1)e.type=i[0]===null?"null":typeof i[0],e.const=i[0];else if(i.length>1){for(let o of["number","string","boolean"])i.every(a=>typeof a===o)&&(e.type=o);i.every(o=>o===null)&&(e.type="null"),e.enum=i}return}case"template_literal":e.type="string",e.pattern=n._zod.pattern.source;return;case"file":{e.type="string",e.format="binary",e.contentEncoding="binary";let{minimum:i,maximum:o,mime:a}=z(n);i!==void 0&&(e.minLength=i),o!==void 0&&(e.maxLength=o),a&&(a.length===0?e.not={}:a.length===1?e.contentMediaType=a[0]:e.anyOf=a.map(d=>({contentMediaType:d})));return}case"array":{let{minimum:i,maximum:o}=z(n);typeof i=="number"&&(e.minItems=i),typeof o=="number"&&(e.maxItems=o),e.type="array",e.items=this.write(r.element);return}case"object":{let i=r.shape;e.type="object";let o={};e.properties=o;for(let d in i)Object.defineProperty(o,d,{value:this.write(i[d]),writable:!0,enumerable:!0,configurable:!0});let a=Object.keys(i).filter(d=>j(i[d])===void 0);a.length>0&&(e.required=a),r.catchall?._zod.def.type==="never"?e.additionalProperties=!1:r.catchall&&(e.additionalProperties=this.write(r.catchall));return}case"union":e[r.inclusive===!1?"oneOf":"anyOf"]=r.options.map(i=>this.write(i));return;case"intersection":{let i=d=>"allOf"in d&&Object.keys(d).length===1,o=this.write(r.left),a=this.write(r.right);e.allOf=[...i(o)?o.allOf:[o],...i(a)?a.allOf:[a]];return}case"tuple":{let i=r.items;e.type="array",e.prefixItems=i.map(s=>this.write(s)),r.rest?e.items=this.write(r.rest):e.items=!1;let o=i.length;for(;o>0&&j(i[o-1])!==void 0;)o-=1;o>0&&(e.minItems=o),r.rest||(e.maxItems=i.length);let{minimum:a,maximum:d}=z(n);typeof a=="number"&&(e.minItems=a),typeof d=="number"&&(e.maxItems=d);return}case"record":{let i=r.keyType;e.type="object";let o=z(i).patterns;if(r.mode==="loose"&&o&&o.size>0){let d=this.write(r.valueType),s={};for(let g of o)s[g.source]=d;e.patternProperties=s}else e.propertyNames=He(this.write(i)),e.additionalProperties=this.write(r.valueType);let a=i._zod.values;if(a&&!r.partial&&j(r.valueType)===void 0){let d=[...a].filter(s=>typeof s=="string"||typeof s=="number");d.length>0&&(e.required=d.map(String))}return}case"nullable":e.anyOf=[this.write(r.innerType),{type:"null"}];return;case"default":case"prefault":{let i=r.defaultValue,o,a=!1,d=JSON.stringify(i,(s,g)=>typeof g=="bigint"?(a=!0,null):g);return!a&&d!==void 0&&(o=JSON.parse(d)),a||(e[r.type==="default"?"default":"_prefault"]=o),r.innerType}case"catch":{try{e.default=r.catchValue(void 0)}catch{}return r.innerType}case"readonly":return e.readOnly=!0,r.innerType;case"pipe":return r.in._zod.traits.has("$ZodTransform")?r.out:r.in;case"lazy":return n._zod.innerType;case"optional":case"nonoptional":case"promise":return r.innerType;default:return}}};function Le(t,n=()=>{}){let e=t,r=new W(n,new Map),i=r.write(e,!0);if(r.cyclic.size>0){let o=new Map,a=0,d=[];for(let g of r.cyclic.keys())if(g===e)o.set(g,"#");else{let f=`__schema${a++}`;o.set(g,`#/$defs/${f}`),d.push([g,f])}r=new W(n,o),i=r.write(e,!0);let s={};for(let[g,f]of d)s[f]=r.write(g,!0);d.length>0&&(i={...i,$defs:s})}return JSON.parse(JSON.stringify({$schema:"https://json-schema.org/draft/2020-12/schema",...i}))}function Fe(t){return Le(t,an)}var rn={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string"},on={phone:"A phone number as it is written, like +1 555 123 4567 or 020 7946 0958 ext. 12.",place:"An address or a place's name, as a person would search a map for it.",duration:"A length of time in whole minutes: 90 is 1 h 30 min."};function an(t){ue(t.zodSchema)&&(t.jsonSchema["x-graview-app-link"]=!0);let n=pe(t.zodSchema);if(n&&(t.jsonSchema.type==="string"||t.jsonSchema.type==="array")){t.jsonSchema["x-graview-linked"]={address:n.address,kinds:[...n.kinds],cardinality:n.cardinality};let s=n.kinds.join(" or "),g=`${n.cardinality==="many"?"Records":"A record"}: a ${s} in the app ${n.address}, as "${n.kinds[0]}:<id>" \u2014 an id found there with find_linked. Linking never changes that app.`,f=t.jsonSchema.description;typeof f=="string"&&f.includes(g)||(t.jsonSchema.description=`${typeof f=="string"&&f?`${f.replace(/\.?$/,".")} `:""}${g}`)}if(ye(t.zodSchema)&&(t.jsonSchema["x-graview-repeat"]=!0,!t.jsonSchema.type&&!t.jsonSchema.anyOf&&!t.jsonSchema.oneOf&&Object.assign(t.jsonSchema,sn())),ge(t.zodSchema)){t.jsonSchema.contentMediaType="text/markdown";let s=t.jsonSchema.description;typeof s=="string"&&s.endsWith("Written in Markdown.")||(t.jsonSchema.description=`${typeof s=="string"&&s?`${s.replace(/\.?$/,".")} `:""}Written in Markdown.`)}let e=Ae(t.zodSchema);if(e){let s=t.jsonSchema;s["x-graview-type"]=e,e==="duration"&&(s["x-graview-unit"]="minutes"),s.description??=on[e]}let r=ve(t.zodSchema,!1);if(r){let s=Re(r);t.jsonSchema["x-graview-format"]=s.format??"unit",s.currency&&(t.jsonSchema["x-graview-currency"]=s.currency),s.unit&&s.format!=="money"&&(t.jsonSchema["x-graview-unit"]=s.unit);let g=t.jsonSchema.description;t.jsonSchema.description=typeof g=="string"&&g.length>0?`${g} ${G(s)}`:G(s)}let i=t.zodSchema._zod?.def;if(!i||i.type!=="string"||typeof i.format!="string"||i.format==="regex")return;let o=t.jsonSchema,a=(i.checks??[]).map(s=>s._zod?.def).filter(s=>s?.format==="regex"&&s.pattern instanceof RegExp).map(s=>s.pattern.source);delete o.pattern;let d=o.allOf;Array.isArray(d)&&d.every(s=>typeof s=="object"&&s!==null&&Object.keys(s).length===1&&"pattern"in s)&&delete o.allOf,o.format=rn[i.format]??i.format,a.length===1?o.pattern=a[0]:a.length>1&&(o.allOf=a.map(s=>({pattern:s})))}function X(t){let n=q(t.input),e=Fe(t.input),r=e.properties??{};if(ke(t)){let i=t.creates.join(" | ");r.id={type:"string",minLength:1,description:`Optional: the id for the ${i} this makes. Refused if the graph already has it; left out, one is minted from the label.`},e.properties=r}Se(t)&&(e.additionalProperties=!1);for(let i of n){let o=r[i.name];if(!o)continue;let a=i.kinds.includes("*")?"any node kind":i.kinds.join(" | ");o.description=[o.description,`Id of a node (${a}).`].filter(Boolean).join(" ")}return{name:t.name,...t.title===void 0?{}:{title:t.title},description:t.description??t.title??t.name,inputSchema:e,nodeRefs:n}}function sn(){let t={type:"string",pattern:"^\\d{4}-\\d{2}-\\d{2}$"},n=(e,r)=>({type:"integer",minimum:e,maximum:r});return{type:"object",description:'How the date beside it repeats; the date is the first occurrence. "on" is weekdays for "week", days of the month (-1 the last) for "month".',properties:{every:{type:"string",enum:[...he]},interval:n(1,99),on:{type:"array",minItems:1,maxItems:31,items:{anyOf:[{type:"string",enum:[...me]},n(-1,31)]}},until:t,count:n(1,1e3),except:{type:"array",maxItems:500,items:t},continues:{type:"string",maxLength:200}},required:["every"],additionalProperties:!1}}function qe(t){let n=new Set;for(let e=t;e;e=e.onBehalfOf)e.id!==void 0&&n.add(`${e.kind}:${e.id}`);return n}function B(t,n){let e=qe(n),r=f=>{if(f.kind==="rule")return!1;let b=qe(f);if(b.size===0)return!1;for(let h of b)if(e.has(h))return!1;return!0},i,o=()=>{if(i)return i;i=new Map;for(let f of t.log.live()){if(f.undoes!==void 0)continue;let b=r(f.author)?f.author:void 0;for(let h of f.primitives){h.op==="remove-node"&&i.delete(h.node.id);let k=h.op==="add-node"?h.node.id:h.op==="patch-node"?h.id:void 0;if(k===void 0)continue;let A=h.op==="add-node"?Object.keys(h.node):Object.keys(h.after),m=i.get(k);(h.op==="add-node"||!m)&&i.set(k,m=new Map);for(let l of A)l==="id"||l==="kind"||(b?m.set(l,b):m.delete(l))}}return i},a=t.schema,d=new Map,s=(f,b)=>{let h=`${f}\0${b}`,k=d.get(h);if(k===void 0){let A=a.tryDefinition(f)?.fields?.shape;k=A!==void 0&&b in A&&Te(A[b]).type==="text",d.set(h,k)}return k},g=f=>t.graph.getNode(f)?.kind;return{prose:s,say:f=>F(f,{graph:t.graph,schema:a}),fieldBy(f,b){let h=g(f);if(!(h===void 0||!s(h,b)))return o().get(f)?.get(b)},recordBy(f){let b=g(f),h=o().get(f);if(b===void 0||!h)return;let k;for(let[A,m]of h)s(b,A)&&(k=m);return k}}}var Q=(t,n,e)=>({untrusted:!0,authoredBy:e.say(n),text:t}),dn="the host's ranker";function We(t,n){return{...t,hits:t.hits.map(e=>{if(e.about!=="node")return e;e.why.by==="meaning"&&e.why.matched!==void 0&&(e={...e,why:{...e.why,matched:{untrusted:!0,authoredBy:dn,text:e.why.matched}}});let r=n.recordBy(e.id);if(!r)return e;let i=n.prose(e.kind,e.why.field)?n.fieldBy(e.id,e.why.field):r;return{...e,label:Q(e.label,r,n),...e.apart!==void 0?{apart:Q(e.apart,r,n)}:{},why:i?{...e.why,fragment:Q(e.why.fragment,i,n)}:e.why}})}}var ee=(t,n,e)=>({title:t,readOnlyHint:n,destructiveHint:!1,idempotentHint:e,openWorldHint:!1}),cn={name:"subscribe",title:"Notify me when something happens",description:`Subscribe the person you act for to be told when something happens in this app \u2014 their host delivers it (an email, a push). on is one of: "act" (an act runs; give act, its declared name, and/or record), "created" (a record of kind is added), "changed" (a record of kind, or the one record, changes), "reaches" (a record of kind, or the one record, comes to satisfy condition, an expression in the app's rule language such as done == true or amount > 100). They are told only of changes someone else made, unless alsoMine is true, and only of records they may see. Returns the subscription and its sentence. Changes nothing in the app.`,inputSchema:{type:"object",properties:{on:{type:"string",enum:["act","created","changed","reaches"],description:"What to be told of."},act:{type:"string",description:"An act's declared name, for on: act."},kind:{type:"string",description:"A kind, for created, changed and reaches."},record:{type:"string",description:"One record, by id or name: for act, changed and reaches."},condition:{type:"string",description:"For reaches: what the record should come to satisfy, in the rule language (done == true)."},alsoMine:{type:"boolean",description:"Also when the person themselves made the change; false when unsaid."}},required:["on"],additionalProperties:!1},mutating:!1,annotations:ee("Notify me when something happens",!1,!1)},ln={name:"unsubscribe",title:"Stop notifying me",description:"Take away one of the person's subscriptions, by the id list_subscriptions or subscribe answered. Changes nothing in the app.",inputSchema:{type:"object",properties:{id:{type:"string",description:"The subscription's id."}},required:["id"],additionalProperties:!1},mutating:!1,annotations:ee("Stop notifying me",!1,!0)},un={name:"list_subscriptions",title:"What I am notified of",description:`List what the person you act for is told of in this app: each subscription's id and its sentence ("When someone else adds a task").`,inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:ee("What I am notified of",!0,!0)},ne=[cn,ln,un];var L=t=>{let n;return()=>n??=t().catch(e=>{throw n=void 0,e})},fn=L(()=>(__graviewPreload(import.meta.url,["./chunk.RX2M4C5W.js","./chunk.FOQ27RAR.js","./chunk.ZIEHF67C.js","./chunk.UHX4WTM7.js","./chunk.IKX4VDTW.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.SGKK4UKP.js"))),pn=()=>(__graviewPreload(import.meta.url,["./chunk.Q7RQC3F7.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.QGVLJTZS.js")).catch(()=>{}),mn=async()=>{(await pn())?.judgeWithLines()},H=L(()=>(__graviewPreload(import.meta.url,["./chunk.WVUJXDXZ.js","./chunk.ZIEHF67C.js","./chunk.UHX4WTM7.js","./chunk.IKX4VDTW.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.H7KCWCB4.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.PC6PID5X.js"))),hn=L(()=>(__graviewPreload(import.meta.url,["./chunk.YVONXFKE.js","./chunk.G4JJXA63.js","./chunk.WBHM5I3I.js","./chunk.FOQ27RAR.js","./chunk.WAB7UDHU.js","./chunk.IW7YFPGG.js","./chunk.Q5WEOX3Q.js","./chunk.4OGOTHRD.js","./chunk.6YD2DLIC.js","./chunk.Q7RQC3F7.js","./chunk.WVUJXDXZ.js","./chunk.ZIEHF67C.js","./chunk.UHX4WTM7.js","./chunk.IKX4VDTW.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.HDRD33II.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.GQHAAKJG.js"))),yn=L(()=>(__graviewPreload(import.meta.url,["./chunk.47RTA6M3.js","./chunk.RX2M4C5W.js","./chunk.FOQ27RAR.js","./chunk.UKAPFIPJ.js","./chunk.UT6642FC.js","./chunk.ZIEHF67C.js","./chunk.UHX4WTM7.js","./chunk.IKX4VDTW.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.HDRD33II.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.ZL7ZBJUU.js"))),gn=L(()=>(__graviewPreload(import.meta.url,["./chunk.Z6TMIAAB.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.63JLXGYX.js"))),bn=t=>t.definitions.some(n=>V(n).size>0),Be=t=>({value:U(t),label:t.label,...t.describe?{describe:t.describe}:{},...t.card?{card:t.card}:{},fields:t.fields,...t.app?{app:t.app}:{}});async function wn(t,n,e,r){let i=String(e.relation??""),[o,a]=i.includes(".")?i.split(".",2):[void 0,i],d=t.schema.definitions.flatMap(l=>[...V(l)].map(([w,S])=>({kind:l.kind,name:w,relation:S}))),s=d.filter(l=>l.name===a&&(o===void 0||l.kind===o));if(s.length!==1){let l=d.map(w=>`${w.kind}.${w.name}`).join(", ")||"none";return{ok:!1,error:`${s.length===0?`No relation to another app is called "${i}"`:`"${i}" names a relation of several kinds`}. The relations to other apps are: ${l}.`}}let{kind:g,name:f,relation:b}=s[0];if(!r)return{ok:!1,error:`This seat cannot read ${b.address}: its host reads no other app's records. Nothing was changed.`};let h={kind:n.kind,...n.id===void 0?{}:{id:n.id},...n.roles?{roles:n.roles}:{}},k=typeof e.of=="string"?e.of:void 0;if(k!==void 0){let l=t.graph.getNode(k);if(!l||l.kind!==g)return{ok:!1,error:`No ${g} "${k}".`};let w=fe(l[f],b),S=await Promise.all(w.map(c=>Promise.resolve().then(()=>r.resolve(c,h)).catch(()=>null)));return{ok:!0,data:{relation:`${g}.${f}`,app:b.address,records:S.map((c,u)=>c===null?{value:U(w[u]),missing:!0}:"denied"in c?{denied:!0,said:"linked record (no access)"}:Be(c))},reads:[k]}}let A=typeof e.limit=="number"&&e.limit>0?Math.min(e.limit,20):20,m=await Promise.resolve().then(()=>r.find({address:b.address,kinds:b.kinds,query:String(e.query??""),limit:A},h)).catch(()=>[]);return Array.isArray(m)?{ok:!0,data:{relation:`${g}.${f}`,app:b.address,records:m.map(Be),link:`edit-${g} with ${f} set to a record's value`}}:{ok:!0,data:{relation:`${g}.${f}`,app:b.address,denied:!0,said:"linked record (no access)"}}}var _=t=>({title:t,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}),Ce={description:'Which records: false (the default) the live ones, true only the archived ones, "all" both. An archived record is set aside, not gone: unarchive-<kind> brings it back.',anyOf:[{type:"boolean"},{type:"string",enum:["all"]}]},te={type:"number",description:"Where the page starts; 0 when unsaid."},oe=[{name:"search_graph",title:"Find by name",description:"Find things by name: records whose name or readable fields carry the words, and the kinds, places and rules the words name \u2014 each with why it matched. Reach for this before get_graph when you know what something is called. Words match the start of words, case and accents aside; key:value tokens narrow as a list's filter does (done:false, is:any for past records, kind:<kind>). Pass subject (a node id) to get the acts you may run on it as hits too. When few records match exactly, records with a near word follow \u2014 a typo, another form of the word, a meaning \u2014 each with near: true and why.matched, the record's own word that answered.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Words, with optional key:value conditions."},limit:{type:"number",description:"Most hits to return; at most 20."},subject:{type:"string",description:"A node id whose acts to include."},archived:Ce},required:["query"],additionalProperties:!1},mutating:!1,annotations:_("Find by name")},{name:"get_graph",title:"Read the graph",description:"Read the graph, 25 nodes a page: their fields, the edges out of them, and how many more. Start here when you need the shape of the domain rather than one thing in it.",inputSchema:{type:"object",properties:{offset:te,archived:Ce},additionalProperties:!1},mutating:!1,annotations:_("Read the graph")},{name:"get_node",title:"Read one node",description:"Read one node: its fields, its links (id, kind and label, 20 each way a page), the violations that implicate it, and its computed values: read-only fields worked out from what you can see, which no act sets. Use this to check a thing before you change it.",inputSchema:{type:"object",properties:{id:{type:"string",description:"A node's id, or its name."},offset:te},required:["id"],additionalProperties:!1},mutating:!1,annotations:_("Read one node")},{name:"get_violations",title:"List the problems",description:"List the invariant violations the graph currently has, 20 a page, with the repairs that would resolve each one. Read this before proposing work: a rule that is already broken is more urgent than anything you could add.",inputSchema:{type:"object",properties:{offset:te,context:{type:"object",description:"Evaluation context, e.g. { weekStart }."}},additionalProperties:!1},mutating:!1,annotations:_("List the problems")},{name:"get_affordances",title:"Ask what can be done",description:"Ask what can legally be done with a selection, ranked. Prefer these over composing a mutation by hand: they are derived from the schema, the invariants and the shape of the graph, so they cannot name an action that does not exist.",inputSchema:{type:"object",properties:{selection:{type:"array",items:{type:"string"},description:"Node ids."},context:{type:"object"}},required:["selection"],additionalProperties:!1},mutating:!1,annotations:_("Ask what can be done")},{name:"describe_place",title:"Say what a place shows",description:`Say what one place of the app shows you, as a person in your seat would see it: its headings, its figures as drawn, its lists with each record's title and what its card or row says, the headings a list is grouped under, what an empty list says, and any block that could not be worked out. Pass a place's slug ("home", a lens's address like "the-offers", a kind's like "offers") or a record's id, and width 390 for a phone. Use it after a change to check what somebody now sees, instead of guessing.`,inputSchema:{type:"object",properties:{place:{type:"string",description:`"home", a place's slug, or a record's id.`},width:{type:"number",description:"The screen's width in CSS pixels; 390 is a phone, 1440 when unsaid."}},required:["place"],additionalProperties:!1},mutating:!1,annotations:_("Say what a place shows")},{name:"preview_mutation",title:"Try an act without applying it",description:"Try a mutation without applying it: get back the diff it would produce and any invariant it would break. Do this when you are unsure, rather than applying and undoing.",inputSchema:{type:"object",properties:{mutation:{type:"string"},args:{type:"object"}},required:["mutation","args"],additionalProperties:!1},mutating:!1,annotations:_("Try an act without applying it")},{name:"undo_batch",title:"Undo a batch",description:"Undo one batch of operations. Fails, naming the blocking operation, when a later operation read what it wrote.",inputSchema:{type:"object",properties:{batch:{type:"string"},include:{type:"array",items:{type:"string"}}},required:["batch"],additionalProperties:!1},mutating:!0,annotations:{title:"Undo a batch",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}},{name:"list_suggestions",title:"List what is suggested",description:"List the suggestions waiting for a person: changes the app's own actor proposed and did not make, each with its id, what it would do, who suggested it, what it was based on and how sure (0 to 1). Nothing changes until one is accepted (accept_suggestion) or declined (decline_suggestion); a declined one is never suggested again.",inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:_("List what is suggested")},{name:"accept_suggestion",title:"Accept a suggestion",description:"Make a waiting suggestion's change, as this seat, carrying what it was based on. Returns the batch (undo_batch takes it back).",inputSchema:{type:"object",properties:{suggestion:{type:"string",description:"The suggestion's id, from list_suggestions."}},required:["suggestion"],additionalProperties:!1},mutating:!0,annotations:{title:"Accept a suggestion",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1}},{name:"decline_suggestion",title:"Decline a suggestion",description:"Decline a waiting suggestion: nothing changes, the decline is kept in the log, and the same change is never suggested or made by the app's own actor again.",inputSchema:{type:"object",properties:{suggestion:{type:"string",description:"The suggestion's id, from list_suggestions."}},required:["suggestion"],additionalProperties:!1},mutating:!0,annotations:{title:"Decline a suggestion",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}],Ve={name:"act_on_several",title:"Do one act to several records",description:`Run one act on several records at once, as one change with one undo. act is the act (its tool name or its declared name), records the records it runs on (ids or names; each goes in the act's subject), args what every call shares ("Set stage to Declined" is args { stage: "declined" }). Each record is judged on its own: one this seat may not change is named with why, and the rest still apply. Returns the batch (undo_batch takes it all back), the records changed, those already so, and those refused.`,inputSchema:{type:"object",properties:{act:{type:"string",description:"The act to run on each record."},records:{type:"array",items:{type:"string"},minItems:1,maxItems:200,description:"Ids or names of the records."},args:{type:"object",description:"Arguments every call shares, besides the record."}},required:["act","records"],additionalProperties:!1},mutating:!0,annotations:{title:"Do one act to several records",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}},ae={type:"object",description:"A lens, as draft_view returns one.",properties:{title:{type:"string"},lens:{type:"string"},on:{type:"string"},bindings:{type:"object"},options:{type:"object"}},required:["title","lens","on"]},se={name:"draft_view",title:"Draw a view",description:'Draw a view of the data from words ("a board of tasks by status", "who covers what") as a lens the app could keep; or check a lens you wrote (lens); or change the one on screen (current, with ask: "only this month"). Returns the lens and its add-lens edit, or one sentence saying why not. Writes nothing.',inputSchema:{type:"object",properties:{ask:{type:"string",description:"What to see, in words."},lens:ae,current:ae},additionalProperties:!1},mutating:!1,annotations:_("Draw a view")},Ge={name:"keep_lens",title:"Keep a view as a lens",description:"Keep a lens draft_view drew as one of the app's places: checked again, then written as the add-lens edit. Returns the remove-lens edit that takes it back.",inputSchema:{...ae,additionalProperties:!1},mutating:!0,annotations:{title:"Keep a view as a lens",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},Ke={name:"find_linked",title:"Find a record in another app",description:`A relation may go to a kind in another app (describe_app lists them under "Linked from other apps"). With relation and words, list the records there this seat may link \u2014 each with the value to link it by ("house:h1"), its name and its describe line. With of (a record id here), read the records that record links, as this seat may see them there. Linking one is the record's edit (edit-<kind>) with the relation set to the value. Another app this seat may not open answers denied, and nothing of it. Writes nothing; never changes the other app.`,inputSchema:{type:"object",properties:{relation:{type:"string",description:"The relation, by name (forHouse) or as <kind>.<relation> (scenario.forHouse)."},query:{type:"string",description:"Words to find by, in the other app's names; empty for the first few."},of:{type:"string",description:"A record here whose linked records to read, instead of finding."},limit:{type:"number",description:"Most records to return; at most 20."}},required:["relation"],additionalProperties:!1},mutating:!1,annotations:_("Find a record in another app")};function kn(t,n){return t===void 0?[]:t==="keep"&&!n?[se,Ge]:[se]}var Sn="An argument that names a record takes its id or its name.",Ze=[...oe.map(t=>t.name),Ve.name,se.name,Ge.name,Ke.name,...ne.map(t=>t.name)],Ye=64;function x(t){let{line:n,...e}=t;return e}function Ue(t){return{...t,...t.introduces?{introduces:t.introduces.map(x)}:{},...t.resolves?{resolves:t.resolves.map(x)}:{},...t.violationsAfter?{violationsAfter:t.violationsAfter.map(x)}:{}}}function vn(t){let n=t.normalize("NFKD").replace(/\p{M}/gu,"").replace(/[^A-Za-z0-9_-]/g,"_");return n.length===0&&(n="act"),/^[A-Za-z_]/.test(n)||(n=`act_${n}`),n.slice(0,Ye)}function An(t){let n=new Set(Ze),e=new Map;for(let r of t){let i=vn(r),o=i;for(let a=2;n.has(o);a+=1)o=`${i.slice(0,Ye-`_${a}`.length)}_${a}`;n.add(o),e.set(r,o)}return e}function On(t,n){if(n.size===0)return t;let e=Object.fromEntries(Object.entries(t.properties??{}).filter(([i])=>!n.has(i))),r=(t.required??[]).filter(i=>!n.has(i));return{...t,properties:e,...t.required?{required:r}:{}}}function Rn(t,n,e){let r=X(t),i=C(t),o=r.nodeRefs.length>0?`${r.description}${/[.!?]$/.test(r.description)?"":"."} ${Sn}`:r.description;return{name:n,title:i,description:o,inputSchema:On(r.inputSchema,e),mutating:!0,annotations:{title:i,readOnlyHint:!1,destructiveHint:t.destructive===!0||(t.severs?.length??0)>0,idempotentHint:t.idempotent===!0,openWorldHint:!1},act:t.name}}function de(t){if(t===null||typeof t!="object")return JSON.stringify(t)??"null";if(Array.isArray(t))return`[${t.map(de).join(",")}]`;let n=t;return`{${Object.keys(n).filter(e=>n[e]!==void 0).sort().map(e=>`${JSON.stringify(e)}:${de(n[e])}`).join(",")}}`}function Tn(t){return`sha256:${Oe(de(t))}`}function _n(t,n,e,r,i,o=!1,a=!1){let d=An(t.map(f=>f.name)),s=[...kn(r,e),...o?[Ke]:[],...a?ne:[]];return{definitions:e?[...oe.filter(f=>!f.mutating),...s]:[...oe,Ve,...s,...t.filter(f=>n.has(f.name)).map(f=>Rn(f,d.get(f.name),i(f)))],names:d}}function lt(t,n={}){let e=n.author??{kind:"agent"},r=t.allMutations(),i=new Set(t.permittedMutations(e).map(m=>m.name)),{definitions:o,names:a}=_n(r,i,n.readOnly===!0,n.drafts?n.drafts.keep?"keep":"draw":void 0,m=>K(t.schema,t.policy,e,m),bn(t.schema),n.subscriptions!==void 0),d=Tn(o),s={app:n.app?.brand?.locale,appTimeZone:n.app?.brand?.timeZone},g=m=>le(s,m),f=m=>{if(!Ze.includes(m)){for(let[l,w]of a)if(w===m)return l;return a.has(m)?m:void 0}},b=(m,l)=>{let w=r.find(u=>u.name===m);if(!w)return{args:l,resolved:[]};let S={...l},c=[];for(let u of q(w.input)){let p=S[u.name];if(typeof p!="string"||p.trim()==="")continue;let y=t.resolveRef(u,p,e);if(!y.ok){let v=y.reason==="none"?` Nothing was changed. Use search_graph to look it up, then pass its id as ${u.name}.`:" Nothing was changed.";return{ok:!1,error:`${y.message}${v}`,argument:u.name,candidates:y.candidates}}y.by!=="id"&&(S[u.name]=y.id,c.push({argument:u.name,given:p,id:y.id,label:y.label}))}return{args:S,resolved:c}},h=async(m,l)=>{try{await mn();let w=o.find(c=>c.name===m)??o.find(c=>c.act===m);if(!w){let c=f(m);if(c){let u=t.permits({name:c,args:l},e);if(!u.ok)return{ok:!1,error:u.refusal.message,reason:"forbidden"}}return{ok:!1,error:`Unknown tool "${m}". Available: ${o.map(u=>u.name).join(", ")}`}}if(w.mutating&&n.readOnly)return{ok:!1,error:`"${m}" changes the graph, and this seat is read-only.`,reason:"forbidden"};if(w.act!==void 0){let c=b(w.act,l);if("ok"in c)return c;let u=w.act,p=g(()=>E(t,e,t.apply({name:u,args:c.args},{...n.author?{author:n.author}:{},...ie(n.via)})));return{ok:!0,data:{batch:p.batch,intent:p.intent,introduces:p.introduces.map(x),resolves:p.resolves.map(x),...c.resolved.length>0?{resolved:c.resolved}:{}},diff:p.diff}}let S=t.seenBy(e);switch(w.name){case"search_graph":{let c=typeof n.places=="function"?n.places():n.places,u=typeof l.subject=="string"?l.subject:void 0,p=$e(S,String(l.query??""),{principal:e,rank:n.near,archived:be(l.archived),limit:typeof l.limit=="number"&&l.limit>0?Math.min(l.limit,20):20,...c?{places:c}:{},...u?{subject:u,from:[u]}:{}}),y=p.later?await p.later:p;return{ok:!0,data:(await H()).searchRead(y,We(y,B(S,e))),reads:y.hits.flatMap(v=>v.about==="node"?[v.id]:[])}}case"get_graph":return{ok:!0,...(await H()).graphRead(S,B(S,e),l)};case"get_node":{let c=String(l.id??""),u=c,p;if(!S.graph.getNode(c)){let v=c.trim()===""?void 0:t.resolveRef({name:"id",kinds:["*"]},c,e);if(v?.ok)u=v.id,p={argument:"id",given:c,id:u,label:v.label};else return v?.reason==="ambiguous"?{ok:!1,error:v.message,argument:"id",candidates:v.candidates}:{ok:!1,error:`No node "${c}".`}}let y=(await H()).nodeRead(S,B(S,e),u,l);return{ok:!0,data:p?{...y.data,resolved:[p]}:y.data,reads:y.reads}}case"describe_place":{let c=n.app??{name:"",schema:t.schema},u=typeof l.width=="number"&&Number.isFinite(l.width)&&l.width>0?l.width:1440,{describePlace:p}=await fn(),y=p(t,e,String(l.place??""),{app:c,width:u});if(!y.ok)return{ok:!1,error:`${y.error} The places are: ${y.places.join(", ")}.`};let v=new Set,M=I=>{for(let $ of I)for(let T of $.groups??[])for(let N of T.items)v.add(N.id),M(N.parts)};return M(y.description.parts),{ok:!0,data:y.description,reads:[...v]}}case"find_linked":return wn(S,e,l,n.linked);case"draft_view":case"keep_lens":{let c=n.app??{name:"",schema:t.schema};return(await hn()).runDraftTool(w.name,l,{app:c,principal:e,...n.drafts?{drafts:n.drafts}:{}})}case"get_violations":{let c=S.violations(l.context);return{ok:!0,...(await H()).violationsRead(c,l)}}case"get_affordances":{let c=l.selection??[];return{ok:!0,data:Ne(S,c,{...typeof n.derive=="function"?n.derive():n.derive,...n.author?{principal:n.author}:{},...l.context?{context:l.context}:{}}),reads:c.filter(p=>S.graph.has(p))}}case"preview_mutation":{let c=String(l.mutation),u=f(c)??c,p=b(u,l.args??{});if("ok"in p)return p;let y=t.missingFor({name:u,args:p.args},e);if(y)return{ok:!1,error:y.message,reason:"missing"};let v=E(t,e,t.preview({name:u,args:p.args},void 0,{author:e})),M=Ue(v);return{ok:!0,data:p.resolved.length>0?{...M,resolved:p.resolved}:M}}case"act_on_several":{let c=String(l.act??""),u=f(c)??c,p=r.find(O=>O.name===u);if(!p||!i.has(u)){let O=p?t.permits({name:u,args:{}},e):void 0;return O&&!O.ok?{ok:!1,error:O.refusal.message,reason:"forbidden"}:{ok:!1,error:`There is no act "${c}" this seat may run. Nothing was changed.`,reason:"invalid"}}let y=p.subject;if(!y)return{ok:!1,error:`"${C(p)}" does not act on a record, so it cannot be run on several. Nothing was changed.`,reason:"invalid"};let v=Array.isArray(l.records)?l.records.filter(O=>typeof O=="string"&&O.trim()!==""):[];if(v.length===0)return{ok:!1,error:"Name at least one record. Nothing was changed.",reason:"invalid"};let M=[],I=[];for(let O of v.slice(0,200)){let P=t.resolveRef({name:y.arg,kinds:y.kinds},O,e);if(!P.ok)return{ok:!1,error:`${P.message} Nothing was changed.`,argument:"records",candidates:P.candidates};M.push(P.id),P.by!=="id"&&I.push({argument:"records",given:O,id:P.id,label:P.label})}let $=b(u,{...l.args??{}});if("ok"in $)return $;let T=(await yn()).actOnSeveral(t,{mutation:u,subject:y.arg,args:$.args},M,{author:e,...ie(n.via)}),N=T.result?E(t,e,T.result):void 0;return{ok:!0,data:{...T.batch?{batch:T.batch,intent:T.intent}:{},applied:T.applied,unchanged:T.unchanged,refused:T.refused.map(O=>({record:O.id,label:O.label,error:O.message,reason:O.reason})),...T.allOrNothing?{keptNone:!0}:{},...N?{introduces:N.introduces.map(x),resolves:N.resolves.map(x)}:{},...I.length>0||$.resolved.length>0?{resolved:[...I,...$.resolved]}:{}},...N?{diff:N.diff}:{}}}case"subscribe":case"unsubscribe":case"list_subscriptions":{let c=await(await gn()).runSubscriptionTool(w.name,l,{store:t,principal:n.subscriber??e,app:n.app?.name??"app",subscriptions:n.subscriptions});return c.ok?{ok:!0,data:c.data}:{ok:!1,error:c.error}}case"list_suggestions":{let c=_e(t,e).map(u=>{let p=F(u.author,{graph:S.graph,schema:t.schema});return{id:u.id,intent:u.intent,by:p,at:u.at,about:u.about,...u.lineage?{basis:{untrusted:!0,authoredBy:p,text:u.lineage.basis},...u.lineage.confidence!==void 0?{confidence:u.lineage.confidence}:{}}:{}}});return{ok:!0,data:{suggestions:c},reads:[...new Set(c.flatMap(u=>u.about))]}}case"accept_suggestion":case"decline_suggestion":{let c=String(l.suggestion??""),u={author:e,...ie(n.via)},p=w.name==="accept_suggestion"?xe(t,c,u):Me(t,c,u),y=E(t,e,p);return{ok:!0,data:{batch:y.batch,intent:y.intent,introduces:y.introduces.map(x),resolves:y.resolves.map(x)},diff:y.diff}}case"undo_batch":{let c=String(l.batch),u=l.include??[],p=S.canUndo([c,...u]);if(!p.ok)return{ok:!1,error:p.message};let y=E(t,e,t.undo([c,...u],{...n.author?{author:n.author}:{}}));return{ok:!0,data:Ue(y),diff:y.diff}}default:return{ok:!1,error:`Unknown tool "${m}".`}}}catch(w){let{reason:S,wouldNeed:c}=we(w);return{ok:!1,error:w instanceof Error?w.message:String(w),reason:S,...c?{wouldNeed:c}:{}}}},k=new Set,A=m=>{for(let l of k)l(m)};return{definitions:o,hash:d,...n.author?{author:n.author}:{},onDiff(m){return t.subscribe(m)},onCall(m){return k.add(m),()=>k.delete(m)},async call(m,l){let w=(o.find(p=>p.name===m)??o.find(p=>p.act===m))?.mutating??!1,S={name:m,args:l,mutating:w,at:new Date().toISOString()};A({...S,phase:"running"});let c=p=>(A(p.ok?{...S,phase:"ok",...!w&&p.reads?{reads:p.reads}:{}}:{...S,phase:"failed",error:p.error}),p),u=await h(m,l);return c(u.ok&&!w?{...u,data:(await H()).withinReadChars(m,u.data)}:u)}}}function ie(t){let n=typeof t=="function"?t():t;return n?{via:n}:{}}export{de as a,lt as b};
@@ -0,0 +1 @@
1
+ import{a as D}from"./chunk.PXQVXBNG.js";import{a as L,f as P,g as N,h as R}from"./chunk.G446PWV6.js";import{Xc as E}from"./chunk.AS4CQBOQ.js";var z=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),T=e=>e?._zod?.def;function W(e){let n=T(e);for(;n&&(n.type==="optional"||n.type==="default"||n.type==="nullable"||n.type==="prefault");)n=T(n.innerType);return n}function K(e){if(e?.type==="boolean")return["true","false"];if(e?.type==="enum")return(e.entries?Object.values(e.entries):e.values??[]).filter(n=>typeof n=="string")}var v=e=>e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[-_]/g," ").replace(/^./,n=>n.toUpperCase());function J(e,n,i){let a=e.tryDefinition(n);if(!a)return[];let c=new Set(a.display?.hide??[]),r=[];for(let[s,l]of Object.entries(a.fields.shape??{})){if(s==="id"||s==="kind"||s==="label"||c.has(s))continue;let o=W(l);if(o?.type==="array"||o?.type==="object"||o?.type==="record")continue;let u=K(o);r.push({key:s,label:v(s),...u?{options:u}:{}})}let y=new Map;for(let[s,l]of Object.entries(a.edges??{}))y.set(s,l.to==="*"?[]:[...l.to]);for(let s of e.definitions)if(s.kind!==n)for(let[l,o]of Object.entries(s.edges??{}))!y.has(l)&&(o.to==="*"||o.to.includes(n))&&y.set(l,[s.kind]);let g=[];for(let[s,l]of y){r.push({key:s,label:v(s)});let o=i&&l.length===1&&l[0]!==n?e.tryDefinition(l[0]):void 0;for(let[u,f]of Object.entries(o?.fields.shape??{})){let p=W(f);p?.type==="enum"&&!o?.display?.hide?.includes(u)&&g.push({key:`${s}.${u}`,label:`${v(s)} \xB7 ${v(u)}`,options:K(p)})}}return r.push(...g),r.push({key:"is",label:"Is",options:a.lifecycle?["current","past","any","flagged","clear"]:["flagged","clear"]}),r}var I=e=>e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function G(e,n,i,a={}){if(i==null)return{ok:!0};if(!z(i))return{ok:!1,says:'A filter is an object of a field and the value it keeps, like { where: { stage: "building" } }.'};let c=Object.entries(i);if(c.length===0)return{ok:!0};let r=[];for(let l of n)for(let o of J(e,l,a.through===!0))r.some(u=>u.key===o.key)||r.push(o);let y=n[0]?e.tryDefinition(n[0]):void 0,g=y?y.plural??`${v(y.kind)}s`:"These",s=[];for(let[l,o]of c){let u=r.find(p=>p.key===l);if(!u)return{ok:!1,says:`${g.replace(/^./,p=>p.toUpperCase())} have no field "${l}" to filter by${r.length>0?`; they filter by ${I(r.map(p=>p.key))}`:""}.`};if(typeof o!="string"&&typeof o!="number"&&typeof o!="boolean")return{ok:!1,says:`The filter on "${l}" is ${Array.isArray(o)?"a list":o===null?"null":`a ${typeof o}`}; it keeps one value: a word, a number, or true or false.`};let f=String(o);if(f.trim().length===0)return{ok:!1,says:`The filter on "${l}" keeps nothing; give it a value, or leave "${l}" out.`};if(f.includes(","))return{ok:!1,says:`The filter on "${l}" holds a comma, which an address reads as a second filter; keep one value.`};if(u.options&&u.options.length>0&&!u.options.includes(f))return{ok:!1,says:`${u.label} has no choice "${f}"; its choices are ${I(u.options.map(p=>`"${p}"`))}.`};s.push(`${l}:${f}`)}return{ok:!0,filter:s.join(",")}}var C=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");function q(e,n){let i=e.find(r=>r.as===n);if(i)return i;let a=n.trim().toLowerCase(),c=C(n);return e.find(r=>r.title!==void 0&&r.title.trim().toLowerCase()===a)??(c?e.find(r=>r.as===c||r.title!==void 0&&C(r.title)===c):void 0)}function Z(e){let n=[];for(let i of e){if(typeof i!="object"||i===null)continue;let{as:a,slug:c,title:r,kind:y}=i,g=typeof a=="string"&&a.length>0?a:typeof c=="string"&&c.length>0?c:void 0;!g||n.some(s=>s.as===g)||n.push({as:g,title:typeof r=="string"?r:g,kind:typeof y=="string"?y:""})}return n}var F=e=>` Its places: ${e.map(n=>typeof n=="string"?`"${n}"`:n.title&&n.title!==n.as?`"${n.as}" (${n.title})`:`"${n.as}"`).join(", ")||"none"}.`;var b=e=>`"${e.length>80?`${e.slice(0,79)}\u2026`:e}"`,O=(e,n)=>`${"place"in e?`The place ${b(e.place)}`:`${b(e.record)} is no record this viewer may see and`} is no place of this app: it goes nowhere.${F(n)}`;function S(e){let n={};for(let i of e.split(",")){let a=i.indexOf(":");a>0&&(n[i.slice(0,a).trim()]=i.slice(a+1).trim())}return n}function ne(e,n=new Set){return e.kinds.filter(i=>!n.has(i)).map(i=>({slug:E(e,i).slice(1),kind:i}))}function U(e,n){let i=[...new Set(n.places.map(f=>f.as))],a=n.lists.map(f=>f.slug).filter(f=>!i.includes(f)),c;if(e.section!==void 0&&e.section!==null){if(typeof e.section!="string"||D(e.section).length===0||e.section.length>120)return{ok:!1,says:`The section ${typeof e.section=="string"?b(e.section):"asked for"} names nothing on a page: a section is a heading's words or an element's id, like "shipping-soon". It goes nowhere.`};c=e.section}let r=c!==void 0?{section:c}:{};if("record"in e&&n.sees(e.record))return e.where!==void 0&&e.where!==null?{ok:!1,says:`${b(e.record)} is one record, and a filter narrows a list or a place: it goes nowhere. Go to { place, where } for a list narrowed.`}:{ok:!0,arrival:{record:e.record,...r}};let y="place"in e?e.place:e.record,g=q(n.places,y),s=g?void 0:n.lists.find(f=>f.slug===y||f.kind===y);if(!g&&!s)return{ok:!1,says:`${O(e,n.places.filter((f,p,m)=>m.findIndex(t=>t.as===f.as)===p))}${_(a)}`};let l=g?[g.kind]:[s.kind],o;if(e.where!==void 0&&e.where!==null){if(!n.schema)return{ok:!1,says:`The place ${b(y)} cannot be narrowed here: it goes nowhere.`};let f=G(n.schema,l,e.where,{through:s!==void 0});if(!f.ok)return{ok:!1,says:`The filter on ${b(y)} goes nowhere: ${f.says}`};o=f.filter}let u=o?{filter:o}:{};return{ok:!0,arrival:g?{place:g.as,...u,...r}:{list:s.kind,...u,...r}}}var _=e=>e.length===0?"":` Its lists: ${e.slice(0,8).map(n=>`"${n}"`).join(", ")}${e.length>8?` and ${e.length-8} more`:""}.`,M="http://www.w3.org/1999/xhtml",V=e=>{let n=e;return n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||e.type==="click"&&typeof n.button=="number"&&n.button!==0};function re(e){let n=new WeakSet,i=new WeakSet,a=new WeakMap,c=new WeakMap,r=t=>U(t,{sees:e.sees,places:e.places(),lists:e.lists?.()??[],...e.schema?{schema:e.schema}:{}}),y=t=>{let d=r(t);return d.ok?e.onNavigate?.(d.arrival):e.onLost?.(d.says),d.ok},g=t=>{let d=t.getAttribute("data-record"),h=t.getAttribute("data-place"),k=t.getAttribute("data-filter"),w=t.getAttribute("data-section"),$={...k?{where:S(k)}:{},...w?{section:w}:{}};if(d)return{record:d,...$};if(h)return{place:h,...$}},s=t=>{if(!e.hrefOf)return;let d=g(t),h=d?r(d):void 0;return h?.ok?e.hrefOf(h.arrival):void 0},l=t=>t.hasAttribute("tabindex")?!1:(t.setAttribute("tabindex","0"),n.add(t),!0),o=t=>{n.delete(t)&&t.removeAttribute("tabindex")},u=t=>{i.delete(t)&&t.getAttribute("role")==="link"&&t.removeAttribute("role")},f=t=>{let d=a.get(t);d&&(a.delete(t),t.getAttribute("href")===d.href&&t.removeAttribute("href"),d.target!==null&&!t.hasAttribute("target")&&t.setAttribute("target",d.target))},p=t=>{let d=c.get(t);d&&(c.delete(t),o(d))},m={link(t){if(!N(t,[...t.querySelectorAll("input, select, textarea")].some(L))){if(!t.hasAttribute("data-graview-link"))return;t.removeAttribute("data-graview-link"),u(t),o(t),f(t),p(t);return}t.hasAttribute("data-graview-link")||t.setAttribute("data-graview-link","");let h=t.localName==="a"&&t.namespaceURI===M,k=t.getAttribute("href"),w=a.get(t),$=k!==null&&w?.href!==k,A=h&&!$?s(t):void 0;if(A!==void 0){k!==A&&t.setAttribute("href",A),a.set(t,{href:A,target:w?w.target:t.getAttribute("target")}),t.removeAttribute("target"),u(t),o(t);return}if($?a.delete(t):f(t),!t.hasAttribute("role")&&(h||P(t))&&(t.setAttribute("role","link"),i.add(t)),t.localName==="tr"&&t.namespaceURI===M){o(t);let x=[...t.children].find(j=>j.localName==="td"||j.localName==="th");c.get(t)!==x&&p(t),x&&!c.has(t)&&l(x)&&c.set(t,x);return}t.localName!=="button"&&l(t)},refresh(t){for(let d of t.querySelectorAll("[data-record], [data-place], [data-graview-link]"))m.link(d)},pressed(t,d,h){if(t.type!=="click"&&!(t.type==="keydown"&&t.key==="Enter"))return!1;let k=R(d,h,w=>w.hasAttribute("data-graview-link"));return k?(t.stopPropagation(),a.has(k)&&V(t)||(t.preventDefault(),m.follow(k)),!0):!1},follow(t){let d=g(t);d&&y(d)},go:y};return m}export{Z as a,F as b,b as c,O as d,S as e,ne as f,U as g,re as h};
@@ -1 +1 @@
1
- import{G as g,P as y,_ as m,ga as d}from"./chunk.XWAMQPUM.js";import{b as S}from"./chunk.AJZBJBMO.js";var v=S(g(),1);function k(){let{store:w,principal:a,ai:n,aiDesk:r,seatTalk:i,views:p,app:t,brand:l,view:A,selection:s}=m(),e=y(w,a),c=d(),o=A.within?.view;return(0,v.useMemo)(()=>({store:e,principal:a,ai:n,desk:r,seatTalk:i,goTo:c,places:[...p.places()],app:t??{name:l?.name??"app",schema:e.schema,...e.policy?{policy:e.policy}:{}},...o?{place:o}:{},selection:s}),[e,a,n,r,i,c,p,t,l,o,s])}export{k as a};
1
+ import{G as g,P as y,_ as m,ga as d}from"./chunk.Y4ZUJUUT.js";import{b as S}from"./chunk.AJZBJBMO.js";var v=S(g(),1);function k(){let{store:w,principal:a,ai:n,aiDesk:r,seatTalk:i,views:p,app:t,brand:l,view:A,selection:s}=m(),e=y(w,a),c=d(),o=A.within?.view;return(0,v.useMemo)(()=>({store:e,principal:a,ai:n,desk:r,seatTalk:i,goTo:c,places:[...p.places()],app:t??{name:l?.name??"app",schema:e.schema,...e.policy?{policy:e.policy}:{}},...o?{place:o}:{},selection:s}),[e,a,n,r,i,c,p,t,l,o,s])}export{k as a};
@@ -0,0 +1 @@
1
+ import{hc as g}from"./chunk.AS4CQBOQ.js";function v(){let t=new Uint8Array(16);return globalThis.crypto.getRandomValues(t),Array.from(t,e=>e.toString(16).padStart(2,"0")).join("")}function k(t,e){if(!t)return;let i={..."filter"in e&&e.filter?{filter:e.filter}:{},...e.section?{section:e.section}:{}};"record"in e?t.record(e.record,i):"list"in e?t.list(e.list,i):t.place(e.place,i)}function w(t,e){if(!t?.href)return;let i={..."filter"in e&&e.filter?{filter:e.filter}:{},...e.section?{section:e.section}:{}};return t.href("record"in e?{record:e.record}:"list"in e?{list:e.list}:{place:e.place},i)}var b=[["accent","--graview-accent"],["ground","--graview-ground"],["panel","--graview-panel"],["ink","--graview-ink"],["inkMuted","--graview-ink-muted"],["edge","--graview-edge"],["fontBody","--graview-font-body"],["fontDisplay","--graview-font-display"],["fontMono","--graview-font-mono"],["radius","--graview-radius"]];function R(t){let e=t.ownerDocument.defaultView,i=e.getComputedStyle(t),s=t.closest("[data-graview-scheme]")?.getAttribute("data-graview-scheme"),d={scheme:s==="dark"||s==="light"?s:/\bdark\b/.test(i.colorScheme??"")?"dark":/\blight\b/.test(i.colorScheme??"")?"light":e.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"};for(let[l,u]of b)d[l]=i.getPropertyValue(u).trim();return d}function T(t,e){let i=t.defaultView;if(!i||typeof i.MutationObserver!="function")return()=>{};let s=new i.MutationObserver(e);s.observe(t.documentElement,{attributes:!0,subtree:!0,attributeFilter:["data-graview-scheme","data-theme"]});let o=i.matchMedia?.("(prefers-color-scheme: dark)");return o?.addEventListener?.("change",e),()=>{s.disconnect(),o?.removeEventListener?.("change",e)}}function x(t,e,i){let s=e?.(),o=t(),d=s?.logo,l=i.url(typeof d=="string"||d===void 0?d:o.scheme==="dark"&&d.dark?d.dark:d.light);return{...o,...s?.name?{name:s.name}:{},...l?{logo:l}:{}}}function B(t,e,i){let s,o,d=n=>{n?.startsWith("blob:")&&t.URL.revokeObjectURL(n)},l=async n=>{if(n.startsWith("<"))return g(n)===null?new t.Blob([n],{type:"image/svg+xml"}):void 0;if(/\\|%2e/i.test(n)||n.split(/[?#]/)[0].split("/").some(m=>m==="."||m===".."))return;let r=new t.URL(n,t.document.baseURI);if(r.origin!==t.location.origin||!/^https?:$/.test(r.protocol))return;let a=await t.fetch(r.href,{credentials:"same-origin"}),c=(a.headers.get("content-type")??"").split(";")[0].trim();return a.ok&&c.startsWith("image/")?new t.Blob([await a.arrayBuffer()],{type:c}):void 0},u=n=>new Promise(r=>{let a=new t.Image;a.onload=()=>r(!0),a.onerror=()=>r(!1),t.setTimeout(()=>r(!1),2e3),a.src=n}),h=n=>new Promise((r,a)=>{let c=new t.FileReader;c.onload=()=>r(String(c.result)),c.onerror=a,c.readAsDataURL(n)}),p=async n=>{if(/^data:image\//i.test(n))return n;let r=await l(n);if(!(!r||s!==n)){if(i==="blob"){let a=t.URL.createObjectURL(r);if(await u(a))return a;t.URL.revokeObjectURL(a)}return h(r)}},f=(n,r)=>{if(s!==n)return d(r);r!==o&&(d(o),o=r,e())};return{url(n){let r=n?.trim()||void 0;return r!==s&&(s=r,r?p(r).then(a=>f(r,a),()=>f(r,void 0)):(d(o),o=void 0)),o},dispose(){s=void 0,d(o),o=void 0}}}export{v as a,k as b,w as c,R as d,T as e,x as f,B as g};
@@ -1 +1 @@
1
- import{e as $}from"./chunk.SZ34UAQ3.js";import{a as C}from"./chunk.UKAPFIPJ.js";import{g as M}from"./chunk.HDRD33II.js";import{ca as k,da as v,fa as j,vb as x}from"./chunk.AS4CQBOQ.js";function N(a,s){let c=a.tryDefinition(s),r=Object.keys(c?.fields?.shape??{}),m=[c?.lifecycle?.field,...r.filter(l=>/^(status|stage|state|phase)$/i.test(l))].filter(l=>l!==void 0&&r.includes(l));return[...new Set(m)].slice(0,1)}function P(a,s){return a.tryDefinition(s)?.fieldRoles?.title??"label"}function V(a,s,c={}){let r=s.map(e=>a.graph.getNode(e)).filter(e=>e!==void 0);if(r.length===0)return{acts:[],withheld:[]};let u=c.principal??{kind:"human"},m=C(a,r.map(e=>e.id),{...c.derive,principal:u,...c.context?{context:c.context}:{}}),l=new Map(a.allMutations().map(e=>[e.name,e])),g=[...new Set(r.map(e=>e.kind))],p=new Set(g.map(e=>P(a.schema,e))),h=new Set(m.affordances.filter(e=>e.provider==="schema").map(e=>e.mutation)),o=e=>{let n=l.get(e.mutation);if(!n?.subject)return;let t=r.length===1&&e.provider==="invariant"&&!h.has(e.mutation)&&e.args[n.subject.arg]===r[0].id;if(!(e.provider!=="schema"&&!t)&&!(r.length>1&&e.batch?.length!==r.length)&&n.derived?.act!=="edit"&&!e.open.some(i=>p.has(i.name)))return n},y=[],b=new Set;for(let e of m.affordances){let n=o(e);if(!n||b.has(n.name))continue;b.add(n.name);let{[n.subject.arg]:t,...i}=e.args;y.push({id:e.id,label:v(n),mutation:n.name,subject:n.subject.arg,args:i,open:e.open,...e.destructive||e.setsAside?{more:!0}:{},...e.destructive?{destructive:!0}:{},affordance:{...e,label:v(n)}})}if(g.length===1){let e=g[0];for(let n of N(a.schema,e))for(let t of $(a.schema,[...l.values()],e,n)){if(t.by==="none"||r.every(d=>d[n]===t.value))continue;let i=r.find(d=>d[n]!==t.value),f=t.acts.find(d=>{let D=t.by==="step"?{[d.subject.arg]:i.id}:{[d.subject.arg]:i.id,[n]:t.value};return a.permits({name:d.name,args:D},u).ok});if(!f)continue;let w=t.by==="step"?{}:{[n]:t.value};if(t.by==="step"&&y.some(d=>d.mutation===f.name))continue;let R=t.by==="step"?v(f):`Move to ${t.label}`,O=`set:${n}:${t.value}`;y.push({id:O,label:R,mutation:f.name,subject:f.subject.arg,args:w,open:[],affordance:{id:O,label:R,provider:"schema",mutation:f.name,args:{[f.subject.arg]:i.id,...w},open:[],score:0,why:`every one is ${e}`,nodeIds:r.map(d=>d.id)}})}}let S=[...y.filter(e=>!e.more),...y.filter(e=>e.more)],A=m.withheld.filter(e=>{let n=l.get(e.mutation);return n?.subject!==void 0&&n.derived?.act!=="edit"&&(r.length===1||e.batch?.length===r.length)}).map(e=>({label:v(l.get(e.mutation)),message:e.refusal.message}));return{acts:S,withheld:A}}function _(a,s,c,r={}){let u=r.author,m=a.allMutations().find(e=>e.name===s.mutation),l=e=>M(a.schema,a.allMutations(),e),g=e=>{let n=a.graph.getNode(e);return n?k(a.schema.tryDefinition(n.kind),n):e},p=[],h=[],o=[];for(let e of[...new Set(c)]){let n={name:s.mutation,args:{...s.args,[s.subject]:e}};if(!m){p.push({id:e,label:g(e),message:`There is no act \u201C${s.mutation}\u201D.`,reason:"invalid"});continue}let t=a.permits(n,u);if(!t.ok){p.push({id:e,label:g(e),message:t.refusal.message,reason:"forbidden"});continue}if(!a.wouldChange(n,u)){h.push(e);continue}o.push({id:e,call:n})}let y=e=>a.previewAll(e,{...u?{author:u}:{},...r.context?{context:r.context}:{}});for(let e=0;o.length>0;e+=1)try{y(o.map(n=>n.call));break}catch(n){let t=[];for(let i of o)try{y([i.call]),t.push(i)}catch(f){p.push({id:i.id,label:g(i.id),message:l(f),reason:x(f).reason})}if(t.length===o.length||e>o.length){for(let i of t)p.push({id:i.id,label:g(i.id),message:l(n),reason:x(n).reason});o=[];break}o=t}if(o.length===0)return{applied:[],unchanged:h,refused:p};let b=s.label??(m?v(m):s.mutation),S=[...new Set(o.map(e=>a.graph.getNode(e.id)?.kind))],A=`${b} \u2014 ${S.length===1&&S[0]?j(a.schema,S[0],o.length):`${o.length} records`}`;try{let e=a.applyAll(o.map(n=>n.call),{intent:A,...u?{author:u}:{},...r.via?{via:r.via}:{}});return{batch:e.batch,intent:A,applied:o.map(n=>n.id),unchanged:h,refused:p,result:e}}catch(e){let n=l(e),t=x(e).reason;return{applied:[],unchanged:h,refused:[...p,...o.map(i=>({id:i.id,label:g(i.id),message:n,reason:t}))],allOrNothing:!0}}}export{V as a,_ as b};
1
+ import{e as $}from"./chunk.RX2M4C5W.js";import{a as C}from"./chunk.UKAPFIPJ.js";import{g as M}from"./chunk.HDRD33II.js";import{ca as k,da as v,fa as j,vb as x}from"./chunk.AS4CQBOQ.js";function N(a,s){let c=a.tryDefinition(s),r=Object.keys(c?.fields?.shape??{}),m=[c?.lifecycle?.field,...r.filter(l=>/^(status|stage|state|phase)$/i.test(l))].filter(l=>l!==void 0&&r.includes(l));return[...new Set(m)].slice(0,1)}function P(a,s){return a.tryDefinition(s)?.fieldRoles?.title??"label"}function V(a,s,c={}){let r=s.map(e=>a.graph.getNode(e)).filter(e=>e!==void 0);if(r.length===0)return{acts:[],withheld:[]};let u=c.principal??{kind:"human"},m=C(a,r.map(e=>e.id),{...c.derive,principal:u,...c.context?{context:c.context}:{}}),l=new Map(a.allMutations().map(e=>[e.name,e])),g=[...new Set(r.map(e=>e.kind))],p=new Set(g.map(e=>P(a.schema,e))),h=new Set(m.affordances.filter(e=>e.provider==="schema").map(e=>e.mutation)),o=e=>{let n=l.get(e.mutation);if(!n?.subject)return;let t=r.length===1&&e.provider==="invariant"&&!h.has(e.mutation)&&e.args[n.subject.arg]===r[0].id;if(!(e.provider!=="schema"&&!t)&&!(r.length>1&&e.batch?.length!==r.length)&&n.derived?.act!=="edit"&&!e.open.some(i=>p.has(i.name)))return n},y=[],b=new Set;for(let e of m.affordances){let n=o(e);if(!n||b.has(n.name))continue;b.add(n.name);let{[n.subject.arg]:t,...i}=e.args;y.push({id:e.id,label:v(n),mutation:n.name,subject:n.subject.arg,args:i,open:e.open,...e.destructive||e.setsAside?{more:!0}:{},...e.destructive?{destructive:!0}:{},affordance:{...e,label:v(n)}})}if(g.length===1){let e=g[0];for(let n of N(a.schema,e))for(let t of $(a.schema,[...l.values()],e,n)){if(t.by==="none"||r.every(d=>d[n]===t.value))continue;let i=r.find(d=>d[n]!==t.value),f=t.acts.find(d=>{let D=t.by==="step"?{[d.subject.arg]:i.id}:{[d.subject.arg]:i.id,[n]:t.value};return a.permits({name:d.name,args:D},u).ok});if(!f)continue;let w=t.by==="step"?{}:{[n]:t.value};if(t.by==="step"&&y.some(d=>d.mutation===f.name))continue;let R=t.by==="step"?v(f):`Move to ${t.label}`,O=`set:${n}:${t.value}`;y.push({id:O,label:R,mutation:f.name,subject:f.subject.arg,args:w,open:[],affordance:{id:O,label:R,provider:"schema",mutation:f.name,args:{[f.subject.arg]:i.id,...w},open:[],score:0,why:`every one is ${e}`,nodeIds:r.map(d=>d.id)}})}}let S=[...y.filter(e=>!e.more),...y.filter(e=>e.more)],A=m.withheld.filter(e=>{let n=l.get(e.mutation);return n?.subject!==void 0&&n.derived?.act!=="edit"&&(r.length===1||e.batch?.length===r.length)}).map(e=>({label:v(l.get(e.mutation)),message:e.refusal.message}));return{acts:S,withheld:A}}function _(a,s,c,r={}){let u=r.author,m=a.allMutations().find(e=>e.name===s.mutation),l=e=>M(a.schema,a.allMutations(),e),g=e=>{let n=a.graph.getNode(e);return n?k(a.schema.tryDefinition(n.kind),n):e},p=[],h=[],o=[];for(let e of[...new Set(c)]){let n={name:s.mutation,args:{...s.args,[s.subject]:e}};if(!m){p.push({id:e,label:g(e),message:`There is no act \u201C${s.mutation}\u201D.`,reason:"invalid"});continue}let t=a.permits(n,u);if(!t.ok){p.push({id:e,label:g(e),message:t.refusal.message,reason:"forbidden"});continue}if(!a.wouldChange(n,u)){h.push(e);continue}o.push({id:e,call:n})}let y=e=>a.previewAll(e,{...u?{author:u}:{},...r.context?{context:r.context}:{}});for(let e=0;o.length>0;e+=1)try{y(o.map(n=>n.call));break}catch(n){let t=[];for(let i of o)try{y([i.call]),t.push(i)}catch(f){p.push({id:i.id,label:g(i.id),message:l(f),reason:x(f).reason})}if(t.length===o.length||e>o.length){for(let i of t)p.push({id:i.id,label:g(i.id),message:l(n),reason:x(n).reason});o=[];break}o=t}if(o.length===0)return{applied:[],unchanged:h,refused:p};let b=s.label??(m?v(m):s.mutation),S=[...new Set(o.map(e=>a.graph.getNode(e.id)?.kind))],A=`${b} \u2014 ${S.length===1&&S[0]?j(a.schema,S[0],o.length):`${o.length} records`}`;try{let e=a.applyAll(o.map(n=>n.call),{intent:A,...u?{author:u}:{},...r.via?{via:r.via}:{}});return{batch:e.batch,intent:A,applied:o.map(n=>n.id),unchanged:h,refused:p,result:e}}catch(e){let n=l(e),t=x(e).reason;return{applied:[],unchanged:h,refused:[...p,...o.map(i=>({id:i.id,label:g(i.id),message:n,reason:t}))],allOrNothing:!0}}}export{V as a,_ as b};
@@ -0,0 +1 @@
1
+ import{a as we,b as De,c as Ke,d as le,e as A,f as Me,h as Te}from"./chunk.6YD2DLIC.js";import{h as Ge,i as Ce,j as Ne}from"./chunk.IKX4VDTW.js";import{a as oe,b as se,c as H,d as Pe,e as Y,g as ee,h as _e}from"./chunk.TBQOSI4J.js";import{c as Ae,h as z,i as Fe,j as de}from"./chunk.KWQ7QOHD.js";import{A as ve,Ga as Ee,Ha as Q,Ia as ae,Lb as ce,Mb as Re,b as L,c as q,e as Se,f as je,g as _,h as S,k as G,l as J,m as C,n as Oe,o as B,p as D,r as $,s as X,t as E,u as R,v as V,w as M,x as e,y as K,z as U,za as xe}from"./chunk.AS4CQBOQ.js";var sn=n=>Object.entries(n).map(([s,r])=>[s,Object.keys(Q(r?.edges))]),pe=(n,s)=>Re(n,sn(s));var me="graview-document",ge=1,ze=256*1024,ne=64*1024,fe=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,ue=/^[a-z][A-Za-z0-9]*$/,rn=new Set(["id","kind"]),an=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,cn=["string","text","number","integer","boolean","date","datetime","enum","list","url","email","image","video","file","app-link","phone","place","duration"];function dn(){let n=k=>k in Object.prototype,s=U(k=>!n(k),"every object already has this name \u2014 choose another"),r=(k,N)=>[...k===void 0?[]:[je(k)],...N===void 0?[]:[Se(N)]],t=(k,N)=>S().check(...r(k,N)),a=(k,N,on)=>D(k).check(...r(N,on)),d=k=>S().check(_(fe,`${k} names are kebab-case, lower-case words joined by hyphens like "tool-note" (field and relation names are camelCase, like "supersededBy")`)),u=S().check(_(an,'relation names are one camelCase word, like "supersededBy" (kind names are kebab-case, like "tool-note")'),s),m=S().check(_(ue,'field names are one word or camelCase, like "dueDate", so rules say them bare (kind names are kebab-case, like "tool-note")'),U(k=>!rn.has(k),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),s),h=t(1,500),i=t(1,2e3),o=t(1,300),p=$({type:V(cn),required:e(C()),description:e(h),label:e(t(1,60)),options:e(a(t(1,80),1,100)),of:e(V(["string","number","date","image","video","file"])),default:e(B()),unit:e(t(void 0,12)),format:e(V(["money","percent","duration","markdown"])),min:e(G()),max:e(G()),step:e(G()),renamedFrom:e(S().check(_(ue))),repeats:e(C())}).check(ve((k,N)=>{k.type==="enum"&&!k.options&&N.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),k.type!=="enum"&&k.options&&N.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),k.type!=="list"&&k.of&&N.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]}),k.repeats&&k.type!=="date"&&k.type!=="datetime"&&N.addIssue({code:"custom",message:'"repeats" belongs only on a date or datetime field',path:["repeats"]})})),w=S().check(_(new RegExp(`${fe.source}|${xe.source}`),'a relation goes to a kind of this document, like "house", or of another app, like "@nick/house/house"')),f=$({to:E([a(w,1),M("*")]),cardinality:e(V(["one","many"])),description:e(h),inverse:e(t(1,80)),appendOnly:e(C()),renamedFrom:e(S()),tidying:e(M("never"))}),l=E([i,$({expr:i,label:e(t(1,60)),description:e(h)})]),c=$({noun:e(t(1,40)),plural:e(t(1,40)),description:e(h),fields:R(m,p).check(U(k=>Object.keys(k).length>0,"a kind has at least one field")),label:e(o),describe:e(o),lifecycle:e($({field:m,retired:a(E([S(),G(),C()]),1)})),figure:e(t(void 0,2e4)),glance:e(a(m,1,20)),page:e($({fields:e(a(m,1,40)),groups:e(a($({title:t(1,60),fields:a(m,1,40)}),1,12))})),edges:e(R(u,f)),computed:e(R(S(),l).check(U(k=>Object.keys(k).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:e(R(S(),S())),renamedFrom:e(S().check(_(fe))),people:e(C()),archives:e(M(!1)),tidying:e(V(["never","no-links"]))}),O=E([S(),G(),C(),Oe(),D(B()),$({expr:i})]),y=S().check(_(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),j=E([$({create:d("kind"),as:e(S().check(_(ue))),set:e(R(m,O))}),$({set:R(m,O),target:e(y)}),$({connect:u,from:y,to:y}),$({sever:u,from:y,to:y}),$({remove:y})]),v=$({title:e(t(1,80)),description:e(h),fromTheOtherEnd:e(t(1,80)),on:e(E([d("kind"),a(d("kind"),1)])),creates:e(d("kind")),sets:e(R(m,O)),writes:e(a(m,1)),connects:e(u),severs:e(u),setsOther:e(R(m,O)),replaces:e(E([M(!0),a(u,1,10)])),removes:e(M(!0)),args:e(R(m,p)),effects:e(a(j,1,20)),allowedWhen:e(i),refusal:e(o),destructive:e(C())}),b=$({act:d("act"),label:e(t(1,80)),args:e(R(S(),O))}),W=$({title:e(t(1,120)),description:e(h),over:E([M("graph"),d("kind")]),when:e(i),require:i,says:e(o),repairs:e(a(b,void 0,10))}),P=$({roles:E([a(d("role"),1),M("*")]),mutations:E([a(d("act"),1),M("*")]),kinds:e(E([D(d("kind")),M("*")])),describe:e(h),self:e(C()),ownEnd:e(C())}),g=e(a(d("field"),1)),x=$({roles:E([a(d("role"),1),M("*")]),kinds:a(d("kind"),1),own:e(C()),via:e(u),fields:g,hide:g}),F=$({grants:D(P),sees:e(D(x))}),te=$({accent:e(S().check(_(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),name:e(t(1,60)),currency:e(S().check(_(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:e(t(2,35)),timeZone:e(t(1,64)),logo:e(E([t(1,ne),$({src:t(1,ne),alt:e(t(1,120))}),$({light:t(1,ne),dark:e(t(1,ne)),alt:e(t(1,120)),darkFallback:e(M("invert"))})])),favicon:e(E([t(1,ne),$({emoji:S()})])),typography:e($({display:e(t(1,200)),body:e(t(1,200)),mono:e(t(1,200))})),shape:e($({radius:e(G().check(q(0),L(32))),density:e(G().check(q(.75),L(1.5)))})),accents:e(R(S(),G().check(q(0),L(360)))),scheme:e(V(["light","dark","auto"])),subtitle:e(M(!1))}),I=R(S(),B()),Z=E([t(1,120),$({by:t(1,120),direction:e(V(["asc","desc"]))})]),ke=G().check(J(),q(1),L(9999)),Je=X({create:e(C()),options:e(X({sort:e(Z),columnSort:e(Z),search:e(a(t(1,120),void 0,40)),filters:e(a(t(1,120),void 0,40)),horizon:e(E([G().check(J(),q(1),L(200)),X({years:G().check(J(),q(1),L(200)),title:t(1,80),from:e(ke),to:e(ke)})]))}))}),Xe=$({card:e(D(B())),row:e(D(B())),page:e(D(B()))}),Qe=()=>{let k=e(V(["asc","desc"]));return E([t(1,120),$({by:t(1,120),direction:k,then:e(E([t(1,120),$({by:t(1,120),direction:k})]))})])},en=()=>E([t(1,120),$({by:t(1,120),order:e(a(t(1,80),void 0,40)),closed:e(a(t(1,80),void 0,40))})]),$e=X({order:e(D(S())),hide:e(D(S())),first:e(S()),primary:e(a(t(1,80),void 0,40)),scene:e(t(1,40)),pages:e(t(1,40)),lists:e(R(S(),$({filters:e(a(t(1,120),void 0,40)),sort:e(Qe()),group:e(en())})))}),nn=$({act:d("act"),title:e(t(1,80)),intro:e(h),fields:e(a(m,1,40)),say:e(h),submit:e(t(1,80)),role:e(d("role"))}),tn=$({$schema:e(S()),format:M(me),formatVersion:M(ge),name:t(1,80),description:e(h),version:e(G().check(J(),q(1))),kinds:R(d("kind"),c).check(U(k=>Object.keys(k).length>0,"a document declares at least one kind"),U(k=>Object.keys(k).length<=40,"a document declares at most 40 kinds")),computed:e(R(S(),l)),acts:e(R(d("act"),v)),rules:e(R(d("rule"),W)),roles:e(D(d("role"))),policy:e(F),modules:e(I),lenses:e(D(Je)),pages:e($e),views:e(R(S(),E([Xe,D(B())]))),brand:e(te),settings:e(D(I)),migrations:e(D(I)),connections:e(R(d("connection"),I)),forms:e(R(d("form"),nn))});return{FieldSpec:p,EdgeSpec:f,ComputedSpec:l,KindSpec:c,ValueSpec:O,EffectSpec:j,ActSpec:v,RepairSpec:b,RuleSpec:W,GrantSpec:P,SightSpec:x,PolicySpec:F,BrandSpec:te,PagesSpec:$e,DocumentSpec:tn}}var ln,T=()=>ln??=dn(),jn=K(()=>T().FieldSpec),On=K(()=>T().EdgeSpec),vn=K(()=>T().ComputedSpec),xn=K(()=>T().KindSpec),En=K(()=>T().ValueSpec),Rn=K(()=>T().EffectSpec),An=K(()=>T().ActSpec),Fn=K(()=>T().RepairSpec),Dn=K(()=>T().RuleSpec),Kn=K(()=>T().GrantSpec),Mn=K(()=>T().SightSpec),Tn=K(()=>T().PolicySpec),Pn=K(()=>T().BrandSpec),Gn=K(()=>T().PagesSpec),Ie=K(()=>T().DocumentSpec);var pn={};function Ve(n,s=pn,r=ge){let{document:t,respelled:a}=we(n),d=a.length>0?{respelled:a}:{};if(!t||typeof t!="object"||Array.isArray(t))return{document:t};let u=t;if(u.format!==me||typeof u.formatVersion!="number"||u.formatVersion>=r)return{document:t,...d};let m=u.formatVersion,h=structuredClone(u);for(let i=m;i<r;i++){let o=s[i];if(!o)throw new Error(`there is no upgrade from format ${i} to ${i+1}`);h={...o(h),formatVersion:i+1}}return{document:h,from:m,...d}}function qe(n,s,r){let t=Object.keys(n).filter(m=>n[m].edges?.[s]!==void 0);if(t.length===0)return;let a=t.map(m=>n[m].edges[s].to),d=a.some(m=>m==="*")?"*":[...new Set(a.flatMap(m=>m))];if(r.length===0||r.some(m=>t.includes(m)))return{reversed:!1,kinds:d};let u=t.filter(m=>{let h=n[m].edges[s].to;return h==="*"||r.every(i=>h.includes(i))});return u.length>0?{reversed:!0,kinds:u}:{reversed:!1,kinds:d}}var Ue=(n,s)=>{let r=n?.fields[s];return r!==void 0&&(r.type==="duration"||(r.type==="number"||r.type==="integer")&&r.format==="duration")};function Be(n,s,r,t){if(t==="out"){let a=n[s]?.edges?.[r]?.to;return a===void 0?[]:a==="*"?Object.keys(n):a}return Object.entries(n).filter(([,a])=>{let d=a.edges?.[r]?.to;return d!==void 0&&(d==="*"||d.includes(s))}).map(([a])=>a)}function ye(n,s,r){if(r.t==="ident")return n[s]?.edges?.[r.name]?Be(n,s,r.name,"out"):void 0;if(r.t==="where")return ye(n,s,r.set);if(r.t==="call"&&(r.fn==="out"||r.fn==="in")&&r.args[0]?.t==="lit"&&typeof r.args[0].value=="string")return Be(n,s,r.args[0].value,r.fn)}var Le=(n,s,r)=>{let t=s.filter(a=>n[a]?.fields[r]!==void 0);return t.length>0&&t.every(a=>Ue(n[a],r))};function We(n,s,r){let t=n.kinds,a=t[s],d=new Map(r),u=new Map,m=(i,o)=>{if(o>8)return!1;switch(i.t){case"ident":return Ue(a,i.name)||h(i.name,o+1);case"member":{let p=ye(t,s,i.object);return p!==void 0&&Le(t,p,i.name)}case"call":{if(i.fn!=="sum"&&i.fn!=="min"&&i.fn!=="max")return!1;let[p,w]=i.args,f=p&&ye(t,s,p);return f!==void 0&&w?.t==="ident"&&Le(t,f,w.name)}case"binary":return(i.op==="+"||i.op==="-")&&m(i.left,o)&&m(i.right,o);case"unary":return i.op==="-"&&m(i.operand,o);default:return!1}},h=(i,o)=>{if(a?.computed?.[i]===void 0)return!1;if(u.has(i))return u.get(i);u.set(i,!1);let p=d.get(i),w=p!==void 0&&m(p,o);return u.set(i,w),w};return r.map(([i])=>i).filter(i=>h(i,0))}function Ze(n,s,r=`kinds.${n}.page`){let t=s.page;if(!t)return[];let a=[],d=[...Object.keys(s.fields),...Object.keys(s.computed??{})],u=new Set,m=(i,o)=>{d.includes(i)?u.has(i)&&a.push(z("page-field-twice",o,`"${i}" is on ${n}'s page twice; name each field once`)):a.push(z("page-field",o,`${n}'s page is to show "${i}", and ${n} has no field or computed field called that`,`use one of: ${d.join(", ")}`)),u.add(i)};(t.fields??[]).forEach((i,o)=>m(i,`${r}.fields.${o}`));let h=new Set;return(t.groups??[]).forEach((i,o)=>{let p=i.title.trim().toLowerCase();h.has(p)&&a.push(z("page-group-twice",`${r}.groups.${o}.title`,`${n}'s page has two groups called "${i.title}"; give each its own title`)),h.add(p),i.fields.forEach((w,f)=>m(w,`${r}.groups.${o}.fields.${f}`))}),a}var fn=new Set(["subject","now","today","me"]);function un(n){if((typeof n=="string"?n:JSON.stringify(n??null)).length>ze)return{findings:[z("too-large","",`a document may be at most ${ze/1024} KB`)]};if(typeof n=="string")try{n=JSON.parse(n)}catch(t){return{findings:[z("not-json","",`this is not JSON: ${t.message}`)]}}try{n=Ve(n).document}catch(t){return{findings:[z("format","formatVersion",t.message)]}}let s=Ie.safeParse(n);if(!s.success)return{findings:s.error.issues.map(t=>{let a=t.path.map(String).join(".");if(t.code==="unrecognized_keys")return z("unknown-key",a,`${t.keys.map(d=>`"${d}"`).join(", ")} ${t.keys.length===1?"is":"are"} not part of a Graview document here`,"check the spelling against docs/declaration-document.md");if(t.code==="invalid_union"&&/\.effects\.\d+$/.test(a))return z("effect-shape",a,"this effect is not one Graview knows",'an effect is one of {"create": kind, "as"?: name, "set"?: {field: value}}, {"set": {field: value, \u2026}, "target"?: "$ref"}, {"connect"|"sever": relation, "from": "$ref", "to": "$ref"}, {"remove": "$ref"}');if(t.code==="invalid_key"){let d=t.issues?.[0]?.message;return z("shape",a,`the name "${String(t.path.at(-1))}" is not allowed here${d?`: ${d}`:""}`)}return z("shape",a,t.message)})};let r=s.data;return{document:r,findings:mn(r)}}var re=n=>[n??[]].flat();function He(n){let s=new Map;for(let[r,t]of Object.entries(n.kinds))for(let[a,d]of Object.entries(Q(t.edges))){let u=s.get(a);s.set(a,{name:a,from:[...u?.from??[],r],to:d.to==="*"||u?.to==="*"?"*":[...new Set([...u?.to??[],...d.to])],cardinality:d.cardinality??"many"})}return s}function pt(n){let s=new Map;for(let[t,a]of Object.entries(n.kinds)){let d=ee(a),u=ae(a.edges);s.set(t,{fields:new Set([...Object.keys(a.fields),...u.keys()]),edges:new Map(Object.entries(Q(a.edges)).map(([m,h])=>[m,h.cardinality??"many"])),...d?{computed:d}:{},...u.size>0?{linked:u}:{}})}let r=ee(n);return r&&s.set(Ae,{computed:r}),s}function Ye(n,s){let r=[],t=re(n.on),a=(d,u)=>{let m=qe(s.kinds,d,t)?.reversed===!0,[h,i]=m?["$to","$subject"]:["$subject","$to"];return u==="connect"?{connect:d,from:h,to:i}:{sever:d,from:h,to:i}};if(n.creates){let d=s.kinds[n.creates],u={};for(let m of Object.keys(d?.fields??{}))u[m]=`$${m}`;for(let m of n.effects??[])"set"in m&&!("create"in m)&&A(m.target)==="new"&&Object.assign(u,m.set);r.push({create:n.creates,as:"new",set:u})}return n.sets&&r.push({set:n.sets}),n.writes&&!(n.creates&&n.on===void 0)&&r.push({set:Object.fromEntries(n.writes.map(d=>[d,`$${d}`]))}),n.connects&&(n.replaces&&r.push({replace:n.replaces===!0?[n.connects]:[...n.replaces],keep:n.connects}),r.push(a(n.connects,"connect"))),n.severs&&r.push(a(n.severs,"sever")),n.setsOther&&(n.connects||n.severs)&&r.push({set:n.setsOther,target:"$to"}),n.removes&&r.push({remove:"$subject"}),n.effects&&r.push(...n.effects.filter(d=>!(n.creates&&"set"in d&&!("create"in d)&&A(d.target)==="new"))),r}function he(n,s,r){try{let t=H(n),a=oe(t);for(let d of a.unknownFunctions)r.push(z("unknown-function",s,`"${d}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));return t}catch(t){if(t instanceof se){r.push(z("expression",s,t.sentence+` (at character ${t.at+1})`));return}throw t}}function be(n,s,r){try{return Y(n)}catch(t){if(t instanceof Pe||t instanceof se){r.push(z("template",s,(t instanceof se,t.sentence)));return}throw t}}function mn(n){let s=[],r=new Set(Object.keys(n.kinds)),t=He(n),a=n.acts??{},d=new Set(n.roles??[]),u=(i,o)=>ae(n.kinds[i]?.edges).has(o),m=i=>Object.keys(n.kinds).some(o=>u(o,i));for(let[i,o]of Object.entries(n.kinds)){let p=`kinds.${i}`;for(let[f,l]of Object.entries(o.edges??{})){if(!Ee(l)&&l.to!=="*")for(let c of l.to)r.has(c)||s.push(z("edge-target",`${p}.edges.${f}.to`,`"${c}" is not a kind this document declares`));o.fields[f]&&s.push(z("edge-field-clash",`${p}.edges.${f}`,`"${f}" is both a field and a relation of ${i}`,"rename one of them"))}o.lifecycle&&!o.fields[o.lifecycle.field]&&s.push(z("lifecycle-field",`${p}.lifecycle.field`,`${i} has no field "${o.lifecycle.field}"`));let w=f=>o.computed!==void 0&&Object.hasOwn(o.computed,f);for(let f of o.glance??[])!o.fields[f]&&!w(f)&&s.push(z("glance-field",`${p}.glance`,`a glance at ${i} is to say "${f}", and ${i} has no field or computed field called that`,`use one of: ${[...Object.keys(o.fields),...Object.keys(o.computed??{})].join(", ")}`));s.push(...Ze(i,o));for(let f of["label","describe"]){let l=o[f];if(!l)continue;let c=be(l,`${p}.${f}`,s);for(let O of c??[])if(O.expr){for(let y of oe(O.expr).names)if(!o.fields[y]){if(w(y)){_e(o,y)||s.push(z("template-field",`${p}.${f}`,`${i}'s ${y} is worked out from beyond the record, and a ${f} is said with no graph to read`,`show it in a view instead, or name a computed field worked out from ${i}'s own fields`));continue}s.push(z("template-field",`${p}.${f}`,`${i} has no field "${y}" for its ${f} to show`,f==="label"?"a label can only show the record's own fields and what they work out":void 0))}}}for(let[f,l]of Object.entries(o.fields)){l.default!==void 0&&l.type==="enum"&&!l.options?.includes(String(l.default))&&s.push(z("default-option",`${p}.fields.${f}.default`,`"${String(l.default)}" is not one of ${f}'s options`));let c=`${f}Repeat`;l.repeats&&(o.fields[c]||o.edges?.[c]||o.computed?.[c])&&s.push(z("repeat-clash",`${p}.fields.${f}.repeats`,`${i} already has "${c}", where how ${f} repeats is kept`))}}for(let[i,o]of Object.entries(a)){let p=`acts.${i}`;for(let c of re(o.on))r.has(c)||s.push(z("act-kind",`${p}.on`,`"${c}" is not a kind this document declares`));let w=re(o.on),f=Ye(o,n);if(o.creates&&o.on===void 0&&o.writes&&r.has(o.creates)){for(let c of o.writes)if(!n.kinds[o.creates].fields[c])if(n.kinds[o.creates].computed?.[c]!==void 0)s.push(z("computed-written",`${p}.writes`,`${o.creates}'s ${c} is worked out, not written: no act can set it`,"write the stored fields it is worked out from"));else{if(u(o.creates,c))continue;s.push(z("act-field",`${p}.writes`,`${o.creates} has no field "${c}"`))}}f.length===0&&s.push(z("act-empty",p,`"${i}" does nothing`,"give it effects or a shorthand such as sets or creates"));let l=new Map;f.forEach((c,O)=>{let y=f.length-(o.effects?.length??0),j=o.effects&&O>=y?`${p}.effects.${O-y}`:p;if("create"in c){if(!r.has(c.create))s.push(z("act-kind",`${j}.create`,`"${c.create}" is not a kind this document declares`));else for(let b of Object.keys(c.set??{}))n.kinds[c.create].fields[b]||(n.kinds[c.create].computed?.[b]!==void 0?s.push(z("computed-written",`${j}.set.${b}`,`${c.create}'s ${b} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):s.push(z("act-field",`${j}.set.${b}`,`${c.create} has no field "${b}"`)));c.as&&l.set(c.as,c.create)}else if("connect"in c||"sever"in c){let b="connect"in c?c.connect:c.sever;!t.has(b)&&!m(b)&&s.push(z("act-edge",`${j}.${"connect"in c?"connect":"sever"}`,`"${b}" is not a relation any kind declares`)),A(c.from)==="subject"&&w.length===0&&s.push(z("act-subject",`${p}.on`,`"${i}" acts on "$subject" but does not say which kinds it is "on"`))}else if("set"in c){let b=A(c.target??"$subject"),W=b==="subject"?w:l.has(b??"")?[l.get(b)]:[];b==="subject"&&w.length===0&&s.push(z("act-subject",`${p}.on`,`"${i}" changes "$subject" but does not say which kinds it is "on"`));for(let P of Object.keys(c.set))for(let g of W)if(!(!r.has(g)||n.kinds[g].fields[P]))if(n.kinds[g].computed?.[P]!==void 0)s.push(z("computed-written",`${j}.set.${P}`,`${g}'s ${P} is worked out, not written: no act can set it`,"set the stored fields it is worked out from"));else{if(u(g,P))continue;s.push(z("act-field",`${j}.set.${P}`,`${g} has no field "${P}"`))}}else"remove"in c&&A(c.remove)==="subject"&&w.length===0&&s.push(z("act-subject",`${p}.on`,`"${i}" removes "$subject" but does not say which kinds it is "on"`));("set"in c&&c.set?Object.values(c.set):[]).forEach(b=>{b&&typeof b=="object"&&!Array.isArray(b)&&"expr"in b&&he(b.expr,`${j}.set`,s)})}),o.allowedWhen&&he(o.allowedWhen,`${p}.allowedWhen`,s),o.refusal&&be(o.refusal,`${p}.refusal`,s)}for(let[i,o]of Object.entries(n.rules??{})){let p=`rules.${i}`;o.over!=="graph"&&!r.has(o.over)&&s.push(z("rule-kind",`${p}.over`,`"${o.over}" is not a kind this document declares`));let w=o.over==="graph"?void 0:n.kinds[o.over];for(let f of["when","require"]){let l=o[f];if(!l)continue;let c=he(l,`${p}.${f}`,s);if(!c)continue;let O=oe(c);for(let y of O.names)if(o.over==="graph")s.push(z("rule-name",`${p}.${f}`,`"${y}" means nothing in a rule over the whole graph`,`name a kind in "over", or use all('kind')`));else if(w&&!w.fields[y]&&!w.edges?.[y]&&w.computed?.[y]===void 0){let j=Object.keys(w.edges??{}).find(v=>v.includes("-")&&v.split("-").includes(y));s.push(z("rule-name",`${p}.${f}`,`${o.over} has no field or relation called "${y}"`,j?`"${j}" reads as a subtraction in a rule; rename the relation to one camelCase word, like "${j.replace(/-([a-z0-9])/g,(v,b)=>b.toUpperCase())}"`:void 0))}for(let y of O.edges)!t.has(y)&&!m(y)&&s.push(z("rule-edge",`${p}.${f}`,`"${y}" is not a relation any kind declares`));for(let y of O.sweeps)r.has(y)?o.over!=="graph"&&s.push(Fe("rule-cost",`${p}.${f}`,`this rule looks at every ${y} for every ${o.over}, which grows slowly as the app grows`,"walk a relation with out()/in() instead of all() where you can")):s.push(z("rule-kind",`${p}.${f}`,`"${y}" is not a kind this document declares`))}o.says&&be(o.says,`${p}.says`,s),(o.repairs??[]).forEach((f,l)=>{!a[f.act]&&!ce(f.act)&&!pe(f.act,n.kinds)&&s.push(z("repair-act",`${p}.repairs.${l}.act`,`"${f.act}" is not an act this document declares`))})}let h=n.policy;return h&&(h.grants.forEach((i,o)=>{if(i.roles!=="*"&&d.size>0)for(let p of i.roles)d.has(p)||s.push(z("grant-role",`policy.grants.${o}.roles`,`"${p}" is not one of the document's roles`));if(i.mutations!=="*")for(let p of i.mutations)!a[p]&&!ce(p)&&!pe(p,n.kinds)&&s.push(z("grant-act",`policy.grants.${o}.mutations`,`"${p}" is not an act this document declares`))}),(h.sees??[]).forEach((i,o)=>{for(let p of i.kinds)r.has(p)||s.push(z("sight-kind",`policy.sees.${o}.kinds`,`"${p}" is not a kind this document declares`));if(i.roles!=="*"&&d.size>0)for(let p of i.roles)d.has(p)||s.push(z("sight-role",`policy.sees.${o}.roles`,`"${p}" is not one of the document's roles`))})),s.push(...Ne(n)),s}function gn(n,s,r,t){let a=new Map,d=re(n.on),u=new Map,m=new Map;(d.length>0||s.some(l=>"remove"in l&&A(l.remove)==="subject"||"from"in l&&(A(l.from)==="subject"||A(l.to)==="subject")||"set"in l&&!("create"in l)&&A(l.target??"$subject")==="subject"))&&a.set(le,{ref:d.length>0?d:"*",required:!0});let i=n.args??{},o=n.writes?.length===1,p=(l,c)=>c&&l.type===c.type&&l.min===void 0&&l.max===void 0&&l.step===void 0?{...l,...c.min===void 0?{}:{min:c.min},...c.max===void 0?{}:{max:c.max},...c.step===void 0?{}:{step:c.step}}:l,w=(l,c)=>c&&l.type===c.type&&l.format===void 0&&l.unit===void 0?{...p(l,c),...c.format?{format:c.format}:{},...c.unit?{unit:c.unit}:{}}:p(l,c),f=(l,c,O)=>{if(l===le||fn.has(l)||u.has(l)||a.has(l))return;let y=i[l]?w(i[l],O):void 0;a.set(l,y?{field:y,optional:!y.required,required:!!y.required}:c())};for(let l of s)if("create"in l){let c=r.kinds[l.create];for(let[O,y]of Object.entries(l.set??{})){let j=A(y),v=c?.fields[O];if(j&&v){let b=!!v.required&&v.default===void 0;f(j,()=>({field:v,optional:!b,required:b}),v)}}l.as&&u.set(l.as,l.create)}else if("connect"in l||"sever"in l){let c=t.get("connect"in l?l.connect:l.sever);for(let[O,y]of[["from",l.from],["to",l.to]]){let j=A(y);if(!j)continue;let v=O==="to"?c?.to??"*":c?.from??"*";v!=="*"&&!m.has(j)&&m.set(j,v),f(j,()=>({ref:v,required:!0}))}}else if("set"in l){let c=A(l.target??"$subject"),O=c==="subject"?d[0]:u.get(c??"")??m.get(c??"")?.[0];c&&c!=="subject"&&!u.has(c)&&f(c,()=>({ref:"*",required:!0}));for(let[y,j]of Object.entries(l.set)){let v=A(j);if(!v)continue;let b=O?r.kinds[O]?.fields[y]:void 0;f(v,()=>b?{field:b,optional:!o,required:o}:{any:!0,required:!1},b)}}else if("remove"in l){let c=A(l.remove);c&&f(c,()=>({ref:"*",required:!0}))}for(let[l,c]of Object.entries(i))a.has(l)||a.set(l,{field:c,optional:!c.required,required:!!c.required});return a}function ft(n,s={}){let r=un(n);if(!r.document||de(r.findings))return{ok:!1,findings:r.findings};let t=r.document,a=[...r.findings];s.previous&&a.push(...yn(t,s.previous));let d=zn(t,a);return de(d.findings)?{ok:!1,findings:d.findings}:Te(d,s)}function ie(n,s){return n.map(r=>{let t=!r.format&&r.expr?.t==="ident"?s?.[r.expr.name]?.format:void 0;return t==="money"||t==="percent"?{...r,format:t}:r})}function zn(n,s){let r=He(n),t={};for(let[i,o]of Object.entries(n.kinds)){let p=Me(o),w=o.label??(p?`{${p}}`:void 0),f=ee(o),l=f?We(n,i,[...f]):[];t[i]={...w?{label:ie(Y(w),o.fields)}:{},...o.describe?{describe:ie(Y(o.describe),o.fields)}:{},...f?{computed:[...f]}:{},...l.length>0?{durations:l}:{}}}let a={};for(let[i,o]of Object.entries(n.acts??{})){let p=Ye(o,n),w=gn(o,p,n,r),f=o.destructive??p.some(g=>"remove"in g||"sever"in g||"replace"in g),l=[...new Set(p.flatMap(g=>"create"in g?[g.create]:[]))],c=[...new Set(p.flatMap(g=>"connect"in g?[g.connect]:[]))],O=[...new Set(p.flatMap(g=>"sever"in g?[g.sever]:"replace"in g?g.replace:[]))],y=[...new Set(p.flatMap(g=>"set"in g&&!("create"in g)&&A(g.target??"$subject")==="subject"?Object.keys(g.set):[]))],j=new Map;for(let g of p){if(!("connect"in g)&&!("sever"in g))continue;let x=r.get("connect"in g?g.connect:g.sever);for(let[F,te]of[["from",g.from],["to",g.to]]){let I=A(te),Z=F==="to"?x?.to:x?.from;I&&I!=="subject"&&Z&&Z!=="*"&&j.set(I,[...new Set([...j.get(I)??[],...Z])])}}let v={};for(let g of p){if(!("set"in g)||"create"in g)continue;let x=A(g.target??"$subject");for(let F of x&&x!=="subject"&&j.get(x)||[])v[F]=[...new Set([...v[F]??[],...Object.keys(g.set)])]}let b={};for(let g of p)if(!(!("set"in g)||"create"in g||A(g.target??"$subject")!=="subject"))for(let[x,F]of Object.entries(g.set??{}))typeof F=="string"&&A(F)===void 0||typeof F=="number"||typeof F=="boolean"?b[x]=typeof F=="string"&&F.startsWith("$$")?F.slice(1):F:delete b[x];let W=l.length===0&&p.every(g=>!("set"in g)||!g.set||Object.values(g.set).every(x=>!(x&&typeof x=="object"&&!Array.isArray(x)&&"expr"in x))),P=new Map;for(let g of p)if(!(!("set"in g)||!g.set))for(let x of Object.values(g.set))x&&typeof x=="object"&&!Array.isArray(x)&&"expr"in x&&P.set(x.expr,H(x.expr));a[i]={title:o.title??i.replace(/-/g," "),effects:p,args:[...w],...o.allowedWhen?{guard:H(o.allowedWhen)}:{},...o.refusal?{refusal:ie(Y(o.refusal),n.kinds[[o.on??[]].flat()[0]??""]?.fields)}:{},exprs:[...P],destructive:f,idempotent:W,creates:l,connects:c,severs:O,writes:y,writesOther:v,sets:b}}let d={};for(let[i,o]of Object.entries(n.rules??{}))d[i]={title:o.title??i.replace(/-/g," "),require:H(o.require),...o.when?{when:H(o.when)}:{},...o.says?{says:ie(Y(o.says),n.kinds[o.over]?.fields)}:{}};let u=De(n,s),m=Ge(n),h=Ce(n);return{format:Ke,document:n,findings:s,kinds:t,...n.computed?{facts:[...ee(n)??[]]}:{},edges:[...r].map(([i,{from:o,to:p,cardinality:w}])=>[i,{from:o,to:p,cardinality:w}]),acts:a,rules:d,brand:u,...Object.keys(m).length>0?{viewSpecs:m}:{},...h?{home:h}:{}}}function ut(n,s,r){let t=/^defineNode\("([^"]+)"\)/.exec(s)?.[1],a=t?r.kinds[t]:void 0;if(!t||!a)return n;let d=Object.keys(a.fields).filter(u=>u!=="label").slice(0,3);return{...n,path:`kinds.${t}.glance`,fix:`Say which: "glance": [${d.map(u=>`"${u}"`).join(", ")}] on kinds.${t} \u2014 the facts a person compares one by, at a glance.`}}function yn(n,s){let r=[],t=new Set(Object.values(s.kinds).flatMap(a=>Object.keys(a.edges??{})));for(let[a,d]of Object.entries(n.kinds)){let u=d.renamedFrom;u&&!s.kinds[u]&&r.push(z("renamed-from-nothing",`kinds.${a}.renamedFrom`,`${a} says it was ${u}, and the previous version has no kind called ${u}`,"name the kind it was, or drop renamedFrom"));let m=s.kinds[u??a];for(let[h,i]of Object.entries(d.fields)){let o=i.renamedFrom;o&&!m?.fields[o]&&r.push(z("renamed-from-nothing",`kinds.${a}.fields.${h}.renamedFrom`,`${h} says it was ${o}, and the previous ${u??a} has no field called ${o}`,"name the field it was, or drop renamedFrom"))}for(let[h,i]of Object.entries(d.edges??{})){let o=i.renamedFrom;o&&!t.has(o)&&r.push(z("renamed-from-nothing",`kinds.${a}.edges.${h}.renamedFrom`,`${h} says it was ${o}, and the previous version has no relation called ${o}`,"name the relation it was, or drop renamedFrom"))}}return r}export{un as a,pt as b,Ye as c,ft as d,ut as e};
@@ -1 +1 @@
1
- import"./chunk.6BJBPDF3.js";import{G as W,R as x}from"./chunk.XWAMQPUM.js";import"./chunk.SDO3U72B.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import{b as D}from"./chunk.AJZBJBMO.js";var g=D(W(),1);var o=D(x(),1),v=864e5,l=t=>Date.UTC(+t.slice(0,4),+t.slice(5,7)-1,+t.slice(8,10)),I=t=>new Date(t).toISOString().slice(0,10),s=(t,i)=>I(l(t)+i*v),m=(t,i)=>{let a=new Date(l(t)),u=a.getUTCMonth()+i,d=Date.UTC(a.getUTCFullYear(),u,1),w=new Date(Date.UTC(a.getUTCFullYear(),u+1,0)).getUTCDate();return I(d+(Math.min(a.getUTCDate(),w)-1)*v)};function p(t,i,a){try{return new Intl.DateTimeFormat(t??"en-US",{...i,timeZone:"UTC"}).format(a)}catch{return new Intl.DateTimeFormat("en-US",{...i,timeZone:"UTC"}).format(a)}}function F(t){try{let i=new Intl.Locale(t??"en-US"),a=i.getWeekInfo?.().firstDay??i.weekInfo?.firstDay;if(a!==void 0)return a%7}catch{return 0}return/^en-US|^en$|-(US|CA|JP|BR|IL|MX|PH)$/.test(t??"en-US")?0:1}function L({id:t,label:i,selected:a,today:u,locale:d,onPick:w,onClose:T}){let[r,f]=(0,g.useState)(a??u),U=(0,g.useRef)(null),y=F(d),b=`${r.slice(0,7)}-01`,M=(new Date(l(b)).getUTCDay()-y+7)%7,P=s(b,-M),A=Array.from({length:6},(e,n)=>Array.from({length:7},(S,c)=>s(P,n*7+c))),$=p(d,{month:"long",year:"numeric"},l(b)),h=(0,g.useRef)(!0);(0,g.useEffect)(()=>{h.current&&U.current?.querySelector(`[data-day="${r}"]`)?.focus(),h.current=!1},[r]);let E=e=>{let n={ArrowLeft:()=>s(r,-1),ArrowRight:()=>s(r,1),ArrowUp:()=>s(r,-7),ArrowDown:()=>s(r,7),PageUp:()=>m(r,e.shiftKey?-12:-1),PageDown:()=>m(r,e.shiftKey?12:1),Home:()=>s(r,-((new Date(l(r)).getUTCDay()-y+7)%7)),End:()=>s(r,6-(new Date(l(r)).getUTCDay()-y+7)%7)};n[e.key]?(e.preventDefault(),h.current=!0,f(n[e.key]())):e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),T())},R=Array.from({length:7},(e,n)=>l("1970-01-04")+(y+n)%7*v),C={minWidth:32,minHeight:32,padding:"0 8px",borderRadius:6};return(0,o.jsxs)("div",{id:t,role:"group","aria-label":`Pick a date for ${i}`,"data-graview-part":"when-month",onKeyDown:e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),T())},style:{flexBasis:"100%",width:"min(100%, 20rem)",boxSizing:"border-box",padding:8,border:"1px solid var(--graview-edge)",borderRadius:8,background:"var(--graview-panel)",color:"var(--graview-ink)"},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6,marginBottom:6},children:[(0,o.jsx)("button",{type:"button","aria-label":"Previous month",onClick:()=>f(m(r,-1)),style:C,children:"\u2039"}),(0,o.jsx)("span",{id:`${t}-title`,"aria-live":"polite",style:{fontWeight:600,fontSize:"0.875rem"},children:$}),(0,o.jsx)("button",{type:"button","aria-label":"Next month",onClick:()=>f(m(r,1)),style:C,children:"\u203A"})]}),(0,o.jsxs)("table",{ref:U,role:"grid","aria-labelledby":`${t}-title`,onKeyDown:E,style:{width:"100%",borderCollapse:"collapse",tableLayout:"fixed",fontSize:"0.8125rem"},children:[(0,o.jsx)("thead",{children:(0,o.jsx)("tr",{children:R.map(e=>(0,o.jsx)("th",{scope:"col",abbr:p(d,{weekday:"long"},e),style:{fontWeight:500,color:"var(--graview-ink-faint)",padding:"2px 0"},children:p(d,{weekday:"narrow"},e)},e))})}),(0,o.jsx)("tbody",{children:A.map(e=>(0,o.jsx)("tr",{children:e.map(n=>{let S=n.slice(0,7)===b.slice(0,7),c=n===a,k=n===u;return(0,o.jsx)("td",{role:"gridcell","aria-selected":c||void 0,style:{padding:1,textAlign:"center"},children:(0,o.jsx)("button",{type:"button","data-day":n,tabIndex:n===r?0:-1,"aria-label":`${p(d,{weekday:"long",year:"numeric",month:"long",day:"numeric"},l(n))}${k?", today":""}${c?", selected":""}`,...k?{"aria-current":"date"}:{},onClick:()=>w(n),onFocus:()=>n!==r&&f(n),style:{width:"100%",minHeight:36,padding:0,borderRadius:6,border:k?"1px solid var(--graview-accent)":"1px solid transparent",background:c?"var(--graview-accent)":"transparent",color:c?"var(--graview-accent-ink)":S?"var(--graview-ink)":"var(--graview-ink-faint)",fontWeight:c?600:400},children:Number(n.slice(8,10))})},n)})},e[0]))})]})]})}export{L as WhenMonth};
1
+ import"./chunk.O4WEJ47H.js";import{G as W,R as x}from"./chunk.Y4ZUJUUT.js";import"./chunk.SDO3U72B.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import{b as D}from"./chunk.AJZBJBMO.js";var g=D(W(),1);var o=D(x(),1),v=864e5,l=t=>Date.UTC(+t.slice(0,4),+t.slice(5,7)-1,+t.slice(8,10)),I=t=>new Date(t).toISOString().slice(0,10),s=(t,i)=>I(l(t)+i*v),m=(t,i)=>{let a=new Date(l(t)),u=a.getUTCMonth()+i,d=Date.UTC(a.getUTCFullYear(),u,1),w=new Date(Date.UTC(a.getUTCFullYear(),u+1,0)).getUTCDate();return I(d+(Math.min(a.getUTCDate(),w)-1)*v)};function p(t,i,a){try{return new Intl.DateTimeFormat(t??"en-US",{...i,timeZone:"UTC"}).format(a)}catch{return new Intl.DateTimeFormat("en-US",{...i,timeZone:"UTC"}).format(a)}}function F(t){try{let i=new Intl.Locale(t??"en-US"),a=i.getWeekInfo?.().firstDay??i.weekInfo?.firstDay;if(a!==void 0)return a%7}catch{return 0}return/^en-US|^en$|-(US|CA|JP|BR|IL|MX|PH)$/.test(t??"en-US")?0:1}function L({id:t,label:i,selected:a,today:u,locale:d,onPick:w,onClose:T}){let[r,f]=(0,g.useState)(a??u),U=(0,g.useRef)(null),y=F(d),b=`${r.slice(0,7)}-01`,M=(new Date(l(b)).getUTCDay()-y+7)%7,P=s(b,-M),A=Array.from({length:6},(e,n)=>Array.from({length:7},(S,c)=>s(P,n*7+c))),$=p(d,{month:"long",year:"numeric"},l(b)),h=(0,g.useRef)(!0);(0,g.useEffect)(()=>{h.current&&U.current?.querySelector(`[data-day="${r}"]`)?.focus(),h.current=!1},[r]);let E=e=>{let n={ArrowLeft:()=>s(r,-1),ArrowRight:()=>s(r,1),ArrowUp:()=>s(r,-7),ArrowDown:()=>s(r,7),PageUp:()=>m(r,e.shiftKey?-12:-1),PageDown:()=>m(r,e.shiftKey?12:1),Home:()=>s(r,-((new Date(l(r)).getUTCDay()-y+7)%7)),End:()=>s(r,6-(new Date(l(r)).getUTCDay()-y+7)%7)};n[e.key]?(e.preventDefault(),h.current=!0,f(n[e.key]())):e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),T())},R=Array.from({length:7},(e,n)=>l("1970-01-04")+(y+n)%7*v),C={minWidth:32,minHeight:32,padding:"0 8px",borderRadius:6};return(0,o.jsxs)("div",{id:t,role:"group","aria-label":`Pick a date for ${i}`,"data-graview-part":"when-month",onKeyDown:e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),T())},style:{flexBasis:"100%",width:"min(100%, 20rem)",boxSizing:"border-box",padding:8,border:"1px solid var(--graview-edge)",borderRadius:8,background:"var(--graview-panel)",color:"var(--graview-ink)"},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6,marginBottom:6},children:[(0,o.jsx)("button",{type:"button","aria-label":"Previous month",onClick:()=>f(m(r,-1)),style:C,children:"\u2039"}),(0,o.jsx)("span",{id:`${t}-title`,"aria-live":"polite",style:{fontWeight:600,fontSize:"0.875rem"},children:$}),(0,o.jsx)("button",{type:"button","aria-label":"Next month",onClick:()=>f(m(r,1)),style:C,children:"\u203A"})]}),(0,o.jsxs)("table",{ref:U,role:"grid","aria-labelledby":`${t}-title`,onKeyDown:E,style:{width:"100%",borderCollapse:"collapse",tableLayout:"fixed",fontSize:"0.8125rem"},children:[(0,o.jsx)("thead",{children:(0,o.jsx)("tr",{children:R.map(e=>(0,o.jsx)("th",{scope:"col",abbr:p(d,{weekday:"long"},e),style:{fontWeight:500,color:"var(--graview-ink-faint)",padding:"2px 0"},children:p(d,{weekday:"narrow"},e)},e))})}),(0,o.jsx)("tbody",{children:A.map(e=>(0,o.jsx)("tr",{children:e.map(n=>{let S=n.slice(0,7)===b.slice(0,7),c=n===a,k=n===u;return(0,o.jsx)("td",{role:"gridcell","aria-selected":c||void 0,style:{padding:1,textAlign:"center"},children:(0,o.jsx)("button",{type:"button","data-day":n,tabIndex:n===r?0:-1,"aria-label":`${p(d,{weekday:"long",year:"numeric",month:"long",day:"numeric"},l(n))}${k?", today":""}${c?", selected":""}`,...k?{"aria-current":"date"}:{},onClick:()=>w(n),onFocus:()=>n!==r&&f(n),style:{width:"100%",minHeight:36,padding:0,borderRadius:6,border:k?"1px solid var(--graview-accent)":"1px solid transparent",background:c?"var(--graview-accent)":"transparent",color:c?"var(--graview-accent-ink)":S?"var(--graview-ink)":"var(--graview-ink-faint)",fontWeight:c?600:400},children:Number(n.slice(8,10))})},n)})},e[0]))})]})]})}export{L as WhenMonth};
@@ -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{b as z}from"./chunk.3NMINX5Z.js";import{a as U,b as V,c as b,d as B,e as C,f as W}from"./chunk.JHIUG25Q.js";import{a as J,b as h,d as A}from"./chunk.NMIXBH37.js";import{a as p,b as T,c as S,e as _}from"./chunk.BBLIT7S7.js";import{a as R}from"./chunk.SDO3U72B.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import"./chunk.AJZBJBMO.js";var Q=R(()=>(__graviewPreload(import.meta.url,["./chunk.AJZBJBMO.js"]),import("./chunk.SHNYYBNW.js")));function te(d,e){let f=d.ownerDocument,u=f.defaultView,t=f.createElement("iframe");t.setAttribute("sandbox",T),t.setAttribute("referrerpolicy","no-referrer"),t.setAttribute("allow",""),t.setAttribute("title",e.title??e.view),t.setAttribute("data-guest-view",e.view),t.setAttribute("aria-busy","true"),t.style.border="0",t.style.width="100%",t.style.display="block",t.src=e.url;let a={applied:0,refused:0,dropped:0},P=h(e.limits),i,y,o={applied:0,refused:0,dropped:0},v=()=>{if(!i)return;let r=i.stats;a.applied+=r.applied-o.applied,a.refused+=r.refused-o.refused,a.dropped+=r.dropped-o.dropped,o={...r}},O=W(u,()=>l(),"data"),g=()=>C(()=>e.theme?.()??b(d),e.brand,O),L="",l=()=>{i&&(L=JSON.stringify(g()),i.push())},k=B(f,()=>{i&&JSON.stringify(g())!==L&&l()}),n,w=!1,D=e.pictures?z(Q,({createGuestPictures:r})=>{n=r(u,{as:"data",view:`"${e.title??e.view}"`,pictures:e.pictures,...e.limits?{limits:e.limits}:{},...e.file?{file:e.file}:{},moved:()=>{i?.push(),G&&E()}}),w&&x()}):()=>{},G=!1,c,N=()=>{!G||n?.waiting()||(clearTimeout(c),t.removeAttribute("data-guest-view-failed"),t.removeAttribute("aria-busy"),t.setAttribute("data-guest-view-drawn",""))},E=()=>{clearTimeout(c),c=setTimeout(N,250)},F=setTimeout(()=>{i||(t.removeAttribute("aria-busy"),t.setAttribute("data-guest-view-failed","silent"))},e.limits?.readyMs??8e3),H=()=>{v(),i?.dispose(),y?.close(),i=void 0,y=void 0,o={applied:0,refused:0,dropped:0}},M=r=>{if(!(r.source===null||r.source!==t.contentWindow)){if(r.origin!==S||!P.message()){a.dropped+=1;return}if(!_(r.data)||r.data.protocol!==1){a.dropped+=1;return}if(e.pictures&&!n){w=!0;return}x()}},x=()=>{w=!1,H();let r=U(),m=new MessageChannel;y=m.port1;let I=A({store:e.store,principal:e.principal,view:e.view,nonce:r,send:s=>m.port1.postMessage(s),...e.input?{input:e.input}:{},...e.reads?{reads:e.reads}:{},...n?{hand:n.hand}:{},theme:g,...e.places?{places:()=>[...new Set(e.places().map(s=>s.as))],placesShown:e.places}:{},...e.onNavigatePlace?{onNavigatePlace:e.onNavigatePlace}:{},...e.onNavigate?{onNavigate:e.onNavigate}:{},...e.onArrive?{onArrive:e.onArrive}:e.goTo?{onArrive:s=>V(e.goTo(),s)}:{},...e.onLost?{onLost:e.onLost}:{},onSize:s=>{e.onSize?e.onSize(s):t.style.height=`${s}px`,N()},...e.limits?{limits:e.limits}:{},limiter:P});i=I,m.port1.onmessage=s=>{I.receive(s.data),v()};let j={graview:"host-hello",protocol:1,nonce:r,view:e.view};t.contentWindow.postMessage(j,"*",[m.port2]),l(),G=!0,E()};return u.addEventListener("message",M),d.appendChild(t),d.removeAttribute("aria-busy"),{iframe:t,update:l,get stats(){return v(),a},dispose(){H(),clearTimeout(F),clearTimeout(c),k(),O.dispose(),D(),n?.dispose(),u.removeEventListener("message",M),t.remove()}}}export{p as GUEST_PROTOCOL,T as GUEST_SANDBOX,S as OPAQUE_ORIGIN,A as createGuestHost,h as createGuestLimiter,te as mountGuestView,J as readAcross,b as readTheme};
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{b as z}from"./chunk.IXOQQBJE.js";import{a as U,b as V,d as b,e as B,f as C,g as W}from"./chunk.3LDYUO77.js";import{a as J,b as h,d as A}from"./chunk.NFIGGSMJ.js";import{a as p,b as T,c as S,e as _}from"./chunk.BBLIT7S7.js";import{a as R}from"./chunk.SDO3U72B.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import"./chunk.AJZBJBMO.js";var Q=R(()=>(__graviewPreload(import.meta.url,["./chunk.AJZBJBMO.js"]),import("./chunk.SHNYYBNW.js")));function te(d,e){let f=d.ownerDocument,u=f.defaultView,t=f.createElement("iframe");t.setAttribute("sandbox",T),t.setAttribute("referrerpolicy","no-referrer"),t.setAttribute("allow",""),t.setAttribute("title",e.title??e.view),t.setAttribute("data-guest-view",e.view),t.setAttribute("aria-busy","true"),t.style.border="0",t.style.width="100%",t.style.display="block",t.src=e.url;let a={applied:0,refused:0,dropped:0},P=h(e.limits),i,y,o={applied:0,refused:0,dropped:0},v=()=>{if(!i)return;let r=i.stats;a.applied+=r.applied-o.applied,a.refused+=r.refused-o.refused,a.dropped+=r.dropped-o.dropped,o={...r}},O=W(u,()=>l(),"data"),g=()=>C(()=>e.theme?.()??b(d),e.brand,O),L="",l=()=>{i&&(L=JSON.stringify(g()),i.push())},k=B(f,()=>{i&&JSON.stringify(g())!==L&&l()}),n,w=!1,D=e.pictures?z(Q,({createGuestPictures:r})=>{n=r(u,{as:"data",view:`"${e.title??e.view}"`,pictures:e.pictures,...e.limits?{limits:e.limits}:{},...e.file?{file:e.file}:{},moved:()=>{i?.push(),G&&E()}}),w&&x()}):()=>{},G=!1,c,N=()=>{!G||n?.waiting()||(clearTimeout(c),t.removeAttribute("data-guest-view-failed"),t.removeAttribute("aria-busy"),t.setAttribute("data-guest-view-drawn",""))},E=()=>{clearTimeout(c),c=setTimeout(N,250)},F=setTimeout(()=>{i||(t.removeAttribute("aria-busy"),t.setAttribute("data-guest-view-failed","silent"))},e.limits?.readyMs??8e3),H=()=>{v(),i?.dispose(),y?.close(),i=void 0,y=void 0,o={applied:0,refused:0,dropped:0}},M=r=>{if(!(r.source===null||r.source!==t.contentWindow)){if(r.origin!==S||!P.message()){a.dropped+=1;return}if(!_(r.data)||r.data.protocol!==1){a.dropped+=1;return}if(e.pictures&&!n){w=!0;return}x()}},x=()=>{w=!1,H();let r=U(),m=new MessageChannel;y=m.port1;let I=A({store:e.store,principal:e.principal,view:e.view,nonce:r,send:s=>m.port1.postMessage(s),...e.input?{input:e.input}:{},...e.reads?{reads:e.reads}:{},...n?{hand:n.hand}:{},theme:g,...e.places?{places:()=>[...new Set(e.places().map(s=>s.as))],placesShown:e.places}:{},...e.onNavigatePlace?{onNavigatePlace:e.onNavigatePlace}:{},...e.onNavigate?{onNavigate:e.onNavigate}:{},...e.onArrive?{onArrive:e.onArrive}:e.goTo?{onArrive:s=>V(e.goTo(),s)}:{},...e.onLost?{onLost:e.onLost}:{},onSize:s=>{e.onSize?e.onSize(s):t.style.height=`${s}px`,N()},...e.limits?{limits:e.limits}:{},limiter:P});i=I,m.port1.onmessage=s=>{I.receive(s.data),v()};let j={graview:"host-hello",protocol:1,nonce:r,view:e.view};t.contentWindow.postMessage(j,"*",[m.port2]),l(),G=!0,E()};return u.addEventListener("message",M),d.appendChild(t),d.removeAttribute("aria-busy"),{iframe:t,update:l,get stats(){return v(),a},dispose(){H(),clearTimeout(F),clearTimeout(c),k(),O.dispose(),D(),n?.dispose(),u.removeEventListener("message",M),t.remove()}}}export{p as GUEST_PROTOCOL,T as GUEST_SANDBOX,S as OPAQUE_ORIGIN,A as createGuestHost,h as createGuestLimiter,te as mountGuestView,J as readAcross,b as readTheme};
@@ -1 +1 @@
1
- import{Fa as H,G as C,Ha as A,R as F}from"./chunk.XWAMQPUM.js";import"./chunk.SDO3U72B.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import{b as x}from"./chunk.AJZBJBMO.js";var t=x(C(),1),f=x(F(),1),q={faces:'[data-testid="app-faces"]',problems:'[data-testid="standing"], [data-testid="standing-link"]',activity:'[data-testid="activity-button"]',ask:'[data-testid="app-find"], [data-testid="app-find-open"]',find:'[data-testid="app-find"], [data-testid="app-find-open"]',profile:'[data-testid="profile-button"]',home:'[data-testid="app-home"]'};function D(e){if(!e.isConnected||e.closest("[hidden], [inert], [aria-hidden='true']"))return!1;if(typeof e.checkVisibility!="function")return!0;if(!e.checkVisibility({visibilityProperty:!0}))return!1;let a=e.getBoundingClientRect();return a.width>1&&a.height>1}function E(e,a){if(!e||a==="ask"&&!e.querySelector("[data-graview-quick-ask]"))return null;for(let d of e.querySelectorAll(q[a]))if(D(d))return d;return null}function W(e){let a=(u,h,c)=>e.querySelector(u)?.getAttribute(h)?.trim()||c,d=a('[data-testid="app-face-scene"]',"title","Scene"),n=a('[data-testid="app-face-pages"]',"title","Pages");return[{anchor:"faces",title:`${d} or ${n}`,words:`One app, two ways to see it: ${d} draws every record as one picture, ${n} as lists and pages to read and change.`},{anchor:"problems",title:"Whether all is in order",words:"The dot is green while every rule holds. When one is broken it counts what is wrong, and pressing it shows each one and where."},{anchor:"activity",title:"Activity",words:"What has happened here and who did it, each change with its way back."},{anchor:"ask",title:"Ask",words:"Press \u2318K (Ctrl+K) to ask about what you have selected, or right-click it and choose Ask about this\u2026. The answer stands beside it, and a change it proposes waits for you to accept it."}]}var R=300,O=1200,$=15e3;function _({root:e,steps:a,onEnd:d}){let[n,u]=(0,t.useState)(null),h=(0,t.useRef)(null),c=(0,t.useRef)(!1),p=(0,t.useRef)(d);p.current=d,(0,t.useEffect)(()=>{let r=Date.now(),o=Date.now(),s=null,i,v=new MutationObserver(()=>o=Date.now());v.observe(document.body,{childList:!0,subtree:!0});let k=()=>{let L=e(),S=Date.now();if(L?.querySelector('[data-testid="app-bar"]')){if(s??=S,S-o>=R||S-s>=O){let T=[...W(L),...a].filter(P=>E(L,P.anchor)!==null);if(T.length===0){c.current=!0,p.current(null);return}h.current=document.activeElement,u({list:T,at:0});return}}else if(S-r>=$){c.current=!0,p.current(null);return}i=setTimeout(k,100)};return i=setTimeout(k,100),()=>{clearTimeout(i),v.disconnect()}},[]);let y=(0,t.useCallback)(()=>{let r=h.current;(r instanceof HTMLElement&&r!==document.body&&r.isConnected?r:e()?.querySelector('[data-testid="app-home"]'))?.focus({preventScroll:!0})},[e]),m=(0,t.useCallback)((r,o)=>{if(c.current)return;c.current=!0;let s=document.querySelector("[data-testid='first-look']"),i=document.activeElement,v=i===null||i===document.body||s!==null&&s.contains(i);u(null),p.current(r),!(!o&&!v)&&(y(),requestAnimationFrame(()=>{let k=document.activeElement;(k===null||k===document.body)&&y()}))},[y]),b=(0,t.useCallback)((r,o)=>{let s=e();for(let i=o;i<r.length;i++)if(E(s,r[i].anchor))return i;return-1},[e]),g=(0,t.useCallback)(()=>{if(!n)return;let r=b(n.list,n.at+1);r<0?m("finished",!0):u({list:n.list,at:r})},[n,b,m]);if((0,t.useEffect)(()=>{if(!n)return;let r=e();if(!r)return;let o=0,s=()=>{cancelAnimationFrame(o),o=requestAnimationFrame(()=>{E(e(),n.list[n.at].anchor)||g()})},i=new MutationObserver(s);return i.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden","class","data-switch-drawn"]}),()=>{cancelAnimationFrame(o),i.disconnect()}},[n,e,g]),!n)return null;let w=n.list[n.at],l=b(n.list,n.at+1)<0;return(0,f.jsx)(I,{root:e,step:w,position:n.at+1,total:n.list.length,last:l,onNext:g,onEnd:m},n.at)}var N={...H,width:"min(320px, calc(100vw - 24px))",maxHeight:"min(70vh, 420px)",overflow:"auto",padding:"12px 14px",borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)",color:"var(--graview-ink)",fontFamily:"var(--graview-font-body, system-ui)",fontSize:"0.875rem",lineHeight:1.45,overflowWrap:"anywhere"},M={minHeight:32,padding:"0 12px",borderRadius:8,font:"inherit",fontWeight:600,cursor:"pointer"};function I({root:e,step:a,position:d,total:n,last:u,onNext:h,onEnd:c}){let p=(0,t.useRef)(null),y=(0,t.useRef)(null),m=(0,t.useId)().replace(/:/g,""),b=(0,t.useMemo)(()=>({get current(){return E(e(),a.anchor)}}),[e,a.anchor]),[g]=(0,t.useState)(()=>{let l=b.current?.getBoundingClientRect(),r=typeof document>"u"?0:document.documentElement.clientWidth||innerWidth;return l&&l.left+l.width/2<r/2?"start":"end"});A(p,!0,b,{align:g}),(0,t.useLayoutEffect)(()=>{y.current?.focus({preventScroll:!0})},[]);let w=(0,t.useRef)(c);return w.current=c,(0,t.useEffect)(()=>{let l=o=>{o.target instanceof Node&&p.current?.contains(o.target)||w.current("dismissed",!1)},r=o=>{if(o.key!=="Escape"||o.defaultPrevented)return;let s=o.target;s instanceof Node&&p.current?.contains(s)||s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||[...document.querySelectorAll("[data-graview-overlay]:not([hidden])")].some(i=>i!==p.current)||w.current("dismissed",!0)};return document.addEventListener("pointerdown",l,!0),document.addEventListener("keydown",r),()=>{document.removeEventListener("pointerdown",l,!0),document.removeEventListener("keydown",r)}},[]),(0,f.jsxs)("div",{ref:p,popover:"manual",role:"dialog","aria-modal":"false","aria-labelledby":`${m}-title`,"aria-describedby":`${m}-words`,tabIndex:-1,"data-testid":"first-look","data-first-look-anchor":a.anchor,"data-graview-overlay":"",onKeyDown:l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),c("dismissed",!0))},style:N,children:[(0,f.jsxs)("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--graview-ink-muted)"},"data-testid":"first-look-count",children:[d," of ",n]}),(0,f.jsx)("p",{id:`${m}-title`,style:{margin:"2px 0 4px",fontWeight:600,fontSize:"0.9375rem"},"data-testid":"first-look-title",children:a.title}),(0,f.jsx)("p",{id:`${m}-words`,style:{margin:0},"data-testid":"first-look-words",children:a.words}),(0,f.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"flex-end",gap:8,marginTop:12},children:[u?null:(0,f.jsx)("button",{type:"button","data-testid":"first-look-skip",onClick:()=>c("dismissed",!0),style:{...M,fontWeight:500,border:"1px solid transparent",background:"none",color:"var(--graview-ink-muted)"},children:"Skip"}),(0,f.jsx)("button",{ref:y,type:"button","data-testid":u?"first-look-done":"first-look-next",onClick:()=>u?c("finished",!0):h(),style:{...M,border:"1px solid var(--graview-accent)",background:"var(--graview-accent)",color:"var(--graview-accent-ink)"},children:u?"Done":"Next"})]})]})}export{_ as FirstLookHints,E as firstLookAnchor};
1
+ import{G as C,Oa as H,Qa as A,R as F}from"./chunk.Y4ZUJUUT.js";import"./chunk.SDO3U72B.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import{b as x}from"./chunk.AJZBJBMO.js";var t=x(C(),1),f=x(F(),1),q={faces:'[data-testid="app-faces"]',problems:'[data-testid="standing"], [data-testid="standing-link"]',activity:'[data-testid="activity-button"]',ask:'[data-testid="app-find"], [data-testid="app-find-open"]',find:'[data-testid="app-find"], [data-testid="app-find-open"]',profile:'[data-testid="profile-button"]',home:'[data-testid="app-home"]'};function D(e){if(!e.isConnected||e.closest("[hidden], [inert], [aria-hidden='true']"))return!1;if(typeof e.checkVisibility!="function")return!0;if(!e.checkVisibility({visibilityProperty:!0}))return!1;let a=e.getBoundingClientRect();return a.width>1&&a.height>1}function E(e,a){if(!e||a==="ask"&&!e.querySelector("[data-graview-quick-ask]"))return null;for(let d of e.querySelectorAll(q[a]))if(D(d))return d;return null}function W(e){let a=(u,h,c)=>e.querySelector(u)?.getAttribute(h)?.trim()||c,d=a('[data-testid="app-face-scene"]',"title","Scene"),n=a('[data-testid="app-face-pages"]',"title","Pages");return[{anchor:"faces",title:`${d} or ${n}`,words:`One app, two ways to see it: ${d} draws every record as one picture, ${n} as lists and pages to read and change.`},{anchor:"problems",title:"Whether all is in order",words:"The dot is green while every rule holds. When one is broken it counts what is wrong, and pressing it shows each one and where."},{anchor:"activity",title:"Activity",words:"What has happened here and who did it, each change with its way back."},{anchor:"ask",title:"Ask",words:"Press \u2318K (Ctrl+K) to ask about what you have selected, or right-click it and choose Ask about this\u2026. The answer stands beside it, and a change it proposes waits for you to accept it."}]}var R=300,O=1200,$=15e3;function _({root:e,steps:a,onEnd:d}){let[n,u]=(0,t.useState)(null),h=(0,t.useRef)(null),c=(0,t.useRef)(!1),p=(0,t.useRef)(d);p.current=d,(0,t.useEffect)(()=>{let r=Date.now(),o=Date.now(),s=null,i,v=new MutationObserver(()=>o=Date.now());v.observe(document.body,{childList:!0,subtree:!0});let k=()=>{let L=e(),S=Date.now();if(L?.querySelector('[data-testid="app-bar"]')){if(s??=S,S-o>=R||S-s>=O){let T=[...W(L),...a].filter(P=>E(L,P.anchor)!==null);if(T.length===0){c.current=!0,p.current(null);return}h.current=document.activeElement,u({list:T,at:0});return}}else if(S-r>=$){c.current=!0,p.current(null);return}i=setTimeout(k,100)};return i=setTimeout(k,100),()=>{clearTimeout(i),v.disconnect()}},[]);let y=(0,t.useCallback)(()=>{let r=h.current;(r instanceof HTMLElement&&r!==document.body&&r.isConnected?r:e()?.querySelector('[data-testid="app-home"]'))?.focus({preventScroll:!0})},[e]),m=(0,t.useCallback)((r,o)=>{if(c.current)return;c.current=!0;let s=document.querySelector("[data-testid='first-look']"),i=document.activeElement,v=i===null||i===document.body||s!==null&&s.contains(i);u(null),p.current(r),!(!o&&!v)&&(y(),requestAnimationFrame(()=>{let k=document.activeElement;(k===null||k===document.body)&&y()}))},[y]),b=(0,t.useCallback)((r,o)=>{let s=e();for(let i=o;i<r.length;i++)if(E(s,r[i].anchor))return i;return-1},[e]),g=(0,t.useCallback)(()=>{if(!n)return;let r=b(n.list,n.at+1);r<0?m("finished",!0):u({list:n.list,at:r})},[n,b,m]);if((0,t.useEffect)(()=>{if(!n)return;let r=e();if(!r)return;let o=0,s=()=>{cancelAnimationFrame(o),o=requestAnimationFrame(()=>{E(e(),n.list[n.at].anchor)||g()})},i=new MutationObserver(s);return i.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden","class","data-switch-drawn"]}),()=>{cancelAnimationFrame(o),i.disconnect()}},[n,e,g]),!n)return null;let w=n.list[n.at],l=b(n.list,n.at+1)<0;return(0,f.jsx)(I,{root:e,step:w,position:n.at+1,total:n.list.length,last:l,onNext:g,onEnd:m},n.at)}var N={...H,width:"min(320px, calc(100vw - 24px))",maxHeight:"min(70vh, 420px)",overflow:"auto",padding:"12px 14px",borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)",color:"var(--graview-ink)",fontFamily:"var(--graview-font-body, system-ui)",fontSize:"0.875rem",lineHeight:1.45,overflowWrap:"anywhere"},M={minHeight:32,padding:"0 12px",borderRadius:8,font:"inherit",fontWeight:600,cursor:"pointer"};function I({root:e,step:a,position:d,total:n,last:u,onNext:h,onEnd:c}){let p=(0,t.useRef)(null),y=(0,t.useRef)(null),m=(0,t.useId)().replace(/:/g,""),b=(0,t.useMemo)(()=>({get current(){return E(e(),a.anchor)}}),[e,a.anchor]),[g]=(0,t.useState)(()=>{let l=b.current?.getBoundingClientRect(),r=typeof document>"u"?0:document.documentElement.clientWidth||innerWidth;return l&&l.left+l.width/2<r/2?"start":"end"});A(p,!0,b,{align:g}),(0,t.useLayoutEffect)(()=>{y.current?.focus({preventScroll:!0})},[]);let w=(0,t.useRef)(c);return w.current=c,(0,t.useEffect)(()=>{let l=o=>{o.target instanceof Node&&p.current?.contains(o.target)||w.current("dismissed",!1)},r=o=>{if(o.key!=="Escape"||o.defaultPrevented)return;let s=o.target;s instanceof Node&&p.current?.contains(s)||s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||[...document.querySelectorAll("[data-graview-overlay]:not([hidden])")].some(i=>i!==p.current)||w.current("dismissed",!0)};return document.addEventListener("pointerdown",l,!0),document.addEventListener("keydown",r),()=>{document.removeEventListener("pointerdown",l,!0),document.removeEventListener("keydown",r)}},[]),(0,f.jsxs)("div",{ref:p,popover:"manual",role:"dialog","aria-modal":"false","aria-labelledby":`${m}-title`,"aria-describedby":`${m}-words`,tabIndex:-1,"data-testid":"first-look","data-first-look-anchor":a.anchor,"data-graview-overlay":"",onKeyDown:l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),c("dismissed",!0))},style:N,children:[(0,f.jsxs)("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--graview-ink-muted)"},"data-testid":"first-look-count",children:[d," of ",n]}),(0,f.jsx)("p",{id:`${m}-title`,style:{margin:"2px 0 4px",fontWeight:600,fontSize:"0.9375rem"},"data-testid":"first-look-title",children:a.title}),(0,f.jsx)("p",{id:`${m}-words`,style:{margin:0},"data-testid":"first-look-words",children:a.words}),(0,f.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"flex-end",gap:8,marginTop:12},children:[u?null:(0,f.jsx)("button",{type:"button","data-testid":"first-look-skip",onClick:()=>c("dismissed",!0),style:{...M,fontWeight:500,border:"1px solid transparent",background:"none",color:"var(--graview-ink-muted)"},children:"Skip"}),(0,f.jsx)("button",{ref:y,type:"button","data-testid":u?"first-look-done":"first-look-next",onClick:()=>u?c("finished",!0):h(),style:{...M,border:"1px solid var(--graview-accent)",background:"var(--graview-accent)",color:"var(--graview-accent-ink)"},children:u?"Done":"Next"})]})]})}export{_ as FirstLookHints,E as firstLookAnchor};
@@ -1,4 +1,4 @@
1
- import{o as K}from"./chunk.6BJBPDF3.js";import{$,G as R,R as x,_ as N}from"./chunk.XWAMQPUM.js";import"./chunk.SDO3U72B.js";import{Qc as g,Rc as b,Sc as f,Xc as h,Zc as k,ha as w}from"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import{b as v}from"./chunk.AJZBJBMO.js";var u=v(R(),1);var o=v(x(),1),E=()=>()=>{};function C(e){let n=(0,u.useMemo)(()=>e?.onChange?i=>e.onChange(i):E,[e]),t=()=>e?.current()??b;return(0,u.useSyncExternalStore)(n,t,t)}var D=(e,n)=>e.lens?n.may.lenses:n.may.views;async function p(e,n,t){try{return await n(),!0}catch(i){return e?.notify({kind:"toast",tone:"bad",sentence:i instanceof Error&&i.message?i.message:t}),!1}}function H(e,n,t,i,r){let s=e.name;return p(r,()=>n==="view"&&s!==void 0?i?t.hide(s):t.show(s):t.lens?.({op:"set-lens-hidden",title:e.title,on:e.kind,hidden:i}),i?`\u201C${e.title}\u201D could not be hidden.`:`\u201C${e.title}\u201D could not be shown.`)}function L(e,n,t,i,r){return p(r,()=>t.lens?.({op:"set-lens-hidden",title:e,hidden:i}),i?`\u201C${n}\u201D could not be hidden.`:`\u201C${n}\u201D could not be shown.`)}function V(e,n,t){return p(t,()=>n.restore(e.name),`\u201C${e.title}\u201D could not be restored.`)}async function M(e,n,t,i){let r=n==="view"&&e.name!==void 0?e.name:g(e.title),s=await p(i,()=>n==="view"&&e.name!==void 0?t.remove(e.name,{title:e.title,kind:e.kind}):t.lens?.({op:"remove-lens",title:e.title,on:e.kind}),`\u201C${e.title}\u201D could not be deleted.`);return s&&i?.notify({kind:"toast",id:`deleted-view-${r}`,sentence:`Deleted \u201C${e.title}\u201D. It is under Recently deleted in the places for ${30} days.`,action:{label:"Restore",onSelect:()=>void V({name:r,title:e.title},t,i)}}),s}function G(){let e=$(),n=e?.keptViews,t=C(n),i=e?.views;return(0,u.useMemo)(()=>{if(!n||!i)return null;let r=d=>f(d,t,n),s=new Set,m=i.places().filter(d=>{if(!d.hidden||r(d)===null)return!1;let c=`${d.name??""}|${d.title}`;return s.has(c)?!1:(s.add(c),!0)}),l=e?.store.schema,y=t.may.lenses&&n.lens&&l?(i.arrangement?.()?.hide??[]).filter(d=>l.tryDefinition(d)!==void 0).map(d=>({kind:d,title:w(l,d),path:h(l,d)})):[];return{keeper:n,hidden:m,lists:y,removed:t.removed.filter(d=>D(d,t)),how:r}},[n,t,i,e?.store.schema])}function T(e,n){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(n??"en-US",{month:"short",day:"numeric"})}var I=`.graview-bar-list li.graview-bar-tidied{display:flex;align-items:flex-start;gap:8px;padding:0 0 0 2px}
1
+ import{o as K}from"./chunk.O4WEJ47H.js";import{$,G as R,R as x,_ as N}from"./chunk.Y4ZUJUUT.js";import"./chunk.SDO3U72B.js";import{Qc as g,Rc as b,Sc as f,Xc as h,Zc as k,ha as w}from"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import{b as v}from"./chunk.AJZBJBMO.js";var u=v(R(),1);var o=v(x(),1),E=()=>()=>{};function C(e){let n=(0,u.useMemo)(()=>e?.onChange?i=>e.onChange(i):E,[e]),t=()=>e?.current()??b;return(0,u.useSyncExternalStore)(n,t,t)}var D=(e,n)=>e.lens?n.may.lenses:n.may.views;async function p(e,n,t){try{return await n(),!0}catch(i){return e?.notify({kind:"toast",tone:"bad",sentence:i instanceof Error&&i.message?i.message:t}),!1}}function H(e,n,t,i,r){let s=e.name;return p(r,()=>n==="view"&&s!==void 0?i?t.hide(s):t.show(s):t.lens?.({op:"set-lens-hidden",title:e.title,on:e.kind,hidden:i}),i?`\u201C${e.title}\u201D could not be hidden.`:`\u201C${e.title}\u201D could not be shown.`)}function L(e,n,t,i,r){return p(r,()=>t.lens?.({op:"set-lens-hidden",title:e,hidden:i}),i?`\u201C${n}\u201D could not be hidden.`:`\u201C${n}\u201D could not be shown.`)}function V(e,n,t){return p(t,()=>n.restore(e.name),`\u201C${e.title}\u201D could not be restored.`)}async function M(e,n,t,i){let r=n==="view"&&e.name!==void 0?e.name:g(e.title),s=await p(i,()=>n==="view"&&e.name!==void 0?t.remove(e.name,{title:e.title,kind:e.kind}):t.lens?.({op:"remove-lens",title:e.title,on:e.kind}),`\u201C${e.title}\u201D could not be deleted.`);return s&&i?.notify({kind:"toast",id:`deleted-view-${r}`,sentence:`Deleted \u201C${e.title}\u201D. It is under Recently deleted in the places for ${30} days.`,action:{label:"Restore",onSelect:()=>void V({name:r,title:e.title},t,i)}}),s}function G(){let e=$(),n=e?.keptViews,t=C(n),i=e?.views;return(0,u.useMemo)(()=>{if(!n||!i)return null;let r=d=>f(d,t,n),s=new Set,m=i.places().filter(d=>{if(!d.hidden||r(d)===null)return!1;let c=`${d.name??""}|${d.title}`;return s.has(c)?!1:(s.add(c),!0)}),l=e?.store.schema,y=t.may.lenses&&n.lens&&l?(i.arrangement?.()?.hide??[]).filter(d=>l.tryDefinition(d)!==void 0).map(d=>({kind:d,title:w(l,d),path:h(l,d)})):[];return{keeper:n,hidden:m,lists:y,removed:t.removed.filter(d=>D(d,t)),how:r}},[n,t,i,e?.store.schema])}function T(e,n){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(n??"en-US",{month:"short",day:"numeric"})}var I=`.graview-bar-list li.graview-bar-tidied{display:flex;align-items:flex-start;gap:8px;padding:0 0 0 2px}
2
2
  .graview-bar-tidied>.graview-bar-item,.graview-bar-gone{flex:1 1 auto;min-width:0}
3
3
  .graview-bar-gone{display:grid;gap:1px;padding:7px 8px;font-size:.875rem;line-height:1.3;overflow-wrap:anywhere;color:var(--graview-ink-muted)}
4
4
  .graview-bar-gone small{font-size:.75rem}