graview 0.1.49 → 0.1.50

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 (187) hide show
  1. package/dist/preview/chunk.24MUPV4Y.js +1 -0
  2. package/dist/preview/chunk.25VJPUDH.js +1 -0
  3. package/dist/preview/{chunk.PCVU3LY3.js → chunk.2P66HH5Y.js} +1 -1
  4. package/dist/preview/chunk.2VZSC2MB.js +1 -0
  5. package/dist/preview/chunk.3L5USMQD.js +1 -0
  6. package/dist/preview/chunk.3O3H37WD.js +1 -0
  7. package/dist/preview/{chunk.VSWEKNKS.js → chunk.3SY6WWWQ.js} +2 -2
  8. package/dist/preview/{chunk.ZILULTJJ.js → chunk.4BQNG3W3.js} +1 -1
  9. package/dist/preview/chunk.4SHSEIHT.js +1 -0
  10. package/dist/preview/{chunk.Q4KNNJFL.js → chunk.4VJARLJ5.js} +1 -1
  11. package/dist/preview/{chunk.FUMQLGNM.js → chunk.4XOSDCCE.js} +1 -1
  12. package/dist/preview/{chunk.TSHBXCMU.js → chunk.53BGPCM6.js} +1 -1
  13. package/dist/preview/{chunk.AOEXSQDG.js → chunk.5DZR46YG.js} +1 -1
  14. package/dist/preview/{chunk.BH365UJ5.js → chunk.5RNB6IC5.js} +1 -1
  15. package/dist/preview/{chunk.NQ7SRWXA.js → chunk.64TFAR5Z.js} +1 -1
  16. package/dist/preview/chunk.6BMCZPT6.js +1 -0
  17. package/dist/preview/{chunk.NQDGUIUQ.js → chunk.6SHF6IL5.js} +1 -1
  18. package/dist/preview/{chunk.YXOJKGRC.js → chunk.6VA5XFRR.js} +1 -1
  19. package/dist/preview/{chunk.AP22NNIM.js → chunk.73BJYIYS.js} +1 -1
  20. package/dist/preview/chunk.7PJVMADH.js +2 -0
  21. package/dist/preview/{chunk.REANMQ6K.js → chunk.7QW6JYGP.js} +1 -1
  22. package/dist/preview/{chunk.SIVMZNHZ.js → chunk.7VX6TBNY.js} +1 -1
  23. package/dist/preview/{chunk.XMOIMPUC.js → chunk.A53G42QO.js} +1 -1
  24. package/dist/preview/chunk.ATWNWPME.js +1 -0
  25. package/dist/preview/chunk.AVCW7C6V.js +1 -0
  26. package/dist/preview/{chunk.YECMUK4X.js → chunk.AXCRFJDL.js} +1 -1
  27. package/dist/preview/{chunk.EYSQPXVE.js → chunk.AXMC6XVT.js} +1 -1
  28. package/dist/preview/{chunk.FIS27KW4.js → chunk.BBNF52IB.js} +1 -1
  29. package/dist/preview/chunk.BJAQRV2R.js +1 -0
  30. package/dist/preview/chunk.BLS2G3CD.js +5 -0
  31. package/dist/preview/chunk.BNQL37AC.js +88 -0
  32. package/dist/preview/{chunk.OFBESPHJ.js → chunk.BORCUDGS.js} +1 -1
  33. package/dist/preview/{chunk.QQRLUBWQ.js → chunk.CBJHYNNT.js} +1 -1
  34. package/dist/preview/{chunk.7MJGZHTS.js → chunk.CDZVUCEK.js} +1 -1
  35. package/dist/preview/{chunk.35FUGOSG.js → chunk.CR5MQMOL.js} +1 -1
  36. package/dist/preview/{chunk.MJ4XTNTL.js → chunk.DUIKIJKC.js} +1 -1
  37. package/dist/preview/{chunk.BNU3KXKL.js → chunk.DUJUJN35.js} +1 -1
  38. package/dist/preview/chunk.ECSWXLBI.js +9 -0
  39. package/dist/preview/{chunk.7MWLDDFL.js → chunk.EF3UB7US.js} +1 -1
  40. package/dist/preview/chunk.EJUZGIQ5.js +1 -0
  41. package/dist/preview/{chunk.N2S3TMBC.js → chunk.ETWREHXF.js} +1 -1
  42. package/dist/preview/{chunk.6RLFO5GA.js → chunk.ETX4QMM2.js} +1 -1
  43. package/dist/preview/{chunk.C75I24Z5.js → chunk.F5FJHKWV.js} +1 -1
  44. package/dist/preview/{chunk.2N6RQ427.js → chunk.F7AFJRPP.js} +1 -1
  45. package/dist/preview/{chunk.2CO2EJQA.js → chunk.FDFVGHQE.js} +1 -1
  46. package/dist/preview/{chunk.4SEY7VWZ.js → chunk.FFPG4PHX.js} +1 -1
  47. package/dist/preview/{chunk.MU5WUTVF.js → chunk.FKUVIG6D.js} +1 -1
  48. package/dist/preview/chunk.GDYI5QDS.js +1 -0
  49. package/dist/preview/{chunk.QQE7N7LB.js → chunk.GPJFNLEJ.js} +1 -1
  50. package/dist/preview/chunk.GQI53L5P.js +1 -0
  51. package/dist/preview/{chunk.3EW6L5DY.js → chunk.GQX57JIE.js} +1 -1
  52. package/dist/preview/{chunk.D53IGR45.js → chunk.GTUBIJTP.js} +1 -1
  53. package/dist/preview/{chunk.2OXXGN7C.js → chunk.GZEZMU2T.js} +2 -2
  54. package/dist/preview/{chunk.OTF3NNTI.js → chunk.HG34MT7C.js} +1 -1
  55. package/dist/preview/{chunk.N2S45SSL.js → chunk.HGP3Q7QX.js} +1 -1
  56. package/dist/preview/chunk.IATLUWAD.js +1 -0
  57. package/dist/preview/chunk.IDQHSAAQ.js +1 -0
  58. package/dist/preview/{chunk.KJBXNMIU.js → chunk.IMFAPZ6J.js} +2 -2
  59. package/dist/preview/{chunk.QBHVBL42.js → chunk.JC5NXMG3.js} +1 -1
  60. package/dist/preview/chunk.JJP5OL5E.js +1 -0
  61. package/dist/preview/{chunk.BVXOLZQ3.js → chunk.JLPBXG4P.js} +1 -1
  62. package/dist/preview/chunk.JLR74UFP.js +1 -0
  63. package/dist/preview/{chunk.G3Q5CYEM.js → chunk.JYJNRCK5.js} +1 -1
  64. package/dist/preview/chunk.K4ITS63T.js +1 -0
  65. package/dist/preview/{chunk.TABIRLQS.js → chunk.KFHXTHIY.js} +1 -1
  66. package/dist/preview/{chunk.NUUT37ER.js → chunk.KGGWFL54.js} +1 -1
  67. package/dist/preview/{chunk.4Q5KWYVY.js → chunk.KOPRZLJH.js} +2 -2
  68. package/dist/preview/{chunk.LUL6PFIQ.js → chunk.KT2LXHSI.js} +1 -1
  69. package/dist/preview/{chunk.GEY4MA4D.js → chunk.KZ3UPV2L.js} +1 -1
  70. package/dist/preview/{chunk.UL43GFVC.js → chunk.L2AV6JRA.js} +1 -1
  71. package/dist/preview/{chunk.3NEALGMI.js → chunk.L5MDUZLQ.js} +1 -1
  72. package/dist/preview/chunk.LDE5HLTM.js +1 -0
  73. package/dist/preview/{chunk.7SGQ3HFG.js → chunk.LGHMUUTG.js} +1 -1
  74. package/dist/preview/{chunk.AVDXG57A.js → chunk.LJXAZ5TF.js} +1 -1
  75. package/dist/preview/{chunk.4OTESF7W.js → chunk.M55U47A6.js} +1 -1
  76. package/dist/preview/chunk.M5RHVUZ6.js +1 -0
  77. package/dist/preview/chunk.MBZ6N5SO.js +1 -0
  78. package/dist/preview/{chunk.RI624PFK.js → chunk.MCPLU2U4.js} +1 -1
  79. package/dist/preview/chunk.MQISKON2.js +1 -0
  80. package/dist/preview/{chunk.RSR2M7ZO.js → chunk.MRUDTYOL.js} +2 -2
  81. package/dist/preview/chunk.N7FIUTVY.js +1 -0
  82. package/dist/preview/chunk.NPU4WYRB.js +1 -0
  83. package/dist/preview/{chunk.EJAVIZ7Y.js → chunk.O6SKKF4V.js} +1 -1
  84. package/dist/preview/{chunk.D25QV6DK.js → chunk.OB7XLVK6.js} +1 -1
  85. package/dist/preview/{chunk.MUHFZXPS.js → chunk.ODHCSYXX.js} +1 -1
  86. package/dist/preview/chunk.OHAWUOUN.js +1 -0
  87. package/dist/preview/chunk.OKQ4JXTW.js +1 -0
  88. package/dist/preview/{chunk.EM5CGFNB.js → chunk.OUNLAMBA.js} +1 -1
  89. package/dist/preview/chunk.OYQ6ZA6T.js +1 -0
  90. package/dist/preview/{chunk.PBCT33FF.js → chunk.Q7RI4SI4.js} +1 -1
  91. package/dist/preview/chunk.Q7UQ5OXA.js +1 -0
  92. package/dist/preview/{chunk.BJR6E2CT.js → chunk.QAUZDLDA.js} +1 -1
  93. package/dist/preview/{chunk.LD6S2FL5.js → chunk.QFI4L2HK.js} +1 -1
  94. package/dist/preview/{chunk.AGVFW6WC.js → chunk.QSZLY62B.js} +1 -1
  95. package/dist/preview/{chunk.O3ONLQUF.js → chunk.QZMBEG4E.js} +1 -1
  96. package/dist/preview/{chunk.IQHVVQEA.js → chunk.RK6BK5FD.js} +1 -1
  97. package/dist/preview/{chunk.BU6V76EF.js → chunk.ROJZLOKZ.js} +1 -1
  98. package/dist/preview/chunk.RXJBYP7B.js +1 -0
  99. package/dist/preview/chunk.S64LCR23.js +1 -0
  100. package/dist/preview/{chunk.D4IKO5YA.js → chunk.S7OFTGBQ.js} +4 -4
  101. package/dist/preview/chunk.SGMVLKZO.js +25 -0
  102. package/dist/preview/{chunk.ST4JHXPS.js → chunk.SJRXBTGP.js} +1 -1
  103. package/dist/preview/{chunk.BTORFVKO.js → chunk.SRU2YDTJ.js} +1 -1
  104. package/dist/preview/chunk.SVH3OMU2.js +1 -0
  105. package/dist/preview/{chunk.TBA4GF34.js → chunk.SWLDDQJS.js} +1 -1
  106. package/dist/preview/{chunk.ON35FJ5H.js → chunk.T4UYLB3Y.js} +1 -1
  107. package/dist/preview/chunk.THTHNY4N.js +1 -0
  108. package/dist/preview/{chunk.WQN7EFW3.js → chunk.TL7UGUY4.js} +2 -2
  109. package/dist/preview/{chunk.A7HMVWMG.js → chunk.TT6QBWRA.js} +1 -1
  110. package/dist/preview/{chunk.XN7PIWVC.js → chunk.TY6VILZB.js} +1 -1
  111. package/dist/preview/{chunk.KDTNKKOY.js → chunk.U2M4SGUU.js} +1 -1
  112. package/dist/preview/chunk.U6FGWVGB.js +1 -0
  113. package/dist/preview/{chunk.GRLPNTUW.js → chunk.UCS3CBT4.js} +1 -1
  114. package/dist/preview/{chunk.QWX2N2VD.js → chunk.UDTBFAS5.js} +1 -1
  115. package/dist/preview/chunk.UEL7FLL7.js +1 -0
  116. package/dist/preview/{chunk.X4MTZKL3.js → chunk.UGJ32SEL.js} +1 -1
  117. package/dist/preview/{chunk.4D26JY5U.js → chunk.UJTRKSCK.js} +1 -1
  118. package/dist/preview/{chunk.2QKSWK4U.js → chunk.UN2OB6OD.js} +1 -1
  119. package/dist/preview/chunk.UOC3SIYT.js +1 -0
  120. package/dist/preview/{chunk.THENABJU.js → chunk.V5IWJ3ZV.js} +1 -1
  121. package/dist/preview/{chunk.OL5D7YTW.js → chunk.VM43YREJ.js} +1 -1
  122. package/dist/preview/chunk.VVRI7DNK.js +1 -0
  123. package/dist/preview/{chunk.7JLYEZW4.js → chunk.WGRF6EHC.js} +1 -1
  124. package/dist/preview/{chunk.DFGXNFFE.js → chunk.XWLGHTH6.js} +1 -1
  125. package/dist/preview/chunk.YAS6LXQ7.js +1 -0
  126. package/dist/preview/{chunk.B2BLZDBD.js → chunk.YCJ74LZS.js} +1 -1
  127. package/dist/preview/{chunk.RMWLV3PR.js → chunk.YEKHDZ45.js} +2 -2
  128. package/dist/preview/chunk.YEMNR4WU.js +1 -0
  129. package/dist/preview/{chunk.ERWBI2NK.js → chunk.YG3BLY67.js} +1 -1
  130. package/dist/preview/{chunk.CXIIRL67.js → chunk.YUV7HZYG.js} +1 -1
  131. package/dist/preview/{chunk.UTRIPGW6.js → chunk.YYS45ZGQ.js} +1 -1
  132. package/dist/preview/{chunk.7JW5SHRR.js → chunk.YZ6UKKEL.js} +1 -1
  133. package/dist/preview/{chunk.OS75HEZP.js → chunk.ZBBCUK2K.js} +1 -1
  134. package/dist/preview/chunk.ZI66HRES.js +1 -0
  135. package/dist/preview/{chunk.6EHE26ZS.js → chunk.ZITDUHX3.js} +1 -1
  136. package/dist/preview/{chunk.423SZS7C.js → chunk.ZK446PSX.js} +3 -3
  137. package/dist/preview/{chunk.H42WBU5C.js → chunk.ZKDJQDKX.js} +1 -1
  138. package/dist/preview/{chunk.DSNHE4MZ.js → chunk.ZOQ3OKKI.js} +1 -1
  139. package/dist/preview/chunk.ZVETGRUM.js +1 -0
  140. package/dist/preview/{chunk.QPNFWP4Z.js → chunk.ZVOP2HHI.js} +1 -1
  141. package/dist/preview/index.html +51 -51
  142. package/dist/preview/page.js +2 -2
  143. package/package.json +6 -6
  144. package/dist/preview/chunk.2AZTW66C.js +0 -1
  145. package/dist/preview/chunk.2OLZ6BYI.js +0 -1
  146. package/dist/preview/chunk.4K7I7WYF.js +0 -1
  147. package/dist/preview/chunk.4QINLTDZ.js +0 -1
  148. package/dist/preview/chunk.4XKACWLT.js +0 -1
  149. package/dist/preview/chunk.52QB4YW2.js +0 -1
  150. package/dist/preview/chunk.54PZWX23.js +0 -1
  151. package/dist/preview/chunk.5YFO6D7J.js +0 -1
  152. package/dist/preview/chunk.6EGHJCEM.js +0 -1
  153. package/dist/preview/chunk.6WRA3Y7D.js +0 -1
  154. package/dist/preview/chunk.7C4IR4S7.js +0 -1
  155. package/dist/preview/chunk.B445DZOY.js +0 -1
  156. package/dist/preview/chunk.D4K23FUB.js +0 -1
  157. package/dist/preview/chunk.D66RI4QS.js +0 -1
  158. package/dist/preview/chunk.DTRNDSMS.js +0 -1
  159. package/dist/preview/chunk.DV4GSLGX.js +0 -9
  160. package/dist/preview/chunk.E2AJ7U5Z.js +0 -1
  161. package/dist/preview/chunk.EPTUOPPC.js +0 -1
  162. package/dist/preview/chunk.FNK2ZZ5E.js +0 -1
  163. package/dist/preview/chunk.FOYVTN5B.js +0 -1
  164. package/dist/preview/chunk.G25JEYCC.js +0 -1
  165. package/dist/preview/chunk.IVHPJUFM.js +0 -1
  166. package/dist/preview/chunk.IWEPDTVG.js +0 -1
  167. package/dist/preview/chunk.IYLOA3MV.js +0 -1
  168. package/dist/preview/chunk.JBG5UQLM.js +0 -1
  169. package/dist/preview/chunk.KLAEKRCA.js +0 -1
  170. package/dist/preview/chunk.NBJ4C33P.js +0 -1
  171. package/dist/preview/chunk.OKHEZJBX.js +0 -1
  172. package/dist/preview/chunk.P2AC6JRL.js +0 -88
  173. package/dist/preview/chunk.PFEKS3KO.js +0 -5
  174. package/dist/preview/chunk.PFR3FQBR.js +0 -1
  175. package/dist/preview/chunk.R5IRHCLZ.js +0 -1
  176. package/dist/preview/chunk.SGJSJGSR.js +0 -1
  177. package/dist/preview/chunk.SPZVEQC5.js +0 -1
  178. package/dist/preview/chunk.SR2345SW.js +0 -1
  179. package/dist/preview/chunk.TM6JVVGW.js +0 -25
  180. package/dist/preview/chunk.UT6642FC.js +0 -1
  181. package/dist/preview/chunk.VV3PNZPI.js +0 -1
  182. package/dist/preview/chunk.W6CGAPNQ.js +0 -1
  183. package/dist/preview/chunk.XJ7YGW6Y.js +0 -1
  184. package/dist/preview/chunk.XXZFWZ4C.js +0 -1
  185. package/dist/preview/chunk.YSFNPYCD.js +0 -2
  186. package/dist/preview/chunk.ZBL47SFK.js +0 -1
  187. /package/dist/preview/{chunk.4HUB3N7I.js → chunk.KHRS2SKB.js} +0 -0
