graview 0.1.47 → 0.1.48

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 (177) hide show
  1. package/dist/preview/{chunk.SWWAEOZ7.js → chunk.2GLJH253.js} +1 -1
  2. package/dist/preview/{chunk.ETPKXUAN.js → chunk.2QNGGF55.js} +1 -1
  3. package/dist/preview/{chunk.O4WEJ47H.js → chunk.2UIUMG23.js} +3 -3
  4. package/dist/preview/{chunk.IXOQQBJE.js → chunk.2VTMTW7K.js} +1 -1
  5. package/dist/preview/chunk.37CJSWLL.js +1 -0
  6. package/dist/preview/{chunk.RG6WNOBW.js → chunk.3BAHAK6W.js} +1 -1
  7. package/dist/preview/{chunk.T42S2WMB.js → chunk.3RP3N2JP.js} +1 -1
  8. package/dist/preview/{chunk.C3NHNYA6.js → chunk.3UD7GG5B.js} +1 -1
  9. package/dist/preview/{chunk.L4YNDNX7.js → chunk.44G5A53D.js} +1 -1
  10. package/dist/preview/chunk.4GQA3AJU.js +1 -0
  11. package/dist/preview/{chunk.QGG6ZRJ5.js → chunk.4KX53HCV.js} +2 -2
  12. package/dist/preview/chunk.4TJOS4C7.js +5 -0
  13. package/dist/preview/{chunk.FWSCBHZ5.js → chunk.4VW6THJF.js} +1 -1
  14. package/dist/preview/{chunk.MCB26YCQ.js → chunk.5IM645XQ.js} +1 -1
  15. package/dist/preview/{chunk.RBJAPOZ3.js → chunk.5IPH2SCE.js} +1 -1
  16. package/dist/preview/{chunk.TBQOSI4J.js → chunk.5Y3Q7ONN.js} +1 -1
  17. package/dist/preview/chunk.664PBQAQ.js +1 -0
  18. package/dist/preview/{chunk.2MCZ4CU5.js → chunk.6TKILWRM.js} +1 -1
  19. package/dist/preview/{chunk.DQS7D2W2.js → chunk.6VAFNCR4.js} +1 -1
  20. package/dist/preview/chunk.72OZLWJL.js +1 -0
  21. package/dist/preview/chunk.72W6S746.js +1 -0
  22. package/dist/preview/{chunk.OONCUAOH.js → chunk.76W2FXEC.js} +1 -1
  23. package/dist/preview/{chunk.64WM4IBI.js → chunk.7FRPNQU4.js} +1 -1
  24. package/dist/preview/chunk.7LL7OSBY.js +6 -0
  25. package/dist/preview/chunk.7QZYFLBS.js +1 -0
  26. package/dist/preview/{chunk.6RY6OSE6.js → chunk.7VT3TRHR.js} +1 -1
  27. package/dist/preview/{chunk.W6COSBO2.js → chunk.B2IIEVBF.js} +2 -2
  28. package/dist/preview/{chunk.IQ2HKGJS.js → chunk.BDHKWVNX.js} +1 -1
  29. package/dist/preview/{chunk.57ZSMK3R.js → chunk.CH5ROV7N.js} +1 -1
  30. package/dist/preview/{chunk.RZF3QM4E.js → chunk.CJ23XTSW.js} +1 -1
  31. package/dist/preview/{chunk.VAFSSSSI.js → chunk.D5ETRTAF.js} +1 -1
  32. package/dist/preview/{chunk.47RTA6M3.js → chunk.DAUC2DFY.js} +1 -1
  33. package/dist/preview/{chunk.63JLXGYX.js → chunk.DFK2NA6L.js} +1 -1
  34. package/dist/preview/{chunk.7N2GXZYI.js → chunk.DHAK6PPX.js} +2 -2
  35. package/dist/preview/{chunk.NFIGGSMJ.js → chunk.DOBQ4LO4.js} +1 -1
  36. package/dist/preview/{chunk.H7KCWCB4.js → chunk.DPHTUTOS.js} +1 -1
  37. package/dist/preview/chunk.DQ7M3LFV.js +1 -0
  38. package/dist/preview/{chunk.63MS2LOP.js → chunk.DUWYF7BO.js} +1 -1
  39. package/dist/preview/{chunk.TCXKPILZ.js → chunk.DWPU56S5.js} +1 -1
  40. package/dist/preview/{chunk.WBHM5I3I.js → chunk.E5GM2SMO.js} +1 -1
  41. package/dist/preview/{chunk.N7JT6MG2.js → chunk.EMQ5POGB.js} +1 -1
  42. package/dist/preview/{chunk.SD6N4DGF.js → chunk.ENPCLMP2.js} +1 -1
  43. package/dist/preview/chunk.EXEZBZGW.js +1 -0
  44. package/dist/preview/{chunk.CMOXKRWT.js → chunk.EZJNUFNQ.js} +1 -1
  45. package/dist/preview/{chunk.C44MC5X3.js → chunk.FOP5RBGF.js} +1 -1
  46. package/dist/preview/chunk.FPYL6REZ.js +1 -0
  47. package/dist/preview/chunk.FQYOTK34.js +1 -0
  48. package/dist/preview/chunk.G7WDMUDV.js +1 -0
  49. package/dist/preview/{chunk.VSNHCGKC.js → chunk.GACKGEUY.js} +1 -1
  50. package/dist/preview/chunk.GH2SWMCW.js +1 -0
  51. package/dist/preview/chunk.GNBN3BK7.js +1 -0
  52. package/dist/preview/{chunk.KSM6NVAT.js → chunk.GT3F6FQ6.js} +1 -1
  53. package/dist/preview/chunk.GTPC6JOW.js +2 -0
  54. package/dist/preview/{chunk.IROYMLER.js → chunk.GUMJEVVP.js} +1 -1
  55. package/dist/preview/{chunk.3LDYUO77.js → chunk.GVNYPFIM.js} +1 -1
  56. package/dist/preview/{chunk.EYI3Y2DY.js → chunk.HC5N3CT2.js} +1 -1
  57. package/dist/preview/{chunk.6TIEX67B.js → chunk.HDE2MGGU.js} +1 -1
  58. package/dist/preview/{chunk.6YD2DLIC.js → chunk.HG4DDNPG.js} +1 -1
  59. package/dist/preview/{chunk.MBETS27C.js → chunk.HKA5T7DL.js} +1 -1
  60. package/dist/preview/{chunk.7ELB37JU.js → chunk.I5TOMBIF.js} +1 -1
  61. package/dist/preview/{chunk.76GF5US2.js → chunk.I7QIHN66.js} +1 -1
  62. package/dist/preview/chunk.ILZYRJDS.js +1 -0
  63. package/dist/preview/{chunk.QZEZHCOI.js → chunk.IRHSTUZM.js} +1 -1
  64. package/dist/preview/{chunk.PYE3WZM7.js → chunk.J2V76Z6G.js} +1 -1
  65. package/dist/preview/{chunk.WHEUTAXA.js → chunk.J6ANRF6E.js} +1 -1
  66. package/dist/preview/{chunk.Y4ZUJUUT.js → chunk.KA44WNB4.js} +1 -1
  67. package/dist/preview/chunk.KTFUVR4V.js +2 -0
  68. package/dist/preview/{chunk.BNPQUI3F.js → chunk.KVEDIBXS.js} +1 -1
  69. package/dist/preview/chunk.KVJFY7N5.js +2 -0
  70. package/dist/preview/{chunk.F67F6QZ6.js → chunk.KW65F4WA.js} +1 -1
  71. package/dist/preview/chunk.LGSFGNWE.js +1 -0
  72. package/dist/preview/{chunk.VXVWUIGO.js → chunk.LNON6P7K.js} +1 -1
  73. package/dist/preview/{chunk.2W22AWSL.js → chunk.LPD74WBI.js} +1 -1
  74. package/dist/preview/{chunk.SZR3Z43B.js → chunk.LXCJVZF3.js} +1 -1
  75. package/dist/preview/{chunk.Q7RQC3F7.js → chunk.MAFFUPCR.js} +1 -1
  76. package/dist/preview/chunk.MTXEURFE.js +1 -0
  77. package/dist/preview/{chunk.DNROW6LX.js → chunk.MVRG75ZD.js} +1 -1
  78. package/dist/preview/{chunk.5TM5VA2H.js → chunk.MVSV7T6E.js} +1 -1
  79. package/dist/preview/{chunk.4YXJPKXD.js → chunk.MZLWLIKR.js} +1 -1
  80. package/dist/preview/chunk.N4M54YK6.js +1 -0
  81. package/dist/preview/{chunk.KSXB4LDF.js → chunk.NB6WN4DO.js} +1 -1
  82. package/dist/preview/{chunk.UHX4WTM7.js → chunk.NFDLCUCC.js} +1 -1
  83. package/dist/preview/{chunk.AGIO2GRV.js → chunk.NLBIX7LH.js} +1 -1
  84. package/dist/preview/{chunk.FOQ27RAR.js → chunk.NQZ73QV7.js} +1 -1
  85. package/dist/preview/chunk.NR5ODXMO.js +1 -0
  86. package/dist/preview/{chunk.VC3UGFHY.js → chunk.NTLHEHOM.js} +1 -1
  87. package/dist/preview/{chunk.TJEV5ZAM.js → chunk.NWT5FPEK.js} +2 -2
  88. package/dist/preview/chunk.NX7IIZLO.js +1 -0
  89. package/dist/preview/{chunk.UKAPFIPJ.js → chunk.O45VO36H.js} +1 -1
  90. package/dist/preview/{chunk.OCTOGZVJ.js → chunk.OAIWGWGU.js} +2 -2
  91. package/dist/preview/{chunk.PC6PID5X.js → chunk.ODRL5OWR.js} +1 -1
  92. package/dist/preview/{chunk.24OZGU7J.js → chunk.OFRGDJYX.js} +1 -1
  93. package/dist/preview/chunk.OVO6L5IP.js +88 -0
  94. package/dist/preview/{chunk.RUPRZDN3.js → chunk.OZGETOTK.js} +1 -1
  95. package/dist/preview/{chunk.ZCYGUP3I.js → chunk.P6FQAILU.js} +1 -1
  96. package/dist/preview/{chunk.5M4TMZXC.js → chunk.PCEYZQAW.js} +1 -1
  97. package/dist/preview/{chunk.IPAZOKMQ.js → chunk.PMJUGHW4.js} +1 -1
  98. package/dist/preview/{chunk.RNEJYIQ7.js → chunk.PPRSGM64.js} +1 -1
  99. package/dist/preview/chunk.PQVUQVRL.js +1 -0
  100. package/dist/preview/{chunk.NEEOVRB7.js → chunk.PTXLOFQW.js} +1 -1
  101. package/dist/preview/{chunk.P4KCZRIG.js → chunk.PVEPU6EA.js} +1 -1
  102. package/dist/preview/chunk.QGE6YKSU.js +1 -0
  103. package/dist/preview/{chunk.Z6TMIAAB.js → chunk.QII2C5OV.js} +1 -1
  104. package/dist/preview/{chunk.FOJDVK2Q.js → chunk.QO7MDWID.js} +1 -1
  105. package/dist/preview/{chunk.RVJXO5GG.js → chunk.QPICKSSM.js} +1 -1
  106. package/dist/preview/{chunk.KRGM25HF.js → chunk.QQCDCRR2.js} +1 -1
  107. package/dist/preview/{chunk.F2VMMCVK.js → chunk.QQTRAY5W.js} +1 -1
  108. package/dist/preview/{chunk.ZWVN75EY.js → chunk.RLXKDXPB.js} +1 -1
  109. package/dist/preview/{chunk.5AGW4NRZ.js → chunk.RQBEQYB2.js} +1 -1
  110. package/dist/preview/chunk.SA34Y3X5.js +2 -0
  111. package/dist/preview/chunk.SAHNXAV3.js +1 -0
  112. package/dist/preview/{chunk.52VGZBO3.js → chunk.SFAAM4KE.js} +1 -1
  113. package/dist/preview/{chunk.4YS7547F.js → chunk.SKJJBLXF.js} +1 -1
  114. package/dist/preview/chunk.SUPWMV2F.js +1 -0
  115. package/dist/preview/{chunk.WJS6P7GI.js → chunk.TBRJOKIK.js} +1 -1
  116. package/dist/preview/{chunk.S5IQFZ5Z.js → chunk.TKMQROXF.js} +1 -1
  117. package/dist/preview/chunk.TMDI7KRS.js +18 -0
  118. package/dist/preview/chunk.TPG6IY4M.js +1 -0
  119. package/dist/preview/{chunk.PKUDIWIF.js → chunk.UGJSMNVO.js} +1 -1
  120. package/dist/preview/{chunk.EUPSAYEI.js → chunk.UJRBOUGC.js} +1 -1
  121. package/dist/preview/{chunk.IJNOT4S4.js → chunk.V2GSBYDK.js} +2 -2
  122. package/dist/preview/chunk.V3N34DSU.js +1 -0
  123. package/dist/preview/{chunk.ZQY6ODXC.js → chunk.V4BCB7N2.js} +1 -1
  124. package/dist/preview/{chunk.CTQULC5F.js → chunk.VQAQQW4Q.js} +1 -1
  125. package/dist/preview/{chunk.A7RKTSOH.js → chunk.W72TTRLX.js} +2 -2
  126. package/dist/preview/{chunk.IKX4VDTW.js → chunk.X7JMJSLU.js} +1 -1
  127. package/dist/preview/{chunk.GCKZ2YRJ.js → chunk.X7N3JUO4.js} +2 -2
  128. package/dist/preview/chunk.XOZU4OFA.js +1 -0
  129. package/dist/preview/{chunk.O2WWYZI7.js → chunk.XTMOFRHL.js} +1 -1
  130. package/dist/preview/{chunk.V7XHNRQM.js → chunk.Y4MQGEUS.js} +2 -2
  131. package/dist/preview/{chunk.MF73YBJL.js → chunk.YDL5BSTG.js} +1 -1
  132. package/dist/preview/chunk.YEVA72L2.js +1 -0
  133. package/dist/preview/chunk.YLWON7X3.js +1 -0
  134. package/dist/preview/chunk.YUH43J2K.js +1 -0
  135. package/dist/preview/{chunk.UV3YU64Z.js → chunk.YVOABA2U.js} +1 -1
  136. package/dist/preview/{chunk.R6V37SR7.js → chunk.ZH4NWRWB.js} +1 -1
  137. package/dist/preview/chunk.ZXZNAG35.js +1 -0
  138. package/dist/preview/index.html +50 -49
  139. package/dist/preview/page.js +2 -2
  140. package/package.json +6 -6
  141. package/dist/preview/chunk.2CLANQHZ.js +0 -1
  142. package/dist/preview/chunk.2L3VFGHX.js +0 -1
  143. package/dist/preview/chunk.4OGOTHRD.js +0 -1
  144. package/dist/preview/chunk.5G53VDOC.js +0 -1
  145. package/dist/preview/chunk.6QVXXQCW.js +0 -2
  146. package/dist/preview/chunk.7NNI7YH4.js +0 -1
  147. package/dist/preview/chunk.A3RNSSUQ.js +0 -1
  148. package/dist/preview/chunk.AS4CQBOQ.js +0 -5
  149. package/dist/preview/chunk.AWXDZUKH.js +0 -1
  150. package/dist/preview/chunk.AYA7SYIU.js +0 -1
  151. package/dist/preview/chunk.BBS5C2BY.js +0 -1
  152. package/dist/preview/chunk.COYLGLTI.js +0 -1
  153. package/dist/preview/chunk.DX357TZ3.js +0 -2
  154. package/dist/preview/chunk.GQHAAKJG.js +0 -1
  155. package/dist/preview/chunk.HDRD33II.js +0 -1
  156. package/dist/preview/chunk.I6JLOEJU.js +0 -1
  157. package/dist/preview/chunk.ISNEX772.js +0 -1
  158. package/dist/preview/chunk.IW7YFPGG.js +0 -1
  159. package/dist/preview/chunk.IYIN6VSN.js +0 -1
  160. package/dist/preview/chunk.JUWWRRHA.js +0 -1
  161. package/dist/preview/chunk.K2NCGPCL.js +0 -1
  162. package/dist/preview/chunk.KWQ7QOHD.js +0 -2
  163. package/dist/preview/chunk.MCCUVGTE.js +0 -1
  164. package/dist/preview/chunk.NDWW5EER.js +0 -1
  165. package/dist/preview/chunk.OJGUIWDD.js +0 -88
  166. package/dist/preview/chunk.PBKO5CKD.js +0 -1
  167. package/dist/preview/chunk.QGVLJTZS.js +0 -1
  168. package/dist/preview/chunk.RX2M4C5W.js +0 -2
  169. package/dist/preview/chunk.SGKK4UKP.js +0 -1
  170. package/dist/preview/chunk.T7RJCEJB.js +0 -18
  171. package/dist/preview/chunk.VW2VCPJX.js +0 -1
  172. package/dist/preview/chunk.WAB7UDHU.js +0 -1
  173. package/dist/preview/chunk.XYEFZ2OO.js +0 -1
  174. package/dist/preview/chunk.YHH4TWZ2.js +0 -1
  175. package/dist/preview/chunk.YVONXFKE.js +0 -6
  176. package/dist/preview/chunk.ZIEHF67C.js +0 -1
  177. package/dist/preview/chunk.ZL7ZBJUU.js +0 -1
