graview 0.1.43 → 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 (154) hide show
  1. package/dist/preview/{chunk.R2B2ZAWI.js → chunk.27ZVVPRZ.js} +1 -1
  2. package/dist/preview/{chunk.ONSG3OIL.js → chunk.2CPC3HQI.js} +1 -1
  3. package/dist/preview/{chunk.4HAGPMY6.js → chunk.2EXY4AHX.js} +4 -4
  4. package/dist/preview/{chunk.6AYTF53S.js → chunk.2O2THM2R.js} +1 -1
  5. package/dist/preview/{chunk.MI2HL3LQ.js → chunk.3IUJ4GW7.js} +1 -1
  6. package/dist/preview/{chunk.XBV4WO7D.js → chunk.3L7OEBJH.js} +1 -1
  7. package/dist/preview/{chunk.T4QT5SZY.js → chunk.3M4VCAA3.js} +1 -1
  8. package/dist/preview/{chunk.OUN2H3TR.js → chunk.3OKJ4GOA.js} +1 -1
  9. package/dist/preview/chunk.3PNDXNX6.js +1 -0
  10. package/dist/preview/{chunk.SGRKCQ2X.js → chunk.3TBH2FMZ.js} +1 -1
  11. package/dist/preview/{chunk.S6BZXNMV.js → chunk.4B4DKCS4.js} +1 -1
  12. package/dist/preview/{chunk.DYW4D74X.js → chunk.4EPT2CQG.js} +1 -1
  13. package/dist/preview/{chunk.7L6LYXCV.js → chunk.4JWT6LIS.js} +1 -1
  14. package/dist/preview/{chunk.FCPH4YZN.js → chunk.4WCQWILK.js} +1 -1
  15. package/dist/preview/{chunk.ZE6LJVVN.js → chunk.56DR42FA.js} +1 -1
  16. package/dist/preview/{chunk.3B47UX2J.js → chunk.5JPELFMA.js} +1 -1
  17. package/dist/preview/{chunk.OIJP6PQV.js → chunk.5WEEZ7WD.js} +1 -1
  18. package/dist/preview/{chunk.OH2N3SX7.js → chunk.64QDUERE.js} +1 -1
  19. package/dist/preview/{chunk.C5NOO4CC.js → chunk.6BIRNR5P.js} +1 -1
  20. package/dist/preview/{chunk.7MXQRSNR.js → chunk.6NFR2LYQ.js} +1 -1
  21. package/dist/preview/{chunk.5BJW4IPW.js → chunk.6VIZGLDK.js} +1 -1
  22. package/dist/preview/{chunk.5J2HETUO.js → chunk.7AEE3VHC.js} +1 -1
  23. package/dist/preview/{chunk.RDXDEFOC.js → chunk.7B5BZZBG.js} +1 -1
  24. package/dist/preview/chunk.7HL7CFXJ.js +1 -0
  25. package/dist/preview/{chunk.ZHRW2UF4.js → chunk.7JVBVB4A.js} +1 -1
  26. package/dist/preview/{chunk.XGRMQUFB.js → chunk.7PUFYK3B.js} +1 -1
  27. package/dist/preview/{chunk.CTSPNTDX.js → chunk.7UV7ODXU.js} +1 -1
  28. package/dist/preview/{chunk.6BU3GCHK.js → chunk.ALFW4ZJQ.js} +1 -1
  29. package/dist/preview/{chunk.EBTYR5CZ.js → chunk.ATKKTPJS.js} +1 -1
  30. package/dist/preview/chunk.AW2T3KFV.js +5 -0
  31. package/dist/preview/{chunk.DQR45N7V.js → chunk.B2CIQ66N.js} +1 -1
  32. package/dist/preview/{chunk.A3WOUDOG.js → chunk.B7FZLIAO.js} +1 -1
  33. package/dist/preview/{chunk.F6CPM7SL.js → chunk.BA4KQR5H.js} +1 -1
  34. package/dist/preview/{chunk.PEXPTDX7.js → chunk.CDFVEL2Y.js} +1 -1
  35. package/dist/preview/chunk.CSQNDAEK.js +1 -0
  36. package/dist/preview/{chunk.26SI4K3P.js → chunk.D2RK2KJD.js} +1 -1
  37. package/dist/preview/chunk.DAZEFSWI.js +1 -0
  38. package/dist/preview/{chunk.ZE4U4JBF.js → chunk.DGXWL4GC.js} +2 -2
  39. package/dist/preview/{chunk.XAXZCOZK.js → chunk.DLVNW4HU.js} +1 -1
  40. package/dist/preview/{chunk.IJ2AF3AW.js → chunk.EJAWDI2V.js} +1 -1
  41. package/dist/preview/{chunk.ZUJZVK2X.js → chunk.EJOTTZWZ.js} +1 -1
  42. package/dist/preview/{chunk.QWY54AVN.js → chunk.ESU2DD3J.js} +1 -1
  43. package/dist/preview/{chunk.C3X3R7LP.js → chunk.EW364363.js} +2 -2
  44. package/dist/preview/{chunk.25VAWLKJ.js → chunk.EYEIDL3T.js} +1 -1
  45. package/dist/preview/chunk.EZRGGPAN.js +1 -0
  46. package/dist/preview/{chunk.4P3LS2OE.js → chunk.F4DWRBO7.js} +1 -1
  47. package/dist/preview/{chunk.CW6IPHRR.js → chunk.FBIK4LTM.js} +2 -2
  48. package/dist/preview/{chunk.LDU25CCL.js → chunk.FIJNKSMQ.js} +1 -1
  49. package/dist/preview/{chunk.QXTLZSBL.js → chunk.FNF6XQI5.js} +1 -1
  50. package/dist/preview/chunk.FNXW46U4.js +349 -0
  51. package/dist/preview/chunk.FUYMLDNJ.js +7 -0
  52. package/dist/preview/{chunk.DZN26GKS.js → chunk.FVHECT47.js} +1 -1
  53. package/dist/preview/{chunk.N3FONYEP.js → chunk.GAN77YDU.js} +2 -2
  54. package/dist/preview/{chunk.XVWJD2DG.js → chunk.GBCWI2LF.js} +1 -1
  55. package/dist/preview/{chunk.7TU2PDYW.js → chunk.H4GHKBMH.js} +1 -1
  56. package/dist/preview/{chunk.HMABYAZR.js → chunk.HB34VQKQ.js} +1 -1
  57. package/dist/preview/chunk.HKA27VJO.js +1 -0
  58. package/dist/preview/{chunk.RQBX7M7Q.js → chunk.HKD5SR45.js} +2 -2
  59. package/dist/preview/{chunk.4YLBGGWT.js → chunk.HP72LB3B.js} +1 -1
  60. package/dist/preview/{chunk.DJ3BD7AZ.js → chunk.IBWPRK2R.js} +1 -1
  61. package/dist/preview/{chunk.BT6FUNQI.js → chunk.IIB22IIP.js} +1 -1
  62. package/dist/preview/{chunk.7XCBIID7.js → chunk.IN4PKQO5.js} +1 -1
  63. package/dist/preview/{chunk.KBMVUIWR.js → chunk.IPHWGBZE.js} +1 -1
  64. package/dist/preview/{chunk.JNCSGUO3.js → chunk.IQWKEGWG.js} +1 -1
  65. package/dist/preview/{chunk.FLMNHV6A.js → chunk.JEMQ66FT.js} +1 -1
  66. package/dist/preview/chunk.JGYGSNQY.js +1 -0
  67. package/dist/preview/{chunk.CO2ZPX3D.js → chunk.JLOSQ5UY.js} +2 -2
  68. package/dist/preview/{chunk.GZA5ZNLJ.js → chunk.JQ7WY2VZ.js} +1 -1
  69. package/dist/preview/chunk.JUT2VCFW.js +1 -0
  70. package/dist/preview/{chunk.R7F6UJVG.js → chunk.KERLVJ6I.js} +1 -1
  71. package/dist/preview/{chunk.6PF5LWRK.js → chunk.KSXB4LDF.js} +1 -1
  72. package/dist/preview/chunk.L6FWIQXS.js +1 -0
  73. package/dist/preview/{chunk.5TBK44MK.js → chunk.LKF4BBCW.js} +1 -1
  74. package/dist/preview/{chunk.NH6D6TWY.js → chunk.LKXYZK5H.js} +1 -1
  75. package/dist/preview/{chunk.KWQ67UK2.js → chunk.LULTKYE3.js} +1 -1
  76. package/dist/preview/{chunk.4ZHUGSJL.js → chunk.LUPBT6YM.js} +1 -1
  77. package/dist/preview/{chunk.AXJJUCWT.js → chunk.LYSHLKAX.js} +1 -1
  78. package/dist/preview/chunk.LYUPJ4VV.js +1 -0
  79. package/dist/preview/{chunk.Z56L6V6Z.js → chunk.MFLJIFZD.js} +1 -1
  80. package/dist/preview/{chunk.LBIDNJ6G.js → chunk.MOF2D6DV.js} +1 -1
  81. package/dist/preview/{chunk.MBOOUJOE.js → chunk.MWUP5X47.js} +1 -1
  82. package/dist/preview/{chunk.RSYFIL2Z.js → chunk.MZOIPCDA.js} +1 -1
  83. package/dist/preview/{chunk.WH2RYGXR.js → chunk.N5ULWKR4.js} +1 -1
  84. package/dist/preview/{chunk.6ROYIMQ2.js → chunk.NBOZPPSM.js} +1 -1
  85. package/dist/preview/{chunk.27QYTMXP.js → chunk.NPS2WN7T.js} +1 -1
  86. package/dist/preview/chunk.NTFCZYOR.js +1 -0
  87. package/dist/preview/{chunk.B2KDYES6.js → chunk.O4VSQ2ER.js} +1 -1
  88. package/dist/preview/{chunk.C3DX4LWD.js → chunk.OAWAUB4P.js} +1 -1
  89. package/dist/preview/{chunk.63DI7XNE.js → chunk.OG6GNGTX.js} +2 -2
  90. package/dist/preview/{chunk.Q5XICUDZ.js → chunk.OGF6UORU.js} +1 -1
  91. package/dist/preview/chunk.OK4FSBHI.js +1 -0
  92. package/dist/preview/{chunk.7IXLH7PR.js → chunk.P546VMA5.js} +1 -1
  93. package/dist/preview/{chunk.X5WB4GJ4.js → chunk.P5K7EYDK.js} +1 -1
  94. package/dist/preview/{chunk.T4Q6OLZU.js → chunk.PL2P2OON.js} +1 -1
  95. package/dist/preview/{chunk.EPPAFWP7.js → chunk.PSTE3LZL.js} +2 -2
  96. package/dist/preview/chunk.PX6VAZFJ.js +1 -0
  97. package/dist/preview/{chunk.6IEDQHKI.js → chunk.QJJKITXF.js} +1 -1
  98. package/dist/preview/{chunk.ZEC64CK6.js → chunk.QNJYXB3U.js} +1 -1
  99. package/dist/preview/{chunk.GSZYT6GF.js → chunk.RDGFZPKN.js} +1 -1
  100. package/dist/preview/{chunk.YKN2VWWQ.js → chunk.REEDZSCG.js} +2 -2
  101. package/dist/preview/{chunk.PWYMZWAN.js → chunk.REOYQTFP.js} +1 -1
  102. package/dist/preview/{chunk.4ZSHTUNK.js → chunk.RLMW7DU6.js} +1 -1
  103. package/dist/preview/{chunk.S2MP53RO.js → chunk.RNUGQRJI.js} +1 -1
  104. package/dist/preview/{chunk.YPEZZLOY.js → chunk.RVQYXPCM.js} +1 -1
  105. package/dist/preview/{chunk.4IDXQVSW.js → chunk.RYNCEZ6Q.js} +1 -1
  106. package/dist/preview/{chunk.RPDTWQKA.js → chunk.T6S3CEW7.js} +3 -3
  107. package/dist/preview/{chunk.FKLEIR4Y.js → chunk.TDCO7LEA.js} +1 -1
  108. package/dist/preview/{chunk.XFQUVMRI.js → chunk.TJO5Y2OJ.js} +1 -1
  109. package/dist/preview/{chunk.3HLNRVFY.js → chunk.TTSNHX3F.js} +1 -1
  110. package/dist/preview/{chunk.6XEATXZC.js → chunk.U3CV5CCL.js} +1 -1
  111. package/dist/preview/{chunk.TMBFLZNH.js → chunk.UG23RICT.js} +1 -1
  112. package/dist/preview/{chunk.U3ETEQDO.js → chunk.URCC626R.js} +1 -1
  113. package/dist/preview/{chunk.3GQL4K3Q.js → chunk.UXLJZIYX.js} +1 -1
  114. package/dist/preview/{chunk.OWL5GZ6U.js → chunk.UZSZPMRC.js} +1 -1
  115. package/dist/preview/{chunk.TX65ZO27.js → chunk.V4DR25S4.js} +1 -1
  116. package/dist/preview/{chunk.I4HUBO22.js → chunk.VAUG5TGZ.js} +1 -1
  117. package/dist/preview/{chunk.KG5R4GTK.js → chunk.WE5SA6TP.js} +1 -1
  118. package/dist/preview/chunk.WNYPP52L.js +1 -0
  119. package/dist/preview/{chunk.KR3J27IA.js → chunk.WPLKHIO5.js} +1 -1
  120. package/dist/preview/{chunk.ZRICIE6T.js → chunk.XPIDPZKS.js} +1 -1
  121. package/dist/preview/{chunk.WWR7Y2KE.js → chunk.Y2MIG2C2.js} +1 -1
  122. package/dist/preview/chunk.YE4GZVOX.js +1 -0
  123. package/dist/preview/{chunk.BYVE2NQY.js → chunk.YERDP6YF.js} +1 -1
  124. package/dist/preview/{chunk.7ROWZZN5.js → chunk.YGX2AE36.js} +1 -1
  125. package/dist/preview/{chunk.FTF67QE2.js → chunk.YTXEPWVW.js} +1 -1
  126. package/dist/preview/{chunk.T4M4MLOS.js → chunk.YTZDCIX2.js} +1 -1
  127. package/dist/preview/chunk.YYPK7IDM.js +1 -0
  128. package/dist/preview/{chunk.BYVLGDVJ.js → chunk.ZKBSEUK4.js} +1 -1
  129. package/dist/preview/{chunk.SKB4XSDG.js → chunk.ZN77U6SU.js} +1 -1
  130. package/dist/preview/{chunk.IJU322EP.js → chunk.ZP6PS5Z4.js} +1 -1
  131. package/dist/preview/chunk.ZZ5F5I3O.js +1 -0
  132. package/dist/preview/index.html +45 -45
  133. package/dist/preview/page.js +2 -2
  134. package/package.json +6 -6
  135. package/dist/preview/chunk.22E4GKYU.js +0 -1
  136. package/dist/preview/chunk.2JMJTREH.js +0 -1
  137. package/dist/preview/chunk.4C65DXZB.js +0 -1
  138. package/dist/preview/chunk.64MP7636.js +0 -1
  139. package/dist/preview/chunk.6K4JBLOP.js +0 -1
  140. package/dist/preview/chunk.7MQ7UWVW.js +0 -5
  141. package/dist/preview/chunk.CXJXVBGF.js +0 -1
  142. package/dist/preview/chunk.E5PHLNXR.js +0 -1
  143. package/dist/preview/chunk.GNPYSMHA.js +0 -1
  144. package/dist/preview/chunk.IWUSCCZN.js +0 -1
  145. package/dist/preview/chunk.K6SPN4D6.js +0 -7
  146. package/dist/preview/chunk.MXU3VQSQ.js +0 -1
  147. package/dist/preview/chunk.NQTCOBOQ.js +0 -1
  148. package/dist/preview/chunk.O4X5WJIC.js +0 -1
  149. package/dist/preview/chunk.ORKXXLWD.js +0 -1
  150. package/dist/preview/chunk.QJUFVEAU.js +0 -1
  151. package/dist/preview/chunk.RY4E4JRI.js +0 -1
  152. package/dist/preview/chunk.VCOIFBUE.js +0 -1
  153. package/dist/preview/chunk.VP35BUUZ.js +0 -349
  154. package/dist/preview/chunk.YQDIVHCH.js +0 -1
