graview 0.1.60 → 0.1.61

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 (179) hide show
  1. package/dist/preview/{chunk.ERFT54HT.js → chunk.2AWVQ5SW.js} +1 -1
  2. package/dist/preview/{chunk.LQVAABPS.js → chunk.2LNSENPV.js} +1 -1
  3. package/dist/preview/chunk.2QFKNTAZ.js +1 -0
  4. package/dist/preview/{chunk.ZXOT3IXJ.js → chunk.2WZAFKJ2.js} +1 -1
  5. package/dist/preview/{chunk.VZJWJ5XM.js → chunk.2XSIJH5J.js} +1 -1
  6. package/dist/preview/{chunk.GNBIVVL3.js → chunk.3FUUYYR5.js} +1 -1
  7. package/dist/preview/{chunk.NHUQ2N6J.js → chunk.3HFUO3DC.js} +1 -1
  8. package/dist/preview/chunk.3ICWPRRJ.js +1 -0
  9. package/dist/preview/{chunk.XR6YR6RV.js → chunk.3RW677X6.js} +1 -1
  10. package/dist/preview/{chunk.FBJARKDT.js → chunk.3SMNWZ3M.js} +1 -1
  11. package/dist/preview/{chunk.JPONLMU7.js → chunk.4G32374Q.js} +1 -1
  12. package/dist/preview/{chunk.IGJZ4UH3.js → chunk.4LG34OC2.js} +2 -2
  13. package/dist/preview/{chunk.3ZT5WQYL.js → chunk.4OEWFPH3.js} +1 -1
  14. package/dist/preview/{chunk.UITT6JWW.js → chunk.4STDIZVI.js} +1 -1
  15. package/dist/preview/{chunk.ZP5RT2EK.js → chunk.5POG3G2C.js} +1 -1
  16. package/dist/preview/{chunk.ULL6ZIJJ.js → chunk.5S7IGASX.js} +1 -1
  17. package/dist/preview/chunk.5T53SF2K.js +1 -0
  18. package/dist/preview/{chunk.3MOJF7BA.js → chunk.5X22RKB3.js} +1 -1
  19. package/dist/preview/{chunk.LSY256J4.js → chunk.65KFZV3A.js} +1 -1
  20. package/dist/preview/chunk.66IKLMYX.js +104 -0
  21. package/dist/preview/chunk.6DOOLVT4.js +1 -0
  22. package/dist/preview/{chunk.TLJOZSDD.js → chunk.6HZY5NRX.js} +1 -1
  23. package/dist/preview/{chunk.RQOX5YDW.js → chunk.6SO64TUI.js} +1 -1
  24. package/dist/preview/{chunk.2USDHXB4.js → chunk.6VLCMBRE.js} +1 -1
  25. package/dist/preview/{chunk.ENL2JJ47.js → chunk.747OH3EE.js} +1 -1
  26. package/dist/preview/chunk.7CETF4A6.js +1 -0
  27. package/dist/preview/{chunk.MVWC3VR3.js → chunk.7LZ6JDJA.js} +2 -2
  28. package/dist/preview/{chunk.PI44XMY2.js → chunk.7R727IKU.js} +1 -1
  29. package/dist/preview/chunk.A2ZQASQV.js +1 -0
  30. package/dist/preview/chunk.AVFOTYZR.js +74 -0
  31. package/dist/preview/{chunk.VUBNBTJP.js → chunk.BDTT4ENI.js} +2 -2
  32. package/dist/preview/{chunk.SB2PZKN5.js → chunk.BFDJTWGX.js} +1 -1
  33. package/dist/preview/{chunk.6ZQAR5ZA.js → chunk.BI6DS3PZ.js} +1 -1
  34. package/dist/preview/{chunk.KI37ZEV3.js → chunk.BJI2C3IZ.js} +1 -1
  35. package/dist/preview/{chunk.YFSBVZTG.js → chunk.C634A6ZC.js} +1 -1
  36. package/dist/preview/{chunk.ZYM2SSGW.js → chunk.CRCJ3TAG.js} +1 -1
  37. package/dist/preview/{chunk.WXUFATY5.js → chunk.CUTLO6DA.js} +1 -1
  38. package/dist/preview/chunk.D4TA5XDC.js +4 -0
  39. package/dist/preview/{chunk.HDUO2USQ.js → chunk.D5Q64GA4.js} +1 -1
  40. package/dist/preview/{chunk.RXYNW5QB.js → chunk.DHJI7LIW.js} +1 -1
  41. package/dist/preview/{chunk.6HF6POIX.js → chunk.DHY7KOBV.js} +1 -1
  42. package/dist/preview/chunk.DKXVEVDG.js +1 -0
  43. package/dist/preview/{chunk.NC7FXY2H.js → chunk.DLDP6OWD.js} +1 -1
  44. package/dist/preview/{chunk.H45Q3O4F.js → chunk.DP5DUV6F.js} +1 -1
  45. package/dist/preview/chunk.DXWTM4SH.js +1 -0
  46. package/dist/preview/{chunk.BQIHNT7C.js → chunk.E6RNMWFN.js} +1 -1
  47. package/dist/preview/{chunk.A3ZXDG6V.js → chunk.E7UDVC4V.js} +1 -1
  48. package/dist/preview/{chunk.M4UD4ARP.js → chunk.EN2ABVIP.js} +1 -1
  49. package/dist/preview/{chunk.7MHCGVGM.js → chunk.EVEHSENK.js} +1 -1
  50. package/dist/preview/{chunk.SRVQJZRT.js → chunk.F4VHCQNP.js} +1 -1
  51. package/dist/preview/{chunk.4TCKEG6I.js → chunk.F7IQ4B6A.js} +1 -1
  52. package/dist/preview/chunk.F7PIW2EM.js +5 -0
  53. package/dist/preview/{chunk.GTKJJYQH.js → chunk.FJIXSGYU.js} +1 -1
  54. package/dist/preview/{chunk.HDP3PS7N.js → chunk.FWUG7Y6C.js} +1 -1
  55. package/dist/preview/chunk.G4VMRYS4.js +1 -0
  56. package/dist/preview/{chunk.URWAFZHF.js → chunk.GI6XQF5X.js} +1 -1
  57. package/dist/preview/{chunk.Y5C4RXG7.js → chunk.GIW657OR.js} +1 -1
  58. package/dist/preview/chunk.GPWYWALF.js +1 -0
  59. package/dist/preview/{chunk.YZ7FUKAL.js → chunk.GQNSNJTJ.js} +1 -1
  60. package/dist/preview/chunk.HGVBGSRS.js +6 -0
  61. package/dist/preview/{chunk.VNDKKTED.js → chunk.HOQMD6WQ.js} +1 -1
  62. package/dist/preview/{chunk.TKVLNBRD.js → chunk.HQNE4I4M.js} +1 -1
  63. package/dist/preview/{chunk.A5PDXNY6.js → chunk.HZHNM2KI.js} +1 -1
  64. package/dist/preview/{chunk.TAT2IQUR.js → chunk.IA5ZBMRD.js} +1 -1
  65. package/dist/preview/{chunk.VFOON3Z3.js → chunk.ISRQQVS4.js} +1 -1
  66. package/dist/preview/{chunk.T7LQD67N.js → chunk.ISXNAFRC.js} +2 -2
  67. package/dist/preview/{chunk.QBLKTFF4.js → chunk.JEQO24GS.js} +1 -1
  68. package/dist/preview/{chunk.VWJGQDCE.js → chunk.JHAFQNGC.js} +1 -1
  69. package/dist/preview/chunk.JU3BCCQM.js +1 -0
  70. package/dist/preview/{chunk.5DD62IOW.js → chunk.K2AC536Q.js} +2 -2
  71. package/dist/preview/chunk.K3UOXAZS.js +1 -0
  72. package/dist/preview/{chunk.CC5BJH5A.js → chunk.KRFRREEW.js} +1 -1
  73. package/dist/preview/chunk.LA2DMHZC.js +1 -0
  74. package/dist/preview/chunk.LQAT7FA6.js +3 -0
  75. package/dist/preview/{chunk.UJTE7UAP.js → chunk.LTI5PKTS.js} +1 -1
  76. package/dist/preview/chunk.MBP7VDYM.js +1 -0
  77. package/dist/preview/{chunk.EL5ICOOM.js → chunk.MBPOYZ3J.js} +1 -1
  78. package/dist/preview/chunk.MBU7UH6J.js +1 -0
  79. package/dist/preview/chunk.MH6CCHEX.js +1 -0
  80. package/dist/preview/{chunk.DCHQHKSA.js → chunk.MK72IRIY.js} +1 -1
  81. package/dist/preview/{chunk.VMV464JK.js → chunk.MNRTA2CB.js} +1 -1
  82. package/dist/preview/chunk.MU3XII7I.js +1 -0
  83. package/dist/preview/chunk.MYVED5LU.js +1 -0
  84. package/dist/preview/chunk.N5WDQAIM.js +5 -0
  85. package/dist/preview/{chunk.4MP72LPR.js → chunk.N7T7VB77.js} +1 -1
  86. package/dist/preview/{chunk.QHDCTAD7.js → chunk.NUEPFPRA.js} +1 -1
  87. package/dist/preview/chunk.ODVRO2BJ.js +1 -0
  88. package/dist/preview/{chunk.5YOLUDVO.js → chunk.OVPFROL3.js} +1 -1
  89. package/dist/preview/{chunk.W3W54DSX.js → chunk.PGA5TUSN.js} +1 -1
  90. package/dist/preview/{chunk.TLWT67ON.js → chunk.PJ5AO7CK.js} +1 -1
  91. package/dist/preview/{chunk.TFWIG6LL.js → chunk.PYVWGTQS.js} +1 -1
  92. package/dist/preview/{chunk.7OPM55I2.js → chunk.PZXTSWDH.js} +1 -1
  93. package/dist/preview/chunk.Q5I5M3FR.js +1 -0
  94. package/dist/preview/chunk.QATUGE34.js +1 -0
  95. package/dist/preview/{chunk.PFSYXD6Q.js → chunk.QL77K3D4.js} +1 -1
  96. package/dist/preview/{chunk.7N32AVIJ.js → chunk.R3N73BJO.js} +1 -1
  97. package/dist/preview/{chunk.P6RORYOT.js → chunk.R5547CJ7.js} +1 -1
  98. package/dist/preview/chunk.REH6RXNH.js +1 -0
  99. package/dist/preview/{chunk.UQWTZJBV.js → chunk.RZ5PPQBV.js} +1 -1
  100. package/dist/preview/{chunk.QDSEVPF3.js → chunk.SAYAFOF6.js} +1 -1
  101. package/dist/preview/{chunk.FRYBMS3W.js → chunk.SBLYBRDU.js} +1 -1
  102. package/dist/preview/{chunk.YH63KQ2G.js → chunk.SCGF4ZPP.js} +1 -1
  103. package/dist/preview/{chunk.HUJ6YTWE.js → chunk.SIYBHZDD.js} +1 -1
  104. package/dist/preview/{chunk.KDRLUBVF.js → chunk.SJALH7IX.js} +1 -1
  105. package/dist/preview/{chunk.F6V7RWDK.js → chunk.SKQO467Y.js} +1 -1
  106. package/dist/preview/chunk.SLAZFFCQ.js +1 -0
  107. package/dist/preview/chunk.SLPJWOKC.js +1 -0
  108. package/dist/preview/{chunk.JEYQBH33.js → chunk.TKLYUVMR.js} +1 -1
  109. package/dist/preview/chunk.TMAZNDA6.js +1 -0
  110. package/dist/preview/{chunk.IGVASEZU.js → chunk.U2ISOUM2.js} +1 -1
  111. package/dist/preview/{chunk.VADQ7ZGA.js → chunk.U3JK2DNC.js} +1 -1
  112. package/dist/preview/chunk.U5P23GO7.js +1 -0
  113. package/dist/preview/{chunk.KBVTLNS5.js → chunk.UACSX64H.js} +3 -3
  114. package/dist/preview/{chunk.Z2ERZ4S6.js → chunk.ULHB3RYK.js} +1 -1
  115. package/dist/preview/{chunk.MSWWWLEA.js → chunk.UO544PZH.js} +1 -1
  116. package/dist/preview/{chunk.Y7G3OGDE.js → chunk.UXOBUK3C.js} +1 -1
  117. package/dist/preview/{chunk.BRT27WON.js → chunk.VKHAAH32.js} +1 -1
  118. package/dist/preview/{chunk.3XGA65Y3.js → chunk.VN7I7XIO.js} +1 -1
  119. package/dist/preview/{chunk.CFKZXLXS.js → chunk.VOOOIECX.js} +1 -1
  120. package/dist/preview/chunk.VS6NT5C4.js +1 -0
  121. package/dist/preview/{chunk.67U6M7OV.js → chunk.VUAOCYG2.js} +1 -1
  122. package/dist/preview/{chunk.PNW5K7BW.js → chunk.VX65S2FA.js} +1 -1
  123. package/dist/preview/{chunk.VDMDPZ6U.js → chunk.VYFMUCBT.js} +1 -1
  124. package/dist/preview/{chunk.FFTYMBBT.js → chunk.W5TVQYAI.js} +1 -1
  125. package/dist/preview/{chunk.OLFJH4RK.js → chunk.WD4VPMEE.js} +1 -1
  126. package/dist/preview/{chunk.BXDM3UMN.js → chunk.WICFQROI.js} +1 -1
  127. package/dist/preview/{chunk.NGTRL5U4.js → chunk.WS7LAT4Z.js} +1 -1
  128. package/dist/preview/{chunk.IHBUBZQT.js → chunk.X2I3XH2E.js} +1 -1
  129. package/dist/preview/{chunk.6WHAWOO7.js → chunk.XFSGB6EU.js} +1 -1
  130. package/dist/preview/{chunk.XGASJAV2.js → chunk.XWWSW3ZV.js} +1 -1
  131. package/dist/preview/chunk.XZUHFXME.js +1 -0
  132. package/dist/preview/{chunk.CQT3W2SF.js → chunk.XZWXDQ3N.js} +1 -1
  133. package/dist/preview/{chunk.IOK4GVJC.js → chunk.Y7H5O2SL.js} +1 -1
  134. package/dist/preview/chunk.YGIJDHAV.js +2 -0
  135. package/dist/preview/{chunk.3V4WP7RY.js → chunk.YOT7ESDG.js} +3 -3
  136. package/dist/preview/{chunk.MJVYWLQQ.js → chunk.ZC3FRCJQ.js} +1 -1
  137. package/dist/preview/{chunk.AVBTPSQF.js → chunk.ZJCM62GH.js} +1 -1
  138. package/dist/preview/{chunk.4LR64TPU.js → chunk.ZKAZA6UJ.js} +1 -1
  139. package/dist/preview/{chunk.3UOKUF5Z.js → chunk.ZQHCNFJK.js} +1 -1
  140. package/dist/preview/{chunk.6C2MHWSX.js → chunk.ZVG3DR5G.js} +1 -1
  141. package/dist/preview/chunk.ZYNUMVEC.js +1 -0
  142. package/dist/preview/index.html +50 -50
  143. package/dist/preview/page.js +2 -2
  144. package/package.json +6 -6
  145. package/dist/preview/chunk.2K4TT2BV.js +0 -1
  146. package/dist/preview/chunk.37TVS7CA.js +0 -1
  147. package/dist/preview/chunk.3IZ3ABII.js +0 -1
  148. package/dist/preview/chunk.7TFLRR7D.js +0 -1
  149. package/dist/preview/chunk.7VKSXGTX.js +0 -1
  150. package/dist/preview/chunk.BF6S5UE4.js +0 -1
  151. package/dist/preview/chunk.BLPYNNR4.js +0 -1
  152. package/dist/preview/chunk.BYKD5RLA.js +0 -1
  153. package/dist/preview/chunk.C7OLSEWK.js +0 -1
  154. package/dist/preview/chunk.CMN6BBAD.js +0 -1
  155. package/dist/preview/chunk.D7YSL3NK.js +0 -2
  156. package/dist/preview/chunk.EQXB7LKI.js +0 -1
  157. package/dist/preview/chunk.FLUK3UXF.js +0 -1
  158. package/dist/preview/chunk.G3R4BTI7.js +0 -1
  159. package/dist/preview/chunk.G4YJPKRG.js +0 -5
  160. package/dist/preview/chunk.GLWSVSQL.js +0 -1
  161. package/dist/preview/chunk.I4XQBQRC.js +0 -1
  162. package/dist/preview/chunk.IBOKXVWN.js +0 -1
  163. package/dist/preview/chunk.JJGCTGWA.js +0 -1
  164. package/dist/preview/chunk.KGW75Z5L.js +0 -3
  165. package/dist/preview/chunk.L6AWE76F.js +0 -1
  166. package/dist/preview/chunk.LGEA5257.js +0 -6
  167. package/dist/preview/chunk.LLYRFVIN.js +0 -104
  168. package/dist/preview/chunk.LZIBQ3VX.js +0 -1
  169. package/dist/preview/chunk.MDJWK5W2.js +0 -1
  170. package/dist/preview/chunk.PHJ6WPWH.js +0 -1
  171. package/dist/preview/chunk.QFUMFQJU.js +0 -1
  172. package/dist/preview/chunk.QI4SLPQ4.js +0 -4
  173. package/dist/preview/chunk.TY4GQJKC.js +0 -1
  174. package/dist/preview/chunk.VSCIXAHN.js +0 -5
  175. package/dist/preview/chunk.WC3DENU4.js +0 -67
  176. package/dist/preview/chunk.WQ6RCEUQ.js +0 -1
  177. package/dist/preview/chunk.X6A4VSSD.js +0 -1
  178. package/dist/preview/chunk.XZPKBHJT.js +0 -1
  179. package/dist/preview/chunk.YEBGI6ED.js +0 -1
