graview 0.1.42 → 0.1.44

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 (204) hide show
  1. package/dist/preview/{chunk.XDPIS7RS.js → chunk.27ZVVPRZ.js} +1 -1
  2. package/dist/preview/chunk.2AZTW66C.js +1 -0
  3. package/dist/preview/{chunk.CSWX7YGI.js → chunk.2CPC3HQI.js} +1 -1
  4. package/dist/preview/{chunk.HQMGTPDC.js → chunk.2EXY4AHX.js} +4 -4
  5. package/dist/preview/chunk.2O2THM2R.js +1 -0
  6. package/dist/preview/{chunk.J7ZMNAWB.js → chunk.3IUJ4GW7.js} +1 -1
  7. package/dist/preview/chunk.3L7OEBJH.js +1 -0
  8. package/dist/preview/{chunk.QHLD4TZW.js → chunk.3M4VCAA3.js} +1 -1
  9. package/dist/preview/chunk.3OKJ4GOA.js +1 -0
  10. package/dist/preview/chunk.3PNDXNX6.js +1 -0
  11. package/dist/preview/{chunk.WERBD5ZR.js → chunk.3TBH2FMZ.js} +1 -1
  12. package/dist/preview/{chunk.IWLVZGW5.js → chunk.4B4DKCS4.js} +1 -1
  13. package/dist/preview/{chunk.PCTVLNOS.js → chunk.4EPT2CQG.js} +1 -1
  14. package/dist/preview/chunk.4JWT6LIS.js +25 -0
  15. package/dist/preview/chunk.4WCQWILK.js +1 -0
  16. package/dist/preview/chunk.56DR42FA.js +1 -0
  17. package/dist/preview/chunk.5JPELFMA.js +2 -0
  18. package/dist/preview/chunk.5WEEZ7WD.js +1 -0
  19. package/dist/preview/chunk.64QDUERE.js +1 -0
  20. package/dist/preview/{chunk.I7QCXRP7.js → chunk.6BIRNR5P.js} +1 -1
  21. package/dist/preview/{chunk.7EB6SDUQ.js → chunk.6NFR2LYQ.js} +1 -1
  22. package/dist/preview/chunk.6VIZGLDK.js +1 -0
  23. package/dist/preview/{chunk.L6HKDIZB.js → chunk.7AEE3VHC.js} +1 -1
  24. package/dist/preview/chunk.7B5BZZBG.js +1 -0
  25. package/dist/preview/chunk.7HL7CFXJ.js +1 -0
  26. package/dist/preview/chunk.7JVBVB4A.js +1 -0
  27. package/dist/preview/{chunk.QXMTGLHR.js → chunk.7PUFYK3B.js} +1 -1
  28. package/dist/preview/{chunk.ARTJL3X2.js → chunk.7UV7ODXU.js} +1 -1
  29. package/dist/preview/chunk.ALFW4ZJQ.js +1 -0
  30. package/dist/preview/{chunk.HG2IO5NS.js → chunk.ATKKTPJS.js} +1 -1
  31. package/dist/preview/chunk.AW2T3KFV.js +5 -0
  32. package/dist/preview/{chunk.PACJFDDU.js → chunk.B2CIQ66N.js} +1 -1
  33. package/dist/preview/{chunk.5FHH5NR6.js → chunk.B7FZLIAO.js} +1 -1
  34. package/dist/preview/{chunk.NS3Z7QNP.js → chunk.BA4KQR5H.js} +1 -1
  35. package/dist/preview/chunk.CDFVEL2Y.js +1 -0
  36. package/dist/preview/chunk.CSQNDAEK.js +1 -0
  37. package/dist/preview/chunk.D2RK2KJD.js +35 -0
  38. package/dist/preview/chunk.DAZEFSWI.js +1 -0
  39. package/dist/preview/{chunk.KMGGP6XT.js → chunk.DGXWL4GC.js} +2 -2
  40. package/dist/preview/chunk.DLVNW4HU.js +1 -0
  41. package/dist/preview/chunk.E2AJ7U5Z.js +1 -0
  42. package/dist/preview/chunk.EJAWDI2V.js +1 -0
  43. package/dist/preview/chunk.EJOTTZWZ.js +1 -0
  44. package/dist/preview/{chunk.WVN62OMH.js → chunk.ESU2DD3J.js} +1 -1
  45. package/dist/preview/chunk.EW364363.js +9 -0
  46. package/dist/preview/chunk.EYEIDL3T.js +1 -0
  47. package/dist/preview/chunk.EZRGGPAN.js +1 -0
  48. package/dist/preview/{chunk.SUQU4AXG.js → chunk.F4DWRBO7.js} +1 -1
  49. package/dist/preview/{chunk.K63BUJBF.js → chunk.FBIK4LTM.js} +2 -2
  50. package/dist/preview/{chunk.ILPD5CZG.js → chunk.FIJNKSMQ.js} +1 -1
  51. package/dist/preview/{chunk.Y2QDZLSY.js → chunk.FNF6XQI5.js} +1 -1
  52. package/dist/preview/chunk.FNXW46U4.js +349 -0
  53. package/dist/preview/chunk.FUYMLDNJ.js +7 -0
  54. package/dist/preview/chunk.FVHECT47.js +1 -0
  55. package/dist/preview/{chunk.KZDLDXLB.js → chunk.GAN77YDU.js} +1 -1
  56. package/dist/preview/{chunk.O7VHAKSA.js → chunk.GBCWI2LF.js} +1 -1
  57. package/dist/preview/chunk.H4GHKBMH.js +1 -0
  58. package/dist/preview/chunk.HB34VQKQ.js +1 -0
  59. package/dist/preview/chunk.HKA27VJO.js +1 -0
  60. package/dist/preview/{chunk.4YBP552Z.js → chunk.HKD5SR45.js} +2 -2
  61. package/dist/preview/{chunk.6HUS5UHZ.js → chunk.HP72LB3B.js} +1 -1
  62. package/dist/preview/{chunk.B6DKKNVR.js → chunk.IBWPRK2R.js} +1 -1
  63. package/dist/preview/{chunk.V3K32XD7.js → chunk.IIB22IIP.js} +1 -1
  64. package/dist/preview/{chunk.57R4ZUMM.js → chunk.IN4PKQO5.js} +1 -1
  65. package/dist/preview/chunk.IPHWGBZE.js +6 -0
  66. package/dist/preview/{chunk.B7DCQJXV.js → chunk.IQWKEGWG.js} +1 -1
  67. package/dist/preview/chunk.JEMQ66FT.js +19 -0
  68. package/dist/preview/chunk.JGYGSNQY.js +1 -0
  69. package/dist/preview/{chunk.EC2T2UVH.js → chunk.JLOSQ5UY.js} +2 -2
  70. package/dist/preview/{chunk.X5WIS4BC.js → chunk.JQ7WY2VZ.js} +1 -1
  71. package/dist/preview/chunk.JUT2VCFW.js +1 -0
  72. package/dist/preview/{chunk.VTUMPH4Z.js → chunk.KERLVJ6I.js} +1 -1
  73. package/dist/preview/chunk.L6FWIQXS.js +1 -0
  74. package/dist/preview/{chunk.U3MQUIJL.js → chunk.LKF4BBCW.js} +1 -1
  75. package/dist/preview/chunk.LKXYZK5H.js +1 -0
  76. package/dist/preview/chunk.LULTKYE3.js +1 -0
  77. package/dist/preview/chunk.LUPBT6YM.js +1 -0
  78. package/dist/preview/{chunk.VO6DBVZR.js → chunk.LYSHLKAX.js} +1 -1
  79. package/dist/preview/chunk.LYUPJ4VV.js +1 -0
  80. package/dist/preview/{chunk.ZQCGDTQ3.js → chunk.MFLJIFZD.js} +1 -1
  81. package/dist/preview/chunk.MOF2D6DV.js +1 -0
  82. package/dist/preview/{chunk.CAZX6OPN.js → chunk.MWUP5X47.js} +1 -1
  83. package/dist/preview/{chunk.LFJH6X6O.js → chunk.MZOIPCDA.js} +1 -1
  84. package/dist/preview/{chunk.VMBIFUYX.js → chunk.N5ULWKR4.js} +1 -1
  85. package/dist/preview/{chunk.27P37343.js → chunk.NBOZPPSM.js} +1 -1
  86. package/dist/preview/chunk.NPS2WN7T.js +1 -0
  87. package/dist/preview/chunk.NTFCZYOR.js +1 -0
  88. package/dist/preview/chunk.O4VSQ2ER.js +1 -0
  89. package/dist/preview/{chunk.ROHM3ETN.js → chunk.OAWAUB4P.js} +1 -1
  90. package/dist/preview/chunk.OG6GNGTX.js +21 -0
  91. package/dist/preview/{chunk.V5VQCANB.js → chunk.OGF6UORU.js} +1 -1
  92. package/dist/preview/chunk.OK4FSBHI.js +1 -0
  93. package/dist/preview/chunk.P546VMA5.js +1 -0
  94. package/dist/preview/chunk.P5K7EYDK.js +1 -0
  95. package/dist/preview/{chunk.BZ4VZ6WQ.js → chunk.PL2P2OON.js} +1 -1
  96. package/dist/preview/chunk.PSTE3LZL.js +5 -0
  97. package/dist/preview/chunk.PX6VAZFJ.js +1 -0
  98. package/dist/preview/{chunk.P6J6VFF5.js → chunk.QJJKITXF.js} +1 -1
  99. package/dist/preview/{chunk.U6YOAS4X.js → chunk.QNJYXB3U.js} +1 -1
  100. package/dist/preview/chunk.RDGFZPKN.js +1 -0
  101. package/dist/preview/{chunk.LWAZ6ZO6.js → chunk.REEDZSCG.js} +2 -2
  102. package/dist/preview/chunk.REOYQTFP.js +1 -0
  103. package/dist/preview/{chunk.2ZGICECC.js → chunk.RLMW7DU6.js} +1 -1
  104. package/dist/preview/{chunk.VEP4EJ2N.js → chunk.RNUGQRJI.js} +1 -1
  105. package/dist/preview/{chunk.ZRIDKFTV.js → chunk.RVQYXPCM.js} +1 -1
  106. package/dist/preview/{chunk.LQGXUMUX.js → chunk.RYNCEZ6Q.js} +1 -1
  107. package/dist/preview/{chunk.WUQOSVQU.js → chunk.T6S3CEW7.js} +2 -2
  108. package/dist/preview/{chunk.PH5ITX3N.js → chunk.TDCO7LEA.js} +1 -1
  109. package/dist/preview/chunk.TJO5Y2OJ.js +1 -0
  110. package/dist/preview/chunk.TTSNHX3F.js +1 -0
  111. package/dist/preview/{chunk.QHP7AJUV.js → chunk.U3CV5CCL.js} +1 -1
  112. package/dist/preview/{chunk.VKJAGZNU.js → chunk.UG23RICT.js} +1 -1
  113. package/dist/preview/chunk.URCC626R.js +1 -0
  114. package/dist/preview/{chunk.37NF3YXZ.js → chunk.UXLJZIYX.js} +1 -1
  115. package/dist/preview/{chunk.AQTCN7KQ.js → chunk.UZSZPMRC.js} +1 -1
  116. package/dist/preview/chunk.V4DR25S4.js +1 -0
  117. package/dist/preview/chunk.VAUG5TGZ.js +1 -0
  118. package/dist/preview/{chunk.HAY22FPJ.js → chunk.WE5SA6TP.js} +1 -1
  119. package/dist/preview/chunk.WNYPP52L.js +1 -0
  120. package/dist/preview/chunk.WPLKHIO5.js +88 -0
  121. package/dist/preview/{chunk.XNW7PUAF.js → chunk.XPIDPZKS.js} +1 -1
  122. package/dist/preview/{chunk.P7ISPJAQ.js → chunk.Y2MIG2C2.js} +1 -1
  123. package/dist/preview/chunk.YE4GZVOX.js +1 -0
  124. package/dist/preview/chunk.YERDP6YF.js +1 -0
  125. package/dist/preview/{chunk.5NDYYTT4.js → chunk.YGX2AE36.js} +1 -1
  126. package/dist/preview/chunk.YTXEPWVW.js +1 -0
  127. package/dist/preview/chunk.YTZDCIX2.js +1 -0
  128. package/dist/preview/chunk.YYPK7IDM.js +1 -0
  129. package/dist/preview/chunk.ZKBSEUK4.js +1 -0
  130. package/dist/preview/chunk.ZN77U6SU.js +1 -0
  131. package/dist/preview/{chunk.HOTOH7ZB.js → chunk.ZP6PS5Z4.js} +1 -1
  132. package/dist/preview/chunk.ZZ5F5I3O.js +1 -0
  133. package/dist/preview/index.html +46 -45
  134. package/dist/preview/page.js +6 -6
  135. package/package.json +6 -6
  136. package/dist/preview/chunk.22QEYFWI.js +0 -1
  137. package/dist/preview/chunk.35FR36BQ.js +0 -1
  138. package/dist/preview/chunk.36LP3I7Z.js +0 -21
  139. package/dist/preview/chunk.3K2KBIRG.js +0 -1
  140. package/dist/preview/chunk.3SKUJWFC.js +0 -1
  141. package/dist/preview/chunk.3WABA2WQ.js +0 -1
  142. package/dist/preview/chunk.4NBB44YU.js +0 -1
  143. package/dist/preview/chunk.4QEDYRES.js +0 -349
  144. package/dist/preview/chunk.4YRCKOX2.js +0 -1
  145. package/dist/preview/chunk.6MLAJKYM.js +0 -1
  146. package/dist/preview/chunk.6NF32PAT.js +0 -1
  147. package/dist/preview/chunk.6WB24MS3.js +0 -1
  148. package/dist/preview/chunk.7HZVCW3Q.js +0 -1
  149. package/dist/preview/chunk.7MJM3OVC.js +0 -1
  150. package/dist/preview/chunk.7OSL64QH.js +0 -1
  151. package/dist/preview/chunk.7XDNCCLG.js +0 -6
  152. package/dist/preview/chunk.7Z2GTKA4.js +0 -1
  153. package/dist/preview/chunk.AOC2KUFE.js +0 -1
  154. package/dist/preview/chunk.AWSUMY3D.js +0 -1
  155. package/dist/preview/chunk.B65HPL4I.js +0 -1
  156. package/dist/preview/chunk.BJET6KOG.js +0 -1
  157. package/dist/preview/chunk.D3ELYLME.js +0 -1
  158. package/dist/preview/chunk.DNMBZONP.js +0 -1
  159. package/dist/preview/chunk.DXAUXGNN.js +0 -1
  160. package/dist/preview/chunk.EHMCRUYR.js +0 -1
  161. package/dist/preview/chunk.EQIQPY4O.js +0 -1
  162. package/dist/preview/chunk.ETWOZQWL.js +0 -1
  163. package/dist/preview/chunk.EVHXF7LZ.js +0 -19
  164. package/dist/preview/chunk.FFRWSODT.js +0 -1
  165. package/dist/preview/chunk.G4AY6NGN.js +0 -1
  166. package/dist/preview/chunk.GN2SZEFH.js +0 -1
  167. package/dist/preview/chunk.GXWOEOUY.js +0 -1
  168. package/dist/preview/chunk.IGA7OD3L.js +0 -1
  169. package/dist/preview/chunk.IXS5XBG6.js +0 -1
  170. package/dist/preview/chunk.JCTT2LAK.js +0 -1
  171. package/dist/preview/chunk.JE4QQEJE.js +0 -25
  172. package/dist/preview/chunk.JEBB3WM7.js +0 -1
  173. package/dist/preview/chunk.JPD2I4Z7.js +0 -1
  174. package/dist/preview/chunk.LKGDN25E.js +0 -1
  175. package/dist/preview/chunk.LMUFLZYT.js +0 -1
  176. package/dist/preview/chunk.LZH65VSN.js +0 -7
  177. package/dist/preview/chunk.MUBZIU6F.js +0 -1
  178. package/dist/preview/chunk.MZ6I2Q4E.js +0 -1
  179. package/dist/preview/chunk.NTJNBKWC.js +0 -1
  180. package/dist/preview/chunk.OMCXJGDI.js +0 -1
  181. package/dist/preview/chunk.OTHGZPUC.js +0 -1
  182. package/dist/preview/chunk.P6FGIYWP.js +0 -35
  183. package/dist/preview/chunk.PYFQGBU3.js +0 -1
  184. package/dist/preview/chunk.RFCTUGMU.js +0 -1
  185. package/dist/preview/chunk.RR4RZH4S.js +0 -1
  186. package/dist/preview/chunk.S5K4FLLG.js +0 -1
  187. package/dist/preview/chunk.SZKVNPEF.js +0 -1
  188. package/dist/preview/chunk.T3F6BKIO.js +0 -1
  189. package/dist/preview/chunk.UG727PEE.js +0 -5
  190. package/dist/preview/chunk.VXZFW52D.js +0 -1
  191. package/dist/preview/chunk.VYPR2MZO.js +0 -1
  192. package/dist/preview/chunk.W77OH637.js +0 -1
  193. package/dist/preview/chunk.WODEO2JF.js +0 -9
  194. package/dist/preview/chunk.WZEA2UK6.js +0 -1
  195. package/dist/preview/chunk.X2M7IOQA.js +0 -1
  196. package/dist/preview/chunk.XPML6T3P.js +0 -1
  197. package/dist/preview/chunk.YJM23BJL.js +0 -88
  198. package/dist/preview/chunk.YLGSXLXF.js +0 -1
  199. package/dist/preview/chunk.YLI6I6XP.js +0 -1
  200. package/dist/preview/chunk.YRYEWVNP.js +0 -1
  201. package/dist/preview/chunk.Z2TYCMBT.js +0 -5
  202. package/dist/preview/chunk.ZAFIZXGX.js +0 -1
  203. package/dist/preview/chunk.ZBYLAC3B.js +0 -2
  204. package/dist/preview/chunk.ZOS5APMD.js +0 -1