@@ -1 +1 @@
1
- import{a as O,b,c as w,d as R,e as V}from"./chunk.MI2HL3LQ.js";import{h as l,i as S}from"./chunk.TMBFLZNH.js";import{Ha as $,Ia as F}from"./chunk.7MQ7UWVW.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};
@@ -1,3 +1,3 @@
1
- import"./chunk.RPDTWQKA.js";import{a as _,b as ge,c as me,e as fe}from"./chunk.DJ3BD7AZ.js";import"./chunk.7MXQRSNR.js";import"./chunk.HJCQ6I3S.js";import{a as ve,d as ye}from"./chunk.A3WOUDOG.js";import"./chunk.WH2RYGXR.js";import{a as de}from"./chunk.5TBK44MK.js";import{d as he}from"./chunk.27QYTMXP.js";import"./chunk.VCOIFBUE.js";import"./chunk.RQBX7M7Q.js";import"./chunk.BT6FUNQI.js";import"./chunk.MBOOUJOE.js";import"./chunk.64MP7636.js";import"./chunk.RY4E4JRI.js";import"./chunk.Q5XICUDZ.js";import"./chunk.UT6642FC.js";import"./chunk.FKLEIR4Y.js";import"./chunk.WVUJXDXZ.js";import"./chunk.QWY54AVN.js";import"./chunk.T4Q6OLZU.js";import"./chunk.R2B2ZAWI.js";import"./chunk.7XCBIID7.js";import"./chunk.MI2HL3LQ.js";import"./chunk.TMBFLZNH.js";import"./chunk.GZHZLJBF.js";import{o as ue,r as K}from"./chunk.EBTYR5CZ.js";import"./chunk.OJGHDWI6.js";import{a as ce}from"./chunk.OWL5GZ6U.js";import"./chunk.RSYFIL2Z.js";import"./chunk.R7F6UJVG.js";import{c as le}from"./chunk.DYW4D74X.js";import{r as pe}from"./chunk.VP35BUUZ.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.7L6LYXCV.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.7MQ7UWVW.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; }
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};