@@ -0,0 +1 @@
1
+ import{b as Ce,d as $e,i as U}from"./chunk.4STDIZVI.js";import{e as Te}from"./chunk.HZHNM2KI.js";import{Ad as Re,Dd as De,Fd as We,Gb as ae,Gd as Me,K as ke,Ya as Se,_d as je,aa as M,ab as G,ca as xe,da as W,dd as ve,ed as Oe,fa as _,ga as z,ha as Ae,ja as we,ka as Ne,wc as se}from"./chunk.F7PIW2EM.js";function V(n,e){return n.display?.labels?.[e]??W(e)}function de(n){let e=U(n);switch(e.type){case"text":case"date":case"number":case"boolean":case"choice":return e.type;default:return}}function Je(n,e){let t=new Map,i=n.tryDefinition(e);for(let[r,a]of Object.entries(i?.edges??{}))t.set(r,{key:r,label:a.description?M(a.description):W(r),about:"edge",far:a.to==="*"?[...n.kinds]:[...a.to]});for(let r of n.definitions)if(r.kind!==e)for(let[a,s]of Object.entries(r.edges??{}))t.has(a)||s.to!=="*"&&!s.to.includes(e)||t.set(a,{key:a,label:s.inverse?M(s.inverse):W(a),about:"edge",far:[r.kind]});return[...t.values()]}var Ze=["current","past","any","flagged","clear"];function Fe(n,e){let t=n?.lifecycle;if(!t||t.retired==="date")return!1;let i=t.retired.map(String);return e.some(r=>r.key===t.field&&i.includes(r.value))}function Be(n,e){let t=n.tryDefinition(e);if(!t)return{kind:e,sorts:[],filters:[],groups:[]};let i=new Set(t.display?.hide??[]),r=t.fields.shape??{},a=[{key:"label",label:"Name",about:"label",type:"text"}],s=[],u=[];for(let[g,k]of Object.entries(r)){if(g==="id"||g==="kind"||g==="label"||i.has(g))continue;let A=en(k);if(A){s.push({key:g,label:V(t,g),about:"field",type:"choice",options:A});continue}let w=de(k);if(!w)continue;let N=V(t,g),O=w==="choice"?Le(k):w==="boolean"?["true","false"]:void 0,S={key:g,label:N,about:"field",type:w,...O?{options:O}:{}};a.push(S),s.push(S),(w==="boolean"||w==="choice")&&u.push(S),w==="date"&&u.push({...S,buckets:["day","week","month","year","decade"]})}for(let g of Je(n,e))a.push(g),s.push(g),u.push(g);let l={key:"is",label:t.lifecycle?"Standing and currency":"Standing",about:"is",type:"choice",options:t.lifecycle?[...Ze]:["flagged","clear"]};s.push(l);let y=t.fieldRoles?.order,f=y&&(y in r||y==="label")?{by:y,direction:"asc"}:void 0;return{kind:e,sorts:a,filters:s,groups:u,...f?{natural:f}:{}}}function On(n,e){let t=[];for(let r of e.filters){let a=r.about==="edge"&&r.far?.length===1?n.tryDefinition(r.far[0]):void 0;if(!(!a||a.kind===e.kind))for(let[s,u]of Object.entries(a.fields.shape??{}))de(u)!=="choice"||a.display?.hide?.includes(s)||t.push({key:`${r.key}.${s}`,label:`${r.label} \xB7 ${V(a,s)}`,about:"via",type:"choice",options:Le(u),far:[a.kind]})}if(t.length===0)return e;let i=e.filters.filter(r=>r.about!=="is");return{...e,filters:[...i,...t,...e.filters.filter(r=>r.about==="is")]}}function Rn(n,e){let t=n.tryDefinition(e.kind),i=Object.entries(t?.computed??{});if(!t||i.length===0)return e;let r=i.filter(([a])=>!e.sorts.some(s=>s.key===a)).map(([a,s])=>({key:a,label:(typeof s=="object"?s.label:void 0)??V(t,a),about:"field",type:"number"}));return{...e,sorts:[...e.sorts,...r]}}function Le(n){let e=U(n);return e.type==="choice"?e.options:[]}function en(n){let e=U(n);return e.type==="several"&&e.of.type==="choice"?e.of.options:void 0}var Ie=n=>n,Pe=n=>n;function nn(n,e,t){let i=new Map;for(let r of[...n.out(e,t),...n.in(e,t)])i.set(r.id,r);return[...i.values()]}function le(n,e,t){let i=n.schema.tryDefinition(e.kind);if(t.key==="is")switch(t.value){case"current":return _(i,Pe(e),n.today);case"past":return!_(i,Pe(e),n.today);case"any":return!0;case"flagged":return n.flagged?.has(e.id)??!1;case"clear":return!(n.flagged?.has(e.id)??!1);default:return!0}let r=i?.fields.shape??{};if(t.key in r){let l=Se(Ie(e),t.key,n.today??ke()),y=de(r[t.key]);if(y==="date"){let[f,g]=t.value.split(":");if(typeof l!="string"||!g)return!1;let k=l.slice(0,10);return f==="before"?k<g:f==="after"?k>g:k===g}if(y==="boolean")return String(l)===t.value;if(Array.isArray(l))return l.some(f=>String(f)===t.value);if(y==="number"){let f=t.value.lastIndexOf(":"),g=f>0?t.value.slice(0,f):"",k=Number(t.value.slice(f+1));if(g==="at-most"||g==="at-least")return typeof l!="number"||!Number.isFinite(k)?!1:g==="at-most"?l<=k:l>=k}return String(l)===t.value}let[a,s]=t.key.split("."),u=nn(n.graph,e.id,a);return s?u.some(l=>String(Ie(l)[s])===t.value):t.value==="*"?u.length>0:t.value==="none"?u.length===0:u.some(l=>l.id===t.value)}var tn=5;function ze(n){return n.normalize("NFD").replace(/\p{M}+/gu,"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim()}function ce(n){return ze(n).replace(/ /g,"")}var X=new Map,rn=5e4;function $(n){let e=X.get(n);if(e===void 0){X.size>=rn&&X.clear();let t=ze(n);e={tokens:t.split(" ").filter(Boolean),whole:t.replace(/ /g,"")},X.set(n,e)}return e}var T=n=>[...$(n).tokens];function j(n,e){if(e.length===0)return;let{whole:t,tokens:i}=$(n),r=e.join("");if(t.length===0)return;if(t===r)return"exact";if(e.every(s=>i.some(u=>u.startsWith(s))))return t.startsWith(r)?"prefix":e.every(s=>i.includes(s))?"word":"part"}function q(n,e,t=48){let i=n.replace(/\s+/g," ").trim();if(i.length<=t)return i;let r=e[0],a=i.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase(),s=r?a.search(new RegExp(`(^|[^\\p{L}\\p{N}])${on(r)}`,"u")):-1,u=s<0?0:s+(a[s]&&/[\p{L}\p{N}]/u.test(a[s])?0:1),l=Math.max(0,u-Math.floor(t/3));if(l>0){let f=i.lastIndexOf(" ",l);l=f<0?0:f+1}let y=Math.min(i.length,l+t);if(y<i.length){let f=i.indexOf(" ",y);y=f<0||f-y>16?y:f}return`${l>0?"\u2026":""}${i.slice(l,y).trim()}${y<i.length?"\u2026":""}`}var on=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),an=/^([\p{L}][\p{L}\p{N}_-]*):(\S+)$/u;function sn(n){let e=[],t=[];for(let i of n.trim().split(/\s+/).filter(Boolean)){let r=an.exec(i);r?t.push({key:r[1],value:r[2]}):e.push(i)}return{words:e.join(" "),conditions:t}}var Ee=new WeakMap;function Q(n,e){let t=Ee.get(e);if(t&&t.definition===n)return t.texts;let i=dn(n,e);return Ee.set(e,{definition:n,texts:i}),i}function dn(n,e){let t=z(n,e),i=[{field:"label",reading:"Name",text:t}];for(let r of $e(e,n,{limit:Number.POSITIVE_INFINITY}))r.key==="label"||r.value===t||typeof e[r.key]!="boolean"&&i.push({field:r.key,reading:r.label,text:r.markdown?Te(r.value):r.value});return i}var I={exact:0,prefix:1,word:2,part:3,field:4,near:5},Ge=new Set(["a","an","the","of","and","or","for","to","in","on","at","by","with","my","our","is"]);function Ke(n){let e=n;e.length>4&&e.endsWith("ies")?e=`${e.slice(0,-3)}y`:e.length>4&&/(ss|x|ch|sh|z)es$/.test(e)?e=e.slice(0,-2):e.length>3&&e.endsWith("s")&&!/(ss|us|is)$/.test(e)&&(e=e.slice(0,-1));for(let t of["ing","ed"])if(e.length>t.length+2&&e.endsWith(t)){e=e.slice(0,-t.length),/([b-df-hj-km-np-rtv-z])\1$/.test(e)&&(e=e.slice(0,-1));break}return e.length>3&&e.endsWith("e")?e.slice(0,-1):e}function He(n,e,t){if(Math.abs(n.length-e.length)>t)return t+1;let i=[],r=Array.from({length:e.length+1},(a,s)=>s);for(let a=1;a<=n.length;a++){let s=[a],u=a;for(let l=1;l<=e.length;l++){let y=Math.min(r[l]+1,s[l-1]+1,r[l-1]+(n[a-1]===e[l-1]?0:1));a>1&&l>1&&n[a-1]===e[l-2]&&n[a-2]===e[l-1]&&(y=Math.min(y,i[l-2]+1)),s[l]=y,y<u&&(u=y)}if(u>t)return t+1;i=r,r=s}return r[e.length]}var Y=new Map;function ln(n,e){let t=Y.get(n);t||(Y.size>=64&&Y.clear(),Y.set(n,t=new Map));let i=t.get(e);return i===void 0&&(i=cn(n,e)??null,t.set(e,i)),i??void 0}function cn(n,e){if(/\d/.test(n))return;let t=Ke(n);if(t.length>=3&&(Ke(e)===t||t.length>=4&&e.startsWith(t)))return"stem";let i=n.length<4?0:n.length<=7?1:2;if(i!==0){if(He(n,e,i)<=i)return"spelling";if(n.length>=5){for(let r=n.length-i;r<=n.length+i;r++)if(r<e.length&&He(n,e.slice(0,r),i)<=i)return"spelling"}}}function fn(n,e){let t=e.length>1?e.filter(r=>!Ge.has(r)):e;if(t.length===0)return;let i;for(let r of t){let a;for(let s of n){for(let u of $(s.text).tokens){if(u.startsWith(r)){a={text:s,matched:u};break}let l=a?void 0:ln(r,u);l&&(a={text:s,matched:u,by:l})}if(a&&!a.by)break}if(!a)return;a.by&&!i&&(i={text:a.text,asked:r,matched:a.matched,by:a.by})}if(i)return{field:i.text.field,reading:i.text.reading,fragment:q(i.text.text,[i.matched]),strength:"near",asked:i.asked,matched:i.matched,by:i.by}}var un=80;function gn(n,e,t){let i=T(e).filter(s=>!Ge.has(s)).join(" ")||e,r=t===void 0?[]:T(t),a=r.length>0&&n.find(s=>r.every(u=>$(s.text).tokens.some(l=>l.startsWith(u))))||n[0];return{field:a.field,reading:a.reading,fragment:q(a.text,r),strength:"near",asked:i,matched:(t??a.text).slice(0,un),by:"meaning"}}function _e(n,e,t,i){let r=T(t);if(r.length===0)return;if(i){let A=Q(n,e),w=i.includes("label")||i.some(v=>typeof e[v]=="string"&&e[v]===A[0].text),N=A.filter((v,D)=>D===0?w:i.includes(v.field)),O=v=>D=>$(D.text).tokens.some(P=>P.startsWith(v));if(!r.every(v=>N.some(O(v))))return;let S=N.find(O(r[0]));return{field:S.field,reading:S.reading,fragment:q(S.text,r),strength:S.field==="label"?j(S.text,r)??"field":"field"}}let a=Q(n,e),[s,...u]=a,l=j(s.text,r);if(l)return{field:"label",reading:s.reading,fragment:q(s.text,r),strength:l};let y=A=>w=>$(w.text).tokens.some(N=>N.startsWith(A));if(!r.every(A=>a.some(y(A))))return;let f=T(s.text),g=r.find(A=>!f.some(w=>w.startsWith(A)))??r[0],k=u.find(y(g));return{field:k.field,reading:k.reading,fragment:q(k.text,[g]),strength:"field"}}var yn=512,hn=64;function pn(n){let e=new Map;if(n.length===0)return e;let t=n.slice(-yn),i=n[n.length-1].seq;for(let r of t){let a=Math.pow(.5,(i-r.seq)/hn);for(let s of r.writes)e.set(s,(e.get(s)??0)+a)}return e}var ue=(n,e)=>we({tryDefinition:()=>n},e),fe=(n,e)=>De({tryDefinition:()=>n},e);function mn(n,e,t){let i=n.tryDefinition(e),r=[{field:"plural",text:ue(i,e)},{field:"kind",text:W(e)},...i?.noun?[{field:"noun",text:i.noun}]:[],...(i?.aliases??[]).map(s=>({field:"alias",text:s}))],a;for(let s of r){let u=j(s.text,t);u&&(!a||I[u]<I[a.strength])&&(a={strength:u,...s})}return a}var bn,kn=(n,e)=>(bn??=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0})).compare(n,e),qe=(n,e)=>(n.nearly??0)-(e.nearly??0)||(n.archived??0)-(e.archived??0)||n.tier-e.tier||n.inKind-e.inKind||n.near-e.near||n.past-e.past||n.touched-e.touched||n.flagged-e.flagged||kn(n.name,e.name)||(n.id<e.id?-1:n.id>e.id?1:0);function En(n,e,t={}){let i=n.schema,r=sn(e),a=T(r.words),s=t.principal??{kind:"human"},u=n.kindsKeptFrom(s),l=n.modules.disabledKinds,y=r.conditions.filter(o=>o.key==="kind").map(o=>o.value),f=r.conditions.filter(o=>o.key==="is").map(o=>o.value),g=f.includes("any")||f.includes("past"),k=f.includes("past")&&!f.includes("any")&&!f.includes("current"),A=f.includes("archived")?!0:t.archived??"all",w=(o,d)=>{let c=ce(d),h=i.tryDefinition(o);return ce(o)===c||ce(ue(h,o))===c},N=i.kinds.filter(o=>!u.has(o)&&!l.has(o)&&(t.kinds===void 0||t.kinds.includes(o))&&(y.length===0||y.some(d=>w(o,d)))),S=r.conditions.filter(o=>o.key!=="kind").map(o=>({...o,admittedBy:N.filter(d=>Be(i,d).filters.some(c=>c.key===o.key))})),v=S.filter(o=>o.key!=="is"),D=f.filter(o=>o==="flagged"||o==="clear"||o==="past"||o==="archived"),P={kinds:N,past:g},Qe={hits:[],words:r.words,conditions:S,searched:P,byKind:{},total:0,matched:[]};if(a.length===0&&v.length===0&&D.length===0)return Qe;let J=t.today,F=t.flagged??new Set(n.violations().flatMap(o=>o.nodeIds)),Ue=t.touched??pn(n.log.all()),Z=new Set;for(let o of t.from??[]){Z.add(o);for(let d of n.graph.neighbors(o))Z.add(d.id)}let ge=ve(n,s)?Oe(n,s):void 0,ee=ae.keptFrom?.(n,s)&&n.seenBy(s).graph,ne=o=>je(o,t.basePath===void 0?{}:{basePath:t.basePath}),ye={schema:i,graph:n.graph,flagged:F,...J?{today:J}:{}},R=[],B={},L=[],E=[],K=(o,d,c,h,p,m)=>{let x=z(c,o);B[d]=(B[d]??0)+1,R.push({hit:{about:"node",id:o.id,kind:d,label:x,why:p,current:h,flagged:F.has(o.id),address:ne(`${fe(c,d)}/${encodeURIComponent(o.id)}`),...m===void 0?{}:{near:!0},...G(o)?{archived:!0}:{}},...m===void 0?{}:{nearly:2-m},tier:I[p.strength],inKind:d===t.inKind?0:1,near:Z.has(o.id)?0:1,past:h?0:1,archived:G(o)?1:0,touched:-(Ue.get(o.id)??0),flagged:F.has(o.id)?0:1,name:x,id:o.id})};for(let o of N){let d=i.tryDefinition(o),c=S.filter(p=>p.key!=="is"&&p.admittedBy.includes(o));if(a.length===0&&c.length===0&&D.length===0)continue;let h=Fe(d,c);for(let p of n.graph.nodesOfKind(o,{archived:A})){if(ge&&!ge(p.id))continue;let m=ee?ee.getNode(p.id):p;if(!m)continue;let x=_(d,m,J);if(!g&&!h&&!x){if(a.length>0&&f.length===0&&c.every(b=>le(ye,m,b))){let b=_e(d,m,r.words);b&&E.push({node:m,kind:o,definition:d,why:b})}continue}if(k&&x||!c.every(b=>le(ye,m,b))||f.includes("flagged")&&!F.has(m.id)||f.includes("clear")&&F.has(m.id))continue;let C=a.length>0?_e(d,m,r.words):c[0]?{field:c[0].key,reading:W(c[0].key),fragment:`${c[0].key}:${c[0].value}`,strength:"field"}:{field:"is",reading:"Is",fragment:`is:${D[0]}`,strength:"field"};C?K(m,o,d,x,C):a.length>0&&L.push({node:m,kind:o,definition:d,current:x})}}let te=o=>o.strength!=="field",re=!1;if(E.length>0&&R.length===0){re=!0;for(let o of E)K(o.node,o.kind,o.definition,!1,o.why)}else if(E.some(o=>te(o.why))&&!R.some(o=>te(o.hit.why))){re=!0;for(let o of E)te(o.why)&&K(o.node,o.kind,o.definition,!1,o.why)}let he=t.near!==!1&&a.length>0&&R.length<tn&&L.length>0,ie=new Set;if(he)for(let o of L){let d=fn(Q(o.definition,o.node),a);d&&(ie.add(o.node.id),K(o.node,o.kind,o.definition,o.current,d,d.by==="stem"?.9:.8))}let Ve=o=>o==="exact"||o==="prefix"?-1:I[o],oe=(o,d,c,h)=>({hit:o,tier:Ve(d),inKind:1,near:1,past:0,touched:0,flagged:1,name:c,id:h});if(a.length>0){for(let d of N){let c=mn(i,d,a);if(!c)continue;let h=Ne(i,d),p={field:c.field,reading:c.field==="plural"?"Plural":"Kind",fragment:c.text,strength:c.strength};R.push(oe({about:"kind",kind:d,label:h,why:p,count:B[d]??0,address:ne(fe(i.tryDefinition(d),d))},c.strength,h,`kind:${d}`))}let o=t.places??[];for(let d of Re(o.filter(c=>N.includes(c.kind)))){if(d.across&&u.has(d.across))continue;let c=j(d.title,a);if(!c)continue;let h={field:"title",reading:"Title",fragment:d.title,strength:c},p=Me(d,o)?fe(i.tryDefinition(d.kind),d.kind).slice(1):void 0,m=ne(We(d.as,p));R.push(oe({about:"place",kind:d.kind,title:d.title,as:d.as,why:h,address:m},c,d.title,`place:${d.kind}:${d.as}`))}for(let d of n.allInvariants()){let c=d.scope==="graph"?void 0:d.scope.kind;if(c&&!N.includes(c))continue;let h=d.label??W(d.name),p=j(h,a),m=p?void 0:j(W(d.name),a),x=p??m;if(!x)continue;let C={field:p?"label":"name",reading:p?"Rule":"Name",fragment:p?h:d.name,strength:x};R.push(oe({about:"rule",name:d.name,label:h,...c?{kind:c}:{},why:C},x,h,`rule:${d.name}`))}}let pe=()=>{R.sort(qe);let o=t.limit??50,d=R.slice(0,o).map(b=>b.hit),c=d.flatMap(b=>b.about==="node"?[(ee||n.graph).getNode(b.id)]:[]).filter(Boolean),h=Ce(c,b=>i.tryDefinition(b)),p=d.map(b=>b.about==="node"&&h.has(b.id)?{...b,apart:h.get(b.id)}:b),m=Object.values(B).reduce((b,Ye)=>b+Ye,0),x=R.flatMap(b=>b.hit.about==="node"?[b.hit.id]:[]),C=t.subject&&N.includes(String(n.graph.getNode(t.subject)?.kind))?xn(n,t.subject,r.words,{principal:s}):[];return{hits:[...p,...C],words:r.words,conditions:S,searched:re?{...P,past:!0}:P,byKind:{...B},total:m,matched:x}},H=pe(),me=t.rank;if(!he||!me)return H;let be=L.filter(o=>!ie.has(o.node.id)).map(({node:o,kind:d,definition:c})=>({id:o.id,kind:d,label:z(c,o),texts:Q(c,o)}));if(be.length===0)return H;let Xe=(async()=>{let o;try{o=await me(r.words,be)}catch{return H}let d=new Map(L.filter(h=>!ie.has(h.node.id)).map(h=>[h.node.id,h])),c=!1;for(let{id:h,score:p,matched:m}of Array.isArray(o)?o:[]){let x=d.get(h);!x||!(p>0)||(d.delete(h),c=!0,K(x.node,x.kind,x.definition,x.current,gn(Q(x.definition,x.node),r.words,typeof m=="string"?m:void 0),Math.min(1,p)))}return c?pe():H})();return{...H,later:Xe}}function xn(n,e,t,i={}){let r=i.principal??{kind:"human"},a=(ae.keptFrom?.(n,r)?n.seenBy(r):n).graph.getNode(e);if(!a)return[];if(n.kindsKeptFrom(r).has(a.kind))return[];let s=T(t),u=z(n.schema.tryDefinition(a.kind),a),l=[];for(let f of n.allMutations()){let g=f.subject;if(!g||g.kinds!=="*"&&!g.kinds.includes(a.kind))continue;let k=f.derived?.act;if((k==="archive"||k==="merge")&&G(a)||k==="unarchive"&&!G(a)||k==="leave-alone"&&se(a)||k==="allow-tidying"&&!se(a)||!n.permits({name:f.name,args:{[g.arg]:a.id}},r).ok)continue;let A=Ae(f),w=T(A),N=s.filter(v=>w.some(D=>D.startsWith(v))),O=N.length>0?j(A,N):void 0,S=O?{field:"title",reading:"Act",fragment:A,strength:O}:{field:"subject",reading:"On",fragment:u,strength:"field"};l.push({hit:{about:"act",name:f.name,title:A,subject:a.id,why:S,destructive:f.destructive===!0},tier:O?I[O]:I.field+1,inKind:0,near:0,past:f.destructive?1:0,touched:0,flagged:f.pinned?0:1,name:A,id:`act:${f.name}`})}l.sort(qe);let y=l.map(f=>f.hit);return i.limit===void 0?y:y.slice(0,i.limit)}function Kn(n,e){let t=e.kinds.map((a,s)=>{let u=ue(n.tryDefinition(a),a);return s===0?u:u.toLowerCase()}),i=xe(t)||"Nothing";return e.kinds.some(a=>n.tryDefinition(a)?.lifecycle)?e.past?`${M(i)}, past ones included.`:`${M(i)}, current ones; add is:any for past ones.`:`${M(i)}.`}export{V as a,de as b,Je as c,Fe as d,Be as e,On as f,Rn as g,Le as h,Ie as i,Pe as j,nn as k,le as l,ze as m,ce as n,sn as o,_e as p,pn as q,En as r,xn as s,Kn as t};
@@ -1,4 +1,4 @@
1
- import{a as I,j as M,k as O}from"./chunk.LQVAABPS.js";import"./chunk.NGTRL5U4.js";import{g as P}from"./chunk.3MOJF7BA.js";import{l as D}from"./chunk.LZIBQ3VX.js";import"./chunk.MSWWWLEA.js";import"./chunk.UITT6JWW.js";import{b as C}from"./chunk.A5PDXNY6.js";import"./chunk.WC3DENU4.js";import"./chunk.VNDKKTED.js";import{G as q,T as F}from"./chunk.4MP72LPR.js";import"./chunk.SDO3U72B.js";import{$c as E,ga as L}from"./chunk.VSCIXAHN.js";import"./chunk.FQLNBIQ5.js";import{b as N}from"./chunk.AJZBJBMO.js";var f=N(q(),1);var n=N(F(),1),R=40,B=60;function T(l,o,s){return l.allNodes().filter(i=>i.kind===o).map(i=>i[s])}function Y(l){if(l.length<2)return[];let o=[...l].sort((a,d)=>a-d),s=o[o.length-1]-o[0];if(s<=0)return[];let i=Math.max(1,10**Math.floor(Math.log10(s/4))),e=s/4>=i*5?i*5:i,t=a=>Math.round(a/e)*e;return[...new Set([.2,.4,.6,.8].map(a=>t(o[Math.floor(a*(o.length-1))])))].filter(a=>a>0)}function _(l,o,s){let i=new Set(s.far??[]),e=new Map;for(let t of o.allNodes())i.has(t.kind)&&e.set(t.id,L(l.tryDefinition(t.kind),t));return[...e.entries()].map(([t,a])=>({id:t,label:a}))}function K(l,o,s){let i=_(l,o,s);return(i.length<=R?i:i.map(t=>({end:t,ties:o.out(t.id).length+o.in(t.id).length})).sort((t,a)=>a.ties-t.ties||t.end.label.localeCompare(a.end.label)).slice(0,R).map(t=>t.end)).sort((t,a)=>t.label.localeCompare(a.label))}function U(l,o,s){let i=[];for(let e of s.filters){let t=i.length;if(e.about==="is")for(let a of e.options??[])i.push({value:`is:${a}`,label:a,group:e.label,condition:{key:"is",value:a}});else if(e.about==="edge"){i.push({value:`${e.key}:*`,label:"anything",group:e.label,condition:{key:e.key,value:"*"}}),i.push({value:`${e.key}:none`,label:"nothing",group:e.label,condition:{key:e.key,value:"none"}});for(let a of K(l,o,e))i.push({value:`${e.key}:${a.id}`,label:a.label,group:e.label,condition:{key:e.key,value:a.id}})}else if(e.type==="date")for(let a of["before","after","on"])i.push({value:`${e.key}:${a}`,label:`${a}\u2026`,group:e.label,ask:{key:e.key,op:a,label:e.label}});else if(e.type==="number"){let a=l.tryDefinition(s.kind),d=Y(T(o,s.kind,e.key).filter(p=>typeof p=="number"));for(let p of["at-most","at-least"])for(let v of p==="at-most"?d:[...d].reverse())i.push({value:`${e.key}:${p}:${v}`,label:`${p==="at-most"?"at most":"at least"} ${C(a,e.key,v)}`,group:e.label,condition:{key:e.key,value:`${p}:${v}`}})}else if(e.type==="text"){let a=[...new Set(T(o,s.kind,e.key).filter(d=>typeof d=="string"&&d.length>0&&!d.includes(",")))].sort((d,p)=>d.localeCompare(p));if(a.length>=2&&a.length<=B)for(let d of a)i.push({value:`${e.key}:${d}`,label:d,group:e.label,condition:{key:e.key,value:d}})}else if(e.type==="boolean")i.push({value:`${e.key}:true`,label:"yes",group:e.label,condition:{key:e.key,value:"true"}}),i.push({value:`${e.key}:false`,label:"no",group:e.label,condition:{key:e.key,value:"false"}});else if(e.about==="via"){let a=l.tryDefinition(e.far?.[0]??"");for(let d of e.options??[])i.push({value:`${e.key}:${d}`,label:C(a,e.key.split(".")[1],d),group:e.label,condition:{key:e.key,value:d}})}else for(let a of e.options??[])i.push({value:`${e.key}:${a}`,label:C(l.tryDefinition(s.kind),e.key,a),group:e.label,condition:{key:e.key,value:a}});for(let a=t;a<i.length;a++)i[a]={...i[a],key:e.key}}return i}function V(l,o,s,i){let e=l.tryDefinition(o);return["at-most","at-least"].map(t=>({value:`${s.key}:${t}:${i}`,label:`${t==="at-most"?"at most":"at least"} ${C(e,s.key,i)}`,group:s.label,key:s.key,condition:{key:s.key,value:`${t}:${i}`}}))}function G(l){let o=l.trim().replace(/(?<=\d),(?=\d{3}\b)/g,"");return/^-?\d+(\.\d+)?$/.test(o)?Number(o):null}function j(l,o,s){let i=U(l,o,s);return s.filters.flatMap(e=>{let t=i.filter(d=>d.key===e.key);if(e.type==="number"&&e.about!=="edge")return[{key:e.key,label:e.label,entries:t,atNumber:d=>V(l,s.kind,e,d)}];if(t.length===0)return[];if(e.about!=="edge")return[{key:e.key,label:e.label,entries:t}];let a=_(l,o,e);return a.length<I?[{key:e.key,label:e.label,entries:t}]:[{key:e.key,label:e.label,entries:t.filter(d=>d.value===`${e.key}:*`||d.value===`${e.key}:none`),typed:[...a].sort((d,p)=>d.label.localeCompare(p.label))}]})}var z=8;function H(l,o){let s=o.trim().toLocaleLowerCase();if(!s)return{shown:[],more:0};let e=[...l.filter(t=>t.label.toLocaleLowerCase().includes(s))].sort((t,a)=>+!t.label.toLocaleLowerCase().startsWith(s)-+!a.label.toLocaleLowerCase().startsWith(s));return{shown:e.slice(0,z),more:Math.max(0,e.length-z)}}var J=["day","week","month","year","decade"];function ie(l){let{which:o,schema:s,graph:i,offers:e,arrangement:t,set:a,toggle:d,has:p,done:v}=l,m=l.testId,A=(0,f.useRef)(null);(0,f.useEffect)(()=>{let u=A.current?.closest("[data-graview-popover]");!u||document.activeElement!==u||(u.querySelector('[aria-pressed="true"]')??u.querySelector("button, input"))?.focus({preventScroll:!0})},[]);let y=t.sort?e.sorts.find(u=>u.key===t.sort.by):void 0,S=t.group?e.groups.find(u=>u.key===t.group.by):void 0,b=O(y),r=e.natural?e.sorts.find(u=>u.key===e.natural.by):void 0,k=o==="filter"||o==="all"&&l.parts?.filter?j(s,i,e):[],w=u=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{children:"Sort by"}),(0,n.jsx)($,{testId:`${m}-sort-default`,value:"",on:!t.sort,onPress:()=>(a({sort:void 0}),u()),children:r?`As declared (${M(r.label)})`:"As they were added"}),e.sorts.map(g=>(0,n.jsx)($,{value:g.key,on:t.sort?.by===g.key,onPress:()=>(a({sort:{by:g.key,direction:t.sort?.direction??"asc"}}),u()),children:g.label},g.key)),t.sort?(0,n.jsxs)("div",{role:"group","aria-label":"Order","data-testid":`${m}-direction`,children:[(0,n.jsx)("p",{"aria-hidden":"true",children:"Order"}),["asc","desc"].map(g=>(0,n.jsx)($,{testId:`${m}-direction-${g}`,value:g,on:t.sort.direction===g,onPress:()=>(a({sort:{by:t.sort.by,direction:g}}),u()),children:b[g]},g))]}):null]}),c=u=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{children:"Group by"}),(0,n.jsx)($,{testId:`${m}-group-none`,value:"",on:!t.group,onPress:()=>(a({group:void 0}),u()),children:"Not grouped"}),e.groups.map(g=>(0,n.jsx)($,{value:g.key,on:t.group?.by===g.key,onPress:()=>(a({group:{by:g.key}}),u()),children:g.label},g.key)),t.group&&S?.buckets?(0,n.jsxs)("div",{role:"group","aria-label":"How wide a group is","data-testid":`${m}-bucket`,children:[(0,n.jsx)("p",{"aria-hidden":"true",children:"Each group"}),J.map(g=>(0,n.jsx)($,{testId:`${m}-bucket-${g}`,value:g,on:(t.group.bucket??"day")===g,onPress:()=>(a({group:{by:t.group.by,bucket:g}}),u()),children:`A ${g}`},g))]}):null]}),x=u=>(0,n.jsx)(Q,{sections:k,has:p,testId:m,onToggle:g=>(d(g),u())}),h=l.parts??{sort:!0,group:!0,filter:!0};return(0,n.jsxs)("div",{ref:A,style:{display:"contents"},children:[(0,n.jsx)("style",{children:Z}),o==="sort"?w(v):o==="group"?c(v):o==="filter"?x(v):(0,n.jsxs)(n.Fragment,{children:[h.sort?(0,n.jsx)("div",{role:"group","aria-label":"Sort",children:w(v)}):null,h.group?(0,n.jsx)("div",{role:"group","aria-label":"Group",children:c(v)}):null,h.filter?(0,n.jsx)("div",{role:"group","aria-label":"Filter",children:x(v)}):null]})]})}function $({value:l,on:o,onPress:s,testId:i,children:e}){return(0,n.jsx)("button",{type:"button",className:"graview-arrange-item",value:l,"data-value":l,"aria-pressed":o,onClick:s,...i?{"data-testid":i}:{},children:e})}function Q({sections:l,has:o,testId:s,onToggle:i}){let[e,t]=(0,f.useState)(null),[a,d]=(0,f.useState)(""),[p,v]=(0,f.useState)(()=>new Set(l.length===1?[l[0].key]:[])),[m,A]=(0,f.useState)({});if(e)return(0,n.jsx)(X,{ask:e,testId:s,onDay:r=>i({key:e.key,value:`${e.op}:${r}`}),onCancel:()=>t(null)});let y=r=>(0,n.jsx)($,{value:r.value,on:r.condition?o(r.condition):!1,onPress:()=>r.condition?i(r.condition):t(r.ask),children:r.label},r.value),S=(r,k)=>{let w=(r.typed??[]).filter(h=>o({key:r.key,value:h.id})),c=H(r.typed??[],k),x=[...w,...c.shown.filter(h=>!w.includes(h))];return(0,n.jsxs)(n.Fragment,{children:[x.map(h=>y({value:`${r.key}:${h.id}`,label:h.label,group:r.label,key:r.key,condition:{key:r.key,value:h.id}})),k.trim()&&c.shown.length===0?(0,n.jsx)("span",{className:"graview-arrange-none",children:"None is called that."}):null,c.more>0?(0,n.jsx)("span",{className:"graview-arrange-none",children:`${c.more} more \u2014 type more of the name`}):null]})},b=a.trim().toLocaleLowerCase();return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("label",{className:"graview-arrange-find",children:[(0,n.jsx)("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:"Find a filter"}),(0,n.jsx)("input",{type:"search","data-testid":`${s}-filter-find`,value:a,placeholder:"Find a filter, a name or a number\u2026",onChange:r=>d(r.target.value)})]}),l.map(r=>{let k=r.entries.filter(c=>c.condition&&o(c.condition)).length+(r.typed??[]).filter(c=>o({key:r.key,value:c.id})).length;if(b){let c=r.label.toLocaleLowerCase().includes(b),x=r.atNumber&&G(b)!==null?r.atNumber(G(b)):[],h=[...x,...c?r.entries:r.entries.filter(g=>g.label.toLocaleLowerCase().includes(b)&&!x.some(W=>W.value===g.value))],u=r.typed?H(r.typed,b):{shown:[],more:0};return h.length===0&&u.shown.length===0?null:(0,n.jsxs)("div",{role:"group","aria-label":r.label,"data-section":r.key,children:[(0,n.jsx)("p",{"aria-hidden":"true",children:r.label}),h.map(y),r.typed?S(r,b):null]},r.key)}if(r.entries.length===0&&!r.typed)return null;let w=p.has(r.key);return(0,n.jsxs)("div",{role:"group","aria-label":r.label,"data-section":r.key,children:[(0,n.jsxs)("button",{type:"button",className:"graview-arrange-section","data-testid":`${s}-section`,"data-key":r.key,"aria-expanded":w,onClick:()=>v(c=>c.has(r.key)?new Set([...c].filter(x=>x!==r.key)):new Set([...c,r.key])),children:[(0,n.jsx)("span",{children:r.label}),k>0?(0,n.jsx)("span",{className:"graview-arrange-on",children:`${k} on`}):null]}),w?(0,n.jsxs)(n.Fragment,{children:[r.typed?(0,n.jsx)("input",{type:"search",className:"graview-arrange-far","data-testid":`${s}-far-find`,"data-key":r.key,"aria-label":`${r.label}: type a name`,placeholder:`Type a name (${r.typed.length})\u2026`,autoFocus:!0,value:m[r.key]??"",onChange:c=>A({...m,[r.key]:c.target.value})}):null,r.entries.map(y),r.typed?S(r,m[r.key]??""):null]}):null]},r.key)})]})}function X({ask:l,testId:o,onDay:s,onCancel:i}){let[e,t]=(0,f.useState)(""),a=/^\d{4}-\d{2}-\d{2}$/.test(e)&&Number(e.slice(0,4))>=1e3,d=()=>{a&&s(e)};return(0,n.jsxs)("div",{role:"group","aria-label":`${l.label} ${l.op} which day`,"data-testid":`${o}-ask-day`,className:"graview-arrange-ask",children:[(0,n.jsx)("p",{"aria-hidden":"true",children:`${l.label} ${l.op}`}),(0,n.jsx)("input",{type:"date","data-testid":`${o}-day`,"aria-label":`${l.label} ${l.op} which day`,autoFocus:!0,value:e,onChange:p=>t(p.target.value),onKeyDown:p=>{p.key==="Enter"?(p.preventDefault(),d()):p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),p.nativeEvent.stopImmediatePropagation(),i())}}),(0,n.jsxs)("span",{children:[(0,n.jsx)("button",{type:"button","data-testid":`${o}-day-add`,disabled:!a,onClick:d,children:"Add"}),(0,n.jsx)("button",{type:"button",onClick:i,children:"Never mind"})]})]})}var Z=`
1
+ import{a as I,j as M,k as O}from"./chunk.2LNSENPV.js";import"./chunk.WS7LAT4Z.js";import{g as P}from"./chunk.5X22RKB3.js";import{l as D}from"./chunk.XZUHFXME.js";import"./chunk.UO544PZH.js";import"./chunk.4STDIZVI.js";import{b as C}from"./chunk.HZHNM2KI.js";import"./chunk.AVFOTYZR.js";import"./chunk.HOQMD6WQ.js";import{G as q,T as F}from"./chunk.N7T7VB77.js";import"./chunk.SDO3U72B.js";import{$c as E,ga as L}from"./chunk.F7PIW2EM.js";import"./chunk.FQLNBIQ5.js";import{b as N}from"./chunk.AJZBJBMO.js";var f=N(q(),1);var n=N(F(),1),R=40,B=60;function T(l,o,s){return l.allNodes().filter(i=>i.kind===o).map(i=>i[s])}function Y(l){if(l.length<2)return[];let o=[...l].sort((a,d)=>a-d),s=o[o.length-1]-o[0];if(s<=0)return[];let i=Math.max(1,10**Math.floor(Math.log10(s/4))),e=s/4>=i*5?i*5:i,t=a=>Math.round(a/e)*e;return[...new Set([.2,.4,.6,.8].map(a=>t(o[Math.floor(a*(o.length-1))])))].filter(a=>a>0)}function _(l,o,s){let i=new Set(s.far??[]),e=new Map;for(let t of o.allNodes())i.has(t.kind)&&e.set(t.id,L(l.tryDefinition(t.kind),t));return[...e.entries()].map(([t,a])=>({id:t,label:a}))}function K(l,o,s){let i=_(l,o,s);return(i.length<=R?i:i.map(t=>({end:t,ties:o.out(t.id).length+o.in(t.id).length})).sort((t,a)=>a.ties-t.ties||t.end.label.localeCompare(a.end.label)).slice(0,R).map(t=>t.end)).sort((t,a)=>t.label.localeCompare(a.label))}function U(l,o,s){let i=[];for(let e of s.filters){let t=i.length;if(e.about==="is")for(let a of e.options??[])i.push({value:`is:${a}`,label:a,group:e.label,condition:{key:"is",value:a}});else if(e.about==="edge"){i.push({value:`${e.key}:*`,label:"anything",group:e.label,condition:{key:e.key,value:"*"}}),i.push({value:`${e.key}:none`,label:"nothing",group:e.label,condition:{key:e.key,value:"none"}});for(let a of K(l,o,e))i.push({value:`${e.key}:${a.id}`,label:a.label,group:e.label,condition:{key:e.key,value:a.id}})}else if(e.type==="date")for(let a of["before","after","on"])i.push({value:`${e.key}:${a}`,label:`${a}\u2026`,group:e.label,ask:{key:e.key,op:a,label:e.label}});else if(e.type==="number"){let a=l.tryDefinition(s.kind),d=Y(T(o,s.kind,e.key).filter(p=>typeof p=="number"));for(let p of["at-most","at-least"])for(let v of p==="at-most"?d:[...d].reverse())i.push({value:`${e.key}:${p}:${v}`,label:`${p==="at-most"?"at most":"at least"} ${C(a,e.key,v)}`,group:e.label,condition:{key:e.key,value:`${p}:${v}`}})}else if(e.type==="text"){let a=[...new Set(T(o,s.kind,e.key).filter(d=>typeof d=="string"&&d.length>0&&!d.includes(",")))].sort((d,p)=>d.localeCompare(p));if(a.length>=2&&a.length<=B)for(let d of a)i.push({value:`${e.key}:${d}`,label:d,group:e.label,condition:{key:e.key,value:d}})}else if(e.type==="boolean")i.push({value:`${e.key}:true`,label:"yes",group:e.label,condition:{key:e.key,value:"true"}}),i.push({value:`${e.key}:false`,label:"no",group:e.label,condition:{key:e.key,value:"false"}});else if(e.about==="via"){let a=l.tryDefinition(e.far?.[0]??"");for(let d of e.options??[])i.push({value:`${e.key}:${d}`,label:C(a,e.key.split(".")[1],d),group:e.label,condition:{key:e.key,value:d}})}else for(let a of e.options??[])i.push({value:`${e.key}:${a}`,label:C(l.tryDefinition(s.kind),e.key,a),group:e.label,condition:{key:e.key,value:a}});for(let a=t;a<i.length;a++)i[a]={...i[a],key:e.key}}return i}function V(l,o,s,i){let e=l.tryDefinition(o);return["at-most","at-least"].map(t=>({value:`${s.key}:${t}:${i}`,label:`${t==="at-most"?"at most":"at least"} ${C(e,s.key,i)}`,group:s.label,key:s.key,condition:{key:s.key,value:`${t}:${i}`}}))}function G(l){let o=l.trim().replace(/(?<=\d),(?=\d{3}\b)/g,"");return/^-?\d+(\.\d+)?$/.test(o)?Number(o):null}function j(l,o,s){let i=U(l,o,s);return s.filters.flatMap(e=>{let t=i.filter(d=>d.key===e.key);if(e.type==="number"&&e.about!=="edge")return[{key:e.key,label:e.label,entries:t,atNumber:d=>V(l,s.kind,e,d)}];if(t.length===0)return[];if(e.about!=="edge")return[{key:e.key,label:e.label,entries:t}];let a=_(l,o,e);return a.length<I?[{key:e.key,label:e.label,entries:t}]:[{key:e.key,label:e.label,entries:t.filter(d=>d.value===`${e.key}:*`||d.value===`${e.key}:none`),typed:[...a].sort((d,p)=>d.label.localeCompare(p.label))}]})}var z=8;function H(l,o){let s=o.trim().toLocaleLowerCase();if(!s)return{shown:[],more:0};let e=[...l.filter(t=>t.label.toLocaleLowerCase().includes(s))].sort((t,a)=>+!t.label.toLocaleLowerCase().startsWith(s)-+!a.label.toLocaleLowerCase().startsWith(s));return{shown:e.slice(0,z),more:Math.max(0,e.length-z)}}var J=["day","week","month","year","decade"];function ie(l){let{which:o,schema:s,graph:i,offers:e,arrangement:t,set:a,toggle:d,has:p,done:v}=l,m=l.testId,A=(0,f.useRef)(null);(0,f.useEffect)(()=>{let u=A.current?.closest("[data-graview-popover]");!u||document.activeElement!==u||(u.querySelector('[aria-pressed="true"]')??u.querySelector("button, input"))?.focus({preventScroll:!0})},[]);let y=t.sort?e.sorts.find(u=>u.key===t.sort.by):void 0,S=t.group?e.groups.find(u=>u.key===t.group.by):void 0,b=O(y),r=e.natural?e.sorts.find(u=>u.key===e.natural.by):void 0,k=o==="filter"||o==="all"&&l.parts?.filter?j(s,i,e):[],w=u=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{children:"Sort by"}),(0,n.jsx)($,{testId:`${m}-sort-default`,value:"",on:!t.sort,onPress:()=>(a({sort:void 0}),u()),children:r?`As declared (${M(r.label)})`:"As they were added"}),e.sorts.map(g=>(0,n.jsx)($,{value:g.key,on:t.sort?.by===g.key,onPress:()=>(a({sort:{by:g.key,direction:t.sort?.direction??"asc"}}),u()),children:g.label},g.key)),t.sort?(0,n.jsxs)("div",{role:"group","aria-label":"Order","data-testid":`${m}-direction`,children:[(0,n.jsx)("p",{"aria-hidden":"true",children:"Order"}),["asc","desc"].map(g=>(0,n.jsx)($,{testId:`${m}-direction-${g}`,value:g,on:t.sort.direction===g,onPress:()=>(a({sort:{by:t.sort.by,direction:g}}),u()),children:b[g]},g))]}):null]}),c=u=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{children:"Group by"}),(0,n.jsx)($,{testId:`${m}-group-none`,value:"",on:!t.group,onPress:()=>(a({group:void 0}),u()),children:"Not grouped"}),e.groups.map(g=>(0,n.jsx)($,{value:g.key,on:t.group?.by===g.key,onPress:()=>(a({group:{by:g.key}}),u()),children:g.label},g.key)),t.group&&S?.buckets?(0,n.jsxs)("div",{role:"group","aria-label":"How wide a group is","data-testid":`${m}-bucket`,children:[(0,n.jsx)("p",{"aria-hidden":"true",children:"Each group"}),J.map(g=>(0,n.jsx)($,{testId:`${m}-bucket-${g}`,value:g,on:(t.group.bucket??"day")===g,onPress:()=>(a({group:{by:t.group.by,bucket:g}}),u()),children:`A ${g}`},g))]}):null]}),x=u=>(0,n.jsx)(Q,{sections:k,has:p,testId:m,onToggle:g=>(d(g),u())}),h=l.parts??{sort:!0,group:!0,filter:!0};return(0,n.jsxs)("div",{ref:A,style:{display:"contents"},children:[(0,n.jsx)("style",{children:Z}),o==="sort"?w(v):o==="group"?c(v):o==="filter"?x(v):(0,n.jsxs)(n.Fragment,{children:[h.sort?(0,n.jsx)("div",{role:"group","aria-label":"Sort",children:w(v)}):null,h.group?(0,n.jsx)("div",{role:"group","aria-label":"Group",children:c(v)}):null,h.filter?(0,n.jsx)("div",{role:"group","aria-label":"Filter",children:x(v)}):null]})]})}function $({value:l,on:o,onPress:s,testId:i,children:e}){return(0,n.jsx)("button",{type:"button",className:"graview-arrange-item",value:l,"data-value":l,"aria-pressed":o,onClick:s,...i?{"data-testid":i}:{},children:e})}function Q({sections:l,has:o,testId:s,onToggle:i}){let[e,t]=(0,f.useState)(null),[a,d]=(0,f.useState)(""),[p,v]=(0,f.useState)(()=>new Set(l.length===1?[l[0].key]:[])),[m,A]=(0,f.useState)({});if(e)return(0,n.jsx)(X,{ask:e,testId:s,onDay:r=>i({key:e.key,value:`${e.op}:${r}`}),onCancel:()=>t(null)});let y=r=>(0,n.jsx)($,{value:r.value,on:r.condition?o(r.condition):!1,onPress:()=>r.condition?i(r.condition):t(r.ask),children:r.label},r.value),S=(r,k)=>{let w=(r.typed??[]).filter(h=>o({key:r.key,value:h.id})),c=H(r.typed??[],k),x=[...w,...c.shown.filter(h=>!w.includes(h))];return(0,n.jsxs)(n.Fragment,{children:[x.map(h=>y({value:`${r.key}:${h.id}`,label:h.label,group:r.label,key:r.key,condition:{key:r.key,value:h.id}})),k.trim()&&c.shown.length===0?(0,n.jsx)("span",{className:"graview-arrange-none",children:"None is called that."}):null,c.more>0?(0,n.jsx)("span",{className:"graview-arrange-none",children:`${c.more} more \u2014 type more of the name`}):null]})},b=a.trim().toLocaleLowerCase();return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("label",{className:"graview-arrange-find",children:[(0,n.jsx)("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:"Find a filter"}),(0,n.jsx)("input",{type:"search","data-testid":`${s}-filter-find`,value:a,placeholder:"Find a filter, a name or a number\u2026",onChange:r=>d(r.target.value)})]}),l.map(r=>{let k=r.entries.filter(c=>c.condition&&o(c.condition)).length+(r.typed??[]).filter(c=>o({key:r.key,value:c.id})).length;if(b){let c=r.label.toLocaleLowerCase().includes(b),x=r.atNumber&&G(b)!==null?r.atNumber(G(b)):[],h=[...x,...c?r.entries:r.entries.filter(g=>g.label.toLocaleLowerCase().includes(b)&&!x.some(W=>W.value===g.value))],u=r.typed?H(r.typed,b):{shown:[],more:0};return h.length===0&&u.shown.length===0?null:(0,n.jsxs)("div",{role:"group","aria-label":r.label,"data-section":r.key,children:[(0,n.jsx)("p",{"aria-hidden":"true",children:r.label}),h.map(y),r.typed?S(r,b):null]},r.key)}if(r.entries.length===0&&!r.typed)return null;let w=p.has(r.key);return(0,n.jsxs)("div",{role:"group","aria-label":r.label,"data-section":r.key,children:[(0,n.jsxs)("button",{type:"button",className:"graview-arrange-section","data-testid":`${s}-section`,"data-key":r.key,"aria-expanded":w,onClick:()=>v(c=>c.has(r.key)?new Set([...c].filter(x=>x!==r.key)):new Set([...c,r.key])),children:[(0,n.jsx)("span",{children:r.label}),k>0?(0,n.jsx)("span",{className:"graview-arrange-on",children:`${k} on`}):null]}),w?(0,n.jsxs)(n.Fragment,{children:[r.typed?(0,n.jsx)("input",{type:"search",className:"graview-arrange-far","data-testid":`${s}-far-find`,"data-key":r.key,"aria-label":`${r.label}: type a name`,placeholder:`Type a name (${r.typed.length})\u2026`,autoFocus:!0,value:m[r.key]??"",onChange:c=>A({...m,[r.key]:c.target.value})}):null,r.entries.map(y),r.typed?S(r,m[r.key]??""):null]}):null]},r.key)})]})}function X({ask:l,testId:o,onDay:s,onCancel:i}){let[e,t]=(0,f.useState)(""),a=/^\d{4}-\d{2}-\d{2}$/.test(e)&&Number(e.slice(0,4))>=1e3,d=()=>{a&&s(e)};return(0,n.jsxs)("div",{role:"group","aria-label":`${l.label} ${l.op} which day`,"data-testid":`${o}-ask-day`,className:"graview-arrange-ask",children:[(0,n.jsx)("p",{"aria-hidden":"true",children:`${l.label} ${l.op}`}),(0,n.jsx)("input",{type:"date","data-testid":`${o}-day`,"aria-label":`${l.label} ${l.op} which day`,autoFocus:!0,value:e,onChange:p=>t(p.target.value),onKeyDown:p=>{p.key==="Enter"?(p.preventDefault(),d()):p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),p.nativeEvent.stopImmediatePropagation(),i())}}),(0,n.jsxs)("span",{children:[(0,n.jsx)("button",{type:"button","data-testid":`${o}-day-add`,disabled:!a,onClick:d,children:"Add"}),(0,n.jsx)("button",{type:"button",onClick:i,children:"Never mind"})]})]})}var Z=`
2
2
  .graview-arrange-list{display:grid;align-content:start;width:min(300px,calc(100vw - 24px));height:auto;max-height:min(70vh,520px);overflow:auto;overscroll-behavior:contain;margin:0;padding:0 6px 6px;border-radius:10px;border:1px solid var(--graview-edge);background:linear-gradient(var(--graview-float),var(--graview-float)),var(--graview-panel);box-shadow:var(--graview-lift-high);color:var(--graview-ink);font-size:.875rem;line-height:1.3}
3
3
  .graview-arrange-list>*:first-child:not(.graview-arrange-find){margin-top:6px}
4
4
  @media (max-width:519px){.graview-arrange-list{left:0!important;right:0!important;top:auto!important;bottom:0!important;width:100%!important;max-height:min(80dvh,560px)!important;border-radius:14px 14px 0 0;padding-bottom:calc(10px + env(safe-area-inset-bottom))}}
@@ -1 +1 @@
1
- import{l as O}from"./chunk.OJGHDWI6.js";import{j as C}from"./chunk.UITT6JWW.js";import{G as b,La as K,T as M,ba as w,c as W,ca as I,da as H,x as G}from"./chunk.4MP72LPR.js";import{C as D,Gb as N,Pb as _,Xb as L,Xc as V,Yc as B,gc as j,rb as F}from"./chunk.VSCIXAHN.js";import{b as m}from"./chunk.AJZBJBMO.js";function U(n,e){let t=n.graph.getNode(e);if(!t)return[];let i=t.kind,a=n.schema.tryDefinition(i);if(!a)return[];let c=n.seenFor,u=c?N.keptFrom?.(n,c)?.(t):void 0,o=new Map;for(let r of n.allMutations()){let s=r.subject;if(!s||!(s.kinds==="*"||s.kinds.includes(i)))continue;let l=r.input.shape??{};for(let d of j(r,a)){if(u?.(d)||!_(r,n.schema,n.graph,e,d,c&&F(c).id))continue;let x=d in l,k=[];for(let h of Object.keys(l)){if(h===s.arg||h===d||ee(l[h]))continue;let v=L(r.input).find(S=>S.name===h);k.push({name:h,...v?{kinds:v.kinds}:{},...v?{candidates:v.kinds.includes("*")?n.graph.allNodes().map(S=>S.id):v.kinds.flatMap(S=>n.graph.nodesOfKind(S).map(Z=>Z.id))}:{},shape:C(r.input,h)})}let X={field:d,mutation:r.name,title:r.title??r.name,shape:x?C(r.input,d):{type:"unknown"},takesValue:x,alternatives:[],open:k,clearable:x&&(r.clearable?.includes(d)??!1),call:h=>({name:r.name,args:x?{[s.arg]:e,[d]:h}:{[s.arg]:e}})};o.set(d,[...o.get(d)??[],X])}}return[...o.values()].map(r=>{let s=[...r.filter(d=>d.takesValue),...r.filter(d=>!d.takesValue)],[f,...l]=s;return{...f,alternatives:l}})}function ee(n){let e=D(n)?.type;return e==="optional"||e==="default"||e==="nullable"}var R=m(b(),1);function Se(n){let{store:e,principal:t}=w(),i=H(),a=(0,R.useMemo)(()=>n===null?[]:U(e,n),[e,n,i]),c=(0,R.useCallback)((u,o,r={})=>{let s=u.call(o);e.apply({name:s.name,args:{...s.args,...r}},{author:t})},[e,t]);return{fields:a,commit:c}}var $=m(b(),1);function Xe(){let{brand:n}=w(),e=n?.kit;return(0,$.useMemo)(()=>V(e),[e])}function Ze(n,e){let t=B(n,e),i={...t.color!==void 0?{color:t.color}:{},...t.pattern!==void 0?{pattern:t.pattern}:{},...t.width!==void 0?{width:t.width}:{},...t.cap!==void 0?{cap:t.cap}:{},...t.opacity!==void 0?{opacity:t.opacity}:{}};return{connector:t,style:O(e,{[e]:i})}}var q=m(b(),1);var g=m(M(),1);function ne(n){let e=n?.hint;return typeof e=="string"&&e.length>0?e:void 0}function te(n){if(n instanceof Error&&n.message)return n.message;let e=String(n);return e==="[object Object]"?"The view threw without a message.":e}var z=class extends q.Component{static contextType=K;state={};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[graview] the ${this.props.view??"view"} of ${this.props.kind} threw while rendering`,e,t.componentStack),this.context?.(e,{module:"@graview/react"})}render(){let{error:e}=this.state;if(!e)return this.props.children;let t=ne(e);return(0,g.jsxs)("div",{role:"alert","data-graview-view-error":this.props.kind,style:{display:"flex",flexDirection:"column",gap:"0.375rem",padding:"var(--graview-pad, 12px)",height:"100%",overflow:"auto",boxSizing:"border-box",borderRadius:"var(--graview-radius-sm, 6px)",background:"var(--graview-panel-warning, #fdf3ec)",color:"var(--graview-ink, #1a1a1a)",font:"var(--graview-font-body, 13px/1.45 system-ui)",fontSize:"0.875rem",lineHeight:1.45},children:[(0,g.jsx)("strong",{style:{color:"var(--graview-warn, #b4462a)"},children:this.props.view?`${this.props.view} could not draw`:"This view could not draw"}),(0,g.jsx)("span",{style:{color:"var(--graview-ink-muted, #555)"},children:this.props.kind}),(0,g.jsx)("span",{children:te(e)}),t?(0,g.jsx)("span",{style:{color:"var(--graview-ink-muted, #555)"},children:t}):null]})}};var y=m(b(),1);var Q=m(M(),1),A=(0,y.createContext)([]);function on({sections:n,children:e}){let t=(0,y.useContext)(A),i=(0,y.useMemo)(()=>[...t,...n.filter(a=>!t.includes(a))],[t,n]);return(0,Q.jsx)(A.Provider,{value:i,children:e})}function Y(){let n=(0,y.useContext)(A),e=I()?.menuSections;return(0,y.useMemo)(()=>e?[...n,...e.filter(t=>!n.includes(t))]:n,[n,e])}function an(){let n=Y();return(0,y.useCallback)(e=>{for(let t of n)try{t(e)?.prepare?.()}catch{}},[n])}function sn(n){let e=Y();if(n===null||e.length===0)return{start:[],end:[]};let t=e.flatMap(i=>{try{let a=i(n);return a&&((a.items?.length??0)>0||a.render)?[a]:[]}catch{return[]}});return{start:t.filter(i=>i.at==="start"),end:t.filter(i=>i.at!=="start")}}var re=m(b(),1);function un(){return w().activity}var P=(n,e)=>n.length*e*.58;var oe=156,ie=2,E=oe-18,ae=7.1,se=16;function ce(n,e){let t=0,i=E;for(let a of n.split(" ")){let c=e(a),u=i+e(" ")+c;if(u<=E)i=u;else{let o=Math.ceil(c/E)||1;t+=o,i=c-(o-1)*E}}return t}var de=16.25,J=27,ue=(n,e)=>{let t=Math.ceil(n.length*ae/E);return e?Math.max(J,Math.ceil(Math.max(t,ce(n,e))*de)+6):Math.max(J,t*se+6)};function fn(n,e,t){return n.length===0?0:10+n.reduce((i,a)=>i+ue(a,t),0)+(n.length-1)*ie}var le=27,pe=8,mn=4,fe=64,yn=n=>Math.max(1,Math.min(pe,n)),hn=n=>n*le+fe;var p=m(b(),1);function wn(n,{units:e,target:t=0,legibleAt:i=260}){let[a,c]=(0,p.useState)(e);(0,p.useEffect)(()=>{let o=n.current;if(o===null||typeof ResizeObserver>"u")return;let r=new ResizeObserver(([s])=>{let f=s?.contentRect.width??0;f>0&&c(f)});return r.observe(o),()=>r.disconnect()},[n]);let u=a/e;return{scale:u,width:a,touchable:u*t>=24,legible:a>=i}}function vn(n="--graview-font-body",e="sans-serif"){let t=(0,p.useRef)(void 0),i=(0,p.useMemo)(()=>{if(typeof getComputedStyle!="function"||typeof document>"u")return e;let a=getComputedStyle(document.documentElement).getPropertyValue(n).trim();return a.length>0?a:e},[n,e]);return(0,p.useMemo)(()=>{t.current===void 0&&(t.current=typeof document>"u"?null:document.createElement("canvas").getContext("2d")??null);let a=t.current;return a===null?P:(c,u)=>{a.font=`${u}px ${i}`;let o=a.measureText(c).width;return o>0?o:P(c,u)}},[i])}var Sn=(0,p.createContext)(void 0);var T=3;function me(n){let e=W(n),t=e.focusId;if(!t)return null;if(e.within?.view){let[a]=G(t);if(a)return{at:`screen:${a}`,audience:!0}}return{at:t,audience:!1}}var ye=102,he=32;function Mn(n,e,t){let i=[],a=new Map,c=new Map,u=0;for(let o of n){let r=me(o.stop),s=r?e(r.at):null;if(!r||!s){o.name&&i.push({kind:"edge",presence:o,point:{x:t-8,y:ye+u++*he}});continue}if(!o.name){let k=c.get(r.at);c.set(r.at,{n:(k?.n??0)+1,box:s});continue}let f=a.get(r.at)??[];if(f.push(o),a.set(r.at,f),f.length>T)continue;let l=s,d=f.length-1,x=r.audience?{x:l.x+l.width*.5+(d-1)*26,y:l.y+Math.min(l.height,24)}:{x:l.x+l.width*.5-26-d*26,y:l.y+l.height-4};i.push({kind:"person",presence:o,point:x,at:r.at,index:d,of:f.length,audience:r.audience})}for(let[o,r]of a){if(r.length<=T)continue;let s=e(o);s&&i.push({kind:"count",at:o,point:{x:s.x+s.width*.5+2*26+18,y:s.y+s.height-4},n:r.length-T})}for(let[o,{n:r,box:s}]of c)i.push({kind:"count",at:o,point:{x:s.x+s.width*.5+40,y:s.y+s.height-4},n:r});for(let o of n)if(o.name){if(o.robot?.at&&o.robot.mode!=="docked"){let r=e(o.robot.at);r&&i.push({kind:"robot",presence:o,point:{x:r.x+r.width/2+22,y:r.y+r.height-4},mode:o.robot.mode})}if(o.over){let r=e(o.over);r&&i.push({kind:"over",presence:o,box:r})}}return i}export{un as a,P as b,oe as c,ie as d,J as e,fn as f,le as g,mn as h,fe as i,yn as j,hn as k,wn as l,vn as m,Se as n,Xe as o,Ze as p,Mn as q,z as r,on as s,an as t,sn as u};
1
+ import{l as O}from"./chunk.OJGHDWI6.js";import{j as C}from"./chunk.4STDIZVI.js";import{G as b,La as K,T as M,ba as w,c as W,ca as I,da as H,x as G}from"./chunk.N7T7VB77.js";import{C as D,Gb as N,Pb as _,Xb as L,Xc as V,Yc as B,gc as j,rb as F}from"./chunk.F7PIW2EM.js";import{b as m}from"./chunk.AJZBJBMO.js";function U(n,e){let t=n.graph.getNode(e);if(!t)return[];let i=t.kind,a=n.schema.tryDefinition(i);if(!a)return[];let c=n.seenFor,u=c?N.keptFrom?.(n,c)?.(t):void 0,o=new Map;for(let r of n.allMutations()){let s=r.subject;if(!s||!(s.kinds==="*"||s.kinds.includes(i)))continue;let l=r.input.shape??{};for(let d of j(r,a)){if(u?.(d)||!_(r,n.schema,n.graph,e,d,c&&F(c).id))continue;let x=d in l,k=[];for(let h of Object.keys(l)){if(h===s.arg||h===d||ee(l[h]))continue;let v=L(r.input).find(S=>S.name===h);k.push({name:h,...v?{kinds:v.kinds}:{},...v?{candidates:v.kinds.includes("*")?n.graph.allNodes().map(S=>S.id):v.kinds.flatMap(S=>n.graph.nodesOfKind(S).map(Z=>Z.id))}:{},shape:C(r.input,h)})}let X={field:d,mutation:r.name,title:r.title??r.name,shape:x?C(r.input,d):{type:"unknown"},takesValue:x,alternatives:[],open:k,clearable:x&&(r.clearable?.includes(d)??!1),call:h=>({name:r.name,args:x?{[s.arg]:e,[d]:h}:{[s.arg]:e}})};o.set(d,[...o.get(d)??[],X])}}return[...o.values()].map(r=>{let s=[...r.filter(d=>d.takesValue),...r.filter(d=>!d.takesValue)],[f,...l]=s;return{...f,alternatives:l}})}function ee(n){let e=D(n)?.type;return e==="optional"||e==="default"||e==="nullable"}var R=m(b(),1);function Se(n){let{store:e,principal:t}=w(),i=H(),a=(0,R.useMemo)(()=>n===null?[]:U(e,n),[e,n,i]),c=(0,R.useCallback)((u,o,r={})=>{let s=u.call(o);e.apply({name:s.name,args:{...s.args,...r}},{author:t})},[e,t]);return{fields:a,commit:c}}var $=m(b(),1);function Xe(){let{brand:n}=w(),e=n?.kit;return(0,$.useMemo)(()=>V(e),[e])}function Ze(n,e){let t=B(n,e),i={...t.color!==void 0?{color:t.color}:{},...t.pattern!==void 0?{pattern:t.pattern}:{},...t.width!==void 0?{width:t.width}:{},...t.cap!==void 0?{cap:t.cap}:{},...t.opacity!==void 0?{opacity:t.opacity}:{}};return{connector:t,style:O(e,{[e]:i})}}var q=m(b(),1);var g=m(M(),1);function ne(n){let e=n?.hint;return typeof e=="string"&&e.length>0?e:void 0}function te(n){if(n instanceof Error&&n.message)return n.message;let e=String(n);return e==="[object Object]"?"The view threw without a message.":e}var z=class extends q.Component{static contextType=K;state={};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[graview] the ${this.props.view??"view"} of ${this.props.kind} threw while rendering`,e,t.componentStack),this.context?.(e,{module:"@graview/react"})}render(){let{error:e}=this.state;if(!e)return this.props.children;let t=ne(e);return(0,g.jsxs)("div",{role:"alert","data-graview-view-error":this.props.kind,style:{display:"flex",flexDirection:"column",gap:"0.375rem",padding:"var(--graview-pad, 12px)",height:"100%",overflow:"auto",boxSizing:"border-box",borderRadius:"var(--graview-radius-sm, 6px)",background:"var(--graview-panel-warning, #fdf3ec)",color:"var(--graview-ink, #1a1a1a)",font:"var(--graview-font-body, 13px/1.45 system-ui)",fontSize:"0.875rem",lineHeight:1.45},children:[(0,g.jsx)("strong",{style:{color:"var(--graview-warn, #b4462a)"},children:this.props.view?`${this.props.view} could not draw`:"This view could not draw"}),(0,g.jsx)("span",{style:{color:"var(--graview-ink-muted, #555)"},children:this.props.kind}),(0,g.jsx)("span",{children:te(e)}),t?(0,g.jsx)("span",{style:{color:"var(--graview-ink-muted, #555)"},children:t}):null]})}};var y=m(b(),1);var Q=m(M(),1),A=(0,y.createContext)([]);function on({sections:n,children:e}){let t=(0,y.useContext)(A),i=(0,y.useMemo)(()=>[...t,...n.filter(a=>!t.includes(a))],[t,n]);return(0,Q.jsx)(A.Provider,{value:i,children:e})}function Y(){let n=(0,y.useContext)(A),e=I()?.menuSections;return(0,y.useMemo)(()=>e?[...n,...e.filter(t=>!n.includes(t))]:n,[n,e])}function an(){let n=Y();return(0,y.useCallback)(e=>{for(let t of n)try{t(e)?.prepare?.()}catch{}},[n])}function sn(n){let e=Y();if(n===null||e.length===0)return{start:[],end:[]};let t=e.flatMap(i=>{try{let a=i(n);return a&&((a.items?.length??0)>0||a.render)?[a]:[]}catch{return[]}});return{start:t.filter(i=>i.at==="start"),end:t.filter(i=>i.at!=="start")}}var re=m(b(),1);function un(){return w().activity}var P=(n,e)=>n.length*e*.58;var oe=156,ie=2,E=oe-18,ae=7.1,se=16;function ce(n,e){let t=0,i=E;for(let a of n.split(" ")){let c=e(a),u=i+e(" ")+c;if(u<=E)i=u;else{let o=Math.ceil(c/E)||1;t+=o,i=c-(o-1)*E}}return t}var de=16.25,J=27,ue=(n,e)=>{let t=Math.ceil(n.length*ae/E);return e?Math.max(J,Math.ceil(Math.max(t,ce(n,e))*de)+6):Math.max(J,t*se+6)};function fn(n,e,t){return n.length===0?0:10+n.reduce((i,a)=>i+ue(a,t),0)+(n.length-1)*ie}var le=27,pe=8,mn=4,fe=64,yn=n=>Math.max(1,Math.min(pe,n)),hn=n=>n*le+fe;var p=m(b(),1);function wn(n,{units:e,target:t=0,legibleAt:i=260}){let[a,c]=(0,p.useState)(e);(0,p.useEffect)(()=>{let o=n.current;if(o===null||typeof ResizeObserver>"u")return;let r=new ResizeObserver(([s])=>{let f=s?.contentRect.width??0;f>0&&c(f)});return r.observe(o),()=>r.disconnect()},[n]);let u=a/e;return{scale:u,width:a,touchable:u*t>=24,legible:a>=i}}function vn(n="--graview-font-body",e="sans-serif"){let t=(0,p.useRef)(void 0),i=(0,p.useMemo)(()=>{if(typeof getComputedStyle!="function"||typeof document>"u")return e;let a=getComputedStyle(document.documentElement).getPropertyValue(n).trim();return a.length>0?a:e},[n,e]);return(0,p.useMemo)(()=>{t.current===void 0&&(t.current=typeof document>"u"?null:document.createElement("canvas").getContext("2d")??null);let a=t.current;return a===null?P:(c,u)=>{a.font=`${u}px ${i}`;let o=a.measureText(c).width;return o>0?o:P(c,u)}},[i])}var Sn=(0,p.createContext)(void 0);var T=3;function me(n){let e=W(n),t=e.focusId;if(!t)return null;if(e.within?.view){let[a]=G(t);if(a)return{at:`screen:${a}`,audience:!0}}return{at:t,audience:!1}}var ye=102,he=32;function Mn(n,e,t){let i=[],a=new Map,c=new Map,u=0;for(let o of n){let r=me(o.stop),s=r?e(r.at):null;if(!r||!s){o.name&&i.push({kind:"edge",presence:o,point:{x:t-8,y:ye+u++*he}});continue}if(!o.name){let k=c.get(r.at);c.set(r.at,{n:(k?.n??0)+1,box:s});continue}let f=a.get(r.at)??[];if(f.push(o),a.set(r.at,f),f.length>T)continue;let l=s,d=f.length-1,x=r.audience?{x:l.x+l.width*.5+(d-1)*26,y:l.y+Math.min(l.height,24)}:{x:l.x+l.width*.5-26-d*26,y:l.y+l.height-4};i.push({kind:"person",presence:o,point:x,at:r.at,index:d,of:f.length,audience:r.audience})}for(let[o,r]of a){if(r.length<=T)continue;let s=e(o);s&&i.push({kind:"count",at:o,point:{x:s.x+s.width*.5+2*26+18,y:s.y+s.height-4},n:r.length-T})}for(let[o,{n:r,box:s}]of c)i.push({kind:"count",at:o,point:{x:s.x+s.width*.5+40,y:s.y+s.height-4},n:r});for(let o of n)if(o.name){if(o.robot?.at&&o.robot.mode!=="docked"){let r=e(o.robot.at);r&&i.push({kind:"robot",presence:o,point:{x:r.x+r.width/2+22,y:r.y+r.height-4},mode:o.robot.mode})}if(o.over){let r=e(o.over);r&&i.push({kind:"over",presence:o,box:r})}}return i}export{un as a,P as b,oe as c,ie as d,J as e,fn as f,le as g,mn as h,fe as i,yn as j,hn as k,wn as l,vn as m,Se as n,Xe as o,Ze as p,Mn as q,z as r,on as s,an as t,sn as u};
@@ -0,0 +1,2 @@
1
+ var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as Ge}from"./chunk.BJUUSIQY.js";import{a as Ke}from"./chunk.5POG3G2C.js";import{a as Ve}from"./chunk.ZVG3DR5G.js";import{a as Je}from"./chunk.D5Q64GA4.js";import{a as pe}from"./chunk.2QFKNTAZ.js";import{c as ue}from"./chunk.AVFOTYZR.js";import{E as Oe,G as hn,J as _e,P as We,T as Ue,ba as ze}from"./chunk.N7T7VB77.js";import{Xb as De,ad as He,da as B,fc as fe,ga as ce,hc as Le,ja as W,kd as qe,ma as Ne,md as Be,oa as G,zb as je}from"./chunk.F7PIW2EM.js";import{j as ee}from"./chunk.FQLNBIQ5.js";import{b as xe}from"./chunk.AJZBJBMO.js";var kn=["search-miss","unanswered","refused","tool-invalid"];var _n=new RegExp("[\\u0000-\\u001f\\u007f-\\u009f\\u200b-\\u200f\\u2028-\\u202e\\u2066-\\u2069]","g");var K=e=>e.onBehalfOf?K(e.onBehalfOf):e.id!==void 0?`${e.kind}:${e.id}`:`${e.kind}:?`,ve=e=>e.toLowerCase().replace(/\s+/g," ").replace(/^[\s\p{P}]+|[\s\p{P}]+$/gu,"");var bn=new Set("a an and are at be by can do does for from has have how i in is it me my of on or our the their there this to was we what when where which who why will with you your".split(" "));function ne(e,n,t,i,o){let r=new Map;for(let f of e){let d=n(f);if(d===void 0)continue;let c=r.get(d)??{first:f,people:new Set,times:0,last:f};c.people.add(K(f.by)),c.times+=1,c.last=f,r.set(d,c)}return[...r.entries()].filter(([,f])=>f.people.size>=i).sort(([f,d],[c,a])=>a.people.size-d.people.size||a.times-d.times||f.localeCompare(c)).slice(0,o).map(([f,d])=>({...t(d.last,f),people:d.people.size,times:d.times}))}function wn(e,n={}){let t=Math.max(1,n.minPeople??2),i=n.most??12,o=n.reader?K(n.reader):void 0,r=e.filter(a=>!qe(a.by)&&(o===void 0||K(a.by)!==o)),f=Object.fromEntries(kn.map(a=>{let s=r.filter(u=>u.type===a);return[a,{events:s.length,people:new Set(s.map(u=>K(u.by))).size}]})),d=[],c=new Map;for(let a of r){let s=a.type==="search-miss"?a.words:a.type==="unanswered"?a.question:void 0;if(s!==void 0)for(let u of new Set(ve(s).split(/[^\p{L}\p{N}]+/u))){if(u.length<3||bn.has(u))continue;let g={...a,id:`${a.id}:${u}`};d.push(g),c.set(g,u)}}return{events:r.length,people:new Set(r.map(a=>K(a.by))).size,byType:f,searches:ne(r,a=>a.type==="search-miss"&&ve(a.words)||void 0,(a,s)=>({words:s}),t,i),questions:ne(r,a=>a.type==="unanswered"&&ve(a.question)||void 0,(a,s)=>({question:s}),t,i),words:ne(d,a=>c.get(a),(a,s)=>({word:s}),t,i),refusals:ne(r,a=>a.type==="refused"?`${a.act}|${a.code}`:void 0,a=>({act:a.act,code:a.code}),t,i),tools:ne(r,a=>a.type==="tool-invalid"?`${a.tool}|${a.act??""}`:void 0,a=>{let s=a;return{tool:s.tool,...s.act?{act:s.act}:{},...s.then?{then:s.then}:{}}},1,i)}}var Ye=e=>e.length>3&&e.endsWith("s")&&!e.endsWith("ss")?e.slice(0,-1):e;function An(e){let n=new Set,t=i=>{for(let o of i.toLowerCase().split(/[^\p{L}\p{N}]+/u))o.length>0&&n.add(Ye(o))};for(let i of e.kinds){let o=e.tryDefinition(i);t(i),t(G(o,i)),t(W(e,i));for(let r of[...o?.aliases??[],...Object.values(o?.fieldAliases??{}).flat()])t(r);for(let r of Object.keys(o?.fields?.shape??{}))t(r),t(B(r))}return n}function Qe(e,n,t={}){let i=wn(e,{most:8,...t}),o=An(n),r=i.searches.filter(s=>!s.words.split(/[^\p{L}\p{N}]+/u).some(u=>u.length>0&&o.has(Ye(u)))).map(s=>({words:s.words,people:s.people})),f=i.questions.map(s=>({question:s.question,people:s.people})),d=i.tools.map(s=>({tool:s.tool,...s.act?{act:s.act}:{},...s.then?{then:s.then}:{},times:s.times})),c=s=>`${s} ${s===1?"person":"people"}`;return{said:[...r.length>0?[`Searched for, found nothing, and nothing here is called it: ${r.map(s=>`\u201C${s.words}\u201D (${c(s.people)})`).join(", ")}.`]:[],...f.length>0?[`Asked and not answered: ${f.map(s=>`\u201C${s.question}\u201D (${c(s.people)})`).join(", ")}.`]:[],...d.length>0?[`Tool calls refused as invalid: ${d.map(s=>`${s.tool}${s.act?` (${s.act})`:""} ${s.times===1?"once":`${s.times} times`}${s.then?`, then worked as ${s.then}`:""}`).join("; ")}.`]:[]].join(`
2
+ `),unknownWords:r,questions:f,toolMistakes:d}}var Sn=e=>/^(?:aggregate|kind):([^,]+)$/.exec(e)?.[1];function Xe(e,n){let t=e.about??[];if(e.field!==void 0&&e.on!==void 0&&n(e.on))return{on:"field",id:e.on,field:e.field};let i=t.filter(n);if(i.length>1)return{on:"selection",ids:i};if(e.on!==void 0&&n(e.on))return{on:"record",id:e.on};if(i.length===1)return{on:"record",id:i[0]};let o=[e.on,...t].map(r=>r===void 0?void 0:Sn(r)).find(r=>r!==void 0);return e.place!==void 0?{on:"lens",place:e.place,...o?{kind:o}:{}}:o!==void 0?{on:"list",kind:o}:{on:"place",place:"home"}}var Q=e=>e.on==="record"||e.on==="field"?[e.id]:e.on==="selection"?e.ids:e.on==="act"&&e.id!==void 0?[e.id]:[],ye=(e,n)=>e.tryDefinition(n)?.fields?.shape??{},Y=(e,n)=>e.tryDefinition(n)?.edges??{},ge=(e,n)=>new Set(e.tryDefinition(n)?.display?.hide??[]),L=(e,n)=>ce(e.tryDefinition(n.kind),n),$e=(e,n,t)=>Ne(e.tryDefinition(n),t)||B(t),Ce=e=>typeof e=="boolean"?e?"yes":"no":String(e);function me(e,n){let t=e.kindsKeptFrom(n);return new Set(e.schema.kinds.filter(i=>!t.has(i)))}function Re(e,n,t,i){if(!e.permits(n,t).ok)return!1;if(!i)return!0;try{return e.previewAll([n],{author:t}).ops.length>0}catch{return!1}}function he(e,n,t){let i=e,{principal:o}=t,r=t.each??8,f=ee(i)?.store??i,d=f.seenBy(o),c=f.schema,a=me(f,o),s=l=>{let h=d.graph.getNode(l);return h&&a.has(h.kind)?h:void 0},u=f.allMutations(),g=new Map(u.map(l=>[l.name,l])),b=[],C=new Set,A=l=>{C.has(l.id)||(C.add(l.id),b.push(l))},m=l=>l.slice(0,r),x=Q(n).filter(l=>s(l)!==void 0);if(Q(n).length>0&&x.length===0)return{target:n,candidates:[]};let O=x.length===1?s(x[0]):void 0,k=O?.kind??(n.on==="list"?n.kind:n.on==="lens"?n.kind??t.places?.find(l=>l.as===n.place)?.kind:void 0)??(n.on==="selection"?s(x[0])?.kind:void 0);if(k!==void 0&&!a.has(k))return{target:n,candidates:[]};let p=(l,h)=>`act:${l}${Object.keys(h).length>0?`:${Object.values(h).map(R=>String(R)).join(",")}`:""}`,w=(l,h,R,E,$)=>{l.destructive||Object.values(h).some(y=>typeof y=="string"&&f.graph.has(y)&&s(y)===void 0)||Re(f,{name:l.name,args:{...h}},o,E.length===0)&&A({type:"act",id:p(l.name,h),label:R,description:$??l.description??R,mutation:l.name,args:h,asks:E})};if(n.on!=="place"||t.acts)if(t.acts)for(let l of t.acts){let h=g.get(l.mutation);!h||l.destructive||n.on==="act"&&l.mutation!==n.act||w(h,l.args,l.label,(l.open??[]).filter(R=>!R.optional).map(R=>R.name),l.why)}else{let l=O?[O]:[];for(let h of u){if(n.on==="act"&&h.name!==n.act)continue;let R=h.input.shape??{},E=$=>Object.entries(R).filter(([y,v])=>y!==$&&v.safeParse?.(void 0).success===!1).map(([y])=>y);if(h.subject)for(let $ of l)fe(c,h).includes($.kind)&&w(h,{[h.subject.arg]:$.id},`${h.title??B(h.name)}: ${L(c,$)}`,E(h.subject.arg));else k!==void 0&&(h.creates??[]).includes(k)&&w(h,{},h.title??B(h.name),E(void 0))}}let T=b.filter(l=>l.type==="act");b.splice(0,b.length,...m(T));let F=(l,h)=>{let R=Le(c,u).get(l.kind),E=ye(c,l.kind),$=ge(c,l.kind),y=[];for(let[v,D]of Object.entries(E)){if(h!==void 0?v!==h:$.has(v)||l[v]!==void 0)continue;let j=pe(D),J=j?.type==="enum"&&!j.multiple?j.options??[]:j?.type==="boolean"?[!0,!1]:[];if(J.length===0)continue;let _=(R?.get(v)??[]).map(N=>g.get(N)).find(N=>N?.subject!==void 0&&Re(f,{name:N.name,args:{[N.subject.arg]:l.id,[v]:J.find(Se=>Se!==l[v])??J[0]}},o,!0));if(_?.subject)for(let N of J)l[v]!==N&&y.push({type:"fill",id:`fill:${l.id}:${v}:${Ce(N)}`,label:`${$e(c,l.kind,v)}: ${Ce(N)}`,description:`Set ${$e(c,l.kind,v).toLowerCase()} of ${L(c,l)} to ${Ce(N)}`,record:l.id,field:v,value:N,call:{name:_.name,args:{[_.subject.arg]:l.id,[v]:N}}})}for(let[v,D]of Object.entries(Y(c,l.kind))){if(h!==void 0&&v!==h)continue;let j=D.to==="*"?[...a]:D.to.filter(I=>a.has(I)),J=new Set(d.graph.out(l.id,v).map(I=>I.id)),_=u.find(I=>(I.connects??[]).includes(v)&&I.subject!==void 0&&fe(c,I).includes(l.kind));if(!_?.subject)continue;let N=De(_.input).find(I=>I.name!==_.subject.arg);if(!N)continue;let Se=j.flatMap(I=>N.kinds.length===0||N.kinds.includes(I)?d.graph.nodesOfKind(I):[]).filter(I=>I.id!==l.id&&!J.has(I.id)&&s(I.id)!==void 0);for(let I of m(Se)){let Me={name:_.name,args:{[_.subject.arg]:l.id,[N.name]:I.id}};Re(f,Me,o,!0)&&y.push({type:"fill",id:`fill:${l.id}:${v}:${I.id}`,label:`${B(v)}: ${L(c,I)}`,description:`Link ${L(c,l)} to ${L(c,I)}${D.description?` as ${D.description}`:""}`,record:l.id,field:v,value:I.id,call:Me})}}return y};if(n.on==="field"&&O)for(let l of F(O,n.field))A(l);else if(O&&n.on==="record")for(let l of m(F(O)))A(l);let q=l=>{let h=W(c,l).toLowerCase(),R=[{type:"panel",id:`panel:${l}:list`,label:`A list of ${h}`,description:`Every ${G(c.tryDefinition(l),l).toLowerCase()} this viewer may see, as a list`,panel:{lens:"blocks",kind:l}}],E=ge(c,l);for(let[$,y]of Object.entries(ye(c,l))){if(E.has($))continue;let v=pe(y),D=$e(c,l,$).toLowerCase();if(v?.type==="enum")R.push({type:"panel",id:`panel:${l}:group:${$}`,label:`${V(h)} by ${D}`,description:`A list of ${h} grouped by ${D}`,panel:{lens:"blocks",kind:l,group:$}}),R.push({type:"panel",id:`panel:${l}:columns:${$}`,label:`Columns of ${h} by ${D}`,description:`${V(h)} in a column for each ${D}`,panel:{lens:"columns",kind:l,column:$}});else if(v?.type==="number"||v?.type==="integer"||v?.type==="date"||v?.type==="datetime"){let j=v.type==="date"||v.type==="datetime";R.push({type:"panel",id:`panel:${l}:sort:${$}`,label:`${V(h)} by ${D}`,description:`A list of ${h}, the ${j?"latest":"highest"} ${D} first`,panel:{lens:"blocks",kind:l,sort:{by:$,direction:"desc"}}}),j&&R.push({type:"panel",id:`panel:${l}:calendar:${$}`,label:`A calendar of ${h}`,description:`${V(h)} on a calendar by ${D}`,panel:{lens:"calendar",kind:l,start:$}})}}return R},H=n.on==="place"?[...a]:k!==void 0?[k]:[];for(let l of H)for(let h of m(q(l)))A(h);for(let l of m((t.places??[]).filter(h=>h.kind===void 0?n.on==="place":a.has(h.kind)&&(n.on==="place"||h.kind===k))))n.on==="lens"&&l.as===n.place||A({type:"place",id:`place:${l.as}`,label:l.title,description:`Go to ${l.title}`,place:l.as});if(O){let l=[];for(let[h,R]of Object.entries(Y(c,O.kind)))for(let E of d.graph.out(O.id,h))s(E.id)&&l.push({type:"record",id:`record:${E.id}`,label:L(c,E),description:`${V(R.description??B(h))}: ${L(c,E)}`,record:E.id,relation:h});for(let h of c.kinds)for(let[R,E]of Object.entries(Y(c,h)))if(!(E.to!=="*"&&!E.to.includes(O.kind)))for(let $ of d.graph.in(O.id,R))$.kind===h&&s($.id)&&l.push({type:"record",id:`record:${$.id}`,label:L(c,$),description:`${V(E.inverse??B(R))}: ${L(c,$)}`,record:$.id,relation:R});for(let h of m(l))A(h)}else if(n.on==="list"||n.on==="lens")for(let l of m(k!==void 0?d.graph.nodesOfKind(k):[]))s(l.id)&&A({type:"record",id:`record:${l.id}`,label:L(c,l),description:`Open ${L(c,l)}`,record:l.id});else if(n.on==="selection")for(let l of x){let h=s(l);A({type:"record",id:`record:${l}`,label:L(c,h),description:`Open ${L(c,h)}`,record:l})}return{target:n,candidates:b}}var V=e=>e&&`${e[0].toUpperCase()}${e.slice(1)}`,xn={columns:["board","kanban","column","lane","pipeline","stage","funnel"],board:["board","map","floor","layout","seat","slot"],calendar:["calendar","schedule","date","due","month","week","agenda","deadline","day"],timeline:["timeline","gantt","schedule","roadmap","span"],coverage:["coverage","matrix","grid","gap"],plan:["plan","floor","map","region","area"],blocks:["list","table","summary","overview","dashboard","card"]},On=new Set(["a","an","the","of","for","my","our","me","us","to","with","and","in","on","by","that","which","i","we","want","need","show","open","go","draw","make","new","view","views","panel","panels","page","lens","please","all","every","some","see","can","could","would","like","one","what","is","are","do","does","here","there","how","it","this","these","those"]),te=e=>e.length>3&&e.endsWith("ies")?`${e.slice(0,-3)}y`:e.length>3&&e.endsWith("s")&&!e.endsWith("ss")?e.slice(0,-1):e,Te=e=>e.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").split(/[^a-z0-9]+/).filter(Boolean);function Ze(e,n,t){let i=e,o=ee(i)?.store??i,r=o.schema,f=me(o,t.principal),d=o.seenBy(t.principal),c=Q(n),a=new Set;for(let p of c){let w=d.graph.getNode(p)?.kind;w!==void 0&&f.has(w)&&a.add(w)}if(c.length>0&&a.size===0)return[];if(n.on==="list"&&a.add(n.kind),n.on==="lens"){let p=n.kind??t.places.find(w=>w.as===n.place)?.kind;p!==void 0&&a.add(p)}let s=new Map;for(let p of r.kinds){if(!f.has(p))continue;let w=r.tryDefinition(p);for(let T of[p,G(w,p),W(r,p)])for(let F of Te(T))s.set(te(F),p)}let u=Te(t.said??"").filter(p=>!On.has(p)),g=new Set,b=[];for(let p of u){let w=s.get(te(p));w!==void 0?g.add(w):b.push(te(p))}let C=g.size>0?g:a;if((t.said??"").trim()!==""&&u.length===0)return[];if(C.size===0&&u.length===0)return[];let A=[];t.places.forEach((p,w)=>{if(p.hidden||n.on==="lens"&&p.as===n.place)return;let T=p.over??(p.kind!==void 0?[p.kind]:[]);if(T.length>0&&!T.some(H=>f.has(H)))return;let F=T.some(H=>C.has(H)),q=!F&&(p.reads??[]).some(H=>C.has(H));C.size>0&&!F&&!q||A.push({place:p,own:F,reads:q,at:w})});let m=p=>new Set(Te(p.title).map(te)),x=new Set(b.filter(p=>A.some(({place:w})=>m(w).has(p)))),O=[];for(let{place:p,own:w,reads:T,at:F}of A){let q=m(p),H=new Set((xn[p.lens??""]??[]).map(te)),l=b.filter($=>q.has($)||H.has($)&&!x.has($)).length,h=b.length-l;if(b.length>0&&l===0)continue;let R=!T&&h===0?"full":"partial",E=(w?4:T?2:1)+l*2-h+(R==="full"?1:0);O.push({view:{place:p.as,title:p.title,...p.kind!==void 0?{kind:p.kind}:{},fit:R},score:E,at:F})}return O.filter((p,w)=>!O.slice(0,w).some(T=>T.view.place===p.view.place&&T.view.title===p.view.title)).sort((p,w)=>w.score-p.score||p.at-w.at).slice(0,t.most??3).map(p=>p.view)}var Ee=new WeakMap;function vn(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619)>>>0;return n.toString(36)}function $n(e,n){let t=e,i=ee(t)?.store??t,o=i.schema,r=me(i,n),d=i.allMutations().filter(A=>!A.destructive&&i.permits({name:A.name,args:{}},n).ok!==!1),c=`${[...r].join(",")}|${d.map(A=>A.name).join(",")}`,a=Ee.get(o)?.get(c);if(a)return a;let s=[...r].map(A=>{let m=ge(o,A),x={};for(let[w,T]of Object.entries(ye(o,A))){if(m.has(w))continue;let F=pe(T);F&&(x[w]=F.type==="enum"?`enum:${(F.options??[]).join("|")}`:F.type)}let O={};for(let[w,T]of Object.entries(Y(o,A)))O[w]=T.to==="*"?[...r]:T.to.filter(F=>r.has(F));let k=o.tryDefinition(A),p=Object.entries(k?.fieldAliases??{}).filter(([w,T])=>w in x&&T.length>0);return{kind:A,noun:G(o.tryDefinition(A),A),plural:W(o,A),fields:x,relations:O,...k?.aliases&&k.aliases.length>0?{aliases:k.aliases}:{},...p.length>0?{fieldAliases:Object.fromEntries(p)}:{}}}),u=d.map(A=>({name:A.name,title:A.title??B(A.name),...A.subject?{on:fe(o,A).filter(m=>r.has(m))}:{}})),g={kinds:s,acts:u},b={version:vn(JSON.stringify(g)),...g},C=Ee.get(o)??new Map;return C.set(c,b),Ee.set(o,C),b}var Cn=e=>e.name??e.id??e.kind;function en(e,n,t){let i=e,{principal:o}=t,r=ee(i)?.store??i,f=r.seenBy(o),d=r.schema,c=me(r,o),a=p=>{let w=f.graph.getNode(p);return w&&c.has(w.kind)?w:void 0},s=p=>({id:p.id,kind:p.kind,label:L(d,p)}),u=Q(n),g=u.length===1?a(u[0]):void 0,b=g?Object.fromEntries(Object.keys(ye(d,g.kind)).filter(p=>!ge(d,g.kind).has(p)&&g[p]!==void 0&&p!=="label").map(p=>[p,g[p]])):{},C={on:n.on,...g?{record:{...s(g),fields:b}}:{},...n.on==="field"&&g?{field:n.field}:{},...n.on==="list"&&c.has(n.kind)?{kind:n.kind}:{},...n.on==="lens"?{place:n.place,...n.kind&&c.has(n.kind)?{kind:n.kind}:{}}:{},...n.on==="place"?{place:n.place}:{},...n.on==="act"?{act:n.act}:{}},A=[...new Set([...n.on==="selection"?n.ids:[],...t.selection??[]])].flatMap(p=>{let w=a(p);return w?[s(w)]:[]}),m=[];if(g){for(let p of Object.keys(Y(d,g.kind)))for(let w of f.graph.out(g.id,p))a(w.id)&&m.push({...s(w),relation:p,direction:"out"});for(let p of d.kinds)for(let w of Object.keys(Y(d,p)))for(let T of f.graph.in(g.id,w))T.kind===p&&a(T.id)&&m.push({...s(T),relation:w,direction:"in"})}let x=f.batches().filter(p=>!p.ops.every(je)).slice(-(t.recent??6)).reverse().map(p=>({intent:p.intent,at:p.at,by:Cn(p.author)})),O=(t.purpose?.jobs??[]).filter(p=>Ge(p,o.roles)&&c.has(p.kind)).map(p=>({name:p.name,ask:p.ask,kind:p.kind})),k=t.purpose&&(t.purpose.for!==void 0||O.length>0)?{...t.purpose.for!==void 0?{for:t.purpose.for}:{},jobs:O}:void 0;return{...t.place!==void 0?{place:t.place}:{},target:C,selection:A,neighbors:m.slice(0,24),recent:x,schema:$n(r,o),...k?{purpose:k}:{},...t.friction?{friction:Qe(t.friction,d,{reader:o})}:{}}}function ie(e){if(!e.off)return e.fast??(e.decide?{model:e.name??"decide",decide:e.decide}:void 0)}function U(e){if(e.off)return;if(e.thinking)return e.thinking;let n=e.name??"model";if(e.complete){let t=e.complete;return{model:n,think:({system:i,prompt:o})=>t({prompt:o,system:i})}}if(e.turn){let t=e.turn;return{model:n,think:async({system:i,prompt:o})=>({text:await t({system:i,messages:[{role:"user",content:o}],tools:[],call:async()=>({error:"No tools here."})})})}}}var Pe=(e,n,t)=>e?n/1e6*(e.inputPerMillion??0)+t/1e6*(e.outputPerMillion??0):void 0,Ie=()=>`ai-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;function Rn(e,n,t=[]){let i=o=>{let r=e.graph.getNode(o);return r?ce(e.schema.tryDefinition(r.kind),r):"a record"};switch(n.on){case"record":return i(n.id);case"field":return`${i(n.id)} \xB7 ${n.field}`;case"selection":return`${n.ids.length} records`;case"list":return e.schema.tryDefinition(n.kind)?W(e.schema,n.kind):n.kind;case"lens":case"place":return t.find(o=>o.as===n.place)?.title??(n.place==="home"?"Home":n.place);case"act":return n.act}}var nn=e=>e.type!=="act"||e.asks.length===0,be=(e,n)=>({id:e.id,type:e.type,label:e.label,...n!==void 0?{confidence:n}:{}});function X(e,n){let t=n.interaction??Ie(),i=he(n.store,n.target,{principal:n.principal,...n.acts?{acts:n.acts}:{},...n.places?{places:n.places}:{}}),o=en(n.store,n.target,{principal:n.principal,...n.place?{place:n.place}:{},...n.selection?{selection:n.selection}:{},...n.purpose?{purpose:n.purpose}:{}}),r=[];return{id:t,catalog:i,state:o,entry:{id:t,at:new Date().toISOString(),by:n.by??n.principal,target:n.target,targetLabel:Rn(n.store,n.target,n.places)},usage:r,meter:f=>{r.push(f),e.meter?.({...f,interaction:t})}}}async function oe(e,n,t,i){let o=await e.decide(n,t),{inputTokens:r,outputTokens:f}=o.usage,d=Pe(e.price,r,f);return i({tier:"fast",model:e.model,inputTokens:r,outputTokens:f,...d!==void 0?{costUsd:d}:{}}),o.answers}async function re(e,n,t,i,o){let r=await e.think({system:n,prompt:t,state:i.state,catalog:i.catalog}),f=r.usage?.inputTokens,d=r.usage?.outputTokens,c=r.usage?.costUsd??(f!==void 0?Pe(e.price,f,d??0):void 0);return o({tier:"thinking",model:e.model,...f!==void 0?{inputTokens:f}:{},...d!==void 0?{outputTokens:d}:{},...c!==void 0?{costUsd:c}:{}}),Ve(r.text)}function se(e,n){let t=new Map(e.map((i,o)=>[`c${o+1}`,i]));return{question:{type:"choice",instructions:n,criteria:Object.fromEntries([...t].map(([i,o])=>[i,`${o.label} \u2014 ${o.description}`]))},of:i=>t.get(i)}}function ae(e,n,t){if(e?.type!=="choice")return[];let i=e,o=Object.entries(i.probabilities).sort((r,f)=>f[1]-r[1]);return o.some(([r])=>r===i.choice)||o.unshift([i.choice,i.confidence]),o.flatMap(([r,f])=>{let d=n(r);return d?[{candidate:d,confidence:f}]:[]}).slice(0,t)}var M=(e,n,t,i)=>({interaction:{...e.entry,ask:{kind:t,said:n??""},offered:[],outcome:"failed",failed:i,usage:[...e.usage]},offers:[]}),Z="AI isn't on here.";async function tn(e,n,t=3){let i=X(e,n),o=n.said??"Suggest",r=i.catalog.candidates.filter(nn).slice(0,24);if(r.length===0)return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:[],outcome:"offered",usage:[]},offers:[]};let f=ie(e),d=U(e),c=[];try{if(f){let{question:a,of:s}=se(r,"Which of these would the person most likely want to do next, here?"),u=await oe(f,{...i.state,candidates:r.map(g=>({id:g.id,type:g.type,says:g.description}))},{next:a},i.meter);c=ae(u.next,s,t)}else if(d){let a=await re(d,'You suggest what a person most likely wants to do next in an app. Answer only JSON: {"pick": [candidate ids, best first]}. Pick only ids from the candidates.',JSON.stringify({state:i.state,candidates:r.map(u=>({id:u.id,says:u.description}))}),i,i.meter);c=(Array.isArray(a?.pick)?a.pick.filter(u=>typeof u=="string"):[]).flatMap(u=>r.filter(g=>g.id===u)).slice(0,t).map(u=>({candidate:u}))}else return M(i,o,"suggest",Z)}catch(a){return M(i,o,"suggest",a instanceof Error?a.message:String(a))}return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:c.map(({candidate:a,confidence:s})=>be(a,s)),outcome:"offered",usage:[...i.usage]},offers:c.map(({candidate:a})=>a)}}var Tn=e=>`several:${e}`;async function it(e,n,t=2){let i=X(e,{...n,acts:[]}),o=n.said??"Suggest for the chosen",r=n.target.on==="selection"?n.target.ids.length:1,d=[...n.shared.map(s=>({type:"act",id:Tn(s.id),label:s.label,description:`${s.label}, for all ${r} chosen`,mutation:s.mutation,args:s.args,asks:[]})),...i.catalog.candidates.filter(s=>s.type==="panel"||s.type==="place")].slice(0,24),c=ie(e);if(!c)return M(i,o,"suggest",Z);if(d.length===0)return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:[],outcome:"offered",usage:[]},offers:[]};let a;try{let{question:s,of:u}=se(d,`Which of these would the person most likely want to do next with the ${r} records they chose together?`),g=await oe(c,{...i.state,candidates:d.map(b=>({id:b.id,type:b.type,says:b.description}))},{next:s},i.meter);a=ae(g.next,u,t).filter((b,C)=>C===0||b.confidence>=En)}catch(s){return M(i,o,"suggest",s instanceof Error?s.message:String(s))}return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:a.map(({candidate:s,confidence:u})=>be(s,u)),outcome:"offered",usage:[...i.usage]},offers:a.map(({candidate:s})=>s)}}var En=.25;async function on(e,n){let t=X(e,n),i=n.said??"Fill in",o=t.catalog.candidates.filter(u=>u.type==="fill"),r=new Map;for(let u of o)r.set(u.field,[...r.get(u.field)??[],u]);if(r.size===0)return{interaction:{...t.entry,ask:{kind:"fill",said:i},offered:[],outcome:"offered",usage:[]},offers:[]};let f=ie(e),d=U(e),c=[];try{if(f){let u=[...r].map(([b,C],A)=>({key:`f${A+1}`,field:b,...se(C,`Which value fits "${b}" best for this record?`)})),g=await oe(f,t.state,Object.fromEntries(u.map(b=>[b.key,b.question])),t.meter);for(let b of u){let C=!Pn(n.store,n.target,b.field)&&In(n.store,n.target,b.field)!=="one";c.push(...ae(g[b.key],b.of,C?3:1).filter((A,m)=>m===0||A.confidence>=.4))}}else if(d){let u=await re(d,`You fill in a record's fields in an app. Answer only JSON: {"fills": [candidate ids]}, at most one per field, only ids from the candidates.`,JSON.stringify({state:t.state,candidates:o.map(C=>({id:C.id,says:C.description}))}),t,t.meter),g=Array.isArray(u?.fills)?u.fills.filter(C=>typeof C=="string"):[],b=new Set;for(let C of g){let A=o.find(m=>m.id===C);A?.type==="fill"&&!b.has(A.field)&&(b.add(A.field),c.push({candidate:A}))}}else return M(t,i,"fill",Z)}catch(u){return M(t,i,"fill",u instanceof Error?u.message:String(u))}let a=t.usage.at(-1)?.model,s=de(n.store,{interaction:t.id,target:n.target,basis:i,...a?{model:a}:{},proposals:c.flatMap(({candidate:u,confidence:g})=>u.type==="fill"?[{id:u.id,label:u.label,said:u.description,call:u.call,record:u.record,field:u.field,...g!==void 0?{confidence:g}:{}}]:[])},n.principal);return{interaction:{...t.entry,ask:{kind:"fill",said:i},offered:s.proposals.map(u=>({id:u.id,type:"fill",label:u.label,...u.confidence!==void 0?{confidence:u.confidence}:{}})),outcome:"offered",usage:[...t.usage]},offers:[],...s.proposals.length>0?{ghost:s}:{}}}function Pn(e,n,t){let i=n.on==="record"||n.on==="field"?n.id:void 0,o=i?e.graph.getNode(i)?.kind:void 0,r=(o?e.schema.tryDefinition(o)?.fields?.shape:void 0)??{};return t in r}function In(e,n,t){let i=n.on==="record"||n.on==="field"?n.id:void 0,o=i?e.graph.getNode(i)?.kind:void 0;return o?e.schema.tryDefinition(o)?.edges?.[t]?.cardinality:void 0}async function rn(e,n){let t=X(e,n),i=n.said??"Add one",o=new Set(n.store.allMutations().filter(s=>(s.creates??[]).length>0).map(s=>s.name)),r=t.catalog.candidates.filter(s=>s.type==="act"&&s.asks.length>0&&o.has(s.mutation));if(r.length===0)return M(t,i,"record","Nothing here makes a record.");let f=U(e);if(!f)return M(t,i,"record",Z);let d;try{let s=await re(f,'You propose one new record for an app by filling in an act. Answer only JSON: {"act": a candidate id, "args": {argument: value}}. Use only the candidates, and fill every argument the act asks for with a value that fits the state.',JSON.stringify({ask:i,state:t.state,candidates:r.map(b=>({id:b.id,says:b.description,asks:b.asks}))}),t,t.meter),u=r.find(b=>b.id===s?.act),g=typeof s?.args=="object"&&s.args!==null?s.args:{};u&&(d={act:u,args:Object.fromEntries(Object.entries(g).filter(([b])=>u.asks.includes(b)))})}catch(s){return M(t,i,"record",s instanceof Error?s.message:String(s))}if(!d)return M(t,i,"record","The model named no act this app has here.");let c=t.usage.at(-1)?.model,a=de(n.store,{interaction:t.id,target:n.target,basis:i,...c?{model:c}:{},proposals:[{id:d.act.id,label:d.act.label,said:d.act.description,call:{name:d.act.mutation,args:{...d.act.args,...d.args}}}]},n.principal);return a.proposals.length===0?M(t,i,"record","What the model proposed could not be made here."):{interaction:{...t.entry,ask:{kind:"record",said:i},offered:a.proposals.map(s=>({id:s.id,type:"act",label:s.said})),outcome:"offered",usage:[...t.usage]},offers:[d.act],ghost:a}}async function sn(e,n){let t=X(e,n),i=n.said??"Make a panel",o=t.catalog.candidates.filter(s=>s.type==="panel");if(o.length===0)return M(t,i,"panel","Nothing here can be drawn as a panel.");let r=ie(e),f=U(e),d;try{if(f){let s=await re(f,'You choose a panel to draw in an app. Answer only JSON: {"panel": a candidate id, "title": a short title}. Choose only among the candidates.',JSON.stringify({ask:i,state:t.state,candidates:o.map(g=>({id:g.id,says:g.description}))}),t,t.meter),u=o.find(g=>g.id===s?.panel);u&&(d={panel:u,...typeof s?.title=="string"&&s.title.trim()?{title:s.title.trim().slice(0,60)}:{}})}else if(r){let{question:s,of:u}=se(o,`Which panel answers this best: ${i}`),g=ae((await oe(r,t.state,{panel:s},t.meter)).panel,u,1)[0];g?.candidate.type==="panel"&&(d={panel:g.candidate,confidence:g.confidence})}else return M(t,i,"panel",Z)}catch(s){return M(t,i,"panel",s instanceof Error?s.message:String(s))}if(!d)return M(t,i,"panel","The model named no panel this app can draw.");let c=d.title??d.panel.label,a={title:c,recipe:{...d.panel.panel,title:c}};return{interaction:{...t.entry,ask:{kind:"panel",said:i},offered:[be(d.panel,d.confidence)],outcome:"drawn",panel:a,usage:[...t.usage]},offers:[d.panel],panel:a}}function Fn(e){return e.off?void 0:e.answer}var Mn=`You answer a person's question about what they are looking at in an app, from the state given and nothing else. Answer only JSON: {"answer": one to three short sentences, "pick": [candidate ids that act on the answer, best first, at most three]}. Pick only ids from the candidates, and none when nothing fits. Never say an id to the person.`;async function ot(e,n){let t=X(e,n),i=n.said.trim(),o=t.catalog.candidates.filter(m=>nn(m)||m.type==="panel"||m.type==="place"||m.type==="record").slice(0,32),r=Fn(e),f=U(e),d=ie(e),c="",a=[],s=m=>m.flatMap(x=>o.filter(O=>O.id===x)).slice(0,3).map(x=>({candidate:x}));try{if(r){let m=await r.answer({said:i,target:n.target,targetLabel:t.entry.targetLabel,state:t.state,catalog:{target:t.catalog.target,candidates:o},...n.follows?{follows:n.follows}:{}}),x=m.usage?.inputTokens,O=m.usage?.outputTokens,k=m.usage?.costUsd??(x!==void 0?Pe(r.price,x,O??0):void 0);t.meter({tier:"thinking",model:r.model,...x!==void 0?{inputTokens:x}:{},...O!==void 0?{outputTokens:O}:{},...k!==void 0?{costUsd:k}:{}}),c=typeof m.text=="string"?m.text.trim():"",a=s(m.pick??[])}else if(f){let m=await re(f,Mn,JSON.stringify({ask:i,about:t.entry.targetLabel,...n.follows?{follows:n.follows}:{},state:t.state,candidates:o.map(x=>({id:x.id,says:x.description}))}),t,t.meter);c=typeof m?.answer=="string"?m.answer.trim():"",a=s(Array.isArray(m?.pick)?m.pick:[])}else if(d&&o.length>0){let{question:m,of:x}=se(o,`Which of these best answers, or acts on: ${i}`),O=await oe(d,{...t.state,asked:i,candidates:o.map(k=>({id:k.id,type:k.type,says:k.description}))},{answer:m},t.meter);a=ae(O.answer,x,3),c=a.length>0?`These fit \u201C${i}\u201D.`:""}else return M(t,i,"ask",Z)}catch(m){return M(t,i,"ask",m instanceof Error?m.message:String(m))}if(!c&&a.length===0){let m=n.target.on==="place"||n.target.on==="lens"?n.target.place:void 0,x=n.target.on==="list"||n.target.on==="lens"?n.target.kind:void 0;return Be(n.store,{type:"unanswered",question:i,...m?{place:m}:{},...x?{kind:x}:{}},n.principal),M(t,i,"ask","The AI had no answer to that here.")}let u=t.usage.at(-1)?.model,g=a.flatMap(({candidate:m,confidence:x})=>{let O=ke(m);return O?[{...O,...x!==void 0?{confidence:x}:{}}]:[]}),b=g.length>0?de(n.store,{interaction:t.id,target:n.target,basis:i,...u?{model:u}:{},proposals:g},n.principal):void 0,C=a.map(({candidate:m})=>m).filter(m=>ke(m)===void 0),A=[...C.map(m=>be(m,a.find(x=>x.candidate===m)?.confidence)),...(b?.proposals??[]).map(m=>({id:m.id,type:m.field!==void 0?"fill":"act",label:m.label,...m.confidence!==void 0?{confidence:m.confidence}:{}}))];return{interaction:{...t.entry,ask:{kind:"ask",said:i},offered:A,outcome:"offered",...c?{answer:c}:{},usage:[...t.usage]},offers:C,...b&&b.proposals.length>0?{ghost:b}:{},...c?{answer:c}:{}}}function de(e,n,t){let i=n.proposals.flatMap(o=>{try{let r=e.previewAll([o.call],{author:t}),f=r.ops.map(d=>d.intent).join("; ");return r.ops.length>0?[{...o,said:f||o.said}]:[]}catch{return[]}});return{...n,proposals:i}}function ke(e){if(e.type==="fill")return{id:e.id,label:e.label,said:e.description,call:e.call,record:e.record,field:e.field};if(e.type==="act"&&e.asks.length===0)return{id:e.id,label:e.label,said:e.description,call:{name:e.mutation,args:{...e.args}}}}function an(e,n,t){let i=n.proposals.filter(r=>t.ids===void 0||t.ids.includes(r.id));if(i.length===0)return{ok:!1,refused:"Nothing was chosen."};let o=i.flatMap(r=>r.confidence===void 0?[]:[r.confidence]);try{let f=e.applyAll(i.map(d=>d.call),{author:t.author,via:`ai:${n.interaction}`,intent:n.basis,lineage:{basis:`Asked \u201C${n.basis}\u201D`,...n.model?{model:n.model}:{},...o.length>0?{confidence:Math.min(...o)}:{},interaction:n.interaction}}).ops[0]?.batch;return f?{ok:!0,batch:f,accepted:i.map(d=>d.id)}:{ok:!1,refused:"That changes nothing now."}}catch(r){return{ok:!1,refused:r instanceof Error?r.message:String(r)}}}function dn(e,n,t){let i=e.ask.kind==="suggest"?n.length>0:e.offered.length>0&&e.offered.every(o=>n.includes(o.id));return{...e,outcome:i?"accepted":"partly",accepted:n,batches:[...e.batches??[],t]}}var ln=e=>({...e,outcome:"dismissed"});var P=xe(hn(),1);var S=xe(Ue(),1);function fn(e,n,t){let i=n.on==="selection"?n.ids:n.on==="record"||n.on==="field"?[n.id]:[],o=i.length>0?Ke(e.store,i,{principal:e.principal,...i.length===1?{focus:i[0]}:{}}).affordances.map(r=>({mutation:r.mutation,label:r.label,args:r.args,open:r.open,why:r.why,...r.destructive?{destructive:!0}:{}})):void 0;return{store:e.store,target:n,principal:e.principal,interaction:Ie(),places:e.places,selection:e.selection,...o?{acts:o}:{},...e.place?{place:e.place}:{},...t?{said:t}:{},...e.app.purpose?{purpose:e.app.purpose}:{}}}async function un(e,n,t){let i=await (__graviewPreload(import.meta.url,["./chunk.HGVBGSRS.js","./chunk.G4JJXA63.js","./chunk.WD4VPMEE.js","./chunk.VUAOCYG2.js","./chunk.ZVG3DR5G.js","./chunk.XOZU4OFA.js","./chunk.LA2DMHZC.js","./chunk.ISRQQVS4.js","./chunk.WVUJXDXZ.js","./chunk.MBU7UH6J.js","./chunk.2QFKNTAZ.js","./chunk.BI6DS3PZ.js","./chunk.PGA5TUSN.js","./chunk.7R727IKU.js","./chunk.LQAT7FA6.js","./chunk.UO544PZH.js","./chunk.4STDIZVI.js","./chunk.HZHNM2KI.js","./chunk.F7PIW2EM.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.ODVRO2BJ.js")),o=i.recipeDraft(n.recipe,{app:e.app,sight:i.draftSight(e.app,e.principal)});if(i.isDraftFailure(o))return o.failed;t?.(),e.seatTalk.setDraft(o,null),e.goTo.draft?.(),pn()}function pn(e=180){if(typeof document>"u")return;let n=document.querySelector('[data-testid="draft-keep"]'),t=document.activeElement,i=!t||t===document.body||t.closest?.("[inert]")!==null;if(n){i&&n.focus();return}e>0&&requestAnimationFrame(()=>pn(e-1))}async function le(e,n,t,i,o){let r=fn(e,t,i),f=n==="suggest"?await tn(e.ai,r):n==="fill"?await on(e.ai,r):n==="record"?await rn(e.ai,r):await sn(e.ai,r);if(f.interaction.outcome==="failed")return n!=="suggest"&&e.desk.record(f.interaction),f;let d=c=>{let a={...f.interaction,outcome:"failed",failed:c};return e.desk.record(a),{...f,interaction:a}};if(n==="fill"||n==="record"){if(!f.ghost||f.ghost.proposals.length===0)return d("Nothing here could be filled in.");o?.(),e.desk.setGhost({ghost:f.ghost}),e.desk.record(f.interaction)}if(n==="panel"&&f.panel){let c=await un(e,f.panel,o);if(c)return d(c);e.desk.record(f.interaction)}return f}var Fe=new WeakMap,Nn=64,cn=new WeakMap;function jn(e){let n=cn.get(e);if(!n){let t=n={n:0};cn.set(e,t),e.subscribe(()=>void(t.n+=1))}return n.n}var yn=(e,n)=>{let t=Q(n);return t.length>0?t.map(i=>e.graph.getNode(i)):[jn(e)]},gn=(e,n,t)=>JSON.stringify({target:n,seat:e.principal,by:t}),mn=(e,n,t)=>{let i=yn(e.store,n);return t.schema===e.store.schema&&t.ai===e.ai&&i.length===t.depends.length&&i.every((o,r)=>o===t.depends[r])};function Dn(e,n,t="menu"){let i=Fe.get(e.store)?.get(gn(e,n,t));return i?.result!==void 0&&mn(e,n,i)?i.result:void 0}function Ln(e,n,t){let i=Fe.get(e.store);i||Fe.set(e.store,i=new Map);let o=gn(e,n,t?.by??"menu"),r=i.get(o);if(r&&mn(e,n,r))return r.result?Promise.resolve(r.result):r.asked;let f=t?t.ask():le(e,"suggest",n),d={schema:e.store.schema,ai:e.ai,depends:yn(e.store,n),asked:f};i.delete(o),i.set(o,d),i.size>Nn&&i.delete(i.keys().next().value);let c=i;return f.then(a=>{a.interaction.outcome!=="failed"?d.result=a:c.get(o)===d&&c.delete(o)}),f}async function Hn(e,n,t,i){let o=n.interaction,r=ke(t);if(r){let f=o.usage?.at(-1)?.model,d=o.offered.find(a=>a.id===t.id)?.confidence,c=de(e.store,{interaction:o.id,target:o.target,basis:`${o.ask.said}: ${t.label}`,...f?{model:f}:{},proposals:[{...r,...d!==void 0?{confidence:d}:{}}]},e.principal);if(c.proposals.length===0){let a="That can't be done now.";return e.desk.record({...o,outcome:"failed",failed:a}),a}i?.(),e.desk.setGhost({ghost:c}),e.desk.record(o);return}if(t.type==="panel"){let f=t.label,d={title:f,recipe:{...t.panel,title:f}},c=await un(e,d,i);return e.desk.record(c?{...o,outcome:"failed",failed:c}:{...o,outcome:"drawn",accepted:[t.id],panel:d}),c}i?.(),t.type==="place"?e.goTo.place(t.place):t.type==="record"&&e.goTo.record(t.record),e.desk.record({...o,outcome:"accepted",accepted:[t.id]})}async function yt(e,n){if(n.ask.kind==="ask")return ue(e.desk,{target:n.target,asked:n.ask.said}),null;let t=n.ask.kind==="panel"||n.ask.kind==="record"?n.ask.kind:"fill";return le(e,t,n.target,n.ask.said)}var z={padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left",borderWidth:1,borderStyle:"solid",borderColor:"transparent",background:"none",boxShadow:"none"},we={margin:0,padding:"4px 10px",fontSize:"0.8125rem",color:"var(--graview-ink-muted)"};function gt({target:e,close:n}){let t=Je(),i=(0,P.useMemo)(()=>Xe(e,y=>t.store.graph.has(y)),[e,t.store]),o=(0,P.useMemo)(()=>{let y=fn(t,i);return he(t.store,i,{principal:t.principal,places:t.places,...y.acts?{acts:y.acts}:{}})},[t,i]),r=o.candidates.some(y=>y.type==="fill"),f=o.candidates.some(y=>y.type==="panel"),d=(0,P.useMemo)(()=>f?Ze(t.store,i,{principal:t.principal,places:t.places,most:1}):[],[f,t,i]),c=(0,P.useMemo)(()=>new Set(t.store.allMutations().filter(y=>(y.creates??[]).length>0).map(y=>y.name)),[t.store]),a=U(t.ai)!==void 0&&o.candidates.some(y=>y.type==="act"&&y.asks.length>0&&c.has(y.mutation)),s=Oe(t.ai),u=Dn(t,i),g=JSON.stringify(i),[b,C]=(0,P.useState)(!1),[A,m]=(0,P.useState)(null),[x,O]=(0,P.useState)(s&&u===void 0);(0,P.useEffect)(()=>{if(u!==void 0||!(s||b))return;let y=!0;return O(!0),Ln(t,i).then(v=>{y&&(m(v),O(!1))}),()=>{y=!1}},[g,b]);let k=u??A,p=(k?.offers??[]).filter(y=>!(y.type==="place"&&d.some(v=>v.place===y.place))).slice(0,Math.max(0,3-d.length)),w=k?.interaction.outcome==="failed"?k.interaction.failed??"The AI could not suggest anything here.":null,T=(0,P.useRef)(!1),F=(0,P.useRef)(null);(0,P.useLayoutEffect)(()=>{k===null||!T.current||(T.current=!1,F.current?.querySelector("button")?.focus())},[k]);let q=(0,P.useRef)(!0);(0,P.useEffect)(()=>()=>{q.current=!1},[]);let[H,l]=(0,P.useState)(!1),[h,R]=(0,P.useState)(null),E=y=>{if(H)return;l(!0),R(null);let v=!1;y(()=>{v=!0,n()}).then(j=>{q.current&&(l(!1),j?R(j):v||n())},j=>{q.current&&(l(!1),R(j instanceof Error?j.message:String(j)))})},$=y=>y.interaction.outcome==="failed"?y.interaction.failed??"The AI could not do that here.":void 0;return(0,S.jsxs)("div",{ref:F,"data-testid":"inline-ai",style:{display:"grid",gap:2},children:[x&&!b?(0,S.jsx)("p",{role:"status","data-testid":"inline-ai-thinking",style:we,children:"Thinking\u2026"}):H?(0,S.jsx)("p",{role:"status","data-testid":"inline-ai-asking",style:we,children:"Asking\u2026"}):h?(0,S.jsx)("p",{role:"alert","data-testid":"inline-ai-failed",style:{...we,color:"var(--graview-warn)"},children:h}):w?(0,S.jsx)("p",{role:"status",style:we,children:w}):null,(0,S.jsxs)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:2},children:[p.map(y=>(0,S.jsx)("li",{children:(0,S.jsxs)("button",{type:"button","data-menu-item":`ai-offer:${y.id}`,"data-ai-offer":y.id,"data-ai-offer-type":y.type,onClick:()=>E(v=>Hn(t,k,y,v)),style:z,children:[y.label,(0,S.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",y.type==="panel"?"a panel":y.type==="place"?"go there":y.type==="record"?"open it":"suggested"]})]})},y.id)),!s&&k===null?(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-suggest","aria-disabled":b||void 0,onClick:y=>{b||(T.current=document.activeElement===y.currentTarget,C(!0))},style:z,children:b?"Thinking\u2026":"Suggest\u2026"})}):null,r?(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-fill",onClick:()=>E(async y=>$(await le(t,"fill",i,"Fill in",y))),style:z,children:"Fill in with AI"})}):null,a?(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-record",onClick:()=>E(async y=>$(await le(t,"record",i,"Add one",y))),style:z,children:"Add one with AI"})}):null,d.map(y=>(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":`ai-open:${y.place}`,"data-ai-existing":y.fit,onClick:()=>{n(),t.goTo.place(y.place),y.fit==="partial"&&ue(t.desk,{target:{on:"lens",place:y.place,...y.kind?{kind:y.kind}:{}}})},style:z,children:y.fit==="full"?`Open ${y.title}`:`Open and adjust ${y.title}`})},y.place)),f?(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-panel",onClick:()=>E(async y=>$(await le(t,"panel",i,"Draw a panel",y))),style:z,children:d.length>0?"Draw a new view":"Draw a panel"})}):null,(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-ask",onClick:()=>{let y=document.activeElement;n(),ue(t.desk,{target:i,returnTo:y instanceof HTMLElement&&y!==document.body?y:null})},style:z,children:"Ask about this\u2026"})})]})]})}var Ae={display:"inline-flex",alignItems:"center",minHeight:28,padding:"2px 10px",fontSize:"0.8125rem",borderRadius:8};function mt({placement:e="picture"}){let{store:n,principal:t,aiDesk:i}=ze(),o=We(n,t),{ghost:r,entries:f}=_e(i),[d,c]=(0,P.useState)(new Set);(0,P.useEffect)(()=>c(new Set),[r?.ghost.interaction]);let a=(0,P.useRef)(null),s=(0,P.useRef)(null),u=r?.batch;if((0,P.useEffect)(()=>{u!==void 0&&s.current?.focus()},[u]),!r)return null;let{ghost:g}=r,b=f.find(k=>k.id===g.interaction),C=()=>{let k=g.target.on==="record"||g.target.on==="field"?g.target.id:void 0,p=a.current?.closest("[data-graview-face], main")?.parentElement??document,w=(k?p.querySelector(`[data-graview-view="${CSS.escape(k)}"][tabindex]`):null)??document.querySelector("[data-graview-page-title]")??a.current?.closest("main")??document.querySelector("main");w&&!w.hasAttribute("tabindex")&&w.setAttribute("tabindex","-1"),w?.focus({preventScroll:!0}),i.setGhost(null)},A=g.proposals.filter(k=>!d.has(k.id)).map(k=>k.id),m=()=>{let k=an(o,g,{author:t,ids:A});if(!k.ok){i.setGhost({...r,refused:k.refused});return}b&&i.record(dn(b,k.accepted,k.batch)),i.setGhost({ghost:g,batch:k.batch,took:k.accepted.length,...r.onCard?{onCard:!0}:{}})},x=()=>{b&&r.batch===void 0&&i.record(ln(b)),C()},O=()=>{if(r.batch!==void 0)try{o.undo(r.batch,{author:t}),C()}catch(k){i.setGhost({...r,refused:k instanceof Error?k.message:String(k)})}};return(0,S.jsxs)("section",{ref:a,"data-testid":"ai-ghost","data-interaction":g.interaction,"aria-label":"Proposed by AI",style:{...e==="card"?{position:"static"}:{position:e==="page"?"fixed":"absolute",insetInline:"max(12px, calc(50% - 220px))",bottom:"calc(var(--graview-foot-room, 0px) + 72px)",zIndex:He("toast"),boxShadow:"var(--graview-lift-high)"},display:"grid",gap:8,padding:12,borderRadius:12,border:"1px dashed var(--graview-accent)",background:"var(--graview-float)",fontSize:"0.875rem"},children:[(0,S.jsx)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:r.batch!==void 0?`Done: ${r.took===1?"one change":`${r.took} changes`}, as one.`:`Proposed by AI \xB7 ${g.basis}`}),r.batch===void 0?(0,S.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:g.proposals.map(k=>(0,S.jsx)("li",{"data-ghost-proposal":k.id,children:(0,S.jsxs)("label",{style:{display:"flex",alignItems:"baseline",gap:8,cursor:"pointer"},children:[(0,S.jsx)("input",{type:"checkbox",checked:!d.has(k.id),onChange:p=>{let w=new Set(d);p.target.checked?w.delete(k.id):w.add(k.id),c(w)}}),(0,S.jsx)("span",{style:{fontStyle:"italic",color:"var(--graview-ink)"},children:k.said}),k.confidence!==void 0?(0,S.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[Math.round(k.confidence*100),"% sure"]}):null]})},k.id))}):null,r.refused?(0,S.jsx)("p",{role:"alert",style:{margin:0,color:"var(--graview-warn)"},children:r.refused}):null,(0,S.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:r.batch===void 0?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("button",{type:"button","data-testid":"ghost-accept",disabled:A.length===0,onClick:m,style:Ae,children:A.length===g.proposals.length?"Accept":`Accept ${A.length} of ${g.proposals.length}`}),(0,S.jsx)("button",{type:"button","data-testid":"ghost-dismiss",onClick:x,style:Ae,children:"Dismiss"})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("button",{type:"button",ref:s,"data-testid":"ghost-undo",onClick:O,style:Ae,children:"Undo"}),(0,S.jsx)("button",{type:"button","data-testid":"ghost-close",onClick:C,style:Ae,children:"Close"})]})})]})}export{Xe as a,Q as b,he as c,Ze as d,ie as e,Ie as f,Rn as g,Tn as h,it as i,ot as j,fn as k,un as l,le as m,Dn as n,Ln as o,Hn as p,yt as q,gt as r,mt as s};