@@ -0,0 +1 @@
1
+ var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{c as $e,d as Pe,e as De}from"./chunk.7FRPNQU4.js";import{q as Ee}from"./chunk.NR5ODXMO.js";import{a as Je}from"./chunk.O45VO36H.js";import{d as Y}from"./chunk.SUPWMV2F.js";import{a as I}from"./chunk.MAFFUPCR.js";import{f as Me,g as Z,i as Ne}from"./chunk.KVJFY7N5.js";import{a as be}from"./chunk.DPHTUTOS.js";import{Ab as Ae,Ba as G,Da as me,Db as Oe,Fa as he,Ga as K,Gb as Re,Jb as B,K as fe,Mc as Te,Na as ye,Nc as _e,Oa as ge,Oc as xe,Ra as we,Xa as W,_a as ke,a as ue,ea as U,wb as Se,ya as pe,zb as ve}from"./chunk.4TJOS4C7.js";var E=(n,t,e)=>{(n[t]===void 0||e>n[t])&&(n[t]=e)},z=(n,t,e)=>{(n[t]===void 0||e<n[t])&&(n[t]=e)},X=(n,t)=>{n.format=t,t.includes("int")&&(n.isInt=!0)},ze=(n,t)=>{n.mime=n.mime?n.mime.filter(e=>t.includes(e)):[...t]},Ie=(n,t)=>{n.multipleOf??=[],n.multipleOf.includes(t)||n.multipleOf.push(t)},je=(n,t)=>(n.patterns??=new Set).add(t),nt={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function j(n){let t={},{def:e,bag:r}=n._zod,i=n._zod.traits.has("$ZodCheck")?[n,...e.checks??[]]:e.checks??[];for(let o of i){let a=o._zod.def;switch(a.check){case"greater_than":E(t,a.inclusive?"minimum":"exclusiveMinimum",a.value);break;case"less_than":z(t,a.inclusive?"maximum":"exclusiveMaximum",a.value);break;case"multiple_of":Ie(t,a.value);break;case"number_format":{X(t,a.format);let d=nt[a.format];d&&(E(t,"minimum",d[0]),z(t,"maximum",d[1]));break}case"bigint_format":X(t,a.format);break;case"min_length":case"min_size":E(t,"minimum",a.minimum);break;case"max_length":case"max_size":z(t,"maximum",a.maximum);break;case"length_equals":E(t,"minimum",a.length),z(t,"maximum",a.length);break;case"size_equals":E(t,"minimum",a.size),z(t,"maximum",a.size);break;case"string_format":X(t,a.format),a.pattern&&je(t,a.pattern),(a.format==="base64"||a.format==="base64url")&&(t.contentEncoding=a.format),(a.local||a.precision===-1)&&(t.laxFormat=!0);break;case"mime_type":ze(t,a.mime);break}}r.minimum!==void 0&&E(t,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&E(t,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&z(t,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&z(t,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&Ie(t,r.multipleOf),r.format!==void 0&&(t.format??=r.format,r.format.includes("int")&&(t.isInt=!0)),r.mime&&ze(t,r.mime);for(let o of r.patterns??[])je(t,o);return t}var it={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""};function L(n){let t=n._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?L(t.out):t.type==="catch"?L(t.innerType):n._zod.optin}var rt=new Set(["promise","optional","nonoptional","nullable","readonly","default","prefault","catch"]);function _(n,t=new Set){if(t.has(n))return!1;t.add(n);let e=n._zod.def,r=e.type;return r==="transform"?!0:r==="array"?_(e.element,t):r==="set"?_(e.valueType,t):r==="lazy"?_(e.getter(),t):rt.has(r)?_(e.innerType,t):r==="intersection"?_(e.left,t)||_(e.right,t):r==="record"||r==="map"?_(e.keyType,t)||_(e.valueType,t):r==="pipe"?n._zod.traits.has("$ZodCodec")||_(e.in,t)||_(e.out,t):r==="object"?Object.values(e.shape).some(i=>_(i,t)):r==="union"?e.options.some(i=>_(i,t)):r==="tuple"?e.items.some(i=>_(i,t))||(e.rest?_(e.rest,t):!1):!1}function ot(n){let t=Object.values(n).filter(e=>typeof e=="number");return Object.entries(n).filter(([e])=>t.indexOf(+e)===-1).map(([,e])=>e)}function Fe(n){let t=n.anyOf;if(!Array.isArray(t)||t.length===0||n.type!==void 0)return;let e=[];for(let r of t){if(!r||typeof r!="object")return;Fe(r);let i=Object.keys(r);if(i.length!==1||i[0]!=="type")return;for(let o of[r.type].flat()){if(typeof o!="string")return;e.includes(o)||e.push(o)}}delete n.anyOf,n.type=e.length===1?e[0]:e}var qe=new Set(["type","properties","required","additionalProperties"]),He=n=>{let t=n.additionalProperties;return t&&typeof t=="object"&&Object.keys(t).length?t:null},Le=(n,t)=>JSON.stringify(n)===JSON.stringify(t);function Q(n){for(let i of n){if(typeof i!="object"||i.type!=="object")return null;for(let o in i)if(!qe.has(o))return null}let t={},e=new Set;for(let i of n){for(let o in i.properties){if(Object.prototype.hasOwnProperty.call(t,o))continue;let a=[];for(let d of n){let s=d.properties?.[o]??He(d);s&&!a.some(g=>Le(g,s))&&a.push(s)}t[o]=a.length===1?a[0]:Q(a)??{allOf:a}}for(let o of i.required??[])e.add(o)}let r={type:"object",properties:t};if(e.size&&(r.required=[...e]),n.every(i=>i.additionalProperties===!1))r.additionalProperties=!1;else{let i=[];for(let o of n){let a=He(o);a&&!i.some(d=>Le(d,a))&&i.push(a)}i.length===1?r.additionalProperties=i[0]:i.length>1&&(r.additionalProperties={allOf:i})}return r}function at(n){let t=n.allOf;if(!Array.isArray(t)||t.length<2)return;for(let i of qe)if(i in n)return;let e=t.filter(i=>Array.isArray(i.oneOf)||Array.isArray(i.anyOf)),r;if(!e.length)r=Q(t);else{let i=e[0],o=Array.isArray(i.oneOf)?"oneOf":"anyOf";if(Object.keys(i).length!==1)return;let a=t.filter(s=>s!==i),d=i[o].map(s=>Q([...a,s]));if(d.some(s=>!s))return;r={[o]:d}}r&&(delete n.allOf,Object.assign(n,r))}function We(n){let t=n;for(let b of["anyOf","oneOf"]){let T=t[b];if(!Array.isArray(T))continue;let O=T.map(We);O.some((v,p)=>v!==T[p])&&(t={...t,[b]:O})}let e=[t.type].flat(),r=!e.includes("string")&&e.some(b=>b==="number"||b==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!i?.some(b=>typeof b=="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:d,exclusiveMaximum:s,multipleOf:g,format:c,id:w,...h}=t;return h.enum?h.enum=h.enum.map(b=>typeof b=="number"?String(b):b):typeof h.const=="number"&&(h.const=String(h.const)),r&&(h.type="string",i||(h.pattern=e.includes("number")?"^-?\\d+(?:\\.\\d+)?$":"^-?\\d+$")),h}var C=class{constructor(t,e){this.override=t;this.refs=e}done=new Map;path=[];cyclic=new Map;write(t,e=!1){let r=this.refs.get(t);if(r!==void 0&&!e)return{$ref:r};if(this.path.includes(t))return this.cyclic.has(t)||this.cyclic.set(t,""),{};let i=this.done.get(t);if(i)return i;this.path.push(t);try{let o=this.written(t);return this.done.set(t,o),o}finally{this.path.pop()}}written(t){let e={},r,i=t._zod.toJSONSchema?.();i?Object.assign(e,i):r=this.process(t,e);let o=ue.get(t);if(o)for(let d of Object.keys(o))e[d]=o[d];_(t)&&(delete e.examples,delete e.default),"_prefault"in e&&(e.default??=e._prefault,delete e._prefault);let a=e;if(r){let d=this.write(r);a={...e};for(let s of Object.keys(d))s in e||(a[s]=d[s])}return this.override({zodSchema:t,jsonSchema:a}),Fe(a),t._zod.def.type==="intersection"&&at(a),a}process(t,e){let r=t._zod.def;switch(r.type){case"string":{e.type="string";let{minimum:i,maximum:o,format:a,patterns:d,contentEncoding:s,laxFormat:g}=j(t);if(typeof i=="number"&&(e.minLength=i),typeof o=="number"&&(e.maxLength=o),a&&(e.format=it[a]??a,(e.format===""||a==="time"||g)&&delete e.format),s&&(e.contentEncoding=s),d&&d.size>0){let c=[...d];c.length===1?e.pattern=c[0].source:e.allOf=c.map(w=>({pattern:w.source}))}return}case"number":{let{minimum:i,maximum:o,multipleOf:a,exclusiveMinimum:d,exclusiveMaximum:s,isInt:g}=j(t);if(e.type=g?"integer":"number",typeof d=="number"&&d>=(i??Number.NEGATIVE_INFINITY)?e.exclusiveMinimum=d:typeof i=="number"&&(e.minimum=i),typeof s=="number"&&s<=(o??Number.POSITIVE_INFINITY)?e.exclusiveMaximum=s:typeof o=="number"&&(e.maximum=o),a){let[c,...w]=new Set(a.filter(h=>Number.isFinite(h)&&h!==0).map(Math.abs));c!==void 0&&(e.multipleOf=c),w.length&&(e.allOf=[...e.allOf??[],...w.map(h=>({multipleOf:h}))])}return}case"boolean":case"success":e.type="boolean";return;case"null":e.type="null";return;case"never":e.not={};return;case"enum":{let i=ot(r.entries);i.length===0?e.not={}:(i.every(o=>typeof o=="number")&&(e.type="number"),i.every(o=>typeof o=="string")&&(e.type="string"),e.enum=i);return}case"literal":{let i=r.values.filter(o=>o!==void 0).map(o=>typeof o=="bigint"?Number(o):o);if(r.values.length===0)e.not={};else if(i.length===1)e.type=i[0]===null?"null":typeof i[0],e.const=i[0];else if(i.length>1){for(let o of["number","string","boolean"])i.every(a=>typeof a===o)&&(e.type=o);i.every(o=>o===null)&&(e.type="null"),e.enum=i}return}case"template_literal":e.type="string",e.pattern=t._zod.pattern.source;return;case"file":{e.type="string",e.format="binary",e.contentEncoding="binary";let{minimum:i,maximum:o,mime:a}=j(t);i!==void 0&&(e.minLength=i),o!==void 0&&(e.maxLength=o),a&&(a.length===0?e.not={}:a.length===1?e.contentMediaType=a[0]:e.anyOf=a.map(d=>({contentMediaType:d})));return}case"array":{let{minimum:i,maximum:o}=j(t);typeof i=="number"&&(e.minItems=i),typeof o=="number"&&(e.maxItems=o),e.type="array",e.items=this.write(r.element);return}case"object":{let i=r.shape;e.type="object";let o={};e.properties=o;for(let d in i)Object.defineProperty(o,d,{value:this.write(i[d]),writable:!0,enumerable:!0,configurable:!0});let a=Object.keys(i).filter(d=>L(i[d])===void 0);a.length>0&&(e.required=a),r.catchall?._zod.def.type==="never"?e.additionalProperties=!1:r.catchall&&(e.additionalProperties=this.write(r.catchall));return}case"union":e[r.inclusive===!1?"oneOf":"anyOf"]=r.options.map(i=>this.write(i));return;case"intersection":{let i=d=>"allOf"in d&&Object.keys(d).length===1,o=this.write(r.left),a=this.write(r.right);e.allOf=[...i(o)?o.allOf:[o],...i(a)?a.allOf:[a]];return}case"tuple":{let i=r.items;e.type="array",e.prefixItems=i.map(s=>this.write(s)),r.rest?e.items=this.write(r.rest):e.items=!1;let o=i.length;for(;o>0&&L(i[o-1])!==void 0;)o-=1;o>0&&(e.minItems=o),r.rest||(e.maxItems=i.length);let{minimum:a,maximum:d}=j(t);typeof a=="number"&&(e.minItems=a),typeof d=="number"&&(e.maxItems=d);return}case"record":{let i=r.keyType;e.type="object";let o=j(i).patterns;if(r.mode==="loose"&&o&&o.size>0){let d=this.write(r.valueType),s={};for(let g of o)s[g.source]=d;e.patternProperties=s}else e.propertyNames=We(this.write(i)),e.additionalProperties=this.write(r.valueType);let a=i._zod.values;if(a&&!r.partial&&L(r.valueType)===void 0){let d=[...a].filter(s=>typeof s=="string"||typeof s=="number");d.length>0&&(e.required=d.map(String))}return}case"nullable":e.anyOf=[this.write(r.innerType),{type:"null"}];return;case"default":case"prefault":{let i=r.defaultValue,o,a=!1,d=JSON.stringify(i,(s,g)=>typeof g=="bigint"?(a=!0,null):g);return!a&&d!==void 0&&(o=JSON.parse(d)),a||(e[r.type==="default"?"default":"_prefault"]=o),r.innerType}case"catch":{try{e.default=r.catchValue(void 0)}catch{}return r.innerType}case"readonly":return e.readOnly=!0,r.innerType;case"pipe":return r.in._zod.traits.has("$ZodTransform")?r.out:r.in;case"lazy":return t._zod.innerType;case"optional":case"nonoptional":case"promise":return r.innerType;default:return}}};function Be(n,t=()=>{}){let e=n,r=new C(t,new Map),i=r.write(e,!0);if(r.cyclic.size>0){let o=new Map,a=0,d=[];for(let g of r.cyclic.keys())if(g===e)o.set(g,"#");else{let c=`__schema${a++}`;o.set(g,`#/$defs/${c}`),d.push([g,c])}r=new C(t,o),i=r.write(e,!0);let s={};for(let[g,c]of d)s[c]=r.write(g,!0);d.length>0&&(i={...i,$defs:s})}return JSON.parse(JSON.stringify({$schema:"https://json-schema.org/draft/2020-12/schema",...i}))}function Ce(n){return Be(n,ct)}var st={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string"},dt={phone:"A phone number as it is written, like +1 555 123 4567 or 020 7946 0958 ext. 12.",place:"An address or a place's name, as a person would search a map for it.",duration:"A length of time in whole minutes: 90 is 1 h 30 min."};function ct(n){pe(n.zodSchema)&&(n.jsonSchema["x-graview-app-link"]=!0);let t=he(n.zodSchema);if(t&&(n.jsonSchema.type==="string"||n.jsonSchema.type==="array")){n.jsonSchema["x-graview-linked"]={address:t.address,kinds:[...t.kinds],cardinality:t.cardinality};let s=t.kinds.join(" or "),g=`${t.cardinality==="many"?"Records":"A record"}: a ${s} in the app ${t.address}, as "${t.kinds[0]}:<id>" \u2014 an id found there with find_linked. Linking never changes that app.`,c=n.jsonSchema.description;typeof c=="string"&&c.includes(g)||(n.jsonSchema.description=`${typeof c=="string"&&c?`${c.replace(/\.?$/,".")} `:""}${g}`)}if(we(n.zodSchema)&&(n.jsonSchema["x-graview-repeat"]=!0,!n.jsonSchema.type&&!n.jsonSchema.anyOf&&!n.jsonSchema.oneOf&&Object.assign(n.jsonSchema,lt())),be(n.zodSchema)){n.jsonSchema.contentMediaType="text/markdown";let s=n.jsonSchema.description;typeof s=="string"&&s.endsWith("Written in Markdown.")||(n.jsonSchema.description=`${typeof s=="string"&&s?`${s.replace(/\.?$/,".")} `:""}Written in Markdown.`)}let e=Re(n.zodSchema);if(e){let s=n.jsonSchema;s["x-graview-type"]=e,e==="duration"&&(s["x-graview-unit"]="minutes"),s.description??=dt[e]}let r=Oe(n.zodSchema,!1);if(r){let s=Me(r);n.jsonSchema["x-graview-format"]=s.format??"unit",s.currency&&(n.jsonSchema["x-graview-currency"]=s.currency),s.unit&&s.format!=="money"&&(n.jsonSchema["x-graview-unit"]=s.unit);let g=n.jsonSchema.description;n.jsonSchema.description=typeof g=="string"&&g.length>0?`${g} ${Z(s)}`:Z(s)}let i=n.zodSchema._zod?.def;if(!i||i.type!=="string"||typeof i.format!="string"||i.format==="regex")return;let o=n.jsonSchema,a=(i.checks??[]).map(s=>s._zod?.def).filter(s=>s?.format==="regex"&&s.pattern instanceof RegExp).map(s=>s.pattern.source);delete o.pattern;let d=o.allOf;Array.isArray(d)&&d.every(s=>typeof s=="object"&&s!==null&&Object.keys(s).length===1&&"pattern"in s)&&delete o.allOf,o.format=st[i.format]??i.format,a.length===1?o.pattern=a[0]:a.length>1&&(o.allOf=a.map(s=>({pattern:s})))}function ee(n){let t=B(n.input),e=Ce(n.input),r=e.properties??{};if(ve(n)){let i=n.creates.join(" | ");r.id={type:"string",minLength:1,description:`Optional: the id for the ${i} this makes. Refused if the graph already has it; left out, one is minted from the label.`},e.properties=r}Ae(n)&&(e.additionalProperties=!1);for(let i of t){let o=r[i.name];if(!o)continue;let a=i.kinds.includes("*")?"any node kind":i.kinds.join(" | ");o.description=[o.description,`Id of a node (${a}).`].filter(Boolean).join(" ")}return{name:n.name,...n.title===void 0?{}:{title:n.title},description:n.description??n.title??n.name,inputSchema:e,nodeRefs:t}}function lt(){let n={type:"string",pattern:"^\\d{4}-\\d{2}-\\d{2}$"},t=(e,r)=>({type:"integer",minimum:e,maximum:r});return{type:"object",description:'How the date beside it repeats; the date is the first occurrence. "on" is weekdays for "week", days of the month (-1 the last) for "month".',properties:{every:{type:"string",enum:[...ge]},interval:t(1,99),on:{type:"array",minItems:1,maxItems:31,items:{anyOf:[{type:"string",enum:[...ye]},t(-1,31)]}},until:n,count:t(1,1e3),except:{type:"array",maxItems:500,items:n},continues:{type:"string",maxLength:200}},required:["every"],additionalProperties:!1}}function Ve(n){let t=new Set;for(let e=n;e;e=e.onBehalfOf)e.id!==void 0&&t.add(`${e.kind}:${e.id}`);return t}function V(n,t){let e=Ve(t),r=c=>{if(c.kind==="rule")return!1;let w=Ve(c);if(w.size===0)return!1;for(let h of w)if(e.has(h))return!1;return!0},i,o=()=>{if(i)return i;i=new Map;for(let c of n.log.live()){if(c.undoes!==void 0)continue;let w=r(c.author)?c.author:void 0;for(let h of c.primitives){h.op==="remove-node"&&i.delete(h.node.id);let b=h.op==="add-node"?h.node.id:h.op==="patch-node"?h.id:void 0;if(b===void 0)continue;let T=h.op==="add-node"?Object.keys(h.node):Object.keys(h.after),O=i.get(b);(h.op==="add-node"||!O)&&i.set(b,O=new Map);for(let v of T)v==="id"||v==="kind"||(w?O.set(v,w):O.delete(v))}}return i},a=n.schema,d=new Map,s=(c,w)=>{let h=`${c}\0${w}`,b=d.get(h);if(b===void 0){let T=a.tryDefinition(c)?.fields?.shape;b=T!==void 0&&w in T&&Ne(T[w]).type==="text",d.set(h,b)}return b},g=c=>n.graph.getNode(c)?.kind;return{prose:s,say:c=>W(c,{graph:n.graph,schema:a}),fieldBy(c,w){let h=g(c);if(!(h===void 0||!s(h,w)))return o().get(c)?.get(w)},recordBy(c){let w=g(c),h=o().get(c);if(w===void 0||!h)return;let b;for(let[T,O]of h)s(w,T)&&(b=O);return b}}}var te=(n,t,e)=>({untrusted:!0,authoredBy:e.say(t),text:n}),ut="the host's ranker";function Ue(n,t){return{...n,hits:n.hits.map(e=>{if(e.about!=="node")return e;e.why.by==="meaning"&&e.why.matched!==void 0&&(e={...e,why:{...e.why,matched:{untrusted:!0,authoredBy:ut,text:e.why.matched}}});let r=t.recordBy(e.id);if(!r)return e;let i=t.prose(e.kind,e.why.field)?t.fieldBy(e.id,e.why.field):r;return{...e,label:te(e.label,r,t),...e.apart!==void 0?{apart:te(e.apart,r,t)}:{},why:i?{...e.why,fragment:te(e.why.fragment,i,t)}:e.why}})}}var ne=(n,t,e)=>({title:n,readOnlyHint:t,destructiveHint:!1,idempotentHint:e,openWorldHint:!1}),ft={name:"subscribe",title:"Notify me when something happens",description:`Subscribe the person you act for to be told when something happens in this app \u2014 their host delivers it (an email, a push). on is one of: "act" (an act runs; give act, its declared name, and/or record), "created" (a record of kind is added), "changed" (a record of kind, or the one record, changes), "reaches" (a record of kind, or the one record, comes to satisfy condition, an expression in the app's rule language such as done == true or amount > 100). They are told only of changes someone else made, unless alsoMine is true, and only of records they may see. Returns the subscription and its sentence. Changes nothing in the app.`,inputSchema:{type:"object",properties:{on:{type:"string",enum:["act","created","changed","reaches"],description:"What to be told of."},act:{type:"string",description:"An act's declared name, for on: act."},kind:{type:"string",description:"A kind, for created, changed and reaches."},record:{type:"string",description:"One record, by id or name: for act, changed and reaches."},condition:{type:"string",description:"For reaches: what the record should come to satisfy, in the rule language (done == true)."},alsoMine:{type:"boolean",description:"Also when the person themselves made the change; false when unsaid."}},required:["on"],additionalProperties:!1},mutating:!1,annotations:ne("Notify me when something happens",!1,!1)},pt={name:"unsubscribe",title:"Stop notifying me",description:"Take away one of the person's subscriptions, by the id list_subscriptions or subscribe answered. Changes nothing in the app.",inputSchema:{type:"object",properties:{id:{type:"string",description:"The subscription's id."}},required:["id"],additionalProperties:!1},mutating:!1,annotations:ne("Stop notifying me",!1,!0)},mt={name:"list_subscriptions",title:"What I am notified of",description:`List what the person you act for is told of in this app: each subscription's id and its sentence ("When someone else adds a task").`,inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:ne("What I am notified of",!0,!0)},ie=[ft,pt,mt];var q=n=>{let t;return()=>t??=n().catch(e=>{throw t=void 0,e})},ht=q(()=>(__graviewPreload(import.meta.url,["./chunk.GTPC6JOW.js","./chunk.NQZ73QV7.js","./chunk.SUPWMV2F.js","./chunk.TPG6IY4M.js","./chunk.NFDLCUCC.js","./chunk.X7JMJSLU.js","./chunk.PPRSGM64.js","./chunk.5Y3Q7ONN.js","./chunk.KTFUVR4V.js","./chunk.KVJFY7N5.js","./chunk.DPHTUTOS.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.FQYOTK34.js"))),yt=()=>(__graviewPreload(import.meta.url,["./chunk.MAFFUPCR.js","./chunk.PPRSGM64.js","./chunk.5Y3Q7ONN.js","./chunk.KTFUVR4V.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.PQVUQVRL.js")).catch(()=>{}),gt=async()=>{(await yt())?.judgeWithLines()},F=q(()=>(__graviewPreload(import.meta.url,["./chunk.WVUJXDXZ.js","./chunk.TPG6IY4M.js","./chunk.NFDLCUCC.js","./chunk.X7JMJSLU.js","./chunk.PPRSGM64.js","./chunk.5Y3Q7ONN.js","./chunk.KTFUVR4V.js","./chunk.DPHTUTOS.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.ODRL5OWR.js"))),wt=q(()=>(__graviewPreload(import.meta.url,["./chunk.7LL7OSBY.js","./chunk.G4JJXA63.js","./chunk.E5GM2SMO.js","./chunk.NQZ73QV7.js","./chunk.NX7IIZLO.js","./chunk.XOZU4OFA.js","./chunk.SUPWMV2F.js","./chunk.Q5WEOX3Q.js","./chunk.4GQA3AJU.js","./chunk.HG4DDNPG.js","./chunk.MAFFUPCR.js","./chunk.WVUJXDXZ.js","./chunk.TPG6IY4M.js","./chunk.NFDLCUCC.js","./chunk.X7JMJSLU.js","./chunk.PPRSGM64.js","./chunk.5Y3Q7ONN.js","./chunk.KTFUVR4V.js","./chunk.N4M54YK6.js","./chunk.KVJFY7N5.js","./chunk.DPHTUTOS.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.ZXZNAG35.js"))),bt=q(()=>(__graviewPreload(import.meta.url,["./chunk.DAUC2DFY.js","./chunk.GTPC6JOW.js","./chunk.NQZ73QV7.js","./chunk.O45VO36H.js","./chunk.UT6642FC.js","./chunk.SUPWMV2F.js","./chunk.TPG6IY4M.js","./chunk.NFDLCUCC.js","./chunk.X7JMJSLU.js","./chunk.PPRSGM64.js","./chunk.5Y3Q7ONN.js","./chunk.KTFUVR4V.js","./chunk.N4M54YK6.js","./chunk.KVJFY7N5.js","./chunk.DPHTUTOS.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.V3N34DSU.js"))),kt=q(()=>(__graviewPreload(import.meta.url,["./chunk.QII2C5OV.js","./chunk.PPRSGM64.js","./chunk.5Y3Q7ONN.js","./chunk.KTFUVR4V.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.DFK2NA6L.js"))),St=n=>n.definitions.some(t=>K(t).size>0),Ge=n=>({value:G(n),label:n.label,...n.describe?{describe:n.describe}:{},...n.card?{card:n.card}:{},fields:n.fields,...n.app?{app:n.app}:{}});async function vt(n,t,e,r){let i=String(e.relation??""),[o,a]=i.includes(".")?i.split(".",2):[void 0,i],d=n.schema.definitions.flatMap(v=>[...K(v)].map(([p,f])=>({kind:v.kind,name:p,relation:f}))),s=d.filter(v=>v.name===a&&(o===void 0||v.kind===o));if(s.length!==1){let v=d.map(p=>`${p.kind}.${p.name}`).join(", ")||"none";return{ok:!1,error:`${s.length===0?`No relation to another app is called "${i}"`:`"${i}" names a relation of several kinds`}. The relations to other apps are: ${v}.`}}let{kind:g,name:c,relation:w}=s[0];if(!r)return{ok:!1,error:`This seat cannot read ${w.address}: its host reads no other app's records. Nothing was changed.`};let h={kind:t.kind,...t.id===void 0?{}:{id:t.id},...t.roles?{roles:t.roles}:{}},b=typeof e.of=="string"?e.of:void 0;if(b!==void 0){let v=n.graph.getNode(b);if(!v||v.kind!==g)return{ok:!1,error:`No ${g} "${b}".`};let p=me(v[c],w),f=await Promise.all(p.map(k=>Promise.resolve().then(()=>r.resolve(k,h)).catch(()=>null)));return{ok:!0,data:{relation:`${g}.${c}`,app:w.address,records:f.map((k,S)=>k===null?{value:G(p[S]),missing:!0}:"denied"in k?{denied:!0,said:"linked record (no access)"}:Ge(k))},reads:[b]}}let T=typeof e.limit=="number"&&e.limit>0?Math.min(e.limit,20):20,O=await Promise.resolve().then(()=>r.find({address:w.address,kinds:w.kinds,query:String(e.query??""),limit:T},h)).catch(()=>[]);return Array.isArray(O)?{ok:!0,data:{relation:`${g}.${c}`,app:w.address,records:O.map(Ge),link:`edit-${g} with ${c} set to a record's value`}}:{ok:!0,data:{relation:`${g}.${c}`,app:w.address,denied:!0,said:"linked record (no access)"}}}var M=n=>({title:n,readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}),Ke={description:'Which records: false (the default) the live ones, true only the archived ones, "all" both. An archived record is set aside, not gone: unarchive-<kind> brings it back.',anyOf:[{type:"boolean"},{type:"string",enum:["all"]}]},re={type:"number",description:"Where the page starts; 0 when unsaid."},se=[{name:"search_graph",title:"Find by name",description:"Find things by name: records whose name or readable fields carry the words, and the kinds, places and rules the words name \u2014 each with why it matched. Reach for this before get_graph when you know what something is called. Words match the start of words, case and accents aside; key:value tokens narrow as a list's filter does (done:false, is:any for past records, kind:<kind>). Pass subject (a node id) to get the acts you may run on it as hits too. When few records match exactly, records with a near word follow \u2014 a typo, another form of the word, a meaning \u2014 each with near: true and why.matched, the record's own word that answered.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Words, with optional key:value conditions."},limit:{type:"number",description:"Most hits to return; at most 20."},subject:{type:"string",description:"A node id whose acts to include."},archived:Ke},required:["query"],additionalProperties:!1},mutating:!1,annotations:M("Find by name")},{name:"get_graph",title:"Read the graph",description:"Read the graph, 25 nodes a page: their fields, the edges out of them, and how many more. Start here when you need the shape of the domain rather than one thing in it.",inputSchema:{type:"object",properties:{offset:re,archived:Ke},additionalProperties:!1},mutating:!1,annotations:M("Read the graph")},{name:"get_node",title:"Read one node",description:"Read one node: its fields, its links (id, kind and label, 20 each way a page), the violations that implicate it, and its computed values: read-only fields worked out from what you can see, which no act sets. Use this to check a thing before you change it.",inputSchema:{type:"object",properties:{id:{type:"string",description:"A node's id, or its name."},offset:re},required:["id"],additionalProperties:!1},mutating:!1,annotations:M("Read one node")},{name:"get_violations",title:"List the problems",description:"List the invariant violations the graph currently has, 20 a page, with the repairs that would resolve each one. Read this before proposing work: a rule that is already broken is more urgent than anything you could add.",inputSchema:{type:"object",properties:{offset:re,context:{type:"object",description:"Evaluation context, e.g. { weekStart }."}},additionalProperties:!1},mutating:!1,annotations:M("List the problems")},{name:"get_affordances",title:"Ask what can be done",description:"Ask what can legally be done with a selection, ranked. Prefer these over composing a mutation by hand: they are derived from the schema, the invariants and the shape of the graph, so they cannot name an action that does not exist.",inputSchema:{type:"object",properties:{selection:{type:"array",items:{type:"string"},description:"Node ids."},context:{type:"object"}},required:["selection"],additionalProperties:!1},mutating:!1,annotations:M("Ask what can be done")},{name:"describe_place",title:"Say what a place shows",description:`Say what one place of the app shows you, as a person in your seat would see it: its headings, its figures as drawn, its lists with each record's title and what its card or row says, the headings a list is grouped under, what an empty list says, the forms it offers (each field in the order asked, its label, whether it must be answered, what it takes and its choices), and any block that could not be worked out. Pass a place's slug ("home", a lens's address like "the-offers", a kind's like "offers"), a record's id, or a visitor form's "forms/<name>", and width 390 for a phone. Use it after a change to check what somebody now sees, instead of guessing.`,inputSchema:{type:"object",properties:{place:{type:"string",description:`"home", a place's slug, a record's id, or "forms/<name>" for a visitor form.`},width:{type:"number",description:"The screen's width in CSS pixels; 390 is a phone, 1440 when unsaid."}},required:["place"],additionalProperties:!1},mutating:!1,annotations:M("Say what a place shows")},{name:"preview_mutation",title:"Try an act without applying it",description:"Try a mutation without applying it: get back the diff it would produce and any invariant it would break. Do this when you are unsure, rather than applying and undoing.",inputSchema:{type:"object",properties:{mutation:{type:"string"},args:{type:"object"}},required:["mutation","args"],additionalProperties:!1},mutating:!1,annotations:M("Try an act without applying it")},{name:"undo_batch",title:"Undo a batch",description:"Undo one batch of operations. Fails, naming the blocking operation, when a later operation read what it wrote.",inputSchema:{type:"object",properties:{batch:{type:"string"},include:{type:"array",items:{type:"string"}}},required:["batch"],additionalProperties:!1},mutating:!0,annotations:{title:"Undo a batch",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}},{name:"list_suggestions",title:"List what is suggested",description:"List the suggestions waiting for a person: changes the app's own actor proposed and did not make, each with its id, what it would do, who suggested it, what it was based on and how sure (0 to 1). Nothing changes until one is accepted (accept_suggestion) or declined (decline_suggestion); a declined one is never suggested again.",inputSchema:{type:"object",properties:{},additionalProperties:!1},mutating:!1,annotations:M("List what is suggested")},{name:"accept_suggestion",title:"Accept a suggestion",description:"Make a waiting suggestion's change, as this seat, carrying what it was based on. Returns the batch (undo_batch takes it back).",inputSchema:{type:"object",properties:{suggestion:{type:"string",description:"The suggestion's id, from list_suggestions."}},required:["suggestion"],additionalProperties:!1},mutating:!0,annotations:{title:"Accept a suggestion",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1}},{name:"decline_suggestion",title:"Decline a suggestion",description:"Decline a waiting suggestion: nothing changes, the decline is kept in the log, and the same change is never suggested or made by the app's own actor again.",inputSchema:{type:"object",properties:{suggestion:{type:"string",description:"The suggestion's id, from list_suggestions."}},required:["suggestion"],additionalProperties:!1},mutating:!0,annotations:{title:"Decline a suggestion",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}],Ye={name:"act_on_several",title:"Do one act to several records",description:`Run one act on several records at once, as one change with one undo. act is the act (its tool name or its declared name), records the records it runs on (ids or names; each goes in the act's subject), args what every call shares ("Set stage to Declined" is args { stage: "declined" }). Each record is judged on its own: one this seat may not change is named with why, and the rest still apply. Returns the batch (undo_batch takes it all back), the records changed, those already so, and those refused.`,inputSchema:{type:"object",properties:{act:{type:"string",description:"The act to run on each record."},records:{type:"array",items:{type:"string"},minItems:1,maxItems:200,description:"Ids or names of the records."},args:{type:"object",description:"Arguments every call shares, besides the record."}},required:["act","records"],additionalProperties:!1},mutating:!0,annotations:{title:"Do one act to several records",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1}},de={type:"object",description:"A lens, as draft_view returns one.",properties:{title:{type:"string"},lens:{type:"string"},on:{type:"string"},bindings:{type:"object"},options:{type:"object"}},required:["title","lens","on"]},ce={name:"draft_view",title:"Draw a view",description:'Draw a view of the data from words ("a board of tasks by status", "who covers what") as a lens the app could keep; or check a lens you wrote (lens); or change the one on screen (current, with ask: "only this month"). Returns the lens and its add-lens edit, or one sentence saying why not. Writes nothing.',inputSchema:{type:"object",properties:{ask:{type:"string",description:"What to see, in words."},lens:de,current:de},additionalProperties:!1},mutating:!1,annotations:M("Draw a view")},Xe={name:"keep_lens",title:"Keep a view as a lens",description:"Keep a lens draft_view drew as one of the app's places: checked again, then written as the add-lens edit. Returns the remove-lens edit that takes it back.",inputSchema:{...de,additionalProperties:!1},mutating:!0,annotations:{title:"Keep a view as a lens",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},Qe={name:"find_linked",title:"Find a record in another app",description:`A relation may go to a kind in another app (describe_app lists them under "Linked from other apps"). With relation and words, list the records there this seat may link \u2014 each with the value to link it by ("house:h1"), its name and its describe line. With of (a record id here), read the records that record links, as this seat may see them there. Linking one is the record's edit (edit-<kind>) with the relation set to the value. Another app this seat may not open answers denied, and nothing of it. Writes nothing; never changes the other app.`,inputSchema:{type:"object",properties:{relation:{type:"string",description:"The relation, by name (forHouse) or as <kind>.<relation> (scenario.forHouse)."},query:{type:"string",description:"Words to find by, in the other app's names; empty for the first few."},of:{type:"string",description:"A record here whose linked records to read, instead of finding."},limit:{type:"number",description:"Most records to return; at most 20."}},required:["relation"],additionalProperties:!1},mutating:!1,annotations:M("Find a record in another app")};function At(n,t){return n===void 0?[]:n==="keep"&&!t?[ce,Xe]:[ce]}var Ot="An argument that names a record takes its id or its name.",et=[...se.map(n=>n.name),Ye.name,ce.name,Xe.name,Qe.name,...ie.map(n=>n.name)],tt=64;function N(n){let{line:t,...e}=n;return e}function Ze(n){return{...n,...n.introduces?{introduces:n.introduces.map(N)}:{},...n.resolves?{resolves:n.resolves.map(N)}:{},...n.violationsAfter?{violationsAfter:n.violationsAfter.map(N)}:{}}}function Rt(n){let t=n.normalize("NFKD").replace(/\p{M}/gu,"").replace(/[^A-Za-z0-9_-]/g,"_");return t.length===0&&(t="act"),/^[A-Za-z_]/.test(t)||(t=`act_${t}`),t.slice(0,tt)}function Tt(n){let t=new Set(et),e=new Map;for(let r of n){let i=Rt(r),o=i;for(let a=2;t.has(o);a+=1)o=`${i.slice(0,tt-`_${a}`.length)}_${a}`;t.add(o),e.set(r,o)}return e}function _t(n,t){if(t.size===0)return n;let e=Object.fromEntries(Object.entries(n.properties??{}).filter(([i])=>!t.has(i))),r=(n.required??[]).filter(i=>!t.has(i));return{...n,properties:e,...n.required?{required:r}:{}}}function xt(n,t,e){let r=ee(n),i=U(n),o=r.nodeRefs.length>0?`${r.description}${/[.!?]$/.test(r.description)?"":"."} ${Ot}`:r.description;return{name:t,title:i,description:o,inputSchema:_t(r.inputSchema,e),mutating:!0,annotations:{title:i,readOnlyHint:!1,destructiveHint:n.destructive===!0||(n.severs?.length??0)>0,idempotentHint:n.idempotent===!0,openWorldHint:!1},act:n.name}}function le(n){if(n===null||typeof n!="object")return JSON.stringify(n)??"null";if(Array.isArray(n))return`[${n.map(le).join(",")}]`;let t=n;return`{${Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${JSON.stringify(e)}:${le(t[e])}`).join(",")}}`}function Mt(n){return`sha256:${Te(le(n))}`}function Nt(n,t,e,r,i,o=!1,a=!1){let d=Tt(n.map(c=>c.name)),s=[...At(r,e),...o?[Qe]:[],...a?ie:[]];return{definitions:e?[...se.filter(c=>!c.mutating),...s]:[...se,Ye,...s,...n.filter(c=>t.has(c.name)).map(c=>xt(c,d.get(c.name),i(c)))],names:d}}function mn(n,t={}){let e=t.author??{kind:"agent"},r=n.allMutations(),i=new Set(n.permittedMutations(e).map(p=>p.name)),{definitions:o,names:a}=Nt(r,i,t.readOnly===!0,t.drafts?t.drafts.keep?"keep":"draw":void 0,p=>Y(n.schema,n.policy,e,p),St(n.schema),t.subscriptions!==void 0),d=Mt(o),s={app:t.app?.brand?.locale,appTimeZone:t.app?.brand?.timeZone},g=p=>fe(s,p),c=p=>{if(!et.includes(p)){for(let[f,k]of a)if(k===p)return f;return a.has(p)?p:_e(p,a.keys())}},w=p=>{let f=xe(p,a.keys());return f?` Did you mean "${f}"?`:""},h=p=>{let f=o.find(S=>S.name===p)??o.find(S=>S.act===p);if(f)return f;let k=c(p);return k===void 0?void 0:o.find(S=>S.act===k)},b=(p,f)=>{let k=r.find(l=>l.name===p);if(!k)return{args:f,resolved:[]};let S={...f},u=[];for(let l of B(k.input)){let m=S[l.name];if(typeof m!="string"||m.trim()==="")continue;let y=n.resolveRef(l,m,e);if(!y.ok){let A=y.reason==="none"?` Nothing was changed. Use search_graph to look it up, then pass its id as ${l.name}.`:" Nothing was changed.";return{ok:!1,error:`${y.message}${A}`,argument:l.name,candidates:y.candidates}}y.by!=="id"&&(S[l.name]=y.id,u.push({argument:l.name,given:m,id:y.id,label:y.label}))}return{args:S,resolved:u}},T=async(p,f)=>{try{await gt();let k=h(p);if(!k){let u=c(p);if(u){let l=n.permits({name:u,args:f},e);if(!l.ok)return{ok:!1,error:l.refusal.message,reason:"forbidden"}}return{ok:!1,error:`Unknown tool "${p}".${w(p)} Available: ${o.map(l=>l.name).join(", ")}`}}if(k.mutating&&t.readOnly)return{ok:!1,error:`"${p}" changes the graph, and this seat is read-only.`,reason:"forbidden"};if(k.act!==void 0){let u=b(k.act,f);if("ok"in u)return u;let l=k.act,m=g(()=>I(n,e,n.apply({name:l,args:u.args},{...t.author?{author:t.author}:{},...oe(t.via)})));return{ok:!0,data:{batch:m.batch,intent:m.intent,introduces:m.introduces.map(N),resolves:m.resolves.map(N),...u.resolved.length>0?{resolved:u.resolved}:{}},diff:m.diff}}let S=n.seenBy(e);switch(k.name){case"search_graph":{let u=typeof t.places=="function"?t.places():t.places,l=typeof f.subject=="string"?f.subject:void 0,m=Ee(S,String(f.query??""),{principal:e,rank:t.near,archived:ke(f.archived),limit:typeof f.limit=="number"&&f.limit>0?Math.min(f.limit,20):20,...u?{places:u}:{},...l?{subject:l,from:[l]}:{}}),y=m.later?await m.later:m;return{ok:!0,data:(await F()).searchRead(y,Ue(y,V(S,e))),reads:y.hits.flatMap(A=>A.about==="node"?[A.id]:[])}}case"get_graph":return{ok:!0,...(await F()).graphRead(S,V(S,e),f)};case"get_node":{let u=String(f.id??""),l=u,m;if(!S.graph.getNode(u)){let A=u.trim()===""?void 0:n.resolveRef({name:"id",kinds:["*"]},u,e);if(A?.ok)l=A.id,m={argument:"id",given:u,id:l,label:A.label};else return A?.reason==="ambiguous"?{ok:!1,error:A.message,argument:"id",candidates:A.candidates}:{ok:!1,error:`No node "${u}".`}}let y=(await F()).nodeRead(S,V(S,e),l,f);return{ok:!0,data:m?{...y.data,resolved:[m]}:y.data,reads:y.reads}}case"describe_place":{let u=t.app??{name:"",schema:n.schema},l=typeof f.width=="number"&&Number.isFinite(f.width)&&f.width>0?f.width:1440,{describePlace:m}=await ht(),y=m(n,e,String(f.place??""),{app:u,width:l});if(!y.ok)return{ok:!1,error:`${y.error} The places are: ${y.places.join(", ")}.`};let A=new Set,$=H=>{for(let D of H)for(let x of D.groups??[])for(let P of x.items)A.add(P.id),$(P.parts)};return $(y.description.parts),{ok:!0,data:y.description,reads:[...A]}}case"find_linked":return vt(S,e,f,t.linked);case"draft_view":case"keep_lens":{let u=t.app??{name:"",schema:n.schema};return(await wt()).runDraftTool(k.name,f,{app:u,principal:e,...t.drafts?{drafts:t.drafts}:{}})}case"get_violations":{let u=S.violations(f.context);return{ok:!0,...(await F()).violationsRead(u,f)}}case"get_affordances":{let u=f.selection??[];return{ok:!0,data:Je(S,u,{...typeof t.derive=="function"?t.derive():t.derive,...t.author?{principal:t.author}:{},...f.context?{context:f.context}:{}}),reads:u.filter(m=>S.graph.has(m))}}case"preview_mutation":{let u=String(f.mutation),l=c(u)??u,m=b(l,f.args??{});if("ok"in m)return m;let y=n.missingFor({name:l,args:m.args},e);if(y)return{ok:!1,error:y.message,reason:"missing"};let A=I(n,e,n.preview({name:l,args:m.args},void 0,{author:e})),$=Ze(A);return{ok:!0,data:m.resolved.length>0?{...$,resolved:m.resolved}:$}}case"act_on_several":{let u=String(f.act??""),l=c(u)??u,m=r.find(R=>R.name===l);if(!m||!i.has(l)){let R=m?n.permits({name:l,args:{}},e):void 0;return R&&!R.ok?{ok:!1,error:R.refusal.message,reason:"forbidden"}:{ok:!1,error:`There is no act "${u}" this seat may run.${w(u)} Nothing was changed.`,reason:"invalid"}}let y=m.subject;if(!y)return{ok:!1,error:`"${U(m)}" does not act on a record, so it cannot be run on several. Nothing was changed.`,reason:"invalid"};let A=Array.isArray(f.records)?f.records.filter(R=>typeof R=="string"&&R.trim()!==""):[];if(A.length===0)return{ok:!1,error:"Name at least one record. Nothing was changed.",reason:"invalid"};let $=[],H=[];for(let R of A.slice(0,200)){let J=n.resolveRef({name:y.arg,kinds:y.kinds},R,e);if(!J.ok)return{ok:!1,error:`${J.message} Nothing was changed.`,argument:"records",candidates:J.candidates};$.push(J.id),J.by!=="id"&&H.push({argument:"records",given:R,id:J.id,label:J.label})}let D=b(l,{...f.args??{}});if("ok"in D)return D;let x=(await bt()).actOnSeveral(n,{mutation:l,subject:y.arg,args:D.args},$,{author:e,...oe(t.via)}),P=x.result?I(n,e,x.result):void 0;return{ok:!0,data:{...x.batch?{batch:x.batch,intent:x.intent}:{},applied:x.applied,unchanged:x.unchanged,refused:x.refused.map(R=>({record:R.id,label:R.label,error:R.message,reason:R.reason})),...x.allOrNothing?{keptNone:!0}:{},...P?{introduces:P.introduces.map(N),resolves:P.resolves.map(N)}:{},...H.length>0||D.resolved.length>0?{resolved:[...H,...D.resolved]}:{}},...P?{diff:P.diff}:{}}}case"subscribe":case"unsubscribe":case"list_subscriptions":{let u=await(await kt()).runSubscriptionTool(k.name,f,{store:n,principal:t.subscriber??e,app:t.app?.name??"app",subscriptions:t.subscriptions});return u.ok?{ok:!0,data:u.data}:{ok:!1,error:u.error}}case"list_suggestions":{let u=$e(n,e).map(l=>{let m=W(l.author,{graph:S.graph,schema:n.schema});return{id:l.id,intent:l.intent,by:m,at:l.at,about:l.about,...l.lineage?{basis:{untrusted:!0,authoredBy:m,text:l.lineage.basis},...l.lineage.confidence!==void 0?{confidence:l.lineage.confidence}:{}}:{}}});return{ok:!0,data:{suggestions:u},reads:[...new Set(u.flatMap(l=>l.about))]}}case"accept_suggestion":case"decline_suggestion":{let u=String(f.suggestion??""),l={author:e,...oe(t.via)},m=k.name==="accept_suggestion"?Pe(n,u,l):De(n,u,l),y=I(n,e,m);return{ok:!0,data:{batch:y.batch,intent:y.intent,introduces:y.introduces.map(N),resolves:y.resolves.map(N)},diff:y.diff}}case"undo_batch":{let u=String(f.batch),l=f.include??[],m=S.canUndo([u,...l]);if(!m.ok)return{ok:!1,error:m.message};let y=I(n,e,n.undo([u,...l],{...t.author?{author:t.author}:{}}));return{ok:!0,data:Ze(y),diff:y.diff}}default:return{ok:!1,error:`Unknown tool "${p}".`}}}catch(k){let{reason:S,wouldNeed:u}=Se(k);return{ok:!1,error:k instanceof Error?k.message:String(k),reason:S,...u?{wouldNeed:u}:{}}}},O=new Set,v=p=>{for(let f of O)f(p)};return{definitions:o,hash:d,...t.author?{author:t.author}:{},onDiff(p){return n.subscribe(p)},onCall(p){return O.add(p),()=>O.delete(p)},async call(p,f){let k=h(p)?.mutating??!1,S={name:p,args:f,mutating:k,at:new Date().toISOString()};v({...S,phase:"running"});let u=m=>(v(m.ok?{...S,phase:"ok",...!k&&m.reads?{reads:m.reads}:{}}:{...S,phase:"failed",error:m.error}),m),l=await T(p,f);return u(l.ok&&!k?{...l,data:(await F()).withinReadChars(p,l.data)}:l)}}}function oe(n){let t=typeof n=="function"?n():n;return t?{via:t}:{}}export{le as a,mn as b};
@@ -1 +1 @@
1
- import{a as O,b}from"./chunk.Z6TMIAAB.js";import"./chunk.RNEJYIQ7.js";import"./chunk.TBQOSI4J.js";import"./chunk.KWQ7QOHD.js";import"./chunk.O4WEJ47H.js";import{G as z,R as M,_ as S}from"./chunk.Y4ZUJUUT.js";import"./chunk.SDO3U72B.js";import{Gc as A}from"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import{b as v}from"./chunk.AJZBJBMO.js";var o=v(z(),1);var t=v(M(),1);function G(i){for(let d of i)for(let[r,s]of Object.entries(d))if(s===!1)return`${r} == true`;return""}var w={margin:0,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"};function j({ask:i,close:d}){let{store:r,principal:s,subscriptions:h,app:f}=S(),c=(0,o.useRef)(null),p=(0,o.useId)(),[n,u]=(0,o.useState)(0),[l,y]=(0,o.useState)(!0),[m,P]=(0,o.useState)(()=>{let e=i.choices.find(g=>g.on==="reaches");if(!e)return"";let a=e.record!==void 0?r.graph.getNode(e.record):void 0;return G(a?[a]:r.graph.nodesOfKind(e.kind).slice(0,5))}),[C,x]=(0,o.useState)(null),[W,k]=(0,o.useState)(!1);(0,o.useEffect)(()=>{let e=c.current;e&&!e.open&&e.showModal()},[]);let T=()=>{let e=i.returnTo;d(),requestAnimationFrame(()=>{e?.isConnected?e.focus():document.querySelector("[data-graview-page-title], main h1, [data-testid='activity-button']")?.focus()})},N=e=>e.on==="reaches"?{...e,condition:m}:e,E=e=>b(r,{when:N(e),alsoMine:!l}),L=async()=>{let e=N(i.choices[n]),a=O(r,e);if(a){x(a);return}k(!0);try{await h.add({who:A(s),app:f?.name??"app",when:e,...l?{}:{alsoMine:!0}}),T()}catch(g){k(!1),x(g instanceof Error?g.message:String(g))}};return(0,t.jsx)("dialog",{ref:c,"aria-labelledby":p,"data-testid":"notify-sheet",onClose:T,onClick:e=>{e.target===e.currentTarget&&e.currentTarget.close()},style:{width:"min(92vw, 420px)",padding:0,border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)",color:"var(--graview-ink)",boxShadow:"var(--graview-lift-high)"},children:(0,t.jsxs)("form",{method:"dialog",onSubmit:e=>{e.preventDefault(),L()},style:{display:"grid",gap:12,padding:18},children:[(0,t.jsx)("h2",{id:p,style:{margin:0,fontSize:"1.0625rem"},children:"Notify me"}),(0,t.jsxs)("fieldset",{style:{margin:0,padding:0,border:0,display:"grid",gap:6},children:[(0,t.jsx)("legend",{style:{...w,marginBottom:6},children:"Tell me"}),i.choices.map((e,a)=>(0,t.jsxs)("label",{style:{display:"flex",gap:8,alignItems:"baseline",cursor:"pointer"},children:[(0,t.jsx)("input",{type:"radio",name:`${p}-when`,checked:n===a,onChange:()=>u(a),"data-notify-choice":e.on}),(0,t.jsx)("span",{children:e.on==="reaches"?`When ${e.record!==void 0?"it":"one"} reaches a condition`:E(e)})]},a))]}),i.choices[n]?.on==="reaches"?(0,t.jsxs)("label",{style:{display:"grid",gap:4},children:[(0,t.jsx)("span",{style:w,children:"The condition, in the app's own words (done == true, amount > 100)"}),(0,t.jsx)("input",{value:m,onChange:e=>P(e.target.value),"data-testid":"notify-condition",autoComplete:"off",spellCheck:!1})]}):null,(0,t.jsxs)("label",{style:{display:"flex",gap:8,alignItems:"center"},children:[(0,t.jsx)("input",{type:"checkbox",checked:l,onChange:e=>y(e.target.checked),"data-testid":"notify-others-only"}),"Only when someone else does it"]}),(0,t.jsxs)("p",{style:w,"data-testid":"notify-said",children:[E(i.choices[n]),"."]}),C?(0,t.jsx)("p",{role:"alert",style:{margin:0,color:"var(--graview-danger, var(--graview-ink))"},children:C}):null,(0,t.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[(0,t.jsx)("button",{type:"button",onClick:()=>c.current?.close(),children:"Cancel"}),(0,t.jsx)("button",{type:"submit",autoFocus:!0,disabled:W,"data-testid":"notify-keep",style:{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"},children:"Notify me"})]})]})})}function B({style:i}){let{store:d,principal:r,subscriptions:s,app:h}=S(),f=(r.onBehalfOf??r).id,[c,p]=(0,o.useState)([]);return(0,o.useEffect)(()=>{if(f===void 0)return;let n=!0,u=()=>void Promise.resolve(s.list(f)).then(y=>n&&p(y.filter(m=>m.app===(h?.name??"app"))),()=>n&&p([]));u();let l=s.onChange?.(u);return()=>{n=!1,l?.()}},[s,f,h]),c.length===0?null:(0,t.jsxs)("section",{"aria-label":"What you are told of","data-testid":"notified",style:{display:"grid",gap:6,...i},children:[(0,t.jsx)("span",{style:{fontSize:"0.75rem",letterSpacing:"0.14em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},children:"You are told"}),(0,t.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:c.map(n=>(0,t.jsxs)("li",{style:{display:"flex",gap:8,alignItems:"baseline",justifyContent:"space-between"},"data-subscription":n.id,children:[(0,t.jsx)("span",{style:{fontSize:"0.8125rem"},children:b(d,n)}),(0,t.jsx)("button",{type:"button","data-testid":"notify-stop","aria-label":`Stop: ${b(d,n)}`,onClick:u=>{let l=u.currentTarget.closest("li"),y=(l?.nextElementSibling??l?.previousElementSibling)?.querySelector("button");Promise.resolve(s.remove(n.id)).then(()=>(y??document.querySelector("[data-testid='activity-button']"))?.focus())},style:{padding:"1px 8px",fontSize:"0.8125rem"},children:"Stop"})]},n.id))})]})}export{B as NotifiedList,j as NotifySheet};
1
+ import{a as O,b}from"./chunk.QII2C5OV.js";import"./chunk.PPRSGM64.js";import"./chunk.5Y3Q7ONN.js";import"./chunk.KTFUVR4V.js";import"./chunk.2UIUMG23.js";import{G as z,R as M,_ as S}from"./chunk.KA44WNB4.js";import"./chunk.SDO3U72B.js";import{Hc as A}from"./chunk.4TJOS4C7.js";import"./chunk.2AZTW66C.js";import{b as v}from"./chunk.AJZBJBMO.js";var o=v(z(),1);var t=v(M(),1);function G(i){for(let d of i)for(let[r,s]of Object.entries(d))if(s===!1)return`${r} == true`;return""}var w={margin:0,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"};function j({ask:i,close:d}){let{store:r,principal:s,subscriptions:h,app:f}=S(),c=(0,o.useRef)(null),p=(0,o.useId)(),[n,u]=(0,o.useState)(0),[l,y]=(0,o.useState)(!0),[m,P]=(0,o.useState)(()=>{let e=i.choices.find(g=>g.on==="reaches");if(!e)return"";let a=e.record!==void 0?r.graph.getNode(e.record):void 0;return G(a?[a]:r.graph.nodesOfKind(e.kind).slice(0,5))}),[C,x]=(0,o.useState)(null),[W,k]=(0,o.useState)(!1);(0,o.useEffect)(()=>{let e=c.current;e&&!e.open&&e.showModal()},[]);let T=()=>{let e=i.returnTo;d(),requestAnimationFrame(()=>{e?.isConnected?e.focus():document.querySelector("[data-graview-page-title], main h1, [data-testid='activity-button']")?.focus()})},N=e=>e.on==="reaches"?{...e,condition:m}:e,E=e=>b(r,{when:N(e),alsoMine:!l}),L=async()=>{let e=N(i.choices[n]),a=O(r,e);if(a){x(a);return}k(!0);try{await h.add({who:A(s),app:f?.name??"app",when:e,...l?{}:{alsoMine:!0}}),T()}catch(g){k(!1),x(g instanceof Error?g.message:String(g))}};return(0,t.jsx)("dialog",{ref:c,"aria-labelledby":p,"data-testid":"notify-sheet",onClose:T,onClick:e=>{e.target===e.currentTarget&&e.currentTarget.close()},style:{width:"min(92vw, 420px)",padding:0,border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)",color:"var(--graview-ink)",boxShadow:"var(--graview-lift-high)"},children:(0,t.jsxs)("form",{method:"dialog",onSubmit:e=>{e.preventDefault(),L()},style:{display:"grid",gap:12,padding:18},children:[(0,t.jsx)("h2",{id:p,style:{margin:0,fontSize:"1.0625rem"},children:"Notify me"}),(0,t.jsxs)("fieldset",{style:{margin:0,padding:0,border:0,display:"grid",gap:6},children:[(0,t.jsx)("legend",{style:{...w,marginBottom:6},children:"Tell me"}),i.choices.map((e,a)=>(0,t.jsxs)("label",{style:{display:"flex",gap:8,alignItems:"baseline",cursor:"pointer"},children:[(0,t.jsx)("input",{type:"radio",name:`${p}-when`,checked:n===a,onChange:()=>u(a),"data-notify-choice":e.on}),(0,t.jsx)("span",{children:e.on==="reaches"?`When ${e.record!==void 0?"it":"one"} reaches a condition`:E(e)})]},a))]}),i.choices[n]?.on==="reaches"?(0,t.jsxs)("label",{style:{display:"grid",gap:4},children:[(0,t.jsx)("span",{style:w,children:"The condition, in the app's own words (done == true, amount > 100)"}),(0,t.jsx)("input",{value:m,onChange:e=>P(e.target.value),"data-testid":"notify-condition",autoComplete:"off",spellCheck:!1})]}):null,(0,t.jsxs)("label",{style:{display:"flex",gap:8,alignItems:"center"},children:[(0,t.jsx)("input",{type:"checkbox",checked:l,onChange:e=>y(e.target.checked),"data-testid":"notify-others-only"}),"Only when someone else does it"]}),(0,t.jsxs)("p",{style:w,"data-testid":"notify-said",children:[E(i.choices[n]),"."]}),C?(0,t.jsx)("p",{role:"alert",style:{margin:0,color:"var(--graview-danger, var(--graview-ink))"},children:C}):null,(0,t.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[(0,t.jsx)("button",{type:"button",onClick:()=>c.current?.close(),children:"Cancel"}),(0,t.jsx)("button",{type:"submit",autoFocus:!0,disabled:W,"data-testid":"notify-keep",style:{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"},children:"Notify me"})]})]})})}function B({style:i}){let{store:d,principal:r,subscriptions:s,app:h}=S(),f=(r.onBehalfOf??r).id,[c,p]=(0,o.useState)([]);return(0,o.useEffect)(()=>{if(f===void 0)return;let n=!0,u=()=>void Promise.resolve(s.list(f)).then(y=>n&&p(y.filter(m=>m.app===(h?.name??"app"))),()=>n&&p([]));u();let l=s.onChange?.(u);return()=>{n=!1,l?.()}},[s,f,h]),c.length===0?null:(0,t.jsxs)("section",{"aria-label":"What you are told of","data-testid":"notified",style:{display:"grid",gap:6,...i},children:[(0,t.jsx)("span",{style:{fontSize:"0.75rem",letterSpacing:"0.14em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},children:"You are told"}),(0,t.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:c.map(n=>(0,t.jsxs)("li",{style:{display:"flex",gap:8,alignItems:"baseline",justifyContent:"space-between"},"data-subscription":n.id,children:[(0,t.jsx)("span",{style:{fontSize:"0.8125rem"},children:b(d,n)}),(0,t.jsx)("button",{type:"button","data-testid":"notify-stop","aria-label":`Stop: ${b(d,n)}`,onClick:u=>{let l=u.currentTarget.closest("li"),y=(l?.nextElementSibling??l?.previousElementSibling)?.querySelector("button");Promise.resolve(s.remove(n.id)).then(()=>(y??document.querySelector("[data-testid='activity-button']"))?.focus())},style:{padding:"1px 8px",fontSize:"0.8125rem"},children:"Stop"})]},n.id))})]})}export{B as NotifiedList,j as NotifySheet};
@@ -1 +1 @@
1
- import{b as a,c as b,d as c,e as d,f as e,g as f,h as g}from"./chunk.2MCZ4CU5.js";import"./chunk.PXQVXBNG.js";import"./chunk.G446PWV6.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import"./chunk.AJZBJBMO.js";export{g as createLinks,f as judgeDestination,e as listsOf,c as nowhere,a as placesSaid,b as quoted,d as whereOfWords};
1
+ import{b as a,c as b,d as c,e as d,f as e,g as f,h as g}from"./chunk.6TKILWRM.js";import"./chunk.PXQVXBNG.js";import"./chunk.G446PWV6.js";import"./chunk.4TJOS4C7.js";import"./chunk.2AZTW66C.js";import"./chunk.AJZBJBMO.js";export{g as createLinks,f as judgeDestination,e as listsOf,c as nowhere,a as placesSaid,b as quoted,d as whereOfWords};
@@ -1 +1 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{b as z}from"./chunk.IXOQQBJE.js";import{a as U,b as V,d as b,e as B,f as C,g as W}from"./chunk.3LDYUO77.js";import{a as J,b as h,d as A}from"./chunk.NFIGGSMJ.js";import{a as p,b as T,c as S,e as _}from"./chunk.BBLIT7S7.js";import{a as R}from"./chunk.SDO3U72B.js";import"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import"./chunk.AJZBJBMO.js";var Q=R(()=>(__graviewPreload(import.meta.url,["./chunk.AJZBJBMO.js"]),import("./chunk.SHNYYBNW.js")));function te(d,e){let f=d.ownerDocument,u=f.defaultView,t=f.createElement("iframe");t.setAttribute("sandbox",T),t.setAttribute("referrerpolicy","no-referrer"),t.setAttribute("allow",""),t.setAttribute("title",e.title??e.view),t.setAttribute("data-guest-view",e.view),t.setAttribute("aria-busy","true"),t.style.border="0",t.style.width="100%",t.style.display="block",t.src=e.url;let a={applied:0,refused:0,dropped:0},P=h(e.limits),i,y,o={applied:0,refused:0,dropped:0},v=()=>{if(!i)return;let r=i.stats;a.applied+=r.applied-o.applied,a.refused+=r.refused-o.refused,a.dropped+=r.dropped-o.dropped,o={...r}},O=W(u,()=>l(),"data"),g=()=>C(()=>e.theme?.()??b(d),e.brand,O),L="",l=()=>{i&&(L=JSON.stringify(g()),i.push())},k=B(f,()=>{i&&JSON.stringify(g())!==L&&l()}),n,w=!1,D=e.pictures?z(Q,({createGuestPictures:r})=>{n=r(u,{as:"data",view:`"${e.title??e.view}"`,pictures:e.pictures,...e.limits?{limits:e.limits}:{},...e.file?{file:e.file}:{},moved:()=>{i?.push(),G&&E()}}),w&&x()}):()=>{},G=!1,c,N=()=>{!G||n?.waiting()||(clearTimeout(c),t.removeAttribute("data-guest-view-failed"),t.removeAttribute("aria-busy"),t.setAttribute("data-guest-view-drawn",""))},E=()=>{clearTimeout(c),c=setTimeout(N,250)},F=setTimeout(()=>{i||(t.removeAttribute("aria-busy"),t.setAttribute("data-guest-view-failed","silent"))},e.limits?.readyMs??8e3),H=()=>{v(),i?.dispose(),y?.close(),i=void 0,y=void 0,o={applied:0,refused:0,dropped:0}},M=r=>{if(!(r.source===null||r.source!==t.contentWindow)){if(r.origin!==S||!P.message()){a.dropped+=1;return}if(!_(r.data)||r.data.protocol!==1){a.dropped+=1;return}if(e.pictures&&!n){w=!0;return}x()}},x=()=>{w=!1,H();let r=U(),m=new MessageChannel;y=m.port1;let I=A({store:e.store,principal:e.principal,view:e.view,nonce:r,send:s=>m.port1.postMessage(s),...e.input?{input:e.input}:{},...e.reads?{reads:e.reads}:{},...n?{hand:n.hand}:{},theme:g,...e.places?{places:()=>[...new Set(e.places().map(s=>s.as))],placesShown:e.places}:{},...e.onNavigatePlace?{onNavigatePlace:e.onNavigatePlace}:{},...e.onNavigate?{onNavigate:e.onNavigate}:{},...e.onArrive?{onArrive:e.onArrive}:e.goTo?{onArrive:s=>V(e.goTo(),s)}:{},...e.onLost?{onLost:e.onLost}:{},onSize:s=>{e.onSize?e.onSize(s):t.style.height=`${s}px`,N()},...e.limits?{limits:e.limits}:{},limiter:P});i=I,m.port1.onmessage=s=>{I.receive(s.data),v()};let j={graview:"host-hello",protocol:1,nonce:r,view:e.view};t.contentWindow.postMessage(j,"*",[m.port2]),l(),G=!0,E()};return u.addEventListener("message",M),d.appendChild(t),d.removeAttribute("aria-busy"),{iframe:t,update:l,get stats(){return v(),a},dispose(){H(),clearTimeout(F),clearTimeout(c),k(),O.dispose(),D(),n?.dispose(),u.removeEventListener("message",M),t.remove()}}}export{p as GUEST_PROTOCOL,T as GUEST_SANDBOX,S as OPAQUE_ORIGIN,A as createGuestHost,h as createGuestLimiter,te as mountGuestView,J as readAcross,b as readTheme};
1
+ var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{b as z}from"./chunk.2VTMTW7K.js";import{a as U,b as V,d as b,e as B,f as C,g as W}from"./chunk.GVNYPFIM.js";import{a as J,b as h,d as A}from"./chunk.DOBQ4LO4.js";import{a as p,b as T,c as S,e as _}from"./chunk.BBLIT7S7.js";import{a as R}from"./chunk.SDO3U72B.js";import"./chunk.4TJOS4C7.js";import"./chunk.2AZTW66C.js";import"./chunk.AJZBJBMO.js";var Q=R(()=>(__graviewPreload(import.meta.url,["./chunk.AJZBJBMO.js"]),import("./chunk.SHNYYBNW.js")));function te(d,e){let f=d.ownerDocument,u=f.defaultView,t=f.createElement("iframe");t.setAttribute("sandbox",T),t.setAttribute("referrerpolicy","no-referrer"),t.setAttribute("allow",""),t.setAttribute("title",e.title??e.view),t.setAttribute("data-guest-view",e.view),t.setAttribute("aria-busy","true"),t.style.border="0",t.style.width="100%",t.style.display="block",t.src=e.url;let a={applied:0,refused:0,dropped:0},P=h(e.limits),i,y,o={applied:0,refused:0,dropped:0},v=()=>{if(!i)return;let r=i.stats;a.applied+=r.applied-o.applied,a.refused+=r.refused-o.refused,a.dropped+=r.dropped-o.dropped,o={...r}},O=W(u,()=>l(),"data"),g=()=>C(()=>e.theme?.()??b(d),e.brand,O),L="",l=()=>{i&&(L=JSON.stringify(g()),i.push())},k=B(f,()=>{i&&JSON.stringify(g())!==L&&l()}),n,w=!1,D=e.pictures?z(Q,({createGuestPictures:r})=>{n=r(u,{as:"data",view:`"${e.title??e.view}"`,pictures:e.pictures,...e.limits?{limits:e.limits}:{},...e.file?{file:e.file}:{},moved:()=>{i?.push(),G&&E()}}),w&&x()}):()=>{},G=!1,c,N=()=>{!G||n?.waiting()||(clearTimeout(c),t.removeAttribute("data-guest-view-failed"),t.removeAttribute("aria-busy"),t.setAttribute("data-guest-view-drawn",""))},E=()=>{clearTimeout(c),c=setTimeout(N,250)},F=setTimeout(()=>{i||(t.removeAttribute("aria-busy"),t.setAttribute("data-guest-view-failed","silent"))},e.limits?.readyMs??8e3),H=()=>{v(),i?.dispose(),y?.close(),i=void 0,y=void 0,o={applied:0,refused:0,dropped:0}},M=r=>{if(!(r.source===null||r.source!==t.contentWindow)){if(r.origin!==S||!P.message()){a.dropped+=1;return}if(!_(r.data)||r.data.protocol!==1){a.dropped+=1;return}if(e.pictures&&!n){w=!0;return}x()}},x=()=>{w=!1,H();let r=U(),m=new MessageChannel;y=m.port1;let I=A({store:e.store,principal:e.principal,view:e.view,nonce:r,send:s=>m.port1.postMessage(s),...e.input?{input:e.input}:{},...e.reads?{reads:e.reads}:{},...n?{hand:n.hand}:{},theme:g,...e.places?{places:()=>[...new Set(e.places().map(s=>s.as))],placesShown:e.places}:{},...e.onNavigatePlace?{onNavigatePlace:e.onNavigatePlace}:{},...e.onNavigate?{onNavigate:e.onNavigate}:{},...e.onArrive?{onArrive:e.onArrive}:e.goTo?{onArrive:s=>V(e.goTo(),s)}:{},...e.onLost?{onLost:e.onLost}:{},onSize:s=>{e.onSize?e.onSize(s):t.style.height=`${s}px`,N()},...e.limits?{limits:e.limits}:{},limiter:P});i=I,m.port1.onmessage=s=>{I.receive(s.data),v()};let j={graview:"host-hello",protocol:1,nonce:r,view:e.view};t.contentWindow.postMessage(j,"*",[m.port2]),l(),G=!0,E()};return u.addEventListener("message",M),d.appendChild(t),d.removeAttribute("aria-busy"),{iframe:t,update:l,get stats(){return v(),a},dispose(){H(),clearTimeout(F),clearTimeout(c),k(),O.dispose(),D(),n?.dispose(),u.removeEventListener("message",M),t.remove()}}}export{p as GUEST_PROTOCOL,T as GUEST_SANDBOX,S as OPAQUE_ORIGIN,A as createGuestHost,h as createGuestLimiter,te as mountGuestView,J as readAcross,b as readTheme};
@@ -0,0 +1 @@
1
+ import{E as b,L as w,M as N,N as T,P as O,Q as S,U as m}from"./chunk.4TJOS4C7.js";var x=864e5,j=/^(\d{4})-(\d{2})-(\d{2})/,p=e=>String(e).padStart(2,"0"),D=e=>new Date(e).toISOString().slice(0,10),a=e=>Date.UTC(+e.slice(0,4),+e.slice(5,7)-1,+e.slice(8,10)),g=(e,t)=>D(a(e)+t*x),W=e=>new Date(a(e)).getUTCDay();function c(e,t,r){if(!(t>=1&&t<=12&&r>=1&&r<=31))return;let i=`${String(e).padStart(4,"0")}-${p(t)}-${p(r)}`;return D(a(i))===i?i:void 0}function F(e=new Date){let t=N();return t?O(e.getTime(),t):{day:`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}`,minutes:e.getHours()*60+e.getMinutes()}}var h=e=>/T\d\d:\d\d(:[\d.]+)?(Z|[+-]\d\d:?\d\d)$/.test(e);function l(e){if(typeof e!="string")return;if(h(e)){let i=new Date(e);return Number.isNaN(i.getTime())?void 0:F(i)}let t=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2}))?/.exec(e);if(!t||!c(Number(t[1]),Number(t[2]),Number(t[3])))return;let r=e.slice(0,10);return t[4]===void 0?{day:r}:{day:r,minutes:Number(t[4])*60+Number(t[5])}}function A(e,t){if(!t.time)return e.day;let r=e.minutes??9*60;if(!t.instant)return`${e.day}T${p(Math.floor(r/60))}:${p(r%60)}`;let i=N(),[,n,o,d]=j.exec(e.day);return(i?new Date(S(e.day,r,i)):new Date(Number(n),Number(o)-1,Number(d),Math.floor(r/60),r%60)).toISOString().replace(/\.\d{3}Z$/,"Z")}function z(e,t=new Date){let r=T(),i=r;try{i=new Intl.DateTimeFormat(e??b,{timeZoneName:"short",timeZone:r}).formatToParts(t).find(n=>n.type==="timeZoneName")?.value??r}catch{i=r}return{zone:r,short:i}}function L(e,t,r,i){let n=l(t);if(!n)return r;let o=e===void 0?void 0:l(e),d=r===void 0?void 0:l(r),u=s=>a(s.day)+(s.minutes??0)*6e4,f=(s,$)=>{let y=u(s)+$;return{day:D(y),...i.time?{minutes:Math.round(y%x/6e4)}:{}}};return o&&d?A(f(d,u(n)-u(o)),i):d&&u(d)>=u(n)?r:i.time?A(f(n,36e5),i):r}var Y=/^(start|starts|startsAt|startsOn|startAt|begins|from|opens|checkIn)$/i,B=/^(end|ends|endsAt|endsOn|endAt|until|to|finish|finishes|closes|through|checkOut)$/i;function P(e,t={}){let r=(t.start&&e.includes(t.start)?t.start:void 0)??e.find(n=>Y.test(n)),i=(t.end&&e.includes(t.end)?t.end:void 0)??e.find(n=>n!==r&&B.test(n));return r&&i?{start:r,end:i}:void 0}var Z=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],H=["sun","mon","tue","wed","thu","fri","sat"],I="(jan(?:uary)?|feb(?:ruary)?|mar(?:ch)?|apr(?:il)?|may|june?|july?|aug(?:ust)?|sept?(?:ember)?|oct(?:ober)?|nov(?:ember)?|dec(?:ember)?)",E="(sun(?:day)?|mon(?:day)?|tue(?:s|sday)?|wed(?:nesday)?|thu(?:r|rs|rsday)?|fri(?:day)?|sat(?:urday)?)",C=e=>Z.indexOf(e.slice(0,3))+1,M=e=>e===void 0?void 0:e.length===2?2e3+Number(e):Number(e);function U(e){try{let t=new Intl.DateTimeFormat(e,{month:"numeric",day:"numeric"}).formatToParts(0).map(r=>r.type);return t.indexOf("month")<t.indexOf("day")}catch{return!0}}function v(e){let t=(n,o)=>({minutes:o,rest:`${e.slice(0,n.index)} ${e.slice(n.index+n[0].length)}`}),r=/\b(noon|midday)\b/.exec(e);if(r)return t(r,12*60);if(r=/\bmidnight\b/.exec(e),r)return t(r,0);if(r=/\b(\d{1,2})(?::(\d{2}))?\s*([ap])\.?m?\.?(?=\s|$)/.exec(e),r){let n=Number(r[1]),o=Number(r[2]??0);return n<1||n>12||o>59?{rest:e,bad:!0}:t(r,(n%12+(r[3]==="p"?12:0))*60+o)}if(r=/\b(\d{1,2}):(\d{2})\b/.exec(e),r){let n=Number(r[1]),o=Number(r[2]);return n>23||o>59?{rest:e,bad:!0}:t(r,n*60+o)}if(r=/\bat\s+(\d{1,2})\b/.exec(e),r){let n=Number(r[1]);return n>23?{rest:e,bad:!0}:t(r,(n>=1&&n<=7?n+12:n)*60)}let i=/\b(morning|afternoon|evening|tonight)\b/.exec(e);return i?{minutes:{morning:9,afternoon:15,evening:18,tonight:20}[i[1]]*60,rest:i[1]==="tonight"?`${e.slice(0,i.index)} today ${e.slice(i.index+i[0].length)}`:`${e.slice(0,i.index)} ${e.slice(i.index+i[0].length)}`}:{rest:e}}function K(e,t,r){let i=e.replace(/\b(on|at|the|of|this)\b/g," ").replace(/\s+/g," ").trim();if(i==="")return null;if(i==="today"||i==="now")return t;if(i==="tomorrow"||i==="tmrw"||i==="tmr")return g(t,1);if(i==="yesterday")return g(t,-1);if(i==="next week")return g(t,7);let n=/^in (\d{1,3}) (day|days|week|weeks)$/.exec(i);if(n)return g(t,Number(n[1])*(n[2].startsWith("week")?7:1));if(n=new RegExp(`^(next )?${E}$`).exec(i),n){let s=(H.indexOf(n[2].slice(0,3))-W(t)+7)%7;return g(t,n[1]&&s===0?7:s)}if(n=/^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(i),n)return c(Number(n[1]),Number(n[2]),Number(n[3]));let o=i.replace(new RegExp(`^${E} `),"");n=new RegExp(`^(\\d{1,2})(?:st|nd|rd|th)? ${I}(?: (\\d{4}))?$`).exec(o);let d=n?{date:n[1],month:n[2],year:n[3]}:void 0;n=new RegExp(`^${I} (\\d{1,2})(?:st|nd|rd|th)?(?: (\\d{4}))?$`).exec(o);let u=d??(n?{date:n[2],month:n[1],year:n[3]}:void 0);if(u)return R(t,M(u.year),C(u.month),Number(u.date));if(n=/^(\d{1,2})[/.-](\d{1,2})(?:[/.-](\d{2}|\d{4}))?$/.exec(o),n){let[f,s]=[Number(n[1]),Number(n[2])],[$,y]=U(r)?[f,s]:[s,f];return R(t,M(n[3]),$,y)}}function R(e,t,r,i){if(t!==void 0)return c(t,r,i);let n=Number(e.slice(0,4)),o=c(n,r,i);return o===void 0?c(n+1,r,i):a(e)-a(o)>183*x?c(n+1,r,i):o}function q(e,t){let r=e.trim();if(h(r)){let u=l(r);if(u)return t.time?u:{day:u.day}}let i=e.toLowerCase().replace(/,/g," ").replace(/(\d{4}-\d{2}-\d{2})t(\d\d:\d\d)(:\d\d(\.\d+)?)?/,"$1 $2").replace(/\s+/g," ").trim();if(i==="")return;let n=v(i);if(n.bad)return;let o=K(n.rest,t.today,t.locale??b);if(o===void 0||o===null&&n.minutes===void 0)return;let d=o??t.base?.day??t.today;return t.time?{day:d,minutes:n.minutes??t.base?.minutes??9*60}:{day:d}}function G(e){if(e===void 0||e==="web"||e.startsWith("ai:")||e.startsWith("app:"))return;if(e==="api")return"via the API";if(e==="cli")return"via the command line";let[t,...r]=e.split(":"),i=r.join(":");return(t==="mcp"||t==="view")&&i?`via ${i}`:t==="mcp"?"via an agent's tools":`via ${e}`}var _=e=>{if(!e.currency)return{before:!0};try{let t=w(e.locale),r=new Intl.NumberFormat(t,{style:"currency",currency:e.currency}).formatToParts(1),i=r.findIndex(d=>d.type==="currency"),n=r.findIndex(d=>d.type==="integer"),o;try{o=new Intl.DisplayNames([t],{type:"currency"}).of(e.currency)}catch{}return{...i>=0?{symbol:r[i].value}:{},before:i<n,...o?{name:o}:{}}}catch{return{symbol:e.currency,before:!0}}};function J(e){let t=e.locale;if(e.format==="money"){let{symbol:r,before:i,name:n}=_(e),o=m(1250,t,{minimumFractionDigits:2,maximumFractionDigits:2});return{...r?i?{prefix:r}:{suffix:r}:{},placeholder:o,hint:n?`in ${n}`:e.currency?`in ${e.currency}`:"an amount of money"}}return e.format==="percent"?{suffix:"%",placeholder:m(15,t),hint:"as a percent"}:{...e.unit?{suffix:e.unit}:{},placeholder:"",hint:e.unit?`in ${e.unit}`:"a number"}}function Q(e,t){return e===void 0||!Number.isFinite(e)?"":t.format==="money"?m(e,t.locale,Number.isInteger(e)?{maximumFractionDigits:0}:{minimumFractionDigits:2,maximumFractionDigits:2}):t.format==="percent"?m(e*100,t.locale,{maximumFractionDigits:4}):m(e,t.locale,{maximumFractionDigits:6})}function V(e){try{let t=new Intl.NumberFormat(w(e)).formatToParts(12345.6);return{group:t.find(r=>r.type==="group")?.value??",",decimal:t.find(r=>r.type==="decimal")?.value??"."}}catch{return{group:",",decimal:"."}}}function X(e,t){let{group:r,decimal:i}=V(t),n=e.replace(/[\s  ']/g,"").replace(/[−–]/g,"-");if(i!=="."&&!n.includes(i)&&/^-?\d+\.\d{1,2}$/.test(n))return Number(n);if(r&&(n=n.split(r).join("")),i!=="."&&(n=n.replace(i,".")),!/^-?(\d+\.?\d*|\.\d+)$/.test(n))return;let o=Number(n);return Number.isFinite(o)?o:void 0}function k(e,t){let r=e.trim();if(r==="")return;let i=t?.format==="money"&&t.currency?_(t).symbol:void 0,n=r;i&&(n=n.split(i).join("")),t?.currency&&(n=n.replace(new RegExp(t.currency,"gi"),"")),n=n.replace(/^[$€£¥₹]|[$€£¥₹]$/g,""),/%\s*$/.test(n)&&(n=n.replace(/%\s*$/,"")),t?.unit&&t.format!=="money"&&(n=n.replace(new RegExp(`\\s*${t.unit.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*$`),""));let d=X(n,t?.locale);if(d!==void 0)return t?.format==="percent"?d/100:d}export{G as a,J as b,Q as c,k as d,F as e,h as f,l as g,A as h,z as i,L as j,P as k,q as l};
@@ -1 +1 @@
1
- var o=new Set(["tell","me","about","what","how","show","describe","the","a","an","and","please"]),$=new Set([...o,"where","is","are","was","find","any","anything","something","things","called","named","which","who","of","for","with","to","in","on","i","my","do","does","have","has","can","you","it","that","this","there","we","our","got","be"]);function k(t){return t.flatMap(e=>{let n=e.repairs.find(s=>!s.missing?.length);return n?[{mutation:n.mutation,args:{...n.args},why:e.message}]:[]})}export{k as a};
1
+ var o=new Set(["tell","me","about","what","how","show","describe","the","a","an","and","please"]),k=new Set([...o,"where","is","are","was","find","any","anything","something","things","called","named","which","who","of","for","with","to","in","on","i","my","do","does","have","has","can","you","it","that","this","there","we","our","got","be"]);function S(t){return t.flatMap(e=>{let n=e.repairs.find(s=>!s.missing?.length);return n?[{mutation:n.mutation,args:{...n.args},why:e.message}]:[]})}export{S as a};
@@ -1 +1 @@
1
- import{a as g}from"./chunk.H7KCWCB4.js";import{D as m,Fb as w,H as y,ua as a,xa as k}from"./chunk.AS4CQBOQ.js";var d=i=>i?._zod?.def,h=/^\^\\d\{4\}-\\d\{2\}-\\d\{2\}\$$/;function b(i){let t=d(i),p=!0,f;for(let e=0;t&&e<4;e++){if(t.type==="optional"||t.type==="nullable")p=!1;else if(t.type==="default")p=!1,f=t.defaultValue;else break;t=d(t.innerType)}if(!t)return{why:"it is not a zod field"};let u=m(i),r={...p?{required:!0}:{},...f!==void 0?{default:f}:{},...u?{description:u}:{}},s=(t.checks??[]).map(e=>d(e)),c=a(i);if(c)return{spec:{type:c,...r}};if(k(i))return{spec:{type:"app-link",...r}};if(g(i))return{spec:{type:"text",format:"markdown",...r}};let l=w(i);if(l)return{spec:{type:l,...r}};switch(t.type){case"string":{let e=t.format;return e==="email"?{spec:{type:"email",...r}}:e==="url"?{spec:{type:"url",...r}}:e==="date"?{spec:{type:"date",...r}}:e==="datetime"||s.some(n=>n?.fn===y)?{spec:{type:"datetime",...r}}:s.some(n=>n?.format==="regex"&&h.test(String(n?.pattern?.source??"")))?{spec:{type:"date",...r}}:{spec:{type:"string",...r}}}case"number":{let e={};for(let n of s){let o=n?.value;typeof o=="number"&&(n?.check==="greater_than"&&n.inclusive?e.min=Math.max(e.min??o,o):n?.check==="less_than"&&n.inclusive?e.max=Math.min(e.max??o,o):n?.check==="multiple_of"&&(e.step=o))}return{spec:{type:s.some(n=>n?.format==="safeint"||n?.format==="int")?"integer":"number",...e,...r}}}case"boolean":return{spec:{type:"boolean",...r}};case"enum":{let e=Object.keys(t.entries??{});return e.length>0?{spec:{type:"enum",options:e,...r}}:{why:"it is an enum with no options"}}case"array":{let e=d(t.element),n=a(t.element)??(e?.type==="number"?"number":e?.type==="string"?"string":void 0);return n?{spec:{type:"list",of:n,...r}}:{why:`it is a list of ${String(e?.type??"something")}, and a document lists words, numbers, dates, images, videos or files`}}default:return{why:`it is a ${String(t.type)}, which a document has no field type for`}}}function L(i){let t=b(i);return"spec"in t?t.spec:void 0}export{L as a};
1
+ import{a as g}from"./chunk.DPHTUTOS.js";import{D as m,Gb as w,H as y,va as a,ya as k}from"./chunk.4TJOS4C7.js";var d=i=>i?._zod?.def,h=/^\^\\d\{4\}-\\d\{2\}-\\d\{2\}\$$/;function b(i){let t=d(i),p=!0,f;for(let e=0;t&&e<4;e++){if(t.type==="optional"||t.type==="nullable")p=!1;else if(t.type==="default")p=!1,f=t.defaultValue;else break;t=d(t.innerType)}if(!t)return{why:"it is not a zod field"};let u=m(i),r={...p?{required:!0}:{},...f!==void 0?{default:f}:{},...u?{description:u}:{}},s=(t.checks??[]).map(e=>d(e)),c=a(i);if(c)return{spec:{type:c,...r}};if(k(i))return{spec:{type:"app-link",...r}};if(g(i))return{spec:{type:"text",format:"markdown",...r}};let l=w(i);if(l)return{spec:{type:l,...r}};switch(t.type){case"string":{let e=t.format;return e==="email"?{spec:{type:"email",...r}}:e==="url"?{spec:{type:"url",...r}}:e==="date"?{spec:{type:"date",...r}}:e==="datetime"||s.some(n=>n?.fn===y)?{spec:{type:"datetime",...r}}:s.some(n=>n?.format==="regex"&&h.test(String(n?.pattern?.source??"")))?{spec:{type:"date",...r}}:{spec:{type:"string",...r}}}case"number":{let e={};for(let n of s){let o=n?.value;typeof o=="number"&&(n?.check==="greater_than"&&n.inclusive?e.min=Math.max(e.min??o,o):n?.check==="less_than"&&n.inclusive?e.max=Math.min(e.max??o,o):n?.check==="multiple_of"&&(e.step=o))}return{spec:{type:s.some(n=>n?.format==="safeint"||n?.format==="int")?"integer":"number",...e,...r}}}case"boolean":return{spec:{type:"boolean",...r}};case"enum":{let e=Object.keys(t.entries??{});return e.length>0?{spec:{type:"enum",options:e,...r}}:{why:"it is an enum with no options"}}case"array":{let e=d(t.element),n=a(t.element)??(e?.type==="number"?"number":e?.type==="string"?"string":void 0);return n?{spec:{type:"list",of:n,...r}}:{why:`it is a list of ${String(e?.type??"something")}, and a document lists words, numbers, dates, images, videos or files`}}default:return{why:`it is a ${String(t.type)}, which a document has no field type for`}}}function L(i){let t=b(i);return"spec"in t?t.spec:void 0}export{L as a};
@@ -1,4 +1,4 @@
1
- import{vc as e}from"./chunk.AS4CQBOQ.js";var i=`
1
+ import{wc as e}from"./chunk.4TJOS4C7.js";var i=`
2
2
  .graview-spec{display:flex;flex-direction:column;gap:6px;min-width:0;color:var(--graview-ink)}
3
3
 
4
4
  .graview-spec-row{flex-direction:row;flex-wrap:wrap;align-items:center;gap:4px 10px;box-sizing:border-box;max-width:100%;padding:5px 10px;border:1px solid var(--graview-edge);border-radius:var(--graview-radius-sm,8px);background:var(--graview-panel);font-size:.875rem}
@@ -1 +1 @@
1
- import{Uc as w,Vc as v,Wc as k,Xc as c,Zc as $,_c as b,gd as f,ha as u,kd as P,ld as S,md as x,pd as A,qd as N}from"./chunk.AS4CQBOQ.js";function H(s){if(!(s.attach==="home"||s.cardinality==="one"||!s.title))return{kind:s.attach,title:s.title,as:k(s.title),name:s.name,lens:"view",...s.hidden?{hidden:!0}:{}}}function V(s,r=[]){let a=[];for(let n of f(s).drawn)for(let i of n.kinds)a.push({kind:i,title:n.title,as:n.as,...n.across?{across:n.across}:{},...n.kinds.length>1?{over:n.kinds}:{},...n.hidden?{hidden:!0}:{}});for(let n of[...s.views?.places?.()??[],...r.flatMap(i=>H(i)??[])])a.some(i=>i.kind===n.kind&&i.as===n.as)||a.push(n);return a}function D(s,r={}){return E(s.schema,V(s,r.views),{...s.pages?{pages:s.pages}:{},lenses:f(s).drawn,home:(s.home?.length??0)>0})}function E(s,r,a={}){let{pages:n}=a,i=s.kinds,d=r.filter(e=>i.includes(e.kind)),o=N(n?.first,s,d),O=new Set(n?.hide??[]),p=A(i,n?.order,d),m=p.flatMap(e=>e.view?[]:[e.kind]),L=p.flatMap(e=>e.view?[e.view]:[]),h=[{slug:"home",title:"Home",kind:null,cardinality:"many",address:"/",stop:"#",...o?.to==="home"||o===void 0&&a.home?{first:!0}:{}},{slug:P,title:x(n),kind:null,cardinality:"many",address:S,stop:"#"}],G=v([...d].sort((e,t)=>m.indexOf(e.kind)-m.indexOf(t.kind))),g=e=>{let t=a.lenses?.find(l=>l.as===e.as&&l.kinds.includes(e.kind)),y=b(e,d);return{slug:e.as,title:e.title,kind:e.kind,...e.over?{over:e.over.filter(l=>i.includes(l))}:{},cardinality:"many",address:$(e.as,y?c(s,e.kind).slice(1):void 0),stop:y?`#focus=aggregate:${e.kind}&in.view=${encodeURIComponent(e.as)}`:`#view=${encodeURIComponent(e.as)}`,...t?{lens:t.lens}:{},...e.name!==void 0?{view:e.name}:{},...e.hidden?{hidden:!0}:{},...o?.to==="place"&&o.place.as===e.as&&(o.place.kind===e.kind||e.over?.includes(o.place.kind))?{first:!0}:{}}};for(let e of G)L.some(t=>w(t,e))||h.push(g(e));for(let e of p){if(e.view){h.push(g(e.view));continue}let t=e.kind;h.push({slug:c(s,t).slice(1),title:u(s,t),kind:t,cardinality:"many",address:c(s,t),stop:`#focus=aggregate:${t}`,...O.has(t)?{hidden:!0}:{},...o?.to==="kind"&&o.kind===t?{first:!0}:{}})}return h}export{D as a,E as b};
1
+ import{Xc as w,Yc as v,Zc as k,_c as c,ad as $,bd as b,ia as u,jd as f,nd as P,od as S,pd as x,sd as A,td as N}from"./chunk.4TJOS4C7.js";function H(s){if(!(s.attach==="home"||s.cardinality==="one"||!s.title))return{kind:s.attach,title:s.title,as:k(s.title),name:s.name,lens:"view",...s.hidden?{hidden:!0}:{}}}function V(s,r=[]){let a=[];for(let n of f(s).drawn)for(let i of n.kinds)a.push({kind:i,title:n.title,as:n.as,...n.across?{across:n.across}:{},...n.kinds.length>1?{over:n.kinds}:{},...n.hidden?{hidden:!0}:{}});for(let n of[...s.views?.places?.()??[],...r.flatMap(i=>H(i)??[])])a.some(i=>i.kind===n.kind&&i.as===n.as)||a.push(n);return a}function D(s,r={}){return E(s.schema,V(s,r.views),{...s.pages?{pages:s.pages}:{},lenses:f(s).drawn,home:(s.home?.length??0)>0})}function E(s,r,a={}){let{pages:n}=a,i=s.kinds,d=r.filter(e=>i.includes(e.kind)),o=N(n?.first,s,d),O=new Set(n?.hide??[]),p=A(i,n?.order,d),m=p.flatMap(e=>e.view?[]:[e.kind]),L=p.flatMap(e=>e.view?[e.view]:[]),h=[{slug:"home",title:"Home",kind:null,cardinality:"many",address:"/",stop:"#",...o?.to==="home"||o===void 0&&a.home?{first:!0}:{}},{slug:P,title:x(n),kind:null,cardinality:"many",address:S,stop:"#"}],G=v([...d].sort((e,t)=>m.indexOf(e.kind)-m.indexOf(t.kind))),g=e=>{let t=a.lenses?.find(l=>l.as===e.as&&l.kinds.includes(e.kind)),y=b(e,d);return{slug:e.as,title:e.title,kind:e.kind,...e.over?{over:e.over.filter(l=>i.includes(l))}:{},cardinality:"many",address:$(e.as,y?c(s,e.kind).slice(1):void 0),stop:y?`#focus=aggregate:${e.kind}&in.view=${encodeURIComponent(e.as)}`:`#view=${encodeURIComponent(e.as)}`,...t?{lens:t.lens}:{},...e.name!==void 0?{view:e.name}:{},...e.hidden?{hidden:!0}:{},...o?.to==="place"&&o.place.as===e.as&&(o.place.kind===e.kind||e.over?.includes(o.place.kind))?{first:!0}:{}}};for(let e of G)L.some(t=>w(t,e))||h.push(g(e));for(let e of p){if(e.view){h.push(g(e.view));continue}let t=e.kind;h.push({slug:c(s,t).slice(1),title:u(s,t),kind:t,cardinality:"many",address:c(s,t),stop:`#focus=aggregate:${t}`,...O.has(t)?{hidden:!0}:{},...o?.to==="kind"&&o.kind===t?{first:!0}:{}})}return h}export{D as a,E as b};
@@ -0,0 +1 @@
1
+ import{b as Ce,d as $e,i as ae}from"./chunk.KVJFY7N5.js";import{e as Te}from"./chunk.DPHTUTOS.js";import{Dc as ve,Ec as Oe,I as ke,Wa as Se,Ya as G,Yc as Re,Zb as ie,_ as M,_c as De,aa as xe,ad as We,bd as Me,ca as _,da as z,ea as Ae,fa as W,ha as we,ia as Ne,vd as je,zc as oe}from"./chunk.4TJOS4C7.js";function se(n,e){return n.display?.labels?.[e]??W(e)}function de(n){let e=ae(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,o=n.tryDefinition(e);for(let[r,a]of Object.entries(o?.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,d]of Object.entries(r.edges??{}))t.has(a)||d.to!=="*"&&!d.to.includes(e)||t.set(a,{key:a,label:d.inverse?M(d.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 o=t.retired.map(String);return e.some(r=>r.key===t.field&&o.includes(r.value))}function Be(n,e){let t=n.tryDefinition(e);if(!t)return{kind:e,sorts:[],filters:[],groups:[]};let o=new Set(t.display?.hide??[]),r=t.fields.shape??{},a=[{key:"label",label:"Name",about:"label",type:"text"}],d=[],f=[];for(let[y,x]of Object.entries(r)){if(y==="id"||y==="kind"||y==="label"||o.has(y))continue;let p=de(x);if(!p)continue;let O=se(t,y),w=p==="choice"?Le(x):p==="boolean"?["true","false"]:void 0,N={key:y,label:O,about:"field",type:p,...w?{options:w}:{}};a.push(N),d.push(N),(p==="boolean"||p==="choice")&&f.push(N),p==="date"&&f.push({...N,buckets:["day","week","month","year","decade"]})}for(let y of Je(n,e))a.push(y),d.push(y),f.push(y);let l={key:"is",label:t.lifecycle?"Standing and currency":"Standing",about:"is",type:"choice",options:t.lifecycle?[...Ze]:["flagged","clear"]};d.push(l);let u=t.fieldRoles?.order,g=u&&(u in r||u==="label")?{by:u,direction:"asc"}:void 0;return{kind:e,sorts:a,filters:d,groups:f,...g?{natural:g}:{}}}function vn(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[d,f]of Object.entries(a.fields.shape??{}))de(f)!=="choice"||a.display?.hide?.includes(d)||t.push({key:`${r.key}.${d}`,label:`${r.label} \xB7 ${se(a,d)}`,about:"via",type:"choice",options:Le(f),far:[a.kind]})}if(t.length===0)return e;let o=e.filters.filter(r=>r.about!=="is");return{...e,filters:[...o,...t,...e.filters.filter(r=>r.about==="is")]}}function On(n,e){let t=n.tryDefinition(e.kind),o=Object.entries(t?.computed??{});if(!t||o.length===0)return e;let r=o.filter(([a])=>!e.sorts.some(d=>d.key===a)).map(([a,d])=>({key:a,label:(typeof d=="object"?d.label:void 0)??se(t,a),about:"field",type:"number"}));return{...e,sorts:[...e.sorts,...r]}}function Le(n){let e=ae(n);return e.type==="choice"?e.options:[]}var Ie=n=>n,Pe=n=>n;function en(n,e,t){let o=new Map;for(let r of[...n.out(e,t),...n.in(e,t)])o.set(r.id,r);return[...o.values()]}function le(n,e,t){let o=n.schema.tryDefinition(e.kind);if(t.key==="is")switch(t.value){case"current":return _(o,Pe(e),n.today);case"past":return!_(o,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=o?.fields.shape??{};if(t.key in r){let l=Se(Ie(e),t.key,n.today??ke()),u=de(r[t.key]);if(u==="date"){let[g,y]=t.value.split(":");if(typeof l!="string"||!y)return!1;let x=l.slice(0,10);return g==="before"?x<y:g==="after"?x>y:x===y}if(u==="boolean")return String(l)===t.value;if(u==="number"){let g=t.value.lastIndexOf(":"),y=g>0?t.value.slice(0,g):"",x=Number(t.value.slice(g+1));if(y==="at-most"||y==="at-least")return typeof l!="number"||!Number.isFinite(x)?!1:y==="at-most"?l<=x:l>=x}return String(l)===t.value}let[a,d]=t.key.split("."),f=en(n.graph,e.id,a);return d?f.some(l=>String(Ie(l)[d])===t.value):t.value==="*"?f.length>0:t.value==="none"?f.length===0:f.some(l=>l.id===t.value)}var nn=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 U=new Map,tn=5e4;function $(n){let e=U.get(n);if(e===void 0){U.size>=tn&&U.clear();let t=ze(n);e={tokens:t.split(" ").filter(Boolean),whole:t.replace(/ /g,"")},U.set(n,e)}return e}var T=n=>[...$(n).tokens];function j(n,e){if(e.length===0)return;let{whole:t,tokens:o}=$(n),r=e.join("");if(t.length===0)return;if(t===r)return"exact";if(e.every(d=>o.some(f=>f.startsWith(d))))return t.startsWith(r)?"prefix":e.every(d=>o.includes(d))?"word":"part"}function q(n,e,t=48){let o=n.replace(/\s+/g," ").trim();if(o.length<=t)return o;let r=e[0],a=o.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase(),d=r?a.search(new RegExp(`(^|[^\\p{L}\\p{N}])${rn(r)}`,"u")):-1,f=d<0?0:d+(a[d]&&/[\p{L}\p{N}]/u.test(a[d])?0:1),l=Math.max(0,f-Math.floor(t/3));if(l>0){let g=o.lastIndexOf(" ",l);l=g<0?0:g+1}let u=Math.min(o.length,l+t);if(u<o.length){let g=o.indexOf(" ",u);u=g<0||g-u>16?u:g}return`${l>0?"\u2026":""}${o.slice(l,u).trim()}${u<o.length?"\u2026":""}`}var rn=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),on=/^([\p{L}][\p{L}\p{N}_-]*):(\S+)$/u;function an(n){let e=[],t=[];for(let o of n.trim().split(/\s+/).filter(Boolean)){let r=on.exec(o);r?t.push({key:r[1],value:r[2]}):e.push(o)}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 o=sn(n,e);return Ee.set(e,{definition:n,texts:o}),o}function sn(n,e){let t=z(n,e),o=[{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"&&o.push({field:r.key,reading:r.label,text:r.markdown?Te(r.value):r.value});return o}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 o=[],r=Array.from({length:e.length+1},(a,d)=>d);for(let a=1;a<=n.length;a++){let d=[a],f=a;for(let l=1;l<=e.length;l++){let u=Math.min(r[l]+1,d[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]&&(u=Math.min(u,o[l-2]+1)),d[l]=u,u<f&&(f=u)}if(f>t)return t+1;o=r,r=d}return r[e.length]}var V=new Map;function dn(n,e){let t=V.get(n);t||(V.size>=64&&V.clear(),V.set(n,t=new Map));let o=t.get(e);return o===void 0&&(o=ln(n,e)??null,t.set(e,o)),o??void 0}function ln(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 o=n.length<4?0:n.length<=7?1:2;if(o!==0){if(He(n,e,o)<=o)return"spelling";if(n.length>=5){for(let r=n.length-o;r<=n.length+o;r++)if(r<e.length&&He(n,e.slice(0,r),o)<=o)return"spelling"}}}function cn(n,e){let t=e.length>1?e.filter(r=>!Ge.has(r)):e;if(t.length===0)return;let o;for(let r of t){let a;for(let d of n){for(let f of $(d.text).tokens){if(f.startsWith(r)){a={text:d,matched:f};break}let l=a?void 0:dn(r,f);l&&(a={text:d,matched:f,by:l})}if(a&&!a.by)break}if(!a)return;a.by&&!o&&(o={text:a.text,asked:r,matched:a.matched,by:a.by})}if(o)return{field:o.text.field,reading:o.text.reading,fragment:q(o.text.text,[o.matched]),strength:"near",asked:o.asked,matched:o.matched,by:o.by}}var fn=80;function gn(n,e,t){let o=T(e).filter(d=>!Ge.has(d)).join(" ")||e,r=t===void 0?[]:T(t),a=r.length>0&&n.find(d=>r.every(f=>$(d.text).tokens.some(l=>l.startsWith(f))))||n[0];return{field:a.field,reading:a.reading,fragment:q(a.text,r),strength:"near",asked:o,matched:(t??a.text).slice(0,fn),by:"meaning"}}function _e(n,e,t,o){let r=T(t);if(r.length===0)return;if(o){let p=Q(n,e),O=o.includes("label")||o.some(v=>typeof e[v]=="string"&&e[v]===p[0].text),w=p.filter((v,D)=>D===0?O:o.includes(v.field)),N=v=>D=>$(D.text).tokens.some(P=>P.startsWith(v));if(!r.every(v=>w.some(N(v))))return;let S=w.find(N(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),[d,...f]=a,l=j(d.text,r);if(l)return{field:"label",reading:d.reading,fragment:q(d.text,r),strength:l};let u=p=>O=>$(O.text).tokens.some(w=>w.startsWith(p));if(!r.every(p=>a.some(u(p))))return;let g=T(d.text),y=r.find(p=>!g.some(O=>O.startsWith(p)))??r[0],x=f.find(u(y));return{field:x.field,reading:x.reading,fragment:q(x.text,[y]),strength:"field"}}var un=512,yn=64;function hn(n){let e=new Map;if(n.length===0)return e;let t=n.slice(-un),o=n[n.length-1].seq;for(let r of t){let a=Math.pow(.5,(o-r.seq)/yn);for(let d of r.writes)e.set(d,(e.get(d)??0)+a)}return e}var ge=(n,e)=>we({tryDefinition:()=>n},e),fe=(n,e)=>De({tryDefinition:()=>n},e);function pn(n,e,t){let o=n.tryDefinition(e),r=[{field:"plural",text:ge(o,e)},{field:"kind",text:W(e)},...o?.noun?[{field:"noun",text:o.noun}]:[]],a;for(let d of r){let f=j(d.text,t);f&&(!a||I[f]<I[a.strength])&&(a={strength:f,...d})}return a}var mn,bn=(n,e)=>(mn??=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||bn(n.name,e.name)||(n.id<e.id?-1:n.id>e.id?1:0);function Ln(n,e,t={}){let o=n.schema,r=an(e),a=T(r.words),d=t.principal??{kind:"human"},f=n.kindsKeptFrom(d),l=n.modules.disabledKinds,u=r.conditions.filter(i=>i.key==="kind").map(i=>i.value),g=r.conditions.filter(i=>i.key==="is").map(i=>i.value),y=g.includes("any")||g.includes("past"),x=g.includes("past")&&!g.includes("any")&&!g.includes("current"),p=g.includes("archived")?!0:t.archived??"all",O=(i,s)=>{let c=ce(s),h=o.tryDefinition(i);return ce(i)===c||ce(ge(h,i))===c},w=o.kinds.filter(i=>!f.has(i)&&!l.has(i)&&(t.kinds===void 0||t.kinds.includes(i))&&(u.length===0||u.some(s=>O(i,s)))),S=r.conditions.filter(i=>i.key!=="kind").map(i=>({...i,admittedBy:w.filter(s=>Be(o,s).filters.some(c=>c.key===i.key))})),v=S.filter(i=>i.key!=="is"),D=g.filter(i=>i==="flagged"||i==="clear"||i==="past"||i==="archived"),P={kinds:w,past:y},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 X=t.today,F=t.flagged??new Set(n.violations().flatMap(i=>i.nodeIds)),Ue=t.touched??hn(n.log.all()),Y=new Set;for(let i of t.from??[]){Y.add(i);for(let s of n.graph.neighbors(i))Y.add(s.id)}let ue=ve(n,d)?Oe(n,d):void 0,J=oe.keptFrom?.(n,d)&&n.seenBy(d).graph,Z=i=>je(i,t.basePath===void 0?{}:{basePath:t.basePath}),ye={schema:o,graph:n.graph,flagged:F,...X?{today:X}:{}},R=[],B={},L=[],E=[],K=(i,s,c,h,m,b)=>{let A=z(c,i);B[s]=(B[s]??0)+1,R.push({hit:{about:"node",id:i.id,kind:s,label:A,why:m,current:h,flagged:F.has(i.id),address:Z(`${fe(c,s)}/${encodeURIComponent(i.id)}`),...b===void 0?{}:{near:!0},...G(i)?{archived:!0}:{}},...b===void 0?{}:{nearly:2-b},tier:I[m.strength],inKind:s===t.inKind?0:1,near:Y.has(i.id)?0:1,past:h?0:1,archived:G(i)?1:0,touched:-(Ue.get(i.id)??0),flagged:F.has(i.id)?0:1,name:A,id:i.id})};for(let i of w){let s=o.tryDefinition(i),c=S.filter(m=>m.key!=="is"&&m.admittedBy.includes(i));if(a.length===0&&c.length===0&&D.length===0)continue;let h=Fe(s,c);for(let m of n.graph.nodesOfKind(i,{archived:p})){if(ue&&!ue(m.id))continue;let b=J?J.getNode(m.id):m;if(!b)continue;let A=_(s,b,X);if(!y&&!h&&!A){if(a.length>0&&g.length===0&&c.every(k=>le(ye,b,k))){let k=_e(s,b,r.words);k&&E.push({node:b,kind:i,definition:s,why:k})}continue}if(x&&A||!c.every(k=>le(ye,b,k))||g.includes("flagged")&&!F.has(b.id)||g.includes("clear")&&F.has(b.id))continue;let C=a.length>0?_e(s,b,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(b,i,s,A,C):a.length>0&&L.push({node:b,kind:i,definition:s,current:A})}}let ee=i=>i.strength!=="field",ne=!1;if(E.length>0&&R.length===0){ne=!0;for(let i of E)K(i.node,i.kind,i.definition,!1,i.why)}else if(E.some(i=>ee(i.why))&&!R.some(i=>ee(i.hit.why))){ne=!0;for(let i of E)ee(i.why)&&K(i.node,i.kind,i.definition,!1,i.why)}let he=t.near!==!1&&a.length>0&&R.length<nn&&L.length>0,te=new Set;if(he)for(let i of L){let s=cn(Q(i.definition,i.node),a);s&&(te.add(i.node.id),K(i.node,i.kind,i.definition,i.current,s,s.by==="stem"?.9:.8))}let Ve=i=>i==="exact"||i==="prefix"?-1:I[i],re=(i,s,c,h)=>({hit:i,tier:Ve(s),inKind:1,near:1,past:0,touched:0,flagged:1,name:c,id:h});if(a.length>0){for(let s of w){let c=pn(o,s,a);if(!c)continue;let h=Ne(o,s),m={field:c.field,reading:c.field==="plural"?"Plural":"Kind",fragment:c.text,strength:c.strength};R.push(re({about:"kind",kind:s,label:h,why:m,count:B[s]??0,address:Z(fe(o.tryDefinition(s),s))},c.strength,h,`kind:${s}`))}let i=t.places??[];for(let s of Re(i.filter(c=>w.includes(c.kind)))){if(s.across&&f.has(s.across))continue;let c=j(s.title,a);if(!c)continue;let h={field:"title",reading:"Title",fragment:s.title,strength:c},m=Me(s,i)?fe(o.tryDefinition(s.kind),s.kind).slice(1):void 0,b=Z(We(s.as,m));R.push(re({about:"place",kind:s.kind,title:s.title,as:s.as,why:h,address:b},c,s.title,`place:${s.kind}:${s.as}`))}for(let s of n.allInvariants()){let c=s.scope==="graph"?void 0:s.scope.kind;if(c&&!w.includes(c))continue;let h=s.label??W(s.name),m=j(h,a),b=m?void 0:j(W(s.name),a),A=m??b;if(!A)continue;let C={field:m?"label":"name",reading:m?"Rule":"Name",fragment:m?h:s.name,strength:A};R.push(re({about:"rule",name:s.name,label:h,...c?{kind:c}:{},why:C},A,h,`rule:${s.name}`))}}let pe=()=>{R.sort(qe);let i=t.limit??50,s=R.slice(0,i).map(k=>k.hit),c=s.flatMap(k=>k.about==="node"?[(J||n.graph).getNode(k.id)]:[]).filter(Boolean),h=Ce(c,k=>o.tryDefinition(k)),m=s.map(k=>k.about==="node"&&h.has(k.id)?{...k,apart:h.get(k.id)}:k),b=Object.values(B).reduce((k,Ye)=>k+Ye,0),A=R.flatMap(k=>k.hit.about==="node"?[k.hit.id]:[]),C=t.subject&&w.includes(String(n.graph.getNode(t.subject)?.kind))?kn(n,t.subject,r.words,{principal:d}):[];return{hits:[...m,...C],words:r.words,conditions:S,searched:ne?{...P,past:!0}:P,byKind:{...B},total:b,matched:A}},H=pe(),me=t.rank;if(!he||!me)return H;let be=L.filter(i=>!te.has(i.node.id)).map(({node:i,kind:s,definition:c})=>({id:i.id,kind:s,label:z(c,i),texts:Q(c,i)}));if(be.length===0)return H;let Xe=(async()=>{let i;try{i=await me(r.words,be)}catch{return H}let s=new Map(L.filter(h=>!te.has(h.node.id)).map(h=>[h.node.id,h])),c=!1;for(let{id:h,score:m,matched:b}of Array.isArray(i)?i:[]){let A=s.get(h);!A||!(m>0)||(s.delete(h),c=!0,K(A.node,A.kind,A.definition,A.current,gn(Q(A.definition,A.node),r.words,typeof b=="string"?b:void 0),Math.min(1,m)))}return c?pe():H})();return{...H,later:Xe}}function kn(n,e,t,o={}){let r=o.principal??{kind:"human"},a=(oe.keptFrom?.(n,r)?n.seenBy(r):n).graph.getNode(e);if(!a)return[];if(n.kindsKeptFrom(r).has(a.kind))return[];let d=T(t),f=z(n.schema.tryDefinition(a.kind),a),l=[];for(let g of n.allMutations()){let y=g.subject;if(!y||y.kinds!=="*"&&!y.kinds.includes(a.kind))continue;let x=g.derived?.act;if((x==="archive"||x==="merge")&&G(a)||x==="unarchive"&&!G(a)||x==="leave-alone"&&ie(a)||x==="allow-tidying"&&!ie(a)||!n.permits({name:g.name,args:{[y.arg]:a.id}},r).ok)continue;let p=Ae(g),O=T(p),w=d.filter(v=>O.some(D=>D.startsWith(v))),N=w.length>0?j(p,w):void 0,S=N?{field:"title",reading:"Act",fragment:p,strength:N}:{field:"subject",reading:"On",fragment:f,strength:"field"};l.push({hit:{about:"act",name:g.name,title:p,subject:a.id,why:S,destructive:g.destructive===!0},tier:N?I[N]:I.field+1,inKind:0,near:0,past:g.destructive?1:0,touched:0,flagged:g.pinned?0:1,name:p,id:`act:${g.name}`})}l.sort(qe);let u=l.map(g=>g.hit);return o.limit===void 0?u:u.slice(0,o.limit)}function En(n,e){let t=e.kinds.map((a,d)=>{let f=ge(n.tryDefinition(a),a);return d===0?f:f.toLowerCase()}),o=xe(t)||"Nothing";return e.kinds.some(a=>n.tryDefinition(a)?.lifecycle)?e.past?`${M(o)}, past ones included.`:`${M(o)}, current ones; add is:any for past ones.`:`${M(o)}.`}export{se as a,de as b,Je as c,Fe as d,Be as e,vn as f,On as g,Le as h,Ie as i,Pe as j,en as k,le as l,ce as m,an as n,_e as o,hn as p,Ln as q,kn as r,En as s};
@@ -1 +1 @@
1
- import{s as a}from"./chunk.5AGW4NRZ.js";import{G as f,R as s,_ as l}from"./chunk.Y4ZUJUUT.js";import{b as i}from"./chunk.AJZBJBMO.js";var d=i(f(),1),p=i(s(),1),c=new Set;function B(e){return c.add(e),()=>void c.delete(e)}function S(){let{store:e,principal:o}=l();return(0,d.useMemo)(()=>n=>{let t=n.on===void 0?void 0:e.graph.getNode(n.on);if(!t)return null;let u=[...c].filter(r=>r.store===e&&r.kind===t.kind);return(n.element?u.find(r=>r.root()?.contains(n.element)??!1):u[0])?.section(t.id,o)??null},[e,o])}function v({children:e}){let o=S(),n=(0,d.useMemo)(()=>[o],[o]);return(0,p.jsx)(a,{sections:n,children:e})}export{B as a,S as b,v as c};
1
+ import{s as a}from"./chunk.RQBEQYB2.js";import{G as f,R as s,_ as l}from"./chunk.KA44WNB4.js";import{b as i}from"./chunk.AJZBJBMO.js";var d=i(f(),1),p=i(s(),1),c=new Set;function B(e){return c.add(e),()=>void c.delete(e)}function S(){let{store:e,principal:o}=l();return(0,d.useMemo)(()=>n=>{let t=n.on===void 0?void 0:e.graph.getNode(n.on);if(!t)return null;let u=[...c].filter(r=>r.store===e&&r.kind===t.kind);return(n.element?u.find(r=>r.root()?.contains(n.element)??!1):u[0])?.section(t.id,o)??null},[e,o])}function v({children:e}){let o=S(),n=(0,d.useMemo)(()=>[o],[o]);return(0,p.jsx)(a,{sections:n,children:e})}export{B as a,S as b,v as c};
@@ -1,4 +1,4 @@
1
- var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as Se,b as $e,c as ze,d as $a,e as za,h as Ee,i as Ce,k as Ae,l as Te,m as Ea}from"./chunk.IYIN6VSN.js";import{c as ke}from"./chunk.VC3UGFHY.js";import{g as ya,h as ka}from"./chunk.IJNOT4S4.js";import"./chunk.AGIO2GRV.js";import{b as ma,c as fa,d as ye,e as ha}from"./chunk.VSNHCGKC.js";import{a as ba}from"./chunk.HJCQ6I3S.js";import{b as xa}from"./chunk.BNPQUI3F.js";import"./chunk.6RY6OSE6.js";import{b as la}from"./chunk.CTQULC5F.js";import{b as fe,d as xe,e as be}from"./chunk.TCXKPILZ.js";import"./chunk.64WM4IBI.js";import{b as he}from"./chunk.IQ2HKGJS.js";import"./chunk.R6V37SR7.js";import"./chunk.IROYMLER.js";import"./chunk.7NNI7YH4.js";import"./chunk.PKUDIWIF.js";import{p as va,q as wa,r as ua}from"./chunk.VW2VCPJX.js";import"./chunk.WBHM5I3I.js";import"./chunk.FOQ27RAR.js";import"./chunk.UKAPFIPJ.js";import"./chunk.UT6642FC.js";import{e as Sa}from"./chunk.FOJDVK2Q.js";import"./chunk.C44MC5X3.js";import"./chunk.TI4OSTQV.js";import"./chunk.Q7RQC3F7.js";import"./chunk.GZHZLJBF.js";import{c as oa,d as da,e as Z,o as sa}from"./chunk.5AGW4NRZ.js";import"./chunk.OJGHDWI6.js";import"./chunk.DQS7D2W2.js";import"./chunk.HDRD33II.js";import"./chunk.DX357TZ3.js";import"./chunk.H7KCWCB4.js";import{H as ca,b as Ye,e as ta,f as ia,j as Wa,m as na,o as pa,v as ga}from"./chunk.O4WEJ47H.js";import{Da as pe,G as O,Ka as ea,La as K,Oa as aa,R as f,Sa as ra,X as Xe,Z as Je,_ as S,aa as le,ha as Ze,i as ue,j as ne,m as Q,n as oe,o as me,r as de,x as je,y as se,z as Qe}from"./chunk.Y4ZUJUUT.js";import{a as j}from"./chunk.SDO3U72B.js";import{$b as Ve,U as _e,fa as Ue,ha as ie,uc as H,wc as P}from"./chunk.AS4CQBOQ.js";import"./chunk.2AZTW66C.js";import{b as p}from"./chunk.AJZBJBMO.js";function qa(e){return`
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 Se,b as $e,c as ze,d as $a,e as za,h as Ee,i as Ce,k as Ae,l as Te,m as Ea}from"./chunk.EXEZBZGW.js";import{c as ke}from"./chunk.NTLHEHOM.js";import{g as ya,h as ka}from"./chunk.V2GSBYDK.js";import"./chunk.NLBIX7LH.js";import{b as ma,c as fa,d as ye,e as ha}from"./chunk.GACKGEUY.js";import{a as ba}from"./chunk.HJCQ6I3S.js";import{b as xa}from"./chunk.KVEDIBXS.js";import"./chunk.7VT3TRHR.js";import{b as la}from"./chunk.VQAQQW4Q.js";import{b as fe,d as xe,e as be}from"./chunk.DWPU56S5.js";import"./chunk.7FRPNQU4.js";import{b as he}from"./chunk.BDHKWVNX.js";import"./chunk.ZH4NWRWB.js";import"./chunk.GUMJEVVP.js";import"./chunk.SAHNXAV3.js";import"./chunk.UGJSMNVO.js";import{p as va,q as wa,r as ua}from"./chunk.NR5ODXMO.js";import"./chunk.E5GM2SMO.js";import"./chunk.NQZ73QV7.js";import"./chunk.O45VO36H.js";import"./chunk.UT6642FC.js";import{e as Sa}from"./chunk.QO7MDWID.js";import"./chunk.FOP5RBGF.js";import"./chunk.TI4OSTQV.js";import"./chunk.MAFFUPCR.js";import"./chunk.GZHZLJBF.js";import{c as oa,d as da,e as Z,o as sa}from"./chunk.RQBEQYB2.js";import"./chunk.OJGHDWI6.js";import"./chunk.6VAFNCR4.js";import"./chunk.N4M54YK6.js";import"./chunk.KVJFY7N5.js";import"./chunk.DPHTUTOS.js";import{H as ca,b as Ye,e as ta,f as ia,j as Wa,m as na,o as pa,v as ga}from"./chunk.2UIUMG23.js";import{Da as pe,G as O,Ka as ea,La as K,Oa as aa,R as f,Sa as ra,X as Xe,Z as Je,_ as S,aa as le,ha as Ze,i as ue,j as ne,m as Q,n as oe,o as me,r as de,x as je,y as se,z as Qe}from"./chunk.KA44WNB4.js";import{a as j}from"./chunk.SDO3U72B.js";import{U as _e,ac as Ve,ga as Ue,ia as ie,vc as H,xc as P}from"./chunk.4TJOS4C7.js";import"./chunk.2AZTW66C.js";import{b as p}from"./chunk.AJZBJBMO.js";function qa(e){return`
2
2
 
3
3
 
4
4
  .graview-altitude-control {
@@ -1123,5 +1123,5 @@ var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=gl
1123
1123
  }
1124
1124
  [data-graview-connector][data-graview-activity] {
1125
1125
  animation: graview-relation 1200ms cubic-bezier(0.22, 1, 0.36, 1);
1126
- }`}function Me(e="dark",n={}){let s=qa(e);return n.scope===void 0?s:Ye(s,n.scope)}var B=p(O(),1);var W=p(f(),1),Fa=pe(j(()=>(__graviewPreload(import.meta.url,["./chunk.O4WEJ47H.js","./chunk.Y4ZUJUUT.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.EYI3Y2DY.js")))).part(e=>(0,W.jsx)(e.MapKey,{}),{quiet:!0});function Ie(){let{store:e}=S(),{view:n}=K(),s=le(),o=(0,B.useMemo)(()=>e.graph.allEdges().length>0,[e,s]),[r,v]=(0,B.useState)(!1),g=(0,B.useId)(),c=(0,B.useRef)(null),M=(0,B.useRef)(null);return(0,B.useEffect)(()=>{if(!r)return;let z=x=>{let I=x.target;I&&(M.current?.contains(I)||c.current?.contains(I))||v(!1)};return document.addEventListener("pointerdown",z,!0),()=>document.removeEventListener("pointerdown",z,!0)},[r]),o?(0,W.jsxs)("div",{style:{display:"contents"},onKeyDown:z=>{z.key!=="Escape"||!r||(z.preventDefault(),z.stopPropagation(),v(!1),c.current?.focus({preventScroll:!0}))},children:[(0,W.jsx)("button",{ref:c,type:"button","data-testid":"lines-key","aria-expanded":r,"aria-controls":g,title:"What the lines mean",onClick:()=>v(z=>!z),style:{position:"absolute",top:60,right:"calc(14px + var(--graview-dock, 0px))",zIndex:P("overview"),height:30,padding:"0 11px",borderRadius:8,borderColor:"transparent",fontSize:"0.8125rem",color:r?"var(--graview-accent)":"var(--graview-ink-muted)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-low)"},children:"Key"}),r?(0,W.jsxs)("div",{ref:M,id:g,"data-testid":"lines-key-pane","data-graview-offstage":"",style:{position:"absolute",top:98,right:"calc(14px + var(--graview-dock, 0px))",zIndex:P("rail"),width:za,maxHeight:"calc(100cqh - 120px)",overflowY:"auto",boxSizing:"border-box",padding:"8px 8px",borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)"},children:[n.overview?(0,W.jsx)(Fa,{}):null,(0,W.jsx)($a,{inside:!0,widthOf:ba})]}):null]}):null}var ce=p(O(),1),ge=p(f(),1);function Ca(e){return e.lens!==null?{what:"lens",kind:e.lens}:e.records.length===1&&e.districts.length===0?{what:"record",id:e.records[0]}:e.districts.length===1&&e.records.length===0?{what:"district",kind:e.districts[0]}:null}var Ga=pe(j(()=>(__graviewPreload(import.meta.url,["./chunk.IJNOT4S4.js","./chunk.O2WWYZI7.js","./chunk.VSNHCGKC.js","./chunk.HJCQ6I3S.js","./chunk.BNPQUI3F.js","./chunk.6RY6OSE6.js","./chunk.IROYMLER.js","./chunk.FWSCBHZ5.js","./chunk.7NNI7YH4.js","./chunk.7N2GXZYI.js","./chunk.PKUDIWIF.js","./chunk.VW2VCPJX.js","./chunk.WBHM5I3I.js","./chunk.FOQ27RAR.js","./chunk.UKAPFIPJ.js","./chunk.UT6642FC.js","./chunk.Q7RQC3F7.js","./chunk.WVUJXDXZ.js","./chunk.ZIEHF67C.js","./chunk.UHX4WTM7.js","./chunk.IKX4VDTW.js","./chunk.RNEJYIQ7.js","./chunk.TBQOSI4J.js","./chunk.KWQ7QOHD.js","./chunk.GZHZLJBF.js","./chunk.5AGW4NRZ.js","./chunk.OJGHDWI6.js","./chunk.DQS7D2W2.js","./chunk.HDRD33II.js","./chunk.DX357TZ3.js","./chunk.H7KCWCB4.js","./chunk.O4WEJ47H.js","./chunk.Y4ZUJUUT.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.RZF3QM4E.js")))),_a=Ga.part((e,n)=>(0,ge.jsx)(e.MapPanelFor,{showing:n.showing}),{what:"This panel",quiet:!0});function Re(){let{store:e,view:n,selection:s,hiddenKinds:o,seatTalk:r}=S();le();let v=(0,ce.useSyncExternalStore)(r.subscribe,()=>r.get().draft!==null,()=>!1);if(!n.overview||v)return null;let g=Ca(xa(s,{...n,beside:!0},c=>e.graph.getNode(c)?.kind));return!g||g.what!=="record"&&(o.has(g.kind)||!e.schema.kinds.includes(g.kind))?null:(0,ge.jsx)(ce.Suspense,{fallback:null,children:(0,ge.jsx)(_a,{showing:g})})}var Ua=p(O(),1);var D=p(f(),1);function Le(){let{view:e,go:n}=K(),{store:s,views:o,hiddenKinds:r}=S(),v=e.overview??!1,g=o.places().map($=>$.kind).filter($=>!r.has($)),c=ca(e,s.schema.kinds,g),M=()=>{n(ne(Q(e,!1),c))},z=(()=>{if(!c)return null;let $=je(c)[0],y=e.within?.view,C=(y?o.places().find(R=>R.as===y):void 0)??($?o.places().filter(R=>R.kind===$).at(-1):void 0);return C?C.title:$?ie(s.schema,$):s.graph.getNode(c)?.label??null})(),x=v?"Close the map":"Up",I=v&&z?`Close the map, down to ${z}`:x;return(0,D.jsxs)("button",{type:"button","data-testid":"overview",className:"graview-altitude-control","aria-pressed":v,"aria-label":I,title:v?I:"Up \u2014 the whole thing, from above",onClick:()=>v?M():n(Q(e,!0)),style:{position:"absolute",top:14,right:"calc(14px + var(--graview-dock, 0px))",zIndex:P("overview"),display:"inline-flex",alignItems:"center",justifyContent:"center",gap:7,height:38,padding:"0 13px 0 11px",borderRadius:8,borderColor:"transparent",fontSize:"0.875rem",whiteSpace:"nowrap",background:"var(--graview-float)",boxShadow:"var(--graview-lift-low)","--graview-altitude":v?1:0,...v?{color:"var(--graview-accent)"}:{}},children:[(0,D.jsxs)("svg",{className:"graview-altitude-mark",width:"16",height:"16",viewBox:"0 0 12 12","aria-hidden":"true",children:[(0,D.jsx)("ellipse",{className:"graview-altitude-mark-ring",cx:"6",cy:"6.6",rx:"5",ry:"2.6",fill:"none",stroke:"currentColor",strokeWidth:"0.9"}),(0,D.jsx)("circle",{className:"graview-altitude-mark-apex",cx:"6",cy:"4",r:"1.5",fill:"currentColor"}),(0,D.jsx)("circle",{className:"graview-altitude-mark-wing","data-side":"left",cx:"1.6",cy:"7.4",r:"1.2",fill:"currentColor"}),(0,D.jsx)("circle",{className:"graview-altitude-mark-wing","data-side":"right",cx:"10.4",cy:"7.4",r:"1.2",fill:"currentColor"})]}),(0,D.jsx)("span",{className:"graview-altitude-label",children:x})]})}var Ne=p(f(),1);function He(){let{administered:e}=S(),{view:n,go:s}=K(),o=e.filter(r=>r.canShow);return o.length===0?null:(0,Ne.jsx)("div",{role:"group","aria-label":"Administered","data-testid":"administered",style:{display:"flex",gap:6},children:o.map(r=>(0,Ne.jsx)("button",{type:"button","aria-pressed":r.shown,"data-testid":`show-${r.name}`,title:r.shown?`Hide the ${r.name}'s own districts again`:r.description??`Show the ${r.name}'s own districts beside the domain`,onClick:()=>s(ma(n,r.name,!r.shown)),style:{padding:"3px 11px",borderRadius:999,fontSize:"0.875rem",borderWidth:1,borderStyle:"solid",borderColor:r.shown?"var(--graview-accent)":"var(--graview-edge)",color:r.shown?"var(--graview-accent)":"var(--graview-ink-muted)",background:r.shown?"var(--graview-panel)":"transparent"},children:r.shown?`Hide the ${r.name}`:`Show the ${r.name}`},r.name))})}var h=p(O(),1);var l=p(f(),1);Xe({search:wa,touchWeights:va});var Va=e=>e.about==="rule"?"rule:":e.about==="act"?"act:":e.kind;function Ia({compact:e=!1}){let{store:n,view:s,setView:o,principal:r,setMenuAt:v,brand:g,aiDesk:c,selection:M}=S(),z=ia(c),x=Je(),I=ea(),$=sa().marks.flag,y=(0,h.useRef)(null),C=(0,h.useId)(),[R,m]=(0,h.useState)(!1),[F,ee]=(0,h.useState)(null),[J,ae]=(0,h.useState)(null),A=s.q??"";(0,h.useEffect)(()=>{let a=t=>{if(t.defaultPrevented)return;let i=t.key.toLowerCase()==="k"&&(t.metaKey||t.ctrlKey)&&!t.altKey&&!t.shiftKey,w=t.key==="/"&&!t.metaKey&&!t.ctrlKey&&!t.altKey;if(!i&&!w)return;let d=y.current;if(!d)return;let _=d.closest("[data-graview-embed]"),L=t.target,U=L===document.body||L===document.documentElement||L===window;if(_&&!(i&&U||L instanceof Node&&_.contains(L)))return;let V=document.activeElement,Ka=V instanceof HTMLInputElement||V instanceof HTMLTextAreaElement||V instanceof HTMLSelectElement||V instanceof HTMLElement&&V.isContentEditable;w&&Ka||(t.preventDefault(),d.getClientRects().length===0&&d.closest("[data-graview-app-bar]")?.querySelector('[data-testid="app-find-open"]')?.click(),d.focus({preventScroll:!0}),d.select(),m(!0))};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[]);let We=(0,h.useMemo)(()=>J&&A.trim()?ua(n,J,x?.words??A,{principal:r,limit:4}):[],[n,A,x,J,r]),ve=(0,h.useMemo)(()=>{let a=new Map;for(let[t,i]of(x?.hits??[]).entries()){if(i.about==="act")continue;let w=Va(i),d=a.get(w)??[];if(d.push({id:`${C}-${t}`,hit:i}),a.set(w,d),i.about==="node"&&i.id===J)for(let[_,L]of We.entries())d.push({id:`${C}-${t}-act-${_}`,hit:L})}return[...a.entries()]},[x,We,J,C]),N=z&&A.trim()?{id:`${C}-ask`,ask:A.trim()}:null,k=(0,h.useMemo)(()=>[...ve.flatMap(([,a])=>a),...N?[N]:[]],[ve,N?.ask]),T=k.find(a=>a.id===F)??k[0],qe=(x?.hits??[]).filter(a=>a.about==="node").length;(0,h.useEffect)(()=>{ee(null),ae(null)},[A]);let re=(0,h.useRef)(null);(0,h.useEffect)(()=>{let a=re.current;if(!a)return;re.current=null;let t=0,i=()=>{let w=document.querySelector(`[data-graview-view="aggregate:${CSS.escape(a)}"]`),d=document.activeElement;if(!(!d||d===document.body||d===document.documentElement||d===y.current||d===w))return;let L=[...w?.querySelectorAll('[role="group"][aria-label="Arrange"] :is(button, input)')??[]].find(U=>U.checkVisibility?.()??!0);if(L)return L.focus({preventScroll:!0});w&&w.tabIndex>=0&&d!==w&&w.focus({preventScroll:!0}),++t<240&&requestAnimationFrame(i)};requestAnimationFrame(i)},[s]);let G=a=>{if(a){if(ee(a.id),"ask"in a){ae(null);return}a.hit.about==="node"?ae(a.hit.id):a.hit.about!=="act"&&ae(null)}},Fe=a=>{let t=document.getElementById(C),i=t?.querySelector('[role="option"]')?.getBoundingClientRect().height??0,w=t?.clientHeight??0;return Math.min(a,i>0&&w>0?Math.max(1,Math.floor(w/i)-1):Xa)};(0,h.useEffect)(()=>{F&&document.getElementById(F)?.scrollIntoView?.({block:"nearest"})},[F]);let we=a=>{if(!a)return;if("ask"in a){ta(c,{pointed:{...M[0]!==void 0?{on:M[0]}:{},about:M},asked:a.ask}),o(i=>ye(i)),m(!1);return}let t=a.hit;switch(t.about){case"node":o(i=>oe(ne(Q(i,!1),t.id),[t.id]));break;case"kind":o(i=>se(Q(i,!1),de(t.kind),{ownPicture:!0})),re.current=t.kind;break;case"place":o(i=>Qe(i,t.kind,t.as)),re.current=t.kind;break;case"rule":{let i=I.filter(w=>w.invariant===t.name).flatMap(w=>w.nodeIds);o(w=>oe(w,[...new Set(i)]));break}case"act":{o(w=>oe(w,[t.subject]));let i=y.current?.getBoundingClientRect();v({x:i?.left??0,y:(i?.bottom??0)+6,on:t.subject});break}}m(!1),y.current?.blur()},Da=x?Ya(x.byKind,x.hits,n.schema):"",te=R&&A.trim().length>0,Oa=(0,h.useCallback)(()=>{let a=y.current?.closest("[data-graview-app-bar]")?.getBoundingClientRect();if(a)return{x:a.right,y:a.bottom-Za};let t=y.current?.getBoundingClientRect();return t?{x:t.right,y:t.bottom}:null},[]),Ge=ra("find",{open:te,onOpenChange:a=>{a||m(!1)},...e?{at:Oa}:{}});return(0,l.jsxs)("div",{style:{position:"relative",minWidth:0,flex:"1 1 auto"},"data-testid":"find",children:[(0,l.jsx)("input",{ref:a=>{y.current=a,Ge.trigger.ref(a)},"data-graview-popover-trigger":"find",type:"search",role:"combobox","aria-label":"Find anything","aria-expanded":te,"aria-controls":C,"aria-autocomplete":"list",...te&&T?{"aria-activedescendant":T.id}:{},"data-testid":"find-box",placeholder:"Find\u2026","aria-keyshortcuts":"/ Meta+K Control+K",value:A,onChange:a=>{let t=a.target.value;m(!0),o(i=>fa(i,t.length>0?t:null))},onFocus:()=>m(!0),onBlur:()=>m(!1),onKeyDown:a=>{let t=F!==null&&T?k.indexOf(T):-1,i=d=>d!==void 0&&!("ask"in d)&&d.hit.about==="act",w=t>=0&&T!==void 0&&!("ask"in T)&&T.hit.about==="node";if(a.key==="ArrowDown"){a.preventDefault(),m(!0);let d=t+1;if(w)for(;d<k.length-1&&i(k[d]);)d+=1;G(k[Math.min(k.length-1,d)])}else if(a.key==="ArrowUp")a.preventDefault(),G(k[Math.max(0,t-1)]);else if((a.key==="PageDown"||a.key==="PageUp")&&k.length>0){a.preventDefault(),m(!0);let d=k.flatMap((U,V)=>i(U)?[]:[V]),_=Math.max(0,d.findIndex(U=>U>=Math.max(t,0))),L=a.key==="PageDown"?Fe(k.length):-Fe(k.length);G(k[d[Math.min(d.length-1,Math.max(0,(t<0?-1:_)+L))]])}else if(a.key==="ArrowRight"&&w&&i(k[t+1]))a.preventDefault(),G(k[t+1]);else if(a.key==="ArrowLeft"&&i(T)){a.preventDefault();let d=t-1;for(;d>0&&i(k[d]);)d-=1;G(k[d])}else a.key==="Enter"?(a.preventDefault(),we(T)):a.key==="Escape"&&(a.preventDefault(),A?o(d=>ye(d)):y.current?.blur())},style:{width:"100%",boxSizing:"border-box",minWidth:0,height:30,padding:"0 var(--graview-bar-find-end, 10px) 0 10px",font:"inherit",fontSize:"0.875rem",color:"var(--graview-ink)",background:"var(--graview-panel)",border:`1px solid ${A?"var(--graview-accent)":"var(--graview-edge)"}`,borderRadius:8}}),(0,l.jsx)("span",{role:"status","aria-live":"polite",style:na,"data-testid":"find-count",children:A.trim()?Da:""}),(0,l.jsxs)("div",{...Ge.pane,id:C,role:"listbox","aria-label":A?`What \u201C${A}\u201D finds`:"What the words find","data-testid":"find-strip",hidden:!te,onMouseDown:a=>a.preventDefault(),style:e?{...Ta,...er}:Ta,children:[k.every(a=>"ask"in a)?(0,l.jsxs)("p",{role:"presentation",style:{margin:0,padding:"10px 12px",color:"var(--graview-ink-muted)",fontSize:"0.875rem"},"data-testid":"find-nothing",children:["Nothing here is called \u201C",x?.words||A,"\u201D."]}):ve.map(([a,t])=>(0,l.jsxs)("div",{role:"group","aria-label":Aa(a,n.schema),children:[(0,l.jsxs)("div",{role:"presentation",style:ar,children:[a!=="rule:"?(0,l.jsx)(Qa,{kind:a,accents:g?.accents}):null,Aa(a,n.schema)]}),t.map(i=>(0,l.jsx)("div",{id:i.id,role:"option","aria-selected":i===T,"data-testid":"find-hit","data-about":i.hit.about,...i.hit.about==="node"&&i.hit.near?{"data-near":""}:{},onMouseEnter:()=>G(i),onClick:()=>we(i),style:{...Ma,...i.hit.about==="act"?{paddingLeft:30}:{},background:i===T?"var(--graview-panel-muted)":"transparent"},children:(0,l.jsx)(ja,{hit:i.hit,flag:$})},i.id))]},a)),N?(0,l.jsx)("div",{id:N.id,role:"option","aria-selected":N===T||T?.id===N.id,"data-testid":"find-ask",onMouseEnter:()=>G(N),onClick:()=>we(N),style:{...Ma,borderTop:"1px solid var(--graview-edge)",marginTop:4,background:T?.id===N.id?"var(--graview-panel-muted)":"transparent"},children:(0,l.jsxs)("span",{children:["Ask: ",(0,l.jsxs)("span",{style:{fontWeight:600},children:["\u2018",N.ask,"\u2019"]})]})}):null,qe>Ja?(0,l.jsxs)("p",{role:"presentation",style:{margin:0,padding:"6px 12px 2px",color:"var(--graview-ink-faint)",fontSize:"0.75rem"},"data-testid":"find-more-words",children:[_e(qe)," found: another word of the name narrows them."]}):null,x&&x.searched.past===!1&&x.searched.kinds.some(a=>n.schema.tryDefinition(a)?.lifecycle)?(0,l.jsx)("p",{role:"presentation",style:{margin:0,padding:"6px 12px 8px",color:"var(--graview-ink-faint)",fontSize:"0.75rem"},children:"Current ones; add is:any for the past."}):null]})]})}function ja({hit:e,flag:n}){switch(e.about){case"node":return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("span",{style:{fontWeight:600,overflowWrap:"anywhere"},children:[e.flagged?(0,l.jsxs)("span",{style:{color:"var(--graview-warn)"},children:[n," "]}):null,e.label,e.apart?(0,l.jsxs)("span",{style:Y,children:[" \xB7 ",e.apart]}):null,e.current?null:(0,l.jsx)("span",{style:Y,children:" \xB7 past"})]}),e.near?(0,l.jsxs)("span",{style:Y,"data-testid":"find-near",children:["Near \u201C",e.why.asked,"\u201D",e.why.field!=="label"?` \u2014 ${e.why.reading.toLowerCase()}: ${e.why.fragment}`:""]}):e.why.field!=="label"?(0,l.jsxs)("span",{style:Y,children:[e.why.reading.toLowerCase(),": ",e.why.fragment]}):null]});case"kind":return(0,l.jsxs)("span",{children:[e.label,(0,l.jsxs)("span",{style:Y,children:[" \xB7 ",e.count," match"]})]});case"place":return(0,l.jsxs)("span",{children:["Go to ",e.title]});case"rule":return(0,l.jsxs)("span",{children:["The rule \u201C",e.label,"\u201D"]});case"act":return(0,l.jsxs)("span",{style:e.destructive?{color:"var(--graview-warn)"}:void 0,children:[e.title,(0,l.jsxs)("span",{style:Y,children:[" \xB7 ",e.why.field==="title"?"act":`on ${e.why.fragment}`]})]})}}function Qa({kind:e,accents:n}){let s=Math.round(Ve(e,n));return(0,l.jsx)("span",{"aria-hidden":"true",style:{width:8,height:8,borderRadius:2,flex:"0 0 auto",background:`hsl(${s} 55% 52%)`}})}function Aa(e,n){return e==="rule:"?"Rules":e==="act:"?"Acts":n.tryDefinition(e)?.plural??`${e}s`}function Ya(e,n,s){let o=Object.entries(e).map(([g,c])=>Ue(s,g,c)),r=n.filter(g=>g.about==="kind"||g.about==="place"||g.about==="rule").length;r>0&&o.push(`${r} ${r===1?"place or rule":"places and rules"}`);let v=n.filter(g=>g.about==="node"&&g.near).length;return o.length===0?"Nothing found":`${o.join(", ")} found${v>0?`, ${v} of them near`:""}`}var Xa=10,Ja=12,Ta={...aa,width:"min(26rem, calc(100vw - 24px))",maxHeight:"min(60vh, 28rem)",overflowY:"auto",boxSizing:"border-box",background:"var(--graview-panel)",borderTop:"1px solid var(--graview-edge)",borderRight:"1px solid var(--graview-edge)",borderBottom:"1px solid var(--graview-edge)",borderLeft:"1px solid var(--graview-edge)",borderRadius:10,boxShadow:"0 10px 28px rgb(0 0 0 / 0.18)",padding:"4px 0"},Za=6,er={width:"var(--graview-bar-width, 100vw)",maxHeight:"55vh",borderRadius:0,borderLeft:"none",borderRight:"none"},ar={display:"flex",alignItems:"center",gap:6,padding:"8px 12px 2px",fontSize:"0.6875rem",letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--graview-ink-muted)"},Ma={display:"grid",gap:1,minHeight:32,padding:"5px 12px",alignContent:"center",cursor:"pointer",fontSize:"0.875rem",lineHeight:1.35,color:"var(--graview-ink)"},Y={color:"var(--graview-ink-muted)",fontSize:"0.8125rem",fontWeight:400};var X=p(O(),1);var Be=p(Wa(),1);var La=p(f(),1);function Ra(){let{following:e,follow:n}=S();return e?(0,La.jsxs)("button",{type:"button","data-testid":"following-who",onClick:()=>n(null),title:"Press, or Escape, to stop following",style:{display:"inline-flex",alignItems:"center",gap:6,minHeight:24,padding:"2px 9px",borderRadius:999,border:"1px solid var(--graview-accent)",background:"transparent",color:"var(--graview-accent)",fontSize:"0.875rem",whiteSpace:"nowrap"},children:["following ",e.name]}):null}var Na=p(O(),1);var b=p(f(),1);function Ha({home:e,homeLabel:n,children:s,onPicture:o=!1}){let{view:r,focus:v,show:g,go:c}=K(),{store:M}=S(),{movedByHand:z}=S(),x=z&&(r.pan!==void 0||Object.keys(r.pins).length>0),I=r.focusId&&r.focusId!==e?M.graph.getNode(r.focusId):void 0,$=m=>ie(M.schema,m),y={display:"inline-flex",alignItems:"center",gap:6,minHeight:26,padding:"2px 6px",fontSize:"0.8125rem",borderRadius:6,border:"1px solid transparent",boxShadow:"none",background:"transparent",color:"var(--graview-ink-muted)",whiteSpace:"nowrap"},C=n!==void 0&&I!==void 0,R=[];if(I&&!o&&R.push({key:"focused",node:(0,b.jsxs)("button",{type:"button","data-testid":"focused",onClick:()=>c(me({...r,focusId:e},!1)),title:he(M,I.id),style:{...y,maxWidth:"min(14rem, 15vw)"},children:[(0,b.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:he(M,I.id)}),(0,b.jsx)("span",{"aria-hidden":"true",style:{opacity:.7},children:"\xD7"})]})}),r.past&&R.push({key:"past",node:(0,b.jsxs)("button",{type:"button","data-testid":"past",onClick:()=>c(ha(r,!1)),title:"Back to now \u2014 retired things leave the picture again",style:y,children:["the past",(0,b.jsx)("span",{"aria-hidden":"true",style:{opacity:.7},children:"\xD7"})]})}),r.zoom&&R.push({key:"zoomed",node:(0,b.jsxs)("button",{type:"button","data-testid":"zoomed",onClick:()=>c(me(r,!1)),title:"Zoom back out",style:y,children:["zoomed in",(0,b.jsx)("span",{"aria-hidden":"true",style:{opacity:.7},children:"\xD7"})]})}),x&&R.push({key:"moved",node:(0,b.jsx)("button",{type:"button","data-testid":"moved",onClick:()=>c(ue(r)),title:"Put the camera and everything you dragged back where the layout wanted them",style:y,children:"Reset view"})}),r.relation){let m=r.relation;R.push({key:"raised",node:(0,b.jsxs)("span",{style:{display:"inline-flex",alignItems:"center"},children:[(0,b.jsxs)("button",{type:"button","data-testid":"raised-into",onClick:()=>c(se(r,de(m),{ownPicture:!0})),title:`Go into the ${$(m).toLowerCase()}`,"aria-label":`Go into the ${$(m).toLowerCase()}`,style:{...y,color:"var(--graview-ink)"},children:[$(m),(0,b.jsx)("span",{"aria-hidden":"true",style:{opacity:.7},children:"\u2198"})]}),(0,b.jsx)("button",{type:"button","data-testid":"raised",onClick:()=>g(null),title:`Stop showing ${$(m).toLowerCase()}`,"aria-label":`Stop showing ${$(m).toLowerCase()}`,style:{...y,minWidth:26,justifyContent:"center"},children:(0,b.jsx)("span",{"aria-hidden":"true",style:{opacity:.7},children:"\xD7"})})]})})}return o&&!C&&R.length===0&&s===void 0?null:(0,b.jsxs)("nav",{"aria-label":"View","data-testid":"trail",style:{display:"flex",alignItems:"center",gap:8,fontSize:"0.875rem",minWidth:0,...o?{pointerEvents:"auto",padding:"4px 6px",borderRadius:8,background:"var(--graview-float)",boxShadow:"var(--graview-lift-low)",overflow:"hidden"}:{}},children:[C?(0,b.jsx)("button",{type:"button",onClick:()=>v(e),style:{border:"none",background:"none",padding:"3px 0",minHeight:24,whiteSpace:"nowrap",color:"var(--graview-ink-muted)"},children:n}):null,R.map(({key:m,node:F},ee)=>(0,b.jsxs)(Na.Fragment,{children:[C||ee>0?(0,b.jsx)("span",{style:{color:"var(--graview-ink-faint)"},children:"\u203A"}):null,F]},m)),s]})}var E=p(f(),1);function Pe(){let[e,n]=(0,X.useState)([]),s=(0,X.useCallback)(o=>{n(r=>{let v=o.phase!=="running"&&r[0]?.name===o.name&&r[0]?.at===o.at;return[o,...v?r.slice(1):r].slice(0,12)})},[]);return[e,s]}function De({find:e,calls:n,seat:s,remembers:o=!1}){return e?(0,E.jsxs)(E.Fragment,{children:[(0,Be.createPortal)((0,E.jsx)(Ia,{compact:e.compact}),e.slot),e.own?(0,Be.createPortal)((0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(X.Suspense,{fallback:null,children:(0,E.jsx)(Ea,{})}),(0,E.jsx)(la,{calls:n,remembers:o,...s!==void 0?{seat:s}:{}})]}),e.own):null]}):null}function Oe({home:e=null}){return(0,E.jsxs)("div",{"data-graview-scene-trail":"",style:{position:"absolute",top:14,left:14,maxWidth:"calc(100% - 150px - var(--graview-dock, 0px))",zIndex:P("overview"),display:"flex",alignItems:"center",gap:6,minWidth:0,pointerEvents:"none"},children:[(0,E.jsx)(Ha,{home:e,onPicture:!0}),(0,E.jsx)("span",{style:{pointerEvents:"auto"},children:(0,E.jsx)(Ra,{})})]})}var q=p(O(),1);var Ba=p(f(),1),rr=j(()=>(__graviewPreload(import.meta.url,["./chunk.UGFDSE37.js","./chunk.O4WEJ47H.js","./chunk.Y4ZUJUUT.js","./chunk.SDO3U72B.js","./chunk.AS4CQBOQ.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.S5IQFZ5Z.js")));function Ke(){let{store:e,principal:n}=S(),s=(0,q.useContext)(pa),o=(0,q.useRef)(null),r=(0,q.useRef)(!1);return(0,q.useEffect)(()=>()=>void(r.current=!0),[]),(0,q.useEffect)(()=>{let v=e.batches().length,g=rr().then(c=>c.sceneWay(e,n,s,v,o.current),()=>{});return()=>void g.then(c=>c?.(r.current))},[e,n,s]),(0,Ba.jsx)("span",{ref:o,hidden:!0})}var Pa=p(O(),1);var u=p(f(),1);function Ht({address:e=!1,auto:n,quickAsk:s=!0,scheme:o,scope:r}){let v=(0,Pa.useMemo)(()=>`${Te({scope:`.${r}`})}
1126
+ }`}function Me(e="dark",n={}){let s=qa(e);return n.scope===void 0?s:Ye(s,n.scope)}var B=p(O(),1);var W=p(f(),1),Fa=pe(j(()=>(__graviewPreload(import.meta.url,["./chunk.2UIUMG23.js","./chunk.KA44WNB4.js","./chunk.SDO3U72B.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.HC5N3CT2.js")))).part(e=>(0,W.jsx)(e.MapKey,{}),{quiet:!0});function Ie(){let{store:e}=S(),{view:n}=K(),s=le(),o=(0,B.useMemo)(()=>e.graph.allEdges().length>0,[e,s]),[r,v]=(0,B.useState)(!1),g=(0,B.useId)(),c=(0,B.useRef)(null),M=(0,B.useRef)(null);return(0,B.useEffect)(()=>{if(!r)return;let z=x=>{let I=x.target;I&&(M.current?.contains(I)||c.current?.contains(I))||v(!1)};return document.addEventListener("pointerdown",z,!0),()=>document.removeEventListener("pointerdown",z,!0)},[r]),o?(0,W.jsxs)("div",{style:{display:"contents"},onKeyDown:z=>{z.key!=="Escape"||!r||(z.preventDefault(),z.stopPropagation(),v(!1),c.current?.focus({preventScroll:!0}))},children:[(0,W.jsx)("button",{ref:c,type:"button","data-testid":"lines-key","aria-expanded":r,"aria-controls":g,title:"What the lines mean",onClick:()=>v(z=>!z),style:{position:"absolute",top:60,right:"calc(14px + var(--graview-dock, 0px))",zIndex:P("overview"),height:30,padding:"0 11px",borderRadius:8,borderColor:"transparent",fontSize:"0.8125rem",color:r?"var(--graview-accent)":"var(--graview-ink-muted)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-low)"},children:"Key"}),r?(0,W.jsxs)("div",{ref:M,id:g,"data-testid":"lines-key-pane","data-graview-offstage":"",style:{position:"absolute",top:98,right:"calc(14px + var(--graview-dock, 0px))",zIndex:P("rail"),width:za,maxHeight:"calc(100cqh - 120px)",overflowY:"auto",boxSizing:"border-box",padding:"8px 8px",borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)"},children:[n.overview?(0,W.jsx)(Fa,{}):null,(0,W.jsx)($a,{inside:!0,widthOf:ba})]}):null]}):null}var ce=p(O(),1),ge=p(f(),1);function Ca(e){return e.lens!==null?{what:"lens",kind:e.lens}:e.records.length===1&&e.districts.length===0?{what:"record",id:e.records[0]}:e.districts.length===1&&e.records.length===0?{what:"district",kind:e.districts[0]}:null}var Ga=pe(j(()=>(__graviewPreload(import.meta.url,["./chunk.V2GSBYDK.js","./chunk.XTMOFRHL.js","./chunk.GACKGEUY.js","./chunk.HJCQ6I3S.js","./chunk.KVEDIBXS.js","./chunk.7VT3TRHR.js","./chunk.GUMJEVVP.js","./chunk.4VW6THJF.js","./chunk.SAHNXAV3.js","./chunk.DHAK6PPX.js","./chunk.UGJSMNVO.js","./chunk.NR5ODXMO.js","./chunk.E5GM2SMO.js","./chunk.NQZ73QV7.js","./chunk.O45VO36H.js","./chunk.UT6642FC.js","./chunk.MAFFUPCR.js","./chunk.WVUJXDXZ.js","./chunk.TPG6IY4M.js","./chunk.NFDLCUCC.js","./chunk.X7JMJSLU.js","./chunk.PPRSGM64.js","./chunk.5Y3Q7ONN.js","./chunk.KTFUVR4V.js","./chunk.GZHZLJBF.js","./chunk.RQBEQYB2.js","./chunk.OJGHDWI6.js","./chunk.6VAFNCR4.js","./chunk.N4M54YK6.js","./chunk.KVJFY7N5.js","./chunk.DPHTUTOS.js","./chunk.2UIUMG23.js","./chunk.KA44WNB4.js","./chunk.SDO3U72B.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.CJ23XTSW.js")))),_a=Ga.part((e,n)=>(0,ge.jsx)(e.MapPanelFor,{showing:n.showing}),{what:"This panel",quiet:!0});function Re(){let{store:e,view:n,selection:s,hiddenKinds:o,seatTalk:r}=S();le();let v=(0,ce.useSyncExternalStore)(r.subscribe,()=>r.get().draft!==null,()=>!1);if(!n.overview||v)return null;let g=Ca(xa(s,{...n,beside:!0},c=>e.graph.getNode(c)?.kind));return!g||g.what!=="record"&&(o.has(g.kind)||!e.schema.kinds.includes(g.kind))?null:(0,ge.jsx)(ce.Suspense,{fallback:null,children:(0,ge.jsx)(_a,{showing:g})})}var Ua=p(O(),1);var D=p(f(),1);function Le(){let{view:e,go:n}=K(),{store:s,views:o,hiddenKinds:r}=S(),v=e.overview??!1,g=o.places().map($=>$.kind).filter($=>!r.has($)),c=ca(e,s.schema.kinds,g),M=()=>{n(ne(Q(e,!1),c))},z=(()=>{if(!c)return null;let $=je(c)[0],y=e.within?.view,C=(y?o.places().find(R=>R.as===y):void 0)??($?o.places().filter(R=>R.kind===$).at(-1):void 0);return C?C.title:$?ie(s.schema,$):s.graph.getNode(c)?.label??null})(),x=v?"Close the map":"Up",I=v&&z?`Close the map, down to ${z}`:x;return(0,D.jsxs)("button",{type:"button","data-testid":"overview",className:"graview-altitude-control","aria-pressed":v,"aria-label":I,title:v?I:"Up \u2014 the whole thing, from above",onClick:()=>v?M():n(Q(e,!0)),style:{position:"absolute",top:14,right:"calc(14px + var(--graview-dock, 0px))",zIndex:P("overview"),display:"inline-flex",alignItems:"center",justifyContent:"center",gap:7,height:38,padding:"0 13px 0 11px",borderRadius:8,borderColor:"transparent",fontSize:"0.875rem",whiteSpace:"nowrap",background:"var(--graview-float)",boxShadow:"var(--graview-lift-low)","--graview-altitude":v?1:0,...v?{color:"var(--graview-accent)"}:{}},children:[(0,D.jsxs)("svg",{className:"graview-altitude-mark",width:"16",height:"16",viewBox:"0 0 12 12","aria-hidden":"true",children:[(0,D.jsx)("ellipse",{className:"graview-altitude-mark-ring",cx:"6",cy:"6.6",rx:"5",ry:"2.6",fill:"none",stroke:"currentColor",strokeWidth:"0.9"}),(0,D.jsx)("circle",{className:"graview-altitude-mark-apex",cx:"6",cy:"4",r:"1.5",fill:"currentColor"}),(0,D.jsx)("circle",{className:"graview-altitude-mark-wing","data-side":"left",cx:"1.6",cy:"7.4",r:"1.2",fill:"currentColor"}),(0,D.jsx)("circle",{className:"graview-altitude-mark-wing","data-side":"right",cx:"10.4",cy:"7.4",r:"1.2",fill:"currentColor"})]}),(0,D.jsx)("span",{className:"graview-altitude-label",children:x})]})}var Ne=p(f(),1);function He(){let{administered:e}=S(),{view:n,go:s}=K(),o=e.filter(r=>r.canShow);return o.length===0?null:(0,Ne.jsx)("div",{role:"group","aria-label":"Administered","data-testid":"administered",style:{display:"flex",gap:6},children:o.map(r=>(0,Ne.jsx)("button",{type:"button","aria-pressed":r.shown,"data-testid":`show-${r.name}`,title:r.shown?`Hide the ${r.name}'s own districts again`:r.description??`Show the ${r.name}'s own districts beside the domain`,onClick:()=>s(ma(n,r.name,!r.shown)),style:{padding:"3px 11px",borderRadius:999,fontSize:"0.875rem",borderWidth:1,borderStyle:"solid",borderColor:r.shown?"var(--graview-accent)":"var(--graview-edge)",color:r.shown?"var(--graview-accent)":"var(--graview-ink-muted)",background:r.shown?"var(--graview-panel)":"transparent"},children:r.shown?`Hide the ${r.name}`:`Show the ${r.name}`},r.name))})}var h=p(O(),1);var l=p(f(),1);Xe({search:wa,touchWeights:va});var Va=e=>e.about==="rule"?"rule:":e.about==="act"?"act:":e.kind;function Ia({compact:e=!1}){let{store:n,view:s,setView:o,principal:r,setMenuAt:v,brand:g,aiDesk:c,selection:M}=S(),z=ia(c),x=Je(),I=ea(),$=sa().marks.flag,y=(0,h.useRef)(null),C=(0,h.useId)(),[R,m]=(0,h.useState)(!1),[F,ee]=(0,h.useState)(null),[J,ae]=(0,h.useState)(null),A=s.q??"";(0,h.useEffect)(()=>{let a=t=>{if(t.defaultPrevented)return;let i=t.key.toLowerCase()==="k"&&(t.metaKey||t.ctrlKey)&&!t.altKey&&!t.shiftKey,w=t.key==="/"&&!t.metaKey&&!t.ctrlKey&&!t.altKey;if(!i&&!w)return;let d=y.current;if(!d)return;let _=d.closest("[data-graview-embed]"),L=t.target,U=L===document.body||L===document.documentElement||L===window;if(_&&!(i&&U||L instanceof Node&&_.contains(L)))return;let V=document.activeElement,Ka=V instanceof HTMLInputElement||V instanceof HTMLTextAreaElement||V instanceof HTMLSelectElement||V instanceof HTMLElement&&V.isContentEditable;w&&Ka||(t.preventDefault(),d.getClientRects().length===0&&d.closest("[data-graview-app-bar]")?.querySelector('[data-testid="app-find-open"]')?.click(),d.focus({preventScroll:!0}),d.select(),m(!0))};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[]);let We=(0,h.useMemo)(()=>J&&A.trim()?ua(n,J,x?.words??A,{principal:r,limit:4}):[],[n,A,x,J,r]),ve=(0,h.useMemo)(()=>{let a=new Map;for(let[t,i]of(x?.hits??[]).entries()){if(i.about==="act")continue;let w=Va(i),d=a.get(w)??[];if(d.push({id:`${C}-${t}`,hit:i}),a.set(w,d),i.about==="node"&&i.id===J)for(let[_,L]of We.entries())d.push({id:`${C}-${t}-act-${_}`,hit:L})}return[...a.entries()]},[x,We,J,C]),N=z&&A.trim()?{id:`${C}-ask`,ask:A.trim()}:null,k=(0,h.useMemo)(()=>[...ve.flatMap(([,a])=>a),...N?[N]:[]],[ve,N?.ask]),T=k.find(a=>a.id===F)??k[0],qe=(x?.hits??[]).filter(a=>a.about==="node").length;(0,h.useEffect)(()=>{ee(null),ae(null)},[A]);let re=(0,h.useRef)(null);(0,h.useEffect)(()=>{let a=re.current;if(!a)return;re.current=null;let t=0,i=()=>{let w=document.querySelector(`[data-graview-view="aggregate:${CSS.escape(a)}"]`),d=document.activeElement;if(!(!d||d===document.body||d===document.documentElement||d===y.current||d===w))return;let L=[...w?.querySelectorAll('[role="group"][aria-label="Arrange"] :is(button, input)')??[]].find(U=>U.checkVisibility?.()??!0);if(L)return L.focus({preventScroll:!0});w&&w.tabIndex>=0&&d!==w&&w.focus({preventScroll:!0}),++t<240&&requestAnimationFrame(i)};requestAnimationFrame(i)},[s]);let G=a=>{if(a){if(ee(a.id),"ask"in a){ae(null);return}a.hit.about==="node"?ae(a.hit.id):a.hit.about!=="act"&&ae(null)}},Fe=a=>{let t=document.getElementById(C),i=t?.querySelector('[role="option"]')?.getBoundingClientRect().height??0,w=t?.clientHeight??0;return Math.min(a,i>0&&w>0?Math.max(1,Math.floor(w/i)-1):Xa)};(0,h.useEffect)(()=>{F&&document.getElementById(F)?.scrollIntoView?.({block:"nearest"})},[F]);let we=a=>{if(!a)return;if("ask"in a){ta(c,{pointed:{...M[0]!==void 0?{on:M[0]}:{},about:M},asked:a.ask}),o(i=>ye(i)),m(!1);return}let t=a.hit;switch(t.about){case"node":o(i=>oe(ne(Q(i,!1),t.id),[t.id]));break;case"kind":o(i=>se(Q(i,!1),de(t.kind),{ownPicture:!0})),re.current=t.kind;break;case"place":o(i=>Qe(i,t.kind,t.as)),re.current=t.kind;break;case"rule":{let i=I.filter(w=>w.invariant===t.name).flatMap(w=>w.nodeIds);o(w=>oe(w,[...new Set(i)]));break}case"act":{o(w=>oe(w,[t.subject]));let i=y.current?.getBoundingClientRect();v({x:i?.left??0,y:(i?.bottom??0)+6,on:t.subject});break}}m(!1),y.current?.blur()},Da=x?Ya(x.byKind,x.hits,n.schema):"",te=R&&A.trim().length>0,Oa=(0,h.useCallback)(()=>{let a=y.current?.closest("[data-graview-app-bar]")?.getBoundingClientRect();if(a)return{x:a.right,y:a.bottom-Za};let t=y.current?.getBoundingClientRect();return t?{x:t.right,y:t.bottom}:null},[]),Ge=ra("find",{open:te,onOpenChange:a=>{a||m(!1)},...e?{at:Oa}:{}});return(0,l.jsxs)("div",{style:{position:"relative",minWidth:0,flex:"1 1 auto"},"data-testid":"find",children:[(0,l.jsx)("input",{ref:a=>{y.current=a,Ge.trigger.ref(a)},"data-graview-popover-trigger":"find",type:"search",role:"combobox","aria-label":"Find anything","aria-expanded":te,"aria-controls":C,"aria-autocomplete":"list",...te&&T?{"aria-activedescendant":T.id}:{},"data-testid":"find-box",placeholder:"Find\u2026","aria-keyshortcuts":"/ Meta+K Control+K",value:A,onChange:a=>{let t=a.target.value;m(!0),o(i=>fa(i,t.length>0?t:null))},onFocus:()=>m(!0),onBlur:()=>m(!1),onKeyDown:a=>{let t=F!==null&&T?k.indexOf(T):-1,i=d=>d!==void 0&&!("ask"in d)&&d.hit.about==="act",w=t>=0&&T!==void 0&&!("ask"in T)&&T.hit.about==="node";if(a.key==="ArrowDown"){a.preventDefault(),m(!0);let d=t+1;if(w)for(;d<k.length-1&&i(k[d]);)d+=1;G(k[Math.min(k.length-1,d)])}else if(a.key==="ArrowUp")a.preventDefault(),G(k[Math.max(0,t-1)]);else if((a.key==="PageDown"||a.key==="PageUp")&&k.length>0){a.preventDefault(),m(!0);let d=k.flatMap((U,V)=>i(U)?[]:[V]),_=Math.max(0,d.findIndex(U=>U>=Math.max(t,0))),L=a.key==="PageDown"?Fe(k.length):-Fe(k.length);G(k[d[Math.min(d.length-1,Math.max(0,(t<0?-1:_)+L))]])}else if(a.key==="ArrowRight"&&w&&i(k[t+1]))a.preventDefault(),G(k[t+1]);else if(a.key==="ArrowLeft"&&i(T)){a.preventDefault();let d=t-1;for(;d>0&&i(k[d]);)d-=1;G(k[d])}else a.key==="Enter"?(a.preventDefault(),we(T)):a.key==="Escape"&&(a.preventDefault(),A?o(d=>ye(d)):y.current?.blur())},style:{width:"100%",boxSizing:"border-box",minWidth:0,height:30,padding:"0 var(--graview-bar-find-end, 10px) 0 10px",font:"inherit",fontSize:"0.875rem",color:"var(--graview-ink)",background:"var(--graview-panel)",border:`1px solid ${A?"var(--graview-accent)":"var(--graview-edge)"}`,borderRadius:8}}),(0,l.jsx)("span",{role:"status","aria-live":"polite",style:na,"data-testid":"find-count",children:A.trim()?Da:""}),(0,l.jsxs)("div",{...Ge.pane,id:C,role:"listbox","aria-label":A?`What \u201C${A}\u201D finds`:"What the words find","data-testid":"find-strip",hidden:!te,onMouseDown:a=>a.preventDefault(),style:e?{...Ta,...er}:Ta,children:[k.every(a=>"ask"in a)?(0,l.jsxs)("p",{role:"presentation",style:{margin:0,padding:"10px 12px",color:"var(--graview-ink-muted)",fontSize:"0.875rem"},"data-testid":"find-nothing",children:["Nothing here is called \u201C",x?.words||A,"\u201D."]}):ve.map(([a,t])=>(0,l.jsxs)("div",{role:"group","aria-label":Aa(a,n.schema),children:[(0,l.jsxs)("div",{role:"presentation",style:ar,children:[a!=="rule:"?(0,l.jsx)(Qa,{kind:a,accents:g?.accents}):null,Aa(a,n.schema)]}),t.map(i=>(0,l.jsx)("div",{id:i.id,role:"option","aria-selected":i===T,"data-testid":"find-hit","data-about":i.hit.about,...i.hit.about==="node"&&i.hit.near?{"data-near":""}:{},onMouseEnter:()=>G(i),onClick:()=>we(i),style:{...Ma,...i.hit.about==="act"?{paddingLeft:30}:{},background:i===T?"var(--graview-panel-muted)":"transparent"},children:(0,l.jsx)(ja,{hit:i.hit,flag:$})},i.id))]},a)),N?(0,l.jsx)("div",{id:N.id,role:"option","aria-selected":N===T||T?.id===N.id,"data-testid":"find-ask",onMouseEnter:()=>G(N),onClick:()=>we(N),style:{...Ma,borderTop:"1px solid var(--graview-edge)",marginTop:4,background:T?.id===N.id?"var(--graview-panel-muted)":"transparent"},children:(0,l.jsxs)("span",{children:["Ask: ",(0,l.jsxs)("span",{style:{fontWeight:600},children:["\u2018",N.ask,"\u2019"]})]})}):null,qe>Ja?(0,l.jsxs)("p",{role:"presentation",style:{margin:0,padding:"6px 12px 2px",color:"var(--graview-ink-faint)",fontSize:"0.75rem"},"data-testid":"find-more-words",children:[_e(qe)," found: another word of the name narrows them."]}):null,x&&x.searched.past===!1&&x.searched.kinds.some(a=>n.schema.tryDefinition(a)?.lifecycle)?(0,l.jsx)("p",{role:"presentation",style:{margin:0,padding:"6px 12px 8px",color:"var(--graview-ink-faint)",fontSize:"0.75rem"},children:"Current ones; add is:any for the past."}):null]})]})}function ja({hit:e,flag:n}){switch(e.about){case"node":return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("span",{style:{fontWeight:600,overflowWrap:"anywhere"},children:[e.flagged?(0,l.jsxs)("span",{style:{color:"var(--graview-warn)"},children:[n," "]}):null,e.label,e.apart?(0,l.jsxs)("span",{style:Y,children:[" \xB7 ",e.apart]}):null,e.current?null:(0,l.jsx)("span",{style:Y,children:" \xB7 past"})]}),e.near?(0,l.jsxs)("span",{style:Y,"data-testid":"find-near",children:["Near \u201C",e.why.asked,"\u201D",e.why.field!=="label"?` \u2014 ${e.why.reading.toLowerCase()}: ${e.why.fragment}`:""]}):e.why.field!=="label"?(0,l.jsxs)("span",{style:Y,children:[e.why.reading.toLowerCase(),": ",e.why.fragment]}):null]});case"kind":return(0,l.jsxs)("span",{children:[e.label,(0,l.jsxs)("span",{style:Y,children:[" \xB7 ",e.count," match"]})]});case"place":return(0,l.jsxs)("span",{children:["Go to ",e.title]});case"rule":return(0,l.jsxs)("span",{children:["The rule \u201C",e.label,"\u201D"]});case"act":return(0,l.jsxs)("span",{style:e.destructive?{color:"var(--graview-warn)"}:void 0,children:[e.title,(0,l.jsxs)("span",{style:Y,children:[" \xB7 ",e.why.field==="title"?"act":`on ${e.why.fragment}`]})]})}}function Qa({kind:e,accents:n}){let s=Math.round(Ve(e,n));return(0,l.jsx)("span",{"aria-hidden":"true",style:{width:8,height:8,borderRadius:2,flex:"0 0 auto",background:`hsl(${s} 55% 52%)`}})}function Aa(e,n){return e==="rule:"?"Rules":e==="act:"?"Acts":n.tryDefinition(e)?.plural??`${e}s`}function Ya(e,n,s){let o=Object.entries(e).map(([g,c])=>Ue(s,g,c)),r=n.filter(g=>g.about==="kind"||g.about==="place"||g.about==="rule").length;r>0&&o.push(`${r} ${r===1?"place or rule":"places and rules"}`);let v=n.filter(g=>g.about==="node"&&g.near).length;return o.length===0?"Nothing found":`${o.join(", ")} found${v>0?`, ${v} of them near`:""}`}var Xa=10,Ja=12,Ta={...aa,width:"min(26rem, calc(100vw - 24px))",maxHeight:"min(60vh, 28rem)",overflowY:"auto",boxSizing:"border-box",background:"var(--graview-panel)",borderTop:"1px solid var(--graview-edge)",borderRight:"1px solid var(--graview-edge)",borderBottom:"1px solid var(--graview-edge)",borderLeft:"1px solid var(--graview-edge)",borderRadius:10,boxShadow:"0 10px 28px rgb(0 0 0 / 0.18)",padding:"4px 0"},Za=6,er={width:"var(--graview-bar-width, 100vw)",maxHeight:"55vh",borderRadius:0,borderLeft:"none",borderRight:"none"},ar={display:"flex",alignItems:"center",gap:6,padding:"8px 12px 2px",fontSize:"0.6875rem",letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--graview-ink-muted)"},Ma={display:"grid",gap:1,minHeight:32,padding:"5px 12px",alignContent:"center",cursor:"pointer",fontSize:"0.875rem",lineHeight:1.35,color:"var(--graview-ink)"},Y={color:"var(--graview-ink-muted)",fontSize:"0.8125rem",fontWeight:400};var X=p(O(),1);var Be=p(Wa(),1);var La=p(f(),1);function Ra(){let{following:e,follow:n}=S();return e?(0,La.jsxs)("button",{type:"button","data-testid":"following-who",onClick:()=>n(null),title:"Press, or Escape, to stop following",style:{display:"inline-flex",alignItems:"center",gap:6,minHeight:24,padding:"2px 9px",borderRadius:999,border:"1px solid var(--graview-accent)",background:"transparent",color:"var(--graview-accent)",fontSize:"0.875rem",whiteSpace:"nowrap"},children:["following ",e.name]}):null}var Na=p(O(),1);var b=p(f(),1);function Ha({home:e,homeLabel:n,children:s,onPicture:o=!1}){let{view:r,focus:v,show:g,go:c}=K(),{store:M}=S(),{movedByHand:z}=S(),x=z&&(r.pan!==void 0||Object.keys(r.pins).length>0),I=r.focusId&&r.focusId!==e?M.graph.getNode(r.focusId):void 0,$=m=>ie(M.schema,m),y={display:"inline-flex",alignItems:"center",gap:6,minHeight:26,padding:"2px 6px",fontSize:"0.8125rem",borderRadius:6,border:"1px solid transparent",boxShadow:"none",background:"transparent",color:"var(--graview-ink-muted)",whiteSpace:"nowrap"},C=n!==void 0&&I!==void 0,R=[];if(I&&!o&&R.push({key:"focused",node:(0,b.jsxs)("button",{type:"button","data-testid":"focused",onClick:()=>c(me({...r,focusId:e},!1)),title:he(M,I.id),style:{...y,maxWidth:"min(14rem, 15vw)"},children:[(0,b.jsx)("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:he(M,I.id)}),(0,b.jsx)("span",{"aria-hidden":"true",style:{opacity:.7},children:"\xD7"})]})}),r.past&&R.push({key:"past",node:(0,b.jsxs)("button",{type:"button","data-testid":"past",onClick:()=>c(ha(r,!1)),title:"Back to now \u2014 retired things leave the picture again",style:y,children:["the past",(0,b.jsx)("span",{"aria-hidden":"true",style:{opacity:.7},children:"\xD7"})]})}),r.zoom&&R.push({key:"zoomed",node:(0,b.jsxs)("button",{type:"button","data-testid":"zoomed",onClick:()=>c(me(r,!1)),title:"Zoom back out",style:y,children:["zoomed in",(0,b.jsx)("span",{"aria-hidden":"true",style:{opacity:.7},children:"\xD7"})]})}),x&&R.push({key:"moved",node:(0,b.jsx)("button",{type:"button","data-testid":"moved",onClick:()=>c(ue(r)),title:"Put the camera and everything you dragged back where the layout wanted them",style:y,children:"Reset view"})}),r.relation){let m=r.relation;R.push({key:"raised",node:(0,b.jsxs)("span",{style:{display:"inline-flex",alignItems:"center"},children:[(0,b.jsxs)("button",{type:"button","data-testid":"raised-into",onClick:()=>c(se(r,de(m),{ownPicture:!0})),title:`Go into the ${$(m).toLowerCase()}`,"aria-label":`Go into the ${$(m).toLowerCase()}`,style:{...y,color:"var(--graview-ink)"},children:[$(m),(0,b.jsx)("span",{"aria-hidden":"true",style:{opacity:.7},children:"\u2198"})]}),(0,b.jsx)("button",{type:"button","data-testid":"raised",onClick:()=>g(null),title:`Stop showing ${$(m).toLowerCase()}`,"aria-label":`Stop showing ${$(m).toLowerCase()}`,style:{...y,minWidth:26,justifyContent:"center"},children:(0,b.jsx)("span",{"aria-hidden":"true",style:{opacity:.7},children:"\xD7"})})]})})}return o&&!C&&R.length===0&&s===void 0?null:(0,b.jsxs)("nav",{"aria-label":"View","data-testid":"trail",style:{display:"flex",alignItems:"center",gap:8,fontSize:"0.875rem",minWidth:0,...o?{pointerEvents:"auto",padding:"4px 6px",borderRadius:8,background:"var(--graview-float)",boxShadow:"var(--graview-lift-low)",overflow:"hidden"}:{}},children:[C?(0,b.jsx)("button",{type:"button",onClick:()=>v(e),style:{border:"none",background:"none",padding:"3px 0",minHeight:24,whiteSpace:"nowrap",color:"var(--graview-ink-muted)"},children:n}):null,R.map(({key:m,node:F},ee)=>(0,b.jsxs)(Na.Fragment,{children:[C||ee>0?(0,b.jsx)("span",{style:{color:"var(--graview-ink-faint)"},children:"\u203A"}):null,F]},m)),s]})}var E=p(f(),1);function Pe(){let[e,n]=(0,X.useState)([]),s=(0,X.useCallback)(o=>{n(r=>{let v=o.phase!=="running"&&r[0]?.name===o.name&&r[0]?.at===o.at;return[o,...v?r.slice(1):r].slice(0,12)})},[]);return[e,s]}function De({find:e,calls:n,seat:s,remembers:o=!1}){return e?(0,E.jsxs)(E.Fragment,{children:[(0,Be.createPortal)((0,E.jsx)(Ia,{compact:e.compact}),e.slot),e.own?(0,Be.createPortal)((0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(X.Suspense,{fallback:null,children:(0,E.jsx)(Ea,{})}),(0,E.jsx)(la,{calls:n,remembers:o,...s!==void 0?{seat:s}:{}})]}),e.own):null]}):null}function Oe({home:e=null}){return(0,E.jsxs)("div",{"data-graview-scene-trail":"",style:{position:"absolute",top:14,left:14,maxWidth:"calc(100% - 150px - var(--graview-dock, 0px))",zIndex:P("overview"),display:"flex",alignItems:"center",gap:6,minWidth:0,pointerEvents:"none"},children:[(0,E.jsx)(Ha,{home:e,onPicture:!0}),(0,E.jsx)("span",{style:{pointerEvents:"auto"},children:(0,E.jsx)(Ra,{})})]})}var q=p(O(),1);var Ba=p(f(),1),rr=j(()=>(__graviewPreload(import.meta.url,["./chunk.UGFDSE37.js","./chunk.2UIUMG23.js","./chunk.KA44WNB4.js","./chunk.SDO3U72B.js","./chunk.4TJOS4C7.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.TKMQROXF.js")));function Ke(){let{store:e,principal:n}=S(),s=(0,q.useContext)(pa),o=(0,q.useRef)(null),r=(0,q.useRef)(!1);return(0,q.useEffect)(()=>()=>void(r.current=!0),[]),(0,q.useEffect)(()=>{let v=e.batches().length,g=rr().then(c=>c.sceneWay(e,n,s,v,o.current),()=>{});return()=>void g.then(c=>c?.(r.current))},[e,n,s]),(0,Ba.jsx)("span",{ref:o,hidden:!0})}var Pa=p(O(),1);var u=p(f(),1);function Ht({address:e=!1,auto:n,quickAsk:s=!0,scheme:o,scope:r}){let v=(0,Pa.useMemo)(()=>`${Te({scope:`.${r}`})}
1127
1127
  ${Me(o,{scope:`.${r}`})}`,[o,r]),g=ga(),[c]=Pe();return(0,u.jsx)(Ze.Provider,{value:!0,children:(0,u.jsxs)("div",{"data-embed-content":"",style:{position:"relative",flex:n?`0 0 ${Sa}px`:"1 1 auto",minHeight:0,containerType:"size"},children:[(0,u.jsx)("style",{children:v}),e?(0,u.jsx)(ka,{}):null,(0,u.jsx)(ya,{}),(0,u.jsx)(Oe,{}),(0,u.jsx)(Le,{}),(0,u.jsx)(Ie,{}),(0,u.jsx)($e,{}),(0,u.jsx)(ze,{face:"scene",on:s}),(0,u.jsx)(Re,{}),(0,u.jsx)(xe,{children:(0,u.jsx)(ke,{children:(0,u.jsx)(Ee,{children:(0,u.jsx)(Ae,{children:(0,u.jsx)(Se,{placement:"menu"})})})})}),(0,u.jsx)(be,{}),(0,u.jsx)(Ce,{}),(0,u.jsx)(De,{find:g,calls:c}),(0,u.jsx)(Ke,{}),(0,u.jsx)(fe,{face:"scene"})]})})}function Bt(){return(0,u.jsx)(He,{})}export{Ht as SceneFace,Bt as SceneKeeping};
@@ -0,0 +1 @@
1
+ import{a as f}from"./chunk.SUPWMV2F.js";import{da as d}from"./chunk.4TJOS4C7.js";function v(n){let o=n.indexOf("{"),a=n.indexOf("["),t=a!==-1&&(o===-1||a<o)?a:o;if(t===-1)return;let e=n[t],r=e==="["?"]":"}",i=0,u=!1,l=!1;for(let s=t;s<n.length;s++){let c=n[s];if(u){l?l=!1:c==="\\"?l=!0:c==='"'&&(u=!1);continue}if(c==='"')u=!0;else if(c===e)i+=1;else if(c===r&&(i-=1,i===0))try{return JSON.parse(n.slice(t,s+1))}catch{return}}}function P(n,o){let a;try{a=n.mutation(o.mutation)}catch{return o}let t={...o.args},e=!1;for(let r of f(a.input)){if(r.control!=="node")continue;let i=t[r.name];if(typeof i!="string"||i.length===0||n.graph.getNode(i))continue;let u=i.trim().toLowerCase(),l=[...n.graph.allNodes()].filter(s=>(r.kinds.includes("*")||r.kinds.includes(s.kind))&&d(n.schema.tryDefinition(s.kind),s).trim().toLowerCase()===u);l.length===1&&(t[r.name]=l[0].id,e=!0)}return e?{...o,args:t}:o}function x(n,o,a){let t=a===void 0?null:new Set(a),e=[];for(let r of o){if(typeof r.mutation!="string")continue;let i=!0;try{n.mutation(r.mutation)}catch{i=!1}i?t&&!t.has(r.mutation)&&e.push({proposal:r,why:"not-allowed"}):e.push({proposal:r,why:"unknown"})}return e}function b(n,o,a){let t=a===void 0?null:new Set(a);return o.filter(e=>{if(typeof e.mutation!="string"||t&&!t.has(e.mutation))return!1;try{n.mutation(e.mutation)}catch{return!1}return e.args!==null&&typeof e.args=="object"})}export{v as a,P as b,x as c,b as d};
@@ -1 +1 @@
1
- import{b as rn,c as an}from"./chunk.UT6642FC.js";import{e as N}from"./chunk.HDRD33II.js";import{c as J}from"./chunk.H7KCWCB4.js";import{Hb as sn,Ib as E,Jc as on,Wb as V,Xa as H,Zb as Q,ca as F,da as K,ea as q,fa as nn,ga as en,ja as tn,ka as z,la as B}from"./chunk.AS4CQBOQ.js";function dn(){return{name:"insight",derive({store:n,nodes:d,kindSelection:t}){let f=[],y=l=>F(n.schema.tryDefinition(l.kind),l);for(let l of d){if([...n.schema.edgeKinds].reduce((c,S)=>c+n.graph.out(l.id,S).length+n.graph.in(l.id,S).length,0)===0){f.push({id:`insight:island:${l.id}`,text:`${y(l)} is connected to nothing yet`,nodeIds:[l.id]});continue}for(let c of n.schema.edgeKinds){let S=n.graph.in(l.id,c).length;if(S<3)continue;let s=[...n.graph.allEdges()].filter(a=>a.kind===c),e=s.length;e>=4&&S/e>.6&&f.push({id:`insight:load:${l.id}:${c}`,text:`${y(l)} ${mn(n,s,c,S)}`,nodeIds:[l.id]})}}for(let l of t){if(n.graph.nodesOfKind(l).length>0)continue;let A=n.schema.definitions.filter(c=>c.kind!==l).filter(c=>Object.values(c.edges).some(S=>S.to!=="*"&&S.to.includes(l))).map(c=>c.plural??`${c.kind}s`);A.length>0&&f.push({id:`insight:gap:${l}`,text:`Nothing here yet, though ${A.join(" and ")} expect to connect to these`,nodeIds:[]})}return{observations:f}}}}function mn(n,d,t,f){let y=new Set(d.map(s=>n.graph.getNode(s.from)?.kind).filter(s=>s!==void 0)),l=y.size===1?[...y][0]:void 0,A=d.length,c=J(n.schema,l??[...y][0]??"",t,"in"),S=s=>l?nn(n.schema,l,s):String(s);return f===A?`${c}: all ${S(f)}`:`${c}: ${f} of the ${S(A)}`}function cn(n){let d=new Map;if(n.length===0)return d;let t=n.slice(-512),f=new Set;for(let l of t)l.undoes&&f.add(l.undoes);let y=n[n.length-1].seq;for(let l of t){if(!l.mutation||f.has(l.id))continue;let A=Math.pow(.5,(y-l.seq)/64);d.set(l.mutation.name,(d.get(l.mutation.name)??0)+A)}return d}function un(n){return 8*(n/(n+1))}var kn=100;function fn(){return{name:"invariant",derive({store:n,selection:d,nodes:t,violations:f}){let y=s=>F(n.schema.tryDefinition(s.kind),s),l=new Set(d),A=f.filter(s=>s.nodeIds.some(e=>l.has(e))||s.subjectId!==void 0&&l.has(s.subjectId)),c=[],S=[];A.forEach((s,e)=>{S.push({id:`violation:${s.invariant}:${e}`,text:s.message,nodeIds:s.nodeIds}),s.repairs.forEach((a,h)=>{c.push({id:`invariant:${s.invariant}:${e}:${h}`,label:a.label,provider:"invariant",mutation:a.mutation,args:a.args??{},open:(a.missing??[]).map(m=>{let o=n.allMutations().find(g=>g.name===a.mutation);if(!o)return{name:m};let r=E(o.input).find(g=>g.name===m),k=r?r.kinds.includes("*")?n.graph.allNodes().map(g=>g.id):r.kinds.flatMap(g=>n.graph.nodesOfKind(g).map($=>$.id)):void 0;return{name:m,shape:N(o.input,m),...r?{kinds:r.kinds}:{},...k?{candidates:k}:{}}}),score:kn-h-(a.missing?.length??0),why:s.message,nodeIds:s.nodeIds,...s.subjectId===void 0?{}:{subjectId:s.subjectId}})})});for(let s of t){let e=n.allInvariants().filter(a=>{if(a.scope==="graph")return!1;let h=a.scope;return h.kind!==s.kind?!1:h.match?h.match(s):!0});e.length!==0&&(A.some(a=>a.subjectId===s.id||a.nodeIds.includes(s.id))||S.push({id:`holds:${s.id}`,text:`${y(s)} holds \u2014 nothing currently breaks ${e.length===1?"it":`any of its ${e.length} rules`}`,nodeIds:[s.id]}))}return{affordances:c,observations:S}}}}var U=40;function ln(){return{name:"schema",derive({store:n,selection:d,nodes:t,kindSelection:f,edgeSelection:y,principal:l}){let A=(e,a)=>l!==void 0&&!n.permits({name:e,args:a},l).ok,c=[];if(t.length===0&&y.length>0){for(let e of y){let a=n.graph.getNode(e.from),h=n.graph.getNode(e.to);if(!a||!h)continue;let m=an(n,e);m?.provisional&&c.push({id:`schema:edge:${V}:${e.kind}:${e.from}:${e.to}`,label:"Keep this link",provider:"schema",mutation:V,args:{kind:e.kind,from:e.from,to:e.to},open:[],score:64,why:rn(m),nodeIds:[e.from,e.to]});for(let o of n.allMutations()){let r=(o.connects??[]).includes(e.kind),k=(o.severs??[]).includes(e.kind);if(!r&&!k||o.derived?.relation!==void 0&&o.derived.kind!==a.kind)continue;let g={},$=[],j=E(o.input);for(let p of j){let w=p.kinds.includes("*")||p.kinds.includes(a.kind),P=p.kinds.includes("*")||p.kinds.includes(h.kind),v=w&&!j.some(I=>I!==p&&(I.kinds.includes(a.kind)||I.kinds.includes("*")));w&&!P?g[p.name]=e.from:P&&!w?g[p.name]=e.to:w&&P&&v?g[p.name]=e.from:$.push({name:p.name,kinds:p.kinds,candidates:[e.from,e.to],shape:N(o.input,p.name)})}for(let p of G(o.input,""))p in g||$.some(w=>w.name===p)||$.push({name:p,shape:N(o.input,p)});$.every(p=>p.optional===!0?!0:p.kinds!==void 0?(p.candidates?.length??0)>0:(p.candidates?.length??0)>0||p.shape!==void 0&&p.shape.type!=="unknown")&&(r&&!k&&$.length===0||c.push({id:`schema:edge:${o.name}:${e.kind}:${e.from}:${e.to}`,label:K(o),provider:"schema",mutation:o.name,args:g,open:$,...o.destructive?{destructive:!0}:{},score:(k?62:58)-$.length,why:`this line is "${J(n.schema,n.graph.getNode(e.from)?.kind??"",e.kind,"out")}"`,nodeIds:[e.from,e.to]}))}}return{affordances:c}}if(t.length===0&&f.length>0){let e=new Set(f),a=[];for(let h of n.allMutations()){if(!(h.creates??[]).some(r=>e.has(r)))continue;let m=[];for(let r of E(h.input)){let k=r.kinds.includes("*")?n.graph.allNodes().map(g=>g.id):r.kinds.flatMap(g=>n.graph.nodesOfKind(g).map($=>$.id));m.push({name:r.name,kinds:r.kinds,candidates:k,shape:N(h.input,r.name),...r.optional?{optional:!0}:{}})}for(let r of G(h.input,""))m.some(k=>k.name===r)||m.push({name:r,shape:N(h.input,r)});if(!m.every(r=>r.optional===!0?!0:r.kinds!==void 0?(r.candidates?.length??0)>0:(r.candidates?.length??0)>0||r.shape!==void 0&&r.shape.type!=="unknown")&&!A(h.name,{})){let r=m.filter(k=>k.optional!==!0&&k.kinds!==void 0&&!k.kinds.includes("*")&&(k.candidates?.length??0)===0);if(r.length>0){let k=[...new Set(r.flatMap(g=>g.kinds??[]))].map(g=>z(B(n.schema.tryDefinition(g),g)));a.push({id:`schema:waits:${h.name}`,text:`"${h.title??h.name}" cannot begin until there is ${k.length===1?k[0]:`${k.slice(0,-1).join(", ")} and ${k[k.length-1]}`}.`,nodeIds:[]})}continue}c.push({id:`schema:add:${h.name}`,label:K(h),provider:"schema",mutation:h.name,args:{},open:m,score:U-m.length,why:`this makes ${(h.creates??[]).filter(r=>e.has(r)).map(r=>z(B(n.schema.tryDefinition(r),r))).join(", ")}`,nodeIds:[]})}return{affordances:c,observations:a}}if(t.length===0)return{};let S=new Set(t.map(e=>e.kind)),s=(e,a,h)=>{let m=[];for(let o of n.graph.allEdges()){if(!a.includes(o.kind))continue;let r=o.from===e?o.to:o.to===e?o.from:null;if(!r)continue;let k=n.graph.getNode(r);k&&(!h.includes("*")&&!h.includes(k.kind)||m.includes(r)||m.push(r))}return m};for(let e of n.allMutations()){let a=e.subject;if(!a||!(a.kinds==="*"?!0:[...S].every(u=>a.kinds.includes(u))))continue;let m=e.derived?.act;if((m==="archive"||m==="merge")&&t.some(u=>H(u))||m==="unarchive"&&!t.some(u=>H(u))||m==="leave-alone"&&t.every(u=>Q(n,u.id))||m==="allow-tidying"&&!t.some(u=>Q(n,u.id)))continue;let o=t.length===1?t[0].id:null,r=e.severs??[],k=e.connects??[];if(o&&r.length>0&&k.length===0&&s(o,r,["*"]).length===0)continue;let g=[];for(let u of E(e.input)){if(u.name===a.arg)continue;let p=u.kinds.includes("*")?n.graph.allNodes().map(w=>w.id):u.kinds.flatMap(w=>n.graph.nodesOfKind(w).map(P=>P.id));if(o&&k.length>0){let w=new Set(s(o,k,u.kinds));p=p.filter(P=>!w.has(P))}else o&&r.length>0&&(p=s(o,r,u.kinds));g.push({name:u.name,kinds:u.kinds,candidates:p.filter(w=>!d.includes(w)),shape:N(e.input,u.name),...u.optional?{optional:!0}:{}})}for(let u of G(e.input,a.arg))g.some(p=>p.name===u)||g.push({name:u,shape:N(e.input,u)});if(g.length===0&&o){let u=yn(e.input,a.arg);if(u.length>0&&!vn(n,e.name,{[a.arg]:o}))for(let p of u){let w=E(e.input).find(P=>P.name===p);g.push({name:p,optional:!0,...w?{kinds:w.kinds}:{},shape:N(e.input,p)})}}if(!g.every(u=>u.optional===!0?!0:u.kinds!==void 0?(u.candidates?.length??0)>0:(u.candidates?.length??0)>0||u.shape!==void 0&&u.shape.type!=="unknown")&&!A(e.name,o?{[a.arg]:o}:{}))continue;let j=t.map(u=>({[a.arg]:u.id}));g.length===0&&!j.some(u=>n.wouldChange({name:e.name,args:u}))||c.push({id:`schema:${e.name}`,label:t.length>1?`${K(e)} (${t.length})`:K(e),provider:"schema",mutation:e.name,args:j[0]??{},open:g,...e.destructive?{destructive:!0}:{},...e.derived?.act==="archive"||e.derived?.act==="merge"||e.derived?.act==="leave-alone"||e.derived?.act==="allow-tidying"?{setsAside:!0}:{},...r.length>0||k.length>0?{ties:!0}:{},...t.length>1?{batch:j}:{},score:U-g.length,why:t.length>1?`all ${t.length} selected nodes are ${[...S].map(u=>en(n.schema,u).toLowerCase()).join(" or ")}`:`this is ${z(B(n.schema.tryDefinition(t[0].kind),t[0].kind))}`,nodeIds:t.map(u=>u.id)})}if(t.length===1){let e=t[0];for(let a of n.allMutations()){let h=a.subject,m=a.severs??[],o=a.connects??[];if(!h||m.length===0&&o.length===0)continue;let r=h.kinds==="*"?"*":h.kinds;if(r==="*"||r.includes(e.kind))continue;let k=E(a.input),g=k.find(v=>v.name!==h.arg&&(v.kinds.includes("*")||v.kinds.includes(e.kind)));if(!g)continue;let $=r,j=$.includes("*")?n.graph.allNodes().map(v=>v.id):$.flatMap(v=>n.graph.nodesOfKind(v).map(I=>I.id)),u=new Set(s(e.id,o.length>0?o:m,$)),p=o.length>0?j.filter(v=>!u.has(v)):j.filter(v=>u.has(v));if(p.length===0)continue;let w=[{name:h.arg,kinds:$,candidates:p,shape:N(a.input,h.arg)}];for(let v of k){if(v.name===g.name||v.name===h.arg)continue;let I=v.kinds.includes("*")?n.graph.allNodes().map(D=>D.id):v.kinds.flatMap(D=>n.graph.nodesOfKind(D).map(O=>O.id));w.push({name:v.name,kinds:v.kinds,candidates:I,shape:N(a.input,v.name),...v.optional?{optional:!0}:{}})}for(let v of G(a.input,g.name))v===h.arg||w.some(I=>I.name===v)||w.push({name:v,shape:N(a.input,v)});w.every(v=>v.optional===!0?!0:v.kinds!==void 0?(v.candidates?.length??0)>0:(v.candidates?.length??0)>0||v.shape!==void 0&&v.shape.type!=="unknown")&&c.push({id:`schema:tie:${a.name}:${e.id}`,label:a.fromTheOtherEnd??K(a),provider:"schema",mutation:a.name,args:{[g.name]:e.id},open:w,ties:!0,...a.destructive?{destructive:!0}:{},score:U-w.length+2,why:`${m.length>0?"this one is on":"this one could join"} ${w[0].candidates.length===1?"it":"one of these"}`,nodeIds:[e.id]})}}return{affordances:c}}}}function yn(n,d){let t=n.shape;return t?Object.entries(t).filter(([f,y])=>f!==d&&y.safeParse(void 0).success).map(([f])=>f):[]}function vn(n,d,t){try{return n.preview({name:d,args:t}),!0}catch{return!1}}function G(n,d){let t=n.shape;return t?Object.entries(t).filter(([f,y])=>f!==d&&!y.safeParse(void 0).success).map(([f])=>f):[]}var bn=70,Sn=80,wn=new Set(["id","kind"]);function hn(){return{name:"structure",derive({store:n,nodes:d}){let t=c=>F(n.schema.tryDefinition(c.kind),c);if(d.length<2)return{};let f=[],y=[],l=d.map(c=>c.id);for(let c of n.schema.edgeKinds){let S=An(d.map(e=>new Set([...n.graph.out(e.id,c).map(a=>a.id),...n.graph.in(e.id,c).map(a=>a.id)])));for(let e of S){let a=n.graph.getNode(e);a&&f.push({id:`shared:${c}:${e}`,text:`all ${d.length} share "${t(a)}" (${q(c).toLowerCase()})`,nodeIds:[...l,e]})}let s=new Map;for(let e of d)for(let a of[...n.graph.out(e.id,c),...n.graph.in(e.id,c)])s.set(a.id,(s.get(a.id)??0)+1);for(let[e,a]of s){if(a!==d.length-1||d.length<3||l.includes(e))continue;let h=n.graph.getNode(e);if(!h)continue;let m=d.find(o=>![...n.graph.out(o.id,c),...n.graph.in(o.id,c)].some(r=>r.id===e));if(m&&(f.push({id:`near-shared:${c}:${e}`,text:`all but "${t(m)}" share "${t(h)}" (${q(c).toLowerCase()})`,nodeIds:[...l,e]}),!(!n.schema.edgeAllowed(c,m.kind,h.kind)&&!n.schema.edgeAllowed(c,h.kind,m.kind))))for(let o of n.allMutations()){let r=o.subject;if(!r||r.kinds!=="*"&&!r.kinds.includes(m.kind)||(o.connects!==void 0||o.severs!==void 0)&&!(o.connects??[]).includes(c))continue;let g=$n(o.input,h.kind);g&&y.push({id:`structure:join:${o.name}:${m.id}:${e}`,label:`${K(o)}: bring "${t(m)}" in line with the others`,provider:"structure",mutation:o.name,args:{[r.arg]:m.id,[g]:e},open:[],score:bn,why:`every other selected node is connected to "${t(h)}"`,nodeIds:[m.id,e]})}}}let A=new Map;for(let c of d)A.set(c.kind,[...A.get(c.kind)??[],c]);for(let[c,S]of A){if(S.length<2)continue;let s=S,e=S.map(o=>o.id),a=A.size>1?`${c}:`:"",h=new Set;for(let o of s)for(let r of Object.keys(o))wn.has(r)||h.add(r);let m=o=>n.schema.definitions.find(r=>r.kind===o);for(let o of[...h].sort()){let r=m(s[0].kind),k=tn(r,o).toLowerCase(),g=r?.display?.format?.[o],$=O=>{if(!g)return O;try{return String(g(JSON.parse(O)))}catch{return O}},j=s.map(O=>O[o]),u=new Map;if(j.forEach((O,R)=>{let L=JSON.stringify(O??null),x=u.get(L);x?x.push(s[R]):u.set(L,[s[R]])}),u.size===1){let O=[...u.keys()][0];if(O==="null")continue;f.push({id:`agree:${a}${o}`,text:`all ${s.length} share the ${k} ${$(O)}`,nodeIds:e});continue}if(s.length<3||u.size!==2)continue;let p=[...u.entries()].sort((O,R)=>R[1].length-O[1].length),[w,P]=p[0],[,v]=p[1];if(v.length!==1||w==="null")continue;let I=v[0],D=JSON.parse(w);f.push({id:`odd-one-out:${a}${o}`,text:`${P.length} share the ${k} ${$(w)}; "${t(I)}" does not`,nodeIds:e});for(let O of n.allMutations()){let R=O.subject;if(!R||R.kinds!=="*"&&!R.kinds.includes(I.kind))continue;let L=gn(O.input);if(!L||!(o in L))continue;let x={[R.arg]:I.id,[o]:D},T=!0;for(let[C,Z]of Object.entries(L)){if(C in x||Z.safeParse(void 0).success)continue;let i=I[C];if(i===void 0){T=!1;break}x[C]=i}!T||!O.input.safeParse(x).success||y.push({id:`structure:align:${O.name}:${o}:${I.id}`,label:`Align the ${k} of "${t(I)}" with the other ${P.length}`,provider:"structure",mutation:O.name,args:x,open:[],score:Sn,why:`${P.length} of ${s.length} share the ${k} ${$(w)}`,nodeIds:e})}}}return{affordances:y,observations:f}}}}function An(n){if(n.length===0)return[];let[d,...t]=n;return[...d].filter(f=>t.every(y=>y.has(f))).sort()}function gn(n){return n.shape??null}function $n(n,d){let t=gn(n);if(!t)return null;for(let[f]of Object.entries(t)){let y=sn(t[f]);if(y&&(y.includes("*")||y.includes(d)))return f}return null}function On(){return[fn(),hn(),ln(),dn()]}function Vn(n,d,t={}){let f=pn(),y=t.providers??On(),l=d.map(i=>n.graph.getNode(i)).filter(i=>i!==void 0),A={store:n,selection:d,nodes:l,kindSelection:t.kindSelection??[],edgeSelection:t.edgeSelection??[],violations:n.violations(t.context),context:t.context??{},principal:t.principal??{kind:"human"}},c=[],S=[];for(let i of y){let b=i.derive(A);c.push(...b.affordances??[]),S.push(...b.observations??[])}let s=new Set(n.allMutations().filter(i=>i.pinned).map(i=>i.name)),e=new Set(t.pins?.pinned??[]),a=new Set(t.pins?.unpinned??[]),h=i=>e.has(i.mutation)?"user":s.has(i.mutation)&&!a.has(i.mutation)?"declared":void 0,m=i=>{let b=h(i);return b?{...i,pinned:b}:i},o=new Map;for(let[i,b]of cn(n.log.all()))o.set(i,un(b));let r=i=>i.pinned==="user"?0:i.pinned==="declared"?1:2,k=i=>i.score+(o.get(i.mutation)??0),g=new Map(n.allMutations().map(i=>[i.name,i])),$=new Map,j=i=>{let b=g.get(i.mutation);if(!b)return[];let M=$.get(i.mutation);M||(M=E(b.input).map(W=>W.name),$.set(i.mutation,M));let _=[];for(let W of i.batch??[i.args])for(let X of M){let Y=W[X]??i.args[X];typeof Y=="string"&&_.push(Y)}return _},u=t.focus,p=4,w=i=>i.open.length>0?1:0,P=i=>{if(u===void 0)return p;let b=j(i);return b.length>0?b.includes(u)?v(i,0):p:i.nodeIds.includes(u)||i.subjectId===u?v(i,1):p},v=(i,b)=>i.provider==="invariant"?b:2+w(i),I=i=>i.setsAside?1:0,D=In(c).map(m),O=new Map(D.map((i,b)=>[i,b])),R=D.sort((i,b)=>{let M=Number(i.destructive??!1)-Number(b.destructive??!1);if(M!==0)return M;let _=I(i)-I(b);if(_!==0)return _;let W=P(i)-P(b);return W!==0?W:P(i)<2?O.get(i)-O.get(b):+(b.provider==="invariant")-+(i.provider==="invariant")||r(i)-r(b)||k(b)-k(i)||i.id.localeCompare(b.id)}),L=t.principal??{kind:"human"},x=[],T=[];for(let i of R){let b=n.permits({name:i.mutation,args:{...i.args,...i.batch?.[0]??{}}},L);if(b.ok)x.push(i);else{let M=jn(n,i,L);if(M==="done")continue;M?x.push(M):T.push({...i,refusal:b.refusal})}}let C=x.map((i,b)=>({...i,rank:b})),Z=T.map((i,b)=>({...i,rank:x.length+b}));return{affordances:t.limit===void 0?C:C.slice(0,t.limit),withheld:Z,observations:Pn(S),ms:pn()-f}}function In(n){let d=new Map;for(let t of n){let f=[t.mutation,JSON.stringify(t.args),JSON.stringify(t.batch??null)].join("|"),y=d.get(f);(!y||t.score>y.score)&&d.set(f,t)}return[...d.values()]}function Pn(n){let d=new Map;for(let t of n)d.set(t.text,t);return[...d.values()]}function pn(){return typeof performance<"u"?performance.now():Date.now()}function Qn(n,d,t={},f={}){let y=(d.batch??[d.args]).map(A=>({name:d.mutation,args:{...d.args,...A,...t}})),l=n.allMutations().find(A=>A.name===d.mutation);return n.applyAll(y,{...l?.describe?{}:{intent:d.label},...f.author?{author:f.author}:{}})}function Un(n,d,t={},f={}){try{return n.preview({name:d.mutation,args:{...d.args,...t}})}catch(y){throw f.pressed&&on(y,f.pressed.author?.id),y}}function jn(n,d,t){let f=n.allMutations().find(s=>s.name===d.mutation)?.subject,y=f!==void 0&&d.args[f.arg]===void 0,l=y?d.open.find(s=>s.name===f.arg):d.open.find(s=>s.name!==f?.arg&&s.candidates);if(!l?.candidates)return;let A=s=>n.permits({name:d.mutation,args:{...d.args,...d.batch?.[0]??{},[l.name]:s}},t).ok,c=l.candidates.filter(A),S=t.id===void 0?void 0:n.graph.getNode(t.id);if(c.length===0){let s=y?f.kinds:"*";return S!==void 0&&(s==="*"||s.includes(S.kind))&&A(S.id)?"done":void 0}return c.length===1&&c[0]===t.id?{...d,args:{...d.args,[l.name]:t.id},open:d.open.filter(s=>s!==l)}:{...d,open:d.open.map(s=>s===l?{...s,candidates:c}:s)}}export{Vn as a,Qn as b,Un as c};
1
+ import{b as rn,c as an}from"./chunk.UT6642FC.js";import{j as N}from"./chunk.KVJFY7N5.js";import{c as J}from"./chunk.DPHTUTOS.js";import{Ib as sn,Jb as E,Kc as on,Xb as V,Ya as H,_b as Q,da as F,ea as K,fa as q,ga as nn,ha as en,ka as tn,la as z,ma as B}from"./chunk.4TJOS4C7.js";function dn(){return{name:"insight",derive({store:n,nodes:d,kindSelection:t}){let f=[],y=l=>F(n.schema.tryDefinition(l.kind),l);for(let l of d){if([...n.schema.edgeKinds].reduce((c,S)=>c+n.graph.out(l.id,S).length+n.graph.in(l.id,S).length,0)===0){f.push({id:`insight:island:${l.id}`,text:`${y(l)} is connected to nothing yet`,nodeIds:[l.id]});continue}for(let c of n.schema.edgeKinds){let S=n.graph.in(l.id,c).length;if(S<3)continue;let s=[...n.graph.allEdges()].filter(a=>a.kind===c),e=s.length;e>=4&&S/e>.6&&f.push({id:`insight:load:${l.id}:${c}`,text:`${y(l)} ${mn(n,s,c,S)}`,nodeIds:[l.id]})}}for(let l of t){if(n.graph.nodesOfKind(l).length>0)continue;let A=n.schema.definitions.filter(c=>c.kind!==l).filter(c=>Object.values(c.edges).some(S=>S.to!=="*"&&S.to.includes(l))).map(c=>c.plural??`${c.kind}s`);A.length>0&&f.push({id:`insight:gap:${l}`,text:`Nothing here yet, though ${A.join(" and ")} expect to connect to these`,nodeIds:[]})}return{observations:f}}}}function mn(n,d,t,f){let y=new Set(d.map(s=>n.graph.getNode(s.from)?.kind).filter(s=>s!==void 0)),l=y.size===1?[...y][0]:void 0,A=d.length,c=J(n.schema,l??[...y][0]??"",t,"in"),S=s=>l?nn(n.schema,l,s):String(s);return f===A?`${c}: all ${S(f)}`:`${c}: ${f} of the ${S(A)}`}function cn(n){let d=new Map;if(n.length===0)return d;let t=n.slice(-512),f=new Set;for(let l of t)l.undoes&&f.add(l.undoes);let y=n[n.length-1].seq;for(let l of t){if(!l.mutation||f.has(l.id))continue;let A=Math.pow(.5,(y-l.seq)/64);d.set(l.mutation.name,(d.get(l.mutation.name)??0)+A)}return d}function un(n){return 8*(n/(n+1))}var kn=100;function fn(){return{name:"invariant",derive({store:n,selection:d,nodes:t,violations:f}){let y=s=>F(n.schema.tryDefinition(s.kind),s),l=new Set(d),A=f.filter(s=>s.nodeIds.some(e=>l.has(e))||s.subjectId!==void 0&&l.has(s.subjectId)),c=[],S=[];A.forEach((s,e)=>{S.push({id:`violation:${s.invariant}:${e}`,text:s.message,nodeIds:s.nodeIds}),s.repairs.forEach((a,h)=>{c.push({id:`invariant:${s.invariant}:${e}:${h}`,label:a.label,provider:"invariant",mutation:a.mutation,args:a.args??{},open:(a.missing??[]).map(m=>{let o=n.allMutations().find(g=>g.name===a.mutation);if(!o)return{name:m};let r=E(o.input).find(g=>g.name===m),k=r?r.kinds.includes("*")?n.graph.allNodes().map(g=>g.id):r.kinds.flatMap(g=>n.graph.nodesOfKind(g).map($=>$.id)):void 0;return{name:m,shape:N(o.input,m),...r?{kinds:r.kinds}:{},...k?{candidates:k}:{}}}),score:kn-h-(a.missing?.length??0),why:s.message,nodeIds:s.nodeIds,...s.subjectId===void 0?{}:{subjectId:s.subjectId}})})});for(let s of t){let e=n.allInvariants().filter(a=>{if(a.scope==="graph")return!1;let h=a.scope;return h.kind!==s.kind?!1:h.match?h.match(s):!0});e.length!==0&&(A.some(a=>a.subjectId===s.id||a.nodeIds.includes(s.id))||S.push({id:`holds:${s.id}`,text:`${y(s)} holds \u2014 nothing currently breaks ${e.length===1?"it":`any of its ${e.length} rules`}`,nodeIds:[s.id]}))}return{affordances:c,observations:S}}}}var U=40;function ln(){return{name:"schema",derive({store:n,selection:d,nodes:t,kindSelection:f,edgeSelection:y,principal:l}){let A=(e,a)=>l!==void 0&&!n.permits({name:e,args:a},l).ok,c=[];if(t.length===0&&y.length>0){for(let e of y){let a=n.graph.getNode(e.from),h=n.graph.getNode(e.to);if(!a||!h)continue;let m=an(n,e);m?.provisional&&c.push({id:`schema:edge:${V}:${e.kind}:${e.from}:${e.to}`,label:"Keep this link",provider:"schema",mutation:V,args:{kind:e.kind,from:e.from,to:e.to},open:[],score:64,why:rn(m),nodeIds:[e.from,e.to]});for(let o of n.allMutations()){let r=(o.connects??[]).includes(e.kind),k=(o.severs??[]).includes(e.kind);if(!r&&!k||o.derived?.relation!==void 0&&o.derived.kind!==a.kind)continue;let g={},$=[],j=E(o.input);for(let p of j){let w=p.kinds.includes("*")||p.kinds.includes(a.kind),P=p.kinds.includes("*")||p.kinds.includes(h.kind),v=w&&!j.some(I=>I!==p&&(I.kinds.includes(a.kind)||I.kinds.includes("*")));w&&!P?g[p.name]=e.from:P&&!w?g[p.name]=e.to:w&&P&&v?g[p.name]=e.from:$.push({name:p.name,kinds:p.kinds,candidates:[e.from,e.to],shape:N(o.input,p.name)})}for(let p of G(o.input,""))p in g||$.some(w=>w.name===p)||$.push({name:p,shape:N(o.input,p)});$.every(p=>p.optional===!0?!0:p.kinds!==void 0?(p.candidates?.length??0)>0:(p.candidates?.length??0)>0||p.shape!==void 0&&p.shape.type!=="unknown")&&(r&&!k&&$.length===0||c.push({id:`schema:edge:${o.name}:${e.kind}:${e.from}:${e.to}`,label:K(o),provider:"schema",mutation:o.name,args:g,open:$,...o.destructive?{destructive:!0}:{},score:(k?62:58)-$.length,why:`this line is "${J(n.schema,n.graph.getNode(e.from)?.kind??"",e.kind,"out")}"`,nodeIds:[e.from,e.to]}))}}return{affordances:c}}if(t.length===0&&f.length>0){let e=new Set(f),a=[];for(let h of n.allMutations()){if(!(h.creates??[]).some(r=>e.has(r)))continue;let m=[];for(let r of E(h.input)){let k=r.kinds.includes("*")?n.graph.allNodes().map(g=>g.id):r.kinds.flatMap(g=>n.graph.nodesOfKind(g).map($=>$.id));m.push({name:r.name,kinds:r.kinds,candidates:k,shape:N(h.input,r.name),...r.optional?{optional:!0}:{}})}for(let r of G(h.input,""))m.some(k=>k.name===r)||m.push({name:r,shape:N(h.input,r)});if(!m.every(r=>r.optional===!0?!0:r.kinds!==void 0?(r.candidates?.length??0)>0:(r.candidates?.length??0)>0||r.shape!==void 0&&r.shape.type!=="unknown")&&!A(h.name,{})){let r=m.filter(k=>k.optional!==!0&&k.kinds!==void 0&&!k.kinds.includes("*")&&(k.candidates?.length??0)===0);if(r.length>0){let k=[...new Set(r.flatMap(g=>g.kinds??[]))].map(g=>z(B(n.schema.tryDefinition(g),g)));a.push({id:`schema:waits:${h.name}`,text:`"${h.title??h.name}" cannot begin until there is ${k.length===1?k[0]:`${k.slice(0,-1).join(", ")} and ${k[k.length-1]}`}.`,nodeIds:[]})}continue}c.push({id:`schema:add:${h.name}`,label:K(h),provider:"schema",mutation:h.name,args:{},open:m,score:U-m.length,why:`this makes ${(h.creates??[]).filter(r=>e.has(r)).map(r=>z(B(n.schema.tryDefinition(r),r))).join(", ")}`,nodeIds:[]})}return{affordances:c,observations:a}}if(t.length===0)return{};let S=new Set(t.map(e=>e.kind)),s=(e,a,h)=>{let m=[];for(let o of n.graph.allEdges()){if(!a.includes(o.kind))continue;let r=o.from===e?o.to:o.to===e?o.from:null;if(!r)continue;let k=n.graph.getNode(r);k&&(!h.includes("*")&&!h.includes(k.kind)||m.includes(r)||m.push(r))}return m};for(let e of n.allMutations()){let a=e.subject;if(!a||!(a.kinds==="*"?!0:[...S].every(u=>a.kinds.includes(u))))continue;let m=e.derived?.act;if((m==="archive"||m==="merge")&&t.some(u=>H(u))||m==="unarchive"&&!t.some(u=>H(u))||m==="leave-alone"&&t.every(u=>Q(n,u.id))||m==="allow-tidying"&&!t.some(u=>Q(n,u.id)))continue;let o=t.length===1?t[0].id:null,r=e.severs??[],k=e.connects??[];if(o&&r.length>0&&k.length===0&&s(o,r,["*"]).length===0)continue;let g=[];for(let u of E(e.input)){if(u.name===a.arg)continue;let p=u.kinds.includes("*")?n.graph.allNodes().map(w=>w.id):u.kinds.flatMap(w=>n.graph.nodesOfKind(w).map(P=>P.id));if(o&&k.length>0){let w=new Set(s(o,k,u.kinds));p=p.filter(P=>!w.has(P))}else o&&r.length>0&&(p=s(o,r,u.kinds));g.push({name:u.name,kinds:u.kinds,candidates:p.filter(w=>!d.includes(w)),shape:N(e.input,u.name),...u.optional?{optional:!0}:{}})}for(let u of G(e.input,a.arg))g.some(p=>p.name===u)||g.push({name:u,shape:N(e.input,u)});if(g.length===0&&o){let u=yn(e.input,a.arg);if(u.length>0&&!vn(n,e.name,{[a.arg]:o}))for(let p of u){let w=E(e.input).find(P=>P.name===p);g.push({name:p,optional:!0,...w?{kinds:w.kinds}:{},shape:N(e.input,p)})}}if(!g.every(u=>u.optional===!0?!0:u.kinds!==void 0?(u.candidates?.length??0)>0:(u.candidates?.length??0)>0||u.shape!==void 0&&u.shape.type!=="unknown")&&!A(e.name,o?{[a.arg]:o}:{}))continue;let j=t.map(u=>({[a.arg]:u.id}));g.length===0&&!j.some(u=>n.wouldChange({name:e.name,args:u}))||c.push({id:`schema:${e.name}`,label:t.length>1?`${K(e)} (${t.length})`:K(e),provider:"schema",mutation:e.name,args:j[0]??{},open:g,...e.destructive?{destructive:!0}:{},...e.derived?.act==="archive"||e.derived?.act==="merge"||e.derived?.act==="leave-alone"||e.derived?.act==="allow-tidying"?{setsAside:!0}:{},...r.length>0||k.length>0?{ties:!0}:{},...t.length>1?{batch:j}:{},score:U-g.length,why:t.length>1?`all ${t.length} selected nodes are ${[...S].map(u=>en(n.schema,u).toLowerCase()).join(" or ")}`:`this is ${z(B(n.schema.tryDefinition(t[0].kind),t[0].kind))}`,nodeIds:t.map(u=>u.id)})}if(t.length===1){let e=t[0];for(let a of n.allMutations()){let h=a.subject,m=a.severs??[],o=a.connects??[];if(!h||m.length===0&&o.length===0)continue;let r=h.kinds==="*"?"*":h.kinds;if(r==="*"||r.includes(e.kind))continue;let k=E(a.input),g=k.find(v=>v.name!==h.arg&&(v.kinds.includes("*")||v.kinds.includes(e.kind)));if(!g)continue;let $=r,j=$.includes("*")?n.graph.allNodes().map(v=>v.id):$.flatMap(v=>n.graph.nodesOfKind(v).map(I=>I.id)),u=new Set(s(e.id,o.length>0?o:m,$)),p=o.length>0?j.filter(v=>!u.has(v)):j.filter(v=>u.has(v));if(p.length===0)continue;let w=[{name:h.arg,kinds:$,candidates:p,shape:N(a.input,h.arg)}];for(let v of k){if(v.name===g.name||v.name===h.arg)continue;let I=v.kinds.includes("*")?n.graph.allNodes().map(D=>D.id):v.kinds.flatMap(D=>n.graph.nodesOfKind(D).map(O=>O.id));w.push({name:v.name,kinds:v.kinds,candidates:I,shape:N(a.input,v.name),...v.optional?{optional:!0}:{}})}for(let v of G(a.input,g.name))v===h.arg||w.some(I=>I.name===v)||w.push({name:v,shape:N(a.input,v)});w.every(v=>v.optional===!0?!0:v.kinds!==void 0?(v.candidates?.length??0)>0:(v.candidates?.length??0)>0||v.shape!==void 0&&v.shape.type!=="unknown")&&c.push({id:`schema:tie:${a.name}:${e.id}`,label:a.fromTheOtherEnd??K(a),provider:"schema",mutation:a.name,args:{[g.name]:e.id},open:w,ties:!0,...a.destructive?{destructive:!0}:{},score:U-w.length+2,why:`${m.length>0?"this one is on":"this one could join"} ${w[0].candidates.length===1?"it":"one of these"}`,nodeIds:[e.id]})}}return{affordances:c}}}}function yn(n,d){let t=n.shape;return t?Object.entries(t).filter(([f,y])=>f!==d&&y.safeParse(void 0).success).map(([f])=>f):[]}function vn(n,d,t){try{return n.preview({name:d,args:t}),!0}catch{return!1}}function G(n,d){let t=n.shape;return t?Object.entries(t).filter(([f,y])=>f!==d&&!y.safeParse(void 0).success).map(([f])=>f):[]}var bn=70,Sn=80,wn=new Set(["id","kind"]);function hn(){return{name:"structure",derive({store:n,nodes:d}){let t=c=>F(n.schema.tryDefinition(c.kind),c);if(d.length<2)return{};let f=[],y=[],l=d.map(c=>c.id);for(let c of n.schema.edgeKinds){let S=An(d.map(e=>new Set([...n.graph.out(e.id,c).map(a=>a.id),...n.graph.in(e.id,c).map(a=>a.id)])));for(let e of S){let a=n.graph.getNode(e);a&&f.push({id:`shared:${c}:${e}`,text:`all ${d.length} share "${t(a)}" (${q(c).toLowerCase()})`,nodeIds:[...l,e]})}let s=new Map;for(let e of d)for(let a of[...n.graph.out(e.id,c),...n.graph.in(e.id,c)])s.set(a.id,(s.get(a.id)??0)+1);for(let[e,a]of s){if(a!==d.length-1||d.length<3||l.includes(e))continue;let h=n.graph.getNode(e);if(!h)continue;let m=d.find(o=>![...n.graph.out(o.id,c),...n.graph.in(o.id,c)].some(r=>r.id===e));if(m&&(f.push({id:`near-shared:${c}:${e}`,text:`all but "${t(m)}" share "${t(h)}" (${q(c).toLowerCase()})`,nodeIds:[...l,e]}),!(!n.schema.edgeAllowed(c,m.kind,h.kind)&&!n.schema.edgeAllowed(c,h.kind,m.kind))))for(let o of n.allMutations()){let r=o.subject;if(!r||r.kinds!=="*"&&!r.kinds.includes(m.kind)||(o.connects!==void 0||o.severs!==void 0)&&!(o.connects??[]).includes(c))continue;let g=$n(o.input,h.kind);g&&y.push({id:`structure:join:${o.name}:${m.id}:${e}`,label:`${K(o)}: bring "${t(m)}" in line with the others`,provider:"structure",mutation:o.name,args:{[r.arg]:m.id,[g]:e},open:[],score:bn,why:`every other selected node is connected to "${t(h)}"`,nodeIds:[m.id,e]})}}}let A=new Map;for(let c of d)A.set(c.kind,[...A.get(c.kind)??[],c]);for(let[c,S]of A){if(S.length<2)continue;let s=S,e=S.map(o=>o.id),a=A.size>1?`${c}:`:"",h=new Set;for(let o of s)for(let r of Object.keys(o))wn.has(r)||h.add(r);let m=o=>n.schema.definitions.find(r=>r.kind===o);for(let o of[...h].sort()){let r=m(s[0].kind),k=tn(r,o).toLowerCase(),g=r?.display?.format?.[o],$=O=>{if(!g)return O;try{return String(g(JSON.parse(O)))}catch{return O}},j=s.map(O=>O[o]),u=new Map;if(j.forEach((O,R)=>{let L=JSON.stringify(O??null),x=u.get(L);x?x.push(s[R]):u.set(L,[s[R]])}),u.size===1){let O=[...u.keys()][0];if(O==="null")continue;f.push({id:`agree:${a}${o}`,text:`all ${s.length} share the ${k} ${$(O)}`,nodeIds:e});continue}if(s.length<3||u.size!==2)continue;let p=[...u.entries()].sort((O,R)=>R[1].length-O[1].length),[w,P]=p[0],[,v]=p[1];if(v.length!==1||w==="null")continue;let I=v[0],D=JSON.parse(w);f.push({id:`odd-one-out:${a}${o}`,text:`${P.length} share the ${k} ${$(w)}; "${t(I)}" does not`,nodeIds:e});for(let O of n.allMutations()){let R=O.subject;if(!R||R.kinds!=="*"&&!R.kinds.includes(I.kind))continue;let L=gn(O.input);if(!L||!(o in L))continue;let x={[R.arg]:I.id,[o]:D},T=!0;for(let[C,Z]of Object.entries(L)){if(C in x||Z.safeParse(void 0).success)continue;let i=I[C];if(i===void 0){T=!1;break}x[C]=i}!T||!O.input.safeParse(x).success||y.push({id:`structure:align:${O.name}:${o}:${I.id}`,label:`Align the ${k} of "${t(I)}" with the other ${P.length}`,provider:"structure",mutation:O.name,args:x,open:[],score:Sn,why:`${P.length} of ${s.length} share the ${k} ${$(w)}`,nodeIds:e})}}}return{affordances:y,observations:f}}}}function An(n){if(n.length===0)return[];let[d,...t]=n;return[...d].filter(f=>t.every(y=>y.has(f))).sort()}function gn(n){return n.shape??null}function $n(n,d){let t=gn(n);if(!t)return null;for(let[f]of Object.entries(t)){let y=sn(t[f]);if(y&&(y.includes("*")||y.includes(d)))return f}return null}function On(){return[fn(),hn(),ln(),dn()]}function Vn(n,d,t={}){let f=pn(),y=t.providers??On(),l=d.map(i=>n.graph.getNode(i)).filter(i=>i!==void 0),A={store:n,selection:d,nodes:l,kindSelection:t.kindSelection??[],edgeSelection:t.edgeSelection??[],violations:n.violations(t.context),context:t.context??{},principal:t.principal??{kind:"human"}},c=[],S=[];for(let i of y){let b=i.derive(A);c.push(...b.affordances??[]),S.push(...b.observations??[])}let s=new Set(n.allMutations().filter(i=>i.pinned).map(i=>i.name)),e=new Set(t.pins?.pinned??[]),a=new Set(t.pins?.unpinned??[]),h=i=>e.has(i.mutation)?"user":s.has(i.mutation)&&!a.has(i.mutation)?"declared":void 0,m=i=>{let b=h(i);return b?{...i,pinned:b}:i},o=new Map;for(let[i,b]of cn(n.log.all()))o.set(i,un(b));let r=i=>i.pinned==="user"?0:i.pinned==="declared"?1:2,k=i=>i.score+(o.get(i.mutation)??0),g=new Map(n.allMutations().map(i=>[i.name,i])),$=new Map,j=i=>{let b=g.get(i.mutation);if(!b)return[];let M=$.get(i.mutation);M||(M=E(b.input).map(W=>W.name),$.set(i.mutation,M));let _=[];for(let W of i.batch??[i.args])for(let X of M){let Y=W[X]??i.args[X];typeof Y=="string"&&_.push(Y)}return _},u=t.focus,p=4,w=i=>i.open.length>0?1:0,P=i=>{if(u===void 0)return p;let b=j(i);return b.length>0?b.includes(u)?v(i,0):p:i.nodeIds.includes(u)||i.subjectId===u?v(i,1):p},v=(i,b)=>i.provider==="invariant"?b:2+w(i),I=i=>i.setsAside?1:0,D=In(c).map(m),O=new Map(D.map((i,b)=>[i,b])),R=D.sort((i,b)=>{let M=Number(i.destructive??!1)-Number(b.destructive??!1);if(M!==0)return M;let _=I(i)-I(b);if(_!==0)return _;let W=P(i)-P(b);return W!==0?W:P(i)<2?O.get(i)-O.get(b):+(b.provider==="invariant")-+(i.provider==="invariant")||r(i)-r(b)||k(b)-k(i)||i.id.localeCompare(b.id)}),L=t.principal??{kind:"human"},x=[],T=[];for(let i of R){let b=n.permits({name:i.mutation,args:{...i.args,...i.batch?.[0]??{}}},L);if(b.ok)x.push(i);else{let M=jn(n,i,L);if(M==="done")continue;M?x.push(M):T.push({...i,refusal:b.refusal})}}let C=x.map((i,b)=>({...i,rank:b})),Z=T.map((i,b)=>({...i,rank:x.length+b}));return{affordances:t.limit===void 0?C:C.slice(0,t.limit),withheld:Z,observations:Pn(S),ms:pn()-f}}function In(n){let d=new Map;for(let t of n){let f=[t.mutation,JSON.stringify(t.args),JSON.stringify(t.batch??null)].join("|"),y=d.get(f);(!y||t.score>y.score)&&d.set(f,t)}return[...d.values()]}function Pn(n){let d=new Map;for(let t of n)d.set(t.text,t);return[...d.values()]}function pn(){return typeof performance<"u"?performance.now():Date.now()}function Qn(n,d,t={},f={}){let y=(d.batch??[d.args]).map(A=>({name:d.mutation,args:{...d.args,...A,...t}})),l=n.allMutations().find(A=>A.name===d.mutation);return n.applyAll(y,{...l?.describe?{}:{intent:d.label},...f.author?{author:f.author}:{}})}function Un(n,d,t={},f={}){try{return n.preview({name:d.mutation,args:{...d.args,...t}})}catch(y){throw f.pressed&&on(y,f.pressed.author?.id),y}}function jn(n,d,t){let f=n.allMutations().find(s=>s.name===d.mutation)?.subject,y=f!==void 0&&d.args[f.arg]===void 0,l=y?d.open.find(s=>s.name===f.arg):d.open.find(s=>s.name!==f?.arg&&s.candidates);if(!l?.candidates)return;let A=s=>n.permits({name:d.mutation,args:{...d.args,...d.batch?.[0]??{},[l.name]:s}},t).ok,c=l.candidates.filter(A),S=t.id===void 0?void 0:n.graph.getNode(t.id);if(c.length===0){let s=y?f.kinds:"*";return S!==void 0&&(s==="*"||s.includes(S.kind))&&A(S.id)?"done":void 0}return c.length===1&&c[0]===t.id?{...d,args:{...d.args,[l.name]:t.id},open:d.open.filter(s=>s!==l)}:{...d,open:d.open.map(s=>s===l?{...s,candidates:c}:s)}}export{Vn as a,Qn as b,Un as c};