@@ -0,0 +1 @@
1
+ import{a as ve,b as qe,c as Ie,d as pe,e as R,f as fe,h as Ve}from"./chunk.BJAQRV2R.js";import{h as Le,i as Ue,j as We}from"./chunk.GQX57JIE.js";import{a as se,b as ie,c as H,d as Be,e as J,g as ne,h as Ze}from"./chunk.QFI4L2HK.js";import{c as _e,h as y,i as Ne,j as le}from"./chunk.KFHXTHIY.js";import{A as Re,Aa as Fe,Ha as De,Ia as ee,Ja as ce,Ob as Ke,Pb as de,Qb as Me,Rb as Pe,Sb as Te,b as W,c as L,e as xe,ec as Ge,f as Ee,fc as Ce,g as q,h as O,k as C,l as X,m as _,n as Ae,o as U,p as K,r as $,s as Q,t as x,u as E,v as I,w as P,x as n,y as M,z as Z}from"./chunk.BLS2G3CD.js";var ue=e=>Object.entries(e).map(([s,r])=>[s,Object.keys(ee(r?.edges))]),me=(e,s)=>Me(e,ue(s));function Ye(e){return[...Object.keys(e.acts??{}),...Object.keys(e.kinds).flatMap(s=>Ke(s)),...Pe(ue(e.kinds))]}var V=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function He(e){if(!V(e)||!V(e.kinds))return e;let s;try{let f=Object.fromEntries(Object.entries(e.kinds).map(([z,i])=>[z,V(i)&&V(i.edges)?{edges:i.edges}:{}]));s=Ye({acts:V(e.acts)?e.acts:{},kinds:f})}catch{return e}let r=new Set(s),t=!1,a=f=>{if(typeof f!="string"||r.has(f))return f;let z=Ge(f,s);return z===void 0?f:(t=!0,z)},d=V(e.policy)&&Array.isArray(e.policy.grants)?{...e.policy,grants:e.policy.grants.map(f=>V(f)&&Array.isArray(f.mutations)?{...f,mutations:f.mutations.map(a)}:f)}:void 0,u=V(e.rules)?Object.fromEntries(Object.entries(e.rules).map(([f,z])=>[f,V(z)&&Array.isArray(z.repairs)?{...z,repairs:z.repairs.map(i=>V(i)?{...i,act:a(i.act)}:i)}:z])):void 0;return t?{...e,...d?{policy:d}:{},...u?{rules:u}:{}}:e}function ge(e,s){let r=Ce(e,Ye(s));return r&&r!==e?`did you mean "${r}"?`:void 0}var he="graview-document",be=1,ke=256*1024,te=64*1024,ze=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,ye=/^[a-z][A-Za-z0-9]*$/,zn=new Set(["id","kind"]),yn=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,hn=["string","text","number","integer","boolean","date","datetime","enum","list","url","email","image","video","file","app-link","phone","place","duration"];function bn(){let e=k=>k in Object.prototype,s=Z(k=>!e(k),"every object already has this name \u2014 choose another"),r=(k,N)=>[...k===void 0?[]:[Ee(k)],...N===void 0?[]:[xe(N)]],t=(k,N)=>O().check(...r(k,N)),a=(k,N,gn)=>K(k).check(...r(N,gn)),d=k=>O().check(q(ze,`${k} names are kebab-case, lower-case words joined by hyphens like "tool-note" (field and relation names are camelCase, like "supersededBy")`)),u=O().check(q(yn,'relation names are one camelCase word, like "supersededBy" (kind names are kebab-case, like "tool-note")'),s),f=O().check(q(ye,'field names are one word or camelCase, like "dueDate", so rules say them bare (kind names are kebab-case, like "tool-note")'),Z(k=>!zn.has(k),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),s),z=t(1,500),i=t(1,2e3),o=t(1,300),p=$({type:I(hn),required:n(_()),description:n(z),label:n(t(1,60)),options:n(a(t(1,80),1,100)),of:n(I(["string","number","date","image","video","file"])),default:n(U()),unit:n(t(void 0,12)),format:n(I(["money","percent","duration","markdown"])),min:n(C()),max:n(C()),step:n(C()),renamedFrom:n(O().check(q(ye))),repeats:n(_()),collaborative:n(_())}).check(Re((k,N)=>{k.type==="enum"&&!k.options&&N.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),k.type!=="enum"&&k.options&&N.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),k.type!=="list"&&k.of&&N.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]}),k.repeats&&k.type!=="date"&&k.type!=="datetime"&&N.addIssue({code:"custom",message:'"repeats" belongs only on a date or datetime field',path:["repeats"]})})),w=O().check(q(new RegExp(`${ze.source}|${Fe.source}`),'a relation goes to a kind of this document, like "house", or of another app, like "@nick/house/house"')),m=$({to:x([a(w,1),P("*")]),cardinality:n(I(["one","many"])),description:n(z),inverse:n(t(1,80)),appendOnly:n(_()),renamedFrom:n(O()),tidying:n(P("never"))}),l=x([i,$({expr:i,label:n(t(1,60)),description:n(z)})]),c=$({noun:n(t(1,40)),plural:n(t(1,40)),description:n(z),fields:E(f,p).check(Z(k=>Object.keys(k).length>0,"a kind has at least one field")),label:n(o),describe:n(o),lifecycle:n($({field:f,retired:a(x([O(),C(),_()]),1)})),figure:n(t(void 0,2e4)),glance:n(a(f,1,20)),page:n($({fields:n(a(f,1,40)),groups:n(a($({title:t(1,60),fields:a(f,1,40)}),1,12))})),edges:n(E(u,m)),computed:n(E(O(),l).check(Z(k=>Object.keys(k).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:n(E(O(),O())),renamedFrom:n(O().check(q(ze))),people:n(_()),archives:n(P(!1)),tidying:n(I(["never","no-links"]))}),j=x([O(),C(),_(),Ae(),K(U()),$({expr:i})]),h=O().check(q(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),S=x([$({create:d("kind"),as:n(O().check(q(ye))),set:n(E(f,j))}),$({set:E(f,j),target:n(h)}),$({connect:u,from:h,to:h}),$({sever:u,from:h,to:h}),$({remove:h})]),A=$({title:n(t(1,80)),description:n(z),fromTheOtherEnd:n(t(1,80)),on:n(x([d("kind"),a(d("kind"),1)])),creates:n(d("kind")),sets:n(E(f,j)),writes:n(a(f,1)),connects:n(u),severs:n(u),setsOther:n(E(f,j)),replaces:n(x([P(!0),a(u,1,10)])),removes:n(P(!0)),args:n(E(f,p)),effects:n(a(S,1,20)),allowedWhen:n(i),refusal:n(o),destructive:n(_())}),b=$({act:d("act"),label:n(t(1,80)),args:n(E(O(),j))}),G=$({title:n(t(1,120)),description:n(z),over:x([P("graph"),d("kind")]),when:n(i),require:i,says:n(o),repairs:n(a(b,void 0,10))}),F=$({roles:x([a(d("role"),1),P("*")]),mutations:x([a(d("act"),1),P("*")]),kinds:n(x([K(d("kind")),P("*")])),describe:n(z),self:n(_()),ownEnd:n(_())}),g=n(a(d("field"),1)),v=$({roles:x([a(d("role"),1),P("*")]),kinds:a(d("kind"),1),own:n(_()),via:n(u),fields:g,hide:g}),D=$({grants:K(F),sees:n(K(v))}),oe=$({accent:n(O().check(q(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),name:n(t(1,60)),currency:n(O().check(q(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:n(t(2,35)),timeZone:n(t(1,64)),logo:n(x([t(1,te),$({src:t(1,te),alt:n(t(1,120))}),$({light:t(1,te),dark:n(t(1,te)),alt:n(t(1,120)),darkFallback:n(P("invert"))})])),favicon:n(x([t(1,te),$({emoji:O()})])),typography:n($({display:n(t(1,200)),body:n(t(1,200)),mono:n(t(1,200))})),shape:n($({radius:n(C().check(L(0),W(32))),density:n(C().check(L(.75),W(1.5)))})),accents:n(E(O(),C().check(L(0),W(360)))),scheme:n(I(["light","dark","auto"])),subtitle:n(P(!1))}),B=E(O(),U()),Y=x([t(1,120),$({by:t(1,120),direction:n(I(["asc","desc"]))})]),je=C().check(X(),L(1),W(9999)),dn=Q({create:n(_()),options:n(Q({sort:n(Y),columnSort:n(Y),search:n(a(t(1,120),void 0,40)),filters:n(a(t(1,120),void 0,40)),horizon:n(x([C().check(X(),L(1),W(200)),Q({years:C().check(X(),L(1),W(200)),title:t(1,80),from:n(je),to:n(je)})]))}))}),ln=$({card:n(K(U())),row:n(K(U())),page:n(K(U()))}),pn=()=>{let k=n(I(["asc","desc"]));return x([t(1,120),$({by:t(1,120),direction:k,then:n(x([t(1,120),$({by:t(1,120),direction:k})]))})])},fn=()=>x([t(1,120),$({by:t(1,120),order:n(a(t(1,80),void 0,40)),closed:n(a(t(1,80),void 0,40))})]),Oe=Q({order:n(K(O())),hide:n(K(O())),first:n(O()),primary:n(a(t(1,80),void 0,40)),scene:n(t(1,40)),pages:n(t(1,40)),lists:n(E(O(),$({filters:n(a(t(1,120),void 0,40)),sort:n(pn()),group:n(fn())})))}),un=$({act:d("act"),title:n(t(1,80)),intro:n(z),fields:n(a(f,1,40)),say:n(z),submit:n(t(1,80)),role:n(d("role"))}),mn=$({$schema:n(O()),format:P(he),formatVersion:P(be),name:t(1,80),description:n(z),version:n(C().check(X(),L(1))),kinds:E(d("kind"),c).check(Z(k=>Object.keys(k).length>0,"a document declares at least one kind"),Z(k=>Object.keys(k).length<=40,"a document declares at most 40 kinds")),computed:n(E(O(),l)),acts:n(E(d("act"),A)),rules:n(E(d("rule"),G)),roles:n(K(d("role"))),policy:n(D),modules:n(B),lenses:n(K(dn)),pages:n(Oe),views:n(E(O(),x([ln,K(U())]))),brand:n(oe),settings:n(K(B)),migrations:n(K(B)),connections:n(E(d("connection"),B)),forms:n(E(d("form"),un)),publishing:n($({mode:I(["live","on-publish"]),working:a(d("role"),void 0,40),publishers:n(a(d("role"),1,40))}))});return{FieldSpec:p,EdgeSpec:m,ComputedSpec:l,KindSpec:c,ValueSpec:j,EffectSpec:S,ActSpec:A,RepairSpec:b,RuleSpec:G,GrantSpec:F,SightSpec:v,PolicySpec:D,BrandSpec:oe,PagesSpec:Oe,DocumentSpec:mn}}var kn,T=()=>kn??=bn(),_n=M(()=>T().FieldSpec),Nn=M(()=>T().EdgeSpec),qn=M(()=>T().ComputedSpec),In=M(()=>T().KindSpec),Vn=M(()=>T().ValueSpec),Bn=M(()=>T().EffectSpec),Ln=M(()=>T().ActSpec),Un=M(()=>T().RepairSpec),Wn=M(()=>T().RuleSpec),Zn=M(()=>T().GrantSpec),Yn=M(()=>T().SightSpec),Hn=M(()=>T().PolicySpec),Jn=M(()=>T().BrandSpec),Xn=M(()=>T().PagesSpec),Je=M(()=>T().DocumentSpec);var $n={};function Xe(e,s=$n,r=be){let{document:t,respelled:a}=ve(e),d=a.length>0?{respelled:a}:{};if(!t||typeof t!="object"||Array.isArray(t))return{document:t};let u=t;if(u.format!==he||typeof u.formatVersion!="number"||u.formatVersion>=r)return{document:t,...d};let f=u.formatVersion,z=structuredClone(u);for(let i=f;i<r;i++){let o=s[i];if(!o)throw new Error(`there is no upgrade from format ${i} to ${i+1}`);z={...o(z),formatVersion:i+1}}return{document:z,from:f,...d}}function Qe(e,s,r){let t=Object.keys(e).filter(f=>e[f].edges?.[s]!==void 0);if(t.length===0)return;let a=t.map(f=>e[f].edges[s].to),d=a.some(f=>f==="*")?"*":[...new Set(a.flatMap(f=>f))];if(r.length===0||r.some(f=>t.includes(f)))return{reversed:!1,kinds:d};let u=t.filter(f=>{let z=e[f].edges[s].to;return z==="*"||r.every(i=>z.includes(i))});return u.length>0?{reversed:!0,kinds:u}:{reversed:!1,kinds:d}}var tn=(e,s)=>{let r=e?.fields[s];return r!==void 0&&(r.type==="duration"||(r.type==="number"||r.type==="integer")&&r.format==="duration")};function en(e,s,r,t){if(t==="out"){let a=e[s]?.edges?.[r]?.to;return a===void 0?[]:a==="*"?Object.keys(e):a}return Object.entries(e).filter(([,a])=>{let d=a.edges?.[r]?.to;return d!==void 0&&(d==="*"||d.includes(s))}).map(([a])=>a)}function $e(e,s,r){if(r.t==="ident")return e[s]?.edges?.[r.name]?en(e,s,r.name,"out"):void 0;if(r.t==="where")return $e(e,s,r.set);if(r.t==="call"&&(r.fn==="out"||r.fn==="in")&&r.args[0]?.t==="lit"&&typeof r.args[0].value=="string")return en(e,s,r.args[0].value,r.fn)}var nn=(e,s,r)=>{let t=s.filter(a=>e[a]?.fields[r]!==void 0);return t.length>0&&t.every(a=>tn(e[a],r))};function on(e,s,r){let t=e.kinds,a=t[s],d=new Map(r),u=new Map,f=(i,o)=>{if(o>8)return!1;switch(i.t){case"ident":return tn(a,i.name)||z(i.name,o+1);case"member":{let p=$e(t,s,i.object);return p!==void 0&&nn(t,p,i.name)}case"call":{if(i.fn!=="sum"&&i.fn!=="min"&&i.fn!=="max")return!1;let[p,w]=i.args,m=p&&$e(t,s,p);return m!==void 0&&w?.t==="ident"&&nn(t,m,w.name)}case"binary":return(i.op==="+"||i.op==="-")&&f(i.left,o)&&f(i.right,o);case"unary":return i.op==="-"&&f(i.operand,o);default:return!1}},z=(i,o)=>{if(a?.computed?.[i]===void 0)return!1;if(u.has(i))return u.get(i);u.set(i,!1);let p=d.get(i),w=p!==void 0&&f(p,o);return u.set(i,w),w};return r.map(([i])=>i).filter(i=>z(i,0))}function sn(e,s,r=`kinds.${e}.page`){let t=s.page;if(!t)return[];let a=[],d=[...Object.keys(s.fields),...Object.keys(s.computed??{})],u=new Set,f=(i,o)=>{d.includes(i)?u.has(i)&&a.push(y("page-field-twice",o,`"${i}" is on ${e}'s page twice; name each field once`)):a.push(y("page-field",o,`${e}'s page is to show "${i}", and ${e} has no field or computed field called that`,`use one of: ${d.join(", ")}`)),u.add(i)};(t.fields??[]).forEach((i,o)=>f(i,`${r}.fields.${o}`));let z=new Set;return(t.groups??[]).forEach((i,o)=>{let p=i.title.trim().toLowerCase();z.has(p)&&a.push(y("page-group-twice",`${r}.groups.${o}.title`,`${e}'s page has two groups called "${i.title}"; give each its own title`)),z.add(p),i.fields.forEach((w,m)=>f(w,`${r}.groups.${o}.fields.${m}`))}),a}function rn(e,s=[]){return Te({declared:Object.keys(e.fields),paged:[...e.page?.fields??[],...(e.page?.groups??[]).flatMap(r=>r.fields)],must:r=>!!e.fields[r].required&&e.fields[r].default===void 0,naming:s})}var wn=new Set(["subject","now","today","me"]);function Sn(e){if((typeof e=="string"?e:JSON.stringify(e??null)).length>ke)return{findings:[y("too-large","",`a document may be at most ${ke/1024} KB`)]};if(typeof e=="string")try{e=JSON.parse(e)}catch(t){return{findings:[y("not-json","",`this is not JSON: ${t.message}`)]}}try{e=Xe(e).document}catch(t){return{findings:[y("format","formatVersion",t.message)]}}e=He(e);let s=Je.safeParse(e);if(!s.success)return{findings:s.error.issues.map(t=>{let a=t.path.map(String).join(".");if(t.code==="unrecognized_keys")return y("unknown-key",a,`${t.keys.map(d=>`"${d}"`).join(", ")} ${t.keys.length===1?"is":"are"} not part of a Graview document here`,"check the spelling against docs/declaration-document.md");if(t.code==="invalid_union"&&/\.effects\.\d+$/.test(a))return y("effect-shape",a,"this effect is not one Graview knows",'an effect is one of {"create": kind, "as"?: name, "set"?: {field: value}}, {"set": {field: value, \u2026}, "target"?: "$ref"}, {"connect"|"sever": relation, "from": "$ref", "to": "$ref"}, {"remove": "$ref"}');if(t.code==="invalid_key"){let d=t.issues?.[0]?.message;return y("shape",a,`the name "${String(t.path.at(-1))}" is not allowed here${d?`: ${d}`:""}`)}return y("shape",a,t.message)})};let r=s.data;return{document:r,findings:jn(r)}}var ae=e=>[e??[]].flat();function an(e){let s=new Map;for(let[r,t]of Object.entries(e.kinds))for(let[a,d]of Object.entries(ee(t.edges))){let u=s.get(a);s.set(a,{name:a,from:[...u?.from??[],r],to:d.to==="*"||u?.to==="*"?"*":[...new Set([...u?.to??[],...d.to])],cardinality:d.cardinality??"many"})}return s}function Et(e){let s=new Map;for(let[t,a]of Object.entries(e.kinds)){let d=ne(a),u=ce(a.edges);s.set(t,{fields:new Set([...Object.keys(a.fields),...u.keys()]),edges:new Map(Object.entries(ee(a.edges)).map(([f,z])=>[f,z.cardinality??"many"])),...d?{computed:d}:{},...u.size>0?{linked:u}:{}})}let r=ne(e);return r&&s.set(_e,{computed:r}),s}function cn(e,s){let r=[],t=ae(e.on),a=(d,u)=>{let f=Qe(s.kinds,d,t)?.reversed===!0,[z,i]=f?["$to","$subject"]:["$subject","$to"];return u==="connect"?{connect:d,from:z,to:i}:{sever:d,from:z,to:i}};if(e.creates){let d=s.kinds[e.creates],u={};for(let f of Object.keys(d?.fields??{}))u[f]=`$${f}`;for(let f of e.effects??[])"set"in f&&!("create"in f)&&R(f.target)==="new"&&Object.assign(u,f.set);r.push({create:e.creates,as:"new",set:u})}return e.sets&&r.push({set:e.sets}),e.writes&&!(e.creates&&e.on===void 0)&&r.push({set:Object.fromEntries(e.writes.map(d=>[d,`$${d}`]))}),e.connects&&(e.replaces&&r.push({replace:e.replaces===!0?[e.connects]:[...e.replaces],keep:e.connects}),r.push(a(e.connects,"connect"))),e.severs&&r.push(a(e.severs,"sever")),e.setsOther&&(e.connects||e.severs)&&r.push({set:e.setsOther,target:"$to"}),e.removes&&r.push({remove:"$subject"}),e.effects&&r.push(...e.effects.filter(d=>!(e.creates&&"set"in d&&!("create"in d)&&R(d.target)==="new"))),r}function we(e,s,r){try{let t=H(e),a=se(t);for(let d of a.unknownFunctions)r.push(y("unknown-function",s,`"${d}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));return t}catch(t){if(t instanceof ie){r.push(y("expression",s,t.sentence+` (at character ${t.at+1})`));return}throw t}}function Se(e,s,r){try{return J(e)}catch(t){if(t instanceof Be||t instanceof ie){r.push(y("template",s,(t instanceof ie,t.sentence)));return}throw t}}function jn(e){let s=[],r=new Set(Object.keys(e.kinds)),t=an(e),a=e.acts??{},d=new Set(e.roles??[]),u=(i,o)=>ce(e.kinds[i]?.edges).has(o),f=i=>Object.keys(e.kinds).some(o=>u(o,i));for(let[i,o]of Object.entries(e.kinds)){let p=`kinds.${i}`;for(let[m,l]of Object.entries(o.edges??{})){if(!De(l)&&l.to!=="*")for(let c of l.to)r.has(c)||s.push(y("edge-target",`${p}.edges.${m}.to`,`"${c}" is not a kind this document declares`));o.fields[m]&&s.push(y("edge-field-clash",`${p}.edges.${m}`,`"${m}" is both a field and a relation of ${i}`,"rename one of them"))}o.lifecycle&&!o.fields[o.lifecycle.field]&&s.push(y("lifecycle-field",`${p}.lifecycle.field`,`${i} has no field "${o.lifecycle.field}"`));let w=m=>o.computed!==void 0&&Object.hasOwn(o.computed,m);for(let m of o.glance??[])!o.fields[m]&&!w(m)&&s.push(y("glance-field",`${p}.glance`,`a glance at ${i} is to say "${m}", and ${i} has no field or computed field called that`,`use one of: ${[...Object.keys(o.fields),...Object.keys(o.computed??{})].join(", ")}`));s.push(...sn(i,o));for(let m of["label","describe"]){let l=o[m];if(!l)continue;let c=Se(l,`${p}.${m}`,s);for(let j of c??[])if(j.expr){for(let h of se(j.expr).names)if(!o.fields[h]){if(w(h)){Ze(o,h)||s.push(y("template-field",`${p}.${m}`,`${i}'s ${h} is worked out from beyond the record, and a ${m} is said with no graph to read`,`show it in a view instead, or name a computed field worked out from ${i}'s own fields`));continue}s.push(y("template-field",`${p}.${m}`,`${i} has no field "${h}" for its ${m} to show`,m==="label"?"a label can only show the record's own fields and what they work out":void 0))}}}for(let[m,l]of Object.entries(o.fields)){l.default!==void 0&&l.type==="enum"&&!l.options?.includes(String(l.default))&&s.push(y("default-option",`${p}.fields.${m}.default`,`"${String(l.default)}" is not one of ${m}'s options`));let c=`${m}Repeat`;l.repeats&&(o.fields[c]||o.edges?.[c]||o.computed?.[c])&&s.push(y("repeat-clash",`${p}.fields.${m}.repeats`,`${i} already has "${c}", where how ${m} repeats is kept`))}}for(let[i,o]of Object.entries(a)){let p=`acts.${i}`;for(let c of ae(o.on))r.has(c)||s.push(y("act-kind",`${p}.on`,`"${c}" is not a kind this document declares`));let w=ae(o.on),m=cn(o,e);if(o.creates&&o.on===void 0&&o.writes&&r.has(o.creates)){for(let c of o.writes)if(!e.kinds[o.creates].fields[c])if(e.kinds[o.creates].computed?.[c]!==void 0)s.push(y("computed-written",`${p}.writes`,`${o.creates}'s ${c} is worked out, not written: no act can set it`,"write the stored fields it is worked out from"));else{if(u(o.creates,c))continue;s.push(y("act-field",`${p}.writes`,`${o.creates} has no field "${c}"`))}}m.length===0&&s.push(y("act-empty",p,`"${i}" does nothing`,"give it effects or a shorthand such as sets or creates"));let l=new Map;m.forEach((c,j)=>{let h=m.length-(o.effects?.length??0),S=o.effects&&j>=h?`${p}.effects.${j-h}`:p;if("create"in c){if(!r.has(c.create))s.push(y("act-kind",`${S}.create`,`"${c.create}" is not a kind this document declares`));else for(let b of Object.keys(c.set??{}))e.kinds[c.create].fields[b]||(e.kinds[c.create].computed?.[b]!==void 0?s.push(y("computed-written",`${S}.set.${b}`,`${c.create}'s ${b} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):s.push(y("act-field",`${S}.set.${b}`,`${c.create} has no field "${b}"`)));c.as&&l.set(c.as,c.create)}else if("connect"in c||"sever"in c){let b="connect"in c?c.connect:c.sever;!t.has(b)&&!f(b)&&s.push(y("act-edge",`${S}.${"connect"in c?"connect":"sever"}`,`"${b}" is not a relation any kind declares`)),R(c.from)==="subject"&&w.length===0&&s.push(y("act-subject",`${p}.on`,`"${i}" acts on "$subject" but does not say which kinds it is "on"`))}else if("set"in c){let b=R(c.target??"$subject"),G=b==="subject"?w:l.has(b??"")?[l.get(b)]:[];b==="subject"&&w.length===0&&s.push(y("act-subject",`${p}.on`,`"${i}" changes "$subject" but does not say which kinds it is "on"`));for(let F of Object.keys(c.set))for(let g of G)if(!(!r.has(g)||e.kinds[g].fields[F]))if(e.kinds[g].computed?.[F]!==void 0)s.push(y("computed-written",`${S}.set.${F}`,`${g}'s ${F} is worked out, not written: no act can set it`,"set the stored fields it is worked out from"));else{if(u(g,F))continue;s.push(y("act-field",`${S}.set.${F}`,`${g} has no field "${F}"`))}}else"remove"in c&&R(c.remove)==="subject"&&w.length===0&&s.push(y("act-subject",`${p}.on`,`"${i}" removes "$subject" but does not say which kinds it is "on"`));("set"in c&&c.set?Object.values(c.set):[]).forEach(b=>{b&&typeof b=="object"&&!Array.isArray(b)&&"expr"in b&&we(b.expr,`${S}.set`,s)})}),o.allowedWhen&&we(o.allowedWhen,`${p}.allowedWhen`,s),o.refusal&&Se(o.refusal,`${p}.refusal`,s)}for(let[i,o]of Object.entries(e.rules??{})){let p=`rules.${i}`;o.over!=="graph"&&!r.has(o.over)&&s.push(y("rule-kind",`${p}.over`,`"${o.over}" is not a kind this document declares`));let w=o.over==="graph"?void 0:e.kinds[o.over];for(let m of["when","require"]){let l=o[m];if(!l)continue;let c=we(l,`${p}.${m}`,s);if(!c)continue;let j=se(c);for(let h of j.names)if(o.over==="graph")s.push(y("rule-name",`${p}.${m}`,`"${h}" means nothing in a rule over the whole graph`,`name a kind in "over", or use all('kind')`));else if(w&&!w.fields[h]&&!w.edges?.[h]&&w.computed?.[h]===void 0){let S=Object.keys(w.edges??{}).find(A=>A.includes("-")&&A.split("-").includes(h));s.push(y("rule-name",`${p}.${m}`,`${o.over} has no field or relation called "${h}"`,S?`"${S}" reads as a subtraction in a rule; rename the relation to one camelCase word, like "${S.replace(/-([a-z0-9])/g,(A,b)=>b.toUpperCase())}"`:void 0))}for(let h of j.edges)!t.has(h)&&!f(h)&&s.push(y("rule-edge",`${p}.${m}`,`"${h}" is not a relation any kind declares`));for(let h of j.sweeps)r.has(h)?o.over!=="graph"&&s.push(Ne("rule-cost",`${p}.${m}`,`this rule looks at every ${h} for every ${o.over}, which grows slowly as the app grows`,"walk a relation with out()/in() instead of all() where you can")):s.push(y("rule-kind",`${p}.${m}`,`"${h}" is not a kind this document declares`))}o.says&&Se(o.says,`${p}.says`,s),(o.repairs??[]).forEach((m,l)=>{!a[m.act]&&!de(m.act)&&!me(m.act,e.kinds)&&s.push(y("repair-act",`${p}.repairs.${l}.act`,`"${m.act}" is not an act this document declares`,ge(m.act,e)))})}let z=e.policy;return z&&(z.grants.forEach((i,o)=>{if(i.roles!=="*"&&d.size>0)for(let p of i.roles)d.has(p)||s.push(y("grant-role",`policy.grants.${o}.roles`,`"${p}" is not one of the document's roles`));if(i.mutations!=="*")for(let p of i.mutations)!a[p]&&!de(p)&&!me(p,e.kinds)&&s.push(y("grant-act",`policy.grants.${o}.mutations`,`"${p}" is not an act this document declares`,ge(p,e)))}),(z.sees??[]).forEach((i,o)=>{for(let p of i.kinds)r.has(p)||s.push(y("sight-kind",`policy.sees.${o}.kinds`,`"${p}" is not a kind this document declares`));if(i.roles!=="*"&&d.size>0)for(let p of i.roles)d.has(p)||s.push(y("sight-role",`policy.sees.${o}.roles`,`"${p}" is not one of the document's roles`))})),s.push(...We(e)),s}function On(e){return e.label?[...e.label.matchAll(/\{\s*([A-Za-z_][A-Za-z0-9_]*)/g)].map(s=>s[1]):[fe(e)??[]].flat()}function vn(e,s,r,t){let a=new Map,d=ae(e.on),u=new Map,f=new Map;(d.length>0||s.some(l=>"remove"in l&&R(l.remove)==="subject"||"from"in l&&(R(l.from)==="subject"||R(l.to)==="subject")||"set"in l&&!("create"in l)&&R(l.target??"$subject")==="subject"))&&a.set(pe,{ref:d.length>0?d:"*",required:!0});let i=e.args??{},o=e.writes?.length===1,p=(l,c)=>c&&l.type===c.type&&l.min===void 0&&l.max===void 0&&l.step===void 0?{...l,...c.min===void 0?{}:{min:c.min},...c.max===void 0?{}:{max:c.max},...c.step===void 0?{}:{step:c.step}}:l,w=(l,c)=>c&&l.type===c.type&&l.format===void 0&&l.unit===void 0?{...p(l,c),...c.format?{format:c.format}:{},...c.unit?{unit:c.unit}:{}}:p(l,c),m=(l,c,j)=>{if(l===pe||wn.has(l)||u.has(l)||a.has(l))return;let h=i[l]?w(i[l],j):void 0;a.set(l,h?{field:h,optional:!h.required,required:!!h.required}:c())};for(let l of s)if("create"in l){let c=r.kinds[l.create],j=c?rn(c,On(c)):[],h=S=>j.includes(S)?j.indexOf(S):j.length;for(let[S,A]of Object.entries(l.set??{}).sort(([b],[G])=>h(b)-h(G))){let b=R(A),G=c?.fields[S];if(b&&G){let F=!!G.required&&G.default===void 0;m(b,()=>({field:G,optional:!F,required:F}),G)}}l.as&&u.set(l.as,l.create)}else if("connect"in l||"sever"in l){let c=t.get("connect"in l?l.connect:l.sever);for(let[j,h]of[["from",l.from],["to",l.to]]){let S=R(h);if(!S)continue;let A=j==="to"?c?.to??"*":c?.from??"*";A!=="*"&&!f.has(S)&&f.set(S,A),m(S,()=>({ref:A,required:!0}))}}else if("set"in l){let c=R(l.target??"$subject"),j=c==="subject"?d[0]:u.get(c??"")??f.get(c??"")?.[0];c&&c!=="subject"&&!u.has(c)&&m(c,()=>({ref:"*",required:!0}));for(let[h,S]of Object.entries(l.set)){let A=R(S);if(!A)continue;let b=j?r.kinds[j]?.fields[h]:void 0;m(A,()=>b?{field:b,optional:!o,required:o}:{any:!0,required:!1},b)}}else if("remove"in l){let c=R(l.remove);c&&m(c,()=>({ref:"*",required:!0}))}for(let[l,c]of Object.entries(i))a.has(l)||a.set(l,{field:c,optional:!c.required,required:!!c.required});return a}function At(e,s={}){let r=Sn(e);if(!r.document||le(r.findings))return{ok:!1,findings:r.findings};let t=r.document,a=[...r.findings];s.previous&&a.push(...En(t,s.previous));let d=xn(t,a);return le(d.findings)?{ok:!1,findings:d.findings}:Ve(d,s)}function re(e,s){return e.map(r=>{let t=!r.format&&r.expr?.t==="ident"?s?.[r.expr.name]?.format:void 0;return t==="money"||t==="percent"?{...r,format:t}:r})}function xn(e,s){let r=an(e),t={};for(let[i,o]of Object.entries(e.kinds)){let p=fe(o),w=o.label??(p?`{${p}}`:void 0),m=ne(o),l=m?on(e,i,[...m]):[];t[i]={...w?{label:re(J(w),o.fields)}:{},...o.describe?{describe:re(J(o.describe),o.fields)}:{},...m?{computed:[...m]}:{},...l.length>0?{durations:l}:{}}}let a={};for(let[i,o]of Object.entries(e.acts??{})){let p=cn(o,e),w=vn(o,p,e,r),m=o.destructive??p.some(g=>"remove"in g||"sever"in g||"replace"in g),l=[...new Set(p.flatMap(g=>"create"in g?[g.create]:[]))],c=[...new Set(p.flatMap(g=>"connect"in g?[g.connect]:[]))],j=[...new Set(p.flatMap(g=>"sever"in g?[g.sever]:"replace"in g?g.replace:[]))],h=[...new Set(p.flatMap(g=>"set"in g&&!("create"in g)&&R(g.target??"$subject")==="subject"?Object.keys(g.set):[]))],S=new Map;for(let g of p){if(!("connect"in g)&&!("sever"in g))continue;let v=r.get("connect"in g?g.connect:g.sever);for(let[D,oe]of[["from",g.from],["to",g.to]]){let B=R(oe),Y=D==="to"?v?.to:v?.from;B&&B!=="subject"&&Y&&Y!=="*"&&S.set(B,[...new Set([...S.get(B)??[],...Y])])}}let A={};for(let g of p){if(!("set"in g)||"create"in g)continue;let v=R(g.target??"$subject");for(let D of v&&v!=="subject"&&S.get(v)||[])A[D]=[...new Set([...A[D]??[],...Object.keys(g.set)])]}let b={};for(let g of p)if(!(!("set"in g)||"create"in g||R(g.target??"$subject")!=="subject"))for(let[v,D]of Object.entries(g.set??{}))typeof D=="string"&&R(D)===void 0||typeof D=="number"||typeof D=="boolean"?b[v]=typeof D=="string"&&D.startsWith("$$")?D.slice(1):D:delete b[v];let G=l.length===0&&p.every(g=>!("set"in g)||!g.set||Object.values(g.set).every(v=>!(v&&typeof v=="object"&&!Array.isArray(v)&&"expr"in v))),F=new Map;for(let g of p)if(!(!("set"in g)||!g.set))for(let v of Object.values(g.set))v&&typeof v=="object"&&!Array.isArray(v)&&"expr"in v&&F.set(v.expr,H(v.expr));a[i]={title:o.title??i.replace(/-/g," "),effects:p,args:[...w],...o.allowedWhen?{guard:H(o.allowedWhen)}:{},...o.refusal?{refusal:re(J(o.refusal),e.kinds[[o.on??[]].flat()[0]??""]?.fields)}:{},exprs:[...F],destructive:m,idempotent:G,creates:l,connects:c,severs:j,writes:h,writesOther:A,sets:b}}let d={};for(let[i,o]of Object.entries(e.rules??{}))d[i]={title:o.title??i.replace(/-/g," "),require:H(o.require),...o.when?{when:H(o.when)}:{},...o.says?{says:re(J(o.says),e.kinds[o.over]?.fields)}:{}};let u=qe(e,s),f=Le(e),z=Ue(e);return{format:Ie,document:e,findings:s,kinds:t,...e.computed?{facts:[...ne(e)??[]]}:{},edges:[...r].map(([i,{from:o,to:p,cardinality:w}])=>[i,{from:o,to:p,cardinality:w}]),acts:a,rules:d,brand:u,...Object.keys(f).length>0?{viewSpecs:f}:{},...z?{home:z}:{}}}function Rt(e,s,r){let t=/^defineNode\("([^"]+)"\)/.exec(s)?.[1],a=t?r.kinds[t]:void 0;if(!t||!a)return e;let d=Object.keys(a.fields).filter(u=>u!=="label").slice(0,3);return{...e,path:`kinds.${t}.glance`,fix:`Say which: "glance": [${d.map(u=>`"${u}"`).join(", ")}] on kinds.${t} \u2014 the facts a person compares one by, at a glance.`}}function En(e,s){let r=[],t=new Set(Object.values(s.kinds).flatMap(a=>Object.keys(a.edges??{})));for(let[a,d]of Object.entries(e.kinds)){let u=d.renamedFrom;u&&!s.kinds[u]&&r.push(y("renamed-from-nothing",`kinds.${a}.renamedFrom`,`${a} says it was ${u}, and the previous version has no kind called ${u}`,"name the kind it was, or drop renamedFrom"));let f=s.kinds[u??a];for(let[z,i]of Object.entries(d.fields)){let o=i.renamedFrom;o&&!f?.fields[o]&&r.push(y("renamed-from-nothing",`kinds.${a}.fields.${z}.renamedFrom`,`${z} says it was ${o}, and the previous ${u??a} has no field called ${o}`,"name the field it was, or drop renamedFrom"))}for(let[z,i]of Object.entries(d.edges??{})){let o=i.renamedFrom;o&&!t.has(o)&&r.push(y("renamed-from-nothing",`kinds.${a}.edges.${z}.renamedFrom`,`${z} says it was ${o}, and the previous version has no relation called ${o}`,"name the relation it was, or drop renamedFrom"))}}return r}export{Sn as a,Et as b,cn as c,At as d,Rt as e};
@@ -0,0 +1 @@
1
+ import{G as h}from"./chunk.SGMVLKZO.js";import{ad as u,mc as a,yc as m}from"./chunk.BLS2G3CD.js";import{b as l}from"./chunk.AJZBJBMO.js";function f(e){let t=[e?.typography?.body,e?.typography?.display,e?.typography?.mono],o=[];for(let i of t){let n=i?.split(",")[0]?.trim().replace(/^["']|["']$/g,"");!n||m(n)||n.toLowerCase()!==a.toLowerCase()&&(o.includes(n)||o.push(n))}return o}function g(e){let t=f(e);return t.length===0?null:`https://fonts.googleapis.com/css2?${t.map(i=>`family=${encodeURIComponent(i).replace(/%20/g,"+")}:wght@400;500;600;700`).join("&")}&display=swap`}var r=l(h(),1);function k(e,t){return new u({schema:e.schema,mutations:e.mutations??[],invariants:e.invariants??[],...t?{snapshot:t}:{},...e.policy?{policy:e.policy}:{},...e.publishing?{publishing:e.publishing}:{},...e.intelligence?{intelligence:e.intelligence}:{},...e.brand?.timeZone?{timeZone:e.brand.timeZone}:{}})}function d(e){if(typeof document>"u")return e==="dark"?"dark":"light";let t=document.documentElement.dataset.theme;return t==="dark"||t==="light"?t:e==="dark"||e==="light"?e:typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function v(e,t){let[o,i]=(0,r.useState)(()=>d(t));return(0,r.useEffect)(()=>{if(!e||typeof document>"u")return;let n=()=>i(d(t));n();let s=new MutationObserver(n);s.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});let c=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null;return c?.addEventListener?.("change",n),()=>{s.disconnect(),c?.removeEventListener?.("change",n)}},[e,t]),o}export{g as a,k as b,v as c};