@@ -1 +1 @@
1
- import{a as O,b,c as w,d as R,e as V}from"./chunk.J7ZMNAWB.js";import{h as l,i as S}from"./chunk.VKJAGZNU.js";import{Ha as $,Ia as F}from"./chunk.UG727PEE.js";var E=["card","row","page"],j=["good","warn","bad","neutral","accent"],H=["money","percent","date","time","datetime","relative","count"],_=4,T=40,I=120,L=["number","money","percent"],B=["large"],U=["card","row"],M=1e3,fe=100;function C(e){let n=/^\s*(out|in)\(\s*['"]([A-Za-z][A-Za-z0-9_-]*)['"]\s*\)\s*$/.exec(e);return n?{edge:n[2],way:n[1]}:/^[A-Za-z][A-Za-z0-9_-]*$/.test(e)?{edge:e}:void 0}var v={title:[],headline:[],list:["sort","limit","group","empty","as"],text:["tone"],badge:["tone"],field:["as","currency","label"],image:["as","label"],progress:["label"],group:["direction"],when:["show"],divider:[],figure:["as","currency","label","emphasis"]},Z=Object.keys(v),G=`{"title": "{name}"}, {"headline": "{count(all('offer'))} offers"}, {"figure": expr, "as"?: "number"|"money"|"percent", "currency"?, "label"?, "emphasis"?: "large"}, {"list": expr, "sort"?, "limit"?, "group"?, "empty"?, "as"?: "card"|"row"}, {"text": "\u2026", "tone"?}, {"badge": "{status}", "tone"?}, {"field": "quote", "as"?, "currency"?, "label"?}, {"image": "photos", "as"?: "thumb"|"gallery"}, {"progress": {"value": expr, "max": expr}, "label"?}, {"group": [blocks], "direction"?: "row"|"column"}, {"when": expr, "show": [blocks]}, {"divider": true}, {"figure": true}`,X=e=>/^(image|video|file)$/.test(e?.of??e?.type??"");function ue(e){return Object.fromEntries(Object.entries(e.views??{}).filter(([,n])=>!Array.isArray(n)))}function ce(e){let n=e.views?.home;return Array.isArray(n)?n:void 0}var Y={field:()=>!1,relation:()=>!1,figure:!1},z=e=>e.kind??"the home",m=(e,n)=>e!==void 0&&Object.hasOwn(e,n),g=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function N(e,n,t){let o=O(e);for(let a of o.unknownFunctions)t.findings.push(l("unknown-function",n,`"${a}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let a of o.names){if(t.kind===null){t.findings.push(l("view-name",n,`"${a}" names nothing here: these blocks are about no one record`,"reach records with all('<kind>'), like count(all('offer')) or first(all('party') where role == 'client').name"));continue}a==="id"||t.spec.field(a)||t.spec.relation(a)||t.findings.push(l("view-name",n,`${t.kind} has no field or relation called "${a}"`))}for(let a of o.edges)t.edges.has(a)||t.findings.push(l("view-edge",n,`"${a}" is not a relation any kind declares`));for(let a of o.sweeps)t.kinds.has(a)||t.findings.push(l("view-kind",n,`"${a}" is not a kind this document declares`))}function k(e,n,t){if(typeof e!="string"||e.length===0||e.length>2e3){t.findings.push(l("view-expression",n,`an expression is a line of the rule language, like "status == 'booked'"`));return}try{N(w(e),n,t)}catch(o){if(!(o instanceof b))throw o;t.findings.push(l("expression",n,`${o.sentence} (at character ${o.at+1})`))}}function A(e,n,t,o){let a=o==="text";if(typeof e!="string"||e.length===0||e.length>300){t.findings.push(l("view-template",n,'a template is words with {field} in braces, like "{name}" or "{quote|money}", at most 300 characters'));return}let d;try{d=V(e)}catch(r){if(r instanceof R||r instanceof b){t.findings.push(l("template",n,r.sentence));return}throw r}for(let r of d)if(r.expr){if(N(r.expr,n,t),a&&!r.format&&r.expr.t==="ident"&&(t.slot==="card"||t.slot==="row")&&t.spec.prose?.(r.expr.name)){let i=r.expr.name;t.findings.push(S("view-whole-text",n,`${t.kind} ${t.slot} shows ${i} whole; it will be clamped. Use {${i}|excerpt} or move it to the page.`,`write {${i}|excerpt}, or {${i}|excerpt: 80} for fewer characters`))}if(o==="headline"&&!r.format&&r.expr.t==="ident"&&t.spec.prose?.(r.expr.name)){let i=r.expr.name;t.findings.push(S("view-headline-long",n,`${z(t)}${t.slot?` ${t.slot}`:""} heads it with ${i}, a long text, drawn at a headline's size; a headline is a few words.`,`say it in a text block, {"text": "{${i}}"}, or head it with {${i}|excerpt: 60}`))}}}function q(e,n,t){if(typeof e=="string"){j.includes(e)||t.findings.push(l("view-tone",n,`"${e}" is not a tone`,`use one of ${j.join(", ")}, or {"expr": "if(status == 'booked', 'good', 'neutral')"}`));return}if(g(e)&&Object.keys(e).length===1&&"expr"in e){k(e.expr,`${n}.expr`,t);return}t.findings.push(l("view-tone",n,'a tone is a word or {"expr": \u2026}',`one of ${j.join(", ")}`))}function x(e,n,t,o){if(!Array.isArray(e)){o.findings.push(l("view-shape",n,"a view is a list of blocks"));return}if(t>_){o.findings.push(l("view-depth",n,`blocks nest at most ${_} deep`,"flatten a group or a condition"));return}e.forEach((a,d)=>J(a,`${n}.${d}`,t,o))}function J(e,n,t,o){if(t===1&&o.count++,o.all++,!g(e)){o.findings.push(l("view-block",n,"a block is an object naming what it shows",`one of ${G}`));return}let a=Object.keys(e),d=a.filter(s=>Z.includes(s)&&!(s==="group"&&a.includes("list")));if(d.length===0){o.findings.push(l("view-block",n,`${a.length>0?a.map(s=>`"${s}"`).join(", "):"an empty object"} is not a block Graview knows`,`one of ${G}`));return}if(d.length>1){o.findings.push(l("view-block",n,`a block is one thing, and this says ${d.map(s=>`"${s}"`).join(" and ")}`,"split it into two blocks"));return}let r=d[0];for(let s of a)s!==r&&s!="key"&&!v[r].includes(s)&&o.findings.push(l("unknown-key",`${n}.${s}`,`"${s}" is not part of a ${r} block`,v[r].length>0?`a ${r} block may also say ${v[r].map(f=>`"${f}"`).join(", ")}`:`a ${r} block says nothing else`));let i=e[r];switch(r){case"title":case"headline":case"text":case"badge":A(i,`${n}.${r}`,o,r==="text"||r==="headline"?r:void 0),"tone"in e&&q(e.tone,`${n}.tone`,o);return;case"image":case"field":{let s=r==="image";if(typeof i!="string"||!(s?o.spec.files?.(i):o.spec.field(i))){let u=typeof i=="string"&&o.spec.relation(i);o.findings.push(l(`view-${r}`,`${n}.${r}`,`${o.kind} has no ${s?"image, video or file ":""}field ${typeof i=="string"?`"${i}"`:"by that name"}`,u?`"${i}" is a relation; show it with {"text": "{${i}.name}"}`:void 0))}let f=s?["thumb","gallery"]:H;"as"in e&&!f.includes(e.as)&&o.findings.push(l("view-format",`${n}.as`,`"${String(e.as)}" is not a way to show ${s?"pictures":"a field"}`,`use one of ${f.join(", ")}`)),s||W(e,n,o,"field"),"label"in e&&ie(e.label,`${n}.label`,o);return}case"progress":{!g(i)||Object.keys(i).some(s=>s!=="value"&&s!=="max")||!("value"in i)||!("max"in i)?o.findings.push(l("view-progress",`${n}.progress`,'progress is {"value": expression, "max": expression}')):(k(i.value,`${n}.progress.value`,o),k(i.max,`${n}.progress.max`,o)),"label"in e&&A(e.label,`${n}.label`,o);return}case"group":"direction"in e&&e.direction!=="row"&&e.direction!=="column"&&o.findings.push(l("view-direction",`${n}.direction`,`a group runs "row" or "column", not "${String(e.direction)}"`)),x(i,`${n}.group`,t+1,o);return;case"when":k(i,`${n}.when`,o),"show"in e?x(e.show,`${n}.show`,t+1,o):o.findings.push(l("view-when",n,'a condition says what it shows: {"when": expr, "show": [blocks]}'));return;case"figure":if(typeof i=="string")return Q(e,n,o);for(let s of["as","currency","label","emphasis"])s in e&&o.findings.push(l("unknown-key",`${n}.${s}`,`"${s}" belongs to a figure that works a number out; {"figure": true} is the kind's picture`,`write {"figure": "count(all('offer'))", "as": "number"}`));i!==!0?o.findings.push(l("view-block",`${n}.figure`,`a figure is a number worked out, {"figure": "sum(all('offer'), net)", "as": "money"}, or the kind's picture, {"figure": true}`)):o.spec.figure||o.findings.push(l("view-figure",`${n}.figure`,`${z(o)} has no figure to show`,o.kind===null?`work a number out: {"figure": "count(all('offer'))"}`:'give the kind a "figure", or leave this block out'));return;case"list":return ne(e,n,o);case"divider":i!==!0&&o.findings.push(l("view-block",`${n}.${r}`,`write {"${r}": true}`));return}}function Q(e,n,t){k(e.figure,`${n}.figure`,t),"as"in e&&!L.includes(e.as)&&t.findings.push(l("view-format",`${n}.as`,`"${String(e.as)}" is not a way to say a figure`,`use one of ${L.join(", ")}`)),W(e,n,t,"figure"),"label"in e&&A(e.label,`${n}.label`,t),"emphasis"in e&&!B.includes(e.emphasis)&&t.findings.push(l("view-emphasis",`${n}.emphasis`,`"${String(e.emphasis)}" is not how loudly a figure is said`,`use ${B.map(o=>`"${o}"`).join(", ")}, or leave it out for the figure's own size`))}function W(e,n,t,o){"currency"in e&&(typeof e.currency!="string"||!/^[A-Z]{3}$/.test(e.currency)?t.findings.push(l("view-currency",`${n}.currency`,'a currency is its three-letter code, like "USD" or "EUR"')):e.as!=="money"&&t.findings.push(l("view-currency",`${n}.currency`,`a currency belongs on a ${o} shown as money`,'add "as": "money"')))}function ee(e,n){let t=[...n.kinds],o=(d,r)=>{let i=new Set;for(let s of d){let f=n.vocabulary.namesOf(s)?.targets?.(r);if(f==="*")return t;for(let u of f??[])i.add(u)}return i.size>0?[...i]:void 0},a=d=>{switch(d.t){case"ident":return n.kind!==null&&n.spec.relation(d.name)?o([n.kind],d.name):void 0;case"member":{let r=a(d.object);return r?o(r,d.name):void 0}case"where":return a(d.set);case"call":{let r=d.args[0],i=r?.t==="lit"&&typeof r.value=="string"?r.value:void 0;if(d.fn==="all")return i!==void 0&&n.kinds.has(i)?[i]:void 0;let s=d.args.length===2&&d.args[1]?.t==="lit"&&typeof d.args[1].value=="string"?d.args[1].value:void 0;if(d.fn==="out"&&s!==void 0){let f=a(r);return f?o(f,s):void 0}if(d.fn==="out")return i!==void 0&&n.kind!==null?o([n.kind],i):void 0;if(d.fn==="in"){let f=s??i,u=s!==void 0?a(r):n.kind!==null?[n.kind]:void 0,c=f!==void 0?n.vocabulary.sources(f).filter(p=>{let y=n.vocabulary.namesOf(p)?.targets?.(f);return!u||y==="*"||u.some(h=>y?.includes(h))}):[];return c.length>0?c:void 0}if((d.fn==="sort"||d.fn==="first")&&r)return a(r);if(d.fn==="either"){let f=d.args.map(a);return f.every(u=>u!==void 0)?[...new Set(f.flatMap(u=>u??[]))]:void 0}return}default:return}};return a(e)}function K(e,n,t,o){let a;try{a=w(e)}catch(r){if(!(r instanceof b))throw r;o.findings.push(l("expression",n,`${r.sentence} (at character ${r.at+1})`));return}let d=O(a);for(let r of d.unknownFunctions)o.findings.push(l("unknown-function",n,`"${r}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let r of d.edges)o.edges.has(r)||o.findings.push(l("view-edge",n,`"${r}" is not a relation any kind declares`));if(t)for(let r of d.names)r==="id"||t.some(i=>o.vocabulary.namesOf(i)?.field(r)||o.vocabulary.namesOf(i)?.relation(r))||o.findings.push(l("view-name",n,`${t.join(" and ")} ${t.length===1?"has":"have"} no field or relation called "${r}"`))}function ne(e,n,t){let o=e.list;k(o,`${n}.list`,t);let a;if(typeof o=="string")try{a=ee(w(o),t)}catch{a=void 0}let d=i=>{if(!a)return[...t.kinds].map(f=>t.vocabulary.namesOf(f)?.choices?.(i)).find(f=>f!==void 0);let s=a.map(f=>t.vocabulary.namesOf(f)?.choices?.(i));return s.every(f=>f!==void 0)?[...new Set(s.flatMap(f=>f??[]))]:void 0},r=a?a.join(" and "):"any kind";if("sort"in e){let i=e.sort;if(typeof i=="string")K(i,`${n}.sort`,a,t);else if(g(i)&&typeof i.by=="string"&&Object.keys(i).every(s=>s==="by"||s==="direction")){let s=i.direction;s!==void 0&&s!=="asc"&&s!=="desc"&&s!=="choices"?t.findings.push(l("list-sort",`${n}.sort.direction`,`a list is sorted "asc", "desc" or "choices", not "${String(s)}"`,'"choices" puts a choice field in the order its choices are declared')):s==="choices"?d(i.by)===void 0&&t.findings.push(l("list-sort",`${n}.sort.by`,`"${i.by}" is not a choice field of ${r}, so it has no declared order`,'sort by a choice field, or say "asc" or "desc"')):K(i.by,`${n}.sort.by`,a,t)}else t.findings.push(l("list-sort",`${n}.sort`,'a sort is a key, like "net", or {"by": key, "direction": "asc" | "desc" | "choices"}'))}if("limit"in e){let i=e.limit;(typeof i!="number"||!Number.isInteger(i)||i<1||i>M)&&t.findings.push(l("list-limit",`${n}.limit`,`a limit is a whole number from 1 to ${M}`))}if("group"in e){let i=e.group,s=typeof i=="string"?i:g(i)&&typeof i.by=="string"?i.by:void 0;if(!(typeof i=="string"||g(i)&&Object.keys(i).every(u=>u==="by"||u==="headings"))||s===void 0)t.findings.push(l("list-group",`${n}.group`,'a group is a choice field, like "type", or {"by": "type", "headings": {"pain": "What hurts"}} \u2014 or a relation, like "inGenre", a heading per linked record'));else{let u=d(s),c=u===void 0?C(s):void 0,p=c!==void 0&&(c.way!==void 0?t.edges.has(c.edge):a?a.every(y=>t.vocabulary.namesOf(y)?.relation(c.edge)):t.edges.has(c.edge));if(u===void 0&&!p&&t.findings.push(l("list-group",`${n}.group`,`"${s}" is not a choice field or a relation of ${r}, so it has nothing to group by`,'group by a field whose type is enum, or by a relation of the kind listed, like "inGenre"')),g(i)&&"headings"in i){let y=i.headings;if(!g(y)||Object.values(y).some(h=>typeof h!="string"||h.length===0||h.length>80))t.findings.push(l("list-group",`${n}.group.headings`,'headings are words per choice, like {"pain": "What hurts"}, at most 80 characters each'));else if(u)for(let h of Object.keys(y))u.includes(h)||t.findings.push(l("list-group",`${n}.group.headings.${h}`,`"${h}" is not one of ${s}'s choices`,`use ${u.join(", ")}`))}}}"empty"in e&&(typeof e.empty!="string"||e.empty.length===0||e.empty.length>200)&&t.findings.push(l("list-empty",`${n}.empty`,"what an empty list says is a sentence, at most 200 characters")),"as"in e&&!U.includes(e.as)&&t.findings.push(l("list-as",`${n}.as`,`a list draws each record as its "card" or its "row", not "${String(e.as)}"`))}function ie(e,n,t){(typeof e!="string"||e.length===0||e.length>60)&&t.findings.push(l("view-label",n,"a label is a few words, at most 60 characters"))}function D(e,n,t,o,a,d,r){let i={kind:null,spec:Y,kinds:o,edges:a,vocabulary:t,findings:d,count:0,all:0};Array.isArray(e)&&e.length===0&&d.push(l("view-shape",n,`${r} has no blocks`,'give it one: {"headline": "\u2026"}')),x(e,n,1,i),P(i,n,r,"show less")}function P(e,n,t,o){e.count>T?e.findings.push(l("view-size",n,`${t} has ${e.count} blocks at its top; a view has at most ${T} there, a group or a condition counting as one`,`${o}, or gather some into a group`)):e.all>I&&e.findings.push(l("view-size",n,`${t} has ${e.all} blocks counting the ones inside its groups and conditions; a view has at most ${I} in all`,o))}function te(e,n,t,o,a){Array.isArray(e)&&e.forEach((d,r)=>{if(!g(d)||d.name!=="blocks"||!g(d.options)||!("blocks"in d.options))return;let i=[];D(d.options.blocks,`lenses.${r}.options.blocks`,n,t,o,i,`the lens "${String(d.title??r)}"`);for(let s of i)a.push({...s,severity:"warning"})})}function oe(e,n,t,o,a,d,r){let i=[];if(e===void 0)return i;if(!g(e))return i.push(l("view-shape",n,'views are an object of kinds, each with a "card", a "row" or a "page"')),i;for(let[s,f]of Object.entries(e)){if(s==="home"&&Array.isArray(f)){D(f,`${n}.home`,r,o,a,i,"the home");continue}let u=t(s);if(!u){i.push(l("view-kind",`${n}.${s}`,`"${s}" is not a kind this ${d} declares`));continue}if(!g(f)){i.push(l("view-shape",`${n}.${s}`,`a kind's views are {"card": [blocks], "row": [blocks], "page": [blocks]}`));continue}for(let c of Object.keys(f))E.includes(c)||i.push(l("view-slot",`${n}.${s}.${c}`,`"${c}" is not a place a view is drawn`,`use ${E.map(p=>`"${p}"`).join(", ")}`));for(let c of E){let p=f[c];if(p===void 0)continue;let y={kind:s,spec:u,kinds:o,edges:a,vocabulary:r,findings:i,count:0,all:0,slot:c};x(p,`${n}.${s}.${c}`,1,y),P(y,`${n}.${s}.${c}`,`this ${c}`,"show less, or move detail to the page")}}return i}function ge(e){let n=new Set(Object.keys(e.kinds)),t=new Set(Object.values(e.kinds).flatMap(r=>Object.keys($(r.edges)))),o=r=>{let i=m(e.kinds,r)?e.kinds[r]:void 0;return i?{field:s=>m(i.fields,s)||m(i.computed,s)||F(i.edges).has(s),relation:s=>m($(i.edges),s),figure:i.figure!==void 0,files:s=>m(i.fields,s)&&X(i.fields[s]),choices:s=>m(i.fields,s)&&i.fields[s].type==="enum"?i.fields[s].options:void 0,targets:s=>m($(i.edges),s)?i.edges[s].to:void 0,prose:s=>m(i.fields,s)&&i.fields[s].type==="text"}:void 0},a={namesOf:o,sources:r=>Object.keys(e.kinds).filter(i=>m(e.kinds[i].edges,r))},d=oe(e.views,"views",o,n,t,"document",a);return te(e.lenses,a,n,t,d),d}export{j as a,H as b,L as c,B as d,M as e,fe as f,C as g,ue as h,ce as i,ge as j};
1
+ import{a as O,b,c as w,d as R,e as V}from"./chunk.3IUJ4GW7.js";import{h as l,i as S}from"./chunk.UG23RICT.js";import{Ha as $,Ia as F}from"./chunk.AW2T3KFV.js";var E=["card","row","page"],j=["good","warn","bad","neutral","accent"],H=["money","percent","date","time","datetime","relative","count"],_=4,T=40,I=120,L=["number","money","percent"],B=["large"],U=["card","row"],M=1e3,fe=100;function C(e){let n=/^\s*(out|in)\(\s*['"]([A-Za-z][A-Za-z0-9_-]*)['"]\s*\)\s*$/.exec(e);return n?{edge:n[2],way:n[1]}:/^[A-Za-z][A-Za-z0-9_-]*$/.test(e)?{edge:e}:void 0}var v={title:[],headline:[],list:["sort","limit","group","empty","as"],text:["tone"],badge:["tone"],field:["as","currency","label"],image:["as","label"],progress:["label"],group:["direction"],when:["show"],divider:[],figure:["as","currency","label","emphasis"]},Z=Object.keys(v),G=`{"title": "{name}"}, {"headline": "{count(all('offer'))} offers"}, {"figure": expr, "as"?: "number"|"money"|"percent", "currency"?, "label"?, "emphasis"?: "large"}, {"list": expr, "sort"?, "limit"?, "group"?, "empty"?, "as"?: "card"|"row"}, {"text": "\u2026", "tone"?}, {"badge": "{status}", "tone"?}, {"field": "quote", "as"?, "currency"?, "label"?}, {"image": "photos", "as"?: "thumb"|"gallery"}, {"progress": {"value": expr, "max": expr}, "label"?}, {"group": [blocks], "direction"?: "row"|"column"}, {"when": expr, "show": [blocks]}, {"divider": true}, {"figure": true}`,X=e=>/^(image|video|file)$/.test(e?.of??e?.type??"");function ue(e){return Object.fromEntries(Object.entries(e.views??{}).filter(([,n])=>!Array.isArray(n)))}function ce(e){let n=e.views?.home;return Array.isArray(n)?n:void 0}var Y={field:()=>!1,relation:()=>!1,figure:!1},z=e=>e.kind??"the home",m=(e,n)=>e!==void 0&&Object.hasOwn(e,n),g=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function N(e,n,t){let o=O(e);for(let a of o.unknownFunctions)t.findings.push(l("unknown-function",n,`"${a}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let a of o.names){if(t.kind===null){t.findings.push(l("view-name",n,`"${a}" names nothing here: these blocks are about no one record`,"reach records with all('<kind>'), like count(all('offer')) or first(all('party') where role == 'client').name"));continue}a==="id"||t.spec.field(a)||t.spec.relation(a)||t.findings.push(l("view-name",n,`${t.kind} has no field or relation called "${a}"`))}for(let a of o.edges)t.edges.has(a)||t.findings.push(l("view-edge",n,`"${a}" is not a relation any kind declares`));for(let a of o.sweeps)t.kinds.has(a)||t.findings.push(l("view-kind",n,`"${a}" is not a kind this document declares`))}function k(e,n,t){if(typeof e!="string"||e.length===0||e.length>2e3){t.findings.push(l("view-expression",n,`an expression is a line of the rule language, like "status == 'booked'"`));return}try{N(w(e),n,t)}catch(o){if(!(o instanceof b))throw o;t.findings.push(l("expression",n,`${o.sentence} (at character ${o.at+1})`))}}function A(e,n,t,o){let a=o==="text";if(typeof e!="string"||e.length===0||e.length>300){t.findings.push(l("view-template",n,'a template is words with {field} in braces, like "{name}" or "{quote|money}", at most 300 characters'));return}let d;try{d=V(e)}catch(r){if(r instanceof R||r instanceof b){t.findings.push(l("template",n,r.sentence));return}throw r}for(let r of d)if(r.expr){if(N(r.expr,n,t),a&&!r.format&&r.expr.t==="ident"&&(t.slot==="card"||t.slot==="row")&&t.spec.prose?.(r.expr.name)){let i=r.expr.name;t.findings.push(S("view-whole-text",n,`${t.kind} ${t.slot} shows ${i} whole; it will be clamped. Use {${i}|excerpt} or move it to the page.`,`write {${i}|excerpt}, or {${i}|excerpt: 80} for fewer characters`))}if(o==="headline"&&!r.format&&r.expr.t==="ident"&&t.spec.prose?.(r.expr.name)){let i=r.expr.name;t.findings.push(S("view-headline-long",n,`${z(t)}${t.slot?` ${t.slot}`:""} heads it with ${i}, a long text, drawn at a headline's size; a headline is a few words.`,`say it in a text block, {"text": "{${i}}"}, or head it with {${i}|excerpt: 60}`))}}}function q(e,n,t){if(typeof e=="string"){j.includes(e)||t.findings.push(l("view-tone",n,`"${e}" is not a tone`,`use one of ${j.join(", ")}, or {"expr": "if(status == 'booked', 'good', 'neutral')"}`));return}if(g(e)&&Object.keys(e).length===1&&"expr"in e){k(e.expr,`${n}.expr`,t);return}t.findings.push(l("view-tone",n,'a tone is a word or {"expr": \u2026}',`one of ${j.join(", ")}`))}function x(e,n,t,o){if(!Array.isArray(e)){o.findings.push(l("view-shape",n,"a view is a list of blocks"));return}if(t>_){o.findings.push(l("view-depth",n,`blocks nest at most ${_} deep`,"flatten a group or a condition"));return}e.forEach((a,d)=>J(a,`${n}.${d}`,t,o))}function J(e,n,t,o){if(t===1&&o.count++,o.all++,!g(e)){o.findings.push(l("view-block",n,"a block is an object naming what it shows",`one of ${G}`));return}let a=Object.keys(e),d=a.filter(s=>Z.includes(s)&&!(s==="group"&&a.includes("list")));if(d.length===0){o.findings.push(l("view-block",n,`${a.length>0?a.map(s=>`"${s}"`).join(", "):"an empty object"} is not a block Graview knows`,`one of ${G}`));return}if(d.length>1){o.findings.push(l("view-block",n,`a block is one thing, and this says ${d.map(s=>`"${s}"`).join(" and ")}`,"split it into two blocks"));return}let r=d[0];for(let s of a)s!==r&&s!="key"&&!v[r].includes(s)&&o.findings.push(l("unknown-key",`${n}.${s}`,`"${s}" is not part of a ${r} block`,v[r].length>0?`a ${r} block may also say ${v[r].map(f=>`"${f}"`).join(", ")}`:`a ${r} block says nothing else`));let i=e[r];switch(r){case"title":case"headline":case"text":case"badge":A(i,`${n}.${r}`,o,r==="text"||r==="headline"?r:void 0),"tone"in e&&q(e.tone,`${n}.tone`,o);return;case"image":case"field":{let s=r==="image";if(typeof i!="string"||!(s?o.spec.files?.(i):o.spec.field(i))){let u=typeof i=="string"&&o.spec.relation(i);o.findings.push(l(`view-${r}`,`${n}.${r}`,`${o.kind} has no ${s?"image, video or file ":""}field ${typeof i=="string"?`"${i}"`:"by that name"}`,u?`"${i}" is a relation; show it with {"text": "{${i}.name}"}`:void 0))}let f=s?["thumb","gallery"]:H;"as"in e&&!f.includes(e.as)&&o.findings.push(l("view-format",`${n}.as`,`"${String(e.as)}" is not a way to show ${s?"pictures":"a field"}`,`use one of ${f.join(", ")}`)),s||W(e,n,o,"field"),"label"in e&&ie(e.label,`${n}.label`,o);return}case"progress":{!g(i)||Object.keys(i).some(s=>s!=="value"&&s!=="max")||!("value"in i)||!("max"in i)?o.findings.push(l("view-progress",`${n}.progress`,'progress is {"value": expression, "max": expression}')):(k(i.value,`${n}.progress.value`,o),k(i.max,`${n}.progress.max`,o)),"label"in e&&A(e.label,`${n}.label`,o);return}case"group":"direction"in e&&e.direction!=="row"&&e.direction!=="column"&&o.findings.push(l("view-direction",`${n}.direction`,`a group runs "row" or "column", not "${String(e.direction)}"`)),x(i,`${n}.group`,t+1,o);return;case"when":k(i,`${n}.when`,o),"show"in e?x(e.show,`${n}.show`,t+1,o):o.findings.push(l("view-when",n,'a condition says what it shows: {"when": expr, "show": [blocks]}'));return;case"figure":if(typeof i=="string")return Q(e,n,o);for(let s of["as","currency","label","emphasis"])s in e&&o.findings.push(l("unknown-key",`${n}.${s}`,`"${s}" belongs to a figure that works a number out; {"figure": true} is the kind's picture`,`write {"figure": "count(all('offer'))", "as": "number"}`));i!==!0?o.findings.push(l("view-block",`${n}.figure`,`a figure is a number worked out, {"figure": "sum(all('offer'), net)", "as": "money"}, or the kind's picture, {"figure": true}`)):o.spec.figure||o.findings.push(l("view-figure",`${n}.figure`,`${z(o)} has no figure to show`,o.kind===null?`work a number out: {"figure": "count(all('offer'))"}`:'give the kind a "figure", or leave this block out'));return;case"list":return ne(e,n,o);case"divider":i!==!0&&o.findings.push(l("view-block",`${n}.${r}`,`write {"${r}": true}`));return}}function Q(e,n,t){k(e.figure,`${n}.figure`,t),"as"in e&&!L.includes(e.as)&&t.findings.push(l("view-format",`${n}.as`,`"${String(e.as)}" is not a way to say a figure`,`use one of ${L.join(", ")}`)),W(e,n,t,"figure"),"label"in e&&A(e.label,`${n}.label`,t),"emphasis"in e&&!B.includes(e.emphasis)&&t.findings.push(l("view-emphasis",`${n}.emphasis`,`"${String(e.emphasis)}" is not how loudly a figure is said`,`use ${B.map(o=>`"${o}"`).join(", ")}, or leave it out for the figure's own size`))}function W(e,n,t,o){"currency"in e&&(typeof e.currency!="string"||!/^[A-Z]{3}$/.test(e.currency)?t.findings.push(l("view-currency",`${n}.currency`,'a currency is its three-letter code, like "USD" or "EUR"')):e.as!=="money"&&t.findings.push(l("view-currency",`${n}.currency`,`a currency belongs on a ${o} shown as money`,'add "as": "money"')))}function ee(e,n){let t=[...n.kinds],o=(d,r)=>{let i=new Set;for(let s of d){let f=n.vocabulary.namesOf(s)?.targets?.(r);if(f==="*")return t;for(let u of f??[])i.add(u)}return i.size>0?[...i]:void 0},a=d=>{switch(d.t){case"ident":return n.kind!==null&&n.spec.relation(d.name)?o([n.kind],d.name):void 0;case"member":{let r=a(d.object);return r?o(r,d.name):void 0}case"where":return a(d.set);case"call":{let r=d.args[0],i=r?.t==="lit"&&typeof r.value=="string"?r.value:void 0;if(d.fn==="all")return i!==void 0&&n.kinds.has(i)?[i]:void 0;let s=d.args.length===2&&d.args[1]?.t==="lit"&&typeof d.args[1].value=="string"?d.args[1].value:void 0;if(d.fn==="out"&&s!==void 0){let f=a(r);return f?o(f,s):void 0}if(d.fn==="out")return i!==void 0&&n.kind!==null?o([n.kind],i):void 0;if(d.fn==="in"){let f=s??i,u=s!==void 0?a(r):n.kind!==null?[n.kind]:void 0,c=f!==void 0?n.vocabulary.sources(f).filter(p=>{let y=n.vocabulary.namesOf(p)?.targets?.(f);return!u||y==="*"||u.some(h=>y?.includes(h))}):[];return c.length>0?c:void 0}if((d.fn==="sort"||d.fn==="first")&&r)return a(r);if(d.fn==="either"){let f=d.args.map(a);return f.every(u=>u!==void 0)?[...new Set(f.flatMap(u=>u??[]))]:void 0}return}default:return}};return a(e)}function K(e,n,t,o){let a;try{a=w(e)}catch(r){if(!(r instanceof b))throw r;o.findings.push(l("expression",n,`${r.sentence} (at character ${r.at+1})`));return}let d=O(a);for(let r of d.unknownFunctions)o.findings.push(l("unknown-function",n,`"${r}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let r of d.edges)o.edges.has(r)||o.findings.push(l("view-edge",n,`"${r}" is not a relation any kind declares`));if(t)for(let r of d.names)r==="id"||t.some(i=>o.vocabulary.namesOf(i)?.field(r)||o.vocabulary.namesOf(i)?.relation(r))||o.findings.push(l("view-name",n,`${t.join(" and ")} ${t.length===1?"has":"have"} no field or relation called "${r}"`))}function ne(e,n,t){let o=e.list;k(o,`${n}.list`,t);let a;if(typeof o=="string")try{a=ee(w(o),t)}catch{a=void 0}let d=i=>{if(!a)return[...t.kinds].map(f=>t.vocabulary.namesOf(f)?.choices?.(i)).find(f=>f!==void 0);let s=a.map(f=>t.vocabulary.namesOf(f)?.choices?.(i));return s.every(f=>f!==void 0)?[...new Set(s.flatMap(f=>f??[]))]:void 0},r=a?a.join(" and "):"any kind";if("sort"in e){let i=e.sort;if(typeof i=="string")K(i,`${n}.sort`,a,t);else if(g(i)&&typeof i.by=="string"&&Object.keys(i).every(s=>s==="by"||s==="direction")){let s=i.direction;s!==void 0&&s!=="asc"&&s!=="desc"&&s!=="choices"?t.findings.push(l("list-sort",`${n}.sort.direction`,`a list is sorted "asc", "desc" or "choices", not "${String(s)}"`,'"choices" puts a choice field in the order its choices are declared')):s==="choices"?d(i.by)===void 0&&t.findings.push(l("list-sort",`${n}.sort.by`,`"${i.by}" is not a choice field of ${r}, so it has no declared order`,'sort by a choice field, or say "asc" or "desc"')):K(i.by,`${n}.sort.by`,a,t)}else t.findings.push(l("list-sort",`${n}.sort`,'a sort is a key, like "net", or {"by": key, "direction": "asc" | "desc" | "choices"}'))}if("limit"in e){let i=e.limit;(typeof i!="number"||!Number.isInteger(i)||i<1||i>M)&&t.findings.push(l("list-limit",`${n}.limit`,`a limit is a whole number from 1 to ${M}`))}if("group"in e){let i=e.group,s=typeof i=="string"?i:g(i)&&typeof i.by=="string"?i.by:void 0;if(!(typeof i=="string"||g(i)&&Object.keys(i).every(u=>u==="by"||u==="headings"))||s===void 0)t.findings.push(l("list-group",`${n}.group`,'a group is a choice field, like "type", or {"by": "type", "headings": {"pain": "What hurts"}} \u2014 or a relation, like "inGenre", a heading per linked record'));else{let u=d(s),c=u===void 0?C(s):void 0,p=c!==void 0&&(c.way!==void 0?t.edges.has(c.edge):a?a.every(y=>t.vocabulary.namesOf(y)?.relation(c.edge)):t.edges.has(c.edge));if(u===void 0&&!p&&t.findings.push(l("list-group",`${n}.group`,`"${s}" is not a choice field or a relation of ${r}, so it has nothing to group by`,'group by a field whose type is enum, or by a relation of the kind listed, like "inGenre"')),g(i)&&"headings"in i){let y=i.headings;if(!g(y)||Object.values(y).some(h=>typeof h!="string"||h.length===0||h.length>80))t.findings.push(l("list-group",`${n}.group.headings`,'headings are words per choice, like {"pain": "What hurts"}, at most 80 characters each'));else if(u)for(let h of Object.keys(y))u.includes(h)||t.findings.push(l("list-group",`${n}.group.headings.${h}`,`"${h}" is not one of ${s}'s choices`,`use ${u.join(", ")}`))}}}"empty"in e&&(typeof e.empty!="string"||e.empty.length===0||e.empty.length>200)&&t.findings.push(l("list-empty",`${n}.empty`,"what an empty list says is a sentence, at most 200 characters")),"as"in e&&!U.includes(e.as)&&t.findings.push(l("list-as",`${n}.as`,`a list draws each record as its "card" or its "row", not "${String(e.as)}"`))}function ie(e,n,t){(typeof e!="string"||e.length===0||e.length>60)&&t.findings.push(l("view-label",n,"a label is a few words, at most 60 characters"))}function D(e,n,t,o,a,d,r){let i={kind:null,spec:Y,kinds:o,edges:a,vocabulary:t,findings:d,count:0,all:0};Array.isArray(e)&&e.length===0&&d.push(l("view-shape",n,`${r} has no blocks`,'give it one: {"headline": "\u2026"}')),x(e,n,1,i),P(i,n,r,"show less")}function P(e,n,t,o){e.count>T?e.findings.push(l("view-size",n,`${t} has ${e.count} blocks at its top; a view has at most ${T} there, a group or a condition counting as one`,`${o}, or gather some into a group`)):e.all>I&&e.findings.push(l("view-size",n,`${t} has ${e.all} blocks counting the ones inside its groups and conditions; a view has at most ${I} in all`,o))}function te(e,n,t,o,a){Array.isArray(e)&&e.forEach((d,r)=>{if(!g(d)||d.name!=="blocks"||!g(d.options)||!("blocks"in d.options))return;let i=[];D(d.options.blocks,`lenses.${r}.options.blocks`,n,t,o,i,`the lens "${String(d.title??r)}"`);for(let s of i)a.push({...s,severity:"warning"})})}function oe(e,n,t,o,a,d,r){let i=[];if(e===void 0)return i;if(!g(e))return i.push(l("view-shape",n,'views are an object of kinds, each with a "card", a "row" or a "page"')),i;for(let[s,f]of Object.entries(e)){if(s==="home"&&Array.isArray(f)){D(f,`${n}.home`,r,o,a,i,"the home");continue}let u=t(s);if(!u){i.push(l("view-kind",`${n}.${s}`,`"${s}" is not a kind this ${d} declares`));continue}if(!g(f)){i.push(l("view-shape",`${n}.${s}`,`a kind's views are {"card": [blocks], "row": [blocks], "page": [blocks]}`));continue}for(let c of Object.keys(f))E.includes(c)||i.push(l("view-slot",`${n}.${s}.${c}`,`"${c}" is not a place a view is drawn`,`use ${E.map(p=>`"${p}"`).join(", ")}`));for(let c of E){let p=f[c];if(p===void 0)continue;let y={kind:s,spec:u,kinds:o,edges:a,vocabulary:r,findings:i,count:0,all:0,slot:c};x(p,`${n}.${s}.${c}`,1,y),P(y,`${n}.${s}.${c}`,`this ${c}`,"show less, or move detail to the page")}}return i}function ge(e){let n=new Set(Object.keys(e.kinds)),t=new Set(Object.values(e.kinds).flatMap(r=>Object.keys($(r.edges)))),o=r=>{let i=m(e.kinds,r)?e.kinds[r]:void 0;return i?{field:s=>m(i.fields,s)||m(i.computed,s)||F(i.edges).has(s),relation:s=>m($(i.edges),s),figure:i.figure!==void 0,files:s=>m(i.fields,s)&&X(i.fields[s]),choices:s=>m(i.fields,s)&&i.fields[s].type==="enum"?i.fields[s].options:void 0,targets:s=>m($(i.edges),s)?i.edges[s].to:void 0,prose:s=>m(i.fields,s)&&i.fields[s].type==="text"}:void 0},a={namesOf:o,sources:r=>Object.keys(e.kinds).filter(i=>m(e.kinds[i].edges,r))},d=oe(e.views,"views",o,n,t,"document",a);return te(e.lenses,a,n,t,d),d}export{j as a,H as b,L as c,B as d,M as e,fe as f,C as g,ue as h,ce as i,ge as j};
@@ -0,0 +1 @@
1
+ var t="\0graview:unset",u=e=>e===void 0||e===t;function d(e){if(e.op!=="patch-node")return e;let r=n=>Object.fromEntries(Object.entries(n).map(([f,o])=>[f,o===void 0?t:o]));return{...e,before:r(e.before),after:r(e.after)}}function a(e){switch(e.op){case"add-node":return{op:"remove-node",node:e.node};case"remove-node":return{op:"add-node",node:e.node};case"patch-node":return{op:"patch-node",id:e.id,before:e.after,after:e.before};case"add-edge":return{op:"remove-edge",edge:e.edge};case"remove-edge":return{op:"add-edge",edge:e.edge}}}function p(e){switch(e.op){case"add-node":case"remove-node":return[e.node.id];case"patch-node":return[e.id];case"add-edge":case"remove-edge":return[e.edge.from,e.edge.to]}}var i=new WeakMap;function s(e){return[...e].reverse().map(d).map(a)}function l(e){if(e.inverse)return e.inverse;let r=i.get(e);return r||i.set(e,r=s(e.primitives)),r}function c(e,r){if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==r[n]&&JSON.stringify(e[n])!==JSON.stringify(r[n]))return!1;return!0}function m(e){if(e.inverse===void 0||!c(e.inverse,s(e.primitives)))return e;let{inverse:r,...n}=e;return n}export{t as a,u as b,d as c,a as d,p as e,l as f,m as g};
@@ -1,3 +1,3 @@
1
- import"./chunk.WUQOSVQU.js";import{a as _,b as ge,c as me,e as fe}from"./chunk.B6DKKNVR.js";import"./chunk.7EB6SDUQ.js";import"./chunk.HJCQ6I3S.js";import{a as ve,d as ye}from"./chunk.5FHH5NR6.js";import"./chunk.VMBIFUYX.js";import{a as de}from"./chunk.U3MQUIJL.js";import{d as he}from"./chunk.DNMBZONP.js";import"./chunk.OTHGZPUC.js";import"./chunk.4YBP552Z.js";import"./chunk.V3K32XD7.js";import"./chunk.CAZX6OPN.js";import"./chunk.X2M7IOQA.js";import"./chunk.WZEA2UK6.js";import"./chunk.V5VQCANB.js";import"./chunk.UT6642FC.js";import"./chunk.PH5ITX3N.js";import"./chunk.WVUJXDXZ.js";import"./chunk.WVN62OMH.js";import"./chunk.BZ4VZ6WQ.js";import"./chunk.XDPIS7RS.js";import"./chunk.57R4ZUMM.js";import"./chunk.J7ZMNAWB.js";import"./chunk.VKJAGZNU.js";import"./chunk.GZHZLJBF.js";import{o as ue,r as K}from"./chunk.HG2IO5NS.js";import"./chunk.OJGHDWI6.js";import{a as ce}from"./chunk.AQTCN7KQ.js";import"./chunk.LFJH6X6O.js";import"./chunk.VTUMPH4Z.js";import{c as le}from"./chunk.PCTVLNOS.js";import{r as pe}from"./chunk.4QEDYRES.js";import{Aa as W,G as xe,K as I,R as re,T as ie,_ as T,aa as R,j as M,ja as G,l as ne,m as B,r as P,v as ae,z as oe,za as se}from"./chunk.JE4QQEJE.js";import"./chunk.SDO3U72B.js";import{U as D,ba as $,ca as F,fa as q,ha as L,la as ee,wc as te}from"./chunk.UG727PEE.js";import{b as V}from"./chunk.AJZBJBMO.js";var l=V(xe(),1);var e=V(re(),1),Se=pe.part((t,u)=>(0,e.jsx)(t.ProblemRows,{...u}),{what:"The problems",as:"li"}),A="var(--graview-gap, 8px)",ke=720;function qe({showing:t}){return t.what==="lens"?(0,e.jsx)(Ae,{kind:t.kind},`lens:${t.kind}`):t.what==="record"?(0,e.jsx)(Pe,{id:t.id},`record:${t.id}`):(0,e.jsx)(Ne,{kind:t.kind},`district:${t.kind}`)}function Y({label:t,wide:u,testId:a,head:o,onClose:s,children:d,sheetHeight:p}){let i=(0,l.useRef)(null),[h,m]=(0,l.useState)(!1);(0,l.useLayoutEffect)(()=>{let r=i.current?.parentElement;if(!r)return;let f=()=>m(r.getBoundingClientRect().width<ke);if(f(),typeof ResizeObserver>"u")return;let x=new ResizeObserver(f);return x.observe(r),()=>x.disconnect()},[]);let v=(0,l.useRef)(s);return v.current=s,(0,l.useEffect)(()=>{let r=k=>{if(k.key!=="Escape"||k.defaultPrevented)return;let y=document.activeElement;y instanceof HTMLInputElement||y instanceof HTMLTextAreaElement||document.querySelector("[data-graview-popover]:popover-open")||f||v.current()},f=!1,x=()=>{f=document.querySelector('[data-testid="following-who"]')!==null};return window.addEventListener("keydown",x,!0),document.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",x,!0),document.removeEventListener("keydown",r)}},[]),(0,e.jsxs)("section",{ref:i,"aria-label":t,"data-testid":a,"data-graview-map-panel":h?"sheet":"dock","data-graview-overlay":"","data-graview-offstage":"",className:"graview-map-panel",style:{position:"absolute",zIndex:te("rail"),boxSizing:"border-box",display:"flex",flexDirection:"column",background:"var(--graview-panel)",color:"var(--graview-ink)",overflow:"hidden",border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",boxShadow:"var(--graview-lift-high)",...h?{left:A,right:A,bottom:`calc(${A} + env(safe-area-inset-bottom, 0px))`,height:p}:{top:A,right:A,bottom:A,width:u}},children:[h?(0,e.jsx)("style",{children:`:has(> [data-graview-map-panel="sheet"]) { --graview-sheet: calc(${p} + 2 * ${A} + env(safe-area-inset-bottom, 0px)); }`}):(0,e.jsx)("style",{children:`:has(> [data-graview-map-panel="dock"]) { --graview-dock: calc(${u} + 2 * ${A}); }`}),(0,e.jsxs)("header",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"14px 14px 10px 18px",borderBottom:"1px solid var(--graview-edge)"},children:[(0,e.jsx)("div",{style:{flex:"1 1 auto",minWidth:0},children:o}),(0,e.jsx)("button",{type:"button","data-testid":"map-panel-close","aria-label":"Close",title:"Close (Escape)",onClick:s,style:{flex:"0 0 auto",minWidth:32,height:32,borderRadius:8,fontSize:"1.1rem",lineHeight:1},children:"\xD7"})]}),(0,e.jsx)("div",{style:{flex:"1 1 auto",minHeight:0,overflow:"auto"},children:d})]})}var U={fontSize:"0.75rem",letterSpacing:"0.09em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},J={margin:"2px 0 0",fontSize:"1.125rem",fontWeight:600,lineHeight:1.3,overflowWrap:"anywhere"},Q={margin:"4px 0 0",fontSize:"0.875rem",color:"var(--graview-ink-muted)"},j={margin:"14px 18px 6px",fontSize:"0.8125rem",fontWeight:600,color:"var(--graview-ink-muted)"},z={listStyle:"none",margin:0,padding:"0 10px 6px"},X={all:"unset",outline:"revert-layer",boxSizing:"border-box",display:"flex",alignItems:"baseline",gap:8,width:"100%",padding:"6px 8px",borderRadius:6,cursor:"pointer",fontSize:"0.875rem"},H={minHeight:30,padding:"0 12px",borderRadius:8,fontSize:"0.8125rem"};function Z(){let{setSelection:t,setMenuAt:u}=T();return(a,o)=>{a.preventDefault(),t([o]),u({x:a.clientX,y:a.clientY,on:o})}}function we({on:t,about:u}){let{setSelection:a,setMenuAt:o}=T();return(0,e.jsx)("button",{type:"button","data-testid":"map-panel-acts","aria-label":`What can be done with ${u}`,"aria-haspopup":"menu",style:H,onClick:s=>{let d=s.currentTarget.getBoundingClientRect();a([t]),o({x:Math.round(d.left),y:Math.round(d.bottom+4),on:t})},children:"Acts\u2026"})}var be=(t,u)=>({...M(B(t,!1),u),relation:null});function Ee(t,u){let a=`[data-graview-stage] [data-graview-view="${CSS.escape(t)}"][tabindex]`,o=null;for(let i=u?.parentElement??null;i&&!o;i=i.parentElement)o=i.querySelector(".graview-ground");o??=document.querySelector(".graview-ground");let s=o!==null&&!o.hasAttribute("tabindex");o&&s&&(o.setAttribute("tabindex","-1"),o.addEventListener("focusout",i=>{i.target===o&&o.removeAttribute("tabindex")},{once:!0})),o?.focus({preventScroll:!0});let d=performance.now()+5e3,p=()=>{let i=document.activeElement;if(!(i===null||i===document.body||i===document.documentElement||i===u||i===o))return;let m=document.querySelector(a);if(m&&m.isConnected&&!m.closest("[inert]"))return m.focus({preventScroll:!0});performance.now()<d&&requestAnimationFrame(p)};requestAnimationFrame(p)}function Ae({kind:t}){let u=Z(),{store:a,views:o,view:s,selection:d,setSelection:p}=T(),{go:i}=W(),h=R(),m=s.within?.view,v=o.places().filter(w=>w.kind===t),r=(m!==void 0?v.find(w=>w.as===m):void 0)??v.at(-1),f=o.resolve(t,{cardinality:"many",fidelity:"full"},r?.as??m),x=f?.view,k=a.schema.tryDefinition(t),y=(0,l.useMemo)(()=>a.graph.nodesOfKind(t).filter(w=>s.past===!0||$(k,w)),[a,t,h,s.past,k]),E=f?.title??r?.title??L(a.schema,t),C=x!==void 0&&G(x),c=d.filter(w=>a.graph.getNode(w)!==void 0),g=ce();return(0,e.jsxs)(Y,{label:E,testId:"lens-panel",wide:"min(max(440px, 46%), 760px)",sheetHeight:"60%",onClose:()=>i(ne(M(s,null),"view",null)),head:C?null:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:U,children:L(a.schema,t)}),(0,e.jsx)("h2",{style:J,"data-testid":"lens-panel-title",children:E}),(0,e.jsxs)("p",{style:Q,children:[q(a.schema,t,y.length),k?.description?` \xB7 ${k.description}`:""]}),r?(0,e.jsx)("div",{style:{marginTop:10},children:(0,e.jsx)("button",{type:"button","data-testid":"lens-panel-open",style:H,title:`Open ${E} on its own`,onClick:()=>i(oe(s,t,r.as)),children:"Open \u2197"})}):null]}),children:[(0,e.jsx)("style",{children:`.graview-ground[data-graview-altitude] .graview-plot:not([data-graview-plot="${P(t)}"]) { opacity: 0.35; }
1
+ import"./chunk.T6S3CEW7.js";import{a as _,b as ge,c as me,e as fe}from"./chunk.IBWPRK2R.js";import"./chunk.6NFR2LYQ.js";import"./chunk.HJCQ6I3S.js";import{a as ve,d as ye}from"./chunk.B7FZLIAO.js";import"./chunk.N5ULWKR4.js";import{a as de}from"./chunk.LKF4BBCW.js";import{d as he}from"./chunk.NPS2WN7T.js";import"./chunk.JUT2VCFW.js";import"./chunk.HKD5SR45.js";import"./chunk.IIB22IIP.js";import"./chunk.MWUP5X47.js";import"./chunk.OK4FSBHI.js";import"./chunk.DAZEFSWI.js";import"./chunk.OGF6UORU.js";import"./chunk.UT6642FC.js";import"./chunk.TDCO7LEA.js";import"./chunk.WVUJXDXZ.js";import"./chunk.ESU2DD3J.js";import"./chunk.PL2P2OON.js";import"./chunk.27ZVVPRZ.js";import"./chunk.IN4PKQO5.js";import"./chunk.3IUJ4GW7.js";import"./chunk.UG23RICT.js";import"./chunk.GZHZLJBF.js";import{o as ue,r as K}from"./chunk.ATKKTPJS.js";import"./chunk.OJGHDWI6.js";import{a as ce}from"./chunk.UZSZPMRC.js";import"./chunk.MZOIPCDA.js";import"./chunk.KERLVJ6I.js";import{c as le}from"./chunk.4EPT2CQG.js";import{r as pe}from"./chunk.FNXW46U4.js";import{Aa as W,G as xe,K as I,R as re,T as ie,_ as T,aa as R,j as M,ja as G,l as ne,m as B,r as P,v as ae,z as oe,za as se}from"./chunk.4JWT6LIS.js";import"./chunk.SDO3U72B.js";import{U as D,ba as $,ca as F,fa as q,ha as L,la as ee,wc as te}from"./chunk.AW2T3KFV.js";import"./chunk.2AZTW66C.js";import{b as V}from"./chunk.AJZBJBMO.js";var l=V(xe(),1);var e=V(re(),1),Se=pe.part((t,u)=>(0,e.jsx)(t.ProblemRows,{...u}),{what:"The problems",as:"li"}),A="var(--graview-gap, 8px)",ke=720;function qe({showing:t}){return t.what==="lens"?(0,e.jsx)(Ae,{kind:t.kind},`lens:${t.kind}`):t.what==="record"?(0,e.jsx)(Pe,{id:t.id},`record:${t.id}`):(0,e.jsx)(Ne,{kind:t.kind},`district:${t.kind}`)}function Y({label:t,wide:u,testId:a,head:o,onClose:s,children:d,sheetHeight:p}){let i=(0,l.useRef)(null),[h,m]=(0,l.useState)(!1);(0,l.useLayoutEffect)(()=>{let r=i.current?.parentElement;if(!r)return;let f=()=>m(r.getBoundingClientRect().width<ke);if(f(),typeof ResizeObserver>"u")return;let x=new ResizeObserver(f);return x.observe(r),()=>x.disconnect()},[]);let v=(0,l.useRef)(s);return v.current=s,(0,l.useEffect)(()=>{let r=k=>{if(k.key!=="Escape"||k.defaultPrevented)return;let y=document.activeElement;y instanceof HTMLInputElement||y instanceof HTMLTextAreaElement||document.querySelector("[data-graview-popover]:popover-open")||f||v.current()},f=!1,x=()=>{f=document.querySelector('[data-testid="following-who"]')!==null};return window.addEventListener("keydown",x,!0),document.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",x,!0),document.removeEventListener("keydown",r)}},[]),(0,e.jsxs)("section",{ref:i,"aria-label":t,"data-testid":a,"data-graview-map-panel":h?"sheet":"dock","data-graview-overlay":"","data-graview-offstage":"",className:"graview-map-panel",style:{position:"absolute",zIndex:te("rail"),boxSizing:"border-box",display:"flex",flexDirection:"column",background:"var(--graview-panel)",color:"var(--graview-ink)",overflow:"hidden",border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",boxShadow:"var(--graview-lift-high)",...h?{left:A,right:A,bottom:`calc(${A} + env(safe-area-inset-bottom, 0px))`,height:p}:{top:A,right:A,bottom:A,width:u}},children:[h?(0,e.jsx)("style",{children:`:has(> [data-graview-map-panel="sheet"]) { --graview-sheet: calc(${p} + 2 * ${A} + env(safe-area-inset-bottom, 0px)); }`}):(0,e.jsx)("style",{children:`:has(> [data-graview-map-panel="dock"]) { --graview-dock: calc(${u} + 2 * ${A}); }`}),(0,e.jsxs)("header",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"14px 14px 10px 18px",borderBottom:"1px solid var(--graview-edge)"},children:[(0,e.jsx)("div",{style:{flex:"1 1 auto",minWidth:0},children:o}),(0,e.jsx)("button",{type:"button","data-testid":"map-panel-close","aria-label":"Close",title:"Close (Escape)",onClick:s,style:{flex:"0 0 auto",minWidth:32,height:32,borderRadius:8,fontSize:"1.1rem",lineHeight:1},children:"\xD7"})]}),(0,e.jsx)("div",{style:{flex:"1 1 auto",minHeight:0,overflow:"auto"},children:d})]})}var U={fontSize:"0.75rem",letterSpacing:"0.09em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},J={margin:"2px 0 0",fontSize:"1.125rem",fontWeight:600,lineHeight:1.3,overflowWrap:"anywhere"},Q={margin:"4px 0 0",fontSize:"0.875rem",color:"var(--graview-ink-muted)"},j={margin:"14px 18px 6px",fontSize:"0.8125rem",fontWeight:600,color:"var(--graview-ink-muted)"},z={listStyle:"none",margin:0,padding:"0 10px 6px"},X={all:"unset",outline:"revert-layer",boxSizing:"border-box",display:"flex",alignItems:"baseline",gap:8,width:"100%",padding:"6px 8px",borderRadius:6,cursor:"pointer",fontSize:"0.875rem"},H={minHeight:30,padding:"0 12px",borderRadius:8,fontSize:"0.8125rem"};function Z(){let{setSelection:t,setMenuAt:u}=T();return(a,o)=>{a.preventDefault(),t([o]),u({x:a.clientX,y:a.clientY,on:o})}}function we({on:t,about:u}){let{setSelection:a,setMenuAt:o}=T();return(0,e.jsx)("button",{type:"button","data-testid":"map-panel-acts","aria-label":`What can be done with ${u}`,"aria-haspopup":"menu",style:H,onClick:s=>{let d=s.currentTarget.getBoundingClientRect();a([t]),o({x:Math.round(d.left),y:Math.round(d.bottom+4),on:t})},children:"Acts\u2026"})}var be=(t,u)=>({...M(B(t,!1),u),relation:null});function Ee(t,u){let a=`[data-graview-stage] [data-graview-view="${CSS.escape(t)}"][tabindex]`,o=null;for(let i=u?.parentElement??null;i&&!o;i=i.parentElement)o=i.querySelector(".graview-ground");o??=document.querySelector(".graview-ground");let s=o!==null&&!o.hasAttribute("tabindex");o&&s&&(o.setAttribute("tabindex","-1"),o.addEventListener("focusout",i=>{i.target===o&&o.removeAttribute("tabindex")},{once:!0})),o?.focus({preventScroll:!0});let d=performance.now()+5e3,p=()=>{let i=document.activeElement;if(!(i===null||i===document.body||i===document.documentElement||i===u||i===o))return;let m=document.querySelector(a);if(m&&m.isConnected&&!m.closest("[inert]"))return m.focus({preventScroll:!0});performance.now()<d&&requestAnimationFrame(p)};requestAnimationFrame(p)}function Ae({kind:t}){let u=Z(),{store:a,views:o,view:s,selection:d,setSelection:p}=T(),{go:i}=W(),h=R(),m=s.within?.view,v=o.places().filter(w=>w.kind===t),r=(m!==void 0?v.find(w=>w.as===m):void 0)??v.at(-1),f=o.resolve(t,{cardinality:"many",fidelity:"full"},r?.as??m),x=f?.view,k=a.schema.tryDefinition(t),y=(0,l.useMemo)(()=>a.graph.nodesOfKind(t).filter(w=>s.past===!0||$(k,w)),[a,t,h,s.past,k]),E=f?.title??r?.title??L(a.schema,t),C=x!==void 0&&G(x),c=d.filter(w=>a.graph.getNode(w)!==void 0),g=ce();return(0,e.jsxs)(Y,{label:E,testId:"lens-panel",wide:"min(max(440px, 46%), 760px)",sheetHeight:"60%",onClose:()=>i(ne(M(s,null),"view",null)),head:C?null:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:U,children:L(a.schema,t)}),(0,e.jsx)("h2",{style:J,"data-testid":"lens-panel-title",children:E}),(0,e.jsxs)("p",{style:Q,children:[q(a.schema,t,y.length),k?.description?` \xB7 ${k.description}`:""]}),r?(0,e.jsx)("div",{style:{marginTop:10},children:(0,e.jsx)("button",{type:"button","data-testid":"lens-panel-open",style:H,title:`Open ${E} on its own`,onClick:()=>i(oe(s,t,r.as)),children:"Open \u2197"})}):null]}),children:[(0,e.jsx)("style",{children:`.graview-ground[data-graview-altitude] .graview-plot:not([data-graview-plot="${P(t)}"]) { opacity: 0.35; }
2
2
  .graview-ground[data-graview-altitude] [data-graview-view^="kind:"]:not([data-graview-view="${P(t)}"]) { opacity: 0.4; }`}),(0,e.jsx)("div",{"data-graview-lens":r?.as??"",style:{padding:"8px 12px 16px",minHeight:"100%",boxSizing:"border-box",display:"grid",gridTemplateRows:"1fr",gridTemplateColumns:"minmax(0, 1fr)",alignItems:"start"},onClick:w=>{let n=I(w.target);if(!n||a.graph.getNode(n)===void 0)return;let b=w.target.closest("button, a, input, select, textarea, [contenteditable='true']");b&&!b.hasAttribute("data-graview-pick")||p([n])},onDoubleClick:w=>{let n=I(w.target);!n||a.graph.getNode(n)===void 0||i(be(s,n))},onContextMenu:w=>{let n=I(w.target);!n||a.graph.getNode(n)===void 0||u(w,n)},children:x?(0,e.jsx)(de.Provider,{value:E,children:(0,e.jsx)(ie,{mode:"fullscreen",children:(0,e.jsx)(K,{kind:t,...f?.title?{view:f.title}:{},children:(0,e.jsx)(x,{nodes:y,label:E,fidelity:"full",cardinality:"many",mode:"fullscreen",selected:!1,...c.length>0?{implicated:c}:{},...g.length>0?{flagged:g}:{}})})})}):null})]})}function Ce(t,u,a,o){let s=o(a),d=new Map;for(let p of u){let i=p.from===a;if(!i&&p.to!==a)continue;let h=i?p.to:p.from,m=o(h);if(m===void 0||s===void 0)continue;let v=`${p.kind}|${i?"out":"in"}|${m}`,r=d.get(v);if(r){r.others.includes(h)||r.others.push(h);continue}d.set(v,{key:v,edge:p.kind,words:le(t,i?s:m,p.kind,i?"out":"in"),kind:m,others:[h]})}return[...d.values()]}function Pe({id:t}){let u=Z(),{store:a,views:o,view:s,setSelection:d}=T(),{go:p}=W(),i=R(),h=a.graph.getNode(t),m=c=>a.graph.getNode(c)?.kind,v=(0,l.useMemo)(()=>Ce(a.schema,a.graph.allEdges(),t,m),[a,t,i]);if(!h)return null;let r=h.kind,f=c=>{let g=a.graph.getNode(c);return g?F(a.schema.tryDefinition(g.kind),g):c},x=ee(a.schema.tryDefinition(r),r),y=o.resolve(r,{cardinality:"one",fidelity:"full"})?.view,E=y!==void 0&&!G(y),C=()=>s.focusId===t?p({...M(s,null),selection:[]}):d([]);return(0,e.jsxs)(Y,{label:`${f(t)}: its links`,testId:"record-panel",wide:E?"min(max(440px, 46%), 760px)":"min(360px, 40%)",sheetHeight:"52%",onClose:C,head:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:U,children:x}),(0,e.jsx)("h2",{style:J,"data-testid":"record-panel-title",children:f(t)}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginTop:10},children:[(0,e.jsx)("button",{type:"button","data-testid":"record-panel-go",style:H,onClick:c=>{p(be(s,t)),Ee(t,c.currentTarget)},children:"Go to it"}),(0,e.jsx)(we,{on:t,about:f(t)}),(0,e.jsxs)("button",{type:"button","data-testid":"record-panel-district",style:H,onClick:()=>d([P(r)]),children:["All ",L(a.schema,r).toLowerCase()]})]})]}),children:[(0,e.jsx)("div",{"data-graview-record-card":t,style:{padding:"8px 18px 0"},children:E?(0,e.jsx)(K,{kind:r,children:(0,e.jsx)(y,{node:h,fidelity:"full",cardinality:"one",mode:"fullscreen",selected:!1})}):(0,e.jsx)(he,{id:t,shown:[f(t)]})}),v.length===0?(0,e.jsx)("p",{style:{...Q,margin:"14px 18px"},children:"No links yet."}):null,v.map(c=>(0,e.jsxs)("section",{"aria-label":c.words,"data-graview-links":c.edge,children:[(0,e.jsxs)("h3",{style:j,children:[c.words.charAt(0).toUpperCase()+c.words.slice(1)," ",(0,e.jsxs)("span",{style:{fontWeight:400,color:"var(--graview-ink-faint)"},children:["\xB7 ",c.others.length]})]}),(0,e.jsx)("ul",{style:z,children:c.others.map(g=>(0,e.jsx)("li",{children:(0,e.jsxs)("button",{type:"button",className:"graview-map-panel-row","data-graview-record":g,style:X,onClick:()=>d([g]),onContextMenu:N=>u(N,g),children:[(0,e.jsx)("span",{style:{flex:"1 1 auto",minWidth:0,overflowWrap:"anywhere"},children:f(g)}),c.kind!==r?null:(0,e.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:x})]})},g))})]},c.key))]})}var Te=24;function Ne({kind:t}){let u=Z(),{store:a,view:o,setSelection:s,setEmphasis:d}=T(),{go:p}=W(),i=R(),[h,m]=(0,l.useState)(""),v=a.schema.tryDefinition(t),r=(0,l.useMemo)(()=>a.graph.nodesOfKind(t).filter(n=>o.past===!0||$(v,n)).map(n=>({id:n.id,name:F(v,n)})).sort((n,b)=>n.name.localeCompare(b.name)),[a,t,i,o.past,v]),f=(0,l.useMemo)(()=>{let n=S=>{let O=a.graph.getNode(S);return O!==void 0&&(o.past===!0||$(a.schema.tryDefinition(O.kind),O))},b=a.graph.allEdges().filter(S=>n(S.from)&&n(S.to));return ve(b,S=>a.graph.getNode(S)?.kind).filter(S=>S.from===t||S.to===t)},[a,t,i,o.past]);(0,l.useEffect)(()=>()=>d(null),[d]);let x=se(),k=ue().marks.flag,y=(0,l.useMemo)(()=>{let n=new Set(r.map(b=>b.id));return x.filter(b=>b.nodeIds.some(S=>n.has(S)))},[x,r]),E=(0,l.useMemo)(()=>[...new Set(y.flatMap(n=>n.nodeIds))].filter(n=>a.graph.getNode(n)?.kind===t).slice(0,300),[y,a,t]),C=(0,l.useRef)(null),c=(0,l.useSyncExternalStore)(ge,_,_);(0,l.useEffect)(()=>{c?.kind!==t||y.length===0||(C.current?.scrollIntoView?.({block:"start"}),C.current?.focus({preventScroll:!0}))},[c?.n,c?.kind,t,y.length>0]),(0,l.useEffect)(()=>()=>{me(),setTimeout(()=>{let n=document.activeElement;if(n&&n!==document.body)return;let b=CSS.escape(t);document.querySelector(`[data-testid="district-problems-${b}"]`)?.focus({preventScroll:!0})??document.querySelector(`[data-graview-view="${P(t).replace(/["\\]/g,"\\$&")}"]`)?.focus({preventScroll:!0})},0)},[t]);let g=L(a.schema,t),N=h.trim().toLowerCase(),w=N?r.filter(n=>n.name.toLowerCase().includes(N)):r;return(0,e.jsxs)(Y,{label:g,testId:"district-panel",wide:"min(360px, 40%)",sheetHeight:"52%",onClose:()=>s([]),head:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:U,children:"District"}),(0,e.jsx)("h2",{style:J,"data-testid":"district-panel-title",children:g}),(0,e.jsxs)("p",{style:Q,children:[q(a.schema,t,r.length),v?.description?` \xB7 ${v.description}`:""]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginTop:10},children:[(0,e.jsx)("button",{type:"button","data-testid":"district-panel-go",style:H,onClick:()=>p({...M(B(o,!1),ae(t)),relation:null}),children:"Go in"}),(0,e.jsx)(we,{on:P(t),about:`the ${g.toLowerCase()}`})]})]}),children:[y.length>0?(0,e.jsxs)("section",{"aria-label":"Problems","data-testid":"district-problems","data-graview-problems":y.length,children:[(0,e.jsx)("style",{children:`${E.map(n=>`.graview-ground[data-graview-altitude] .graview-building[data-graview-building="${CSS.escape(n)}"] polygon`).join(`,
3
3
  `)} { stroke: var(--graview-accent); stroke-width: 2.2; stroke-opacity: 1; }`}),(0,e.jsxs)("h3",{ref:C,tabIndex:-1,"data-testid":"district-problems-heading",style:{display:"flex",alignItems:"baseline",gap:8,margin:0,padding:"14px 18px 8px",fontSize:"0.9375rem",fontWeight:600,color:"var(--graview-warn)",borderTop:"1px solid var(--graview-edge)",scrollMarginTop:0,outlineOffset:-2},children:[(0,e.jsx)("span",{"aria-hidden":"true",children:k}),(0,e.jsx)("span",{style:{color:"var(--graview-ink)"},children:fe(y.length,g)})]}),(0,e.jsx)("ol",{style:z,"data-testid":"district-problem-rows",children:(0,e.jsx)(l.Suspense,{fallback:null,children:(0,e.jsx)(Se,{violations:y,pick:n=>{let b=n.subjectId??n.nodeIds[0];b!==void 0&&s([b])}})})})]}):null,f.length>0?(0,e.jsxs)("section",{"aria-label":"Relations",children:[(0,e.jsx)("h3",{style:j,children:"Relations"}),(0,e.jsx)("ul",{style:z,children:f.map(n=>(0,e.jsx)("li",{children:(0,e.jsxs)("div",{"data-graview-relation-said":n.edge,tabIndex:0,style:{...X,cursor:"default"},onPointerEnter:()=>d(n.edge),onPointerLeave:()=>d(null),onFocus:()=>d(n.edge),onBlur:()=>d(null),children:[(0,e.jsx)("span",{style:{flex:"1 1 auto",minWidth:0},children:ye(a.schema,n)}),(0,e.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",fontVariantNumeric:"tabular-nums"},title:`${D(n.links)} links`,children:D(n.links)})]})},n.key))})]}):null,(0,e.jsxs)("div",{role:"group","aria-label":g,children:[(0,e.jsxs)("h3",{style:j,children:[g," ",(0,e.jsxs)("span",{style:{fontWeight:400,color:"var(--graview-ink-faint)"},children:["\xB7 ",r.length]})]}),r.length>Te?(0,e.jsx)("div",{style:{padding:"0 18px 6px"},children:(0,e.jsx)("input",{type:"search","data-testid":"district-panel-narrow","aria-label":`Narrow the ${g.toLowerCase()} by name`,placeholder:"Narrow by name",value:h,onChange:n=>m(n.target.value),style:{width:"100%",boxSizing:"border-box",minHeight:32}})}):null,(0,e.jsx)("ul",{style:z,children:w.map(n=>(0,e.jsx)("li",{children:(0,e.jsx)("button",{type:"button",className:"graview-map-panel-row","data-graview-record":n.id,style:X,onClick:()=>s([n.id]),onContextMenu:b=>u(b,n.id),children:(0,e.jsx)("span",{style:{flex:"1 1 auto",minWidth:0,overflowWrap:"anywhere"},children:n.name})})},n.id))})]})]})}export{qe as MapPanelFor};